@homebound/beam 2.227.0 → 2.227.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Css.d.ts +9 -9
- package/dist/components/Accordion.d.ts +1 -1
- package/dist/components/Accordion.js +4 -4
- package/dist/components/AccordionList.js +1 -1
- package/dist/components/AutoSaveIndicator.js +5 -5
- package/dist/components/Avatar.d.ts +1 -1
- package/dist/components/Avatar.js +2 -2
- package/dist/components/AvatarButton.js +1 -1
- package/dist/components/BeamContext.js +1 -1
- package/dist/components/Button.d.ts +2 -2
- package/dist/components/Button.js +1 -1
- package/dist/components/ButtonDatePicker.js +2 -2
- package/dist/components/ButtonGroup.d.ts +2 -2
- package/dist/components/ButtonGroup.js +6 -6
- package/dist/components/ButtonMenu.d.ts +5 -5
- package/dist/components/ButtonMenu.js +1 -1
- package/dist/components/ButtonModal.js +1 -1
- package/dist/components/Chip.d.ts +1 -1
- package/dist/components/Chip.js +2 -2
- package/dist/components/Chips.d.ts +1 -1
- package/dist/components/Chips.js +3 -3
- package/dist/components/Copy.js +2 -2
- package/dist/components/CssReset.js +1 -1
- package/dist/components/Filters/BooleanFilter.d.ts +1 -1
- package/dist/components/Filters/BooleanFilter.js +2 -2
- package/dist/components/Filters/DateFilter.d.ts +2 -2
- package/dist/components/Filters/DateFilter.js +2 -2
- package/dist/components/Filters/DateRangeFilter.d.ts +2 -2
- package/dist/components/Filters/DateRangeFilter.js +2 -2
- package/dist/components/Filters/FilterModal.js +4 -4
- package/dist/components/Filters/Filters.d.ts +2 -2
- package/dist/components/Filters/Filters.js +8 -8
- package/dist/components/Filters/MultiFilter.d.ts +1 -1
- package/dist/components/Filters/MultiFilter.js +4 -4
- package/dist/components/Filters/NumberRangeFilter.d.ts +2 -2
- package/dist/components/Filters/NumberRangeFilter.js +5 -5
- package/dist/components/Filters/SingleFilter.d.ts +1 -1
- package/dist/components/Filters/SingleFilter.js +1 -1
- package/dist/components/Filters/ToggleFilter.d.ts +1 -1
- package/dist/components/Filters/ToggleFilter.js +2 -2
- package/dist/components/Filters/index.js +5 -1
- package/dist/components/Filters/testDomain.d.ts +9 -9
- package/dist/components/Filters/types.d.ts +2 -2
- package/dist/components/HbLoadingSpinner.js +9 -5
- package/dist/components/HelperText.js +1 -1
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/Icon.js +97 -97
- package/dist/components/IconButton.js +1 -1
- package/dist/components/Label.js +3 -3
- package/dist/components/Layout/PreventBrowserScroll.js +1 -1
- package/dist/components/Layout/RightPaneLayout/RightPaneContext.d.ts +1 -1
- package/dist/components/Layout/RightPaneLayout/RightPaneContext.js +6 -2
- package/dist/components/Layout/RightPaneLayout/RightPaneLayout.js +3 -3
- package/dist/components/Layout/RightPaneLayout/index.js +5 -1
- package/dist/components/Layout/ScrollableContent.js +3 -3
- package/dist/components/Layout/ScrollableParent.js +2 -2
- package/dist/components/Layout/index.js +5 -1
- package/dist/components/Loader.js +1 -1
- package/dist/components/LoadingSkeleton.d.ts +2 -2
- package/dist/components/LoadingSkeleton.js +1 -1
- package/dist/components/Modal/Modal.d.ts +3 -3
- package/dist/components/Modal/Modal.js +5 -5
- package/dist/components/Modal/OpenModal.js +2 -2
- package/dist/components/Modal/TestModalContent.js +3 -3
- package/dist/components/Modal/index.js +5 -1
- package/dist/components/NavLink.d.ts +1 -1
- package/dist/components/NavLink.js +2 -2
- package/dist/components/PresentationContext.d.ts +2 -2
- package/dist/components/PresentationContext.js +1 -1
- package/dist/components/Snackbar/Snackbar.d.ts +1 -1
- package/dist/components/Snackbar/Snackbar.js +1 -1
- package/dist/components/Snackbar/SnackbarContext.d.ts +1 -1
- package/dist/components/Snackbar/SnackbarContext.js +1 -1
- package/dist/components/Snackbar/SnackbarNotice.d.ts +1 -1
- package/dist/components/Snackbar/SnackbarNotice.js +1 -1
- package/dist/components/Stepper.js +11 -11
- package/dist/components/SuperDrawer/ConfirmCloseModal.js +2 -2
- package/dist/components/SuperDrawer/SuperDrawer.js +3 -3
- package/dist/components/SuperDrawer/SuperDrawerContent.js +3 -3
- package/dist/components/SuperDrawer/components/SuperDrawerHeader.js +2 -2
- package/dist/components/SuperDrawer/index.js +5 -1
- package/dist/components/SuperDrawer/useSuperDrawer.d.ts +1 -1
- package/dist/components/SuperDrawer/useSuperDrawer.js +2 -2
- package/dist/components/Table/GridTable.d.ts +1 -1
- package/dist/components/Table/GridTable.js +33 -29
- package/dist/components/Table/GridTableApi.d.ts +1 -1
- package/dist/components/Table/TableActions.d.ts +1 -1
- package/dist/components/Table/TableActions.js +1 -1
- package/dist/components/Table/TableStyles.d.ts +1 -1
- package/dist/components/Table/components/CollapseToggle.js +1 -1
- package/dist/components/Table/components/EditColumnsButton.js +2 -2
- package/dist/components/Table/components/ExpandableHeader.js +2 -2
- package/dist/components/Table/components/Row.d.ts +2 -2
- package/dist/components/Table/components/Row.js +7 -3
- package/dist/components/Table/components/SelectToggle.js +1 -1
- package/dist/components/Table/components/SortHeader.js +3 -3
- package/dist/components/Table/components/cell.d.ts +2 -2
- package/dist/components/Table/components/cell.js +6 -6
- package/dist/components/Table/index.js +5 -1
- package/dist/components/Table/types.d.ts +13 -13
- package/dist/components/Table/utils/TableState.d.ts +4 -4
- package/dist/components/Table/utils/columns.js +2 -2
- package/dist/components/Table/utils/simpleHelpers.d.ts +1 -1
- package/dist/components/Table/utils/utils.js +5 -5
- package/dist/components/Tabs.d.ts +1 -1
- package/dist/components/Tabs.js +7 -7
- package/dist/components/Tag.d.ts +2 -2
- package/dist/components/Tag.js +1 -1
- package/dist/components/Toast/Toast.d.ts +1 -1
- package/dist/components/Toast/Toast.js +1 -1
- package/dist/components/Toast/ToastContext.d.ts +1 -1
- package/dist/components/Toast/ToastContext.js +1 -1
- package/dist/components/ToggleChip.d.ts +1 -1
- package/dist/components/ToggleChip.js +2 -2
- package/dist/components/ToggleChips.d.ts +1 -1
- package/dist/components/ToggleChips.js +1 -1
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip.js +9 -5
- package/dist/components/index.js +5 -1
- package/dist/components/internal/CompoundField.js +6 -6
- package/dist/components/internal/ContextualModal.js +1 -1
- package/dist/components/internal/DatePicker/DatePicker.js +2 -2
- package/dist/components/internal/DatePicker/DatePickerOverlay.js +1 -1
- package/dist/components/internal/DatePicker/DateRangePicker.js +2 -2
- package/dist/components/internal/DatePicker/Day.js +6 -6
- package/dist/components/internal/DatePicker/Header.js +2 -2
- package/dist/components/internal/DatePicker/WeekHeader.js +1 -1
- package/dist/components/internal/DatePicker/index.js +5 -1
- package/dist/components/internal/Menu.js +3 -3
- package/dist/components/internal/MenuItem.js +6 -6
- package/dist/components/internal/MenuSection.js +1 -1
- package/dist/components/internal/OverlayTrigger.js +1 -1
- package/dist/components/internal/Popover.js +1 -1
- package/dist/components/internal/index.js +5 -1
- package/dist/components/testData.d.ts +1 -1
- package/dist/components/testData.js +5 -5
- package/dist/forms/BoundCheckboxField.d.ts +1 -1
- package/dist/forms/BoundCheckboxField.js +3 -3
- package/dist/forms/BoundCheckboxGroupField.d.ts +1 -1
- package/dist/forms/BoundCheckboxGroupField.js +2 -2
- package/dist/forms/BoundChipSelectField.js +3 -3
- package/dist/forms/BoundDateField.d.ts +1 -1
- package/dist/forms/BoundDateField.js +2 -2
- package/dist/forms/BoundDateRangeField.d.ts +1 -1
- package/dist/forms/BoundDateRangeField.js +2 -2
- package/dist/forms/BoundMultiSelectField.d.ts +1 -1
- package/dist/forms/BoundMultiSelectField.js +3 -3
- package/dist/forms/BoundNumberField.d.ts +1 -1
- package/dist/forms/BoundNumberField.js +2 -2
- package/dist/forms/BoundRadioGroupField.d.ts +1 -1
- package/dist/forms/BoundRadioGroupField.js +2 -2
- package/dist/forms/BoundRichTextField.d.ts +1 -1
- package/dist/forms/BoundRichTextField.js +2 -2
- package/dist/forms/BoundSelectAndTextField.d.ts +2 -2
- package/dist/forms/BoundSelectAndTextField.js +1 -1
- package/dist/forms/BoundSelectField.d.ts +1 -1
- package/dist/forms/BoundSelectField.js +3 -3
- package/dist/forms/BoundSwitchField.d.ts +1 -1
- package/dist/forms/BoundSwitchField.js +3 -3
- package/dist/forms/BoundTextAreaField.d.ts +1 -1
- package/dist/forms/BoundTextAreaField.js +2 -2
- package/dist/forms/BoundTextField.d.ts +1 -1
- package/dist/forms/BoundTextField.js +2 -2
- package/dist/forms/BoundToggleChipGroupField.d.ts +1 -1
- package/dist/forms/BoundToggleChipGroupField.js +1 -1
- package/dist/forms/FormHeading.js +2 -2
- package/dist/forms/FormLines.d.ts +1 -1
- package/dist/forms/FormLines.js +5 -5
- package/dist/forms/FormStateApp.js +5 -5
- package/dist/forms/StaticField.js +1 -1
- package/dist/forms/StepperFormApp.js +10 -10
- package/dist/forms/index.js +5 -1
- package/dist/hooks/index.js +5 -1
- package/dist/hooks/useBreakpoint.d.ts +1 -1
- package/dist/hooks/useQueryState.d.ts +1 -1
- package/dist/hooks/useSessionStorage.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/inputs/Checkbox.js +1 -1
- package/dist/inputs/CheckboxBase.js +6 -6
- package/dist/inputs/CheckboxGroup.js +2 -2
- package/dist/inputs/ChipSelectField.d.ts +2 -2
- package/dist/inputs/ChipSelectField.js +14 -14
- package/dist/inputs/ChipTextField.js +3 -3
- package/dist/inputs/DateFields/DateField.js +1 -1
- package/dist/inputs/DateFields/DateField.mock.js +2 -2
- package/dist/inputs/DateFields/DateFieldBase.js +7 -7
- package/dist/inputs/DateFields/DateRangeField.js +1 -1
- package/dist/inputs/DateFields/index.js +5 -1
- package/dist/inputs/DateFields/utils.d.ts +2 -2
- package/dist/inputs/ErrorMessage.js +2 -2
- package/dist/inputs/MultiSelectField.js +2 -2
- package/dist/inputs/MultiSelectField.mock.js +4 -4
- package/dist/inputs/NumberField.d.ts +1 -1
- package/dist/inputs/NumberField.js +4 -4
- package/dist/inputs/RadioGroupField.js +3 -3
- package/dist/inputs/RichTextField.js +3 -3
- package/dist/inputs/RichTextField.mock.js +2 -2
- package/dist/inputs/SelectField.js +2 -2
- package/dist/inputs/SelectField.mock.js +4 -4
- package/dist/inputs/Switch.js +5 -5
- package/dist/inputs/SwitchGroup.d.ts +1 -1
- package/dist/inputs/SwitchGroup.js +1 -1
- package/dist/inputs/TextAreaField.js +1 -1
- package/dist/inputs/TextField.d.ts +1 -1
- package/dist/inputs/TextField.js +1 -1
- package/dist/inputs/TextFieldBase.js +10 -10
- package/dist/inputs/ToggleButton.js +1 -1
- package/dist/inputs/ToggleChipGroup.d.ts +1 -1
- package/dist/inputs/ToggleChipGroup.js +3 -3
- package/dist/inputs/Value.d.ts +1 -1
- package/dist/inputs/index.js +5 -1
- package/dist/inputs/internal/ListBox.js +3 -3
- package/dist/inputs/internal/ListBoxChip.js +1 -1
- package/dist/inputs/internal/ListBoxSection.js +1 -1
- package/dist/inputs/internal/ListBoxToggleChip.js +2 -2
- package/dist/inputs/internal/LoadingDots.js +2 -2
- package/dist/inputs/internal/MenuSearchField.js +1 -1
- package/dist/inputs/internal/Option.js +3 -3
- package/dist/inputs/internal/SelectFieldBase.d.ts +1 -1
- package/dist/inputs/internal/SelectFieldBase.js +2 -2
- package/dist/inputs/internal/SelectFieldInput.js +4 -4
- package/dist/inputs/internal/VirtualizedOptions.js +2 -2
- package/dist/interfaces.d.ts +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/utils/getInteractiveElement.js +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +5 -1
- package/dist/utils/rtl.js +1 -1
- package/dist/utils/sb.d.ts +2 -2
- package/dist/utils/sb.js +4 -4
- package/dist/utils/useTestIds.d.ts +1 -1
- package/package.json +4 -4
|
@@ -11,7 +11,7 @@ const defaultLabel_1 = require("../utils/defaultLabel");
|
|
|
11
11
|
function BoundCheckboxGroupField(props) {
|
|
12
12
|
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onBlur, onFocus, ...others } = props;
|
|
13
13
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
14
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.CheckboxGroup,
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.CheckboxGroup, { label: label, values: field.value || [], onChange: (values) => {
|
|
15
15
|
onChange(values);
|
|
16
16
|
field.maybeAutoSave();
|
|
17
17
|
}, errorMsg: field.touched ? field.errors.join(" ") : undefined, onBlur: () => {
|
|
@@ -20,6 +20,6 @@ function BoundCheckboxGroupField(props) {
|
|
|
20
20
|
}, onFocus: () => {
|
|
21
21
|
field.focus();
|
|
22
22
|
(0, utils_1.maybeCall)(onFocus);
|
|
23
|
-
}
|
|
23
|
+
}, ...testId, ...others })) }));
|
|
24
24
|
}
|
|
25
25
|
exports.BoundCheckboxGroupField = BoundCheckboxGroupField;
|
|
@@ -13,7 +13,7 @@ function BoundChipSelectField(props) {
|
|
|
13
13
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
14
14
|
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => {
|
|
15
15
|
var _a;
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(ChipSelectField_1.ChipSelectField,
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(ChipSelectField_1.ChipSelectField, { label: label, value: (_a = field.value) !== null && _a !== void 0 ? _a : undefined, onSelect: (value) => {
|
|
17
17
|
onSelect(value);
|
|
18
18
|
field.maybeAutoSave();
|
|
19
19
|
}, getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, onBlur: () => {
|
|
@@ -27,7 +27,7 @@ function BoundChipSelectField(props) {
|
|
|
27
27
|
await onCreateNew(v);
|
|
28
28
|
field.maybeAutoSave();
|
|
29
29
|
}
|
|
30
|
-
: undefined
|
|
31
|
-
} }
|
|
30
|
+
: undefined, ...others, ...testId }));
|
|
31
|
+
} }));
|
|
32
32
|
}
|
|
33
33
|
exports.BoundChipSelectField = BoundChipSelectField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { DateFieldProps } from "../inputs";
|
|
3
|
-
export
|
|
3
|
+
export type BoundDateFieldProps = Omit<DateFieldProps, "label" | "value" | "onChange"> & {
|
|
4
4
|
field: FieldState<any, Date | null | undefined>;
|
|
5
5
|
label?: string;
|
|
6
6
|
onChange?: (value: Date | undefined) => void;
|
|
@@ -10,7 +10,7 @@ const defaultLabel_1 = require("../utils/defaultLabel");
|
|
|
10
10
|
function BoundDateField(props) {
|
|
11
11
|
const { field, readOnly, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onBlur, onFocus, onEnter, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.DateField,
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.DateField, { label: label, value: field.value || undefined, onChange: (value) => {
|
|
14
14
|
onChange(value);
|
|
15
15
|
field.maybeAutoSave();
|
|
16
16
|
}, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, onBlur: () => {
|
|
@@ -22,6 +22,6 @@ function BoundDateField(props) {
|
|
|
22
22
|
}, onEnter: () => {
|
|
23
23
|
(0, utils_1.maybeCall)(onEnter);
|
|
24
24
|
field.maybeAutoSave();
|
|
25
|
-
}
|
|
25
|
+
}, ...testId, ...others })) }));
|
|
26
26
|
}
|
|
27
27
|
exports.BoundDateField = BoundDateField;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { DateRangeFieldProps } from "../inputs";
|
|
3
3
|
import { DateRange } from "../types";
|
|
4
|
-
export
|
|
4
|
+
export type BoundDateRangeFieldProps = Omit<DateRangeFieldProps, "label" | "value" | "onChange"> & {
|
|
5
5
|
field: FieldState<any, DateRange | null | undefined>;
|
|
6
6
|
label?: string;
|
|
7
7
|
onChange?: (value: DateRange | undefined) => void;
|
|
@@ -10,7 +10,7 @@ const defaultLabel_1 = require("../utils/defaultLabel");
|
|
|
10
10
|
function BoundDateRangeField(props) {
|
|
11
11
|
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onBlur, onFocus, onEnter, readOnly, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.DateRangeField,
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.DateRangeField, { label: label, value: field.value || undefined, onChange: (value) => {
|
|
14
14
|
onChange(value);
|
|
15
15
|
field.maybeAutoSave();
|
|
16
16
|
}, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, onBlur: () => {
|
|
@@ -22,6 +22,6 @@ function BoundDateRangeField(props) {
|
|
|
22
22
|
}, onEnter: () => {
|
|
23
23
|
(0, utils_1.maybeCall)(onEnter);
|
|
24
24
|
field.maybeAutoSave();
|
|
25
|
-
}, readOnly: readOnly || field.readOnly
|
|
25
|
+
}, readOnly: readOnly || field.readOnly, ...testId, ...others })) }));
|
|
26
26
|
}
|
|
27
27
|
exports.BoundDateRangeField = BoundDateRangeField;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { MultiSelectFieldProps, Value } from "../inputs";
|
|
3
3
|
import { HasIdAndName, Optional } from "../types";
|
|
4
|
-
export
|
|
4
|
+
export type BoundMultiSelectFieldProps<O, V extends Value> = Omit<MultiSelectFieldProps<O, V>, "values" | "onSelect" | "label"> & {
|
|
5
5
|
onSelect?: (values: V[], opts: O[]) => void;
|
|
6
6
|
field: FieldState<any, V[] | null | undefined>;
|
|
7
7
|
label?: string;
|
|
@@ -14,7 +14,7 @@ function BoundMultiSelectField(props) {
|
|
|
14
14
|
const testId = (0, useTestIds_1.useTestIds)(props, field.key);
|
|
15
15
|
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => {
|
|
16
16
|
var _a;
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(inputs_1.MultiSelectField,
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(inputs_1.MultiSelectField, { label: label, values: (_a = field.value) !== null && _a !== void 0 ? _a : [], onSelect: (values, options) => {
|
|
18
18
|
onSelect(values, options);
|
|
19
19
|
field.maybeAutoSave();
|
|
20
20
|
}, options: options, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, onBlur: () => {
|
|
@@ -23,7 +23,7 @@ function BoundMultiSelectField(props) {
|
|
|
23
23
|
}, onFocus: () => {
|
|
24
24
|
field.focus();
|
|
25
25
|
(0, utils_1.maybeCall)(onFocus);
|
|
26
|
-
}
|
|
27
|
-
} }
|
|
26
|
+
}, ...others, ...testId }));
|
|
27
|
+
} }));
|
|
28
28
|
}
|
|
29
29
|
exports.BoundMultiSelectField = BoundMultiSelectField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { NumberFieldProps } from "../inputs/NumberField";
|
|
3
|
-
export
|
|
3
|
+
export type BoundNumberFieldProps = Omit<NumberFieldProps, "value" | "onChange" | "label"> & {
|
|
4
4
|
label?: string;
|
|
5
5
|
field: FieldState<any, number | null | undefined>;
|
|
6
6
|
onChange?: (value: number | undefined) => void;
|
|
@@ -10,7 +10,7 @@ const defaultLabel_1 = require("../utils/defaultLabel");
|
|
|
10
10
|
function BoundNumberField(props) {
|
|
11
11
|
const { field, readOnly, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key.replace(/InCents$/, "")), type = field.key.endsWith("InCents") ? "cents" : undefined, onFocus, onBlur, onEnter, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, label || field.key);
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(NumberField_1.NumberField,
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(NumberField_1.NumberField, { label: label, value: typeof field.value === "number" ? field.value : undefined, onChange: onChange, type: type, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, onFocus: () => {
|
|
14
14
|
field.focus();
|
|
15
15
|
(0, utils_1.maybeCall)(onFocus);
|
|
16
16
|
}, onBlur: () => {
|
|
@@ -19,6 +19,6 @@ function BoundNumberField(props) {
|
|
|
19
19
|
}, onEnter: () => {
|
|
20
20
|
(0, utils_1.maybeCall)(onEnter);
|
|
21
21
|
field.maybeAutoSave();
|
|
22
|
-
}
|
|
22
|
+
}, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
24
|
exports.BoundNumberField = BoundNumberField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { RadioGroupFieldProps } from "../inputs";
|
|
3
|
-
export
|
|
3
|
+
export type BoundRadioGroupFieldProps<K extends string> = Omit<RadioGroupFieldProps<K>, "value" | "onChange" | "label"> & {
|
|
4
4
|
field: FieldState<any, K | null | undefined>;
|
|
5
5
|
/** Make optional so that callers can override if they want to. */
|
|
6
6
|
onChange?: (value: K) => void;
|
|
@@ -10,7 +10,7 @@ const defaultLabel_1 = require("../utils/defaultLabel");
|
|
|
10
10
|
function BoundRadioGroupField(props) {
|
|
11
11
|
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onBlur, onFocus, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.RadioGroupField,
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.RadioGroupField, { label: label, value: field.value || undefined, onChange: (value) => {
|
|
14
14
|
onChange(value);
|
|
15
15
|
field.maybeAutoSave();
|
|
16
16
|
}, errorMsg: field.touched ? field.errors.join(" ") : undefined, onBlur: () => {
|
|
@@ -19,6 +19,6 @@ function BoundRadioGroupField(props) {
|
|
|
19
19
|
}, onFocus: () => {
|
|
20
20
|
field.focus();
|
|
21
21
|
(0, utils_1.maybeCall)(onFocus);
|
|
22
|
-
}
|
|
22
|
+
}, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
24
|
exports.BoundRadioGroupField = BoundRadioGroupField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { RichTextFieldProps } from "../inputs/RichTextField";
|
|
3
|
-
export
|
|
3
|
+
export type BoundRichTextFieldProps = Omit<RichTextFieldProps, "value" | "onChange"> & {
|
|
4
4
|
field: FieldState<any, string | null | undefined>;
|
|
5
5
|
onChange?: (value: string | undefined) => void;
|
|
6
6
|
};
|
|
@@ -10,7 +10,7 @@ const defaultLabel_1 = require("../utils/defaultLabel");
|
|
|
10
10
|
function BoundRichTextField(props) {
|
|
11
11
|
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), readOnly, onFocus, onBlur, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(RichTextField_1.RichTextField,
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(RichTextField_1.RichTextField, { label: label, value: field.value || undefined, onChange: onChange,
|
|
14
14
|
// TODO: Potentially support this in the future?
|
|
15
15
|
// errorMsg={field.touched ? field.errors.join(" ") : undefined}
|
|
16
16
|
onBlur: () => {
|
|
@@ -19,6 +19,6 @@ function BoundRichTextField(props) {
|
|
|
19
19
|
}, onFocus: () => {
|
|
20
20
|
field.focus();
|
|
21
21
|
(0, utils_1.maybeCall)(onFocus);
|
|
22
|
-
}, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly
|
|
22
|
+
}, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
24
|
exports.BoundRichTextField = BoundRichTextField;
|
|
@@ -12,6 +12,6 @@ export declare function BoundSelectAndTextField<O, V extends Value, X extends On
|
|
|
12
12
|
export declare function BoundSelectAndTextField<O extends HasIdAndName<V>, V extends Value, X extends Only<TextFieldXss, X>>(props: Omit<BoundSelectAndTextFieldProps<O, V, X>, "selectFieldProps"> & {
|
|
13
13
|
selectFieldProps: Optional<CompoundSelectFieldProps<O, V>, "getOptionValue" | "getOptionLabel">;
|
|
14
14
|
}): JSX.Element;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
type CompoundSelectFieldProps<O, V extends Value> = Omit<BoundSelectFieldProps<O, V>, "compact">;
|
|
16
|
+
type CompoundTextFieldProps<X> = Omit<BoundTextFieldProps<X>, "compact">;
|
|
17
17
|
export {};
|
|
@@ -10,6 +10,6 @@ function BoundSelectAndTextField(props) {
|
|
|
10
10
|
var _a, _b;
|
|
11
11
|
const { selectFieldProps, textFieldProps, compact = true } = props;
|
|
12
12
|
const tid = (0, utils_1.useTestIds)(props);
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)(CompoundField_1.CompoundField, { children: [(0, jsx_runtime_1.jsx)(index_1.BoundSelectField,
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)(CompoundField_1.CompoundField, { children: [(0, jsx_runtime_1.jsx)(index_1.BoundSelectField, { ...tid[(0, defaultTestId_1.defaultTestId)((_a = selectFieldProps.label) !== null && _a !== void 0 ? _a : selectFieldProps.field.key)], ...selectFieldProps, sizeToContent: true, compact: compact }), (0, jsx_runtime_1.jsx)(index_1.BoundTextField, { ...tid[(0, defaultTestId_1.defaultTestId)((_b = textFieldProps.label) !== null && _b !== void 0 ? _b : textFieldProps.field.key)], ...textFieldProps, compact: compact })] }));
|
|
14
14
|
}
|
|
15
15
|
exports.BoundSelectAndTextField = BoundSelectAndTextField;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { SelectFieldProps, Value } from "../inputs";
|
|
3
3
|
import { HasIdAndName, Optional } from "../types";
|
|
4
|
-
export
|
|
4
|
+
export type BoundSelectFieldProps<O, V extends Value> = Omit<SelectFieldProps<O, V>, "value" | "onSelect" | "label"> & {
|
|
5
5
|
onSelect?: (value: V | undefined, opt: O | undefined) => void;
|
|
6
6
|
field: FieldState<any, V | null | undefined>;
|
|
7
7
|
label?: string;
|
|
@@ -14,7 +14,7 @@ function BoundSelectField(props) {
|
|
|
14
14
|
const testId = (0, useTestIds_1.useTestIds)(props, field.key);
|
|
15
15
|
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => {
|
|
16
16
|
var _a;
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(inputs_1.SelectField,
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(inputs_1.SelectField, { label: label, value: (_a = field.value) !== null && _a !== void 0 ? _a : undefined, onSelect: (value, opt) => {
|
|
18
18
|
onSelect(value, opt);
|
|
19
19
|
field.maybeAutoSave();
|
|
20
20
|
}, options: options, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, onBlur: () => {
|
|
@@ -23,7 +23,7 @@ function BoundSelectField(props) {
|
|
|
23
23
|
}, onFocus: () => {
|
|
24
24
|
field.focus();
|
|
25
25
|
(0, utils_1.maybeCall)(onFocus);
|
|
26
|
-
}
|
|
27
|
-
} }
|
|
26
|
+
}, ...others, ...testId }));
|
|
27
|
+
} }));
|
|
28
28
|
}
|
|
29
29
|
exports.BoundSelectField = BoundSelectField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { SwitchProps } from "../inputs";
|
|
3
|
-
export
|
|
3
|
+
export type BoundSwitchFieldProps = Omit<SwitchProps, "selected" | "onChange" | "label"> & {
|
|
4
4
|
field: FieldState<any, boolean | null | undefined>;
|
|
5
5
|
/** Make optional so that callers can override if they want to. */
|
|
6
6
|
onChange?: (value: boolean) => void;
|
|
@@ -12,10 +12,10 @@ function BoundSwitchField(props) {
|
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
13
|
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => {
|
|
14
14
|
var _a;
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(inputs_1.Switch,
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(inputs_1.Switch, { label: label, labelStyle: labelStyle, selected: (_a = field.value) !== null && _a !== void 0 ? _a : false, onChange: (selected) => {
|
|
16
16
|
onChange(selected);
|
|
17
17
|
field.maybeAutoSave();
|
|
18
|
-
}, disabled: disabled || field.readOnly
|
|
19
|
-
} }
|
|
18
|
+
}, disabled: disabled || field.readOnly, ...testId, ...others }));
|
|
19
|
+
} }));
|
|
20
20
|
}
|
|
21
21
|
exports.BoundSwitchField = BoundSwitchField;
|
|
@@ -2,7 +2,7 @@ import { FieldState } from "@homebound/form-state";
|
|
|
2
2
|
import { Only } from "../Css";
|
|
3
3
|
import { TextAreaFieldProps } from "../inputs";
|
|
4
4
|
import { TextFieldXss } from "../interfaces";
|
|
5
|
-
export
|
|
5
|
+
export type BoundTextAreaFieldProps<X> = Omit<TextAreaFieldProps<X>, "value" | "onChange" | "label"> & {
|
|
6
6
|
label?: string;
|
|
7
7
|
field: FieldState<any, string | null | undefined>;
|
|
8
8
|
onChange?: (value: string | undefined) => void;
|
|
@@ -10,7 +10,7 @@ const defaultLabel_1 = require("../utils/defaultLabel");
|
|
|
10
10
|
function BoundTextAreaField(props) {
|
|
11
11
|
const { field, readOnly, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onFocus, onBlur, onEnter, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.TextAreaField,
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.TextAreaField, { label: label, value: field.value || undefined, onChange: onChange, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, onBlur: () => {
|
|
14
14
|
field.blur();
|
|
15
15
|
(0, utils_1.maybeCall)(onBlur);
|
|
16
16
|
}, onFocus: () => {
|
|
@@ -19,6 +19,6 @@ function BoundTextAreaField(props) {
|
|
|
19
19
|
}, onEnter: () => {
|
|
20
20
|
(0, utils_1.maybeCall)(onEnter);
|
|
21
21
|
field.maybeAutoSave();
|
|
22
|
-
}
|
|
22
|
+
}, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
24
|
exports.BoundTextAreaField = BoundTextAreaField;
|
|
@@ -2,7 +2,7 @@ import { FieldState } from "@homebound/form-state";
|
|
|
2
2
|
import { Only } from "../Css";
|
|
3
3
|
import { TextFieldProps } from "../inputs";
|
|
4
4
|
import { TextFieldXss } from "../interfaces";
|
|
5
|
-
export
|
|
5
|
+
export type BoundTextFieldProps<X> = Omit<TextFieldProps<X>, "value" | "onChange" | "label"> & {
|
|
6
6
|
label?: string;
|
|
7
7
|
field: FieldState<any, string | null | undefined>;
|
|
8
8
|
onChange?: (value: string | undefined) => void;
|
|
@@ -10,7 +10,7 @@ const defaultLabel_1 = require("../utils/defaultLabel");
|
|
|
10
10
|
function BoundTextField(props) {
|
|
11
11
|
const { field, readOnly, onBlur, onFocus, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onEnter, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.TextField,
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.TextField, { label: label, value: field.value || undefined, onChange: onChange, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, onBlur: () => {
|
|
14
14
|
(0, utils_1.maybeCall)(onBlur);
|
|
15
15
|
field.blur();
|
|
16
16
|
}, onFocus: () => {
|
|
@@ -19,6 +19,6 @@ function BoundTextField(props) {
|
|
|
19
19
|
}, onEnter: () => {
|
|
20
20
|
(0, utils_1.maybeCall)(onEnter);
|
|
21
21
|
field.maybeAutoSave();
|
|
22
|
-
}
|
|
22
|
+
}, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
24
|
exports.BoundTextField = BoundTextField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { ToggleChipGroupProps } from "../inputs";
|
|
3
|
-
export
|
|
3
|
+
export type BoundToggleChipGroupFieldProps = Omit<ToggleChipGroupProps, "values" | "onChange" | "label"> & {
|
|
4
4
|
field: FieldState<any, string[] | null | undefined>;
|
|
5
5
|
/** Make optional so that callers can override if they want to. */
|
|
6
6
|
onChange?: (values: string[]) => void;
|
|
@@ -10,6 +10,6 @@ const defaultLabel_1 = require("../utils/defaultLabel");
|
|
|
10
10
|
function BoundToggleChipGroupField(props) {
|
|
11
11
|
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => (0, jsx_runtime_1.jsx)(inputs_1.ToggleChipGroup,
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => (0, jsx_runtime_1.jsx)(inputs_1.ToggleChipGroup, { label: label, values: field.value || [], onChange: onChange, ...testId, ...others }) }));
|
|
14
14
|
}
|
|
15
15
|
exports.BoundToggleChipGroupField = BoundToggleChipGroupField;
|
|
@@ -5,12 +5,12 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
|
5
5
|
const Css_1 = require("../Css");
|
|
6
6
|
function FormHeading(props) {
|
|
7
7
|
const { title, xss, isFirst = false, ...others } = props;
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)("h3",
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)("h3", { css: {
|
|
9
9
|
...Css_1.Css.baseMd.$,
|
|
10
10
|
// Add space before the heading, but only if it's not first.
|
|
11
11
|
...(!isFirst && Css_1.Css.mt4.$),
|
|
12
12
|
...xss,
|
|
13
|
-
}
|
|
13
|
+
}, ...others, children: title }));
|
|
14
14
|
}
|
|
15
15
|
exports.FormHeading = FormHeading;
|
|
16
16
|
// https://github.com/gaearon/react-hot-loader/issues/304#issuecomment-456569720
|
package/dist/forms/FormLines.js
CHANGED
|
@@ -19,12 +19,12 @@ function FormLines(props) {
|
|
|
19
19
|
...("labelSuffix" in props ? { labelSuffix } : {}),
|
|
20
20
|
...("compact" in props ? { compact } : {}),
|
|
21
21
|
};
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider,
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, { fieldProps: newFieldProps, children: (0, jsx_runtime_1.jsx)("div", { css: {
|
|
23
23
|
// Note that we're purposefully not using display:flex so that our children's margins will collapse.
|
|
24
24
|
...Css_1.Css.w(sizes[width]).$,
|
|
25
25
|
// Purposefully use this instead of childGap3 to put margin-bottom on the last line
|
|
26
26
|
"& > *": Css_1.Css.mb2.$,
|
|
27
|
-
}
|
|
27
|
+
}, children: react_1.Children.map(children, (child) => {
|
|
28
28
|
if (child && typeof child === "object" && "type" in child && child.type.isFormHeading) {
|
|
29
29
|
const clone = (0, react_1.cloneElement)(child, { isFirst: firstFormHeading });
|
|
30
30
|
firstFormHeading = false;
|
|
@@ -33,12 +33,12 @@ function FormLines(props) {
|
|
|
33
33
|
else {
|
|
34
34
|
return child;
|
|
35
35
|
}
|
|
36
|
-
}) })
|
|
36
|
+
}) }) }));
|
|
37
37
|
}
|
|
38
38
|
exports.FormLines = FormLines;
|
|
39
39
|
/** Draws a line between form lines. */
|
|
40
40
|
function FormDivider() {
|
|
41
|
-
return (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.hPx(1).my2.bgGray200.$ }
|
|
41
|
+
return (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.hPx(1).my2.bgGray200.$ });
|
|
42
42
|
}
|
|
43
43
|
exports.FormDivider = FormDivider;
|
|
44
44
|
/** Groups multiple fields side-by-side. */
|
|
@@ -51,7 +51,7 @@ function FieldGroup(props) {
|
|
|
51
51
|
return typeof width === `number` ? `${width}fr` : width;
|
|
52
52
|
})
|
|
53
53
|
.join(" ");
|
|
54
|
-
return (0, jsx_runtime_1.jsx)("div",
|
|
54
|
+
return (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.dg.gap2.gtc(gtc).$, children: children });
|
|
55
55
|
}
|
|
56
56
|
exports.FieldGroup = FieldGroup;
|
|
57
57
|
const sizes = {
|
|
@@ -56,23 +56,23 @@ function FormStateApp() {
|
|
|
56
56
|
{ value: "a:4", label: "Iguana" },
|
|
57
57
|
{ value: "a:5", label: "Turtle" },
|
|
58
58
|
];
|
|
59
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsxs)("div",
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.$, children: [(0, jsx_runtime_1.jsxs)("header", { css: Css_1.Css.wPx(700).$, children: [(0, jsx_runtime_1.jsxs)(FormLines_1.FormLines, { labelSuffix: { required: "*", optional: "(Opt)" }, children: [(0, jsx_runtime_1.jsx)("b", { children: "Author" }), (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { field: formState.firstName }), (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { field: formState.middleInitial }), (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { field: formState.lastName }), (0, jsx_runtime_1.jsx)(forms_1.BoundDateField, { field: formState.birthday }), (0, jsx_runtime_1.jsxs)(forms_1.FieldGroup, { children: [(0, jsx_runtime_1.jsx)(forms_1.StaticField, { label: "Revenue", value: "$500" }), (0, jsx_runtime_1.jsx)(forms_1.StaticField, { label: "Website", children: (0, jsx_runtime_1.jsx)("a", { href: "https://google.com", children: "google.com" }) })] }), (0, jsx_runtime_1.jsx)(forms_1.BoundNumberField, { field: formState.heightInInches }), (0, jsx_runtime_1.jsx)(forms_1.FormDivider, {}), (0, jsx_runtime_1.jsx)(forms_1.BoundSelectField, { field: formState.favoriteSport, options: sports }), (0, jsx_runtime_1.jsx)(forms_1.BoundMultiSelectField, { field: formState.favoriteShapes, options: shapes }), (0, jsx_runtime_1.jsx)(BoundCheckboxGroupField_1.BoundCheckboxGroupField, { field: formState.favoriteColors, options: colors }), (0, jsx_runtime_1.jsx)(forms_1.BoundToggleChipGroupField, { field: formState.animals, options: animals }), (0, jsx_runtime_1.jsx)(forms_1.FormDivider, {}), (0, jsx_runtime_1.jsx)(forms_1.BoundSwitchField, { field: formState.isAvailable })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("strong", { children: ["Books", (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "plus", onClick: () => formState.books.add({ id: String(formState.books.value.length) }) })] }), (0, jsx_runtime_1.jsx)(components_1.GridTable, { columns: columns, rows: rows })] }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.gap1.$, children: [(0, jsx_runtime_1.jsx)(components_1.Button, { onClick: () => formState.revertChanges(), label: "Cancel" }), (0, jsx_runtime_1.jsx)(components_1.Button, { onClick: () => {
|
|
60
60
|
if (formState.canSave()) {
|
|
61
61
|
formState.commitChanges();
|
|
62
62
|
}
|
|
63
|
-
}, label: "Save" }
|
|
63
|
+
}, label: "Save" })] })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(components_1.Button, { label: "Read Only", onClick: () => setReadOnly(!readOnly) }) }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.mt1.$, children: [(0, jsx_runtime_1.jsx)("strong", { children: "Form Values:" }), (0, jsx_runtime_1.jsx)("pre", { children: JSON.stringify(formState.value, null, 2) })] })] })] })) }));
|
|
64
64
|
}
|
|
65
65
|
exports.FormStateApp = FormStateApp;
|
|
66
66
|
function createColumns(formState) {
|
|
67
67
|
return [
|
|
68
|
-
{ header: "#", data: ({ id }) => (0, jsx_runtime_1.jsx)("span", { children: id.value }
|
|
68
|
+
{ header: "#", data: ({ id }) => (0, jsx_runtime_1.jsx)("span", { children: id.value }) },
|
|
69
69
|
{
|
|
70
70
|
header: "Title",
|
|
71
|
-
data: ({ title }) => (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { label: "Book Title", hideLabel: true, compact: true, field: title }
|
|
71
|
+
data: ({ title }) => (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { label: "Book Title", hideLabel: true, compact: true, field: title }),
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
header: "Actions",
|
|
75
|
-
data: (row) => (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "x", onClick: () => formState.books.remove(row.value) }
|
|
75
|
+
data: (row) => (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "x", onClick: () => formState.books.remove(row.value) }),
|
|
76
76
|
},
|
|
77
77
|
];
|
|
78
78
|
}
|
|
@@ -10,6 +10,6 @@ function StaticField(props) {
|
|
|
10
10
|
const { label, value, children } = props;
|
|
11
11
|
const tid = (0, useTestIds_1.useTestIds)(props, typeof label === "string" ? (0, defaultTestId_1.defaultTestId)(label) : "staticField");
|
|
12
12
|
const id = (0, utils_1.useId)();
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label",
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", { css: Css_1.Css.db.sm.gray700.mbPx(4).$, htmlFor: id, ...tid.label, children: label }), (0, jsx_runtime_1.jsx)("div", { id: id, css: Css_1.Css.smMd.gray900.df.aic.$, ...tid, children: value || children })] }));
|
|
14
14
|
}
|
|
15
15
|
exports.StaticField = StaticField;
|
|
@@ -23,7 +23,7 @@ function StepperFormApp() {
|
|
|
23
23
|
});
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
|
-
return (0, jsx_runtime_1.jsx)(StepperForm, { formState: formState }
|
|
26
|
+
return (0, jsx_runtime_1.jsx)(StepperForm, { formState: formState });
|
|
27
27
|
}
|
|
28
28
|
exports.StepperFormApp = StepperFormApp;
|
|
29
29
|
function StepperForm({ formState }) {
|
|
@@ -64,26 +64,26 @@ function StepperForm({ formState }) {
|
|
|
64
64
|
// Return the disposer in order to clean up useEffect.
|
|
65
65
|
return disposer;
|
|
66
66
|
}, [setStep, formState.birthday.valid, formState.books.valid, formState.firstName.valid, formState.lastName.valid]);
|
|
67
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(Stepper_1.Stepper, { steps: steps, currentStep: currentStep, onChange: setActiveStep }
|
|
67
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(Stepper_1.Stepper, { steps: steps, currentStep: currentStep, onChange: setActiveStep }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.mt2.$, children: [currentStep === "author" && (0, jsx_runtime_1.jsx)(AuthorDetails, { formState: formState, onNext: onNext }), currentStep === "books" && (0, jsx_runtime_1.jsx)(BookList, { formState: formState, onNext: onNext, onBack: onBack }), currentStep === "misc" && (0, jsx_runtime_1.jsx)(MiscAuthorDetails, { formState: formState, onBack: onBack })] })] }));
|
|
68
68
|
}
|
|
69
69
|
function AuthorDetails({ formState, onNext }) {
|
|
70
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1",
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { css: Css_1.Css.mb1.$, children: "Author Details" }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.mb2.$, children: (0, jsx_runtime_1.jsx)(BoundTextField_1.BoundTextField, { field: formState.firstName, helperText: "Required to enable next step" }) }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.mb2.$, children: (0, jsx_runtime_1.jsx)(BoundTextField_1.BoundTextField, { field: formState.lastName, helperText: "Required to enable next step" }) }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.jcfe.bt.bGray300.py1.mt2.$, children: (0, jsx_runtime_1.jsx)(components_1.Button, { label: "Continue to Books", disabled: !formState.firstName.valid || !formState.lastName.valid, onClick: onNext }) })] })) }));
|
|
71
71
|
}
|
|
72
72
|
function BookList({ formState, onNext, onBack }) {
|
|
73
73
|
const columns = (0, react_1.useMemo)(() => createColumns(formState), [formState]);
|
|
74
74
|
const rows = (0, hooks_1.useComputed)(() => [components_1.simpleHeader, ...formState.books.rows.map((data) => ({ kind: "data", id: data.id.value, data }))], []);
|
|
75
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h1",
|
|
75
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h1", { css: Css_1.Css.df.aic.$, children: ["Books", (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "plus", onClick: () => { var _a; return formState.books.add({ id: String(((_a = formState.books.value) === null || _a === void 0 ? void 0 : _a.length) || 1) }); } })] }), (0, jsx_runtime_1.jsx)(components_1.GridTable, { columns: columns, rows: rows }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.jcsb.bt.bGray300.py1.mt2.$, children: [(0, jsx_runtime_1.jsx)(components_1.Button, { variant: "tertiary", label: "Back", onClick: onBack }), (0, jsx_runtime_1.jsx)(components_1.Button, { label: "Continue to Misc.", disabled: !formState.books.valid, onClick: onNext })] })] }));
|
|
76
76
|
}
|
|
77
77
|
function createColumns(formState) {
|
|
78
78
|
return [
|
|
79
|
-
{ header: "#", data: ({ id }) => (0, jsx_runtime_1.jsx)("span", { children: id.value }
|
|
79
|
+
{ header: "#", data: ({ id }) => (0, jsx_runtime_1.jsx)("span", { children: id.value }) },
|
|
80
80
|
{
|
|
81
81
|
header: "Title",
|
|
82
|
-
data: ({ title }) => (0, jsx_runtime_1.jsx)(BoundTextField_1.BoundTextField, { label: "", compact: true, field: title }
|
|
82
|
+
data: ({ title }) => (0, jsx_runtime_1.jsx)(BoundTextField_1.BoundTextField, { label: "", compact: true, field: title }),
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
header: "Actions",
|
|
86
|
-
data: (row) => (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "x", onClick: () => formState.books.remove(row.value) }
|
|
86
|
+
data: (row) => (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "x", onClick: () => formState.books.remove(row.value) }),
|
|
87
87
|
},
|
|
88
88
|
];
|
|
89
89
|
}
|
|
@@ -91,13 +91,13 @@ function MiscAuthorDetails({ formState, onBack }) {
|
|
|
91
91
|
const [showFormData, setShowFormData] = (0, react_1.useState)(false);
|
|
92
92
|
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => {
|
|
93
93
|
var _a, _b;
|
|
94
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1",
|
|
94
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { css: Css_1.Css.mb1.$, children: "Author Details" }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.mb2.$, children: (0, jsx_runtime_1.jsx)(BoundDateField_1.BoundDateField, { field: formState.birthday, helperText: "Required" }) }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.mb2.$, children: (0, jsx_runtime_1.jsx)(BoundNumberField_1.BoundNumberField, { field: formState.heightInInches }) }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.jcsb.bt.bGray300.py1.mt2.$, children: [(0, jsx_runtime_1.jsx)(components_1.Button, { variant: "tertiary", label: "Back", onClick: onBack }), (0, jsx_runtime_1.jsx)(components_1.Button, { disabled: !formState.valid, onClick: () => {
|
|
95
95
|
if (formState.canSave()) {
|
|
96
96
|
formState.commitChanges();
|
|
97
97
|
setShowFormData(true);
|
|
98
98
|
}
|
|
99
|
-
}, label: "Save" }
|
|
100
|
-
} }
|
|
99
|
+
}, label: "Save" })] }), showFormData && ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.mt5.$, children: [(0, jsx_runtime_1.jsx)("h2", { children: "Form saved!" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "First Name" }), " ", formState.value.firstName] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Last Name" }), " ", formState.value.lastName] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Books" }), " ", (_a = formState.value.books) === null || _a === void 0 ? void 0 : _a.map((b) => b.title).join(", ")] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Birthday" }), " ", (_b = formState.value.birthday) === null || _b === void 0 ? void 0 : _b.toDateString()] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Height" }), " ", formState.value.heightInInches] })] })] }))] }));
|
|
100
|
+
} }));
|
|
101
101
|
}
|
|
102
102
|
// Configure the fields/behavior for AuthorInput's fields
|
|
103
103
|
const formConfig = {
|
package/dist/forms/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|