mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) New Grist Forms styling and field options
Summary: - New styling for forms. - New field options for various field types (spinner, checkbox, radio buttons, alignment, sort). - Improved alignment of form fields in columns. - Support for additional select input keyboard shortcuts (Enter and Backspace). - Prevent submitting form on Enter if an input has focus. - Fix for changing form field type causing the field to disappear. Test Plan: Browser tests. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D4223
This commit is contained in:
@@ -175,6 +175,21 @@ export async function firstDefined<T>(...list: Array<() => Promise<T>>): Promise
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number repesentation of `value`, or `defaultVal` if it cannot
|
||||
* be represented as a valid number.
|
||||
*/
|
||||
export function numberOrDefault<T>(value: unknown, defaultVal: T): number | T {
|
||||
if (typeof value === 'number') {
|
||||
return !Number.isNaN(value) ? value : defaultVal;
|
||||
} else if (typeof value === 'string') {
|
||||
const maybeNumber = Number.parseFloat(value);
|
||||
return !Number.isNaN(maybeNumber) ? maybeNumber : defaultVal;
|
||||
} else {
|
||||
return defaultVal;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses json and returns the result, or returns defaultVal if parsing fails.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user