@cube-dev/ui-kit 0.180.0 → 0.181.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 +14 -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 +3 -3
- 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 +1 -1
- package/dist/components/actions/ItemButton/ItemButton.js +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 +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 +1 -1
- 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 +2 -2
- 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 +2 -2
- 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.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 +3 -1
- package/dist/components/fields/Checkbox/Checkbox.js +4 -5
- 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 +1 -1
- 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.d.ts +1 -1
- package/dist/components/fields/ColorInput/ColorInput.js +1 -1
- package/dist/components/fields/ColorInput/ColorInput.js.map +1 -1
- package/dist/components/fields/ColorPicker/ColorPicker.d.ts +1 -1
- package/dist/components/fields/ColorPicker/ColorPicker.js +1 -1
- package/dist/components/fields/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/components/fields/ColorSwatch/ColorSwatch.js +1 -1
- package/dist/components/fields/ColorSwatchGroup/ColorSwatchGroup.d.ts +1 -1
- package/dist/components/fields/ColorSwatchGroup/ColorSwatchGroup.js +1 -1
- package/dist/components/fields/ColorSwatchGroup/ColorSwatchGroup.js.map +1 -1
- package/dist/components/fields/ComboBox/ComboBox.d.ts +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +8 -2
- package/dist/components/fields/ComboBox/ComboBox.js.map +1 -1
- package/dist/components/fields/CommandTextArea/CommandTextArea.js +1 -1
- package/dist/components/fields/CommandTextArea/caretPosition.js +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/DatePickerSegment.js +1 -1
- package/dist/components/fields/DatePicker/DateRangePicker.d.ts +4 -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 +4 -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 +4 -1
- package/dist/components/fields/FileInput/FileInput.js +38 -29
- package/dist/components/fields/FileInput/FileInput.js.map +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.d.ts +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.js +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.js.map +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.d.ts +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.js +8 -5
- 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.d.ts +1 -1
- package/dist/components/fields/ListBox/ListBox.js +5 -3
- package/dist/components/fields/ListBox/ListBox.js.map +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 +3 -1
- package/dist/components/fields/NumberInput/NumberInput.js +1 -1
- 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.d.ts +1 -1
- package/dist/components/fields/Picker/Picker.js +8 -5
- 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 +1 -1
- 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.d.ts +1 -1
- package/dist/components/fields/Select/Select.js +16 -2
- 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 +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 +3 -1
- 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.d.ts +2 -0
- package/dist/components/fields/TextArea/TextArea.js +1 -1
- package/dist/components/fields/TextArea/TextArea.js.map +1 -1
- package/dist/components/fields/TextInput/TextInput.d.ts +4 -1
- package/dist/components/fields/TextInput/TextInput.js +1 -1
- package/dist/components/fields/TextInput/TextInput.js.map +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.d.ts +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js.map +1 -1
- package/dist/components/fields/TriggerActions.js +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.d.ts +2 -0
- package/dist/components/form/Form/Field.js +1 -1
- package/dist/components/form/Form/Field.js.map +1 -1
- package/dist/components/form/Form/Form.js +1 -1
- package/dist/components/form/Form/ModernFormRoot.d.ts +9 -4
- package/dist/components/form/Form/ModernFormRoot.js +13 -6
- package/dist/components/form/Form/ModernFormRoot.js.map +1 -1
- package/dist/components/form/Form/ResetButton/ResetButton.d.ts +1 -1
- package/dist/components/form/Form/ResetButton/ResetButton.js +1 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.d.ts +3 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.js +2 -2
- package/dist/components/form/Form/SubmitButton/SubmitButton.js.map +1 -1
- package/dist/components/form/Form/SubmitError.d.ts +8 -2
- package/dist/components/form/Form/SubmitError.js +11 -4
- package/dist/components/form/Form/SubmitError.js.map +1 -1
- package/dist/components/form/Form/backend.js +1 -1
- package/dist/components/form/Form/index.d.ts +12 -8
- package/dist/components/form/Form/index.js +4 -2
- package/dist/components/form/Form/index.js.map +1 -1
- package/dist/components/form/Form/modern/actions.js +27 -9
- package/dist/components/form/Form/modern/actions.js.map +1 -1
- package/dist/components/form/Form/modern/context.d.ts +3 -0
- package/dist/components/form/Form/modern/context.js +1 -1
- package/dist/components/form/Form/modern/controller.d.ts +19 -8
- package/dist/components/form/Form/modern/controller.js +15 -4
- package/dist/components/form/Form/modern/controller.js.map +1 -1
- package/dist/components/form/Form/modern/field-binding.js +23 -5
- package/dist/components/form/Form/modern/field-binding.js.map +1 -1
- package/dist/components/form/Form/modern/field.d.ts +30 -0
- package/dist/components/form/Form/modern/field.js +23 -0
- package/dist/components/form/Form/modern/field.js.map +1 -0
- package/dist/components/form/Form/modern/path-types.d.ts +5 -1
- package/dist/components/form/Form/modern/react.d.ts +7 -2
- package/dist/components/form/Form/modern/react.js +21 -3
- package/dist/components/form/Form/modern/react.js.map +1 -1
- package/dist/components/form/Form/modern/read-types.d.ts +11 -0
- package/dist/components/form/Form/modern/store.js +82 -19
- package/dist/components/form/Form/modern/store.js.map +1 -1
- package/dist/components/form/Form/modern/types.d.ts +39 -23
- package/dist/components/form/Form/modern/validation.d.ts +2 -1
- package/dist/components/form/Form/modern/validation.js +4 -4
- package/dist/components/form/Form/modern/validation.js.map +1 -1
- package/dist/components/form/Form/modern/values.js +16 -2
- package/dist/components/form/Form/modern/values.js.map +1 -1
- package/dist/components/form/Form/use-field/types.d.ts +1 -1
- package/dist/components/form/Form/use-field/use-field-binding.js +12 -8
- package/dist/components/form/Form/use-field/use-field-binding.js.map +1 -1
- package/dist/components/form/Form/use-field/use-field-props.d.ts +3 -1
- package/dist/components/form/Form/use-field/use-field-props.js +16 -5
- 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 +3 -1
- package/dist/components/form/Form/use-field/use-field.js +1 -1
- package/dist/components/form/Form/use-field/use-field.js.map +1 -1
- package/dist/components/form/Form/use-form.d.ts +1 -1
- package/dist/components/form/Form/use-form.js +1 -1
- package/dist/components/form/Form/validation.js +1 -1
- package/dist/components/form/Label.js +1 -1
- package/dist/components/form/index.d.ts +6 -5
- 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 +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 -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 +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 +8 -2
- package/dist/components/overlays/Modal/Overlay.js.map +1 -1
- package/dist/components/overlays/Modal/Popover.js +4 -2
- package/dist/components/overlays/Modal/Popover.js.map +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 +12 -2
- package/dist/components/overlays/Tooltip/TooltipTrigger.js.map +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 +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 +7 -5
- package/dist/index.js +2 -2
- 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 +13 -5
- 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 +1 -1
- 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/escapePropagation.js +39 -0
- package/dist/utils/react/escapePropagation.js.map +1 -0
- 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/programmaticFocus.js +58 -0
- package/dist/utils/react/programmaticFocus.js.map +1 -0
- 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/useOverlayEscapeGuard.js +41 -0
- package/dist/utils/react/useOverlayEscapeGuard.js.map +1 -0
- 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 +2 -2
- package/docs/CreateComponent.md +1 -1
- package/docs/FieldProperties.md +25 -13
- package/docs/Usage.md +17 -31
- package/docs/components/fields/FileInput.md +4 -0
- package/docs/components/form/Field.md +2 -2
- package/docs/components/form/Form.md +13 -39
- package/docs/components/form/FormInstance.md +5 -9
- package/docs/components/form/ModernForm.md +269 -0
- package/docs/modern-form-guide.md +269 -0
- package/docs/modern-form-migration.md +20 -59
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
2
|
-
import { getFieldKey } from "./values.js";
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.181.0 | Cube Dev Team */
|
|
2
|
+
import { getFieldKey, hasPath, normalizePath, readPath } from "./values.js";
|
|
3
3
|
import { getControllerInternals } from "./controller.js";
|
|
4
4
|
|
|
5
5
|
//#region src/components/form/Form/modern/field-binding.ts
|
|
@@ -9,10 +9,26 @@ function sameFieldView(a, b) {
|
|
|
9
9
|
function createModernFieldBackend(form, name) {
|
|
10
10
|
const { store, getServerSnapshot } = getControllerInternals(form, `The "${name}" field`);
|
|
11
11
|
const key = getFieldKey(name);
|
|
12
|
+
const path = normalizePath(name);
|
|
13
|
+
const views = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
const view = (state) => {
|
|
15
|
+
if (state.fields[key]) return state.fields[key];
|
|
16
|
+
if (!hasPath(state.values, path)) return void 0;
|
|
17
|
+
let cached = views.get(state);
|
|
18
|
+
if (!cached) {
|
|
19
|
+
cached = Object.freeze({
|
|
20
|
+
value: readPath(state.values, path),
|
|
21
|
+
errors: Object.freeze([]),
|
|
22
|
+
status: "unvalidated"
|
|
23
|
+
});
|
|
24
|
+
views.set(state, cached);
|
|
25
|
+
}
|
|
26
|
+
return cached;
|
|
27
|
+
};
|
|
12
28
|
return {
|
|
13
29
|
subscribe: store.subscribe,
|
|
14
|
-
getSnapshot: () => store.
|
|
15
|
-
getServerSnapshot: () => getServerSnapshot()
|
|
30
|
+
getSnapshot: () => view(store.getSnapshot()),
|
|
31
|
+
getServerSnapshot: () => view(getServerSnapshot()),
|
|
16
32
|
register: () => store.register(name),
|
|
17
33
|
change: (value, dontTouch) => store.setValue(name, value, {
|
|
18
34
|
source: "user",
|
|
@@ -27,9 +43,11 @@ function fieldRegistrationOptions(props, defaultTrigger) {
|
|
|
27
43
|
return {
|
|
28
44
|
...Object.hasOwn(props, "defaultValue") ? { defaultValue: props.defaultValue } : {},
|
|
29
45
|
preserve: props.preserve,
|
|
46
|
+
dependsOn: props.dependsOn,
|
|
47
|
+
deps: props.deps,
|
|
30
48
|
isEqual: props.isEqual,
|
|
31
49
|
rules: props.isRequired && !rules?.some((rule) => rule.required) ? [{ required: true }, ...rules ?? []] : rules,
|
|
32
|
-
rulesKey: props.rulesKey
|
|
50
|
+
rulesKey: props.rulesKey,
|
|
33
51
|
validationDelay: props.validationDelay,
|
|
34
52
|
validateTrigger: props.validateTrigger ?? defaultTrigger ?? "onBlur",
|
|
35
53
|
errorPolicy: props.errorPolicy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-binding.js","names":[],"sources":["../../../../../src/components/form/Form/modern/field-binding.ts"],"sourcesContent":["import { getControllerInternals } from './controller';\nimport { getFieldKey } from './values';\n\nimport type { ReactNode } from 'react';\nimport type { FieldCoreProps, ValidateTrigger } from '../../../../shared/form';\nimport type { FormController } from './controller';\nimport type {\n FieldState,\n RegistrationOptions,\n RegistrationToken,\n} from './types';\n\n/** The only state a bound input renders; metadata stays in selector subscribers. */\nexport type FieldView = Pick<\n FieldState<ReactNode>,\n 'value' | 'errors' | 'status'\n>;\n\nexport interface FieldBackendHandle {\n subscribe(listener: () => void): () => void;\n getSnapshot(): FieldView | undefined;\n getServerSnapshot(): FieldView | undefined;\n register(): RegistrationToken<ReactNode> | undefined;\n change(value: unknown, dontTouch: boolean, trigger: ValidateTrigger): void;\n blur(): void;\n}\n\nexport function sameFieldView(a?: FieldView, b?: FieldView) {\n return (\n Object.is(a?.value, b?.value) &&\n a?.errors === b?.errors &&\n a?.status === b?.status\n );\n}\n\nexport function createModernFieldBackend(\n form: FormController<any>,\n name:
|
|
1
|
+
{"version":3,"file":"field-binding.js","names":[],"sources":["../../../../../src/components/form/Form/modern/field-binding.ts"],"sourcesContent":["import { getControllerInternals } from './controller';\nimport { getFieldKey, hasPath, normalizePath, readPath } from './values';\n\nimport type { ReactNode } from 'react';\nimport type { FieldCoreProps, ValidateTrigger } from '../../../../shared/form';\nimport type { FormController, ModernFormState } from './controller';\nimport type {\n FieldState,\n RegistrationOptions,\n RegistrationToken,\n} from './types';\nimport type { FormPath } from './values';\n\n/** The only state a bound input renders; metadata stays in selector subscribers. */\nexport type FieldView = Pick<\n FieldState<ReactNode>,\n 'value' | 'errors' | 'status'\n>;\n\nexport interface FieldBackendHandle {\n subscribe(listener: () => void): () => void;\n getSnapshot(): FieldView | undefined;\n getServerSnapshot(): FieldView | undefined;\n register(): RegistrationToken<ReactNode> | undefined;\n change(value: unknown, dontTouch: boolean, trigger: ValidateTrigger): void;\n blur(): void;\n}\n\nexport function sameFieldView(a?: FieldView, b?: FieldView) {\n return (\n Object.is(a?.value, b?.value) &&\n a?.errors === b?.errors &&\n a?.status === b?.status\n );\n}\n\nexport function createModernFieldBackend(\n form: FormController<any>,\n name: FormPath,\n): FieldBackendHandle {\n const { store, getServerSnapshot } = getControllerInternals(\n form,\n `The \"${name}\" field`,\n );\n const key = getFieldKey(name);\n const path = normalizePath(name);\n const views = new WeakMap<object, FieldView>();\n const view = (state: ModernFormState): FieldView | undefined => {\n if (state.fields[key]) return state.fields[key];\n if (!hasPath(state.values, path)) return undefined;\n let cached = views.get(state);\n if (!cached) {\n cached = Object.freeze({\n value: readPath(state.values, path),\n errors: Object.freeze([]),\n status: 'unvalidated',\n });\n views.set(state, cached);\n }\n return cached;\n };\n return {\n subscribe: store.subscribe,\n getSnapshot: () => view(store.getSnapshot()),\n getServerSnapshot: () => view(getServerSnapshot()),\n register: () => store.register(name),\n change: (value, dontTouch) =>\n store.setValue(name, value, {\n source: 'user',\n touch: !dontTouch,\n validate: dontTouch ? 'never' : 'auto',\n }),\n blur: () => store.blur(name),\n };\n}\n\nexport function fieldRegistrationOptions(\n props: FieldCoreProps & {\n defaultValue?: unknown;\n validateTrigger?: ValidateTrigger;\n },\n defaultTrigger?: ValidateTrigger,\n): RegistrationOptions<ReactNode> {\n const rules = props.rules?.flat(Infinity);\n return {\n ...(Object.hasOwn(props, 'defaultValue')\n ? { defaultValue: props.defaultValue }\n : {}),\n preserve: props.preserve,\n dependsOn: props.dependsOn,\n deps: props.deps,\n isEqual: props.isEqual,\n rules:\n props.isRequired && !rules?.some((rule) => rule.required)\n ? [{ required: true }, ...(rules ?? [])]\n : rules,\n rulesKey: props.rulesKey,\n validationDelay: props.validationDelay,\n validateTrigger: props.validateTrigger ?? defaultTrigger ?? 'onBlur',\n errorPolicy: props.errorPolicy,\n };\n}\n"],"mappings":";;;;;AA4BA,SAAgB,cAAc,GAAe,GAAe;AAC1D,QACE,OAAO,GAAG,GAAG,OAAO,GAAG,MAAM,IAC7B,GAAG,WAAW,GAAG,UACjB,GAAG,WAAW,GAAG;;AAIrB,SAAgB,yBACd,MACA,MACoB;CACpB,MAAM,EAAE,OAAO,sBAAsB,uBACnC,MACA,QAAQ,KAAK,SACd;CACD,MAAM,MAAM,YAAY,KAAK;CAC7B,MAAM,OAAO,cAAc,KAAK;CAChC,MAAM,wBAAQ,IAAI,SAA4B;CAC9C,MAAM,QAAQ,UAAkD;AAC9D,MAAI,MAAM,OAAO,KAAM,QAAO,MAAM,OAAO;AAC3C,MAAI,CAAC,QAAQ,MAAM,QAAQ,KAAK,CAAE,QAAO;EACzC,IAAI,SAAS,MAAM,IAAI,MAAM;AAC7B,MAAI,CAAC,QAAQ;AACX,YAAS,OAAO,OAAO;IACrB,OAAO,SAAS,MAAM,QAAQ,KAAK;IACnC,QAAQ,OAAO,OAAO,EAAE,CAAC;IACzB,QAAQ;IACT,CAAC;AACF,SAAM,IAAI,OAAO,OAAO;;AAE1B,SAAO;;AAET,QAAO;EACL,WAAW,MAAM;EACjB,mBAAmB,KAAK,MAAM,aAAa,CAAC;EAC5C,yBAAyB,KAAK,mBAAmB,CAAC;EAClD,gBAAgB,MAAM,SAAS,KAAK;EACpC,SAAS,OAAO,cACd,MAAM,SAAS,MAAM,OAAO;GAC1B,QAAQ;GACR,OAAO,CAAC;GACR,UAAU,YAAY,UAAU;GACjC,CAAC;EACJ,YAAY,MAAM,KAAK,KAAK;EAC7B;;AAGH,SAAgB,yBACd,OAIA,gBACgC;CAChC,MAAM,QAAQ,MAAM,OAAO,KAAK,SAAS;AACzC,QAAO;EACL,GAAI,OAAO,OAAO,OAAO,eAAe,GACpC,EAAE,cAAc,MAAM,cAAc,GACpC,EAAE;EACN,UAAU,MAAM;EAChB,WAAW,MAAM;EACjB,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,OACE,MAAM,cAAc,CAAC,OAAO,MAAM,SAAS,KAAK,SAAS,GACrD,CAAC,EAAE,UAAU,MAAM,EAAE,GAAI,SAAS,EAAE,CAAE,GACtC;EACN,UAAU,MAAM;EAChB,iBAAiB,MAAM;EACvB,iBAAiB,MAAM,mBAAmB,kBAAkB;EAC5D,aAAa,MAAM;EACpB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
import { FormPath } from "./values.js";
|
|
3
|
+
import { CheckedFormPath, FormValueAtPath } from "./path-types.js";
|
|
4
|
+
import { FormReadValue, FormValues } from "./read-types.js";
|
|
5
|
+
import { RegistrationOptions } from "./types.js";
|
|
6
|
+
import { FormController } from "./controller.js";
|
|
7
|
+
import { ReactNode } from "react";
|
|
8
|
+
|
|
9
|
+
//#region src/components/form/Form/modern/field.d.ts
|
|
10
|
+
declare const FIELD_VALUE: unique symbol;
|
|
11
|
+
/** Pure configuration, never a mutable/reactive field instance. */
|
|
12
|
+
interface FormField<Value = unknown> {
|
|
13
|
+
readonly [FIELD_VALUE]: Value;
|
|
14
|
+
readonly form: FormController<any>;
|
|
15
|
+
readonly path: FormPath;
|
|
16
|
+
readonly options: RegistrationOptions<ReactNode>;
|
|
17
|
+
}
|
|
18
|
+
interface FormFieldContext<T extends object> {
|
|
19
|
+
readonly signal: AbortSignal;
|
|
20
|
+
getValue<const Path extends FormPath>(path: CheckedFormPath<T, Path>): FormReadValue<FormValueAtPath<T, Path>> | undefined;
|
|
21
|
+
getValues(): FormValues<T>;
|
|
22
|
+
}
|
|
23
|
+
interface FormFieldOptions<T extends object, Value> extends Omit<RegistrationOptions<ReactNode>, 'defaultValue' | 'isEqual'> {
|
|
24
|
+
readonly validate?: (value: FormReadValue<Value> | undefined, context: FormFieldContext<T>) => ReactNode | void | Promise<ReactNode | void>;
|
|
25
|
+
readonly defaultValue?: Value;
|
|
26
|
+
readonly isEqual?: (previous: FormReadValue<Value> | undefined, next: FormReadValue<Value> | undefined) => boolean;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { FormField, FormFieldContext, FormFieldOptions };
|
|
30
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.181.0 | Cube Dev Team */
|
|
2
|
+
import { normalizePath } from "./values.js";
|
|
3
|
+
|
|
4
|
+
//#region src/components/form/Form/modern/field.ts
|
|
5
|
+
function createFormField(form, path, options = {}) {
|
|
6
|
+
const { validate, ...registration } = options;
|
|
7
|
+
const normalized = normalizePath(path);
|
|
8
|
+
return Object.freeze({
|
|
9
|
+
form,
|
|
10
|
+
path: typeof path === "string" ? path : normalized,
|
|
11
|
+
options: Object.freeze({
|
|
12
|
+
...registration,
|
|
13
|
+
...validate && { rules: [...registration.rules ?? [], {
|
|
14
|
+
authored: validate,
|
|
15
|
+
validator: (_rule, value, context) => validate(value, context)
|
|
16
|
+
}] }
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { createFormField };
|
|
23
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","names":[],"sources":["../../../../../src/components/form/Form/modern/field.ts"],"sourcesContent":["import { normalizePath } from './values';\n\nimport type { ReactNode } from 'react';\nimport type { FormController } from './controller';\nimport type { CheckedFormPath, FormValueAtPath } from './path-types';\nimport type { FormReadValue, FormValues } from './read-types';\nimport type { RegistrationOptions } from './types';\nimport type { FormPath } from './values';\n\ndeclare const FIELD_VALUE: unique symbol;\n\n/** Pure configuration, never a mutable/reactive field instance. */\nexport interface FormField<Value = unknown> {\n readonly [FIELD_VALUE]: Value;\n readonly form: FormController<any>;\n readonly path: FormPath;\n readonly options: RegistrationOptions<ReactNode>;\n}\n\nexport interface FormFieldContext<T extends object> {\n readonly signal: AbortSignal;\n getValue<const Path extends FormPath>(\n path: CheckedFormPath<T, Path>,\n ): FormReadValue<FormValueAtPath<T, Path>> | undefined;\n getValues(): FormValues<T>;\n}\n\nexport interface FormFieldOptions<T extends object, Value>\n extends Omit<RegistrationOptions<ReactNode>, 'defaultValue' | 'isEqual'> {\n readonly validate?: (\n value: FormReadValue<Value> | undefined,\n context: FormFieldContext<T>,\n ) => ReactNode | void | Promise<ReactNode | void>;\n readonly defaultValue?: Value;\n readonly isEqual?: (\n previous: FormReadValue<Value> | undefined,\n next: FormReadValue<Value> | undefined,\n ) => boolean;\n}\n\nexport function createFormField<T extends object, Value>(\n form: FormController<T>,\n path: FormPath,\n options: FormFieldOptions<T, Value> = {},\n): FormField<Value> {\n const { validate, ...registration } = options;\n const normalized = normalizePath(path);\n return Object.freeze({\n form,\n path: typeof path === 'string' ? path : normalized,\n options: Object.freeze({\n ...registration,\n ...(validate && {\n rules: [\n ...(registration.rules ?? []),\n {\n // The adapter has fixed source. Retain the authored function for\n // lazy rule comparison, without changing the consumer's deps.\n authored: validate,\n validator: (_rule, value, context) =>\n validate(value, context as FormFieldContext<T>),\n },\n ],\n }),\n }),\n }) as FormField<Value>;\n}\n"],"mappings":";;;;AAwCA,SAAgB,gBACd,MACA,MACA,UAAsC,EAAE,EACtB;CAClB,MAAM,EAAE,UAAU,GAAG,iBAAiB;CACtC,MAAM,aAAa,cAAc,KAAK;AACtC,QAAO,OAAO,OAAO;EACnB;EACA,MAAM,OAAO,SAAS,WAAW,OAAO;EACxC,SAAS,OAAO,OAAO;GACrB,GAAG;GACH,GAAI,YAAY,EACd,OAAO,CACL,GAAI,aAAa,SAAS,EAAE,EAC5B;IAGE,UAAU;IACV,YAAY,OAAO,OAAO,YACxB,SAAS,OAAO,QAA+B;IAClD,CACF,EACF;GACF,CAAC;EACH,CAAC"}
|
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
import { FormPath } from "./values.js";
|
|
3
3
|
|
|
4
4
|
//#region src/components/form/Form/modern/path-types.d.ts
|
|
5
|
+
type ValidPath<Value, Path extends readonly (string | number)[]> = unknown extends Value ? true : Path extends readonly [infer Key extends string | number, ...infer Rest extends readonly (string | number)[]] ? Key extends keyof NonNullable<Value> ? Rest extends readonly [] ? true : ValidPath<NonNullable<Value>[Key], Rest> : NonNullable<Value> extends readonly (infer Item)[] ? Key extends `${number}` ? ValidPath<Item, Rest> : false : false : true;
|
|
6
|
+
/** Check only the supplied literal path. Widened strings support dynamic models. */
|
|
7
|
+
type CheckedFormPath<T extends object, Path extends FormPath> = Path & (Path extends string ? string extends Path ? unknown : Path extends keyof T ? unknown : never : Path extends readonly (string | number)[] ? ValidPath<T, Path> extends false ? never : unknown : never);
|
|
5
8
|
/** Resolve only the supplied path; never enumerate a model's possible paths. */
|
|
6
9
|
type SegmentValue<Value, Key extends string | number> = Value extends null | undefined ? undefined : Key extends keyof Value ? Value[Key] : Value extends readonly (infer Item)[] ? Key extends `${number}` ? Item : unknown : unknown;
|
|
7
10
|
type TupleValue<Value, Path extends readonly (string | number)[]> = Path extends readonly [infer Key extends string | number, ...infer Rest extends readonly (string | number)[]] ? Rest extends readonly [] ? SegmentValue<Value, Key> : TupleValue<SegmentValue<Value, Key>, Rest> : unknown;
|
|
8
11
|
/** Strings are literal keys; unknown/dynamic names and paths return unknown. */
|
|
9
12
|
type FormValueAtPath<Values extends object, Path extends FormPath> = Path extends string ? Path extends keyof Values ? Values[Path] : unknown : Path extends readonly (string | number)[] ? TupleValue<Values, Path> : unknown;
|
|
13
|
+
type CheckedFormDependencies<T extends object, Dependencies extends readonly FormPath[]> = { readonly [I in keyof Dependencies]: CheckedFormPath<T, Dependencies[I]> };
|
|
10
14
|
//#endregion
|
|
11
|
-
export { FormValueAtPath };
|
|
15
|
+
export { CheckedFormDependencies, CheckedFormPath, FormValueAtPath };
|
|
12
16
|
//# sourceMappingURL=path-types.d.ts.map
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { FormPath } from "./values.js";
|
|
3
|
+
import { CheckedFormPath, FormValueAtPath } from "./path-types.js";
|
|
4
|
+
import { FormReadValue } from "./read-types.js";
|
|
5
|
+
import { FormController, ModernFieldState, ModernFormState, UseFormControllerOptions } from "./controller.js";
|
|
3
6
|
import { ReactNode } from "react";
|
|
4
7
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
8
|
|
|
6
9
|
//#region src/components/form/Form/modern/react.d.ts
|
|
7
10
|
declare function useFormController<T extends object = Record<string, unknown>>(options?: UseFormControllerOptions<T>): FormController<T>;
|
|
11
|
+
declare function useFormValue<T extends object, const Path extends FormPath>(form: FormController<T>, path: CheckedFormPath<T, Path>): FormReadValue<FormValueAtPath<T, Path>> | undefined;
|
|
12
|
+
declare function useFormFieldState<T extends object, const Path extends FormPath>(form: FormController<T>, path: CheckedFormPath<T, Path>): ModernFieldState<FormValueAtPath<T, Path>> | undefined;
|
|
8
13
|
interface FormSelectorOptions<Selected> {
|
|
9
14
|
isEqual?: (previous: Selected, next: Selected) => boolean;
|
|
10
15
|
}
|
|
@@ -17,5 +22,5 @@ interface FormSubscribeProps<T extends object, Selected> extends FormSelectorOpt
|
|
|
17
22
|
}
|
|
18
23
|
declare function FormSubscribe<T extends object = Record<string, unknown>, Selected = unknown>(props: FormSubscribeProps<T, Selected>): react_jsx_runtime0.JSX.Element;
|
|
19
24
|
//#endregion
|
|
20
|
-
export { FormSelectorOptions, FormSubscribe, FormSubscribeProps, useFormController, useFormSelector };
|
|
25
|
+
export { FormSelectorOptions, FormSubscribe, FormSubscribeProps, useFormController, useFormFieldState, useFormSelector, useFormValue };
|
|
21
26
|
//# sourceMappingURL=react.d.ts.map
|
|
@@ -1,15 +1,33 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.181.0 | Cube Dev Team */
|
|
2
|
+
import { useLayoutEffect as useLayoutEffect$1 } from "../../../../utils/react/useLayoutEffect.js";
|
|
2
3
|
import { ModernControllerContext } from "./context.js";
|
|
4
|
+
import { getFieldKey, normalizePath, readPath } from "./values.js";
|
|
3
5
|
import { createFormController, getControllerInternals } from "./controller.js";
|
|
4
|
-
import { useContext, useState } from "react";
|
|
6
|
+
import { useContext, useMemo, useState } from "react";
|
|
5
7
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
6
8
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/with-selector.js";
|
|
7
9
|
|
|
8
10
|
//#region src/components/form/Form/modern/react.tsx
|
|
9
11
|
function useFormController(options) {
|
|
10
12
|
const [controller] = useState(() => createFormController(options));
|
|
13
|
+
const { store } = getControllerInternals(controller, "Form.useController()");
|
|
14
|
+
useLayoutEffect$1(() => {
|
|
15
|
+
store.updateCallbacks({
|
|
16
|
+
onSubmit: options?.onSubmit,
|
|
17
|
+
onSubmitFailed: options?.onSubmitFailed,
|
|
18
|
+
onValuesChange: options?.onValuesChange
|
|
19
|
+
});
|
|
20
|
+
});
|
|
11
21
|
return controller;
|
|
12
22
|
}
|
|
23
|
+
function useFormValue(form, path) {
|
|
24
|
+
const normalized = useMemo(() => normalizePath(path), [path]);
|
|
25
|
+
return useFormSelector(form, (state) => readPath(state.values, normalized));
|
|
26
|
+
}
|
|
27
|
+
function useFormFieldState(form, path) {
|
|
28
|
+
const key = useMemo(() => getFieldKey(path), [path]);
|
|
29
|
+
return useFormSelector(form, (state) => state.fields[key]);
|
|
30
|
+
}
|
|
13
31
|
function useFormSelector(controller, selector, options) {
|
|
14
32
|
const { getServerSnapshot } = getControllerInternals(controller, "Form.useSelector()");
|
|
15
33
|
return useSyncExternalStoreWithSelector(controller.subscribe, controller.getSnapshot, getServerSnapshot, selector, options?.isEqual);
|
|
@@ -23,5 +41,5 @@ function FormSubscribe(props) {
|
|
|
23
41
|
}
|
|
24
42
|
|
|
25
43
|
//#endregion
|
|
26
|
-
export { FormSubscribe, useFormController, useFormSelector };
|
|
44
|
+
export { FormSubscribe, useFormController, useFormFieldState, useFormSelector, useFormValue };
|
|
27
45
|
//# sourceMappingURL=react.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","names":[],"sources":["../../../../../src/components/form/Form/modern/react.tsx"],"sourcesContent":["import { useContext, useState } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js';\n\nimport { ModernControllerContext } from './context';\nimport { createFormController, getControllerInternals } from './controller';\n\nimport type { ReactNode } from 'react';\nimport type {\n FormController,\n ModernFormState,\n UseFormControllerOptions,\n} from './controller';\n\nexport function useFormController<T extends object = Record<string, unknown>>(\n options?: UseFormControllerOptions<T>,\n): FormController<T> {\n // Initial options seed synchronously. A new options object never resets the\n // controller, and the creator does not subscribe its owner to form changes.\n const [controller] = useState(() => createFormController(options));\n // Do not dispose from effect cleanup: Strict Mode and hidden React trees\n // reconnect effects while preserving state. Subscriptions own their cleanup;\n // the controller has no external resources and is collected with its owner.\n return controller;\n}\n\nexport interface FormSelectorOptions<Selected> {\n isEqual?: (previous: Selected, next: Selected) => boolean;\n}\n\nexport function useFormSelector<T extends object, Selected>(\n controller: FormController<T>,\n selector: (state: ModernFormState<T>) => Selected,\n options?: FormSelectorOptions<Selected>,\n): Selected {\n const { getServerSnapshot } = getControllerInternals(\n controller,\n 'Form.useSelector()',\n );\n return useSyncExternalStoreWithSelector(\n controller.subscribe,\n controller.getSnapshot,\n getServerSnapshot,\n selector,\n options?.isEqual,\n );\n}\n\nexport interface FormSubscribeProps<T extends object, Selected>\n extends FormSelectorOptions<Selected> {\n /** Omit to use modern context. An explicit undefined detaches from context. */\n form?: FormController<T>;\n selector: (state: ModernFormState<T>) => Selected;\n children: (selected: Selected) => ReactNode;\n}\n\nexport function FormSubscribe<\n T extends object = Record<string, unknown>,\n Selected = unknown,\n>(props: FormSubscribeProps<T, Selected>) {\n const fromContext = useContext(ModernControllerContext);\n const controller = Object.hasOwn(props, 'form') ? props.form : fromContext;\n if (!controller) {\n throw new Error(\n '<Form.Subscribe> requires a modern form prop or a modern <Form> root.',\n );\n }\n const selected = useFormSelector(controller, props.selector, {\n isEqual: props.isEqual,\n });\n return <>{props.children(selected)}</>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"react.js","names":[],"sources":["../../../../../src/components/form/Form/modern/react.tsx"],"sourcesContent":["import { useContext, useMemo, useState } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js';\n\nimport { useLayoutEffect } from '../../../../utils/react/useLayoutEffect';\n\nimport { ModernControllerContext } from './context';\nimport { createFormController, getControllerInternals } from './controller';\nimport { getFieldKey, normalizePath, readPath } from './values';\n\nimport type { ReactNode } from 'react';\nimport type {\n FormController,\n ModernFieldState,\n ModernFormState,\n UseFormControllerOptions,\n} from './controller';\nimport type { CheckedFormPath, FormValueAtPath } from './path-types';\nimport type { FormReadValue } from './read-types';\nimport type { FormPath } from './values';\n\nexport function useFormController<T extends object = Record<string, unknown>>(\n options?: UseFormControllerOptions<T>,\n): FormController<T> {\n // Initial options seed synchronously. A new options object never resets the\n // controller, and the creator does not subscribe its owner to form changes.\n const [controller] = useState(() => createFormController(options));\n const { store } = getControllerInternals(controller, 'Form.useController()');\n // Intentionally commit after every render: callbacks are live, unlike the\n // initial defaults/policy. Abandoned renders must never replace callbacks.\n useLayoutEffect(() => {\n store.updateCallbacks({\n onSubmit: options?.onSubmit,\n onSubmitFailed: options?.onSubmitFailed,\n onValuesChange: options?.onValuesChange,\n });\n });\n // Do not dispose from effect cleanup: Strict Mode and hidden React trees\n // reconnect effects while preserving state. Subscriptions own their cleanup;\n // the controller has no external resources and is collected with its owner.\n return controller;\n}\n\nexport function useFormValue<T extends object, const Path extends FormPath>(\n form: FormController<T>,\n path: CheckedFormPath<T, Path>,\n): FormReadValue<FormValueAtPath<T, Path>> | undefined {\n const normalized = useMemo(() => normalizePath(path), [path]);\n return useFormSelector(form, (state) =>\n readPath(state.values, normalized),\n ) as FormReadValue<FormValueAtPath<T, Path>> | undefined;\n}\n\nexport function useFormFieldState<\n T extends object,\n const Path extends FormPath,\n>(\n form: FormController<T>,\n path: CheckedFormPath<T, Path>,\n): ModernFieldState<FormValueAtPath<T, Path>> | undefined {\n const key = useMemo(() => getFieldKey(path), [path]);\n return useFormSelector(form, (state) => state.fields[key]) as\n | ModernFieldState<FormValueAtPath<T, Path>>\n | undefined;\n}\n\nexport interface FormSelectorOptions<Selected> {\n isEqual?: (previous: Selected, next: Selected) => boolean;\n}\n\nexport function useFormSelector<T extends object, Selected>(\n controller: FormController<T>,\n selector: (state: ModernFormState<T>) => Selected,\n options?: FormSelectorOptions<Selected>,\n): Selected {\n const { getServerSnapshot } = getControllerInternals(\n controller,\n 'Form.useSelector()',\n );\n return useSyncExternalStoreWithSelector(\n controller.subscribe,\n controller.getSnapshot,\n getServerSnapshot,\n selector,\n options?.isEqual,\n );\n}\n\nexport interface FormSubscribeProps<T extends object, Selected>\n extends FormSelectorOptions<Selected> {\n /** Omit to use modern context. An explicit undefined detaches from context. */\n form?: FormController<T>;\n selector: (state: ModernFormState<T>) => Selected;\n children: (selected: Selected) => ReactNode;\n}\n\nexport function FormSubscribe<\n T extends object = Record<string, unknown>,\n Selected = unknown,\n>(props: FormSubscribeProps<T, Selected>) {\n const fromContext = useContext(ModernControllerContext);\n const controller = Object.hasOwn(props, 'form') ? props.form : fromContext;\n if (!controller) {\n throw new Error(\n '<Form.Subscribe> requires a modern form prop or a modern <Form> root.',\n );\n }\n const selected = useFormSelector(controller, props.selector, {\n isEqual: props.isEqual,\n });\n return <>{props.children(selected)}</>;\n}\n"],"mappings":";;;;;;;;;;AAoBA,SAAgB,kBACd,SACmB;CAGnB,MAAM,CAAC,cAAc,eAAe,qBAAqB,QAAQ,CAAC;CAClE,MAAM,EAAE,UAAU,uBAAuB,YAAY,uBAAuB;AAG5E,yBAAsB;AACpB,QAAM,gBAAgB;GACpB,UAAU,SAAS;GACnB,gBAAgB,SAAS;GACzB,gBAAgB,SAAS;GAC1B,CAAC;GACF;AAIF,QAAO;;AAGT,SAAgB,aACd,MACA,MACqD;CACrD,MAAM,aAAa,cAAc,cAAc,KAAK,EAAE,CAAC,KAAK,CAAC;AAC7D,QAAO,gBAAgB,OAAO,UAC5B,SAAS,MAAM,QAAQ,WAAW,CACnC;;AAGH,SAAgB,kBAId,MACA,MACwD;CACxD,MAAM,MAAM,cAAc,YAAY,KAAK,EAAE,CAAC,KAAK,CAAC;AACpD,QAAO,gBAAgB,OAAO,UAAU,MAAM,OAAO,KAAK;;AAS5D,SAAgB,gBACd,YACA,UACA,SACU;CACV,MAAM,EAAE,sBAAsB,uBAC5B,YACA,qBACD;AACD,QAAO,iCACL,WAAW,WACX,WAAW,aACX,mBACA,UACA,SAAS,QACV;;AAWH,SAAgB,cAGd,OAAwC;CACxC,MAAM,cAAc,WAAW,wBAAwB;CACvD,MAAM,aAAa,OAAO,OAAO,OAAO,OAAO,GAAG,MAAM,OAAO;AAC/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,wEACD;CAEH,MAAM,WAAW,gBAAgB,YAAY,MAAM,UAAU,EAC3D,SAAS,MAAM,SAChB,CAAC;AACF,QAAO,4CAAG,MAAM,SAAS,SAAS,GAAI"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
import { CalendarDate, CalendarDateTime, Time, ZonedDateTime } from "@internationalized/date";
|
|
3
|
+
|
|
4
|
+
//#region src/components/form/Form/modern/read-types.d.ts
|
|
5
|
+
type AtomicFormValue = Date | RegExp | File | Blob | Map<any, any> | Set<any> | ((...args: any[]) => any) | CalendarDate | CalendarDateTime | Time | ZonedDateTime;
|
|
6
|
+
/** Partial immutable data; platform and date-control values stay atomic. */
|
|
7
|
+
type FormReadValue<T> = T extends AtomicFormValue ? T : T extends object ? { readonly [K in keyof T]?: FormReadValue<T[K]> } : T;
|
|
8
|
+
type FormValues<T extends object> = FormReadValue<T>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { FormReadValue, FormValues };
|
|
11
|
+
//# sourceMappingURL=read-types.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.181.0 | Cube Dev Team */
|
|
2
2
|
import { FORM_BACKEND } from "../backend.js";
|
|
3
|
+
import { createValueSnapshotter, defineValue, formValueEqual, freezeContainer, getFieldKey, hasPath, isPlainObject, normalizePath, pathValueChanged, readPath, readonlySet, sameMembers, writePath } from "./values.js";
|
|
3
4
|
import { rulesSignature, runRules } from "./validation.js";
|
|
4
|
-
import { createValueSnapshotter, defineValue, formValueEqual, freezeContainer, getFieldKey, hasPath, isPlainObject, normalizePath, readPath, readonlySet, sameMembers, writePath } from "./values.js";
|
|
5
5
|
|
|
6
6
|
//#region src/components/form/Form/modern/store.ts
|
|
7
7
|
const EMPTY_ERRORS = Object.freeze([]);
|
|
@@ -10,6 +10,12 @@ const EMPTY_FIELDS = Object.freeze(Object.create(null));
|
|
|
10
10
|
function related(a, b) {
|
|
11
11
|
return a.slice(0, Math.min(a.length, b.length)).every((key, index) => key === b[index]);
|
|
12
12
|
}
|
|
13
|
+
function sameDependencies(a = [], b = []) {
|
|
14
|
+
return a.length === b.length && a.every((value, index) => Object.is(value, b[index]));
|
|
15
|
+
}
|
|
16
|
+
function samePaths(a = [], b = []) {
|
|
17
|
+
return a.length === b.length && a.every((path, index) => sameDependencies(path, b[index]));
|
|
18
|
+
}
|
|
13
19
|
/** Only traverse path ancestors; a field's value (even cyclic data) is a leaf. */
|
|
14
20
|
function projectActive(value, path, previous) {
|
|
15
21
|
if (path.terminal) return value;
|
|
@@ -54,6 +60,7 @@ function createFormStore(inputOptions = {}) {
|
|
|
54
60
|
isInvalid: false,
|
|
55
61
|
isValidating: false,
|
|
56
62
|
isSubmitting: false,
|
|
63
|
+
canReset: false,
|
|
57
64
|
submitError: void 0,
|
|
58
65
|
revision: 0
|
|
59
66
|
});
|
|
@@ -103,6 +110,8 @@ function createFormStore(inputOptions = {}) {
|
|
|
103
110
|
function invalidate(record, keepErrors = false) {
|
|
104
111
|
const controller = record.validation;
|
|
105
112
|
record.validation = void 0;
|
|
113
|
+
record.reads = void 0;
|
|
114
|
+
record.readsAll = false;
|
|
106
115
|
record.validationRevision++;
|
|
107
116
|
record.status = "unvalidated";
|
|
108
117
|
if (!keepErrors) record.errors = EMPTY_ERRORS;
|
|
@@ -114,11 +123,24 @@ function createFormStore(inputOptions = {}) {
|
|
|
114
123
|
controller.abort();
|
|
115
124
|
}
|
|
116
125
|
}
|
|
126
|
+
function dependencyChanged(record, previous) {
|
|
127
|
+
return record.owner?.options.dependsOn?.some((path) => pathValueChanged(previous, values, path)) ?? false;
|
|
128
|
+
}
|
|
129
|
+
function validationReadChanged(record, previous) {
|
|
130
|
+
if (!record.validation) return false;
|
|
131
|
+
if (record.readsAll && previous !== values) return true;
|
|
132
|
+
for (const path of record.reads?.values() ?? []) if (pathValueChanged(previous, values, path)) return true;
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
117
135
|
function invalidateRelated(path, previous, config) {
|
|
118
|
-
for (const record of records.values())
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
if (
|
|
136
|
+
for (const record of records.values()) {
|
|
137
|
+
const dependency = dependencyChanged(record, previous);
|
|
138
|
+
const fieldChanged = related(path, record.path) || pathValueChanged(previous, values, record.path);
|
|
139
|
+
if (fieldChanged || dependency || validationReadChanged(record, previous)) {
|
|
140
|
+
const revalidate = (fieldChanged || dependency) && !!config && !!record.registrations.size && (config.validate === "always" || config.validate !== "never" && (record.owner?.options.validateTrigger === "onChange" || !!record.errors.length || dependency && record.status !== "unvalidated"));
|
|
141
|
+
invalidate(record, revalidate);
|
|
142
|
+
if (revalidate) validateRecord(record, false);
|
|
143
|
+
}
|
|
122
144
|
}
|
|
123
145
|
}
|
|
124
146
|
function activeValues() {
|
|
@@ -152,6 +174,7 @@ function createFormStore(inputOptions = {}) {
|
|
|
152
174
|
let validCount = 0;
|
|
153
175
|
let invalid = false;
|
|
154
176
|
let validating = false;
|
|
177
|
+
let resettable = submitError != null;
|
|
155
178
|
for (const record of records.values()) {
|
|
156
179
|
const field = {
|
|
157
180
|
name: record.name,
|
|
@@ -172,6 +195,7 @@ function createFormStore(inputOptions = {}) {
|
|
|
172
195
|
});
|
|
173
196
|
if (field.dirty) dirtyNames.add(record.name);
|
|
174
197
|
if (field.touched) touchedNames.add(record.name);
|
|
198
|
+
resettable ||= field.dirty || field.touched || !!field.errors.length || field.status !== "unvalidated";
|
|
175
199
|
if (field.active) {
|
|
176
200
|
activeCount++;
|
|
177
201
|
if (field.status === "valid") validCount++;
|
|
@@ -192,6 +216,7 @@ function createFormStore(inputOptions = {}) {
|
|
|
192
216
|
isInvalid: invalid,
|
|
193
217
|
isValidating: validating,
|
|
194
218
|
isSubmitting: !!submission,
|
|
219
|
+
canReset: !submission && resettable,
|
|
195
220
|
submitError,
|
|
196
221
|
revision: state.revision
|
|
197
222
|
};
|
|
@@ -291,6 +316,8 @@ function createFormStore(inputOptions = {}) {
|
|
|
291
316
|
function prepareRegistration(path, config) {
|
|
292
317
|
const prepared = {
|
|
293
318
|
...config,
|
|
319
|
+
deps: config.deps ? Object.freeze([...config.deps]) : void 0,
|
|
320
|
+
dependsOn: config.dependsOn?.map((dependency) => Object.freeze(normalizePath(dependency))),
|
|
294
321
|
rules: config.rules?.map((rule) => Object.freeze({
|
|
295
322
|
...rule,
|
|
296
323
|
...rule.enum ? { enum: Object.freeze([...rule.enum]) } : {}
|
|
@@ -322,7 +349,7 @@ function createFormStore(inputOptions = {}) {
|
|
|
322
349
|
assertLive();
|
|
323
350
|
const normalized = normalizePath(path);
|
|
324
351
|
const prepared = prepareRegistration(normalized, config);
|
|
325
|
-
const signature = prepared.
|
|
352
|
+
const signature = rulesSignature(prepared.rules, { hashFunctions: prepared.rulesKey === void 0 });
|
|
326
353
|
const record = ensure(normalized);
|
|
327
354
|
const registration = {
|
|
328
355
|
options: prepared,
|
|
@@ -345,8 +372,8 @@ function createFormStore(inputOptions = {}) {
|
|
|
345
372
|
update(next) {
|
|
346
373
|
if (released || disposed) return;
|
|
347
374
|
const prepared = prepareRegistration(record.path, next);
|
|
348
|
-
const signature = prepared.
|
|
349
|
-
const validationChanged = registration.signature !== signature || registration.options.validationDelay !== prepared.validationDelay || registration.options.validateTrigger !== prepared.validateTrigger || registration.options.errorPolicy !== prepared.errorPolicy;
|
|
375
|
+
const signature = rulesSignature(prepared.rules, { hashFunctions: prepared.rulesKey === void 0 });
|
|
376
|
+
const validationChanged = registration.signature !== signature || registration.options.rulesKey !== prepared.rulesKey || !sameDependencies(registration.options.deps, prepared.deps) || !samePaths(registration.options.dependsOn, prepared.dependsOn) || registration.options.validationDelay !== prepared.validationDelay || registration.options.validateTrigger !== prepared.validateTrigger || registration.options.errorPolicy !== prepared.errorPolicy;
|
|
350
377
|
if (!(!registration.defaultConsidered && Object.hasOwn(prepared, "defaultValue")) && !validationChanged && (registration.options.preserve ?? true) === (prepared.preserve ?? true) && registration.options.isEqual === prepared.isEqual) {
|
|
351
378
|
registration.options = prepared;
|
|
352
379
|
return;
|
|
@@ -355,9 +382,11 @@ function createFormStore(inputOptions = {}) {
|
|
|
355
382
|
registration.options = prepared;
|
|
356
383
|
registration.signature = signature;
|
|
357
384
|
registration.order = ++order;
|
|
358
|
-
|
|
385
|
+
const revalidate = validationChanged && record.status !== "unvalidated";
|
|
386
|
+
if (record.owner !== registration || validationChanged) invalidate(record, revalidate);
|
|
359
387
|
record.owner = registration;
|
|
360
388
|
seed(record, registration);
|
|
389
|
+
if (revalidate) validateRecord(record, false);
|
|
361
390
|
});
|
|
362
391
|
},
|
|
363
392
|
release(config = {}) {
|
|
@@ -372,9 +401,10 @@ function createFormStore(inputOptions = {}) {
|
|
|
372
401
|
if (!record.registrations.size) {
|
|
373
402
|
if (registration.options.preserve === false) {
|
|
374
403
|
const removeValue = () => {
|
|
404
|
+
const previous = values;
|
|
375
405
|
values = writePath(values, record.path, void 0, true);
|
|
376
406
|
record.touched = false;
|
|
377
|
-
|
|
407
|
+
invalidateRelated(record.path, previous, { validate: "auto" });
|
|
378
408
|
if (!hasPath(defaults, record.path)) records.delete(record.name);
|
|
379
409
|
};
|
|
380
410
|
if (config.deferValueRemoval) {
|
|
@@ -429,9 +459,10 @@ function createFormStore(inputOptions = {}) {
|
|
|
429
459
|
values = defaults;
|
|
430
460
|
for (const saved of preserved.sort((a, b) => a.path.length - b.path.length)) values = writePath(values, saved.path, saved.value, !saved.exists);
|
|
431
461
|
const names = [];
|
|
432
|
-
for (const record of records.values())
|
|
433
|
-
|
|
434
|
-
|
|
462
|
+
for (const record of records.values()) {
|
|
463
|
+
const changed = pathValueChanged(previous, values, record.path);
|
|
464
|
+
if (changed || dependencyChanged(record, previous) || validationReadChanged(record, previous)) invalidate(record);
|
|
465
|
+
if (changed) names.push(record.name);
|
|
435
466
|
}
|
|
436
467
|
event(names, "adopt");
|
|
437
468
|
});
|
|
@@ -483,6 +514,8 @@ function createFormStore(inputOptions = {}) {
|
|
|
483
514
|
const copied = errors.length ? Object.freeze([...errors]) : EMPTY_ERRORS;
|
|
484
515
|
batch(() => {
|
|
485
516
|
record.validation = void 0;
|
|
517
|
+
record.reads = void 0;
|
|
518
|
+
record.readsAll = false;
|
|
486
519
|
record.errors = copied;
|
|
487
520
|
record.status = copied.length ? "invalid" : "valid";
|
|
488
521
|
});
|
|
@@ -533,10 +566,16 @@ function createFormStore(inputOptions = {}) {
|
|
|
533
566
|
return Promise.resolve(result(EMPTY_ERRORS, true));
|
|
534
567
|
}
|
|
535
568
|
if (!rules.length) {
|
|
569
|
+
record.reads = void 0;
|
|
570
|
+
record.readsAll = false;
|
|
536
571
|
const committed = token.complete(EMPTY_ERRORS);
|
|
537
572
|
return Promise.resolve(result(EMPTY_ERRORS, !committed || record.validationRevision !== revision));
|
|
538
573
|
}
|
|
539
|
-
const
|
|
574
|
+
const validationValues = values;
|
|
575
|
+
const reads = /* @__PURE__ */ new Map();
|
|
576
|
+
record.reads = reads;
|
|
577
|
+
record.readsAll = false;
|
|
578
|
+
const value = readPath(validationValues, record.path);
|
|
540
579
|
return new Promise((resolve) => {
|
|
541
580
|
let timer;
|
|
542
581
|
let settled = false;
|
|
@@ -557,8 +596,21 @@ function createFormStore(inputOptions = {}) {
|
|
|
557
596
|
const errors = await runRules(value, rules, {
|
|
558
597
|
name: record.name,
|
|
559
598
|
signal: token.signal,
|
|
560
|
-
getValue: (path) =>
|
|
561
|
-
|
|
599
|
+
getValue: (path) => {
|
|
600
|
+
const normalized = normalizePath(path);
|
|
601
|
+
if (!settled && !token.signal.aborted) {
|
|
602
|
+
reads.set(getFieldKey(normalized), normalized);
|
|
603
|
+
if (pathValueChanged(validationValues, values, normalized)) token.cancel();
|
|
604
|
+
}
|
|
605
|
+
return readPath(validationValues, normalized);
|
|
606
|
+
},
|
|
607
|
+
getValues: () => {
|
|
608
|
+
if (!settled && !token.signal.aborted) {
|
|
609
|
+
record.readsAll = true;
|
|
610
|
+
if (values !== validationValues) token.cancel();
|
|
611
|
+
}
|
|
612
|
+
return validationValues;
|
|
613
|
+
}
|
|
562
614
|
}, config?.errorPolicy ?? options.errorPolicy ?? "first");
|
|
563
615
|
if (!settled) {
|
|
564
616
|
const committed = token.complete(errors);
|
|
@@ -669,7 +721,10 @@ function createFormStore(inputOptions = {}) {
|
|
|
669
721
|
errors: Object.freeze(errors)
|
|
670
722
|
};
|
|
671
723
|
try {
|
|
672
|
-
await callbacks.onSubmitFailed?.(
|
|
724
|
+
await callbacks.onSubmitFailed?.({
|
|
725
|
+
status: "invalid",
|
|
726
|
+
errors: Object.freeze(errors)
|
|
727
|
+
});
|
|
673
728
|
} catch (error) {
|
|
674
729
|
report(error);
|
|
675
730
|
}
|
|
@@ -691,7 +746,10 @@ function createFormStore(inputOptions = {}) {
|
|
|
691
746
|
submitError = error;
|
|
692
747
|
});
|
|
693
748
|
try {
|
|
694
|
-
await callbacks.onSubmitFailed?.(
|
|
749
|
+
await callbacks.onSubmitFailed?.({
|
|
750
|
+
status: "failed",
|
|
751
|
+
error
|
|
752
|
+
});
|
|
695
753
|
} catch (failure) {
|
|
696
754
|
report(failure);
|
|
697
755
|
}
|
|
@@ -767,6 +825,11 @@ function createFormStore(inputOptions = {}) {
|
|
|
767
825
|
validate,
|
|
768
826
|
submit,
|
|
769
827
|
bindCallbacks,
|
|
828
|
+
updateCallbacks(callbacks) {
|
|
829
|
+
options.onSubmit = callbacks.onSubmit;
|
|
830
|
+
options.onSubmitFailed = callbacks.onSubmitFailed;
|
|
831
|
+
options.onValuesChange = callbacks.onValuesChange;
|
|
832
|
+
},
|
|
770
833
|
blur(path) {
|
|
771
834
|
const record = records.get(getFieldKey(path));
|
|
772
835
|
if (!record?.registrations.size) return;
|