@cube-dev/ui-kit 0.178.0 → 0.180.0
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/CHANGELOG.md +73 -0
- package/dist/_internal/hooks/use-debounced-value.js +1 -1
- package/dist/_internal/hooks/use-deprecation-warning.js +1 -1
- package/dist/_internal/hooks/use-event.js +1 -1
- package/dist/_internal/hooks/use-is-first-render.js +1 -1
- package/dist/_internal/hooks/use-sync-ref.js +1 -1
- package/dist/_internal/hooks/use-timer/timer.js +1 -1
- package/dist/_internal/hooks/use-timer/use-timer.js +1 -1
- package/dist/_internal/hooks/use-warn.js +1 -1
- package/dist/components/Block.js +1 -1
- package/dist/components/CollectionItem.js +1 -1
- package/dist/components/GlobalStyles.js +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/Button.js +1 -1
- package/dist/components/actions/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/actions/ButtonSplit/ButtonSplit.js +1 -1
- package/dist/components/actions/ButtonSplit/context.js +1 -1
- package/dist/components/actions/CommandMenu/CommandMenu.js +1 -1
- package/dist/components/actions/CommandMenu/styled.js +1 -1
- package/dist/components/actions/ItemAction/ItemAction.js +1 -1
- package/dist/components/actions/ItemActionContext.js +1 -1
- package/dist/components/actions/ItemActionsWrapper.js +218 -0
- package/dist/components/actions/ItemActionsWrapper.js.map +1 -0
- package/dist/components/actions/ItemButton/ItemButton.d.ts +11 -1
- package/dist/components/actions/ItemButton/ItemButton.js +25 -143
- package/dist/components/actions/ItemButton/ItemButton.js.map +1 -1
- package/dist/components/actions/Link/Link.js +1 -1
- package/dist/components/actions/Menu/Menu.js +1 -1
- package/dist/components/actions/Menu/MenuItem.js +1 -1
- package/dist/components/actions/Menu/MenuSection.js +1 -1
- package/dist/components/actions/Menu/MenuTrigger.js +3 -1
- package/dist/components/actions/Menu/MenuTrigger.js.map +1 -1
- package/dist/components/actions/Menu/SubMenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubmenuTriggerContext.js +1 -1
- package/dist/components/actions/Menu/context.js +1 -1
- package/dist/components/actions/Menu/styled.js +1 -1
- package/dist/components/actions/actions-run.js +34 -0
- package/dist/components/actions/actions-run.js.map +1 -0
- package/dist/components/actions/index.js +1 -1
- package/dist/components/actions/use-action.js +1 -1
- package/dist/components/actions/use-anchored-menu.js +1 -1
- package/dist/components/actions/use-context-menu.js +1 -1
- package/dist/components/content/ActiveZone/ActiveZone.js +1 -1
- package/dist/components/content/Alert/Alert.js +1 -1
- package/dist/components/content/Alert/use-alert.js +1 -1
- package/dist/components/content/Avatar/Avatar.js +1 -1
- package/dist/components/content/Badge/Badge.js +1 -1
- package/dist/components/content/Card/Card.js +1 -1
- package/dist/components/content/Content.js +1 -1
- package/dist/components/content/CopyPasteBlock/CopyPasteBlock.js +1 -1
- package/dist/components/content/CopySnippet/CopySnippet.js +1 -1
- package/dist/components/content/Disclosure/Disclosure.js +1 -1
- package/dist/components/content/Divider.js +1 -1
- package/dist/components/content/Footer.js +1 -1
- package/dist/components/content/Header.js +1 -1
- package/dist/components/content/HotKeys/HotKeys.js +1 -1
- package/dist/components/content/InfoBadge/InfoBadge.js +1 -1
- package/dist/components/content/InlineInput/InlineInput.js +1 -1
- package/dist/components/content/Item/Item.js +5 -5
- package/dist/components/content/Item/Item.js.map +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.js +1 -1
- package/dist/components/content/ItemCard/ItemCard.js +1 -1
- package/dist/components/content/Layout/GridLayout.js +1 -1
- package/dist/components/content/Layout/Layout.js +1 -1
- package/dist/components/content/Layout/LayoutBlock.js +1 -1
- package/dist/components/content/Layout/LayoutCenter.js +1 -1
- package/dist/components/content/Layout/LayoutContainer.js +1 -1
- package/dist/components/content/Layout/LayoutContent.js +1 -1
- package/dist/components/content/Layout/LayoutContext.js +1 -1
- package/dist/components/content/Layout/LayoutFlex.js +1 -1
- package/dist/components/content/Layout/LayoutFooter.js +1 -1
- package/dist/components/content/Layout/LayoutGrid.js +1 -1
- package/dist/components/content/Layout/LayoutHeader.js +1 -1
- package/dist/components/content/Layout/LayoutPane.js +1 -1
- package/dist/components/content/Layout/LayoutPanel.js +1 -1
- package/dist/components/content/Layout/LayoutPanelHeader.js +1 -1
- package/dist/components/content/Layout/LayoutToolbar.js +1 -1
- package/dist/components/content/Layout/hooks/useTinyScrollbar.js +1 -1
- package/dist/components/content/Layout/index.js +1 -1
- package/dist/components/content/Layout/utils.js +1 -1
- package/dist/components/content/Paragraph.js +1 -1
- package/dist/components/content/Placeholder/Placeholder.js +1 -1
- package/dist/components/content/PrismCode/PrismCode.js +1 -1
- package/dist/components/content/PrismCode/prismSetup.js +1 -1
- package/dist/components/content/PrismDiffCode/PrismDiffCode.js +1 -1
- package/dist/components/content/Result/Result.js +1 -1
- package/dist/components/content/Skeleton/Skeleton.js +1 -1
- package/dist/components/content/Tag/Tag.js +1 -1
- package/dist/components/content/Text.d.ts +14 -14
- package/dist/components/content/Text.js +1 -1
- package/dist/components/content/TextItem/TextItem.js +1 -1
- package/dist/components/content/Title.js +1 -1
- package/dist/components/content/Tree/Tree.js +1 -1
- package/dist/components/content/Tree/TreeNode.js +1 -1
- package/dist/components/content/Tree/styled.js +1 -1
- package/dist/components/content/Tree/tree-index.js +1 -1
- package/dist/components/content/Tree/use-checkbox-tree.js +1 -1
- package/dist/components/content/Tree/use-load-data.js +1 -1
- package/dist/components/content/highlightText.js +1 -1
- package/dist/components/content/use-auto-tooltip.js +1 -1
- package/dist/components/data/DataTable/DataTable.js +1 -1
- package/dist/components/data/ItemTable/ItemTable.js +1 -1
- package/dist/components/data/ItemTable/ItemTableBulkBar.js +1 -1
- package/dist/components/data/ItemTable/ItemTableDragPreview.js +1 -1
- package/dist/components/data/ItemTable/ItemTableFooter.js +1 -1
- package/dist/components/data/ItemTable/ItemTableToolbar.js +1 -1
- package/dist/components/data/TableBase/ColumnResizer.js +1 -1
- package/dist/components/data/TableBase/RowCollection.js +1 -1
- package/dist/components/data/TableBase/TableHeaderCell.js +1 -1
- package/dist/components/data/TableBase/TableRow.js +1 -1
- package/dist/components/data/TableBase/TableView.js +1 -1
- package/dist/components/data/TableBase/column-menu.js +1 -1
- package/dist/components/data/TableBase/column-tint.js +1 -1
- package/dist/components/data/TableBase/row-menu.js +1 -1
- package/dist/components/data/TableBase/styled.js +1 -1
- package/dist/components/data/TableBase/table-tree.js +1 -1
- package/dist/components/data/TableBase/types.js +1 -1
- package/dist/components/data/TableBase/use-cell-selection.js +0 -0
- package/dist/components/data/TableBase/use-column-order.js +1 -1
- package/dist/components/data/TableBase/use-container-width.js +1 -1
- package/dist/components/data/TableBase/use-row-move-animation.js +1 -1
- package/dist/components/data/TableBase/use-scrollability.js +1 -1
- package/dist/components/data/TableBase/use-table-columns.js +1 -1
- package/dist/components/data/TableBase/use-table-search.js +1 -1
- package/dist/components/data/TableBase/use-table-selection.js +1 -1
- package/dist/components/data/TableBase/use-table-sort.js +1 -1
- package/dist/components/data/TableBase/use-table-sorts.js +1 -1
- package/dist/components/data/TableBase/use-table-storage.js +1 -1
- package/dist/components/data/TableBase/use-table-tree-state.js +1 -1
- package/dist/components/fields/Checkbox/Checkbox.d.ts +7 -0
- package/dist/components/fields/Checkbox/Checkbox.js +1 -1
- package/dist/components/fields/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/fields/Checkbox/CheckboxGroup.d.ts +1 -1
- package/dist/components/fields/Checkbox/CheckboxGroup.js +3 -3
- package/dist/components/fields/Checkbox/CheckboxGroup.js.map +1 -1
- package/dist/components/fields/Checkbox/context.js +1 -1
- package/dist/components/fields/ColorInput/ColorInput.js +1 -1
- package/dist/components/fields/ColorPicker/ColorPicker.js +1 -1
- package/dist/components/fields/ColorSwatch/ColorSwatch.js +1 -1
- package/dist/components/fields/ColorSwatchGroup/ColorSwatchGroup.js +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +1 -1
- package/dist/components/fields/CommandTextArea/CommandTextArea.js +2 -2
- package/dist/components/fields/CommandTextArea/CommandTextArea.js.map +1 -1
- package/dist/components/fields/CommandTextArea/caretPosition.js +1 -1
- package/dist/components/fields/CommandTextArea/caretPosition.js.map +1 -1
- package/dist/components/fields/CommandTextArea/useCaretAnchor.js +1 -1
- package/dist/components/fields/DatePicker/DateInput.d.ts +1 -1
- package/dist/components/fields/DatePicker/DateInput.js +1 -1
- package/dist/components/fields/DatePicker/DateInput.js.map +1 -1
- package/dist/components/fields/DatePicker/DateInputBase.js +1 -1
- package/dist/components/fields/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/fields/DatePicker/DatePicker.js +1 -1
- package/dist/components/fields/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/fields/DatePicker/DatePickerButton.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerElement.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerInput.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerInput.js.map +1 -1
- package/dist/components/fields/DatePicker/DatePickerSegment.js +1 -1
- package/dist/components/fields/DatePicker/DateRangePicker.d.ts +1 -1
- package/dist/components/fields/DatePicker/DateRangePicker.js +1 -1
- package/dist/components/fields/DatePicker/DateRangePicker.js.map +1 -1
- package/dist/components/fields/DatePicker/DateRangeSeparatedPicker.d.ts +1 -1
- package/dist/components/fields/DatePicker/DateRangeSeparatedPicker.js +1 -1
- package/dist/components/fields/DatePicker/DateRangeSeparatedPicker.js.map +1 -1
- package/dist/components/fields/DatePicker/MonthPicker.js +1 -1
- package/dist/components/fields/DatePicker/PeriodPicker.d.ts +1 -1
- package/dist/components/fields/DatePicker/PeriodPicker.js +1 -1
- package/dist/components/fields/DatePicker/PeriodPicker.js.map +1 -1
- package/dist/components/fields/DatePicker/QuarterPicker.js +1 -1
- package/dist/components/fields/DatePicker/TimeInput.d.ts +1 -1
- package/dist/components/fields/DatePicker/TimeInput.js +1 -1
- package/dist/components/fields/DatePicker/TimeInput.js.map +1 -1
- package/dist/components/fields/DatePicker/WeekPicker.js +1 -1
- package/dist/components/fields/DatePicker/YearPicker.js +1 -1
- package/dist/components/fields/DatePicker/parseDate.js +1 -1
- package/dist/components/fields/DatePicker/period.js +1 -1
- package/dist/components/fields/DatePicker/props.js +1 -1
- package/dist/components/fields/DatePicker/utils.js +1 -1
- package/dist/components/fields/FileInput/FileInput.d.ts +2 -0
- package/dist/components/fields/FileInput/FileInput.js +1 -1
- package/dist/components/fields/FileInput/FileInput.js.map +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.js +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.js +18 -27
- package/dist/components/fields/FilterPicker/FilterPicker.js.map +1 -1
- package/dist/components/fields/Input/Input.js +1 -1
- package/dist/components/fields/ListBox/DraggableListBox.js +1 -1
- package/dist/components/fields/ListBox/ListBox.js +1 -1
- package/dist/components/fields/ListBoxPopover/ListBoxPopover.js +1 -1
- package/dist/components/fields/ListBoxPopover/listNavigation.js +1 -1
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.js +1 -1
- package/dist/components/fields/NumberInput/NumberInput.d.ts +1 -1
- package/dist/components/fields/NumberInput/NumberInput.js +3 -3
- package/dist/components/fields/NumberInput/NumberInput.js.map +1 -1
- package/dist/components/fields/NumberInput/StepButton.js +1 -1
- package/dist/components/fields/PasswordInput/PasswordInput.js +1 -1
- package/dist/components/fields/Picker/Picker.js +18 -27
- package/dist/components/fields/Picker/Picker.js.map +1 -1
- package/dist/components/fields/RadioGroup/Radio.js +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.js +3 -3
- package/dist/components/fields/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/fields/RadioGroup/context.js +1 -1
- package/dist/components/fields/SearchComboBox/SearchComboBox.js +1 -1
- package/dist/components/fields/SearchInput/SearchInput.js +1 -1
- package/dist/components/fields/Select/Select.js +53 -55
- package/dist/components/fields/Select/Select.js.map +1 -1
- package/dist/components/fields/Slider/Gradation.js +1 -1
- package/dist/components/fields/Slider/HueSlider.js +1 -1
- package/dist/components/fields/Slider/RangeSlider.js +1 -1
- package/dist/components/fields/Slider/Slider.js +1 -1
- package/dist/components/fields/Slider/SliderBase.js +2 -2
- package/dist/components/fields/Slider/SliderBase.js.map +1 -1
- package/dist/components/fields/Slider/SliderThumb.js +1 -1
- package/dist/components/fields/Slider/SliderTrack.js +1 -1
- package/dist/components/fields/Slider/elements.js +1 -1
- package/dist/components/fields/Slider/index.js +1 -1
- package/dist/components/fields/Slider/types.d.ts +1 -1
- package/dist/components/fields/Switch/Switch.d.ts +2 -0
- package/dist/components/fields/Switch/Switch.js +1 -1
- package/dist/components/fields/Switch/Switch.js.map +1 -1
- package/dist/components/fields/TextArea/TextArea.js +1 -1
- package/dist/components/fields/TextInput/TextInput.js +1 -1
- package/dist/components/fields/TextInput/TextInputBase.d.ts +1 -1
- package/dist/components/fields/TextInput/TextInputBase.js +1 -1
- package/dist/components/fields/TextInput/TextInputBase.js.map +1 -1
- package/dist/components/fields/TextInput/useAutoSizeTextArea.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/fields/TriggerActions.js +5 -56
- package/dist/components/fields/TriggerActions.js.map +1 -1
- package/dist/components/fields/color/ColorPanel.js +1 -1
- package/dist/components/fields/color/channels.js +1 -1
- package/dist/components/fields/color/color.js +1 -1
- package/dist/components/fields/color/context.js +1 -1
- package/dist/components/form/FieldWrapper/FieldWrapper.js +1 -1
- package/dist/components/form/Form/Field.js +1 -1
- package/dist/components/form/Form/Form.d.ts +38 -2
- package/dist/components/form/Form/Form.js +86 -16
- package/dist/components/form/Form/Form.js.map +1 -1
- package/dist/components/form/Form/ModernFormRoot.d.ts +19 -0
- package/dist/components/form/Form/ModernFormRoot.js +108 -0
- package/dist/components/form/Form/ModernFormRoot.js.map +1 -0
- package/dist/components/form/Form/ResetButton/ResetButton.d.ts +2 -1
- package/dist/components/form/Form/ResetButton/ResetButton.js +17 -2
- package/dist/components/form/Form/ResetButton/ResetButton.js.map +1 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.d.ts +2 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.js +17 -2
- package/dist/components/form/Form/SubmitButton/SubmitButton.js.map +1 -1
- package/dist/components/form/Form/SubmitError.js +26 -3
- package/dist/components/form/Form/SubmitError.js.map +1 -1
- package/dist/components/form/Form/backend.d.ts +25 -0
- package/dist/components/form/Form/backend.js +30 -0
- package/dist/components/form/Form/backend.js.map +1 -0
- package/dist/components/form/Form/index.d.ts +18 -4
- package/dist/components/form/Form/index.js +8 -2
- package/dist/components/form/Form/index.js.map +1 -1
- package/dist/components/form/Form/modern/actions.js +41 -0
- package/dist/components/form/Form/modern/actions.js.map +1 -0
- package/dist/components/form/Form/modern/context.d.ts +9 -0
- package/dist/components/form/Form/modern/context.js +14 -0
- package/dist/components/form/Form/modern/context.js.map +1 -0
- package/dist/components/form/Form/modern/controller.d.ts +23 -0
- package/dist/components/form/Form/modern/controller.js +48 -0
- package/dist/components/form/Form/modern/controller.js.map +1 -0
- package/dist/components/form/Form/modern/field-binding.js +41 -0
- package/dist/components/form/Form/modern/field-binding.js.map +1 -0
- package/dist/components/form/Form/modern/path-types.d.ts +12 -0
- package/dist/components/form/Form/modern/react.d.ts +21 -0
- package/dist/components/form/Form/modern/react.js +27 -0
- package/dist/components/form/Form/modern/react.js.map +1 -0
- package/dist/components/form/Form/modern/store.js +813 -0
- package/dist/components/form/Form/modern/store.js.map +1 -0
- package/dist/components/form/Form/modern/types.d.ts +173 -0
- package/dist/components/form/Form/modern/validation.d.ts +27 -0
- package/dist/components/form/Form/modern/validation.js +41 -0
- package/dist/components/form/Form/modern/validation.js.map +1 -0
- package/dist/components/form/Form/modern/values.d.ts +7 -0
- package/dist/components/form/Form/modern/values.js +144 -0
- package/dist/components/form/Form/modern/values.js.map +1 -0
- package/dist/components/form/Form/use-field/types.d.ts +4 -1
- package/dist/components/form/Form/use-field/use-field-binding.js +93 -0
- package/dist/components/form/Form/use-field/use-field-binding.js.map +1 -0
- package/dist/components/form/Form/use-field/use-field-props.d.ts +12 -1
- package/dist/components/form/Form/use-field/use-field-props.js +67 -50
- package/dist/components/form/Form/use-field/use-field-props.js.map +1 -1
- package/dist/components/form/Form/use-field/use-field.d.ts +6 -0
- package/dist/components/form/Form/use-field/use-field.js +47 -22
- package/dist/components/form/Form/use-field/use-field.js.map +1 -1
- package/dist/components/form/Form/use-form.d.ts +4 -1
- package/dist/components/form/Form/use-form.js +9 -5
- package/dist/components/form/Form/use-form.js.map +1 -1
- package/dist/components/form/Form/validation.js +2 -2
- package/dist/components/form/Label.js +1 -1
- package/dist/components/form/index.d.ts +8 -1
- package/dist/components/form/validation/ValidationIndicator.js +1 -1
- package/dist/components/form/validation/resolve-validation-props.js +1 -1
- package/dist/components/form/validation/use-validation-props.js +1 -1
- package/dist/components/form/wrapper.js +1 -1
- package/dist/components/helpers/DisplayTransition/DisplayTransition.js +1 -1
- package/dist/components/helpers/IconSwitch/IconSwitch.js +1 -1
- package/dist/components/layout/Board/Board.js +1 -1
- package/dist/components/layout/Board/BoardProvider.js +1 -1
- package/dist/components/layout/Board/BoardResponsive.js +1 -1
- package/dist/components/layout/Board/Widget.js +1 -1
- package/dist/components/layout/Board/WidgetHost.js +1 -1
- package/dist/components/layout/Board/board-context.js +1 -1
- package/dist/components/layout/Board/board-store.js +1 -1
- package/dist/components/layout/Board/grid-core/calculate.js +1 -1
- package/dist/components/layout/Board/grid-core/collision-modes.js +1 -1
- package/dist/components/layout/Board/grid-core/collision.js +1 -1
- package/dist/components/layout/Board/grid-core/compactors.js +1 -1
- package/dist/components/layout/Board/grid-core/constraints.js +1 -1
- package/dist/components/layout/Board/grid-core/group-move.js +1 -1
- package/dist/components/layout/Board/grid-core/layout.js +1 -1
- package/dist/components/layout/Board/grid-core/placement.js +1 -1
- package/dist/components/layout/Board/grid-core/sort.js +1 -1
- package/dist/components/layout/Board/index.js +1 -1
- package/dist/components/layout/Board/responsive-utils.js +1 -1
- package/dist/components/layout/Board/use-board-layout.js +1 -1
- package/dist/components/layout/Board/use-board-registry.js +1 -1
- package/dist/components/layout/Board/use-board-select-modifier-key.js +1 -1
- package/dist/components/layout/Board/use-board-selection.js +1 -1
- package/dist/components/layout/Flex.js +1 -1
- package/dist/components/layout/Flow.js +1 -1
- package/dist/components/layout/Grid.js +1 -1
- package/dist/components/layout/Panel.js +1 -1
- package/dist/components/layout/Prefix.js +1 -1
- package/dist/components/layout/ResizablePanel.js +1 -1
- package/dist/components/layout/Space.js +1 -1
- package/dist/components/layout/Suffix.js +1 -1
- package/dist/components/navigation/Pagination/Pagination.js +1 -1
- package/dist/components/navigation/Pagination/use-pagination.js +1 -1
- package/dist/components/navigation/Tabs/DraggableTabList.js +1 -1
- package/dist/components/navigation/Tabs/TabButton.js +36 -40
- package/dist/components/navigation/Tabs/TabButton.js.map +1 -1
- package/dist/components/navigation/Tabs/TabDropIndicator.js +1 -1
- package/dist/components/navigation/Tabs/TabPanel.js +1 -1
- package/dist/components/navigation/Tabs/TabPicker.js +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +1 -1
- package/dist/components/navigation/Tabs/TabsAction.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/popover-placement.js +1 -1
- package/dist/components/navigation/Tabs/styled.js +1 -29
- package/dist/components/navigation/Tabs/styled.js.map +1 -1
- package/dist/components/navigation/Tabs/types.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-editing.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-indicator.js +1 -1
- package/dist/components/organisms/StatsCard/StatsCard.js +1 -1
- package/dist/components/other/Calendar/Calendar.js +1 -1
- package/dist/components/other/Calendar/CalendarCell.js +1 -1
- package/dist/components/other/Calendar/CalendarGrid.js +1 -1
- package/dist/components/other/Calendar/CalendarHeader.js +1 -1
- package/dist/components/other/Calendar/CalendarPanel.js +1 -1
- package/dist/components/other/Calendar/PeriodCalendar.js +1 -1
- package/dist/components/other/Calendar/PeriodGrid.js +1 -1
- package/dist/components/other/Calendar/RangeCalendar.js +1 -1
- package/dist/components/other/Calendar/styled.js +1 -1
- package/dist/components/other/CubeLogo/CubeLogo.js +1 -1
- package/dist/components/other/NoDataIcon/NoDataIcon.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogApiProvider.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogZone.js +1 -1
- package/dist/components/overlays/Dialog/Dialog.js +1 -1
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +1 -1
- package/dist/components/overlays/Dialog/DialogTrigger.js +4 -2
- package/dist/components/overlays/Dialog/DialogTrigger.js.map +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Modal/Modal.js +1 -1
- package/dist/components/overlays/Modal/OpenTransitionContext.js +1 -1
- package/dist/components/overlays/Modal/Overlay.js +1 -1
- package/dist/components/overlays/Modal/Popover.js +1 -1
- package/dist/components/overlays/Modal/Tray.js +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +1 -1
- package/dist/components/overlays/Notifications/NotificationCard.js +1 -1
- package/dist/components/overlays/Notifications/NotificationContext.js +1 -1
- package/dist/components/overlays/Notifications/NotificationItem.js +1 -1
- package/dist/components/overlays/Notifications/OverlayContainer.js +1 -1
- package/dist/components/overlays/Notifications/OverlayProvider.js +1 -1
- package/dist/components/overlays/Notifications/PersistentNotificationsList.js +1 -1
- package/dist/components/overlays/Notifications/dismissed-storage.js +1 -1
- package/dist/components/overlays/Notifications/format-relative-time.js +1 -1
- package/dist/components/overlays/Notifications/index.js +1 -1
- package/dist/components/overlays/Notifications/use-notification-state.js +1 -1
- package/dist/components/overlays/Notifications/use-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-overlay-timers.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-state.js +1 -1
- package/dist/components/overlays/Notifications/use-toast-state.js +1 -1
- package/dist/components/overlays/Toast/ToastItem.js +1 -1
- package/dist/components/overlays/Toast/index.js +1 -1
- package/dist/components/overlays/Toast/useProgressToast.js +1 -1
- package/dist/components/overlays/Toast/useToast.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipProvider.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipTrigger.js +1 -1
- package/dist/components/overlays/Tooltip/context.js +1 -1
- package/dist/components/portal/Portal.js +1 -1
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +1 -1
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/Spin/Cube.js +1 -1
- package/dist/components/status/Spin/InternalSpinner.js +1 -1
- package/dist/components/status/Spin/Spin.js +1 -1
- package/dist/components/status/Spin/SpinsContainer.js +1 -1
- package/dist/data/item-themes.js +25 -6
- package/dist/data/item-themes.js.map +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/eslint-plugin/defaults.generated.js +1 -1
- package/dist/eslint-plugin/index.js +1 -1
- package/dist/eslint-plugin/rules/no-redundant-default-prop.js +1 -1
- package/dist/i18n/I18nProvider.js +1 -1
- package/dist/i18n/createFormatter.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/instance.js +1 -1
- package/dist/i18n/locales/de-DE/uikit.js +1 -1
- package/dist/i18n/locales/en-US/uikit.js +1 -1
- package/dist/i18n/locales/es-ES/uikit.js +1 -1
- package/dist/i18n/locales/es-MX/uikit.js +1 -1
- package/dist/i18n/locales/fr-FR/uikit.js +1 -1
- package/dist/i18n/locales/it-IT/uikit.js +1 -1
- package/dist/i18n/locales/ja-JP/uikit.js +1 -1
- package/dist/i18n/locales/nb-NO/uikit.js +1 -1
- package/dist/i18n/locales/pt-BR/uikit.js +1 -1
- package/dist/i18n/locales/pt-PT/uikit.js +1 -1
- package/dist/i18n/locales/sv-SE/uikit.js +1 -1
- package/dist/i18n/locales/vi-VN/uikit.js +1 -1
- package/dist/i18n/locales.js +1 -1
- package/dist/i18n/useFormatter.js +1 -1
- package/dist/i18n/useI18n.js +1 -1
- package/dist/icons/AdjustmentsHorizontalIcon.js +1 -1
- package/dist/icons/AdjustmentsIcon.js +1 -1
- package/dist/icons/AiIcon.js +1 -1
- package/dist/icons/AreaChartIcon.js +1 -1
- package/dist/icons/ArrowNarrowDownIcon.js +1 -1
- package/dist/icons/ArrowNarrowUpIcon.js +1 -1
- package/dist/icons/BackwardIcon.js +1 -1
- package/dist/icons/BarChartIcon.js +1 -1
- package/dist/icons/BellFilledIcon.js +1 -1
- package/dist/icons/BellIcon.js +1 -1
- package/dist/icons/BooleanIcon.js +1 -1
- package/dist/icons/CalendarEditIcon.js +1 -1
- package/dist/icons/CalendarIcon.js +1 -1
- package/dist/icons/CaretDownIcon.js +1 -1
- package/dist/icons/CaretUpIcon.js +1 -1
- package/dist/icons/ChartAreaStackedIcon.js +1 -1
- package/dist/icons/ChartAreaStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBarGroupedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarGroupedIcon.js +1 -1
- package/dist/icons/ChartBarHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarLineIcon.js +1 -1
- package/dist/icons/ChartBarStackedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBoxPlot2Icon.js +1 -1
- package/dist/icons/ChartBoxPlotIcon.js +1 -1
- package/dist/icons/ChartBubbleIcon.js +1 -1
- package/dist/icons/ChartDonut2Icon.js +1 -1
- package/dist/icons/ChartFunnelIcon.js +1 -1
- package/dist/icons/ChartHeatmapIcon.js +1 -1
- package/dist/icons/ChartKPIIcon.js +1 -1
- package/dist/icons/ChartPie2Icon.js +1 -1
- package/dist/icons/ChartScatterIcon.js +1 -1
- package/dist/icons/CheckCircleFilledIcon.js +1 -1
- package/dist/icons/CheckCircleIcon.js +1 -1
- package/dist/icons/CheckIcon.js +1 -1
- package/dist/icons/CircleFilledIcon.js +1 -1
- package/dist/icons/ClearIcon.js +1 -1
- package/dist/icons/CloseCircleFilledIcon.js +1 -1
- package/dist/icons/CloseCircleIcon.js +1 -1
- package/dist/icons/CloseIcon.js +1 -1
- package/dist/icons/CodeIcon.js +1 -1
- package/dist/icons/ColumnTotalIcon.js +1 -1
- package/dist/icons/CopyIcon.js +1 -1
- package/dist/icons/CountIcon.js +1 -1
- package/dist/icons/CubeIcon.js +1 -1
- package/dist/icons/CubePauseIcon.js +1 -1
- package/dist/icons/CubePlayIcon.js +1 -1
- package/dist/icons/CurrencyDollarIcon.js +1 -1
- package/dist/icons/DangerIcon.js +1 -1
- package/dist/icons/DashboardIcon.js +1 -1
- package/dist/icons/DatabaseIcon.js +1 -1
- package/dist/icons/DecimalDecreaseIcon.js +1 -1
- package/dist/icons/DecimalIncreaseIcon.js +1 -1
- package/dist/icons/DirectionIcon.js +1 -1
- package/dist/icons/DonutIcon.js +1 -1
- package/dist/icons/DownIcon.js +1 -1
- package/dist/icons/EditIcon.js +1 -1
- package/dist/icons/ExclamationCircleFilledIcon.js +1 -1
- package/dist/icons/ExclamationCircleIcon.js +1 -1
- package/dist/icons/ExclamationIcon.js +1 -1
- package/dist/icons/EyeIcon.js +1 -1
- package/dist/icons/EyeInvisibleIcon.js +1 -1
- package/dist/icons/FilterIcon.js +1 -1
- package/dist/icons/FolderFilledIcon.js +1 -1
- package/dist/icons/FolderIcon.js +1 -1
- package/dist/icons/FolderOpenFilledIcon.js +1 -1
- package/dist/icons/FolderOpenIcon.js +1 -1
- package/dist/icons/ForwardIcon.js +1 -1
- package/dist/icons/GripVerticalIcon.js +1 -1
- package/dist/icons/HierarchyIcon.js +1 -1
- package/dist/icons/HierarchyOpenIcon.js +1 -1
- package/dist/icons/Icon.js +1 -1
- package/dist/icons/InfoCircleIcon.js +1 -1
- package/dist/icons/InfoIcon.js +1 -1
- package/dist/icons/KeyIcon.js +1 -1
- package/dist/icons/LeftIcon.js +1 -1
- package/dist/icons/LineChartIcon.js +1 -1
- package/dist/icons/LoadingIcon.js +1 -1
- package/dist/icons/LockFilledIcon.js +1 -1
- package/dist/icons/LockIcon.js +1 -1
- package/dist/icons/MoreIcon.js +1 -1
- package/dist/icons/NotAllowedIcon.js +1 -1
- package/dist/icons/Number123Icon.js +1 -1
- package/dist/icons/NumberIcon.js +1 -1
- package/dist/icons/PauseCircleFilledIcon.js +1 -1
- package/dist/icons/PauseCircleIcon.js +1 -1
- package/dist/icons/PauseIcon.js +1 -1
- package/dist/icons/PercentageIcon.js +1 -1
- package/dist/icons/PieChartIcon.js +1 -1
- package/dist/icons/PipetteIcon.js +1 -1
- package/dist/icons/PlayCircleIcon.js +1 -1
- package/dist/icons/PlayIcon.js +1 -1
- package/dist/icons/PlusIcon.js +1 -1
- package/dist/icons/ProgressBarIcon.js +1 -1
- package/dist/icons/ReloadIcon.js +1 -1
- package/dist/icons/ReportIcon.js +1 -1
- package/dist/icons/ReturnIcon.js +1 -1
- package/dist/icons/RightIcon.js +1 -1
- package/dist/icons/RowTotalsIcon.js +1 -1
- package/dist/icons/SchemeIcon.js +1 -1
- package/dist/icons/SearchIcon.js +1 -1
- package/dist/icons/SemanticQueryIcon.js +1 -1
- package/dist/icons/SettingsIcon.js +1 -1
- package/dist/icons/ShieldFilledIcon.js +1 -1
- package/dist/icons/ShieldIcon.js +1 -1
- package/dist/icons/SlashIcon.js +1 -1
- package/dist/icons/SparklesIcon.js +1 -1
- package/dist/icons/SqlIcon.js +1 -1
- package/dist/icons/StatsIcon.js +1 -1
- package/dist/icons/StopIcon.js +1 -1
- package/dist/icons/StringIcon.js +1 -1
- package/dist/icons/SubtotalsIcon.js +1 -1
- package/dist/icons/SwitchIcon.js +1 -1
- package/dist/icons/TableIcon.js +1 -1
- package/dist/icons/ThumbsDownIcon.js +1 -1
- package/dist/icons/ThumbsUpIcon.js +1 -1
- package/dist/icons/ThunderboltCrossedIcon.js +1 -1
- package/dist/icons/ThunderboltFilledIcon.js +1 -1
- package/dist/icons/ThunderboltIcon.js +1 -1
- package/dist/icons/TimeIcon.js +1 -1
- package/dist/icons/TrashIcon.js +1 -1
- package/dist/icons/UnlockIcon.js +1 -1
- package/dist/icons/UpIcon.js +1 -1
- package/dist/icons/UserGroupIcon.js +1 -1
- package/dist/icons/UserIcon.js +1 -1
- package/dist/icons/UserLockIcon.js +1 -1
- package/dist/icons/ViewIcon.js +1 -1
- package/dist/icons/WarningFilledIcon.js +1 -1
- package/dist/icons/WarningIcon.js +1 -1
- package/dist/icons/wrap-icon.js +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.js +3 -3
- package/dist/probe/canonicalize.js +1 -1
- package/dist/probe/css.js +1 -1
- package/dist/probe/index.js +1 -1
- package/dist/provider.js +1 -1
- package/dist/providers/TrackingProvider.js +1 -1
- package/dist/providers/navigationAdapter.default.js +1 -1
- package/dist/shared/form.d.ts +16 -2
- package/dist/shared/index.d.ts +1 -1
- package/dist/tokens/all-tokens.js +1 -1
- package/dist/tokens/base.js +1 -1
- package/dist/tokens/color-seed.js +1 -1
- package/dist/tokens/color-theme.js +1 -1
- package/dist/tokens/colors.js +1 -1
- package/dist/tokens/layout.js +1 -1
- package/dist/tokens/lazy-styles.js +1 -1
- package/dist/tokens/legacy-color.js +1 -1
- package/dist/tokens/palette-config.js +1 -1
- package/dist/tokens/palette.js +1 -1
- package/dist/tokens/resolve.js +1 -1
- package/dist/tokens/shadows.js +1 -1
- package/dist/tokens/sizes.js +1 -1
- package/dist/tokens/spacing.js +1 -1
- package/dist/tokens/typography.js +1 -1
- package/dist/utils/ResizeSensor.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/dotize.js +50 -0
- package/dist/utils/dotize.js.map +1 -0
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/modules.js +1 -1
- package/dist/utils/promise.js +1 -1
- package/dist/utils/raf.js +1 -1
- package/dist/utils/random.js +1 -1
- package/dist/utils/range.js +1 -1
- package/dist/utils/react/RenderCache.js +1 -1
- package/dist/utils/react/Slots.js +1 -1
- package/dist/utils/react/chain.js +1 -1
- package/dist/utils/react/disabledProps.js +1 -1
- package/dist/utils/react/forwardRefWithGenerics.js +1 -1
- package/dist/utils/react/index.js +1 -1
- package/dist/utils/react/interactions.js +1 -1
- package/dist/utils/react/isTextOnly.js +1 -1
- package/dist/utils/react/mapProps.js +1 -1
- package/dist/utils/react/mergeProps.js +1 -1
- package/dist/utils/react/nullableValue.js +1 -1
- package/dist/utils/react/resolveIcon.js +1 -1
- package/dist/utils/react/sharedStore.js +1 -1
- package/dist/utils/react/useBufferedValue.js +1 -1
- package/dist/utils/react/useCombinedRefs.js +1 -1
- package/dist/utils/react/useControlledFocusVisible.js +1 -1
- package/dist/utils/react/useEventBus.js +1 -1
- package/dist/utils/react/useId.js +1 -1
- package/dist/utils/react/useIsDarwin.js +1 -1
- package/dist/utils/react/useKeySymbols.js +1 -1
- package/dist/utils/react/useLayoutEffect.js +1 -1
- package/dist/utils/react/useLocalStorage.js +1 -1
- package/dist/utils/react/useMergeStyles.js +1 -1
- package/dist/utils/react/usePopoverSync.js +1 -1
- package/dist/utils/react/useQaProps.js +1 -1
- package/dist/utils/react/useScheme.js +1 -1
- package/dist/utils/react/useViewportSize.js +1 -1
- package/dist/utils/react/wrapNodeIfPlain.js +1 -1
- package/dist/utils/selection.js +1 -1
- package/dist/utils/styles.js +1 -1
- package/dist/utils/tree.js +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/version.js +3 -3
- package/docs/CreateComponent.md +4 -0
- package/docs/Usage.md +2 -0
- package/docs/components/Block.md +3 -3
- package/docs/components/CollectionItem.md +3 -3
- package/docs/components/GridProvider.md +3 -3
- package/docs/components/Root.md +1 -1
- package/docs/components/actions/Action.md +3 -3
- package/docs/components/actions/Banner.md +3 -3
- package/docs/components/actions/Button.md +3 -3
- package/docs/components/actions/ButtonGroup.md +3 -3
- package/docs/components/actions/ButtonSplit.md +3 -3
- package/docs/components/actions/CommandMenu.md +3 -3
- package/docs/components/actions/ItemAction.md +3 -1
- package/docs/components/actions/ItemButton.md +15 -1
- package/docs/components/actions/Link.md +3 -3
- package/docs/components/actions/Menu.md +3 -3
- package/docs/components/actions/MenuTrigger.md +3 -3
- package/docs/components/actions/SubMenuTrigger.md +3 -3
- package/docs/components/actions/use-anchored-menu.md +3 -3
- package/docs/components/actions/use-context-menu.md +3 -3
- package/docs/components/content/ActiveZone.md +3 -3
- package/docs/components/content/Alert.md +3 -3
- package/docs/components/content/Avatar.md +3 -3
- package/docs/components/content/Card.md +3 -3
- package/docs/components/content/Content.md +3 -3
- package/docs/components/content/CopyPasteBlock.md +1 -1
- package/docs/components/content/CopySnippet.md +3 -3
- package/docs/components/content/Disclosure.md +3 -3
- package/docs/components/content/Divider.md +3 -3
- package/docs/components/content/Footer.md +3 -3
- package/docs/components/content/Header.md +3 -3
- package/docs/components/content/HotKeys.md +3 -3
- package/docs/components/content/InlineInput.md +3 -3
- package/docs/components/content/Item.md +3 -3
- package/docs/components/content/Layout.md +3 -3
- package/docs/components/content/Paragraph.md +3 -3
- package/docs/components/content/Placeholder.md +3 -3
- package/docs/components/content/Result.md +3 -3
- package/docs/components/content/Skeleton.md +3 -3
- package/docs/components/content/Title.md +3 -3
- package/docs/components/content/Tree.md +3 -3
- package/docs/components/data/DataTable.md +3 -3
- package/docs/components/data/ItemTable.md +3 -3
- package/docs/components/fields/Checkbox.md +3 -3
- package/docs/components/fields/ColorInput.md +3 -3
- package/docs/components/fields/ColorPicker.md +3 -3
- package/docs/components/fields/ColorSwatch.md +3 -3
- package/docs/components/fields/ColorSwatchGroup.md +3 -3
- package/docs/components/fields/ComboBox.md +3 -3
- package/docs/components/fields/CommandTextArea.md +3 -3
- package/docs/components/fields/DatePicker.md +3 -3
- package/docs/components/fields/FileInput.md +3 -3
- package/docs/components/fields/FilterListBox.md +3 -3
- package/docs/components/fields/FilterPicker.md +13 -3
- package/docs/components/fields/HueSlider.md +3 -3
- package/docs/components/fields/ListBox.md +3 -3
- package/docs/components/fields/NumberInput.md +3 -3
- package/docs/components/fields/PasswordInput.md +3 -3
- package/docs/components/fields/PeriodPicker.md +3 -3
- package/docs/components/fields/Picker.md +13 -3
- package/docs/components/fields/RadioGroup.md +3 -3
- package/docs/components/fields/SearchComboBox.md +3 -3
- package/docs/components/fields/SearchInput.md +3 -3
- package/docs/components/fields/Select.md +13 -3
- package/docs/components/fields/Slider.md +3 -3
- package/docs/components/fields/Switch.md +3 -3
- package/docs/components/fields/TextArea.md +3 -3
- package/docs/components/fields/TextInput.md +3 -3
- package/docs/components/fields/TextInputMapper.md +3 -3
- package/docs/components/form/Field.md +3 -3
- package/docs/components/form/Form.md +54 -4
- package/docs/components/layout/Board.md +3 -3
- package/docs/components/layout/Flex.md +3 -3
- package/docs/components/layout/Flow.md +3 -3
- package/docs/components/layout/Grid.md +3 -3
- package/docs/components/layout/Panel.md +3 -3
- package/docs/components/layout/Prefix.md +3 -3
- package/docs/components/layout/ResizablePanel.md +3 -3
- package/docs/components/layout/Space.md +3 -3
- package/docs/components/layout/Suffix.md +3 -3
- package/docs/components/navigation/Pagination.md +3 -3
- package/docs/components/navigation/Tabs.md +3 -3
- package/docs/components/organisms/StatsCard.md +3 -3
- package/docs/components/overlays/AlertDialog.md +3 -3
- package/docs/components/overlays/Dialog.md +2 -2
- package/docs/components/overlays/DialogContainer.md +2 -2
- package/docs/components/overlays/DialogForm.md +2 -2
- package/docs/components/overlays/DialogTrigger.md +2 -2
- package/docs/components/overlays/Tooltip.md +3 -3
- package/docs/components/overlays/TooltipProvider.md +3 -3
- package/docs/components/overlays/TooltipTrigger.md +3 -3
- package/docs/components/status/LoadingAnimation.md +3 -3
- package/docs/components/status/Spin.md +3 -3
- package/docs/modern-form-migration.md +104 -0
- package/docs/modern-form-typecheck.md +35 -0
- package/docs/tasty/ai-agents.md +8 -3
- package/docs/tasty/debug.md +2 -5
- package/docs/tasty/methodology.md +3 -3
- package/docs/tasty/pipeline.md +3 -0
- package/docs/tasty/runtime-benchmarks.md +105 -68
- package/docs/tasty/ssr.md +1 -1
- package/docs/tasty/styles.md +43 -11
- package/package.json +13 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","names":[],"sources":["../../../../../src/components/form/Form/modern/store.ts"],"sourcesContent":["import { FORM_BACKEND } from '../backend';\n\nimport { rulesSignature, runRules } from './validation';\nimport {\n createValueSnapshotter,\n defineValue,\n formValueEqual,\n freezeContainer,\n getFieldKey,\n hasPath,\n isPlainObject,\n normalizePath,\n readonlySet,\n readPath,\n sameMembers,\n writePath,\n} from './values';\n\nimport type {\n CallbackBinding,\n FieldState,\n FormCallbacks,\n FormChange,\n FormState,\n FormStore,\n FormStoreOptions,\n ModernFieldValidationResult,\n ModernSubmitResult,\n ModernValidationResult,\n RegistrationOptions,\n RegistrationToken,\n SetValueOptions,\n SubmissionToken,\n ValidationToken,\n} from './types';\nimport type { FormPath } from './values';\n\ninterface Registration<ErrorValue> {\n options: RegistrationOptions<ErrorValue>;\n signature: string;\n order: number;\n defaultConsidered: boolean;\n}\n\ninterface FieldRecord<ErrorValue> {\n name: string;\n path: readonly string[];\n /** Defaults create aggregate metadata; explicit commands/fields own guards. */\n explicit: boolean;\n registrations: Set<Registration<ErrorValue>>;\n owner?: Registration<ErrorValue>;\n fieldDefault?: { value: unknown };\n touched: boolean;\n errors: readonly ErrorValue[];\n status: FieldState['status'];\n validationRevision: number;\n validation?: AbortController;\n}\n\nconst EMPTY_ERRORS = Object.freeze([]);\nconst EMPTY_OBJECT = Object.freeze({});\nconst EMPTY_FIELDS = Object.freeze(Object.create(null)) as Readonly<\n Record<string, never>\n>;\n\nfunction related(a: readonly string[], b: readonly string[]): boolean {\n return a\n .slice(0, Math.min(a.length, b.length))\n .every((key, index) => key === b[index]);\n}\n\ninterface ActivePath {\n terminal: boolean;\n children: Map<string, ActivePath>;\n}\n\n/** Only traverse path ancestors; a field's value (even cyclic data) is a leaf. */\nfunction projectActive(\n value: unknown,\n path: ActivePath,\n previous: unknown,\n): unknown {\n if (path.terminal) return value;\n const result: Record<string, unknown> | unknown[] = Array.isArray(value)\n ? []\n : {};\n if (isPlainObject(value) || Array.isArray(value)) {\n for (const [key, child] of path.children) {\n if (!Object.hasOwn(value, key)) continue;\n defineValue(\n result,\n key,\n projectActive(\n Reflect.get(value, key),\n child,\n readPath(previous, [key]),\n ),\n );\n }\n }\n return formValueEqual(result, previous) ? previous : freezeContainer(result);\n}\n\n/**\n * Framework-neutral store, registration ownership, and async pipelines.\n * Not exported from the package; React receives the public command facade.\n */\nexport function createFormStore<\n T extends object = Record<string, unknown>,\n ErrorValue = unknown,\n>(inputOptions: FormStoreOptions<T> = {}): FormStore<T, ErrorValue> {\n const options = { ...inputOptions };\n const ownValue = createValueSnapshotter();\n const records = new Map<string, FieldRecord<ErrorValue>>();\n // Subscription identity belongs to the registration, not to the callback.\n const listeners = new Set<{ notify: () => void }>();\n let values: object = ownValue(options.defaultValues ?? {});\n let defaults = values;\n let submitError: unknown;\n let submission: AbortController | undefined;\n let binding: { callbacks: FormCallbacks<T> } | undefined;\n let order = 0;\n let depth = 0;\n let notifying = false;\n let disposed = false;\n let pending = false;\n let changes: FormChange[] = [];\n const cancellations = new Set<AbortController>();\n\n let state: FormState<T, ErrorValue> = Object.freeze({\n values: values as Partial<T>,\n defaultValues: defaults as Partial<T>,\n activeValues: EMPTY_OBJECT,\n fields: EMPTY_FIELDS,\n dirtyFields: readonlySet<string>([]),\n touchedFields: readonlySet<string>([]),\n isDirty: false,\n isTouched: false,\n isValid: false,\n isInvalid: false,\n isValidating: false,\n isSubmitting: false,\n submitError: undefined,\n revision: 0,\n });\n\n function assertLive() {\n if (disposed) throw new Error('Cannot use a disposed modern form store.');\n }\n\n function report(error: unknown) {\n try {\n if (options.onListenerError) options.onListenerError(error);\n else console.error('[form-store] Listener failed', error);\n } catch (reportError) {\n // An error reporter must not break delivery to the remaining listeners.\n console.error('[form-store] Error reporter failed', reportError);\n }\n }\n\n function developmentError(message: string) {\n if (process.env.NODE_ENV === 'production') return;\n try {\n if (options.onDevelopmentError) options.onDevelopmentError(message);\n else console.error(`[form-store] ${message}`);\n } catch (error) {\n report(error);\n }\n }\n\n function ensure(path: FormPath, explicit = true): FieldRecord<ErrorValue> {\n const normalized = normalizePath(path);\n const name = getFieldKey(normalized);\n let record = records.get(name);\n if (!record) {\n record = {\n name,\n path: normalized,\n explicit,\n registrations: new Set(),\n touched: false,\n errors: EMPTY_ERRORS,\n status: 'unvalidated',\n validationRevision: 0,\n };\n records.set(name, record);\n }\n record.explicit ||= explicit;\n return record;\n }\n\n function dirty(record: FieldRecord<ErrorValue>): boolean {\n return (\n hasPath(values, record.path) &&\n !(record.owner?.options.isEqual ?? formValueEqual)(\n readPath(values, record.path),\n readPath(defaults, record.path),\n )\n );\n }\n\n function invalidate(record: FieldRecord<ErrorValue>, keepErrors = false) {\n const controller = record.validation;\n record.validation = undefined;\n record.validationRevision++;\n record.status = 'unvalidated';\n if (!keepErrors) record.errors = EMPTY_ERRORS;\n // Abort handlers are user code. Deliver them after the complete snapshot\n // publishes, so they cannot interleave writes with the command cancelling\n // them (or resurrect a token that command later overwrites).\n if (controller) cancellations.add(controller);\n }\n\n function cancelPending() {\n for (const controller of Array.from(cancellations)) {\n cancellations.delete(controller);\n controller.abort();\n }\n }\n\n function invalidateRelated(\n path: readonly string[],\n previous: object,\n config?: SetValueOptions,\n ) {\n for (const record of records.values()) {\n if (\n related(path, record.path) ||\n !Object.is(\n readPath(previous, record.path),\n readPath(values, record.path),\n ) ||\n hasPath(previous, record.path) !== hasPath(values, record.path)\n ) {\n const revalidate =\n !!config &&\n !!record.registrations.size &&\n (config.validate === 'always' ||\n (config.validate !== 'never' &&\n (record.owner?.options.validateTrigger === 'onChange' ||\n !!record.errors.length)));\n invalidate(record, revalidate);\n if (revalidate) void validateRecord(record, false);\n }\n }\n }\n\n function activeValues(): object {\n const tree: ActivePath = { terminal: false, children: new Map() };\n // A registered parent includes its complete object, including inactive\n // descendants. Register only the leaves to submit only those leaves.\n for (const record of records.values()) {\n if (!record.registrations.size || !hasPath(values, record.path)) continue;\n let node = tree;\n for (const key of record.path) {\n let child = node.children.get(key);\n if (!child) {\n child = { terminal: false, children: new Map() };\n node.children.set(key, child);\n }\n node = child;\n }\n node.terminal = true;\n }\n return projectActive(values, tree, state.activeValues) as object;\n }\n\n function buildSnapshot(): FormState<T, ErrorValue> {\n const fields: Record<string, FieldState<ErrorValue>> = Object.create(null);\n const dirtyNames = new Set<string>();\n const touchedNames = new Set<string>();\n let activeCount = 0;\n let validCount = 0;\n let invalid = false;\n let validating = false;\n for (const record of records.values()) {\n const field: FieldState<ErrorValue> = {\n name: record.name,\n value: readPath(values, record.path),\n defaultValue: readPath(defaults, record.path),\n errors: record.errors,\n status: record.status,\n touched: record.touched,\n dirty: dirty(record),\n active: record.registrations.size > 0,\n registrationCount: record.registrations.size,\n validationRevision: record.validationRevision,\n };\n const previous = state.fields[record.name];\n Object.defineProperty(fields, record.name, {\n value: formValueEqual(field, previous)\n ? previous\n : Object.freeze(field),\n enumerable: true,\n });\n if (field.dirty) dirtyNames.add(record.name);\n if (field.touched) touchedNames.add(record.name);\n if (field.active) {\n activeCount++;\n if (field.status === 'valid') validCount++;\n invalid ||= field.status === 'invalid';\n validating ||= field.status === 'validating';\n }\n }\n const next: FormState<T, ErrorValue> = {\n values: values as Partial<T>,\n defaultValues: defaults as Partial<T>,\n activeValues: activeValues() as Partial<T>,\n fields: formValueEqual(fields, state.fields)\n ? state.fields\n : Object.freeze(fields),\n dirtyFields: sameMembers(dirtyNames, state.dirtyFields)\n ? state.dirtyFields\n : readonlySet(dirtyNames),\n touchedFields: sameMembers(touchedNames, state.touchedFields)\n ? state.touchedFields\n : readonlySet(touchedNames),\n isDirty: dirtyNames.size > 0,\n isTouched: touchedNames.size > 0,\n isValid: activeCount > 0 && validCount === activeCount,\n isInvalid: invalid,\n isValidating: validating,\n isSubmitting: !!submission,\n submitError,\n revision: state.revision,\n };\n if (formValueEqual(next, state)) return state;\n return Object.freeze({ ...next, revision: state.revision + 1 });\n }\n\n function flush() {\n if (depth || notifying || disposed) return;\n notifying = true;\n try {\n while ((pending || cancellations.size) && !disposed) {\n pending = false;\n const events = changes;\n changes = [];\n const previous = state;\n state = buildSnapshot();\n const published = state;\n if (state !== previous) {\n for (const listener of Array.from(listeners)) {\n if (!listeners.has(listener)) continue;\n try {\n listener.notify();\n } catch (error) {\n report(error);\n }\n }\n }\n if (events.length && !disposed && resolveCallbacks().onValuesChange) {\n // One callback per transaction; names are unioned, user source wins,\n // and the final command supplies the transaction's kind.\n const change: FormChange = Object.freeze({\n names: Object.freeze(\n Array.from(new Set(events.flatMap((event) => event.names))),\n ),\n source: events.some((event) => event.source === 'user')\n ? 'user'\n : 'program',\n kind: events[events.length - 1].kind,\n });\n try {\n const result = resolveCallbacks().onValuesChange?.(\n published.values,\n change,\n );\n if (result) Promise.resolve(result).catch(report);\n } catch (error) {\n report(error);\n }\n }\n cancelPending();\n }\n } finally {\n notifying = false;\n }\n }\n\n function batch(fn: () => void) {\n assertLive();\n depth++;\n try {\n fn();\n } finally {\n depth--;\n pending = true;\n flush();\n }\n }\n\n function event(\n names: string[],\n kind: FormChange['kind'],\n source: FormChange['source'] = 'program',\n ) {\n if (names.length) changes.push({ names, kind, source });\n }\n\n function write(\n path: FormPath,\n value: unknown,\n config: SetValueOptions = {},\n ): boolean {\n const normalized = normalizePath(path);\n const previous = values;\n const next = writePath(values, normalized, ownValue(value));\n const record = ensure(normalized);\n const changed = next !== values;\n if (changed) {\n values = next;\n invalidateRelated(record.path, previous, config);\n }\n if (config.touch ?? config.source === 'user') record.touched = true;\n if (changed && (config.notify ?? config.source === 'user')) {\n event([record.name], 'set', config.source);\n }\n return changed;\n }\n\n function setValue(path: FormPath, value: unknown, config?: SetValueOptions) {\n // Validate paths before entering a transaction (no partial invalid writes).\n const normalized = normalizePath(path);\n const prepared = { ...config };\n batch(() => {\n write(normalized, value, prepared);\n });\n }\n\n function setValues(next: Partial<T>, config?: SetValueOptions) {\n assertLive();\n const prepared = { ...config };\n const entries = Object.entries(next).map(\n ([name, value]) => [normalizePath(name), ownValue(value)] as const,\n );\n // Copying input or an invalid array-length write can throw. Check every\n // value/path before the first write, including when inside an outer batch.\n let checked = values;\n for (const [path, value] of entries)\n checked = writePath(checked, path, value);\n batch(() => {\n for (const [path, value] of entries) write(path, value, prepared);\n });\n }\n\n function prepareRegistration(\n path: FormPath,\n config: RegistrationOptions<ErrorValue>,\n ): RegistrationOptions<ErrorValue> {\n const prepared = {\n ...config,\n rules: config.rules?.map((rule) =>\n Object.freeze({\n ...rule,\n ...(rule.enum ? { enum: Object.freeze([...rule.enum]) } : {}),\n }),\n ),\n };\n if (Object.hasOwn(prepared, 'defaultValue')) {\n prepared.defaultValue = ownValue(prepared.defaultValue);\n const normalized = normalizePath(path);\n if (!hasPath(values, normalized) && !hasPath(defaults, normalized)) {\n writePath(values, normalized, prepared.defaultValue);\n writePath(defaults, normalized, prepared.defaultValue);\n }\n }\n return prepared;\n }\n\n function seed(\n record: FieldRecord<ErrorValue>,\n registration: Registration<ErrorValue>,\n ) {\n if (\n registration.defaultConsidered ||\n !Object.hasOwn(registration.options, 'defaultValue')\n )\n return;\n registration.defaultConsidered = true;\n const value = ownValue(registration.options.defaultValue);\n if (!hasPath(values, record.path) && !hasPath(defaults, record.path)) {\n const previous = values;\n values = writePath(values, record.path, value);\n defaults = writePath(defaults, record.path, value);\n record.fieldDefault = { value };\n invalidateRelated(record.path, previous);\n } else if (\n record.fieldDefault &&\n record.registrations.size > 1 &&\n !formValueEqual(record.fieldDefault.value, value)\n ) {\n developmentError(\n `Field \"${record.name}\" registered with conflicting defaultValue; the first default is kept.`,\n );\n }\n }\n\n function register(\n path: FormPath,\n config: RegistrationOptions<ErrorValue> = {},\n ): RegistrationToken<ErrorValue> {\n assertLive();\n const normalized = normalizePath(path);\n const prepared = prepareRegistration(normalized, config);\n const signature = prepared.rulesKey ?? rulesSignature(prepared.rules);\n const record = ensure(normalized);\n const registration: Registration<ErrorValue> = {\n options: prepared,\n signature,\n order: ++order,\n defaultConsidered: false,\n };\n let released = false;\n batch(() => {\n record.registrations.add(registration);\n record.owner = registration;\n seed(record, registration);\n invalidate(record);\n });\n return Object.freeze({\n name: record.name,\n get released() {\n return released || disposed;\n },\n update(next: RegistrationOptions<ErrorValue>) {\n if (released || disposed) return;\n const prepared = prepareRegistration(record.path, next);\n const signature = prepared.rulesKey ?? rulesSignature(prepared.rules);\n const validationChanged =\n registration.signature !== signature ||\n registration.options.validationDelay !== prepared.validationDelay ||\n registration.options.validateTrigger !== prepared.validateTrigger ||\n registration.options.errorPolicy !== prepared.errorPolicy;\n const hasNewDefault =\n !registration.defaultConsidered &&\n Object.hasOwn(prepared, 'defaultValue');\n if (\n !hasNewDefault &&\n !validationChanged &&\n (registration.options.preserve ?? true) ===\n (prepared.preserve ?? true) &&\n registration.options.isEqual === prepared.isEqual\n ) {\n // Keep the latest closures/messages without invalidating equivalent rules.\n registration.options = prepared;\n return;\n }\n batch(() => {\n registration.options = prepared;\n registration.signature = signature;\n registration.order = ++order;\n // Only an ownership change invalidates; equivalent options pushed\n // after every React commit must not cause a publication loop.\n if (record.owner !== registration || validationChanged)\n invalidate(record);\n record.owner = registration;\n seed(record, registration);\n });\n },\n release(config: { deferValueRemoval?: boolean } = {}) {\n if (released || disposed) return;\n released = true;\n batch(() => {\n record.registrations.delete(registration);\n if (record.owner === registration) {\n record.owner = Array.from(record.registrations).sort(\n (a, b) => b.order - a.order,\n )[0];\n invalidate(record);\n }\n if (!record.registrations.size) {\n if (registration.options.preserve === false) {\n const removeValue = () => {\n values = writePath(values, record.path, undefined, true);\n record.touched = false;\n for (const other of records.values()) {\n if (other !== record && related(other.path, record.path))\n invalidate(other);\n }\n if (!hasPath(defaults, record.path))\n records.delete(record.name);\n };\n if (config.deferValueRemoval) {\n // Unregister and abort immediately. Only destructive retention\n // cleanup waits one microtask, allowing Strict Mode's effect\n // replay to reconnect without losing the current value.\n const revision = record.validationRevision;\n queueMicrotask(() => {\n if (\n !disposed &&\n records.get(record.name) === record &&\n !record.registrations.size &&\n record.validationRevision === revision\n )\n batch(removeValue);\n });\n } else removeValue();\n }\n if (\n !hasPath(values, record.path) &&\n !hasPath(defaults, record.path)\n )\n records.delete(record.name);\n }\n });\n },\n });\n }\n\n function replaceDefaults(next: Partial<T>) {\n const entries = Object.keys(next);\n entries.forEach((name) => normalizePath(name));\n defaults = ownValue(next);\n for (const name of entries) ensure(name, false);\n for (const record of records.values()) record.fieldDefault = undefined;\n }\n\n function setDefaultValues(\n next: Partial<T>,\n config: { currentValues?: 'preserve' | 'replace' } = {},\n ) {\n const replace = config.currentValues === 'replace';\n batch(() => {\n replaceDefaults(next);\n if (replace) {\n values = defaults;\n for (const record of records.values()) {\n invalidate(record);\n record.touched = false;\n }\n event(Array.from(records.keys()), 'defaults');\n }\n });\n }\n\n function adoptDefaultValues(\n next: Partial<T>,\n config: {\n when?: 'untouched' | 'clean' | 'always';\n preserveDirty?: boolean;\n } = {},\n ) {\n const when = config.when ?? 'untouched';\n const preserveDirty = config.preserveDirty ?? false;\n batch(() => {\n // Retain edits at the narrowest guarded field path. This also protects a\n // nested edited leaf when the server replaces its containing object.\n const candidates = Array.from(records.values());\n const preserved = candidates\n .filter((record) => {\n // An implicitly tracked parent must not shield untouched siblings\n // when an explicit nested field is the actual edited control.\n if (\n !record.explicit &&\n candidates.some(\n (child) =>\n child.explicit &&\n child.path.length > record.path.length &&\n related(record.path, child.path),\n )\n )\n return false;\n return (\n (when === 'untouched' && record.touched) ||\n (when === 'clean' && dirty(record)) ||\n (preserveDirty && dirty(record))\n );\n })\n .map((record) => ({\n path: record.path,\n exists: hasPath(values, record.path),\n value: readPath(values, record.path),\n }));\n const previous = values;\n replaceDefaults(next);\n values = defaults;\n for (const saved of preserved.sort(\n (a, b) => a.path.length - b.path.length,\n )) {\n values = writePath(values, saved.path, saved.value, !saved.exists);\n }\n const names: string[] = [];\n for (const record of records.values()) {\n if (\n !Object.is(\n readPath(previous, record.path),\n readPath(values, record.path),\n ) ||\n hasPath(previous, record.path) !== hasPath(values, record.path)\n ) {\n invalidate(record);\n names.push(record.name);\n }\n }\n event(names, 'adopt');\n });\n }\n\n function reset(config: { values?: Partial<T> } = {}) {\n batch(() => {\n if (Object.hasOwn(config, 'values')) replaceDefaults(config.values ?? {});\n values = defaults;\n const names = Array.from(records.keys());\n for (const record of records.values()) {\n invalidate(record);\n record.touched = false;\n if (!record.registrations.size && !hasPath(values, record.path))\n records.delete(record.name);\n }\n const previous = submission;\n submission = undefined;\n submitError = undefined;\n if (previous) cancellations.add(previous);\n event(names, 'reset');\n });\n }\n\n function setFieldErrors(path: FormPath, errors: readonly ErrorValue[]) {\n assertLive();\n const copied = errors.length ? Object.freeze([...errors]) : EMPTY_ERRORS;\n batch(() => {\n const record = ensure(path);\n const status = copied.length ? 'invalid' : 'valid';\n if (record.status === status && formValueEqual(record.errors, copied))\n return;\n invalidate(record);\n record.errors = copied;\n record.status = status;\n });\n }\n\n function startValidation(path: FormPath): ValidationToken<ErrorValue> {\n assertLive();\n const record = records.get(getFieldKey(path));\n if (!record?.registrations.size)\n throw new Error('Only active form fields can validate.');\n const controller = new AbortController();\n batch(() => {\n invalidate(record, true);\n record.validation = controller;\n record.status = 'validating';\n });\n const current = () =>\n !disposed &&\n record.validation === controller &&\n !controller.signal.aborted;\n return Object.freeze({\n signal: controller.signal,\n complete(errors: readonly ErrorValue[]) {\n if (!current()) return false;\n const copied = errors.length\n ? Object.freeze([...errors])\n : EMPTY_ERRORS;\n batch(() => {\n record.validation = undefined;\n record.errors = copied;\n record.status = copied.length ? 'invalid' : 'valid';\n });\n return true;\n },\n cancel() {\n if (current())\n batch(() => {\n invalidate(record, true);\n });\n },\n });\n }\n\n function startSubmission(): SubmissionToken | undefined {\n assertLive();\n if (submission) return undefined;\n const controller = new AbortController();\n batch(() => {\n submission = controller;\n submitError = undefined;\n });\n return Object.freeze({\n signal: controller.signal,\n complete(result?: { error: unknown }) {\n if (disposed || submission !== controller || controller.signal.aborted)\n return false;\n const error = result?.error;\n batch(() => {\n submission = undefined;\n submitError = error;\n });\n return true;\n },\n });\n }\n\n function validateRecord(\n record: FieldRecord<ErrorValue>,\n immediate: boolean,\n parentSignal?: AbortSignal,\n ): Promise<ModernFieldValidationResult<ErrorValue>> {\n const result = (errors: readonly ErrorValue[], stale = false) => ({\n name: record.name,\n errors,\n isValid: !stale && !errors.length,\n stale,\n });\n if (parentSignal?.aborted)\n return Promise.resolve(result(EMPTY_ERRORS, true));\n const config = record.owner?.options;\n const rules = config?.rules ?? [];\n const token = startValidation(record.path);\n const revision = record.validationRevision;\n if (token.signal.aborted || parentSignal?.aborted) {\n token.cancel();\n return Promise.resolve(result(EMPTY_ERRORS, true));\n }\n if (!rules.length) {\n const committed = token.complete(EMPTY_ERRORS);\n return Promise.resolve(\n result(\n EMPTY_ERRORS,\n !committed || record.validationRevision !== revision,\n ),\n );\n }\n const value = readPath(values, record.path);\n return new Promise((resolve) => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n let settled = false;\n const finish = (errors: readonly ErrorValue[], stale: boolean) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n token.signal.removeEventListener('abort', abort);\n parentSignal?.removeEventListener('abort', cancel);\n resolve(result(errors, stale));\n };\n const abort = () => finish(EMPTY_ERRORS, true);\n const cancel = () => token.cancel();\n token.signal.addEventListener('abort', abort, { once: true });\n parentSignal?.addEventListener('abort', cancel, { once: true });\n const run = async () => {\n timer = undefined;\n const errors = await runRules(\n value,\n rules,\n {\n name: record.name,\n signal: token.signal,\n getValue: (path) => readPath(values, normalizePath(path)),\n getValues: () => values as Partial<T>,\n },\n config?.errorPolicy ?? options.errorPolicy ?? 'first',\n );\n if (!settled) {\n const committed = token.complete(errors);\n finish(\n Object.freeze(errors),\n !committed ||\n record.validationRevision !== revision ||\n !!parentSignal?.aborted,\n );\n }\n };\n const delay = immediate ? 0 : config?.validationDelay ?? 0;\n if (delay > 0) timer = setTimeout(() => void run(), delay);\n else void run();\n });\n }\n\n function validate(\n paths?: readonly FormPath[],\n config: { immediate?: boolean; signal?: AbortSignal } = {},\n ): Promise<ModernValidationResult<ErrorValue>> {\n assertLive();\n const targets = paths\n ? Array.from(new Set(paths.map(getFieldKey))).map((key) =>\n records.get(key),\n )\n : Array.from(records.values());\n const active = targets.filter(\n (record): record is FieldRecord<ErrorValue> =>\n !!record?.registrations.size,\n );\n let runs: Promise<ModernFieldValidationResult<ErrorValue>>[] = [];\n let revisions: number[] = [];\n batch(() => {\n runs = active.map((record) =>\n validateRecord(record, config.immediate ?? true, config.signal),\n );\n // Capture before publishing: a synchronous subscriber can edit/reset.\n revisions = active.map((record) => record.validationRevision);\n });\n return Promise.all(runs).then((results) => {\n const fields = results.map((result, index) => {\n const record = active[index];\n return record.validationRevision === revisions[index] &&\n !!record.registrations.size &&\n !config.signal?.aborted\n ? result\n : { ...result, stale: true, isValid: false };\n });\n return {\n fields,\n stale: fields.some((field) => field.stale) || !!config.signal?.aborted,\n isValid: !!fields.length && fields.every((field) => field.isValid),\n };\n });\n }\n\n function resolveCallbacks(): FormCallbacks<T> {\n return { ...options, ...binding?.callbacks };\n }\n\n function cancelSubmission() {\n batch(() => {\n if (submission) cancellations.add(submission);\n submission = undefined;\n });\n }\n\n function bindCallbacks(callbacks: FormCallbacks<T>): CallbackBinding<T> {\n assertLive();\n if (binding)\n developmentError(\n 'A second Form root owns this controller; the newest callback binding wins.',\n );\n const own = { callbacks: { ...callbacks } };\n binding = own;\n let released = false;\n return Object.freeze({\n update(next: FormCallbacks<T>) {\n if (!released && !disposed && binding === own)\n own.callbacks = { ...next };\n },\n release() {\n if (released || disposed) return;\n released = true;\n if (binding === own) {\n binding = undefined;\n cancelSubmission();\n }\n },\n });\n }\n\n async function submit(\n config: { include?: 'active' | 'all' } = {},\n ): Promise<ModernSubmitResult<ErrorValue>> {\n const token = startSubmission();\n if (!token) return { status: 'ignored', reason: 'submitting' };\n const include = config.include ?? 'active';\n // Cancellation settles promptly even if a validator or callback ignores its signal.\n return new Promise((resolve) => {\n let settled = false;\n const finish = (result: ModernSubmitResult<ErrorValue>) => {\n if (settled) return;\n settled = true;\n token.signal.removeEventListener('abort', abort);\n resolve(result);\n };\n const abort = () => finish({ status: 'stale' });\n token.signal.addEventListener('abort', abort, { once: true });\n if (token.signal.aborted) {\n abort();\n return;\n }\n const run = async () => {\n const pendingValidation = validate(undefined, { signal: token.signal });\n const validatedRecords = Array.from(records.values()).filter(\n (record) => record.registrations.size,\n );\n const revisions = validatedRecords.map(\n (record) => record.validationRevision,\n );\n const validation = await pendingValidation;\n if (settled) return;\n const changedSinceValidation =\n validatedRecords.length !== validation.fields.length ||\n validatedRecords.length !==\n Array.from(records.values()).filter(\n (record) => record.registrations.size,\n ).length ||\n validatedRecords.some(\n (record, index) =>\n !record.registrations.size ||\n record.validationRevision !== revisions[index],\n );\n if (validation.stale || changedSinceValidation) {\n token.complete();\n finish({ status: 'stale' });\n return;\n }\n const callbacks = resolveCallbacks();\n let result: ModernSubmitResult<ErrorValue>;\n if (!validation.isValid) {\n const errors = Object.fromEntries(\n validation.fields\n .filter((field) => !field.isValid)\n .map((field) => [field.name, field.errors]),\n );\n result = { status: 'invalid', errors: Object.freeze(errors) };\n try {\n await callbacks.onSubmitFailed?.(errors);\n } catch (error) {\n report(error);\n }\n if (!settled) {\n token.complete();\n finish(result);\n }\n return;\n }\n try {\n await callbacks.onSubmit?.(\n (include === 'all' ? values : activeValues()) as Partial<T>,\n { include, signal: token.signal },\n );\n result = { status: 'submitted' };\n } catch (error) {\n if (settled) return;\n // Keep the guard active while failure callbacks run.\n batch(() => {\n submitError = error;\n });\n try {\n await callbacks.onSubmitFailed?.(error);\n } catch (failure) {\n report(failure);\n }\n result = { status: 'failed', error };\n }\n if (!settled) {\n token.complete(\n result.status === 'failed' ? { error: result.error } : undefined,\n );\n finish(result);\n }\n };\n void run().catch((error) => {\n if (!settled) {\n token.complete({ error });\n finish({ status: 'failed', error });\n }\n });\n });\n }\n\n function subscribe(listener: () => void) {\n assertLive();\n const entry = { notify: listener };\n listeners.add(entry);\n return () => {\n listeners.delete(entry);\n };\n }\n\n function dispose() {\n if (disposed) return;\n disposed = true;\n listeners.clear();\n binding = undefined;\n changes = [];\n pending = false;\n for (const record of records.values()) {\n record.registrations.clear();\n record.owner = undefined;\n invalidate(record);\n }\n const previous = submission;\n submission = undefined;\n if (previous) cancellations.add(previous);\n state = buildSnapshot();\n records.clear();\n cancelPending();\n }\n\n for (const name of Object.keys(values)) ensure(name, false);\n state = buildSnapshot();\n\n return Object.freeze({\n [FORM_BACKEND]: 'modern' as const,\n getSnapshot: () => state,\n getFieldSnapshot: (path: FormPath) => state.fields[getFieldKey(path)],\n getValue: (path: FormPath) => readPath(values, normalizePath(path)),\n getValues: () => values as Partial<T>,\n getActiveValues: () => activeValues() as Partial<T>,\n subscribe,\n subscribeSelector<Selected>(\n selector: (snapshot: FormState<T, ErrorValue>) => Selected,\n listener: (value: Selected, previous: Selected) => void,\n isEqual: (a: Selected, b: Selected) => boolean = Object.is,\n ) {\n let selected = selector(state);\n return subscribe(() => {\n const next = selector(state);\n if (isEqual(selected, next)) return;\n const previous = selected;\n selected = next;\n listener(next, previous);\n });\n },\n register,\n validate,\n submit,\n bindCallbacks,\n blur(path: FormPath) {\n const record = records.get(getFieldKey(path));\n if (!record?.registrations.size) return;\n batch(() => {\n record.touched = true;\n if ((record.owner?.options.validateTrigger ?? 'onBlur') === 'onBlur')\n void validateRecord(record, false);\n });\n },\n setValue,\n setValues,\n batch,\n setDefaultValues,\n adoptDefaultValues,\n reset,\n touch(path: FormPath, touched = true) {\n batch(() => {\n ensure(path).touched = touched;\n });\n },\n setFieldErrors,\n clearFieldErrors: (path: FormPath) => setFieldErrors(path, EMPTY_ERRORS),\n startValidation,\n startSubmission,\n setSubmitError(error: unknown) {\n batch(() => {\n submitError = error;\n });\n },\n clearSubmitError() {\n batch(() => {\n submitError = undefined;\n });\n },\n dispose,\n debug: Object.freeze({\n listenerCount: () => listeners.size,\n registrationCount: () =>\n Array.from(records.values()).reduce(\n (count, record) => count + record.registrations.size,\n 0,\n ),\n }),\n }) as FormStore<T, ErrorValue>;\n}\n"],"mappings":";;;;;;AA2DA,MAAM,eAAe,OAAO,OAAO,EAAE,CAAC;AACtC,MAAM,eAAe,OAAO,OAAO,EAAE,CAAC;AACtC,MAAM,eAAe,OAAO,OAAO,OAAO,OAAO,KAAK,CAAC;AAIvD,SAAS,QAAQ,GAAsB,GAA+B;AACpE,QAAO,EACJ,MAAM,GAAG,KAAK,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CACtC,OAAO,KAAK,UAAU,QAAQ,EAAE,OAAO;;;AAS5C,SAAS,cACP,OACA,MACA,UACS;AACT,KAAI,KAAK,SAAU,QAAO;CAC1B,MAAM,SAA8C,MAAM,QAAQ,MAAM,GACpE,EAAE,GACF,EAAE;AACN,KAAI,cAAc,MAAM,IAAI,MAAM,QAAQ,MAAM,CAC9C,MAAK,MAAM,CAAC,KAAK,UAAU,KAAK,UAAU;AACxC,MAAI,CAAC,OAAO,OAAO,OAAO,IAAI,CAAE;AAChC,cACE,QACA,KACA,cACE,QAAQ,IAAI,OAAO,IAAI,EACvB,OACA,SAAS,UAAU,CAA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AAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
|
|
2
|
+
import { FormPath } from "./values.js";
|
|
3
|
+
import { ModernValidationRule } from "./validation.js";
|
|
4
|
+
import { ModernFormBrand } from "../backend.js";
|
|
5
|
+
|
|
6
|
+
//#region src/components/form/Form/modern/types.d.ts
|
|
7
|
+
type FieldStatus = 'unvalidated' | 'validating' | 'valid' | 'invalid';
|
|
8
|
+
interface FieldState<ErrorValue = unknown> {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly value: unknown;
|
|
11
|
+
readonly defaultValue: unknown;
|
|
12
|
+
readonly errors: readonly ErrorValue[];
|
|
13
|
+
readonly status: FieldStatus;
|
|
14
|
+
readonly touched: boolean;
|
|
15
|
+
readonly dirty: boolean;
|
|
16
|
+
readonly active: boolean;
|
|
17
|
+
readonly registrationCount: number;
|
|
18
|
+
readonly validationRevision: number;
|
|
19
|
+
}
|
|
20
|
+
interface FormState<T extends object, ErrorValue = unknown> {
|
|
21
|
+
readonly values: Readonly<Partial<T>>;
|
|
22
|
+
readonly activeValues: Readonly<Partial<T>>;
|
|
23
|
+
readonly defaultValues: Readonly<Partial<T>>;
|
|
24
|
+
readonly fields: Readonly<Record<string, FieldState<ErrorValue>>>;
|
|
25
|
+
readonly dirtyFields: ReadonlySet<string>;
|
|
26
|
+
readonly touchedFields: ReadonlySet<string>;
|
|
27
|
+
readonly isDirty: boolean;
|
|
28
|
+
readonly isTouched: boolean;
|
|
29
|
+
readonly isValid: boolean;
|
|
30
|
+
readonly isInvalid: boolean;
|
|
31
|
+
readonly isValidating: boolean;
|
|
32
|
+
readonly isSubmitting: boolean;
|
|
33
|
+
readonly submitError: unknown;
|
|
34
|
+
readonly revision: number;
|
|
35
|
+
}
|
|
36
|
+
interface RegistrationOptions<ErrorValue = unknown> {
|
|
37
|
+
readonly rules?: readonly ModernValidationRule<ErrorValue>[];
|
|
38
|
+
readonly rulesKey?: string;
|
|
39
|
+
readonly validationDelay?: number;
|
|
40
|
+
readonly validateTrigger?: 'onBlur' | 'onChange' | 'onSubmit';
|
|
41
|
+
readonly errorPolicy?: 'first' | 'all';
|
|
42
|
+
readonly defaultValue?: unknown;
|
|
43
|
+
readonly preserve?: boolean;
|
|
44
|
+
readonly isEqual?: (a: unknown, b: unknown) => boolean;
|
|
45
|
+
}
|
|
46
|
+
interface RegistrationToken<ErrorValue = unknown> {
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly released: boolean;
|
|
49
|
+
update(options: RegistrationOptions<ErrorValue>): void;
|
|
50
|
+
/** React effect replay can reconnect before the queued value removal. */
|
|
51
|
+
release(options?: {
|
|
52
|
+
deferValueRemoval?: boolean;
|
|
53
|
+
}): void;
|
|
54
|
+
}
|
|
55
|
+
interface FormChange {
|
|
56
|
+
readonly names: readonly string[];
|
|
57
|
+
readonly source: 'user' | 'program';
|
|
58
|
+
readonly kind: 'set' | 'reset' | 'adopt' | 'defaults';
|
|
59
|
+
}
|
|
60
|
+
interface SetValueOptions {
|
|
61
|
+
readonly validate?: 'auto' | 'always' | 'never';
|
|
62
|
+
readonly source?: FormChange['source'];
|
|
63
|
+
readonly touch?: boolean;
|
|
64
|
+
readonly notify?: boolean;
|
|
65
|
+
}
|
|
66
|
+
interface ModernSubmitContext {
|
|
67
|
+
readonly include: 'active' | 'all';
|
|
68
|
+
readonly signal: AbortSignal;
|
|
69
|
+
}
|
|
70
|
+
interface FormCallbacks<T extends object> {
|
|
71
|
+
readonly onSubmit?: (values: Readonly<Partial<T>>, context: ModernSubmitContext) => void | Promise<void>;
|
|
72
|
+
readonly onSubmitFailed?: (error: unknown) => void | Promise<void>;
|
|
73
|
+
readonly onValuesChange?: (values: Readonly<Partial<T>>, change: FormChange) => void | Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
interface CallbackBinding<T extends object> {
|
|
76
|
+
update(callbacks: FormCallbacks<T>): void;
|
|
77
|
+
release(): void;
|
|
78
|
+
}
|
|
79
|
+
interface ModernFieldValidationResult<ErrorValue = unknown> {
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly errors: readonly ErrorValue[];
|
|
82
|
+
readonly isValid: boolean;
|
|
83
|
+
readonly stale: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface ModernValidationResult<ErrorValue = unknown> {
|
|
86
|
+
readonly fields: readonly ModernFieldValidationResult<ErrorValue>[];
|
|
87
|
+
readonly isValid: boolean;
|
|
88
|
+
readonly stale: boolean;
|
|
89
|
+
}
|
|
90
|
+
type ModernSubmitResult<ErrorValue = unknown> = {
|
|
91
|
+
status: 'ignored';
|
|
92
|
+
reason: 'submitting';
|
|
93
|
+
} | {
|
|
94
|
+
status: 'stale';
|
|
95
|
+
} | {
|
|
96
|
+
status: 'invalid';
|
|
97
|
+
errors: Readonly<Record<string, readonly ErrorValue[]>>;
|
|
98
|
+
} | {
|
|
99
|
+
status: 'failed';
|
|
100
|
+
error: unknown;
|
|
101
|
+
} | {
|
|
102
|
+
status: 'submitted';
|
|
103
|
+
};
|
|
104
|
+
interface FormStoreOptions<T extends object> extends FormCallbacks<T> {
|
|
105
|
+
readonly errorPolicy?: 'first' | 'all';
|
|
106
|
+
readonly defaultValues?: Partial<T>;
|
|
107
|
+
readonly onValuesChange?: (values: Readonly<Partial<T>>, change: FormChange) => void | Promise<void>;
|
|
108
|
+
readonly onListenerError?: (error: unknown) => void;
|
|
109
|
+
readonly onDevelopmentError?: (message: string) => void;
|
|
110
|
+
}
|
|
111
|
+
/** Internal state token owned by the validation pipeline. */
|
|
112
|
+
interface ValidationToken<ErrorValue> {
|
|
113
|
+
readonly signal: AbortSignal;
|
|
114
|
+
complete(errors: readonly ErrorValue[]): boolean;
|
|
115
|
+
cancel(): void;
|
|
116
|
+
}
|
|
117
|
+
/** A reset/disposal invalidates the token so a late completion cannot publish. */
|
|
118
|
+
interface SubmissionToken {
|
|
119
|
+
readonly signal: AbortSignal;
|
|
120
|
+
complete(result?: {
|
|
121
|
+
error: unknown;
|
|
122
|
+
}): boolean;
|
|
123
|
+
}
|
|
124
|
+
/** Internal until the React/controller API lands in subsequent phases. */
|
|
125
|
+
interface FormStore<T extends object = Record<string, unknown>, ErrorValue = unknown> extends ModernFormBrand {
|
|
126
|
+
getSnapshot(): FormState<T, ErrorValue>;
|
|
127
|
+
getFieldSnapshot(path: FormPath): FieldState<ErrorValue> | undefined;
|
|
128
|
+
getValue<K extends keyof T & string>(name: K): T[K] | undefined;
|
|
129
|
+
getValue(path: FormPath): unknown;
|
|
130
|
+
getValues(): Readonly<Partial<T>>;
|
|
131
|
+
getActiveValues(): Readonly<Partial<T>>;
|
|
132
|
+
subscribe(listener: () => void): () => void;
|
|
133
|
+
subscribeSelector<Selected>(selector: (state: FormState<T, ErrorValue>) => Selected, listener: (value: Selected, previous: Selected) => void, isEqual?: (a: Selected, b: Selected) => boolean): () => void;
|
|
134
|
+
register(path: FormPath, options?: RegistrationOptions<ErrorValue>): RegistrationToken<ErrorValue>;
|
|
135
|
+
validate(paths?: readonly FormPath[], options?: {
|
|
136
|
+
immediate?: boolean;
|
|
137
|
+
signal?: AbortSignal;
|
|
138
|
+
}): Promise<ModernValidationResult<ErrorValue>>;
|
|
139
|
+
submit(options?: {
|
|
140
|
+
include?: 'active' | 'all';
|
|
141
|
+
}): Promise<ModernSubmitResult<ErrorValue>>;
|
|
142
|
+
blur(path: FormPath): void;
|
|
143
|
+
bindCallbacks(callbacks: FormCallbacks<T>): CallbackBinding<T>;
|
|
144
|
+
setValue(path: FormPath, value: unknown, options?: SetValueOptions): void;
|
|
145
|
+
setValues(values: Partial<T>, options?: SetValueOptions): void;
|
|
146
|
+
/** Synchronous notification transaction; completed writes commit even if fn throws. */
|
|
147
|
+
batch(fn: () => void): void;
|
|
148
|
+
setDefaultValues(values: Partial<T>, options?: {
|
|
149
|
+
currentValues?: 'preserve' | 'replace';
|
|
150
|
+
}): void;
|
|
151
|
+
adoptDefaultValues(values: Partial<T>, options?: {
|
|
152
|
+
when?: 'untouched' | 'clean' | 'always';
|
|
153
|
+
preserveDirty?: boolean;
|
|
154
|
+
}): void;
|
|
155
|
+
reset(options?: {
|
|
156
|
+
values?: Partial<T>;
|
|
157
|
+
}): void;
|
|
158
|
+
touch(path: FormPath, touched?: boolean): void;
|
|
159
|
+
setFieldErrors(path: FormPath, errors: readonly ErrorValue[]): void;
|
|
160
|
+
clearFieldErrors(path: FormPath): void;
|
|
161
|
+
startValidation(path: FormPath): ValidationToken<ErrorValue>;
|
|
162
|
+
startSubmission(): SubmissionToken | undefined;
|
|
163
|
+
setSubmitError(error: unknown): void;
|
|
164
|
+
clearSubmitError(): void;
|
|
165
|
+
dispose(): void;
|
|
166
|
+
readonly debug: {
|
|
167
|
+
listenerCount(): number;
|
|
168
|
+
registrationCount(): number;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { FormCallbacks, FormChange, FormState, FormStore, FormStoreOptions, ModernFieldValidationResult, ModernSubmitContext, ModernSubmitResult, ModernValidationResult, SetValueOptions };
|
|
173
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
import { FormPath } from "./values.js";
|
|
3
|
+
|
|
4
|
+
//#region src/components/form/Form/modern/validation.d.ts
|
|
5
|
+
interface ModernValidationContext<T extends object = Record<string, unknown>> {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly signal: AbortSignal;
|
|
8
|
+
getValue(path: FormPath): unknown;
|
|
9
|
+
getValues(): Readonly<Partial<T>>;
|
|
10
|
+
}
|
|
11
|
+
/** Library-neutral: return an error, or throw/reject; undefined/null means success. */
|
|
12
|
+
interface ModernValidationRule<ErrorValue = unknown> {
|
|
13
|
+
required?: boolean;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
len?: number;
|
|
17
|
+
pattern?: RegExp;
|
|
18
|
+
type?: string;
|
|
19
|
+
enum?: readonly unknown[];
|
|
20
|
+
whitespace?: boolean;
|
|
21
|
+
transform?: (value: any) => unknown;
|
|
22
|
+
message?: ErrorValue;
|
|
23
|
+
validator?: (rule: ModernValidationRule<ErrorValue>, value: any, context: ModernValidationContext<any>) => ErrorValue | void | Promise<ErrorValue | void>;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { ModernValidationContext, ModernValidationRule };
|
|
27
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
|
+
import { applyRule } from "../validation.js";
|
|
3
|
+
|
|
4
|
+
//#region src/components/form/Form/modern/validation.ts
|
|
5
|
+
/** Inline rules are equivalent by content; use rulesKey for closure captures. */
|
|
6
|
+
function rulesSignature(rules = []) {
|
|
7
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8
|
+
const signature = (value) => {
|
|
9
|
+
if (typeof value === "function") return `function:${value.toString()}`;
|
|
10
|
+
if (value instanceof RegExp) return `regexp:${value.source}/${value.flags}`;
|
|
11
|
+
if (!value || typeof value !== "object") return `${typeof value}:${String(value)}`;
|
|
12
|
+
if (seen.has(value)) return "cycle";
|
|
13
|
+
seen.add(value);
|
|
14
|
+
const result = JSON.stringify(Object.keys(value).filter((key) => key !== "message").sort().map((key) => [key, signature(Reflect.get(value, key))]));
|
|
15
|
+
seen.delete(value);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
return signature(rules);
|
|
19
|
+
}
|
|
20
|
+
async function runRules(value, rules, context, policy) {
|
|
21
|
+
const errors = [];
|
|
22
|
+
for (const rule of rules) {
|
|
23
|
+
if (context.signal.aborted) break;
|
|
24
|
+
const { validator, transform, ...checks } = rule;
|
|
25
|
+
try {
|
|
26
|
+
const transformed = transform ? transform(value) : value;
|
|
27
|
+
await applyRule(transformed, checks, void 0);
|
|
28
|
+
if (context.signal.aborted) break;
|
|
29
|
+
const result = await validator?.(rule, transformed, context);
|
|
30
|
+
if (result !== void 0 && result !== null && result !== "") errors.push(result);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
errors.push((error instanceof Error ? error.message || rule.message : error) ?? rule.message ?? (rule.required ? "Required" : "Invalid value"));
|
|
33
|
+
}
|
|
34
|
+
if (errors.length && policy === "first") break;
|
|
35
|
+
}
|
|
36
|
+
return errors;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { rulesSignature, runRules };
|
|
41
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","names":[],"sources":["../../../../../src/components/form/Form/modern/validation.ts"],"sourcesContent":["import { applyRule } from '../validation';\n\nimport type { FormPath } from './values';\n\nexport interface ModernValidationContext<\n T extends object = Record<string, unknown>,\n> {\n readonly name: string;\n readonly signal: AbortSignal;\n getValue(path: FormPath): unknown;\n getValues(): Readonly<Partial<T>>;\n}\n\n/** Library-neutral: return an error, or throw/reject; undefined/null means success. */\nexport interface ModernValidationRule<ErrorValue = unknown> {\n required?: boolean;\n min?: number;\n max?: number;\n len?: number;\n pattern?: RegExp;\n type?: string;\n enum?: readonly unknown[];\n whitespace?: boolean;\n transform?: (value: any) => unknown;\n message?: ErrorValue;\n validator?: (\n rule: ModernValidationRule<ErrorValue>,\n value: any,\n context: ModernValidationContext<any>,\n ) => ErrorValue | void | Promise<ErrorValue | void>;\n}\n\n/** Inline rules are equivalent by content; use rulesKey for closure captures. */\nexport function rulesSignature<ErrorValue>(\n rules: readonly ModernValidationRule<ErrorValue>[] = [],\n): string {\n const seen = new Set<object>();\n const signature = (value: unknown): string => {\n if (typeof value === 'function') return `function:${value.toString()}`;\n if (value instanceof RegExp) return `regexp:${value.source}/${value.flags}`;\n if (!value || typeof value !== 'object')\n return `${typeof value}:${String(value)}`;\n if (seen.has(value)) return 'cycle';\n seen.add(value);\n const result = JSON.stringify(\n Object.keys(value)\n .filter((key) => key !== 'message')\n .sort()\n .map((key) => [key, signature(Reflect.get(value, key))]),\n );\n seen.delete(value);\n return result;\n };\n return signature(rules);\n}\n\nexport async function runRules<ErrorValue>(\n value: unknown,\n rules: readonly ModernValidationRule<ErrorValue>[],\n context: ModernValidationContext<any>,\n policy: 'first' | 'all',\n): Promise<ErrorValue[]> {\n const errors: ErrorValue[] = [];\n for (const rule of rules) {\n if (context.signal.aborted) break;\n const { validator, transform, ...checks } = rule;\n try {\n const transformed = transform ? transform(value) : value;\n await applyRule(transformed, checks, undefined);\n if (context.signal.aborted) break;\n const result = await validator?.(rule, transformed, context);\n if (result !== undefined && result !== null && result !== '')\n errors.push(result as ErrorValue);\n } catch (error) {\n errors.push(\n ((error instanceof Error ? error.message || rule.message : error) ??\n rule.message ??\n (rule.required ? 'Required' : 'Invalid value')) as ErrorValue,\n );\n }\n if (errors.length && policy === 'first') break;\n }\n return errors;\n}\n"],"mappings":";;;;;AAiCA,SAAgB,eACd,QAAqD,EAAE,EAC/C;CACR,MAAM,uBAAO,IAAI,KAAa;CAC9B,MAAM,aAAa,UAA2B;AAC5C,MAAI,OAAO,UAAU,WAAY,QAAO,YAAY,MAAM,UAAU;AACpE,MAAI,iBAAiB,OAAQ,QAAO,UAAU,MAAM,OAAO,GAAG,MAAM;AACpE,MAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,QAAO,GAAG,OAAO,MAAM,GAAG,OAAO,MAAM;AACzC,MAAI,KAAK,IAAI,MAAM,CAAE,QAAO;AAC5B,OAAK,IAAI,MAAM;EACf,MAAM,SAAS,KAAK,UAClB,OAAO,KAAK,MAAM,CACf,QAAQ,QAAQ,QAAQ,UAAU,CAClC,MAAM,CACN,KAAK,QAAQ,CAAC,KAAK,UAAU,QAAQ,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,CAC3D;AACD,OAAK,OAAO,MAAM;AAClB,SAAO;;AAET,QAAO,UAAU,MAAM;;AAGzB,eAAsB,SACpB,OACA,OACA,SACA,QACuB;CACvB,MAAM,SAAuB,EAAE;AAC/B,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,QAAQ,OAAO,QAAS;EAC5B,MAAM,EAAE,WAAW,WAAW,GAAG,WAAW;AAC5C,MAAI;GACF,MAAM,cAAc,YAAY,UAAU,MAAM,GAAG;AACnD,SAAM,UAAU,aAAa,QAAQ,OAAU;AAC/C,OAAI,QAAQ,OAAO,QAAS;GAC5B,MAAM,SAAS,MAAM,YAAY,MAAM,aAAa,QAAQ;AAC5D,OAAI,WAAW,UAAa,WAAW,QAAQ,WAAW,GACxD,QAAO,KAAK,OAAqB;WAC5B,OAAO;AACd,UAAO,MACH,iBAAiB,QAAQ,MAAM,WAAW,KAAK,UAAU,UACzD,KAAK,YACJ,KAAK,WAAW,aAAa,iBACjC;;AAEH,MAAI,OAAO,UAAU,WAAW,QAAS;;AAE3C,QAAO"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/form/Form/modern/values.d.ts
|
|
3
|
+
/** A string is a literal field name; tuples explicitly address nested values. */
|
|
4
|
+
type FormPath = string | readonly (string | number)[];
|
|
5
|
+
//#endregion
|
|
6
|
+
export { FormPath };
|
|
7
|
+
//# sourceMappingURL=values.d.ts.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
|
+
//#region src/components/form/Form/modern/values.ts
|
|
3
|
+
const ownedContainers = /* @__PURE__ */ new WeakSet();
|
|
4
|
+
function freezeContainer(value) {
|
|
5
|
+
ownedContainers.add(value);
|
|
6
|
+
return Object.freeze(value);
|
|
7
|
+
}
|
|
8
|
+
function isPlainObject(value) {
|
|
9
|
+
if (!value || typeof value !== "object") return false;
|
|
10
|
+
const prototype = Object.getPrototypeOf(value);
|
|
11
|
+
return prototype === Object.prototype || prototype === null;
|
|
12
|
+
}
|
|
13
|
+
function isContainer(value) {
|
|
14
|
+
return Array.isArray(value) || isPlainObject(value);
|
|
15
|
+
}
|
|
16
|
+
function enumerableKeys(value) {
|
|
17
|
+
return Reflect.ownKeys(value).filter((key) => Object.prototype.propertyIsEnumerable.call(value, key));
|
|
18
|
+
}
|
|
19
|
+
/** Preserve the special non-enumerable descriptor of an array's length. */
|
|
20
|
+
function defineValue(container, key, value) {
|
|
21
|
+
Object.defineProperty(container, key, Array.isArray(container) && key === "length" ? { value } : {
|
|
22
|
+
value,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
configurable: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function emptyCopy(value) {
|
|
29
|
+
return Array.isArray(value) ? new Array(value.length) : Object.create(Object.getPrototypeOf(value));
|
|
30
|
+
}
|
|
31
|
+
function copyContainer(value) {
|
|
32
|
+
const copy = emptyCopy(value);
|
|
33
|
+
for (const key of enumerableKeys(value)) defineValue(copy, key, Reflect.get(value, key));
|
|
34
|
+
return copy;
|
|
35
|
+
}
|
|
36
|
+
/** The ADR's default dirty comparator: Object.is, then one structural level. */
|
|
37
|
+
function formValueEqual(a, b) {
|
|
38
|
+
if (Object.is(a, b)) return true;
|
|
39
|
+
if (!isContainer(a) || !isContainer(b)) return false;
|
|
40
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
41
|
+
if (Array.isArray(a) && Array.isArray(b) && a.length !== b.length) return false;
|
|
42
|
+
const keys = enumerableKeys(a);
|
|
43
|
+
return keys.length === enumerableKeys(b).length && keys.every((key) => Object.hasOwn(b, key) && Object.is(Reflect.get(a, key), Reflect.get(b, key)));
|
|
44
|
+
}
|
|
45
|
+
function normalizePath(path) {
|
|
46
|
+
const parts = typeof path === "string" ? [path] : path;
|
|
47
|
+
if (!parts.length) throw new Error("A form field path must not be empty.");
|
|
48
|
+
return Object.freeze(Array.from(parts, (part) => {
|
|
49
|
+
if (typeof part !== "string" && (!Number.isSafeInteger(part) || part < 0)) throw new Error("A numeric form path segment must be a non-negative safe integer.");
|
|
50
|
+
const key = String(part);
|
|
51
|
+
if (key === "__proto__" || key === "prototype" || key === "constructor") throw new Error(`Unsafe form path segment: ${key}`);
|
|
52
|
+
return key;
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
/** Escaping keeps literal dotted names distinct from nested tuple paths. */
|
|
56
|
+
function getFieldKey(path) {
|
|
57
|
+
return normalizePath(path).map((part) => part.replace(/\\/g, "\\\\").replace(/\./g, "\\.")).join(".");
|
|
58
|
+
}
|
|
59
|
+
function readPath(root, path) {
|
|
60
|
+
let value = root;
|
|
61
|
+
for (const key of path) {
|
|
62
|
+
if (!isContainer(value) || !Object.hasOwn(value, key)) return void 0;
|
|
63
|
+
value = Reflect.get(value, key);
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
function hasPath(root, path) {
|
|
68
|
+
const parent = readPath(root, path.slice(0, -1));
|
|
69
|
+
return isContainer(parent) && Object.hasOwn(parent, path[path.length - 1]);
|
|
70
|
+
}
|
|
71
|
+
/** Copy just the ancestor chain. Array deletion leaves indices in place. */
|
|
72
|
+
function writePath(root, path, value, remove = false) {
|
|
73
|
+
function write(current, depth) {
|
|
74
|
+
const key = path[depth];
|
|
75
|
+
const container = isContainer(current) ? current : void 0;
|
|
76
|
+
const exists = !!container && Object.hasOwn(container, key);
|
|
77
|
+
const previous = exists ? Reflect.get(container, key) : void 0;
|
|
78
|
+
if (remove && !exists) return current;
|
|
79
|
+
const last = depth === path.length - 1;
|
|
80
|
+
const next = last ? value : write(previous, depth + 1);
|
|
81
|
+
if (!remove && exists && Object.is(previous, next)) return current;
|
|
82
|
+
if (remove && !last && Object.is(previous, next)) return current;
|
|
83
|
+
if (remove && last && Array.isArray(container) && key === "length") return current;
|
|
84
|
+
const copy = container ? copyContainer(container) : depth > 0 && /^(0|[1-9]\d*)$/.test(key) ? [] : {};
|
|
85
|
+
if (remove && last) Reflect.deleteProperty(copy, key);
|
|
86
|
+
else defineValue(copy, key, next);
|
|
87
|
+
return freezeContainer(copy);
|
|
88
|
+
}
|
|
89
|
+
return write(root, 0);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Own plain data without freezing caller-owned objects. Non-plain values (dates,
|
|
93
|
+
* files, ReactNode errors, etc.) are opaque and must be treated as immutable.
|
|
94
|
+
* Reusing an input reference means reusing its value, just like React state.
|
|
95
|
+
*/
|
|
96
|
+
function createValueSnapshotter() {
|
|
97
|
+
const copies = /* @__PURE__ */ new WeakMap();
|
|
98
|
+
function snapshot(value) {
|
|
99
|
+
const pending = /* @__PURE__ */ new WeakMap();
|
|
100
|
+
const entries = [];
|
|
101
|
+
function clone(input) {
|
|
102
|
+
if (!isContainer(input) || ownedContainers.has(input)) return input;
|
|
103
|
+
if (copies.has(input)) return copies.get(input);
|
|
104
|
+
if (pending.has(input)) return pending.get(input);
|
|
105
|
+
const copy = emptyCopy(input);
|
|
106
|
+
pending.set(input, copy);
|
|
107
|
+
entries.push([input, copy]);
|
|
108
|
+
for (const key of enumerableKeys(input)) defineValue(copy, key, clone(Reflect.get(input, key)));
|
|
109
|
+
return copy;
|
|
110
|
+
}
|
|
111
|
+
const result = clone(value);
|
|
112
|
+
for (const [input, copy] of entries) {
|
|
113
|
+
freezeContainer(copy);
|
|
114
|
+
copies.set(input, copy);
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
return snapshot;
|
|
119
|
+
}
|
|
120
|
+
/** Object.freeze(new Set()) still permits add/delete. Hide the writable set. */
|
|
121
|
+
function readonlySet(values) {
|
|
122
|
+
const set = new Set(values);
|
|
123
|
+
const view = Object.freeze({
|
|
124
|
+
get size() {
|
|
125
|
+
return set.size;
|
|
126
|
+
},
|
|
127
|
+
has: (value) => set.has(value),
|
|
128
|
+
entries: () => set.entries(),
|
|
129
|
+
keys: () => set.keys(),
|
|
130
|
+
values: () => set.values(),
|
|
131
|
+
[Symbol.iterator]: () => set[Symbol.iterator](),
|
|
132
|
+
forEach: (callback, thisArg) => {
|
|
133
|
+
set.forEach((value) => callback.call(thisArg, value, value, view));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return view;
|
|
137
|
+
}
|
|
138
|
+
function sameMembers(a, b) {
|
|
139
|
+
return a.size === b.size && Array.from(a).every((value) => b.has(value));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
export { createValueSnapshotter, defineValue, formValueEqual, freezeContainer, getFieldKey, hasPath, isPlainObject, normalizePath, readPath, readonlySet, sameMembers, writePath };
|
|
144
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.js","names":[],"sources":["../../../../../src/components/form/Form/modern/values.ts"],"sourcesContent":["/** A string is a literal field name; tuples explicitly address nested values. */\nexport type FormPath = string | readonly (string | number)[];\n\ntype Container = Record<string, unknown> | unknown[];\n\n// Path copies and ingress copies share ownership, including across stores.\n// A WeakSet does not keep old snapshots alive after subscribers release them.\nconst ownedContainers = new WeakSet<object>();\n\nexport function freezeContainer<T extends object>(value: T): T {\n ownedContainers.add(value);\n return Object.freeze(value);\n}\n\nexport function isPlainObject(\n value: unknown,\n): value is Record<string, unknown> {\n if (!value || typeof value !== 'object') return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction isContainer(value: unknown): value is Container {\n return Array.isArray(value) || isPlainObject(value);\n}\n\nfunction enumerableKeys(value: object): (string | symbol)[] {\n return Reflect.ownKeys(value).filter((key) =>\n Object.prototype.propertyIsEnumerable.call(value, key),\n );\n}\n\n/** Preserve the special non-enumerable descriptor of an array's length. */\nexport function defineValue(\n container: object,\n key: PropertyKey,\n value: unknown,\n) {\n Object.defineProperty(\n container,\n key,\n Array.isArray(container) && key === 'length'\n ? { value }\n : { value, enumerable: true, writable: true, configurable: true },\n );\n}\n\nfunction emptyCopy(value: Container): Container {\n return Array.isArray(value)\n ? new Array(value.length)\n : Object.create(Object.getPrototypeOf(value));\n}\n\nfunction copyContainer(value: Container): Container {\n const copy = emptyCopy(value);\n for (const key of enumerableKeys(value))\n defineValue(copy, key, Reflect.get(value, key));\n return copy;\n}\n\n/** The ADR's default dirty comparator: Object.is, then one structural level. */\nexport function formValueEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (!isContainer(a) || !isContainer(b)) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n if (Array.isArray(a) && Array.isArray(b) && a.length !== b.length)\n return false;\n const keys = enumerableKeys(a);\n return (\n keys.length === enumerableKeys(b).length &&\n keys.every(\n (key) =>\n Object.hasOwn(b, key) &&\n Object.is(Reflect.get(a, key), Reflect.get(b, key)),\n )\n );\n}\n\nexport function normalizePath(path: FormPath): readonly string[] {\n const parts = typeof path === 'string' ? [path] : path;\n if (!parts.length) throw new Error('A form field path must not be empty.');\n return Object.freeze(\n Array.from(parts, (part) => {\n if (\n typeof part !== 'string' &&\n (!Number.isSafeInteger(part) || part < 0)\n ) {\n throw new Error(\n 'A numeric form path segment must be a non-negative safe integer.',\n );\n }\n const key = String(part);\n if (key === '__proto__' || key === 'prototype' || key === 'constructor') {\n throw new Error(`Unsafe form path segment: ${key}`);\n }\n return key;\n }),\n );\n}\n\n/** Escaping keeps literal dotted names distinct from nested tuple paths. */\nexport function getFieldKey(path: FormPath): string {\n return normalizePath(path)\n .map((part) => part.replace(/\\\\/g, '\\\\\\\\').replace(/\\./g, '\\\\.'))\n .join('.');\n}\n\nexport function readPath(root: unknown, path: readonly string[]): unknown {\n let value = root;\n for (const key of path) {\n if (!isContainer(value) || !Object.hasOwn(value, key)) return undefined;\n value = Reflect.get(value, key);\n }\n return value;\n}\n\nexport function hasPath(root: unknown, path: readonly string[]): boolean {\n const parent = readPath(root, path.slice(0, -1));\n return isContainer(parent) && Object.hasOwn(parent, path[path.length - 1]);\n}\n\n/** Copy just the ancestor chain. Array deletion leaves indices in place. */\nexport function writePath(\n root: object,\n path: readonly string[],\n value: unknown,\n remove = false,\n): object {\n function write(current: unknown, depth: number): unknown {\n const key = path[depth];\n const container = isContainer(current) ? current : undefined;\n const exists = !!container && Object.hasOwn(container, key);\n const previous = exists ? Reflect.get(container!, key) : undefined;\n if (remove && !exists) return current;\n const last = depth === path.length - 1;\n const next = last ? value : write(previous, depth + 1);\n if (!remove && exists && Object.is(previous, next)) return current;\n if (remove && !last && Object.is(previous, next)) return current;\n // Array length cannot be removed, even for preserve:false registrations.\n if (remove && last && Array.isArray(container) && key === 'length')\n return current;\n const copy: Container = container\n ? copyContainer(container)\n : depth > 0 && /^(0|[1-9]\\d*)$/.test(key)\n ? []\n : {};\n if (remove && last) Reflect.deleteProperty(copy, key);\n else defineValue(copy, key, next);\n return freezeContainer(copy);\n }\n return write(root, 0) as object;\n}\n\n/**\n * Own plain data without freezing caller-owned objects. Non-plain values (dates,\n * files, ReactNode errors, etc.) are opaque and must be treated as immutable.\n * Reusing an input reference means reusing its value, just like React state.\n */\nexport function createValueSnapshotter() {\n const copies = new WeakMap<object, unknown>();\n function snapshot<T>(value: T): T {\n // Commit the ownership cache only after the entire graph copied. A throwing\n // getter must not leave an incomplete, mutable snapshot cached for a retry.\n const pending = new WeakMap<object, object>();\n const entries: [object, object][] = [];\n function clone(input: unknown): unknown {\n if (!isContainer(input) || ownedContainers.has(input)) return input;\n if (copies.has(input)) return copies.get(input);\n if (pending.has(input)) return pending.get(input);\n const copy = emptyCopy(input);\n pending.set(input, copy);\n entries.push([input, copy]);\n for (const key of enumerableKeys(input)) {\n defineValue(copy, key, clone(Reflect.get(input, key)));\n }\n return copy;\n }\n const result = clone(value);\n for (const [input, copy] of entries) {\n freezeContainer(copy);\n copies.set(input, copy);\n }\n return result as T;\n }\n return snapshot;\n}\n\n/** Object.freeze(new Set()) still permits add/delete. Hide the writable set. */\nexport function readonlySet<T>(values: Iterable<T>): ReadonlySet<T> {\n const set = new Set(values);\n const view: ReadonlySet<T> = Object.freeze({\n get size() {\n return set.size;\n },\n has: (value: T) => set.has(value),\n entries: () => set.entries(),\n keys: () => set.keys(),\n values: () => set.values(),\n [Symbol.iterator]: () => set[Symbol.iterator](),\n forEach: (\n callback: (value: T, key: T, set: ReadonlySet<T>) => void,\n thisArg?: unknown,\n ) => {\n set.forEach((value) => callback.call(thisArg, value, value, view));\n },\n });\n return view;\n}\n\nexport function sameMembers<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean {\n return a.size === b.size && Array.from(a).every((value) => b.has(value));\n}\n"],"mappings":";;AAOA,MAAM,kCAAkB,IAAI,SAAiB;AAE7C,SAAgB,gBAAkC,OAAa;AAC7D,iBAAgB,IAAI,MAAM;AAC1B,QAAO,OAAO,OAAO,MAAM;;AAG7B,SAAgB,cACd,OACkC;AAClC,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;CAChD,MAAM,YAAY,OAAO,eAAe,MAAM;AAC9C,QAAO,cAAc,OAAO,aAAa,cAAc;;AAGzD,SAAS,YAAY,OAAoC;AACvD,QAAO,MAAM,QAAQ,MAAM,IAAI,cAAc,MAAM;;AAGrD,SAAS,eAAe,OAAoC;AAC1D,QAAO,QAAQ,QAAQ,MAAM,CAAC,QAAQ,QACpC,OAAO,UAAU,qBAAqB,KAAK,OAAO,IAAI,CACvD;;;AAIH,SAAgB,YACd,WACA,KACA,OACA;AACA,QAAO,eACL,WACA,KACA,MAAM,QAAQ,UAAU,IAAI,QAAQ,WAChC,EAAE,OAAO,GACT;EAAE;EAAO,YAAY;EAAM,UAAU;EAAM,cAAc;EAAM,CACpE;;AAGH,SAAS,UAAU,OAA6B;AAC9C,QAAO,MAAM,QAAQ,MAAM,GACvB,IAAI,MAAM,MAAM,OAAO,GACvB,OAAO,OAAO,OAAO,eAAe,MAAM,CAAC;;AAGjD,SAAS,cAAc,OAA6B;CAClD,MAAM,OAAO,UAAU,MAAM;AAC7B,MAAK,MAAM,OAAO,eAAe,MAAM,CACrC,aAAY,MAAM,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC;AACjD,QAAO;;;AAIT,SAAgB,eAAe,GAAY,GAAqB;AAC9D,KAAI,OAA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BAAgB,IAAI,MAAM,CAAE,QAAO;AAC9D,OAAI,OAAO,IAAI,MAAM,CAAE,QAAO,OAAO,IAAI,MAAM;AAC/C,OAAI,QAAQ,IAAI,MAAM,CAAE,QAAO,QAAQ,IAAI,MAAM;GACjD,MAAM,OAAO,UAAU,MAAM;AAC7B,WAAQ,IAAI,OAAO,KAAK;AACxB,WAAQ,KAAK,CAAC,OAAO,KAAK,CAAC;AAC3B,QAAK,MAAM,OAAO,eAAe,MAAM,CACrC,aAAY,MAAM,KAAK,MAAM,QAAQ,IAAI,OAAO,IAAI,CAAC,CAAC;AAExD,UAAO;;EAET,MAAM,SAAS,MAAM,MAAM;AAC3B,OAAK,MAAM,CAAC,OAAO,SAAS,SAAS;AACnC,mBAAgB,KAAK;AACrB,UAAO,IAAI,OAAO,KAAK;;AAEzB,SAAO;;AAET,QAAO;;;AAIT,SAAgB,YAAe,QAAqC;CAClE,MAAM,MAAM,IAAI,IAAI,OAAO;CAC3B,MAAM,OAAuB,OAAO,OAAO;EACzC,IAAI,OAAO;AACT,UAAO,IAAI;;EAEb,MAAM,UAAa,IAAI,IAAI,MAAM;EACjC,eAAe,IAAI,SAAS;EAC5B,YAAY,IAAI,MAAM;EACtB,cAAc,IAAI,QAAQ;GACzB,OAAO,iBAAiB,IAAI,OAAO,WAAW;EAC/C,UACE,UACA,YACG;AACH,OAAI,SAAS,UAAU,SAAS,KAAK,SAAS,OAAO,OAAO,KAAK,CAAC;;EAErE,CAAC;AACF,QAAO;;AAGT,SAAgB,YAAe,GAAmB,GAA4B;AAC5E,QAAO,EAAE,SAAS,EAAE,QAAQ,MAAM,KAAK,EAAE,CAAC,OAAO,UAAU,EAAE,IAAI,MAAM,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { FieldCoreProps, NecessityIndicator, ValidateTrigger, ValidationProps, ValidationState } from "../../../../shared/form.js";
|
|
3
3
|
import "../../../../shared/index.js";
|
|
4
4
|
import { CubeFieldData, FieldTypes } from "../types.js";
|
|
5
|
+
import { FormController } from "../modern/controller.js";
|
|
5
6
|
import { CubeFormInstance } from "../use-form.js";
|
|
6
7
|
import { ReactNode } from "react";
|
|
7
8
|
|
|
@@ -10,7 +11,7 @@ interface UseFieldProps<T extends FieldTypes> extends FieldCoreProps, Validation
|
|
|
10
11
|
/** The initial value of the input. */
|
|
11
12
|
defaultValue?: any;
|
|
12
13
|
/** The form instance */
|
|
13
|
-
form?: CubeFormInstance<T>;
|
|
14
|
+
form?: CubeFormInstance<T> | FormController<any>;
|
|
14
15
|
/**
|
|
15
16
|
* The validation state of the field
|
|
16
17
|
* @deprecated Use `isInvalid` / `isValid` instead.
|
|
@@ -18,6 +19,8 @@ interface UseFieldProps<T extends FieldTypes> extends FieldCoreProps, Validation
|
|
|
18
19
|
validationState?: ValidationState;
|
|
19
20
|
/** Whether to show valid state */
|
|
20
21
|
showValid?: boolean;
|
|
22
|
+
/** Explicit loading presentation overrides the modern validation state. */
|
|
23
|
+
isLoading?: boolean;
|
|
21
24
|
/** On which event perform the validation for the field */
|
|
22
25
|
validateTrigger?: ValidateTrigger;
|
|
23
26
|
/**
|