@homebound/beam 2.369.3 → 2.369.5
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.js +7 -7
- package/dist/components/Accordion.js +1 -2
- package/dist/components/AccordionList.js +1 -2
- package/dist/components/AutoSaveIndicator.js +1 -2
- package/dist/components/AutoSaveStatus/AutoSaveStatusProvider.js +3 -3
- package/dist/components/AutoSaveStatus/useAutoSaveStatus.js +1 -2
- package/dist/components/Avatar/Avatar.js +1 -2
- package/dist/components/Avatar/AvatarButton.js +2 -2
- package/dist/components/Avatar/AvatarGroup.js +1 -2
- package/dist/components/Banner.js +1 -2
- package/dist/components/BeamContext.js +3 -3
- package/dist/components/Button.js +1 -2
- package/dist/components/ButtonDatePicker.js +1 -2
- package/dist/components/ButtonGroup.js +1 -2
- package/dist/components/ButtonMenu.js +1 -2
- package/dist/components/ButtonModal.js +1 -2
- package/dist/components/Chip.d.ts +1 -1
- package/dist/components/Chip.js +3 -3
- package/dist/components/Chips.js +1 -2
- package/dist/components/Copy.js +1 -2
- package/dist/components/CssReset.js +2 -2
- package/dist/components/DnDGrid/DnDGrid.js +2 -2
- package/dist/components/DnDGrid/DnDGridContext.js +2 -2
- package/dist/components/DnDGrid/DnDGridItemHandle.js +1 -2
- package/dist/components/DnDGrid/useDnDGridItem.js +1 -2
- package/dist/components/Filters/BooleanFilter.js +1 -2
- package/dist/components/Filters/CheckboxFilter.js +1 -2
- package/dist/components/Filters/DateFilter.js +1 -2
- package/dist/components/Filters/DateRangeFilter.js +1 -2
- package/dist/components/Filters/FilterModal.js +2 -3
- package/dist/components/Filters/MultiFilter.js +1 -2
- package/dist/components/Filters/NumberRangeFilter.js +1 -2
- package/dist/components/Filters/SingleFilter.js +2 -3
- package/dist/components/Filters/ToggleFilter.js +1 -2
- package/dist/components/Filters/TreeFilter.js +1 -2
- package/dist/components/Filters/index.d.ts +1 -1
- package/dist/components/Filters/index.js +3 -3
- package/dist/components/Filters/testDomain.js +3 -3
- package/dist/components/Filters/types.d.ts +0 -1
- package/dist/components/Filters/utils.js +2 -2
- package/dist/components/Grid/ResponsiveGrid.js +1 -2
- package/dist/components/Grid/ResponsiveGridItem.js +1 -2
- package/dist/components/Grid/useResponsiveGrid.js +1 -2
- package/dist/components/Grid/useResponsiveGridItem.js +1 -2
- package/dist/components/HbLoadingSpinner.js +3 -3
- package/dist/components/HelperText.js +1 -2
- package/dist/components/IconButton.js +2 -2
- package/dist/components/Label.js +3 -3
- package/dist/components/Layout/FullBleed.js +1 -2
- package/dist/components/Layout/PreventBrowserScroll.js +1 -2
- package/dist/components/Layout/RightPaneLayout/RightPaneContext.js +3 -3
- package/dist/components/Layout/RightPaneLayout/RightPaneLayout.js +1 -2
- package/dist/components/Layout/RightPaneLayout/useRightPane.js +1 -2
- package/dist/components/Layout/ScrollableContent.js +1 -2
- package/dist/components/Layout/ScrollableParent.js +3 -3
- package/dist/components/Loader.js +1 -2
- package/dist/components/LoadingSkeleton.js +1 -2
- package/dist/components/MaxLines.js +3 -4
- package/dist/components/Modal/Modal.js +5 -6
- package/dist/components/Modal/ModalContext.js +3 -3
- package/dist/components/Modal/OpenModal.d.ts +0 -1
- package/dist/components/Modal/OpenModal.js +1 -2
- package/dist/components/Modal/TestModalContent.js +3 -4
- package/dist/components/Modal/useModal.js +1 -2
- package/dist/components/NavLink.js +2 -3
- package/dist/components/Pagination.js +4 -4
- package/dist/components/PresentationContext.js +3 -3
- package/dist/components/ScrollShadows.js +1 -2
- package/dist/components/Snackbar/Snackbar.js +1 -2
- package/dist/components/Snackbar/SnackbarContext.js +3 -3
- package/dist/components/Snackbar/SnackbarNotice.js +1 -2
- package/dist/components/Snackbar/useSnackbar.js +1 -2
- package/dist/components/Stepper.js +1 -2
- package/dist/components/SuperDrawer/ConfirmCloseModal.js +1 -2
- package/dist/components/SuperDrawer/SuperDrawer.js +1 -2
- package/dist/components/SuperDrawer/components/SuperDrawerHeader.js +1 -2
- package/dist/components/SuperDrawer/useSuperDrawer.js +1 -2
- package/dist/components/SuperDrawer/utils.js +1 -1
- package/dist/components/Table/GridTable.js +13 -16
- package/dist/components/Table/GridTableApi.js +3 -3
- package/dist/components/Table/TableActions.js +1 -2
- package/dist/components/Table/TableStyles.js +2 -2
- package/dist/components/Table/components/CollapseToggle.js +1 -2
- package/dist/components/Table/components/EditColumnsButton.js +1 -2
- package/dist/components/Table/components/ExpandableHeader.js +1 -2
- package/dist/components/Table/components/KeptGroupRow.js +1 -2
- package/dist/components/Table/components/SelectToggle.js +1 -2
- package/dist/components/Table/components/SortHeader.js +1 -2
- package/dist/components/Table/components/cell.js +1 -1
- package/dist/components/Table/hooks/useSetupColumnSizes.js +1 -2
- package/dist/components/Table/utils/ColumnState.js +1 -1
- package/dist/components/Table/utils/GridRowLookup.js +2 -3
- package/dist/components/Table/utils/RowState.d.ts +1 -1
- package/dist/components/Table/utils/RowState.js +1 -1
- package/dist/components/Table/utils/TableState.js +2 -2
- package/dist/components/Table/utils/columns.js +12 -12
- package/dist/components/Table/utils/simpleHelpers.js +2 -2
- package/dist/components/Table/utils/sortRows.js +4 -5
- package/dist/components/Table/utils/utils.js +15 -15
- package/dist/components/Table/utils/visitor.js +1 -2
- package/dist/components/Tabs.js +6 -7
- package/dist/components/Tag.d.ts +1 -1
- package/dist/components/Tag.js +6 -7
- package/dist/components/Toast/Toast.js +1 -2
- package/dist/components/Toast/ToastContext.js +3 -3
- package/dist/components/Toast/useToast.js +1 -2
- package/dist/components/ToggleChip.js +1 -2
- package/dist/components/ToggleChips.js +1 -2
- package/dist/components/Tooltip.js +7 -6
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +4 -4
- package/dist/components/internal/CompoundField.d.ts +0 -1
- package/dist/components/internal/CompoundField.js +1 -2
- package/dist/components/internal/ContextualModal.js +1 -2
- package/dist/components/internal/DatePicker/DatePicker.js +1 -2
- package/dist/components/internal/DatePicker/DatePickerOverlay.js +1 -2
- package/dist/components/internal/DatePicker/DateRangePicker.js +1 -2
- package/dist/components/internal/DatePicker/Day.js +1 -2
- package/dist/components/internal/DatePicker/Header.js +2 -3
- package/dist/components/internal/DatePicker/WeekHeader.js +1 -2
- package/dist/components/internal/Menu.js +1 -2
- package/dist/components/internal/MenuItem.js +1 -2
- package/dist/components/internal/MenuSection.js +1 -2
- package/dist/components/internal/OverlayTrigger.js +5 -6
- package/dist/components/internal/Popover.js +2 -3
- package/dist/components/testData.js +2 -2
- package/dist/forms/BoundCheckboxField.js +1 -2
- package/dist/forms/BoundCheckboxGroupField.js +1 -2
- package/dist/forms/BoundChipSelectField.d.ts +0 -1
- package/dist/forms/BoundChipSelectField.js +1 -2
- package/dist/forms/BoundDateField.js +1 -2
- package/dist/forms/BoundDateRangeField.js +1 -2
- package/dist/forms/BoundIconCardField.d.ts +1 -1
- package/dist/forms/BoundIconCardField.js +3 -4
- package/dist/forms/BoundIconCardGroupField.d.ts +1 -1
- package/dist/forms/BoundIconCardGroupField.js +1 -2
- package/dist/forms/BoundMultiLineSelectField.d.ts +0 -1
- package/dist/forms/BoundMultiLineSelectField.js +1 -2
- package/dist/forms/BoundMultiSelectField.d.ts +0 -1
- package/dist/forms/BoundMultiSelectField.js +1 -2
- package/dist/forms/BoundNumberField.js +1 -2
- package/dist/forms/BoundRadioGroupField.js +1 -2
- package/dist/forms/BoundRichTextField.js +1 -2
- package/dist/forms/BoundSelectAndTextField.d.ts +0 -1
- package/dist/forms/BoundSelectAndTextField.js +1 -2
- package/dist/forms/BoundSelectField.d.ts +0 -1
- package/dist/forms/BoundSelectField.js +2 -3
- package/dist/forms/BoundSwitchField.js +1 -2
- package/dist/forms/BoundTextAreaField.js +1 -2
- package/dist/forms/BoundTextField.js +1 -2
- package/dist/forms/BoundToggleChipGroupField.js +1 -2
- package/dist/forms/BoundTreeSelectField.d.ts +0 -1
- package/dist/forms/BoundTreeSelectField.js +1 -2
- package/dist/forms/FormHeading.js +1 -2
- package/dist/forms/FormLines.js +4 -5
- package/dist/forms/FormStateApp.js +3 -3
- package/dist/forms/StaticField.js +1 -2
- package/dist/forms/StepperFormApp.js +1 -2
- package/dist/forms/SubmitButton.js +1 -2
- package/dist/forms/formStateDomain.js +1 -1
- package/dist/forms/index.d.ts +2 -2
- package/dist/forms/index.js +2 -2
- package/dist/forms/labelUtils.js +1 -2
- package/dist/hooks/useBreakpoint.js +1 -2
- package/dist/hooks/useComputed.d.ts +42 -1
- package/dist/hooks/useComputed.js +43 -3
- package/dist/hooks/useFilter.js +1 -2
- package/dist/hooks/useGroupBy.js +1 -2
- package/dist/hooks/useHover.js +1 -2
- package/dist/hooks/usePersistedFilter.js +2 -3
- package/dist/hooks/useQueryState.js +1 -2
- package/dist/hooks/useRenderCount.js +1 -2
- package/dist/hooks/useSessionStorage.js +1 -2
- package/dist/inputs/Autocomplete.js +1 -2
- package/dist/inputs/Checkbox.js +1 -2
- package/dist/inputs/CheckboxBase.js +2 -3
- package/dist/inputs/CheckboxGroup.js +1 -2
- package/dist/inputs/ChipSelectField.js +5 -5
- package/dist/inputs/ChipTextField.js +1 -2
- package/dist/inputs/DateFields/DateField.js +1 -2
- package/dist/inputs/DateFields/DateField.mock.js +1 -2
- package/dist/inputs/DateFields/DateFieldBase.js +2 -3
- package/dist/inputs/DateFields/DateRangeField.js +1 -2
- package/dist/inputs/DateFields/utils.js +7 -7
- package/dist/inputs/ErrorMessage.js +1 -2
- package/dist/inputs/IconCard.js +2 -2
- package/dist/inputs/IconCardGroup.js +5 -6
- package/dist/inputs/MultiLineSelectField.d.ts +0 -1
- package/dist/inputs/MultiLineSelectField.js +1 -2
- package/dist/inputs/MultiSelectField.js +1 -2
- package/dist/inputs/NumberField.js +2 -3
- package/dist/inputs/RadioGroupField.js +2 -2
- package/dist/inputs/RichTextField.d.ts +1 -1
- package/dist/inputs/RichTextField.js +2 -3
- package/dist/inputs/RichTextField.mock.js +1 -2
- package/dist/inputs/SelectField.d.ts +0 -1
- package/dist/inputs/SelectField.js +1 -2
- package/dist/inputs/Switch.js +3 -3
- package/dist/inputs/SwitchGroup.js +1 -2
- package/dist/inputs/TextAreaField.js +1 -2
- package/dist/inputs/TextField.js +1 -2
- package/dist/inputs/TextFieldBase.js +2 -3
- package/dist/inputs/ToggleButton.js +2 -2
- package/dist/inputs/ToggleChipGroup.d.ts +1 -1
- package/dist/inputs/ToggleChipGroup.js +2 -3
- package/dist/inputs/TreeSelectField/TreeOption.js +1 -2
- package/dist/inputs/TreeSelectField/TreeSelectField.js +5 -5
- package/dist/inputs/TreeSelectField/utils.js +5 -6
- package/dist/inputs/Value.js +2 -3
- package/dist/inputs/hooks/useGrowingTextField.js +1 -2
- package/dist/inputs/index.d.ts +1 -1
- package/dist/inputs/index.js +1 -1
- package/dist/inputs/internal/ComboBoxBase.js +6 -6
- package/dist/inputs/internal/ComboBoxInput.js +2 -3
- package/dist/inputs/internal/ListBox.js +1 -2
- package/dist/inputs/internal/ListBoxChip.js +1 -2
- package/dist/inputs/internal/ListBoxSection.js +1 -2
- package/dist/inputs/internal/ListBoxToggleChip.js +1 -2
- package/dist/inputs/internal/LoadingDots.js +1 -2
- package/dist/inputs/internal/MenuSearchField.js +1 -2
- package/dist/inputs/internal/Option.js +1 -2
- package/dist/inputs/internal/VirtualizedOptions.d.ts +0 -1
- package/dist/inputs/internal/VirtualizedOptions.js +2 -4
- package/dist/inputs/utils.js +1 -2
- package/dist/types.js +1 -2
- package/dist/utils/defaultLabel.js +1 -2
- package/dist/utils/defaultTestId.js +1 -2
- package/dist/utils/getInteractiveElement.js +1 -2
- package/dist/utils/index.js +12 -12
- package/dist/utils/options.js +2 -3
- package/dist/utils/rtl.d.ts +2 -3
- package/dist/utils/rtl.js +13 -13
- package/dist/utils/sb.d.ts +3 -3
- package/dist/utils/sb.js +7 -7
- package/dist/utils/shallowEqual.js +1 -2
- package/dist/utils/useTestIds.js +2 -3
- package/package.json +38 -45
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundCheckboxField =
|
|
3
|
+
exports.BoundCheckboxField = BoundCheckboxField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -25,4 +25,3 @@ function BoundCheckboxField(props) {
|
|
|
25
25
|
}, disabled: disabled || field.readOnly, ...testId, ...others }));
|
|
26
26
|
} }));
|
|
27
27
|
}
|
|
28
|
-
exports.BoundCheckboxField = BoundCheckboxField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundCheckboxGroupField =
|
|
3
|
+
exports.BoundCheckboxGroupField = BoundCheckboxGroupField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -22,4 +22,3 @@ function BoundCheckboxGroupField(props) {
|
|
|
22
22
|
(0, utils_1.maybeCall)(onFocus);
|
|
23
23
|
}, ...testId, ...others })) }));
|
|
24
24
|
}
|
|
25
|
-
exports.BoundCheckboxGroupField = BoundCheckboxGroupField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundChipSelectField =
|
|
3
|
+
exports.BoundChipSelectField = BoundChipSelectField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const ChipSelectField_1 = require("../inputs/ChipSelectField");
|
|
@@ -30,4 +30,3 @@ function BoundChipSelectField(props) {
|
|
|
30
30
|
: undefined, ...others, ...testId }));
|
|
31
31
|
} }));
|
|
32
32
|
}
|
|
33
|
-
exports.BoundChipSelectField = BoundChipSelectField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundDateField =
|
|
3
|
+
exports.BoundDateField = BoundDateField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -24,4 +24,3 @@ function BoundDateField(props) {
|
|
|
24
24
|
field.maybeAutoSave();
|
|
25
25
|
}, ...testId, ...others })) }));
|
|
26
26
|
}
|
|
27
|
-
exports.BoundDateField = BoundDateField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundDateRangeField =
|
|
3
|
+
exports.BoundDateRangeField = BoundDateRangeField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -24,4 +24,3 @@ function BoundDateRangeField(props) {
|
|
|
24
24
|
field.maybeAutoSave();
|
|
25
25
|
}, readOnly: readOnly || field.readOnly, ...testId, ...others })) }));
|
|
26
26
|
}
|
|
27
|
-
exports.BoundDateRangeField = BoundDateRangeField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
|
-
import { IconCardProps } from "../inputs";
|
|
3
2
|
import { IconProps } from "../components";
|
|
3
|
+
import { IconCardProps } from "../inputs";
|
|
4
4
|
export type BoundIconCardFieldProps = Omit<IconCardProps, "label" | "selected" | "onChange"> & {
|
|
5
5
|
field: FieldState<boolean | null | undefined>;
|
|
6
6
|
icon: IconProps["icon"];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundIconCardField =
|
|
3
|
+
exports.BoundIconCardField = BoundIconCardField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const mobx_react_1 = require("mobx-react");
|
|
5
6
|
const inputs_1 = require("../inputs");
|
|
6
|
-
const defaultLabel_1 = require("../utils/defaultLabel");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
-
const
|
|
8
|
+
const defaultLabel_1 = require("../utils/defaultLabel");
|
|
9
9
|
/** Wraps `IconCard` and binds it to a form field. */
|
|
10
10
|
function BoundIconCardField(props) {
|
|
11
11
|
const { icon, field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), ...others } = props;
|
|
@@ -19,4 +19,3 @@ function BoundIconCardField(props) {
|
|
|
19
19
|
}, disabled: field.readOnly, ...testId, ...others }));
|
|
20
20
|
} }));
|
|
21
21
|
}
|
|
22
|
-
exports.BoundIconCardField = BoundIconCardField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
|
-
import { IconCardGroupProps } from "../inputs/IconCardGroup";
|
|
3
2
|
import { Value } from "../inputs";
|
|
3
|
+
import { IconCardGroupProps } from "../inputs/IconCardGroup";
|
|
4
4
|
export type BoundIconCardGroupFieldProps<V extends Value> = Omit<IconCardGroupProps<V>, "label" | "values" | "onChange"> & {
|
|
5
5
|
field: FieldState<V[] | null | undefined>;
|
|
6
6
|
/** Make optional so that callers can override if they want to. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundIconCardGroupField =
|
|
3
|
+
exports.BoundIconCardGroupField = BoundIconCardGroupField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const IconCardGroup_1 = require("../inputs/IconCardGroup");
|
|
@@ -16,4 +16,3 @@ function BoundIconCardGroupField(props) {
|
|
|
16
16
|
field.maybeAutoSave();
|
|
17
17
|
}, disabled: field.readOnly, ...testId, ...others })) }));
|
|
18
18
|
}
|
|
19
|
-
exports.BoundIconCardGroupField = BoundIconCardGroupField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundMultiLineSelectField =
|
|
3
|
+
exports.BoundMultiLineSelectField = BoundMultiLineSelectField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -26,4 +26,3 @@ function BoundMultiLineSelectField(props) {
|
|
|
26
26
|
}, ...others, ...testId }));
|
|
27
27
|
} }));
|
|
28
28
|
}
|
|
29
|
-
exports.BoundMultiLineSelectField = BoundMultiLineSelectField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundMultiSelectField =
|
|
3
|
+
exports.BoundMultiSelectField = BoundMultiSelectField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -26,4 +26,3 @@ function BoundMultiSelectField(props) {
|
|
|
26
26
|
}, ...others, ...testId }));
|
|
27
27
|
} }));
|
|
28
28
|
}
|
|
29
|
-
exports.BoundMultiSelectField = BoundMultiSelectField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundNumberField =
|
|
3
|
+
exports.BoundNumberField = BoundNumberField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const NumberField_1 = require("../inputs/NumberField");
|
|
@@ -21,4 +21,3 @@ function BoundNumberField(props) {
|
|
|
21
21
|
field.maybeAutoSave();
|
|
22
22
|
}, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
|
-
exports.BoundNumberField = BoundNumberField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundRadioGroupField =
|
|
3
|
+
exports.BoundRadioGroupField = BoundRadioGroupField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -21,4 +21,3 @@ function BoundRadioGroupField(props) {
|
|
|
21
21
|
(0, utils_1.maybeCall)(onFocus);
|
|
22
22
|
}, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
|
-
exports.BoundRadioGroupField = BoundRadioGroupField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundRichTextField =
|
|
3
|
+
exports.BoundRichTextField = BoundRichTextField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const RichTextField_1 = require("../inputs/RichTextField");
|
|
@@ -21,4 +21,3 @@ function BoundRichTextField(props) {
|
|
|
21
21
|
(0, utils_1.maybeCall)(onFocus);
|
|
22
22
|
}, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
|
-
exports.BoundRichTextField = BoundRichTextField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundSelectAndTextField =
|
|
3
|
+
exports.BoundSelectAndTextField = BoundSelectAndTextField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const CompoundField_1 = require("../components/internal/CompoundField");
|
|
6
6
|
const index_1 = require("./index");
|
|
@@ -12,4 +12,3 @@ function BoundSelectAndTextField(props) {
|
|
|
12
12
|
const tid = (0, utils_1.useTestIds)(props);
|
|
13
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
|
-
exports.BoundSelectAndTextField = BoundSelectAndTextField;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundSelectField =
|
|
3
|
+
exports.BoundSelectField = BoundSelectField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
8
|
const defaultLabel_1 = require("../utils/defaultLabel");
|
|
9
|
-
const useTestIds_1 = require("../utils/useTestIds");
|
|
10
9
|
const options_1 = require("../utils/options");
|
|
10
|
+
const useTestIds_1 = require("../utils/useTestIds");
|
|
11
11
|
function BoundSelectField(props) {
|
|
12
12
|
const { field, options, readOnly, getOptionValue = options_1.defaultOptionValue, getOptionLabel = options_1.defaultOptionLabel, onSelect = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onBlur, onFocus, ...others } = props;
|
|
13
13
|
const testId = (0, useTestIds_1.useTestIds)(props, field.key);
|
|
@@ -25,4 +25,3 @@ function BoundSelectField(props) {
|
|
|
25
25
|
}, ...others, ...testId }));
|
|
26
26
|
} }));
|
|
27
27
|
}
|
|
28
|
-
exports.BoundSelectField = BoundSelectField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundSwitchField =
|
|
3
|
+
exports.BoundSwitchField = BoundSwitchField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -18,4 +18,3 @@ function BoundSwitchField(props) {
|
|
|
18
18
|
}, disabled: disabled || field.readOnly, ...testId, ...others }));
|
|
19
19
|
} }));
|
|
20
20
|
}
|
|
21
|
-
exports.BoundSwitchField = BoundSwitchField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundTextAreaField =
|
|
3
|
+
exports.BoundTextAreaField = BoundTextAreaField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -21,4 +21,3 @@ function BoundTextAreaField(props) {
|
|
|
21
21
|
field.maybeAutoSave();
|
|
22
22
|
}, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
|
-
exports.BoundTextAreaField = BoundTextAreaField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundTextField =
|
|
3
|
+
exports.BoundTextField = BoundTextField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -21,4 +21,3 @@ function BoundTextField(props) {
|
|
|
21
21
|
field.maybeAutoSave();
|
|
22
22
|
}, ...testId, ...others })) }));
|
|
23
23
|
}
|
|
24
|
-
exports.BoundTextField = BoundTextField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundToggleChipGroupField =
|
|
3
|
+
exports.BoundToggleChipGroupField = BoundToggleChipGroupField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -12,4 +12,3 @@ function BoundToggleChipGroupField(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: () => (0, jsx_runtime_1.jsx)(inputs_1.ToggleChipGroup, { label: label, values: field.value || [], onChange: onChange, ...testId, ...others }) }));
|
|
14
14
|
}
|
|
15
|
-
exports.BoundToggleChipGroupField = BoundToggleChipGroupField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BoundTreeSelectField =
|
|
3
|
+
exports.BoundTreeSelectField = BoundTreeSelectField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const inputs_1 = require("../inputs");
|
|
@@ -26,4 +26,3 @@ function BoundTreeSelectField(props) {
|
|
|
26
26
|
}, ...others, ...testId }));
|
|
27
27
|
} }));
|
|
28
28
|
}
|
|
29
|
-
exports.BoundTreeSelectField = BoundTreeSelectField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormHeading =
|
|
3
|
+
exports.FormHeading = FormHeading;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const Css_1 = require("../Css");
|
|
6
6
|
function FormHeading(props) {
|
|
@@ -12,6 +12,5 @@ function FormHeading(props) {
|
|
|
12
12
|
...xss,
|
|
13
13
|
}, ...others, children: title }));
|
|
14
14
|
}
|
|
15
|
-
exports.FormHeading = FormHeading;
|
|
16
15
|
// https://github.com/gaearon/react-hot-loader/issues/304#issuecomment-456569720
|
|
17
16
|
FormHeading.isFormHeading = true;
|
package/dist/forms/FormLines.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FormLines = FormLines;
|
|
4
|
+
exports.FormDivider = FormDivider;
|
|
5
|
+
exports.FieldGroup = FieldGroup;
|
|
4
6
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
7
|
const react_1 = require("react");
|
|
8
|
+
const components_1 = require("../components");
|
|
6
9
|
const PresentationContext_1 = require("../components/PresentationContext");
|
|
7
10
|
const Css_1 = require("../Css");
|
|
8
|
-
const components_1 = require("../components");
|
|
9
11
|
/**
|
|
10
12
|
* Applies standard Form layout/size/spacing between lines.
|
|
11
13
|
*
|
|
@@ -40,12 +42,10 @@ function FormLines(props) {
|
|
|
40
42
|
}
|
|
41
43
|
}) }) }));
|
|
42
44
|
}
|
|
43
|
-
exports.FormLines = FormLines;
|
|
44
45
|
/** Draws a line between form lines. */
|
|
45
46
|
function FormDivider() {
|
|
46
47
|
return (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.hPx(1).my2.bgGray200.$ });
|
|
47
48
|
}
|
|
48
|
-
exports.FormDivider = FormDivider;
|
|
49
49
|
/** Groups multiple fields side-by-side. */
|
|
50
50
|
function FieldGroup(props) {
|
|
51
51
|
// TODO Actually use title
|
|
@@ -58,7 +58,6 @@ function FieldGroup(props) {
|
|
|
58
58
|
.join(" ");
|
|
59
59
|
return (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.dg.gap2.gtc(gtc).$, children: children });
|
|
60
60
|
}
|
|
61
|
-
exports.FieldGroup = FieldGroup;
|
|
62
61
|
const sizes = {
|
|
63
62
|
full: "100%",
|
|
64
63
|
lg: "550px",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formConfig =
|
|
3
|
+
exports.formConfig = void 0;
|
|
4
|
+
exports.FormStateApp = FormStateApp;
|
|
4
5
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
6
|
const form_state_1 = require("@homebound/form-state");
|
|
6
7
|
const mobx_react_1 = require("mobx-react");
|
|
@@ -25,7 +26,7 @@ function FormStateApp() {
|
|
|
25
26
|
const [readOnly, setReadOnly] = (0, react_1.useState)(false);
|
|
26
27
|
const formState = (0, form_state_1.useFormState)({
|
|
27
28
|
config: exports.formConfig,
|
|
28
|
-
init: queryResponse,
|
|
29
|
+
init: { input: queryResponse },
|
|
29
30
|
addRules(state) {
|
|
30
31
|
state.lastName.rules.push(() => {
|
|
31
32
|
return state.firstName.value === state.lastName.value ? "Last name cannot equal first name" : undefined;
|
|
@@ -78,7 +79,6 @@ function FormStateApp() {
|
|
|
78
79
|
}
|
|
79
80
|
}, 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) })] })] })] })) }));
|
|
80
81
|
}
|
|
81
|
-
exports.FormStateApp = FormStateApp;
|
|
82
82
|
function createColumns(formState) {
|
|
83
83
|
return [
|
|
84
84
|
{ header: "#", data: ({ id }) => (0, jsx_runtime_1.jsx)("span", { children: id.value }) },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StaticField =
|
|
3
|
+
exports.StaticField = StaticField;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const utils_1 = require("@react-aria/utils");
|
|
6
6
|
const PresentationContext_1 = require("../components/PresentationContext");
|
|
@@ -15,4 +15,3 @@ function StaticField(props) {
|
|
|
15
15
|
const id = (0, utils_1.useId)();
|
|
16
16
|
return ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.if(labelStyle === "left").df.jcsb.maxw100.$, ...tid.container, 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.if(labelStyle === "left").w50.$, ...tid, children: value || children })] }));
|
|
17
17
|
}
|
|
18
|
-
exports.StaticField = StaticField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StepperFormApp =
|
|
3
|
+
exports.StepperFormApp = StepperFormApp;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const form_state_1 = require("@homebound/form-state");
|
|
6
6
|
const mobx_1 = require("mobx");
|
|
@@ -25,7 +25,6 @@ function StepperFormApp() {
|
|
|
25
25
|
});
|
|
26
26
|
return (0, jsx_runtime_1.jsx)(StepperForm, { formState: formState });
|
|
27
27
|
}
|
|
28
|
-
exports.StepperFormApp = StepperFormApp;
|
|
29
28
|
function StepperForm({ formState }) {
|
|
30
29
|
const [steps, setSteps] = (0, react_1.useState)(() => [
|
|
31
30
|
{ state: "incomplete", label: "Author Details", value: "author" },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SubmitButton =
|
|
3
|
+
exports.SubmitButton = SubmitButton;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const src_1 = require("..");
|
|
6
6
|
/** Provides a Button that will auto-disable if `formState` is invalid. */
|
|
@@ -20,4 +20,3 @@ function SubmitButton(props) {
|
|
|
20
20
|
}
|
|
21
21
|
}, ...others }));
|
|
22
22
|
}
|
|
23
|
-
exports.SubmitButton = SubmitButton;
|
|
@@ -15,7 +15,7 @@ var AuthorHeight;
|
|
|
15
15
|
(function (AuthorHeight) {
|
|
16
16
|
AuthorHeight[AuthorHeight["SHORT"] = 0] = "SHORT";
|
|
17
17
|
AuthorHeight[AuthorHeight["TALL"] = 1] = "TALL";
|
|
18
|
-
})(AuthorHeight
|
|
18
|
+
})(AuthorHeight || (exports.AuthorHeight = AuthorHeight = {}));
|
|
19
19
|
class DateOnly {
|
|
20
20
|
constructor(date) {
|
|
21
21
|
this.date = date;
|
package/dist/forms/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export * from "./BoundCheckboxGroupField";
|
|
|
3
3
|
export * from "./BoundChipSelectField";
|
|
4
4
|
export * from "./BoundDateField";
|
|
5
5
|
export * from "./BoundDateRangeField";
|
|
6
|
+
export * from "./BoundIconCardField";
|
|
7
|
+
export * from "./BoundIconCardGroupField";
|
|
6
8
|
export * from "./BoundMultiLineSelectField";
|
|
7
9
|
export * from "./BoundMultiSelectField";
|
|
8
10
|
export * from "./BoundNumberField";
|
|
@@ -15,8 +17,6 @@ export * from "./BoundTextAreaField";
|
|
|
15
17
|
export * from "./BoundTextField";
|
|
16
18
|
export * from "./BoundToggleChipGroupField";
|
|
17
19
|
export * from "./BoundTreeSelectField";
|
|
18
|
-
export * from "./BoundIconCardField";
|
|
19
|
-
export * from "./BoundIconCardGroupField";
|
|
20
20
|
export * from "./FormHeading";
|
|
21
21
|
export * from "./FormLines";
|
|
22
22
|
export * from "./StaticField";
|
package/dist/forms/index.js
CHANGED
|
@@ -19,6 +19,8 @@ __exportStar(require("./BoundCheckboxGroupField"), exports);
|
|
|
19
19
|
__exportStar(require("./BoundChipSelectField"), exports);
|
|
20
20
|
__exportStar(require("./BoundDateField"), exports);
|
|
21
21
|
__exportStar(require("./BoundDateRangeField"), exports);
|
|
22
|
+
__exportStar(require("./BoundIconCardField"), exports);
|
|
23
|
+
__exportStar(require("./BoundIconCardGroupField"), exports);
|
|
22
24
|
__exportStar(require("./BoundMultiLineSelectField"), exports);
|
|
23
25
|
__exportStar(require("./BoundMultiSelectField"), exports);
|
|
24
26
|
__exportStar(require("./BoundNumberField"), exports);
|
|
@@ -31,8 +33,6 @@ __exportStar(require("./BoundTextAreaField"), exports);
|
|
|
31
33
|
__exportStar(require("./BoundTextField"), exports);
|
|
32
34
|
__exportStar(require("./BoundToggleChipGroupField"), exports);
|
|
33
35
|
__exportStar(require("./BoundTreeSelectField"), exports);
|
|
34
|
-
__exportStar(require("./BoundIconCardField"), exports);
|
|
35
|
-
__exportStar(require("./BoundIconCardGroupField"), exports);
|
|
36
36
|
__exportStar(require("./FormHeading"), exports);
|
|
37
37
|
__exportStar(require("./FormLines"), exports);
|
|
38
38
|
__exportStar(require("./StaticField"), exports);
|
package/dist/forms/labelUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLabelSuffix =
|
|
3
|
+
exports.getLabelSuffix = getLabelSuffix;
|
|
4
4
|
const PresentationContext_1 = require("../components/PresentationContext");
|
|
5
5
|
function getLabelSuffix(required) {
|
|
6
6
|
var _a, _b;
|
|
@@ -17,4 +17,3 @@ function getLabelSuffix(required) {
|
|
|
17
17
|
return undefined;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
exports.getLabelSuffix = getLabelSuffix;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useBreakpoint =
|
|
6
|
+
exports.useBreakpoint = useBreakpoint;
|
|
7
7
|
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const index_1 = require("../utils/index");
|
|
@@ -31,7 +31,6 @@ function useBreakpoint() {
|
|
|
31
31
|
}, [handleResize]);
|
|
32
32
|
return breakpoints;
|
|
33
33
|
}
|
|
34
|
-
exports.useBreakpoint = useBreakpoint;
|
|
35
34
|
function matchMediaBreakpoints() {
|
|
36
35
|
const bps = {};
|
|
37
36
|
(0, index_1.safeEntries)(Css_1.Breakpoints).forEach(([name, bp]) => {
|
|
@@ -1,2 +1,43 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Evaluates a computed function `fn` to a regular value and triggers a re-render whenever it changes.
|
|
3
|
+
*
|
|
4
|
+
* Some examples:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* // Good, watching a single value
|
|
8
|
+
* const firstName = useComputed(() => author.firstName, [author]);
|
|
9
|
+
*
|
|
10
|
+
* // Good, watching multiple values in a single `useComputed`
|
|
11
|
+
* const { firstName, lastName } = useComputed(() => {
|
|
12
|
+
* // Make sure to read the values
|
|
13
|
+
* const { firstName, lastName } = author;
|
|
14
|
+
* return { firstName, lastName };
|
|
15
|
+
* }, [author]);
|
|
16
|
+
*
|
|
17
|
+
* // Good, watching a form-state field
|
|
18
|
+
* const firstName = useComputed(() => {
|
|
19
|
+
* return formState.firstName.value;
|
|
20
|
+
* }, [formState]);
|
|
21
|
+
*
|
|
22
|
+
* // Good, watching an observable `formState` + a POJO/immutable `items` which is not an observable
|
|
23
|
+
* const item = useComputed(() => {
|
|
24
|
+
* return items.find((i) => i.id === formState.itemId.value);
|
|
25
|
+
* }, [formState, items]);
|
|
26
|
+
*
|
|
27
|
+
* // Bad, fn and deps are "watching the same thing".
|
|
28
|
+
* const firstName = useComputed(() => {
|
|
29
|
+
* return formState.firstName.value;
|
|
30
|
+
* }, [formState.firstName.value]);
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Note that the difference between the `fn` and the `deps` is:
|
|
34
|
+
*
|
|
35
|
+
* - `fn` is "which values we are watching in the observable" (i.e. store or `formState`), and
|
|
36
|
+
* - `deps` is "which observable we're watching" (i.e. store or `formState`)
|
|
37
|
+
*
|
|
38
|
+
* So the `deps` array shouldn't overlap with any of the "watched values" of the `fn` lambda,
|
|
39
|
+
* other than the root observer itself (which admittedly should rarely change, i.e. our stores
|
|
40
|
+
* are generally global-ish/very stable, but can change if the user switches pages i.e. "from
|
|
41
|
+
* editing author:1 t editing author:2").
|
|
42
|
+
*/
|
|
2
43
|
export declare function useComputed<T>(fn: (prev: T | undefined) => T, deps: readonly any[]): T;
|
|
@@ -1,10 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useComputed =
|
|
3
|
+
exports.useComputed = useComputed;
|
|
4
4
|
const mobx_1 = require("mobx");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const shallowEqual_1 = require("../utils/shallowEqual");
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Evaluates a computed function `fn` to a regular value and triggers a re-render whenever it changes.
|
|
9
|
+
*
|
|
10
|
+
* Some examples:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* // Good, watching a single value
|
|
14
|
+
* const firstName = useComputed(() => author.firstName, [author]);
|
|
15
|
+
*
|
|
16
|
+
* // Good, watching multiple values in a single `useComputed`
|
|
17
|
+
* const { firstName, lastName } = useComputed(() => {
|
|
18
|
+
* // Make sure to read the values
|
|
19
|
+
* const { firstName, lastName } = author;
|
|
20
|
+
* return { firstName, lastName };
|
|
21
|
+
* }, [author]);
|
|
22
|
+
*
|
|
23
|
+
* // Good, watching a form-state field
|
|
24
|
+
* const firstName = useComputed(() => {
|
|
25
|
+
* return formState.firstName.value;
|
|
26
|
+
* }, [formState]);
|
|
27
|
+
*
|
|
28
|
+
* // Good, watching an observable `formState` + a POJO/immutable `items` which is not an observable
|
|
29
|
+
* const item = useComputed(() => {
|
|
30
|
+
* return items.find((i) => i.id === formState.itemId.value);
|
|
31
|
+
* }, [formState, items]);
|
|
32
|
+
*
|
|
33
|
+
* // Bad, fn and deps are "watching the same thing".
|
|
34
|
+
* const firstName = useComputed(() => {
|
|
35
|
+
* return formState.firstName.value;
|
|
36
|
+
* }, [formState.firstName.value]);
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Note that the difference between the `fn` and the `deps` is:
|
|
40
|
+
*
|
|
41
|
+
* - `fn` is "which values we are watching in the observable" (i.e. store or `formState`), and
|
|
42
|
+
* - `deps` is "which observable we're watching" (i.e. store or `formState`)
|
|
43
|
+
*
|
|
44
|
+
* So the `deps` array shouldn't overlap with any of the "watched values" of the `fn` lambda,
|
|
45
|
+
* other than the root observer itself (which admittedly should rarely change, i.e. our stores
|
|
46
|
+
* are generally global-ish/very stable, but can change if the user switches pages i.e. "from
|
|
47
|
+
* editing author:1 t editing author:2").
|
|
48
|
+
*/
|
|
8
49
|
function useComputed(fn, deps) {
|
|
9
50
|
// We always return the useRef value, and use this just to trigger re-renders
|
|
10
51
|
const [, setTick] = (0, react_1.useState)(0);
|
|
@@ -64,4 +105,3 @@ function useComputed(fn, deps) {
|
|
|
64
105
|
// We can use `!` here b/c we know that `autorun` set current
|
|
65
106
|
return ref.current.value;
|
|
66
107
|
}
|
|
67
|
-
exports.useComputed = useComputed;
|