@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,93 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
|
+
import { useLayoutEffect as useLayoutEffect$1 } from "../../../../utils/react/useLayoutEffect.js";
|
|
3
|
+
import { useEvent } from "../../../../_internal/hooks/use-event.js";
|
|
4
|
+
import { isModernFormController } from "../backend.js";
|
|
5
|
+
import { useField } from "./use-field.js";
|
|
6
|
+
import { createModernFieldBackend, fieldRegistrationOptions, sameFieldView } from "../modern/field-binding.js";
|
|
7
|
+
import { useMemo, useRef } from "react";
|
|
8
|
+
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/with-selector.js";
|
|
9
|
+
|
|
10
|
+
//#region src/components/form/Form/use-field/use-field-binding.ts
|
|
11
|
+
const noop = () => {};
|
|
12
|
+
const selectView = (view) => view;
|
|
13
|
+
/**
|
|
14
|
+
* One unconditional subscription/registration boundary. The frozen legacy
|
|
15
|
+
* adapter still runs its original hooks, inert on the modern path, so an input
|
|
16
|
+
* can cross backends without remounting or changing hook order. Its render-time
|
|
17
|
+
* mutations remain contained in use-field.ts; modern handles are pure to create.
|
|
18
|
+
*/
|
|
19
|
+
function useFieldBinding(props, params, generatedId) {
|
|
20
|
+
const modern = !params.unbound && isModernFormController(props.form);
|
|
21
|
+
const controller = modern ? props.form : void 0;
|
|
22
|
+
const name = props.name ?? "";
|
|
23
|
+
const legacy = useField(props, {
|
|
24
|
+
...params,
|
|
25
|
+
unbound: params.unbound || modern
|
|
26
|
+
});
|
|
27
|
+
const modernHandle = useMemo(() => controller ? createModernFieldBackend(controller, name) : void 0, [controller, name]);
|
|
28
|
+
const legacyHandle = useMemo(() => {
|
|
29
|
+
const snapshot = {
|
|
30
|
+
value: legacy.value,
|
|
31
|
+
errors: legacy.field?.errors ?? [],
|
|
32
|
+
status: legacy.field?.status ?? "unvalidated"
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
subscribe: () => noop,
|
|
36
|
+
getSnapshot: () => snapshot,
|
|
37
|
+
getServerSnapshot: () => snapshot,
|
|
38
|
+
register: () => void 0,
|
|
39
|
+
change: (value, dontTouch, trigger) => legacy.onChange?.(value, dontTouch, trigger),
|
|
40
|
+
blur: legacy.onBlur
|
|
41
|
+
};
|
|
42
|
+
}, [legacy]);
|
|
43
|
+
const handle = modernHandle ?? legacyHandle;
|
|
44
|
+
const field = useSyncExternalStoreWithSelector(handle.subscribe, handle.getSnapshot, handle.getServerSnapshot, selectView, sameFieldView);
|
|
45
|
+
const registration = useRef(void 0);
|
|
46
|
+
useLayoutEffect$1(() => {
|
|
47
|
+
const token = handle.register();
|
|
48
|
+
registration.current = token;
|
|
49
|
+
return () => {
|
|
50
|
+
token?.release({ deferValueRemoval: true });
|
|
51
|
+
if (registration.current === token) registration.current = void 0;
|
|
52
|
+
};
|
|
53
|
+
}, [handle]);
|
|
54
|
+
useLayoutEffect$1(() => {
|
|
55
|
+
registration.current?.update(fieldRegistrationOptions(props, params.defaultValidationTrigger));
|
|
56
|
+
});
|
|
57
|
+
const trigger = props.validateTrigger ?? params.defaultValidationTrigger ?? "onBlur";
|
|
58
|
+
const onChange = useEvent((value, dontTouch) => {
|
|
59
|
+
if (controller && props.shouldUpdate !== void 0) {
|
|
60
|
+
const previous = controller.getValues();
|
|
61
|
+
if (props.shouldUpdate === false || typeof props.shouldUpdate === "function" && !props.shouldUpdate(previous, {
|
|
62
|
+
...previous,
|
|
63
|
+
[name]: value
|
|
64
|
+
})) return;
|
|
65
|
+
}
|
|
66
|
+
handle.change(value, dontTouch, trigger);
|
|
67
|
+
});
|
|
68
|
+
const onBlur = useEvent(() => handle.blur());
|
|
69
|
+
if (!controller) return legacy;
|
|
70
|
+
const required = props.isRequired || props.rules?.flat(Infinity).some((rule) => rule.required === true);
|
|
71
|
+
return {
|
|
72
|
+
form: controller,
|
|
73
|
+
name,
|
|
74
|
+
id: props.id ?? `${props.idPrefix ? `${props.idPrefix}_` : ""}${name}-${generatedId}`,
|
|
75
|
+
nonInput: false,
|
|
76
|
+
value: field ? field.value : props.defaultValue,
|
|
77
|
+
onChange,
|
|
78
|
+
onBlur,
|
|
79
|
+
validateTrigger: trigger,
|
|
80
|
+
isInvalid: props.isInvalid ?? !!field?.errors.length,
|
|
81
|
+
isValid: props.isValid ?? !!(props.showValid && field?.status === "valid"),
|
|
82
|
+
isLoading: props.isLoading ?? field?.status === "validating",
|
|
83
|
+
...required ? { isRequired: true } : {},
|
|
84
|
+
...required && !props.isRequired && props.necessityIndicator === void 0 ? { necessityIndicator: null } : {},
|
|
85
|
+
description: props.description,
|
|
86
|
+
message: props.message !== void 0 ? props.message : field?.errors[0],
|
|
87
|
+
errorMessage: props.errorMessage !== void 0 ? props.errorMessage : field?.errors[0]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
export { useFieldBinding };
|
|
93
|
+
//# sourceMappingURL=use-field-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-field-binding.js","names":[],"sources":["../../../../../src/components/form/Form/use-field/use-field-binding.ts"],"sourcesContent":["import { useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js';\n\nimport { useEvent } from '../../../../_internal/hooks/use-event';\nimport { useLayoutEffect } from '../../../../utils/react/useLayoutEffect';\nimport { isModernFormController } from '../backend';\nimport {\n createModernFieldBackend,\n fieldRegistrationOptions,\n sameFieldView,\n} from '../modern/field-binding';\n\nimport { useField } from './use-field';\n\nimport type { ReactNode } from 'react';\nimport type { FormController } from '../modern/controller';\nimport type { FieldBackendHandle, FieldView } from '../modern/field-binding';\nimport type { RegistrationToken } from '../modern/types';\nimport type { FieldTypes } from '../types';\nimport type { FieldReturnValue, UseFieldProps } from './types';\nimport type { UseFieldParams } from './use-field';\n\nconst noop = () => {};\nconst selectView = (view: FieldView | undefined) => view;\n\n/**\n * One unconditional subscription/registration boundary. The frozen legacy\n * adapter still runs its original hooks, inert on the modern path, so an input\n * can cross backends without remounting or changing hook order. Its render-time\n * mutations remain contained in use-field.ts; modern handles are pure to create.\n */\nexport function useFieldBinding<\n T extends FieldTypes,\n P extends UseFieldProps<T>,\n>(\n props: P,\n params: UseFieldParams,\n generatedId: string,\n): Omit<FieldReturnValue<T>, 'form'> & {\n form?: FieldReturnValue<T>['form'] | FormController<any>;\n isLoading?: boolean;\n} {\n const modern = !params.unbound && isModernFormController(props.form);\n const controller = modern\n ? (props.form as unknown as FormController<any>)\n : undefined;\n const name = props.name ?? '';\n const legacy = useField<T, P>(props, {\n ...params,\n unbound: params.unbound || modern,\n });\n const modernHandle = useMemo(\n () => (controller ? createModernFieldBackend(controller, name) : undefined),\n [controller, name],\n );\n const legacyHandle = useMemo<FieldBackendHandle>(() => {\n const snapshot: FieldView = {\n value: legacy.value,\n errors: legacy.field?.errors ?? [],\n status: legacy.field?.status ?? 'unvalidated',\n };\n return {\n subscribe: () => noop,\n getSnapshot: () => snapshot,\n getServerSnapshot: () => snapshot,\n register: () => undefined,\n change: (value, dontTouch, trigger) =>\n legacy.onChange?.(value, dontTouch, trigger),\n blur: legacy.onBlur,\n };\n }, [legacy]);\n const handle = modernHandle ?? legacyHandle;\n const field = useSyncExternalStoreWithSelector(\n handle.subscribe,\n handle.getSnapshot,\n handle.getServerSnapshot,\n selectView,\n sameFieldView,\n );\n const registration = useRef<RegistrationToken<ReactNode> | undefined>(\n undefined,\n );\n useLayoutEffect(() => {\n const token = handle.register();\n registration.current = token;\n return () => {\n token?.release({ deferValueRemoval: true });\n if (registration.current === token) registration.current = undefined;\n };\n }, [handle]);\n useLayoutEffect(() => {\n registration.current?.update(\n fieldRegistrationOptions(props, params.defaultValidationTrigger),\n );\n });\n const trigger =\n props.validateTrigger ?? params.defaultValidationTrigger ?? 'onBlur';\n const onChange = useEvent((value: unknown, dontTouch: boolean) => {\n if (controller && props.shouldUpdate !== undefined) {\n const previous = controller.getValues();\n if (\n props.shouldUpdate === false ||\n (typeof props.shouldUpdate === 'function' &&\n !props.shouldUpdate(previous, { ...previous, [name]: value }))\n )\n return;\n }\n handle.change(value, dontTouch, trigger);\n });\n const onBlur = useEvent(() => handle.blur());\n if (!controller) return legacy;\n\n const required =\n props.isRequired ||\n props.rules?.flat(Infinity).some((rule) => rule.required === true);\n const id =\n props.id ??\n `${props.idPrefix ? `${props.idPrefix}_` : ''}${name}-${generatedId}`;\n return {\n form: controller,\n name,\n id,\n nonInput: false,\n value: field ? field.value : props.defaultValue,\n onChange,\n onBlur,\n validateTrigger: trigger,\n isInvalid: props.isInvalid ?? !!field?.errors.length,\n isValid: props.isValid ?? !!(props.showValid && field?.status === 'valid'),\n isLoading: props.isLoading ?? field?.status === 'validating',\n ...(required ? { isRequired: true } : {}),\n ...(required && !props.isRequired && props.necessityIndicator === undefined\n ? { necessityIndicator: null }\n : {}),\n description: props.description,\n message: props.message !== undefined ? props.message : field?.errors[0],\n errorMessage:\n props.errorMessage !== undefined ? props.errorMessage : field?.errors[0],\n };\n}\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,aAAa;AACnB,MAAM,cAAc,SAAgC;;;;;;;AAQpD,SAAgB,gBAId,OACA,QACA,aAIA;CACA,MAAM,SAAS,CAAC,OAAO,WAAW,uBAAuB,MAAM,KAAK;CACpE,MAAM,aAAa,SACd,MAAM,OACP;CACJ,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,SAAS,SAAe,OAAO;EACnC,GAAG;EACH,SAAS,OAAO,WAAW;EAC5B,CAAC;CACF,MAAM,eAAe,cACZ,aAAa,yBAAyB,YAAY,KAAK,GAAG,QACjE,CAAC,YAAY,KAAK,CACnB;CACD,MAAM,eAAe,cAAkC;EACrD,MAAM,WAAsB;GAC1B,OAAO,OAAO;GACd,QAAQ,OAAO,OAAO,UAAU,EAAE;GAClC,QAAQ,OAAO,OAAO,UAAU;GACjC;AACD,SAAO;GACL,iBAAiB;GACjB,mBAAmB;GACnB,yBAAyB;GACzB,gBAAgB;GAChB,SAAS,OAAO,WAAW,YACzB,OAAO,WAAW,OAAO,WAAW,QAAQ;GAC9C,MAAM,OAAO;GACd;IACA,CAAC,OAAO,CAAC;CACZ,MAAM,SAAS,gBAAgB;CAC/B,MAAM,QAAQ,iCACZ,OAAO,WACP,OAAO,aACP,OAAO,mBACP,YACA,cACD;CACD,MAAM,eAAe,OACnB,OACD;AACD,yBAAsB;EACpB,MAAM,QAAQ,OAAO,UAAU;AAC/B,eAAa,UAAU;AACvB,eAAa;AACX,UAAO,QAAQ,EAAE,mBAAmB,MAAM,CAAC;AAC3C,OAAI,aAAa,YAAY,MAAO,cAAa,UAAU;;IAE5D,CAAC,OAAO,CAAC;AACZ,yBAAsB;AACpB,eAAa,SAAS,OACpB,yBAAyB,OAAO,OAAO,yBAAyB,CACjE;GACD;CACF,MAAM,UACJ,MAAM,mBAAmB,OAAO,4BAA4B;CAC9D,MAAM,WAAW,UAAU,OAAgB,cAAuB;AAChE,MAAI,cAAc,MAAM,iBAAiB,QAAW;GAClD,MAAM,WAAW,WAAW,WAAW;AACvC,OACE,MAAM,iBAAiB,SACtB,OAAO,MAAM,iBAAiB,cAC7B,CAAC,MAAM,aAAa,UAAU;IAAE,GAAG;KAAW,OAAO;IAAO,CAAC,CAE/D;;AAEJ,SAAO,OAAO,OAAO,WAAW,QAAQ;GACxC;CACF,MAAM,SAAS,eAAe,OAAO,MAAM,CAAC;AAC5C,KAAI,CAAC,WAAY,QAAO;CAExB,MAAM,WACJ,MAAM,cACN,MAAM,OAAO,KAAK,SAAS,CAAC,MAAM,SAAS,KAAK,aAAa,KAAK;AAIpE,QAAO;EACL,MAAM;EACN;EACA,IALA,MAAM,MACN,GAAG,MAAM,WAAW,GAAG,MAAM,SAAS,KAAK,KAAK,KAAK,GAAG;EAKxD,UAAU;EACV,OAAO,QAAQ,MAAM,QAAQ,MAAM;EACnC;EACA;EACA,iBAAiB;EACjB,WAAW,MAAM,aAAa,CAAC,CAAC,OAAO,OAAO;EAC9C,SAAS,MAAM,WAAW,CAAC,EAAE,MAAM,aAAa,OAAO,WAAW;EAClE,WAAW,MAAM,aAAa,OAAO,WAAW;EAChD,GAAI,WAAW,EAAE,YAAY,MAAM,GAAG,EAAE;EACxC,GAAI,YAAY,CAAC,MAAM,cAAc,MAAM,uBAAuB,SAC9D,EAAE,oBAAoB,MAAM,GAC5B,EAAE;EACN,aAAa,MAAM;EACnB,SAAS,MAAM,YAAY,SAAY,MAAM,UAAU,OAAO,OAAO;EACrE,cACE,MAAM,iBAAiB,SAAY,MAAM,eAAe,OAAO,OAAO;EACzE"}
|
|
@@ -23,7 +23,18 @@ type UseFieldPropsParams = {
|
|
|
23
23
|
*/
|
|
24
24
|
unsafe__isDisabled?: boolean;
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The single entry point for input components (see
|
|
28
|
+
* `docs/rules/input-components.md`).
|
|
29
|
+
*
|
|
30
|
+
* Every hook below runs on every render, whatever the mode: standalone (no
|
|
31
|
+
* `name`), inside the deprecated `<Field>`, disabled through
|
|
32
|
+
* `unsafe__isDisabled`, or bound to a form. The mode only decides which props
|
|
33
|
+
* come back, so an input can gain or lose a `name`, or move between forms,
|
|
34
|
+
* without changing its hook order. The legacy binding (`useField`) is the
|
|
35
|
+
* legacy backend's adapter and is inert when the field is not bound to it.
|
|
36
|
+
*/
|
|
37
|
+
declare function useFieldProps<T extends FieldTypes, Props extends UseFieldProps<T>>(inputProps: Props, params?: UseFieldPropsParams): Props;
|
|
27
38
|
//#endregion
|
|
28
39
|
export { UseFieldPropsParams, useFieldProps };
|
|
29
40
|
//# sourceMappingURL=use-field-props.d.ts.map
|
|
@@ -1,71 +1,88 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps } from "../../../../utils/react/mergeProps.js";
|
|
3
3
|
import { useEvent } from "../../../../_internal/hooks/use-event.js";
|
|
4
4
|
import { warn } from "../../../../utils/warnings.js";
|
|
5
5
|
import { useProviderProps } from "../../../../provider.js";
|
|
6
6
|
import { useValidationProps } from "../../validation/use-validation-props.js";
|
|
7
|
+
import { isModernFormController } from "../backend.js";
|
|
7
8
|
import { useFormProps } from "../Form.js";
|
|
8
|
-
import {
|
|
9
|
+
import { useFieldBinding } from "./use-field-binding.js";
|
|
9
10
|
import { useInsideLegacyField } from "../Field.js";
|
|
10
|
-
import { useDebugValue, useId,
|
|
11
|
+
import { useDebugValue, useId, useState } from "react";
|
|
11
12
|
|
|
12
13
|
//#region src/components/form/Form/use-field/use-field-props.tsx
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const defaultValuePropsMapper = ({ value, onChange }) => ({
|
|
15
|
+
value: value ?? null,
|
|
16
|
+
onChange
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* The single entry point for input components (see
|
|
20
|
+
* `docs/rules/input-components.md`).
|
|
21
|
+
*
|
|
22
|
+
* Every hook below runs on every render, whatever the mode: standalone (no
|
|
23
|
+
* `name`), inside the deprecated `<Field>`, disabled through
|
|
24
|
+
* `unsafe__isDisabled`, or bound to a form. The mode only decides which props
|
|
25
|
+
* come back, so an input can gain or lose a `name`, or move between forms,
|
|
26
|
+
* without changing its hook order. The legacy binding (`useField`) is the
|
|
27
|
+
* legacy backend's adapter and is inert when the field is not bound to it.
|
|
28
|
+
*/
|
|
29
|
+
function useFieldProps(inputProps, params = {}) {
|
|
30
|
+
const props = useValidationProps(useFormProps(useProviderProps(inputProps)));
|
|
31
|
+
const [isDisabled] = useState(params.unsafe__isDisabled ?? false);
|
|
32
|
+
const { valuePropsMapper = defaultValuePropsMapper, defaultValidationTrigger = "onBlur" } = params;
|
|
24
33
|
const isInsideLegacyField = useInsideLegacyField();
|
|
25
34
|
if (props.rules && !props.name) warn(`The "rules" prop is not suitable for fields that are not part of a form. Use "name" prop to link the field to a form.`);
|
|
26
|
-
if (isInsideLegacyField || isDisabledRef.current === true) return props;
|
|
27
35
|
const hasName = props.name != null;
|
|
28
36
|
const generatedId = useId();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
if (result.id && !result.labelProps) result.labelProps = { for: result.id };
|
|
36
|
-
else if (result.id && result.labelProps && !result.labelProps.for) result.labelProps = {
|
|
37
|
-
...result.labelProps,
|
|
38
|
-
for: result.id
|
|
39
|
-
};
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
return props;
|
|
43
|
-
}
|
|
44
|
-
const field = useField(props, { defaultValidationTrigger: params.defaultValidationTrigger });
|
|
37
|
+
const isBound = hasName && !isInsideLegacyField && !isDisabled;
|
|
38
|
+
const field = useFieldBinding(props, {
|
|
39
|
+
defaultValidationTrigger: params.defaultValidationTrigger,
|
|
40
|
+
unbound: !isBound
|
|
41
|
+
}, generatedId);
|
|
45
42
|
const isOutsideOfForm = field?.form == null;
|
|
46
|
-
if (props.rules && isOutsideOfForm) warn(`The "rules" prop is not supported for fields that are not part of a form. The "${props.name}" field is placed outside the form.`);
|
|
47
43
|
const onChangeEvent = useEvent((value, dontTouch) => {
|
|
48
44
|
field?.onChange?.(value, dontTouch, field?.validateTrigger ?? defaultValidationTrigger);
|
|
49
45
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
46
|
+
function resolveResult() {
|
|
47
|
+
if (isInsideLegacyField || isDisabled) return props;
|
|
48
|
+
if (!hasName) {
|
|
49
|
+
if (!props.id) {
|
|
50
|
+
const result = {
|
|
51
|
+
...props,
|
|
52
|
+
id: generatedId
|
|
53
|
+
};
|
|
54
|
+
if (result.id && !result.labelProps) result.labelProps = { for: result.id };
|
|
55
|
+
else if (result.id && result.labelProps && !result.labelProps.for) result.labelProps = {
|
|
56
|
+
...result.labelProps,
|
|
57
|
+
for: result.id
|
|
58
|
+
};
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
return props;
|
|
62
|
+
}
|
|
63
|
+
if (props.rules && isOutsideOfForm) warn(`The "rules" prop is not supported for fields that are not part of a form. The "${props.name}" field is placed outside the form.`);
|
|
64
|
+
const valueProps = !isOutsideOfForm ? valuePropsMapper({
|
|
65
|
+
value: field.value,
|
|
66
|
+
onChange: onChangeEvent
|
|
67
|
+
}) : {};
|
|
68
|
+
const { form: _form, onChange: _fieldOnChange, onBlur: _fieldOnBlur, ...fieldRest } = field ?? {};
|
|
69
|
+
const result = isOutsideOfForm ? props : mergeProps(props, fieldRest, valueProps, {
|
|
70
|
+
validateTrigger: field.validateTrigger ?? defaultValidationTrigger,
|
|
71
|
+
onBlur: field.onBlur
|
|
72
|
+
});
|
|
73
|
+
return result.id ? {
|
|
74
|
+
...result,
|
|
75
|
+
labelProps: {
|
|
76
|
+
...result.labelProps,
|
|
77
|
+
for: result.id
|
|
78
|
+
}
|
|
79
|
+
} : result;
|
|
68
80
|
}
|
|
81
|
+
const resolved = resolveResult();
|
|
82
|
+
const result = isModernFormController(resolved.form) ? {
|
|
83
|
+
...resolved,
|
|
84
|
+
form: void 0
|
|
85
|
+
} : resolved;
|
|
69
86
|
useDebugValue(result);
|
|
70
87
|
return result;
|
|
71
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-field-props.js","names":[],"sources":["../../../../../src/components/form/Form/use-field/use-field-props.tsx"],"sourcesContent":["import { useDebugValue, useId,
|
|
1
|
+
{"version":3,"file":"use-field-props.js","names":[],"sources":["../../../../../src/components/form/Form/use-field/use-field-props.tsx"],"sourcesContent":["import { useDebugValue, useId, useState } from 'react';\n\nimport { useEvent } from '../../../../_internal/index';\nimport { useProviderProps } from '../../../../provider';\nimport { mergeProps } from '../../../../utils/react/index';\nimport { warn } from '../../../../utils/warnings';\nimport { useValidationProps } from '../../validation/index';\nimport { isModernFormController } from '../backend';\nimport { useInsideLegacyField } from '../Field';\nimport { useFormProps } from '../Form';\n\nimport { useFieldBinding } from './use-field-binding';\n\nimport type { ValidateTrigger } from '../../../../shared/index';\nimport type { FieldTypes } from '../types';\nimport type { UseFieldProps } from './types';\n\nexport type UseFieldPropsParams = {\n valuePropsMapper?: ({ value, onChange }) => any;\n /**\n * @default 'onBlur'\n */\n defaultValidationTrigger?: ValidateTrigger;\n /**\n * prop helps to prevent calling hook conditionally, but changing this prop during render is unsafe and forbidden\n * If you want to change this prop after mount, remount the component with a new value.\n */\n unsafe__isDisabled?: boolean;\n};\n\nconst defaultValuePropsMapper = ({ value, onChange }) => ({\n value: value ?? null,\n onChange,\n});\n\n/**\n * The single entry point for input components (see\n * `docs/rules/input-components.md`).\n *\n * Every hook below runs on every render, whatever the mode: standalone (no\n * `name`), inside the deprecated `<Field>`, disabled through\n * `unsafe__isDisabled`, or bound to a form. The mode only decides which props\n * come back, so an input can gain or lose a `name`, or move between forms,\n * without changing its hook order. The legacy binding (`useField`) is the\n * legacy backend's adapter and is inert when the field is not bound to it.\n */\nexport function useFieldProps<\n T extends FieldTypes,\n Props extends UseFieldProps<T>,\n>(inputProps: Props, params: UseFieldPropsParams = {}): Props {\n // Provider defaults, then form context, then the normalization of the\n // deprecated `validationState` prop into `isInvalid`/`isValid`.\n const props: Props = useValidationProps(\n useFormProps(useProviderProps(inputProps)),\n );\n\n // The initial value is what counts: changing it after mount is unsupported.\n const [isDisabled] = useState(params.unsafe__isDisabled ?? false);\n\n const {\n valuePropsMapper = defaultValuePropsMapper,\n defaultValidationTrigger = 'onBlur',\n } = params;\n\n const isInsideLegacyField = useInsideLegacyField();\n\n if (props.rules && !props.name) {\n warn(\n `The \"rules\" prop is not suitable for fields that are not part of a form. Use \"name\" prop to link the field to a form.`,\n );\n }\n\n const hasName = props.name != null;\n const generatedId = useId();\n const isBound = hasName && !isInsideLegacyField && !isDisabled;\n\n const field = useFieldBinding<T, Props>(\n props,\n {\n defaultValidationTrigger: params.defaultValidationTrigger,\n unbound: !isBound,\n },\n generatedId,\n );\n\n const isOutsideOfForm = field?.form == null;\n\n const onChangeEvent = useEvent((value, dontTouch: boolean) => {\n field?.onChange?.(\n value,\n dontTouch,\n field?.validateTrigger ?? defaultValidationTrigger,\n );\n });\n\n function resolveResult(): Props {\n if (isInsideLegacyField || isDisabled) {\n return props;\n }\n\n if (!hasName) {\n // Standalone field - just add generated ID if not provided\n if (!props.id) {\n const result = { ...props, id: generatedId };\n\n if (result.id && !result.labelProps) {\n result.labelProps = { for: result.id };\n } else if (result.id && result.labelProps && !result.labelProps.for) {\n result.labelProps = { ...result.labelProps, for: result.id };\n }\n\n return result as Props;\n }\n return props;\n }\n\n if (props.rules && isOutsideOfForm) {\n warn(\n `The \"rules\" prop is not supported for fields that are not part of a form. The \"${props.name}\" field is placed outside the form.`,\n );\n }\n\n const valueProps = !isOutsideOfForm\n ? valuePropsMapper({\n value: field.value,\n onChange: onChangeEvent,\n })\n : {};\n\n // Exclude `form` (it must never reach a DOM node) and the field's own\n // handlers: `valueProps` already routes the component's change event into\n // `field.onChange` under the name the component listens to, and `onBlur` is\n // added once below. `mergeProps` chains same-named handlers, so merging them\n // here as well made every user change and every blur run the field handler\n // twice — and onChange/onBlur-triggered validation validate twice.\n const {\n form: _form,\n onChange: _fieldOnChange,\n onBlur: _fieldOnBlur,\n ...fieldRest\n } = field ?? {};\n\n const result: Props = isOutsideOfForm\n ? props\n : mergeProps(props, fieldRest, valueProps, {\n validateTrigger: field.validateTrigger ?? defaultValidationTrigger,\n // Chained after the caller's own `onBlur` by `mergeProps`.\n onBlur: field.onBlur,\n });\n\n return result.id\n ? { ...result, labelProps: { ...result.labelProps, for: result.id } }\n : result;\n }\n\n const resolved = resolveResult();\n // React Aria forwards `form` to native inputs. A modern controller is a\n // binding source, never an HTML form id, including in standalone/group mode.\n const result = isModernFormController(resolved.form)\n ? { ...resolved, form: undefined }\n : resolved;\n\n useDebugValue(result);\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,MAAM,2BAA2B,EAAE,OAAO,gBAAgB;CACxD,OAAO,SAAS;CAChB;CACD;;;;;;;;;;;;AAaD,SAAgB,cAGd,YAAmB,SAA8B,EAAE,EAAS;CAG5D,MAAM,QAAe,mBACnB,aAAa,iBAAiB,WAAW,CAAC,CAC3C;CAGD,MAAM,CAAC,cAAc,SAAS,OAAO,sBAAsB,MAAM;CAEjE,MAAM,EACJ,mBAAmB,yBACnB,2BAA2B,aACzB;CAEJ,MAAM,sBAAsB,sBAAsB;AAElD,KAAI,MAAM,SAAS,CAAC,MAAM,KACxB,MACE,wHACD;CAGH,MAAM,UAAU,MAAM,QAAQ;CAC9B,MAAM,cAAc,OAAO;CAC3B,MAAM,UAAU,WAAW,CAAC,uBAAuB,CAAC;CAEpD,MAAM,QAAQ,gBACZ,OACA;EACE,0BAA0B,OAAO;EACjC,SAAS,CAAC;EACX,EACD,YACD;CAED,MAAM,kBAAkB,OAAO,QAAQ;CAEvC,MAAM,gBAAgB,UAAU,OAAO,cAAuB;AAC5D,SAAO,WACL,OACA,WACA,OAAO,mBAAmB,yBAC3B;GACD;CAEF,SAAS,gBAAuB;AAC9B,MAAI,uBAAuB,WACzB,QAAO;AAGT,MAAI,CAAC,SAAS;AAEZ,OAAI,CAAC,MAAM,IAAI;IACb,MAAM,SAAS;KAAE,GAAG;KAAO,IAAI;KAAa;AAE5C,QAAI,OAAO,MAAM,CAAC,OAAO,WACvB,QAAO,aAAa,EAAE,KAAK,OAAO,IAAI;aAC7B,OAAO,MAAM,OAAO,cAAc,CAAC,OAAO,WAAW,IAC9D,QAAO,aAAa;KAAE,GAAG,OAAO;KAAY,KAAK,OAAO;KAAI;AAG9D,WAAO;;AAET,UAAO;;AAGT,MAAI,MAAM,SAAS,gBACjB,MACE,kFAAkF,MAAM,KAAK,qCAC9F;EAGH,MAAM,aAAa,CAAC,kBAChB,iBAAiB;GACf,OAAO,MAAM;GACb,UAAU;GACX,CAAC,GACF,EAAE;EAQN,MAAM,EACJ,MAAM,OACN,UAAU,gBACV,QAAQ,cACR,GAAG,cACD,SAAS,EAAE;EAEf,MAAM,SAAgB,kBAClB,QACA,WAAW,OAAO,WAAW,YAAY;GACvC,iBAAiB,MAAM,mBAAmB;GAE1C,QAAQ,MAAM;GACf,CAAC;AAEN,SAAO,OAAO,KACV;GAAE,GAAG;GAAQ,YAAY;IAAE,GAAG,OAAO;IAAY,KAAK,OAAO;IAAI;GAAE,GACnE;;CAGN,MAAM,WAAW,eAAe;CAGhC,MAAM,SAAS,uBAAuB,SAAS,KAAK,GAChD;EAAE,GAAG;EAAU,MAAM;EAAW,GAChC;AAEJ,eAAc,OAAO;AAErB,QAAO"}
|
|
@@ -7,6 +7,12 @@ import { FieldReturnValue, UseFieldProps } from "./types.js";
|
|
|
7
7
|
//#region src/components/form/Form/use-field/use-field.d.ts
|
|
8
8
|
type UseFieldParams = {
|
|
9
9
|
defaultValidationTrigger?: ValidateTrigger;
|
|
10
|
+
/**
|
|
11
|
+
* Run without a binding: `useFieldProps` sets this for an input that is
|
|
12
|
+
* standalone, inside the deprecated `<Field>` or disabled, so that this hook
|
|
13
|
+
* is still called (stable hook order) but registers nothing.
|
|
14
|
+
*/
|
|
15
|
+
unbound?: boolean;
|
|
10
16
|
};
|
|
11
17
|
declare function useField<T extends FieldTypes, Props extends UseFieldProps<T>>(props: Props, params: UseFieldParams): FieldReturnValue<T>;
|
|
12
18
|
//#endregion
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
|
+
import { useLayoutEffect as useLayoutEffect$1 } from "../../../../utils/react/useLayoutEffect.js";
|
|
2
3
|
import { useEvent } from "../../../../_internal/hooks/use-event.js";
|
|
3
4
|
import { useIsFirstRender } from "../../../../_internal/hooks/use-is-first-render.js";
|
|
4
5
|
import { resolveValidationProps } from "../../validation/resolve-validation-props.js";
|
|
6
|
+
import { isModernFormController, modernBackendUnavailableError } from "../backend.js";
|
|
5
7
|
import { delayValidationRule } from "../validation.js";
|
|
6
8
|
import { useFormProps } from "../Form.js";
|
|
7
9
|
import { useEffect, useMemo, useState } from "react";
|
|
@@ -26,7 +28,13 @@ function removeId(name, id) {
|
|
|
26
28
|
}
|
|
27
29
|
function useField(props, params) {
|
|
28
30
|
props = useFormProps(props);
|
|
29
|
-
let { defaultValue, id, idPrefix, name, form, rules, message, description, errorMessage, validateTrigger = params.defaultValidationTrigger, validationDelay, showValid, shouldUpdate, isRequired: isRequiredProp, necessityIndicator: necessityIndicatorProp } = props;
|
|
31
|
+
let { defaultValue, id, idPrefix, name, form: sourceForm, rules, message, description, errorMessage, validateTrigger = params.defaultValidationTrigger, validationDelay, showValid, shouldUpdate, isRequired: isRequiredProp, necessityIndicator: necessityIndicatorProp } = props;
|
|
32
|
+
if (params.unbound) {
|
|
33
|
+
name = void 0;
|
|
34
|
+
sourceForm = void 0;
|
|
35
|
+
}
|
|
36
|
+
if (!params.unbound && isModernFormController(sourceForm)) throw modernBackendUnavailableError(name != null ? `The "${name}" field` : "A field without a name");
|
|
37
|
+
const form = sourceForm;
|
|
30
38
|
const { isInvalid: isInvalidProp, isValid: isValidProp } = resolveValidationProps(props);
|
|
31
39
|
const processedRules = useMemo(() => {
|
|
32
40
|
let finalRules = rules;
|
|
@@ -43,29 +51,37 @@ function useField(props, params) {
|
|
|
43
51
|
const nonInput = !name;
|
|
44
52
|
const fieldName = name != null ? name : "";
|
|
45
53
|
const isFirstRender = useIsFirstRender();
|
|
46
|
-
|
|
54
|
+
const baseId = id || (idPrefix ? `${idPrefix}_${fieldName}` : fieldName);
|
|
55
|
+
const [assignedId, setAssignedId] = useState({
|
|
56
|
+
base: baseId,
|
|
57
|
+
id: baseId
|
|
58
|
+
});
|
|
59
|
+
const currentId = id || (assignedId.base === baseId ? assignedId.id : baseId);
|
|
60
|
+
useLayoutEffect$1(() => {
|
|
61
|
+
if (id || nonInput) return;
|
|
62
|
+
const newId = createId(baseId);
|
|
63
|
+
setAssignedId((previous) => previous.base === baseId && previous.id === newId ? previous : {
|
|
64
|
+
base: baseId,
|
|
65
|
+
id: newId
|
|
66
|
+
});
|
|
67
|
+
return () => {
|
|
68
|
+
removeId(baseId, newId);
|
|
69
|
+
};
|
|
70
|
+
}, [
|
|
71
|
+
baseId,
|
|
72
|
+
id,
|
|
73
|
+
nonInput
|
|
74
|
+
]);
|
|
75
|
+
const [boundForms] = useState(() => /* @__PURE__ */ new Set());
|
|
47
76
|
useEffect(() => {
|
|
48
|
-
let newId;
|
|
49
|
-
if (!id && !nonInput) {
|
|
50
|
-
newId = createId(fieldId);
|
|
51
|
-
setFieldId(newId);
|
|
52
|
-
}
|
|
53
77
|
return () => {
|
|
54
|
-
if (
|
|
55
|
-
|
|
78
|
+
if (fieldName) boundForms.forEach((boundForm) => boundForm.removeField(fieldName));
|
|
79
|
+
boundForms.clear();
|
|
56
80
|
};
|
|
57
|
-
}, [fieldName]);
|
|
81
|
+
}, [fieldName, boundForms]);
|
|
58
82
|
let field = form?.getFieldInstance(fieldName);
|
|
59
|
-
if (field) field.rules = processedRules;
|
|
60
|
-
let isRequired = !!processedRules?.find((rule) => "required" in rule && rule.required === true);
|
|
61
|
-
const suppressNecessityIndicator = isRequired && !isRequiredProp && necessityIndicatorProp === void 0;
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (!form) return;
|
|
64
|
-
if (field) form.forceReRender();
|
|
65
|
-
else field = form.createField(fieldName);
|
|
66
|
-
}, [field]);
|
|
67
83
|
if (form) {
|
|
68
|
-
if (isFirstRender) {
|
|
84
|
+
if (isFirstRender || !field && fieldName) {
|
|
69
85
|
if (!field) field = form.createField(fieldName, true);
|
|
70
86
|
if (field?.value == null && defaultValue != null) {
|
|
71
87
|
form.setFieldValue(fieldName, defaultValue, false, true);
|
|
@@ -75,6 +91,15 @@ function useField(props, params) {
|
|
|
75
91
|
}
|
|
76
92
|
if (!field?.touched && defaultValue != null) form.setFieldValue(fieldName, defaultValue, false, true);
|
|
77
93
|
}
|
|
94
|
+
if (field) field.rules = processedRules;
|
|
95
|
+
let isRequired = !!processedRules?.find((rule) => "required" in rule && rule.required === true);
|
|
96
|
+
const suppressNecessityIndicator = isRequired && !isRequiredProp && necessityIndicatorProp === void 0;
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (form && field) {
|
|
99
|
+
boundForms.add(form);
|
|
100
|
+
form.forceReRender();
|
|
101
|
+
}
|
|
102
|
+
}, [field, boundForms]);
|
|
78
103
|
const onChangeHandler = useEvent((val, dontTouch) => {
|
|
79
104
|
if (!form) return;
|
|
80
105
|
const field = form.getFieldInstance(fieldName);
|
|
@@ -95,7 +120,7 @@ function useField(props, params) {
|
|
|
95
120
|
});
|
|
96
121
|
let value = field?.value;
|
|
97
122
|
return useMemo(() => ({
|
|
98
|
-
id:
|
|
123
|
+
id: currentId,
|
|
99
124
|
name: fieldName,
|
|
100
125
|
value,
|
|
101
126
|
validateTrigger,
|
|
@@ -117,7 +142,7 @@ function useField(props, params) {
|
|
|
117
142
|
field?.value,
|
|
118
143
|
field?.errors?.length,
|
|
119
144
|
field?.status,
|
|
120
|
-
|
|
145
|
+
currentId,
|
|
121
146
|
fieldName,
|
|
122
147
|
isRequired,
|
|
123
148
|
suppressNecessityIndicator,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-field.js","names":[],"sources":["../../../../../src/components/form/Form/use-field/use-field.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\n\nimport { useEvent, useIsFirstRender } from '../../../../_internal/index';\nimport { ValidateTrigger } from '../../../../shared/index';\nimport { resolveValidationProps } from '../../validation/index';\nimport { useFormProps } from '../Form';\nimport { FieldTypes } from '../types';\nimport { delayValidationRule } from '../validation';\n\nimport { FieldReturnValue, UseFieldProps } from './types';\n\nconst ID_MAP = {};\n\nfunction createId(name) {\n if (!name) return;\n\n if (!ID_MAP[name]) {\n ID_MAP[name] = [];\n }\n\n let i = 0;\n let id;\n\n do {\n id = i ? `${name}_${i}` : name;\n i++;\n } while (ID_MAP[name].includes(id));\n\n ID_MAP[name].push(id);\n\n return id;\n}\n\nfunction removeId(name, id) {\n if (!ID_MAP[name]) return;\n\n ID_MAP[name] = ID_MAP[name].filter((_id) => _id !== id);\n}\n\nexport type UseFieldParams = {\n defaultValidationTrigger?: ValidateTrigger;\n};\n\nexport function useField<T extends FieldTypes, Props extends UseFieldProps<T>>(\n props: Props,\n params: UseFieldParams,\n): FieldReturnValue<T> {\n props = useFormProps(props);\n\n let {\n defaultValue,\n id,\n idPrefix,\n name,\n form,\n rules,\n message,\n description,\n errorMessage,\n validateTrigger = params.defaultValidationTrigger,\n validationDelay,\n showValid,\n shouldUpdate,\n isRequired: isRequiredProp,\n necessityIndicator: necessityIndicatorProp,\n } = props;\n\n const { isInvalid: isInvalidProp, isValid: isValidProp } =\n resolveValidationProps(props);\n\n const processedRules = useMemo(() => {\n let finalRules = rules;\n\n // If isRequired prop is set, ensure there's a required rule\n if (isRequiredProp) {\n const hasRequiredRule = finalRules?.some(\n (rule) => 'required' in rule && rule.required === true,\n );\n\n if (!hasRequiredRule) {\n finalRules = finalRules\n ? [{ required: true }, ...finalRules]\n : [{ required: true }];\n }\n }\n\n // Add delay rule if needed\n if (finalRules && finalRules.length && validationDelay) {\n return [delayValidationRule(validationDelay), ...finalRules];\n }\n\n return finalRules;\n }, [rules, validationDelay, isRequiredProp]);\n\n const nonInput = !name;\n const fieldName: string = name != null ? name : '';\n\n const isFirstRender = useIsFirstRender();\n let [fieldId, setFieldId] = useState(\n id || (idPrefix ? `${idPrefix}_${fieldName}` : fieldName),\n );\n\n useEffect(() => {\n let newId;\n\n if (!id && !nonInput) {\n newId = createId(fieldId);\n\n setFieldId(newId);\n }\n\n return () => {\n if (!id) {\n removeId(idPrefix ? `${idPrefix}_${fieldName}` : fieldName, newId);\n }\n\n if (fieldName && form) {\n form.removeField(fieldName);\n }\n };\n }, [fieldName]);\n\n let field = form?.getFieldInstance(fieldName);\n\n if (field) {\n field.rules = processedRules;\n }\n\n let isRequired = !!processedRules?.find(\n (rule) => 'required' in rule && rule.required === true,\n );\n\n // `isRequired` has two sources with different intent. A `required` rule states\n // how the field behaves: it is what validation runs, and `aria-required` is\n // its programmatic mirror, so the flag has to reach the input either way. The\n // `isRequired` prop additionally states what the label should say. So unless\n // the prop itself asked for the marker, suppress it — an absent prop and an\n // explicit `isRequired={false}` both mean \"do not mark this\", the latter\n // rather more loudly. An explicit `necessityIndicator` overrides either way,\n // being a request for the marker in its own right.\n const suppressNecessityIndicator =\n isRequired && !isRequiredProp && necessityIndicatorProp === undefined;\n\n useEffect(() => {\n if (!form) return;\n\n if (field) {\n form.forceReRender();\n } else {\n field = form.createField(fieldName);\n }\n }, [field]);\n\n if (form) {\n if (isFirstRender) {\n if (!field) {\n field = form.createField(fieldName, true);\n }\n\n if (field?.value == null && defaultValue != null) {\n form.setFieldValue(fieldName, defaultValue, false, true);\n form.updateInitialFieldsValue({ [fieldName]: defaultValue });\n\n field = form?.getFieldInstance(fieldName);\n }\n }\n\n if (!field?.touched && defaultValue != null) {\n form.setFieldValue(fieldName, defaultValue, false, true);\n }\n }\n\n const onChangeHandler = useEvent((val: any, dontTouch: boolean) => {\n if (!form) return;\n\n const field = form.getFieldInstance(fieldName);\n\n if (shouldUpdate) {\n const fieldsValue = form.getFieldsValue();\n\n // check if we should update the value of the field\n const shouldNotBeUpdated =\n typeof shouldUpdate === 'boolean'\n ? !shouldUpdate\n : !shouldUpdate(fieldsValue, {\n ...fieldsValue,\n [fieldName]: val,\n });\n\n if (shouldNotBeUpdated) {\n return;\n }\n }\n\n form.setFieldValue(fieldName, val, !dontTouch);\n\n if (\n !dontTouch &&\n (validateTrigger === 'onChange' ||\n (field && field.errors && field.errors.length))\n ) {\n form.validateField(fieldName).catch(() => {}); // do nothing on fail\n }\n });\n\n const onBlurHandler = useEvent(() => {\n if (validateTrigger === 'onBlur') {\n // We need a timeout so the change event can be done.\n setTimeout(() => {\n form?.validateField(fieldName).catch(() => {}); // do nothing on fail\n });\n }\n });\n\n let value = field?.value;\n\n return useMemo(\n () => ({\n id: fieldId,\n name: fieldName,\n value,\n validateTrigger,\n form,\n field,\n nonInput,\n\n // Explicit validation props always win over the state derived from the form\n isInvalid: isInvalidProp ?? !!field?.errors?.length,\n isValid: isValidProp ?? !!(showValid && field?.status === 'valid'),\n ...(isRequired && { isRequired }),\n ...(suppressNecessityIndicator && { necessityIndicator: null }),\n message:\n message !== undefined\n ? message\n : field?.status === 'invalid' && field?.errors?.[0],\n description,\n errorMessage:\n errorMessage !== undefined\n ? errorMessage\n : field?.status === 'invalid' && field?.errors?.length\n ? field.errors[0]\n : undefined,\n onBlur: onBlurHandler,\n onChange: onChangeHandler,\n }),\n [\n form,\n field,\n field?.value,\n field?.errors?.length,\n field?.status,\n fieldId,\n fieldName,\n isRequired,\n suppressNecessityIndicator,\n message,\n description,\n errorMessage,\n onBlurHandler,\n onChangeHandler,\n validateTrigger,\n isInvalidProp,\n isValidProp,\n showValid,\n nonInput,\n ],\n );\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"use-field.js","names":[],"sources":["../../../../../src/components/form/Form/use-field/use-field.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\n\nimport { useEvent, useIsFirstRender } from '../../../../_internal/index';\nimport { ValidateTrigger } from '../../../../shared/index';\nimport { useLayoutEffect } from '../../../../utils/react/useLayoutEffect';\nimport { resolveValidationProps } from '../../validation/index';\nimport {\n isModernFormController,\n modernBackendUnavailableError,\n} from '../backend';\nimport { useFormProps } from '../Form';\nimport { FieldTypes } from '../types';\nimport { delayValidationRule } from '../validation';\n\nimport { FieldReturnValue, UseFieldProps } from './types';\n\nimport type { CubeFormInstance } from '../use-form';\n\nconst ID_MAP = {};\n\nfunction createId(name) {\n if (!name) return;\n\n if (!ID_MAP[name]) {\n ID_MAP[name] = [];\n }\n\n let i = 0;\n let id;\n\n do {\n id = i ? `${name}_${i}` : name;\n i++;\n } while (ID_MAP[name].includes(id));\n\n ID_MAP[name].push(id);\n\n return id;\n}\n\nfunction removeId(name, id) {\n if (!ID_MAP[name]) return;\n\n ID_MAP[name] = ID_MAP[name].filter((_id) => _id !== id);\n}\n\nexport type UseFieldParams = {\n defaultValidationTrigger?: ValidateTrigger;\n /**\n * Run without a binding: `useFieldProps` sets this for an input that is\n * standalone, inside the deprecated `<Field>` or disabled, so that this hook\n * is still called (stable hook order) but registers nothing.\n */\n unbound?: boolean;\n};\n\nexport function useField<T extends FieldTypes, Props extends UseFieldProps<T>>(\n props: Props,\n params: UseFieldParams,\n): FieldReturnValue<T> {\n props = useFormProps(props);\n\n let {\n defaultValue,\n id,\n idPrefix,\n name,\n form: sourceForm,\n rules,\n message,\n description,\n errorMessage,\n validateTrigger = params.defaultValidationTrigger,\n validationDelay,\n showValid,\n shouldUpdate,\n isRequired: isRequiredProp,\n necessityIndicator: necessityIndicatorProp,\n } = props;\n\n if (params.unbound) {\n name = undefined;\n sourceForm = undefined;\n }\n\n if (!params.unbound && isModernFormController(sourceForm)) {\n throw modernBackendUnavailableError(\n name != null ? `The \"${name}\" field` : 'A field without a name',\n );\n }\n\n // A modern source is rejected above (or cleared when this adapter is inert).\n // Keep unbranded structural legacy instances supported as before.\n const form = sourceForm as CubeFormInstance<T> | undefined;\n\n const { isInvalid: isInvalidProp, isValid: isValidProp } =\n resolveValidationProps(props);\n\n const processedRules = useMemo(() => {\n let finalRules = rules;\n\n // If isRequired prop is set, ensure there's a required rule\n if (isRequiredProp) {\n const hasRequiredRule = finalRules?.some(\n (rule) => 'required' in rule && rule.required === true,\n );\n\n if (!hasRequiredRule) {\n finalRules = finalRules\n ? [{ required: true }, ...finalRules]\n : [{ required: true }];\n }\n }\n\n // Add delay rule if needed\n if (finalRules && finalRules.length && validationDelay) {\n return [delayValidationRule(validationDelay), ...finalRules];\n }\n\n return finalRules;\n }, [rules, validationDelay, isRequiredProp]);\n\n const nonInput = !name;\n const fieldName: string = name != null ? name : '';\n\n const isFirstRender = useIsFirstRender();\n const baseId = id || (idPrefix ? `${idPrefix}_${fieldName}` : fieldName);\n\n // The id the effect below registered, with the base it was registered for.\n // Between a base change and that effect's next run the state is stale, and\n // handing it out would let the element carry the previous binding's id for\n // one commit — which can duplicate a sibling's live id — so the current base\n // is used until the effect catches up. An explicit `id` is used as it is.\n const [assignedId, setAssignedId] = useState({ base: baseId, id: baseId });\n const currentId = id || (assignedId.base === baseId ? assignedId.id : baseId);\n\n // Ids are registered per base (form name prefix plus field name), so that\n // duplicates get a suffix and the base is released when it changes or the\n // input unmounts. `id` and `nonInput` cannot change without the base. A\n // layout effect: when the base changes, the commit that carries the\n // unsuffixed base is corrected before the browser paints, so a duplicate\n // never shows a colliding id.\n useLayoutEffect(() => {\n if (id || nonInput) return;\n\n const newId = createId(baseId);\n\n setAssignedId((previous) =>\n previous.base === baseId && previous.id === newId\n ? previous\n : { base: baseId, id: newId },\n );\n\n return () => {\n removeId(baseId, newId);\n };\n }, [baseId, id, nonInput]);\n\n // Every form this hook registered the current name with. The dual-backend\n // shell keeps the hook mounted for standalone inputs, so a form may arrive\n // later or change, and the name may change; the name is released from all\n // of them, not from whichever form a closure happened to capture. This is\n // state rather than a ref only to keep render free of ref access.\n const [boundForms] = useState(() => new Set<CubeFormInstance<any>>());\n\n useEffect(() => {\n return () => {\n if (fieldName) {\n boundForms.forEach((boundForm) => boundForm.removeField(fieldName));\n }\n\n boundForms.clear();\n };\n }, [fieldName, boundForms]);\n\n let field = form?.getFieldInstance(fieldName);\n\n if (form) {\n // First render of this binding: the hook's first render, or a named field\n // that is not registered yet because the name or the form changed after\n // mount. Without a name the engine returns an unstored placeholder, so it\n // is only created on the first render, as before: creating it again on\n // every render would give the effect below a new object each time.\n if (isFirstRender || (!field && fieldName)) {\n if (!field) {\n field = form.createField(fieldName, true);\n }\n\n if (field?.value == null && defaultValue != null) {\n form.setFieldValue(fieldName, defaultValue, false, true);\n form.updateInitialFieldsValue({ [fieldName]: defaultValue });\n\n field = form?.getFieldInstance(fieldName);\n }\n }\n\n if (!field?.touched && defaultValue != null) {\n form.setFieldValue(fieldName, defaultValue, false, true);\n }\n }\n\n if (field) {\n field.rules = processedRules;\n }\n\n let isRequired = !!processedRules?.find(\n (rule) => 'required' in rule && rule.required === true,\n );\n\n // `isRequired` has two sources with different intent. A `required` rule states\n // how the field behaves: it is what validation runs, and `aria-required` is\n // its programmatic mirror, so the flag has to reach the input either way. The\n // `isRequired` prop additionally states what the label should say. So unless\n // the prop itself asked for the marker, suppress it — an absent prop and an\n // explicit `isRequired={false}` both mean \"do not mark this\", the latter\n // rather more loudly. An explicit `necessityIndicator` overrides either way,\n // being a request for the marker in its own right.\n const suppressNecessityIndicator =\n isRequired && !isRequiredProp && necessityIndicatorProp === undefined;\n\n // Registration happens during render. Once it is committed, remember the\n // form for the release above and re-render the form's owner so its\n // render-time reads see the new field. `form` is deliberately not a\n // dependency: a form whose identity changes on every render (a copy, an\n // inline mock) shares its store, and re-running here would loop.\n useEffect(() => {\n if (form && field) {\n boundForms.add(form);\n form.forceReRender();\n }\n }, [field, boundForms]);\n\n const onChangeHandler = useEvent((val: any, dontTouch: boolean) => {\n if (!form) return;\n\n const field = form.getFieldInstance(fieldName);\n\n if (shouldUpdate) {\n const fieldsValue = form.getFieldsValue();\n\n // check if we should update the value of the field\n const shouldNotBeUpdated =\n typeof shouldUpdate === 'boolean'\n ? !shouldUpdate\n : !shouldUpdate(fieldsValue, {\n ...fieldsValue,\n [fieldName]: val,\n });\n\n if (shouldNotBeUpdated) {\n return;\n }\n }\n\n form.setFieldValue(fieldName, val, !dontTouch);\n\n if (\n !dontTouch &&\n (validateTrigger === 'onChange' ||\n (field && field.errors && field.errors.length))\n ) {\n form.validateField(fieldName).catch(() => {}); // do nothing on fail\n }\n });\n\n const onBlurHandler = useEvent(() => {\n if (validateTrigger === 'onBlur') {\n // We need a timeout so the change event can be done.\n setTimeout(() => {\n form?.validateField(fieldName).catch(() => {}); // do nothing on fail\n });\n }\n });\n\n let value = field?.value;\n\n return useMemo(\n () => ({\n id: currentId,\n name: fieldName,\n value,\n validateTrigger,\n form,\n field,\n nonInput,\n\n // Explicit validation props always win over the state derived from the form\n isInvalid: isInvalidProp ?? !!field?.errors?.length,\n isValid: isValidProp ?? !!(showValid && field?.status === 'valid'),\n ...(isRequired && { isRequired }),\n ...(suppressNecessityIndicator && { necessityIndicator: null }),\n message:\n message !== undefined\n ? message\n : field?.status === 'invalid' && field?.errors?.[0],\n description,\n errorMessage:\n errorMessage !== undefined\n ? errorMessage\n : field?.status === 'invalid' && field?.errors?.length\n ? field.errors[0]\n : undefined,\n onBlur: onBlurHandler,\n onChange: onChangeHandler,\n }),\n [\n form,\n field,\n field?.value,\n field?.errors?.length,\n field?.status,\n currentId,\n fieldName,\n isRequired,\n suppressNecessityIndicator,\n message,\n description,\n errorMessage,\n onBlurHandler,\n onChangeHandler,\n validateTrigger,\n isInvalidProp,\n isValidProp,\n showValid,\n nonInput,\n ],\n );\n}\n"],"mappings":"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"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
import { CubeFieldData, FieldTypes, SetFieldsArrType } from "./types.js";
|
|
3
|
+
import { FORM_BACKEND, LegacyFormBrand } from "./backend.js";
|
|
3
4
|
import { ReactNode } from "react";
|
|
4
5
|
|
|
5
6
|
//#region src/components/form/Form/use-form.d.ts
|
|
6
7
|
type PartialString<T> = { [P in keyof T & string]?: T[P] };
|
|
7
8
|
type CubeFormData<T extends FieldTypes> = { [K in keyof T & string]?: CubeFieldData<K, T[K]> };
|
|
8
|
-
declare class CubeFormInstance<T extends FieldTypes, TFormData extends CubeFormData<T> = CubeFormData<T>> {
|
|
9
|
+
declare class CubeFormInstance<T extends FieldTypes, TFormData extends CubeFormData<T> = CubeFormData<T>> implements LegacyFormBrand {
|
|
10
|
+
/** Backend brand: the `<Form>` facade and the field hook dispatch on it. */
|
|
11
|
+
readonly [FORM_BACKEND]: "legacy";
|
|
9
12
|
forceReRender: () => void;
|
|
10
13
|
private defaultValues;
|
|
11
14
|
private fields;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
|
+
import { FORM_BACKEND, isModernFormController, modernBackendUnavailableError } from "./backend.js";
|
|
2
3
|
import { applyRules } from "./validation.js";
|
|
3
|
-
import {
|
|
4
|
+
import { dotizeConvert } from "../../../utils/dotize.js";
|
|
4
5
|
import { useRef, useState } from "react";
|
|
5
6
|
|
|
6
7
|
//#region src/components/form/Form/use-form.tsx
|
|
@@ -18,6 +19,8 @@ function isEqual(v1, v2) {
|
|
|
18
19
|
return JSON.stringify(v1) === JSON.stringify(v2);
|
|
19
20
|
}
|
|
20
21
|
var CubeFormInstance = class {
|
|
22
|
+
/** Backend brand: the `<Form>` facade and the field hook dispatch on it. */
|
|
23
|
+
[FORM_BACKEND] = "legacy";
|
|
21
24
|
forceReRender = () => {};
|
|
22
25
|
defaultValues = {};
|
|
23
26
|
fields = {};
|
|
@@ -55,7 +58,7 @@ var CubeFormInstance = class {
|
|
|
55
58
|
let flag = false;
|
|
56
59
|
newData = {
|
|
57
60
|
...newData,
|
|
58
|
-
...
|
|
61
|
+
...dotizeConvert(newData)
|
|
59
62
|
};
|
|
60
63
|
Object.keys(newData).forEach((name) => {
|
|
61
64
|
let field = this.fields[name];
|
|
@@ -127,14 +130,14 @@ var CubeFormInstance = class {
|
|
|
127
130
|
setInitialFieldsValue(values) {
|
|
128
131
|
this.defaultValues = {
|
|
129
132
|
...values,
|
|
130
|
-
...
|
|
133
|
+
...dotizeConvert(values)
|
|
131
134
|
};
|
|
132
135
|
}
|
|
133
136
|
updateInitialFieldsValue(values) {
|
|
134
137
|
this.defaultValues = {
|
|
135
138
|
...this.defaultValues,
|
|
136
139
|
...values,
|
|
137
|
-
...
|
|
140
|
+
...dotizeConvert(values)
|
|
138
141
|
};
|
|
139
142
|
}
|
|
140
143
|
resetFields(names, skipRender) {
|
|
@@ -318,6 +321,7 @@ var CubeFormInstance = class {
|
|
|
318
321
|
};
|
|
319
322
|
function useForm(form, ref, options = {}) {
|
|
320
323
|
const { onSubmit, onValuesChange } = options;
|
|
324
|
+
if (isModernFormController(form)) throw modernBackendUnavailableError("Form.useForm()");
|
|
321
325
|
const formRef = useRef(null);
|
|
322
326
|
const [, forceUpdate] = useState({});
|
|
323
327
|
if (!formRef.current) {
|