@cube-dev/ui-kit 0.179.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 +14 -0
- package/dist/_internal/hooks/use-debounced-value.js +1 -1
- package/dist/_internal/hooks/use-deprecation-warning.js +1 -1
- package/dist/_internal/hooks/use-event.js +1 -1
- package/dist/_internal/hooks/use-is-first-render.js +1 -1
- package/dist/_internal/hooks/use-sync-ref.js +1 -1
- package/dist/_internal/hooks/use-timer/timer.js +1 -1
- package/dist/_internal/hooks/use-timer/use-timer.js +1 -1
- package/dist/_internal/hooks/use-warn.js +1 -1
- package/dist/components/Block.js +1 -1
- package/dist/components/CollectionItem.js +1 -1
- package/dist/components/GlobalStyles.js +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/Button.d.ts +1 -0
- 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 +1 -1
- package/dist/components/actions/ItemButton/ItemButton.js +1 -1
- package/dist/components/actions/Link/Link.js +1 -1
- package/dist/components/actions/Menu/Menu.js +1 -1
- package/dist/components/actions/Menu/MenuItem.js +1 -1
- package/dist/components/actions/Menu/MenuSection.js +1 -1
- package/dist/components/actions/Menu/MenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubMenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubmenuTriggerContext.js +1 -1
- package/dist/components/actions/Menu/context.js +1 -1
- package/dist/components/actions/Menu/styled.js +1 -1
- package/dist/components/actions/actions-run.js +1 -1
- package/dist/components/actions/index.js +1 -1
- package/dist/components/actions/use-action.js +1 -1
- package/dist/components/actions/use-anchored-menu.js +1 -1
- package/dist/components/actions/use-context-menu.js +1 -1
- package/dist/components/content/ActiveZone/ActiveZone.js +1 -1
- package/dist/components/content/Alert/Alert.js +1 -1
- package/dist/components/content/Alert/use-alert.js +1 -1
- package/dist/components/content/Avatar/Avatar.js +1 -1
- package/dist/components/content/Badge/Badge.js +1 -1
- package/dist/components/content/Card/Card.js +1 -1
- package/dist/components/content/Content.js +1 -1
- package/dist/components/content/CopyPasteBlock/CopyPasteBlock.js +1 -1
- package/dist/components/content/CopySnippet/CopySnippet.js +1 -1
- package/dist/components/content/Disclosure/Disclosure.js +1 -1
- package/dist/components/content/Divider.js +1 -1
- package/dist/components/content/Footer.js +1 -1
- package/dist/components/content/Header.js +1 -1
- package/dist/components/content/HotKeys/HotKeys.js +1 -1
- package/dist/components/content/InfoBadge/InfoBadge.js +1 -1
- package/dist/components/content/InlineInput/InlineInput.js +1 -1
- package/dist/components/content/Item/Item.js +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.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.d.ts +2 -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.d.ts +1 -0
- 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 +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/index.d.ts +1 -0
- package/dist/components/fields/ListBoxPopover/listNavigation.js +1 -1
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.d.ts +2 -0
- 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 +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 +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 +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 +6 -2
- 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 +1 -1
- package/dist/components/navigation/Tabs/TabDropIndicator.js +1 -1
- package/dist/components/navigation/Tabs/TabPanel.js +1 -1
- package/dist/components/navigation/Tabs/TabPicker.js +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +1 -1
- package/dist/components/navigation/Tabs/TabsAction.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/popover-placement.js +1 -1
- package/dist/components/navigation/Tabs/styled.js +1 -1
- package/dist/components/navigation/Tabs/types.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-editing.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-indicator.js +1 -1
- package/dist/components/organisms/StatsCard/StatsCard.js +1 -1
- package/dist/components/other/Calendar/Calendar.js +1 -1
- package/dist/components/other/Calendar/CalendarCell.js +1 -1
- package/dist/components/other/Calendar/CalendarGrid.js +1 -1
- package/dist/components/other/Calendar/CalendarHeader.js +1 -1
- package/dist/components/other/Calendar/CalendarPanel.js +1 -1
- package/dist/components/other/Calendar/PeriodCalendar.js +1 -1
- package/dist/components/other/Calendar/PeriodGrid.js +1 -1
- package/dist/components/other/Calendar/RangeCalendar.js +1 -1
- package/dist/components/other/Calendar/styled.js +1 -1
- package/dist/components/other/CubeLogo/CubeLogo.js +1 -1
- package/dist/components/other/NoDataIcon/NoDataIcon.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogApiProvider.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogZone.js +1 -1
- package/dist/components/overlays/Dialog/Dialog.js +1 -1
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +1 -1
- package/dist/components/overlays/Dialog/DialogTrigger.js +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Modal/Modal.d.ts +2 -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.d.ts +1 -0
- 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/Modal/types.d.ts +1 -0
- 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.d.ts +2 -0
- 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.d.ts +2 -0
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/index.d.ts +1 -0
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +1 -1
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/Spin/Cube.js +1 -1
- package/dist/components/status/Spin/InternalSpinner.js +1 -1
- package/dist/components/status/Spin/Spin.js +1 -1
- package/dist/components/status/Spin/SpinsContainer.js +1 -1
- package/dist/data/item-themes.js +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/eslint-plugin/defaults.generated.js +1 -1
- package/dist/eslint-plugin/index.js +1 -1
- package/dist/eslint-plugin/rules/no-redundant-default-prop.js +1 -1
- package/dist/i18n/I18nProvider.js +1 -1
- package/dist/i18n/createFormatter.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/instance.js +1 -1
- package/dist/i18n/locales/de-DE/uikit.js +1 -1
- package/dist/i18n/locales/en-US/uikit.js +1 -1
- package/dist/i18n/locales/es-ES/uikit.js +1 -1
- package/dist/i18n/locales/es-MX/uikit.js +1 -1
- package/dist/i18n/locales/fr-FR/uikit.js +1 -1
- package/dist/i18n/locales/it-IT/uikit.js +1 -1
- package/dist/i18n/locales/ja-JP/uikit.js +1 -1
- package/dist/i18n/locales/nb-NO/uikit.js +1 -1
- package/dist/i18n/locales/pt-BR/uikit.js +1 -1
- package/dist/i18n/locales/pt-PT/uikit.js +1 -1
- package/dist/i18n/locales/sv-SE/uikit.js +1 -1
- package/dist/i18n/locales/vi-VN/uikit.js +1 -1
- package/dist/i18n/locales.js +1 -1
- package/dist/i18n/useFormatter.js +1 -1
- package/dist/i18n/useI18n.js +1 -1
- package/dist/icons/AdjustmentsHorizontalIcon.js +1 -1
- package/dist/icons/AdjustmentsIcon.js +1 -1
- package/dist/icons/AiIcon.js +1 -1
- package/dist/icons/AreaChartIcon.js +1 -1
- package/dist/icons/ArrowNarrowDownIcon.js +1 -1
- package/dist/icons/ArrowNarrowUpIcon.js +1 -1
- package/dist/icons/BackwardIcon.js +1 -1
- package/dist/icons/BarChartIcon.js +1 -1
- package/dist/icons/BellFilledIcon.js +1 -1
- package/dist/icons/BellIcon.js +1 -1
- package/dist/icons/BooleanIcon.js +1 -1
- package/dist/icons/CalendarEditIcon.js +1 -1
- package/dist/icons/CalendarIcon.js +1 -1
- package/dist/icons/CaretDownIcon.js +1 -1
- package/dist/icons/CaretUpIcon.js +1 -1
- package/dist/icons/ChartAreaStackedIcon.js +1 -1
- package/dist/icons/ChartAreaStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBarGroupedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarGroupedIcon.js +1 -1
- package/dist/icons/ChartBarHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarLineIcon.js +1 -1
- package/dist/icons/ChartBarStackedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBoxPlot2Icon.js +1 -1
- package/dist/icons/ChartBoxPlotIcon.js +1 -1
- package/dist/icons/ChartBubbleIcon.js +1 -1
- package/dist/icons/ChartDonut2Icon.js +1 -1
- package/dist/icons/ChartFunnelIcon.js +1 -1
- package/dist/icons/ChartHeatmapIcon.js +1 -1
- package/dist/icons/ChartKPIIcon.js +1 -1
- package/dist/icons/ChartPie2Icon.js +1 -1
- package/dist/icons/ChartScatterIcon.js +1 -1
- package/dist/icons/CheckCircleFilledIcon.js +1 -1
- package/dist/icons/CheckCircleIcon.js +1 -1
- package/dist/icons/CheckIcon.js +1 -1
- package/dist/icons/CircleFilledIcon.js +1 -1
- package/dist/icons/ClearIcon.js +1 -1
- package/dist/icons/CloseCircleFilledIcon.js +1 -1
- package/dist/icons/CloseCircleIcon.js +1 -1
- package/dist/icons/CloseIcon.js +1 -1
- package/dist/icons/CodeIcon.js +1 -1
- package/dist/icons/ColumnTotalIcon.js +1 -1
- package/dist/icons/CopyIcon.js +1 -1
- package/dist/icons/CountIcon.js +1 -1
- package/dist/icons/CubeIcon.js +1 -1
- package/dist/icons/CubePauseIcon.js +1 -1
- package/dist/icons/CubePlayIcon.js +1 -1
- package/dist/icons/CurrencyDollarIcon.js +1 -1
- package/dist/icons/DangerIcon.js +1 -1
- package/dist/icons/DashboardIcon.js +1 -1
- package/dist/icons/DatabaseIcon.js +1 -1
- package/dist/icons/DecimalDecreaseIcon.js +1 -1
- package/dist/icons/DecimalIncreaseIcon.js +1 -1
- package/dist/icons/DirectionIcon.js +1 -1
- package/dist/icons/DonutIcon.js +1 -1
- package/dist/icons/DownIcon.js +1 -1
- package/dist/icons/EditIcon.js +1 -1
- package/dist/icons/ExclamationCircleFilledIcon.js +1 -1
- package/dist/icons/ExclamationCircleIcon.js +1 -1
- package/dist/icons/ExclamationIcon.js +1 -1
- package/dist/icons/EyeIcon.js +1 -1
- package/dist/icons/EyeInvisibleIcon.js +1 -1
- package/dist/icons/FilterIcon.js +1 -1
- package/dist/icons/FolderFilledIcon.js +1 -1
- package/dist/icons/FolderIcon.js +1 -1
- package/dist/icons/FolderOpenFilledIcon.js +1 -1
- package/dist/icons/FolderOpenIcon.js +1 -1
- package/dist/icons/ForwardIcon.js +1 -1
- package/dist/icons/GripVerticalIcon.js +1 -1
- package/dist/icons/HierarchyIcon.js +1 -1
- package/dist/icons/HierarchyOpenIcon.js +1 -1
- package/dist/icons/Icon.js +1 -1
- package/dist/icons/InfoCircleIcon.js +1 -1
- package/dist/icons/InfoIcon.js +1 -1
- package/dist/icons/KeyIcon.js +1 -1
- package/dist/icons/LeftIcon.js +1 -1
- package/dist/icons/LineChartIcon.js +1 -1
- package/dist/icons/LoadingIcon.js +1 -1
- package/dist/icons/LockFilledIcon.js +1 -1
- package/dist/icons/LockIcon.js +1 -1
- package/dist/icons/MoreIcon.js +1 -1
- package/dist/icons/NotAllowedIcon.js +1 -1
- package/dist/icons/Number123Icon.js +1 -1
- package/dist/icons/NumberIcon.js +1 -1
- package/dist/icons/PauseCircleFilledIcon.js +1 -1
- package/dist/icons/PauseCircleIcon.js +1 -1
- package/dist/icons/PauseIcon.js +1 -1
- package/dist/icons/PercentageIcon.js +1 -1
- package/dist/icons/PieChartIcon.js +1 -1
- package/dist/icons/PipetteIcon.js +1 -1
- package/dist/icons/PlayCircleIcon.js +1 -1
- package/dist/icons/PlayIcon.js +1 -1
- package/dist/icons/PlusIcon.js +1 -1
- package/dist/icons/ProgressBarIcon.js +1 -1
- package/dist/icons/ReloadIcon.js +1 -1
- package/dist/icons/ReportIcon.js +1 -1
- package/dist/icons/ReturnIcon.js +1 -1
- package/dist/icons/RightIcon.js +1 -1
- package/dist/icons/RowTotalsIcon.js +1 -1
- package/dist/icons/SchemeIcon.js +1 -1
- package/dist/icons/SearchIcon.js +1 -1
- package/dist/icons/SemanticQueryIcon.js +1 -1
- package/dist/icons/SettingsIcon.js +1 -1
- package/dist/icons/ShieldFilledIcon.js +1 -1
- package/dist/icons/ShieldIcon.js +1 -1
- package/dist/icons/SlashIcon.js +1 -1
- package/dist/icons/SparklesIcon.js +1 -1
- package/dist/icons/SqlIcon.js +1 -1
- package/dist/icons/StatsIcon.js +1 -1
- package/dist/icons/StopIcon.js +1 -1
- package/dist/icons/StringIcon.js +1 -1
- package/dist/icons/SubtotalsIcon.js +1 -1
- package/dist/icons/SwitchIcon.js +1 -1
- package/dist/icons/TableIcon.js +1 -1
- package/dist/icons/ThumbsDownIcon.js +1 -1
- package/dist/icons/ThumbsUpIcon.js +1 -1
- package/dist/icons/ThunderboltCrossedIcon.js +1 -1
- package/dist/icons/ThunderboltFilledIcon.js +1 -1
- package/dist/icons/ThunderboltIcon.js +1 -1
- package/dist/icons/TimeIcon.js +1 -1
- package/dist/icons/TrashIcon.js +1 -1
- package/dist/icons/UnlockIcon.js +1 -1
- package/dist/icons/UpIcon.js +1 -1
- package/dist/icons/UserGroupIcon.js +1 -1
- package/dist/icons/UserIcon.js +1 -1
- package/dist/icons/UserLockIcon.js +1 -1
- package/dist/icons/ViewIcon.js +1 -1
- package/dist/icons/WarningFilledIcon.js +1 -1
- package/dist/icons/WarningIcon.js +1 -1
- package/dist/icons/wrap-icon.js +1 -1
- package/dist/index.d.ts +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 +1 -1
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/modules.js +1 -1
- package/dist/utils/promise.js +1 -1
- package/dist/utils/raf.js +1 -1
- package/dist/utils/random.js +1 -1
- package/dist/utils/range.js +1 -1
- package/dist/utils/react/RenderCache.js +1 -1
- package/dist/utils/react/Slots.js +1 -1
- package/dist/utils/react/chain.js +1 -1
- package/dist/utils/react/disabledProps.js +1 -1
- package/dist/utils/react/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/form/Form.md +51 -1
- package/docs/modern-form-migration.md +104 -0
- package/docs/modern-form-typecheck.md +35 -0
- package/package.json +12 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodPicker.js","names":["Calendar","DateInputBase","mergeProps"],"sources":["../../../../src/components/fields/DatePicker/PeriodPicker.tsx"],"sourcesContent":["import { FocusableRef } from '@react-types/shared';\nimport {\n BaseProps,\n CONTAINER_STYLES,\n ContainerStyleProps,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport { forwardRef, useId, useRef } from 'react';\nimport {\n AriaDatePickerProps,\n DateValue,\n useDatePicker,\n useFocusRing,\n useLocale,\n} from 'react-aria';\nimport { useDatePickerState } from 'react-stately';\n\nimport { useI18n } from '../../../i18n';\nimport { FieldBaseProps } from '../../../shared';\nimport { mergeProps } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { useFieldProps, wrapWithField } from '../../form';\nimport { Calendar } from '../../other/Calendar/Calendar';\nimport { PeriodCalendar } from '../../other/Calendar/PeriodCalendar';\nimport { Dialog, DialogTrigger } from '../../overlays/Dialog';\n\nimport { DateInputBase } from './DateInputBase';\nimport { DatePickerButton } from './DatePickerButton';\nimport { formatPeriod, PickerType, snapToPeriod } from './period';\nimport { useFocusManagerRef } from './utils';\n\nconst PeriodValueElement = tasty({\n qa: 'PeriodPickerValue',\n styles: {\n preset: 't3',\n width: 'max 100%',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n color: {\n '': '#dark',\n placeholder: '#dark.30',\n disabled: '#dark.30',\n },\n },\n});\n\nexport interface CubePeriodPickerProps<T extends DateValue = DateValue>\n extends Omit<AriaDatePickerProps<T>, 'errorMessage' | 'granularity'>,\n BaseProps,\n ContainerStyleProps,\n FieldBaseProps {\n /** Which period the picker selects. Set by the concrete picker components. */\n picker?: PickerType;\n wrapperStyles?: Styles;\n inputStyles?: Styles;\n triggerStyles?: Styles;\n styles?: Styles;\n size?: 'small' | 'medium' | 'large' | (string & {});\n shouldFlip?: boolean;\n /** Placeholder shown when no value is selected. */\n placeholder?: string;\n /** Override how the selected value is rendered as text. */\n formatValue?: (date: DateValue, picker: PickerType, locale: string) => string;\n}\n\nfunction PeriodPicker<T extends DateValue>(\n props: CubePeriodPickerProps<T>,\n ref: FocusableRef<HTMLElement>,\n) {\n const { t } = useI18n();\n\n props = useFieldProps(props, {\n defaultValidationTrigger: 'onBlur',\n });\n\n let styles = extractStyles(props, CONTAINER_STYLES);\n\n let {\n qa,\n size,\n picker = 'month',\n placeholder,\n formatValue,\n isDisabled,\n isReadOnly,\n isInvalid,\n isValid,\n autoFocus,\n } = props;\n\n let defaultPlaceholder: Record<PickerType, string> = {\n week: t('datePicker.selectWeek', 'Select week'),\n month: t('datePicker.selectMonth', 'Select month'),\n quarter: t('datePicker.selectQuarter', 'Select quarter'),\n year: t('datePicker.selectYear', 'Select year'),\n };\n\n let { locale } = useLocale();\n let targetRef = useRef<HTMLDivElement>(null);\n let state = useDatePickerState({\n ...props,\n granularity: 'day',\n shouldCloseOnSelect: true,\n });\n let { isOpen, setOpen } = state;\n\n let domRef = useFocusManagerRef(ref);\n\n let { isFocused: isFocusedButton, focusProps: focusPropsButton } =\n useFocusRing({\n within: false,\n isTextInput: false,\n autoFocus,\n });\n\n let { groupProps, labelProps, buttonProps, dialogProps, calendarProps } =\n useDatePicker({ ...props, granularity: 'day' }, state, targetRef);\n\n let handleSelect = (date: DateValue) => {\n state.setValue(snapToPeriod(date, picker, locale));\n setOpen(false);\n };\n\n let displayText = state.value\n ? (formatValue ?? formatPeriod)(state.value, picker, locale)\n : placeholder ?? defaultPlaceholder[picker];\n\n // The value is rendered as text rather than editable segments, so the trigger\n // has to point at it to announce the current selection.\n let valueId = useId();\n\n const panel =\n picker === 'week' ? (\n <Calendar\n {...calendarProps}\n autoFocus\n pickerMode=\"week\"\n isDisabled={isDisabled}\n onChange={handleSelect}\n />\n ) : (\n <PeriodCalendar\n autoFocus\n picker={picker}\n value={calendarProps.value}\n minValue={calendarProps.minValue}\n maxValue={calendarProps.maxValue}\n isDateUnavailable={calendarProps.isDateUnavailable}\n isDisabled={isDisabled}\n onChange={handleSelect}\n />\n );\n\n const component = (\n <DateInputBase\n ref={targetRef}\n qa={qa || 'PeriodPicker'}\n inputType=\"datepicker\"\n styles={{ display: 'grid', ...styles, ...props.wrapperStyles }}\n inputStyles={{\n cursor: isDisabled || isReadOnly ? 'default' : 'pointer',\n ...props.inputStyles,\n }}\n disableFocusRing={isFocusedButton}\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n isValid={isValid}\n size={size}\n fieldProps={groupProps}\n suffix={\n <DialogTrigger\n hideArrow\n type=\"popover\"\n mobileType=\"tray\"\n placement=\"bottom right\"\n targetRef={targetRef}\n isOpen={isOpen}\n shouldFlip={props.shouldFlip}\n onOpenChange={setOpen}\n >\n <DatePickerButton\n size={size}\n {...mergeProps(buttonProps, focusPropsButton)}\n aria-describedby={valueId}\n // Passed separately, not merged: only the field-disabled half is\n // inherited. See `DatePickerButton`.\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n styles={props.triggerStyles}\n />\n <Dialog {...dialogProps} width=\"max-content\">\n {panel}\n </Dialog>\n </DialogTrigger>\n }\n >\n <PeriodValueElement\n id={valueId}\n mods={{ placeholder: !state.value, disabled: isDisabled }}\n onClick={() => !isDisabled && !isReadOnly && setOpen(true)}\n >\n {displayText}\n </PeriodValueElement>\n </DateInputBase>\n );\n\n return wrapWithField(component, domRef, {\n ...props,\n labelProps: mergeProps(props.labelProps, labelProps),\n });\n}\n\nconst _PeriodPicker = forwardRef(PeriodPicker);\n\n_PeriodPicker.displayName = 'PeriodPicker';\n\nexport { _PeriodPicker as PeriodPicker };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,qBAAqB,MAAM;CAC/B,IAAI;CACJ,QAAQ;EACN,QAAQ;EACR,OAAO;EACP,YAAY;EACZ,cAAc;EACd,UAAU;EACV,OAAO;GACL,IAAI;GACJ,aAAa;GACb,UAAU;GACX;EACF;CACF,CAAC;AAqBF,SAAS,aACP,OACA,KACA;CACA,MAAM,EAAE,MAAM,SAAS;AAEvB,SAAQ,cAAc,OAAO,EAC3B,0BAA0B,UAC3B,CAAC;CAEF,IAAI,SAAS,cAAc,OAAO,iBAAiB;CAEnD,IAAI,EACF,IACA,MACA,SAAS,SACT,aACA,aACA,YACA,YACA,WACA,SACA,cACE;CAEJ,IAAI,qBAAiD;EACnD,MAAM,EAAE,yBAAyB,cAAc;EAC/C,OAAO,EAAE,0BAA0B,eAAe;EAClD,SAAS,EAAE,4BAA4B,iBAAiB;EACxD,MAAM,EAAE,yBAAyB,cAAc;EAChD;CAED,IAAI,EAAE,WAAW,WAAW;CAC5B,IAAI,YAAY,OAAuB,KAAK;CAC5C,IAAI,QAAQ,mBAAmB;EAC7B,GAAG;EACH,aAAa;EACb,qBAAqB;EACtB,CAAC;CACF,IAAI,EAAE,QAAQ,YAAY;CAE1B,IAAI,SAAS,mBAAmB,IAAI;CAEpC,IAAI,EAAE,WAAW,iBAAiB,YAAY,qBAC5C,aAAa;EACX,QAAQ;EACR,aAAa;EACb;EACD,CAAC;CAEJ,IAAI,EAAE,YAAY,YAAY,aAAa,aAAa,kBACtD,cAAc;EAAE,GAAG;EAAO,aAAa;EAAO,EAAE,OAAO,UAAU;CAEnE,IAAI,gBAAgB,SAAoB;AACtC,QAAM,SAAS,aAAa,MAAM,QAAQ,OAAO,CAAC;AAClD,UAAQ,MAAM;;CAGhB,IAAI,cAAc,MAAM,SACnB,eAAe,cAAc,MAAM,OAAO,QAAQ,OAAO,GAC1D,eAAe,mBAAmB;CAItC,IAAI,UAAU,OAAO;CAErB,MAAM,QACJ,WAAW,SACT,oBAACA;EACC,GAAI;EACJ;EACA,YAAW;EACC;EACZ,UAAU;GACV,GAEF,oBAAC;EACC;EACQ;EACR,OAAO,cAAc;EACrB,UAAU,cAAc;EACxB,UAAU,cAAc;EACxB,mBAAmB,cAAc;EACrB;EACZ,UAAU;GACV;AAwDN,QAAO,cApDL,oBAACC;EACC,KAAK;EACL,IAAI,MAAM;EACV,WAAU;EACV,QAAQ;GAAE,SAAS;GAAQ,GAAG;GAAQ,GAAG,MAAM;GAAe;EAC9D,aAAa;GACX,QAAQ,cAAc,aAAa,YAAY;GAC/C,GAAG,MAAM;GACV;EACD,kBAAkB;EACN;EACD;EACF;EACH;EACN,YAAY;EACZ,QACE,qBAAC;GACC;GACA,MAAK;GACL,YAAW;GACX,WAAU;GACC;GACH;GACR,YAAY,MAAM;GAClB,cAAc;cAEd,oBAAC;IACO;IACN,GAAIC,aAAW,aAAa,iBAAiB;IAC7C,oBAAkB;IAGN;IACA;IACZ,QAAQ,MAAM;KACd,EACF,oBAAC;IAAO,GAAI;IAAa,OAAM;cAC5B;KACM;IACK;YAGlB,oBAAC;GACC,IAAI;GACJ,MAAM;IAAE,aAAa,CAAC,MAAM;IAAO,UAAU;IAAY;GACzD,eAAe,CAAC,cAAc,CAAC,cAAc,QAAQ,KAAK;aAEzD;IACkB;GACP,EAGc,QAAQ;EACtC,GAAG;EACH,YAAYA,aAAW,MAAM,YAAY,WAAW;EACrD,CAAC;;AAGJ,MAAM,gBAAgB,WAAW,aAAa;AAE9C,cAAc,cAAc"}
|
|
1
|
+
{"version":3,"file":"PeriodPicker.js","names":["Calendar","DateInputBase","mergeProps"],"sources":["../../../../src/components/fields/DatePicker/PeriodPicker.tsx"],"sourcesContent":["import { FocusableRef } from '@react-types/shared';\nimport {\n BaseProps,\n CONTAINER_STYLES,\n ContainerStyleProps,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport { forwardRef, useId, useRef } from 'react';\nimport {\n AriaDatePickerProps,\n DateValue,\n useDatePicker,\n useFocusRing,\n useLocale,\n} from 'react-aria';\nimport { useDatePickerState } from 'react-stately';\n\nimport { useI18n } from '../../../i18n';\nimport { FieldBaseProps } from '../../../shared';\nimport { mergeProps } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { useFieldProps, wrapWithField } from '../../form';\nimport { Calendar } from '../../other/Calendar/Calendar';\nimport { PeriodCalendar } from '../../other/Calendar/PeriodCalendar';\nimport { Dialog, DialogTrigger } from '../../overlays/Dialog';\n\nimport { DateInputBase } from './DateInputBase';\nimport { DatePickerButton } from './DatePickerButton';\nimport { formatPeriod, PickerType, snapToPeriod } from './period';\nimport { useFocusManagerRef } from './utils';\n\nconst PeriodValueElement = tasty({\n qa: 'PeriodPickerValue',\n styles: {\n preset: 't3',\n width: 'max 100%',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n color: {\n '': '#dark',\n placeholder: '#dark.30',\n disabled: '#dark.30',\n },\n },\n});\n\nexport interface CubePeriodPickerProps<T extends DateValue = DateValue>\n extends Omit<AriaDatePickerProps<T>, 'errorMessage' | 'granularity' | 'form'>,\n BaseProps,\n ContainerStyleProps,\n FieldBaseProps {\n /** Which period the picker selects. Set by the concrete picker components. */\n picker?: PickerType;\n wrapperStyles?: Styles;\n inputStyles?: Styles;\n triggerStyles?: Styles;\n styles?: Styles;\n size?: 'small' | 'medium' | 'large' | (string & {});\n shouldFlip?: boolean;\n /** Placeholder shown when no value is selected. */\n placeholder?: string;\n /** Override how the selected value is rendered as text. */\n formatValue?: (date: DateValue, picker: PickerType, locale: string) => string;\n}\n\nfunction PeriodPicker<T extends DateValue>(\n props: CubePeriodPickerProps<T>,\n ref: FocusableRef<HTMLElement>,\n) {\n const { t } = useI18n();\n\n props = useFieldProps(props, {\n defaultValidationTrigger: 'onBlur',\n });\n\n let styles = extractStyles(props, CONTAINER_STYLES);\n\n let {\n qa,\n size,\n picker = 'month',\n placeholder,\n formatValue,\n isDisabled,\n isReadOnly,\n isInvalid,\n isValid,\n autoFocus,\n } = props;\n\n let defaultPlaceholder: Record<PickerType, string> = {\n week: t('datePicker.selectWeek', 'Select week'),\n month: t('datePicker.selectMonth', 'Select month'),\n quarter: t('datePicker.selectQuarter', 'Select quarter'),\n year: t('datePicker.selectYear', 'Select year'),\n };\n\n let { locale } = useLocale();\n let targetRef = useRef<HTMLDivElement>(null);\n let state = useDatePickerState({\n ...props,\n granularity: 'day',\n shouldCloseOnSelect: true,\n });\n let { isOpen, setOpen } = state;\n\n let domRef = useFocusManagerRef(ref);\n\n let { isFocused: isFocusedButton, focusProps: focusPropsButton } =\n useFocusRing({\n within: false,\n isTextInput: false,\n autoFocus,\n });\n\n let { groupProps, labelProps, buttonProps, dialogProps, calendarProps } =\n useDatePicker({ ...props, granularity: 'day' }, state, targetRef);\n\n let handleSelect = (date: DateValue) => {\n state.setValue(snapToPeriod(date, picker, locale));\n setOpen(false);\n };\n\n let displayText = state.value\n ? (formatValue ?? formatPeriod)(state.value, picker, locale)\n : placeholder ?? defaultPlaceholder[picker];\n\n // The value is rendered as text rather than editable segments, so the trigger\n // has to point at it to announce the current selection.\n let valueId = useId();\n\n const panel =\n picker === 'week' ? (\n <Calendar\n {...calendarProps}\n autoFocus\n pickerMode=\"week\"\n isDisabled={isDisabled}\n onChange={handleSelect}\n />\n ) : (\n <PeriodCalendar\n autoFocus\n picker={picker}\n value={calendarProps.value}\n minValue={calendarProps.minValue}\n maxValue={calendarProps.maxValue}\n isDateUnavailable={calendarProps.isDateUnavailable}\n isDisabled={isDisabled}\n onChange={handleSelect}\n />\n );\n\n const component = (\n <DateInputBase\n ref={targetRef}\n qa={qa || 'PeriodPicker'}\n inputType=\"datepicker\"\n styles={{ display: 'grid', ...styles, ...props.wrapperStyles }}\n inputStyles={{\n cursor: isDisabled || isReadOnly ? 'default' : 'pointer',\n ...props.inputStyles,\n }}\n disableFocusRing={isFocusedButton}\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n isValid={isValid}\n size={size}\n fieldProps={groupProps}\n suffix={\n <DialogTrigger\n hideArrow\n type=\"popover\"\n mobileType=\"tray\"\n placement=\"bottom right\"\n targetRef={targetRef}\n isOpen={isOpen}\n shouldFlip={props.shouldFlip}\n onOpenChange={setOpen}\n >\n <DatePickerButton\n size={size}\n {...mergeProps(buttonProps, focusPropsButton)}\n aria-describedby={valueId}\n // Passed separately, not merged: only the field-disabled half is\n // inherited. See `DatePickerButton`.\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n styles={props.triggerStyles}\n />\n <Dialog {...dialogProps} width=\"max-content\">\n {panel}\n </Dialog>\n </DialogTrigger>\n }\n >\n <PeriodValueElement\n id={valueId}\n mods={{ placeholder: !state.value, disabled: isDisabled }}\n onClick={() => !isDisabled && !isReadOnly && setOpen(true)}\n >\n {displayText}\n </PeriodValueElement>\n </DateInputBase>\n );\n\n return wrapWithField(component, domRef, {\n ...props,\n labelProps: mergeProps(props.labelProps, labelProps),\n });\n}\n\nconst _PeriodPicker = forwardRef(PeriodPicker);\n\n_PeriodPicker.displayName = 'PeriodPicker';\n\nexport { _PeriodPicker as PeriodPicker };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,qBAAqB,MAAM;CAC/B,IAAI;CACJ,QAAQ;EACN,QAAQ;EACR,OAAO;EACP,YAAY;EACZ,cAAc;EACd,UAAU;EACV,OAAO;GACL,IAAI;GACJ,aAAa;GACb,UAAU;GACX;EACF;CACF,CAAC;AAqBF,SAAS,aACP,OACA,KACA;CACA,MAAM,EAAE,MAAM,SAAS;AAEvB,SAAQ,cAAc,OAAO,EAC3B,0BAA0B,UAC3B,CAAC;CAEF,IAAI,SAAS,cAAc,OAAO,iBAAiB;CAEnD,IAAI,EACF,IACA,MACA,SAAS,SACT,aACA,aACA,YACA,YACA,WACA,SACA,cACE;CAEJ,IAAI,qBAAiD;EACnD,MAAM,EAAE,yBAAyB,cAAc;EAC/C,OAAO,EAAE,0BAA0B,eAAe;EAClD,SAAS,EAAE,4BAA4B,iBAAiB;EACxD,MAAM,EAAE,yBAAyB,cAAc;EAChD;CAED,IAAI,EAAE,WAAW,WAAW;CAC5B,IAAI,YAAY,OAAuB,KAAK;CAC5C,IAAI,QAAQ,mBAAmB;EAC7B,GAAG;EACH,aAAa;EACb,qBAAqB;EACtB,CAAC;CACF,IAAI,EAAE,QAAQ,YAAY;CAE1B,IAAI,SAAS,mBAAmB,IAAI;CAEpC,IAAI,EAAE,WAAW,iBAAiB,YAAY,qBAC5C,aAAa;EACX,QAAQ;EACR,aAAa;EACb;EACD,CAAC;CAEJ,IAAI,EAAE,YAAY,YAAY,aAAa,aAAa,kBACtD,cAAc;EAAE,GAAG;EAAO,aAAa;EAAO,EAAE,OAAO,UAAU;CAEnE,IAAI,gBAAgB,SAAoB;AACtC,QAAM,SAAS,aAAa,MAAM,QAAQ,OAAO,CAAC;AAClD,UAAQ,MAAM;;CAGhB,IAAI,cAAc,MAAM,SACnB,eAAe,cAAc,MAAM,OAAO,QAAQ,OAAO,GAC1D,eAAe,mBAAmB;CAItC,IAAI,UAAU,OAAO;CAErB,MAAM,QACJ,WAAW,SACT,oBAACA;EACC,GAAI;EACJ;EACA,YAAW;EACC;EACZ,UAAU;GACV,GAEF,oBAAC;EACC;EACQ;EACR,OAAO,cAAc;EACrB,UAAU,cAAc;EACxB,UAAU,cAAc;EACxB,mBAAmB,cAAc;EACrB;EACZ,UAAU;GACV;AAwDN,QAAO,cApDL,oBAACC;EACC,KAAK;EACL,IAAI,MAAM;EACV,WAAU;EACV,QAAQ;GAAE,SAAS;GAAQ,GAAG;GAAQ,GAAG,MAAM;GAAe;EAC9D,aAAa;GACX,QAAQ,cAAc,aAAa,YAAY;GAC/C,GAAG,MAAM;GACV;EACD,kBAAkB;EACN;EACD;EACF;EACH;EACN,YAAY;EACZ,QACE,qBAAC;GACC;GACA,MAAK;GACL,YAAW;GACX,WAAU;GACC;GACH;GACR,YAAY,MAAM;GAClB,cAAc;cAEd,oBAAC;IACO;IACN,GAAIC,aAAW,aAAa,iBAAiB;IAC7C,oBAAkB;IAGN;IACA;IACZ,QAAQ,MAAM;KACd,EACF,oBAAC;IAAO,GAAI;IAAa,OAAM;cAC5B;KACM;IACK;YAGlB,oBAAC;GACC,IAAI;GACJ,MAAM;IAAE,aAAa,CAAC,MAAM;IAAO,UAAU;IAAY;GACzD,eAAe,CAAC,cAAc,CAAC,cAAc,QAAQ,KAAK;aAEzD;IACkB;GACP,EAGc,QAAQ;EACtC,GAAG;EACH,YAAYA,aAAW,MAAM,YAAY,WAAW;EACrD,CAAC;;AAGJ,MAAM,gBAAgB,WAAW,aAAa;AAE9C,cAAc,cAAc"}
|
|
@@ -8,7 +8,7 @@ import { AriaTimeFieldProps, DateValue, TimeValue } from "react-aria";
|
|
|
8
8
|
import * as _react_types_shared0 from "@react-types/shared";
|
|
9
9
|
|
|
10
10
|
//#region src/components/fields/DatePicker/TimeInput.d.ts
|
|
11
|
-
interface CubeTimeInputProps<T extends TimeValue = TimeValue> extends Omit<AriaTimeFieldProps<T>, 'errorMessage'>, BaseProps, ContainerStyleProps, FieldBaseProps {
|
|
11
|
+
interface CubeTimeInputProps<T extends TimeValue = TimeValue> extends Omit<AriaTimeFieldProps<T>, 'errorMessage' | 'form'>, BaseProps, ContainerStyleProps, FieldBaseProps {
|
|
12
12
|
wrapperStyles?: Styles;
|
|
13
13
|
inputStyles?: Styles;
|
|
14
14
|
styles?: Styles;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { useFieldProps } from "../../form/Form/use-field/use-field-props.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeInput.js","names":["DateInputBase","mergeProps"],"sources":["../../../../src/components/fields/DatePicker/TimeInput.tsx"],"sourcesContent":["import { FocusableRef } from '@react-types/shared';\nimport {\n BaseProps,\n CONTAINER_STYLES,\n ContainerStyleProps,\n Styles,\n} from '@tenphi/tasty';\nimport { forwardRef, useRef } from 'react';\nimport {\n AriaTimeFieldProps,\n DateValue,\n TimeValue,\n useTimeField,\n} from 'react-aria';\nimport { useTimeFieldState } from 'react-stately';\n\nimport { FieldBaseProps } from '../../../shared';\nimport { mergeProps } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { useFieldProps, wrapWithField } from '../../form';\n\nimport { DateInputBase } from './DateInputBase';\nimport { DatePickerSegment } from './DatePickerSegment';\nimport { DEFAULT_TIME_PROPS } from './props';\nimport { Granularity } from './types';\nimport { useFocusManagerRef } from './utils';\n\nexport interface CubeTimeInputProps<T extends TimeValue = TimeValue>\n extends Omit<AriaTimeFieldProps<T>, 'errorMessage'>,\n BaseProps,\n ContainerStyleProps,\n FieldBaseProps {\n wrapperStyles?: Styles;\n inputStyles?: Styles;\n styles?: Styles;\n size?: 'small' | 'medium' | 'large' | (string & {});\n value?: TimeValue;\n /** The minimum allowed date that a user may select. */\n minValue?: TimeValue;\n /** The maximum allowed date that a user may select. */\n maxValue?: TimeValue;\n /** Callback that is called for each date of the calendar. If it returns true, then the date is unavailable. */\n isDateUnavailable?: (date: DateValue) => boolean;\n /** A placeholder date that influences the format of the placeholder shown when no value is selected. Defaults to today's date at midnight. */\n placeholderValue?: TimeValue;\n /** Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale. */\n hourCycle?: 12 | 24;\n /** Determines the smallest unit that is displayed in the date picker. By default, this is `\"day\"` for dates, and `\"minute\"` for times. */\n granularity?: Granularity;\n /**\n * Whether to hide the time zone abbreviation.\n * @default false\n */\n hideTimeZone?: boolean;\n onChange?: (value: TimeValue) => void;\n}\n\nfunction TimeInput<T extends TimeValue>(\n props: CubeTimeInputProps<T>,\n ref: FocusableRef<HTMLElement>,\n) {\n props = useFieldProps(props, {\n defaultValidationTrigger: 'onBlur',\n });\n props = Object.assign({}, DEFAULT_TIME_PROPS, props);\n\n let styles = extractStyles(props, CONTAINER_STYLES);\n\n let {\n qa,\n inputStyles,\n wrapperStyles,\n autoFocus,\n isDisabled,\n isReadOnly,\n isRequired,\n isInvalid,\n isValid,\n size = 'medium',\n labelProps: userLabelProps,\n } = props;\n\n let domRef = useFocusManagerRef(ref);\n // let { locale } = useLocale();\n let state = useTimeFieldState({\n ...props,\n locale: 'en-US',\n });\n\n let fieldRef = useRef(null);\n let { labelProps, fieldProps } = useTimeField(props, state, fieldRef);\n\n const timeInput = (\n <DateInputBase\n ref={fieldRef}\n qa={qa || 'TimeInput'}\n inputType=\"timeinput\"\n size={size}\n fieldProps={fieldProps}\n isDisabled={isDisabled}\n autoFocus={autoFocus}\n inputStyles={inputStyles}\n styles={wrapperStyles}\n isInvalid={isInvalid}\n isValid={isValid}\n >\n {state.segments.map((segment, i) => (\n <DatePickerSegment\n key={i}\n segment={segment}\n state={state}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n />\n ))}\n </DateInputBase>\n );\n\n return wrapWithField(timeInput, domRef, {\n ...props,\n labelProps: mergeProps(labelProps, userLabelProps),\n });\n}\n\n/**\n * TimeFields allow users to enter and edit time values using a keyboard.\n * Each part of the time is displayed in an individually editable segment.\n */\nconst _TimeInput = forwardRef(TimeInput);\n\n_TimeInput.displayName = 'TimeInput';\n\nexport { _TimeInput as TimeInput };\n"],"mappings":";;;;;;;;;;;;;;;;AAyDA,SAAS,UACP,OACA,KACA;AACA,SAAQ,cAAc,OAAO,EAC3B,0BAA0B,UAC3B,CAAC;AACF,SAAQ,OAAO,OAAO,EAAE,EAAE,oBAAoB,MAAM;AAEvC,eAAc,OAAO,iBAAiB;CAEnD,IAAI,EACF,IACA,aACA,eACA,WACA,YACA,YACA,YACA,WACA,SACA,OAAO,UACP,YAAY,mBACV;CAEJ,IAAI,SAAS,mBAAmB,IAAI;CAEpC,IAAI,QAAQ,kBAAkB;EAC5B,GAAG;EACH,QAAQ;EACT,CAAC;CAEF,IAAI,WAAW,OAAO,KAAK;CAC3B,IAAI,EAAE,YAAY,eAAe,aAAa,OAAO,OAAO,SAAS;AA6BrE,QAAO,cA1BL,oBAACA;EACC,KAAK;EACL,IAAI,MAAM;EACV,WAAU;EACJ;EACM;EACA;EACD;EACE;EACb,QAAQ;EACG;EACF;YAER,MAAM,SAAS,KAAK,SAAS,MAC5B,oBAAC;GAEU;GACF;GACK;GACA;GACA;KALP,EAML,CACF;GACY,EAGc,QAAQ;EACtC,GAAG;EACH,YAAYC,aAAW,YAAY,eAAe;EACnD,CAAC;;;;;;AAOJ,MAAM,aAAa,WAAW,UAAU;AAExC,WAAW,cAAc"}
|
|
1
|
+
{"version":3,"file":"TimeInput.js","names":["DateInputBase","mergeProps"],"sources":["../../../../src/components/fields/DatePicker/TimeInput.tsx"],"sourcesContent":["import { FocusableRef } from '@react-types/shared';\nimport {\n BaseProps,\n CONTAINER_STYLES,\n ContainerStyleProps,\n Styles,\n} from '@tenphi/tasty';\nimport { forwardRef, useRef } from 'react';\nimport {\n AriaTimeFieldProps,\n DateValue,\n TimeValue,\n useTimeField,\n} from 'react-aria';\nimport { useTimeFieldState } from 'react-stately';\n\nimport { FieldBaseProps } from '../../../shared';\nimport { mergeProps } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { useFieldProps, wrapWithField } from '../../form';\n\nimport { DateInputBase } from './DateInputBase';\nimport { DatePickerSegment } from './DatePickerSegment';\nimport { DEFAULT_TIME_PROPS } from './props';\nimport { Granularity } from './types';\nimport { useFocusManagerRef } from './utils';\n\nexport interface CubeTimeInputProps<T extends TimeValue = TimeValue>\n extends Omit<AriaTimeFieldProps<T>, 'errorMessage' | 'form'>,\n BaseProps,\n ContainerStyleProps,\n FieldBaseProps {\n wrapperStyles?: Styles;\n inputStyles?: Styles;\n styles?: Styles;\n size?: 'small' | 'medium' | 'large' | (string & {});\n value?: TimeValue;\n /** The minimum allowed date that a user may select. */\n minValue?: TimeValue;\n /** The maximum allowed date that a user may select. */\n maxValue?: TimeValue;\n /** Callback that is called for each date of the calendar. If it returns true, then the date is unavailable. */\n isDateUnavailable?: (date: DateValue) => boolean;\n /** A placeholder date that influences the format of the placeholder shown when no value is selected. Defaults to today's date at midnight. */\n placeholderValue?: TimeValue;\n /** Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale. */\n hourCycle?: 12 | 24;\n /** Determines the smallest unit that is displayed in the date picker. By default, this is `\"day\"` for dates, and `\"minute\"` for times. */\n granularity?: Granularity;\n /**\n * Whether to hide the time zone abbreviation.\n * @default false\n */\n hideTimeZone?: boolean;\n onChange?: (value: TimeValue) => void;\n}\n\nfunction TimeInput<T extends TimeValue>(\n props: CubeTimeInputProps<T>,\n ref: FocusableRef<HTMLElement>,\n) {\n props = useFieldProps(props, {\n defaultValidationTrigger: 'onBlur',\n });\n props = Object.assign({}, DEFAULT_TIME_PROPS, props);\n\n let styles = extractStyles(props, CONTAINER_STYLES);\n\n let {\n qa,\n inputStyles,\n wrapperStyles,\n autoFocus,\n isDisabled,\n isReadOnly,\n isRequired,\n isInvalid,\n isValid,\n size = 'medium',\n labelProps: userLabelProps,\n } = props;\n\n let domRef = useFocusManagerRef(ref);\n // let { locale } = useLocale();\n let state = useTimeFieldState({\n ...props,\n locale: 'en-US',\n });\n\n let fieldRef = useRef(null);\n let { labelProps, fieldProps } = useTimeField(props, state, fieldRef);\n\n const timeInput = (\n <DateInputBase\n ref={fieldRef}\n qa={qa || 'TimeInput'}\n inputType=\"timeinput\"\n size={size}\n fieldProps={fieldProps}\n isDisabled={isDisabled}\n autoFocus={autoFocus}\n inputStyles={inputStyles}\n styles={wrapperStyles}\n isInvalid={isInvalid}\n isValid={isValid}\n >\n {state.segments.map((segment, i) => (\n <DatePickerSegment\n key={i}\n segment={segment}\n state={state}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n />\n ))}\n </DateInputBase>\n );\n\n return wrapWithField(timeInput, domRef, {\n ...props,\n labelProps: mergeProps(labelProps, userLabelProps),\n });\n}\n\n/**\n * TimeFields allow users to enter and edit time values using a keyboard.\n * Each part of the time is displayed in an individually editable segment.\n */\nconst _TimeInput = forwardRef(TimeInput);\n\n_TimeInput.displayName = 'TimeInput';\n\nexport { _TimeInput as TimeInput };\n"],"mappings":";;;;;;;;;;;;;;;;AAyDA,SAAS,UACP,OACA,KACA;AACA,SAAQ,cAAc,OAAO,EAC3B,0BAA0B,UAC3B,CAAC;AACF,SAAQ,OAAO,OAAO,EAAE,EAAE,oBAAoB,MAAM;AAEvC,eAAc,OAAO,iBAAiB;CAEnD,IAAI,EACF,IACA,aACA,eACA,WACA,YACA,YACA,YACA,WACA,SACA,OAAO,UACP,YAAY,mBACV;CAEJ,IAAI,SAAS,mBAAmB,IAAI;CAEpC,IAAI,QAAQ,kBAAkB;EAC5B,GAAG;EACH,QAAQ;EACT,CAAC;CAEF,IAAI,WAAW,OAAO,KAAK;CAC3B,IAAI,EAAE,YAAY,eAAe,aAAa,OAAO,OAAO,SAAS;AA6BrE,QAAO,cA1BL,oBAACA;EACC,KAAK;EACL,IAAI,MAAM;EACV,WAAU;EACJ;EACM;EACA;EACD;EACE;EACb,QAAQ;EACG;EACF;YAER,MAAM,SAAS,KAAK,SAAS,MAC5B,oBAAC;GAEU;GACF;GACK;GACA;GACA;KALP,EAML,CACF;GACY,EAGc,QAAQ;EACtC,GAAG;EACH,YAAYC,aAAW,YAAY,eAAe;EACnD,CAAC;;;;;;AAOJ,MAAM,aAAa,WAAW,UAAU;AAExC,WAAW,cAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { CalendarDate, startOfMonth, startOfWeek, startOfYear, toCalendarDate } from "@internationalized/date";
|
|
3
3
|
|
|
4
4
|
//#region src/components/fields/DatePicker/period.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { useImperativeHandle, useRef } from "react";
|
|
3
3
|
import { createDOMRef } from "@react-spectrum/utils";
|
|
4
4
|
import { createFocusManager } from "@react-aria/focus";
|
|
@@ -9,6 +9,8 @@ import { AriaTextFieldProps } from "react-aria";
|
|
|
9
9
|
|
|
10
10
|
//#region src/components/fields/FileInput/FileInput.d.ts
|
|
11
11
|
interface CubeFileInputProps extends BaseProps, PositionStyleProps, ContainerStyleProps, BlockStyleProps, AriaTextFieldProps, FieldBaseProps {
|
|
12
|
+
/** The form instance; redeclared for the same reason as in `Checkbox`. */
|
|
13
|
+
form?: FieldBaseProps['form'];
|
|
12
14
|
/**
|
|
13
15
|
* The size of the input
|
|
14
16
|
* @default default
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { useCombinedRefs } from "../../../utils/react/useCombinedRefs.js";
|
|
4
4
|
import { useI18n } from "../../../i18n/useI18n.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.js","names":[],"sources":["../../../../src/components/fields/FileInput/FileInput.tsx"],"sourcesContent":["import { createFocusableRef } from '@react-spectrum/utils';\nimport {\n BaseProps,\n BlockStyleProps,\n CONTAINER_STYLES,\n ContainerStyleProps,\n PositionStyleProps,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport {\n forwardRef,\n RefObject,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useI18n } from '../../../i18n';\nimport { FieldBaseProps } from '../../../shared';\nimport { useCombinedRefs } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { Action } from '../../actions';\nimport {\n getValidationMods,\n useFieldProps,\n ValidationIndicator,\n wrapWithField,\n} from '../../form';\n\nimport type { AriaTextFieldProps } from 'react-aria';\nimport type { Props } from '../../../props';\n\nconst FileInputElement = tasty(Action, {\n qa: 'FileInputWrapper',\n styles: {\n display: 'inline-flex',\n position: 'relative',\n preset: 't3',\n padding: '.5x 1x',\n gap: '1x',\n flow: 'row',\n placeItems: 'center start',\n fill: {\n '': '#surface',\n 'drag-hover': '#primary.16',\n ':hover': '#primary.08',\n disabled: '#disabled-surface',\n },\n border: {\n '': true,\n valid: '#success-text.50',\n invalid: '#danger-text.50',\n ':focus-within & :focus-visible': '#primary-text',\n },\n radius: true,\n cursor: '$pointer',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n\n Button: {\n radius: true,\n border: {\n '': '#clear',\n pressed: '#primary.30',\n },\n fill: '#primary.12',\n color: {\n '': '#primary',\n disabled: '#dark.30',\n },\n padding: '.5x (1.5x - 1px)',\n transition: 'theme',\n },\n\n Placeholder: {\n color: '#dark-02',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n width: 'max 100%',\n overflow: 'hidden',\n },\n\n Value: {\n color: '#dark-02',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n width: 'max 100%',\n overflow: 'hidden',\n },\n\n State: {\n display: 'flex',\n placeItems: 'center',\n },\n\n ValidationIcon: {\n $: '> State >',\n display: 'grid',\n placeItems: 'center',\n width: 'min 2x',\n fontSize: '$icon-size',\n },\n\n Input: {\n position: 'absolute',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n radius: '$content-radius',\n opacity: 0.01,\n cursor: '$pointer',\n zIndex: 10,\n },\n },\n});\n\nexport interface CubeFileInputProps\n extends BaseProps,\n PositionStyleProps,\n ContainerStyleProps,\n BlockStyleProps,\n AriaTextFieldProps,\n FieldBaseProps {\n /**\n * The size of the input\n * @default default\n */\n size?: 'small' | 'default' | 'large' | string;\n /** The input ref */\n inputRef?: RefObject<HTMLInputElement>;\n /** Style map for the input */\n inputStyles?: Styles;\n /**\n * The type of the input\n * @default file\n */\n type?: 'file' | 'text';\n /** Direct input props */\n inputProps?: Props;\n /** The file types that the input should accept */\n accept?: string;\n value?: string;\n onChange?: (value: string) => void;\n placeholder?: string;\n}\n\nfunction extractContents(element, callback) {\n const files = element?.files;\n\n if (files && files.length > 0) {\n const fileReader = new FileReader();\n\n fileReader.onload = function () {\n callback(fileReader.result);\n };\n\n fileReader.readAsText(files[0]);\n }\n}\n\nfunction extractFileNameFromValue(value?: string) {\n return typeof value === 'string'\n ? (value as string).split('\\\\')?.pop()\n : undefined;\n}\n\nfunction FileInput(props: CubeFileInputProps, ref) {\n const { t } = useI18n();\n\n props = useFieldProps(\n { ...props },\n {\n defaultValidationTrigger: 'onChange',\n valuePropsMapper: ({ value, onChange }) => ({\n onChange,\n value: props.type === 'file' || !props.type ? value : undefined,\n }),\n },\n );\n\n let {\n id,\n name,\n qa,\n value,\n onChange,\n placeholder,\n inputRef,\n isDisabled,\n isInvalid,\n isValid,\n inputStyles,\n type = 'file',\n inputProps,\n accept,\n form,\n ...otherProps\n } = props;\n\n const [dragHover, setDragHover] = useState(false);\n const defaultValue = useMemo(\n () => (type === 'file' ? value : undefined),\n [type, value],\n );\n const defaultFileName = useMemo(\n () => extractFileNameFromValue(defaultValue),\n [],\n );\n const [fileName, setFileName] = useState<string | undefined>(defaultFileName);\n\n let domRef = useRef(null);\n\n inputRef = useCombinedRefs(inputRef);\n\n const onLocalChange = useCallback(\n (event: any) => {\n const value = event.target.value;\n\n setFileName(extractFileNameFromValue(value));\n\n if (type === 'file') {\n onChange?.(value);\n } else {\n extractContents(event.target, onChange);\n }\n },\n [onChange],\n );\n\n let styles = extractStyles(otherProps, CONTAINER_STYLES);\n\n // Expose imperative interface for ref\n useImperativeHandle(ref, () => ({\n ...createFocusableRef(domRef, inputRef),\n select() {\n if (inputRef?.current) {\n inputRef.current.select();\n }\n },\n getInputElement() {\n return inputRef?.current;\n },\n }));\n\n const fileInput = (\n <FileInputElement\n ref={domRef}\n styles={inputStyles}\n isDisabled={isDisabled}\n mods={{\n selected: !!value,\n 'drag-hover': dragHover,\n ...getValidationMods({ isInvalid, isValid }),\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === 'Space') {\n inputRef?.current?.click();\n }\n }}\n >\n <input\n ref={inputRef}\n id={id}\n name={name}\n accept={accept}\n data-qa={qa || 'FileInput'}\n data-input-type=\"fileinput\"\n data-element=\"Input\"\n disabled={isDisabled}\n type=\"file\"\n multiple={false}\n tabIndex={-1}\n onChange={onLocalChange}\n onDragEnter={() => {\n setDragHover(true);\n }}\n onDragLeave={() => {\n setDragHover(false);\n }}\n onDrop={() => {\n setDragHover(false);\n }}\n {...inputProps}\n />\n <div data-element=\"Button\">\n {t('fileInput.chooseFile', 'Choose file')}\n </div>\n <div data-element={fileName ? 'Value' : 'Placeholder'}>\n {fileName ||\n placeholder ||\n t('fileInput.noFileSelected', 'No file selected')}\n </div>\n <ValidationIndicator isInvalid={isInvalid} isValid={isValid} />\n </FileInputElement>\n );\n\n return wrapWithField(fileInput, domRef, {\n ...props,\n });\n}\n\n/**\n * FileInputs are file inputs that allow users to select local files to\n * upload them to the server.\n */\nconst _FileInput = forwardRef(FileInput);\n\n_FileInput.displayName = 'FileInput';\n\nexport { _FileInput as FileInput };\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"FileInput.js","names":[],"sources":["../../../../src/components/fields/FileInput/FileInput.tsx"],"sourcesContent":["import { createFocusableRef } from '@react-spectrum/utils';\nimport {\n BaseProps,\n BlockStyleProps,\n CONTAINER_STYLES,\n ContainerStyleProps,\n PositionStyleProps,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport {\n forwardRef,\n RefObject,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useI18n } from '../../../i18n';\nimport { FieldBaseProps } from '../../../shared';\nimport { useCombinedRefs } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { Action } from '../../actions';\nimport {\n getValidationMods,\n useFieldProps,\n ValidationIndicator,\n wrapWithField,\n} from '../../form';\n\nimport type { AriaTextFieldProps } from 'react-aria';\nimport type { Props } from '../../../props';\n\nconst FileInputElement = tasty(Action, {\n qa: 'FileInputWrapper',\n styles: {\n display: 'inline-flex',\n position: 'relative',\n preset: 't3',\n padding: '.5x 1x',\n gap: '1x',\n flow: 'row',\n placeItems: 'center start',\n fill: {\n '': '#surface',\n 'drag-hover': '#primary.16',\n ':hover': '#primary.08',\n disabled: '#disabled-surface',\n },\n border: {\n '': true,\n valid: '#success-text.50',\n invalid: '#danger-text.50',\n ':focus-within & :focus-visible': '#primary-text',\n },\n radius: true,\n cursor: '$pointer',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n\n Button: {\n radius: true,\n border: {\n '': '#clear',\n pressed: '#primary.30',\n },\n fill: '#primary.12',\n color: {\n '': '#primary',\n disabled: '#dark.30',\n },\n padding: '.5x (1.5x - 1px)',\n transition: 'theme',\n },\n\n Placeholder: {\n color: '#dark-02',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n width: 'max 100%',\n overflow: 'hidden',\n },\n\n Value: {\n color: '#dark-02',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n width: 'max 100%',\n overflow: 'hidden',\n },\n\n State: {\n display: 'flex',\n placeItems: 'center',\n },\n\n ValidationIcon: {\n $: '> State >',\n display: 'grid',\n placeItems: 'center',\n width: 'min 2x',\n fontSize: '$icon-size',\n },\n\n Input: {\n position: 'absolute',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n radius: '$content-radius',\n opacity: 0.01,\n cursor: '$pointer',\n zIndex: 10,\n },\n },\n});\n\nexport interface CubeFileInputProps\n extends BaseProps,\n PositionStyleProps,\n ContainerStyleProps,\n BlockStyleProps,\n AriaTextFieldProps,\n FieldBaseProps {\n /** The form instance; redeclared for the same reason as in `Checkbox`. */\n form?: FieldBaseProps['form'];\n /**\n * The size of the input\n * @default default\n */\n size?: 'small' | 'default' | 'large' | string;\n /** The input ref */\n inputRef?: RefObject<HTMLInputElement>;\n /** Style map for the input */\n inputStyles?: Styles;\n /**\n * The type of the input\n * @default file\n */\n type?: 'file' | 'text';\n /** Direct input props */\n inputProps?: Props;\n /** The file types that the input should accept */\n accept?: string;\n value?: string;\n onChange?: (value: string) => void;\n placeholder?: string;\n}\n\nfunction extractContents(element, callback) {\n const files = element?.files;\n\n if (files && files.length > 0) {\n const fileReader = new FileReader();\n\n fileReader.onload = function () {\n callback(fileReader.result);\n };\n\n fileReader.readAsText(files[0]);\n }\n}\n\nfunction extractFileNameFromValue(value?: string) {\n return typeof value === 'string'\n ? (value as string).split('\\\\')?.pop()\n : undefined;\n}\n\nfunction FileInput(props: CubeFileInputProps, ref) {\n const { t } = useI18n();\n\n props = useFieldProps(\n { ...props },\n {\n defaultValidationTrigger: 'onChange',\n valuePropsMapper: ({ value, onChange }) => ({\n onChange,\n value: props.type === 'file' || !props.type ? value : undefined,\n }),\n },\n );\n\n let {\n id,\n name,\n qa,\n value,\n onChange,\n placeholder,\n inputRef,\n isDisabled,\n isInvalid,\n isValid,\n inputStyles,\n type = 'file',\n inputProps,\n accept,\n form,\n ...otherProps\n } = props;\n\n const [dragHover, setDragHover] = useState(false);\n const defaultValue = useMemo(\n () => (type === 'file' ? value : undefined),\n [type, value],\n );\n const defaultFileName = useMemo(\n () => extractFileNameFromValue(defaultValue),\n [],\n );\n const [fileName, setFileName] = useState<string | undefined>(defaultFileName);\n\n let domRef = useRef(null);\n\n inputRef = useCombinedRefs(inputRef);\n\n const onLocalChange = useCallback(\n (event: any) => {\n const value = event.target.value;\n\n setFileName(extractFileNameFromValue(value));\n\n if (type === 'file') {\n onChange?.(value);\n } else {\n extractContents(event.target, onChange);\n }\n },\n [onChange],\n );\n\n let styles = extractStyles(otherProps, CONTAINER_STYLES);\n\n // Expose imperative interface for ref\n useImperativeHandle(ref, () => ({\n ...createFocusableRef(domRef, inputRef),\n select() {\n if (inputRef?.current) {\n inputRef.current.select();\n }\n },\n getInputElement() {\n return inputRef?.current;\n },\n }));\n\n const fileInput = (\n <FileInputElement\n ref={domRef}\n styles={inputStyles}\n isDisabled={isDisabled}\n mods={{\n selected: !!value,\n 'drag-hover': dragHover,\n ...getValidationMods({ isInvalid, isValid }),\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === 'Space') {\n inputRef?.current?.click();\n }\n }}\n >\n <input\n ref={inputRef}\n id={id}\n name={name}\n accept={accept}\n data-qa={qa || 'FileInput'}\n data-input-type=\"fileinput\"\n data-element=\"Input\"\n disabled={isDisabled}\n type=\"file\"\n multiple={false}\n tabIndex={-1}\n onChange={onLocalChange}\n onDragEnter={() => {\n setDragHover(true);\n }}\n onDragLeave={() => {\n setDragHover(false);\n }}\n onDrop={() => {\n setDragHover(false);\n }}\n {...inputProps}\n />\n <div data-element=\"Button\">\n {t('fileInput.chooseFile', 'Choose file')}\n </div>\n <div data-element={fileName ? 'Value' : 'Placeholder'}>\n {fileName ||\n placeholder ||\n t('fileInput.noFileSelected', 'No file selected')}\n </div>\n <ValidationIndicator isInvalid={isInvalid} isValid={isValid} />\n </FileInputElement>\n );\n\n return wrapWithField(fileInput, domRef, {\n ...props,\n });\n}\n\n/**\n * FileInputs are file inputs that allow users to select local files to\n * upload them to the server.\n */\nconst _FileInput = forwardRef(FileInput);\n\n_FileInput.displayName = 'FileInput';\n\nexport { _FileInput as FileInput };\n"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { useCombinedRefs } from "../../../utils/react/useCombinedRefs.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
4
4
|
import { _Text } from "../../content/Text.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { TextInput } from "../TextInput/TextInput.js";
|
|
3
3
|
import { _FileInput } from "../FileInput/FileInput.js";
|
|
4
4
|
import { _NumberInput } from "../NumberInput/NumberInput.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { useCombinedRefs } from "../../../utils/react/useCombinedRefs.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
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 as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { DisplayTransition } from "../../helpers/DisplayTransition/DisplayTransition.js";
|
|
4
4
|
import { Portal } from "../../portal/Portal.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
//#region src/components/fields/ListBoxPopover/listNavigation.ts
|
|
3
3
|
/**
|
|
4
4
|
* Walks a collection (possibly nested under sections) and collects the keys of
|
|
@@ -6,7 +6,7 @@ import * as react from "react";
|
|
|
6
6
|
import { AriaNumberFieldProps as AriaNumberFieldProps$1 } from "react-aria";
|
|
7
7
|
|
|
8
8
|
//#region src/components/fields/NumberInput/NumberInput.d.ts
|
|
9
|
-
interface CubeNumberInputProps extends Omit<CubeTextInputBaseProps, 'defaultValue' | 'value' | 'onChange'>, Omit<AriaNumberFieldProps$1, 'validate'> {
|
|
9
|
+
interface CubeNumberInputProps extends Omit<CubeTextInputBaseProps, 'defaultValue' | 'value' | 'onChange'>, Omit<AriaNumberFieldProps$1, 'validate' | 'form'> {
|
|
10
10
|
/** Whether or to hide stepper */
|
|
11
11
|
hideStepper?: boolean;
|
|
12
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
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 as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { castNullableNumberValue } from "../../../utils/react/nullableValue.js";
|
|
4
4
|
import { useFieldProps } from "../../form/Form/use-field/use-field-props.js";
|
|
@@ -7,7 +7,7 @@ import { StepButton } from "./StepButton.js";
|
|
|
7
7
|
import { tasty } from "@tenphi/tasty";
|
|
8
8
|
import { forwardRef, useRef } from "react";
|
|
9
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { useLocale, useNumberField } from "react-aria";
|
|
10
|
+
import { mergeProps, useLocale, useNumberField } from "react-aria";
|
|
11
11
|
import { useNumberFieldState } from "react-stately";
|
|
12
12
|
|
|
13
13
|
//#region src/components/fields/NumberInput/NumberInput.tsx
|
|
@@ -49,7 +49,7 @@ function NumberInput(props, ref) {
|
|
|
49
49
|
...otherProps,
|
|
50
50
|
ref,
|
|
51
51
|
labelProps: mergedLabelProps,
|
|
52
|
-
inputProps: mergeProps$1(inputProps, { "data-input-type": "numberinput" }, userInputProps),
|
|
52
|
+
inputProps: mergeProps$1(mergeProps(inputProps, { id: props.id }), { "data-input-type": "numberinput" }, userInputProps),
|
|
53
53
|
inputRef,
|
|
54
54
|
wrapperProps: groupProps,
|
|
55
55
|
suffixPosition: "after",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.js","names":["mergeProps"],"sources":["../../../../src/components/fields/NumberInput/NumberInput.tsx"],"sourcesContent":["import { tasty } from '@tenphi/tasty';\nimport { ForwardedRef, forwardRef, RefObject, useRef } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"NumberInput.js","names":["mergeProps","mergeAriaProps"],"sources":["../../../../src/components/fields/NumberInput/NumberInput.tsx"],"sourcesContent":["import { tasty } from '@tenphi/tasty';\nimport { ForwardedRef, forwardRef, RefObject, useRef } from 'react';\nimport {\n AriaNumberFieldProps,\n mergeProps as mergeAriaProps,\n useLocale,\n useNumberField,\n} from 'react-aria';\nimport { useNumberFieldState } from 'react-stately';\n\nimport { mergeProps } from '../../../utils/react';\nimport {\n castNullableNumberValue,\n WithNullableValue,\n} from '../../../utils/react/nullableValue';\nimport { useFieldProps } from '../../form';\nimport { CubeTextInputBaseProps, TextInputBase } from '../TextInput';\n\nimport { StepButton } from './StepButton';\n\nexport interface CubeNumberInputProps\n extends Omit<CubeTextInputBaseProps, 'defaultValue' | 'value' | 'onChange'>,\n Omit<AriaNumberFieldProps, 'validate' | 'form'> {\n /** Whether or to hide stepper */\n hideStepper?: boolean;\n}\n\nconst StyledTextInputBase = tasty(TextInputBase, {\n inputStyles: {\n textAlign: 'right',\n },\n});\n\nconst StepperContainer = tasty({\n styles: {\n display: 'grid',\n gridColumns: '1sf',\n gridRows: '1sf 1sf',\n flow: 'column',\n placeSelf: 'stretch',\n margin: '(.5x - 1bw) left',\n },\n});\n\nfunction NumberInput(\n props: WithNullableValue<CubeNumberInputProps>,\n ref: ForwardedRef<HTMLElement>,\n) {\n props = castNullableNumberValue(props);\n props = useFieldProps(props);\n\n let {\n hideStepper,\n suffix,\n value,\n defaultValue,\n onChange,\n inputRef,\n labelProps: userLabelProps,\n inputProps: userInputProps,\n ...otherProps\n } = props;\n let showStepper = !hideStepper;\n let { locale } = useLocale();\n let state = useNumberFieldState({ ...props, locale });\n let localInputRef = useRef<HTMLInputElement>(null);\n\n inputRef = inputRef ?? localInputRef;\n\n let {\n groupProps,\n labelProps,\n inputProps,\n incrementButtonProps,\n decrementButtonProps,\n } = useNumberField(props, state, inputRef as RefObject<HTMLInputElement>);\n\n // Merge user-provided labelProps with aria labelProps\n const mergedLabelProps = mergeProps(labelProps, userLabelProps);\n\n const steppers = showStepper ? (\n <StepperContainer>\n <StepButton\n isDisabled={props.isDisabled}\n direction=\"up\"\n {...incrementButtonProps}\n size={otherProps.size}\n />\n <StepButton\n isDisabled={props.isDisabled}\n direction=\"down\"\n {...decrementButtonProps}\n size={otherProps.size}\n />\n </StepperContainer>\n ) : undefined;\n\n return (\n <StyledTextInputBase\n {...otherProps}\n ref={ref}\n labelProps={mergedLabelProps}\n inputProps={mergeProps(\n // `useNumberField` seeds its input id once. Merging the current id\n // through react-aria's own `mergeProps` updates that seed, so the\n // input, its label and the steppers' `aria-controls` follow the id\n // when the form binding changes after mount.\n mergeAriaProps(inputProps, { id: props.id }),\n { 'data-input-type': 'numberinput' },\n userInputProps,\n )}\n inputRef={inputRef}\n wrapperProps={groupProps}\n suffixPosition=\"after\"\n suffix={\n showStepper ? (\n props.suffixPosition === 'before' ? (\n <>\n {suffix}\n {steppers}\n </>\n ) : (\n <>\n {steppers}\n {suffix}\n </>\n )\n ) : (\n suffix\n )\n }\n />\n );\n}\n\n/**\n * NumberFields allow users to enter a number and increment or decrement the value using stepper buttons.\n */\nconst _NumberInput = forwardRef(NumberInput);\n\n(_NumberInput as any).cubeInputType = 'Number';\n\n_NumberInput.displayName = 'NumberInput';\n\nexport { _NumberInput as NumberInput };\nexport type { AriaNumberFieldProps };\n"],"mappings":";;;;;;;;;;;;;AA2BA,MAAM,sBAAsB,MAAM,eAAe,EAC/C,aAAa,EACX,WAAW,SACZ,EACF,CAAC;AAEF,MAAM,mBAAmB,MAAM,EAC7B,QAAQ;CACN,SAAS;CACT,aAAa;CACb,UAAU;CACV,MAAM;CACN,WAAW;CACX,QAAQ;CACT,EACF,CAAC;AAEF,SAAS,YACP,OACA,KACA;AACA,SAAQ,wBAAwB,MAAM;AACtC,SAAQ,cAAc,MAAM;CAE5B,IAAI,EACF,aACA,QACA,OACA,cACA,UACA,UACA,YAAY,gBACZ,YAAY,gBACZ,GAAG,eACD;CACJ,IAAI,cAAc,CAAC;CACnB,IAAI,EAAE,WAAW,WAAW;CAC5B,IAAI,QAAQ,oBAAoB;EAAE,GAAG;EAAO;EAAQ,CAAC;CACrD,IAAI,gBAAgB,OAAyB,KAAK;AAElD,YAAW,YAAY;CAEvB,IAAI,EACF,YACA,YACA,YACA,sBACA,yBACE,eAAe,OAAO,OAAO,SAAwC;CAGzE,MAAM,mBAAmBA,aAAW,YAAY,eAAe;CAE/D,MAAM,WAAW,cACf,qBAAC,+BACC,oBAAC;EACC,YAAY,MAAM;EAClB,WAAU;EACV,GAAI;EACJ,MAAM,WAAW;GACjB,EACF,oBAAC;EACC,YAAY,MAAM;EAClB,WAAU;EACV,GAAI;EACJ,MAAM,WAAW;GACjB,IACe,GACjB;AAEJ,QACE,oBAAC;EACC,GAAI;EACC;EACL,YAAY;EACZ,YAAYA,aAKVC,WAAe,YAAY,EAAE,IAAI,MAAM,IAAI,CAAC,EAC5C,EAAE,mBAAmB,eAAe,EACpC,eACD;EACS;EACV,cAAc;EACd,gBAAe;EACf,QACE,cACE,MAAM,mBAAmB,WACvB,8CACG,QACA,YACA,GAEH,8CACG,UACA,UACA,GAGL;GAGJ;;;;;AAON,MAAM,eAAe,WAAW,YAAY;AAE5C,AAAC,aAAqB,gBAAgB;AAEtC,aAAa,cAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { useI18n } from "../../../i18n/useI18n.js";
|
|
3
3
|
import { DirectionIcon } from "../../../icons/DirectionIcon.js";
|
|
4
4
|
import { Button } from "../../actions/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { chain } from "../../../utils/react/chain.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { useBufferedValue } from "../../../utils/react/useBufferedValue.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
4
4
|
import { _Text } from "../../content/Text.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { useFocus as useFocus$1 } from "../../../utils/react/interactions.js";
|
|
@@ -8,7 +8,7 @@ import * as react from "react";
|
|
|
8
8
|
import { AriaRadioGroupProps } from "react-aria";
|
|
9
9
|
|
|
10
10
|
//#region src/components/fields/RadioGroup/RadioGroup.d.ts
|
|
11
|
-
interface CubeRadioGroupProps extends BaseProps, Omit<AriaRadioGroupProps, 'errorMessage'>, ContainerStyleProps, FieldBaseProps {
|
|
11
|
+
interface CubeRadioGroupProps extends BaseProps, Omit<AriaRadioGroupProps, 'errorMessage' | 'form'>, ContainerStyleProps, FieldBaseProps {
|
|
12
12
|
groupStyles?: Styles;
|
|
13
13
|
orientation?: 'horizontal' | 'vertical';
|
|
14
14
|
value?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { castNullableStringValue } from "../../../utils/react/nullableValue.js";
|
|
5
|
-
import {
|
|
5
|
+
import { FormScopeMask } from "../../form/Form/Form.js";
|
|
6
6
|
import { useFieldProps } from "../../form/Form/use-field/use-field-props.js";
|
|
7
7
|
import { wrapWithField } from "../../form/wrapper.js";
|
|
8
8
|
import { RadioContext } from "./context.js";
|
|
@@ -78,7 +78,7 @@ function RadioGroup(props, ref) {
|
|
|
78
78
|
focused: isFocusWithinVisible
|
|
79
79
|
},
|
|
80
80
|
...groupFocusProps,
|
|
81
|
-
children: /* @__PURE__ */ jsx(
|
|
81
|
+
children: /* @__PURE__ */ jsx(FormScopeMask, {
|
|
82
82
|
value: {
|
|
83
83
|
isRequired,
|
|
84
84
|
isInvalid,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","names":["mergeProps"],"sources":["../../../../src/components/fields/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { useObjectRef } from '@react-aria/utils';\nimport {\n BaseProps,\n CONTAINER_STYLES,\n ContainerStyleProps,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport { forwardRef } from 'react';\nimport { AriaRadioGroupProps, useFocusRing, useRadioGroup } from 'react-aria';\nimport { useRadioGroupState } from 'react-stately';\n\nimport { FieldBaseProps } from '../../../shared';\nimport { mergeProps } from '../../../utils/react';\nimport {\n castNullableStringValue,\n WithNullableValue,\n} from '../../../utils/react/nullableValue';\nimport { extractStyles } from '../../../utils/styles';\nimport { CubeItemProps } from '../../content/Item/Item';\nimport {
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","names":["mergeProps"],"sources":["../../../../src/components/fields/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { useObjectRef } from '@react-aria/utils';\nimport {\n BaseProps,\n CONTAINER_STYLES,\n ContainerStyleProps,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport { forwardRef } from 'react';\nimport { AriaRadioGroupProps, useFocusRing, useRadioGroup } from 'react-aria';\nimport { useRadioGroupState } from 'react-stately';\n\nimport { FieldBaseProps } from '../../../shared';\nimport { mergeProps } from '../../../utils/react';\nimport {\n castNullableStringValue,\n WithNullableValue,\n} from '../../../utils/react/nullableValue';\nimport { extractStyles } from '../../../utils/styles';\nimport { CubeItemProps } from '../../content/Item/Item';\nimport { FormScopeMask, useFieldProps, wrapWithField } from '../../form';\n\nimport { RadioContext } from './context';\n\nexport interface CubeRadioGroupProps\n extends BaseProps,\n Omit<AriaRadioGroupProps, 'errorMessage' | 'form'>,\n ContainerStyleProps,\n FieldBaseProps {\n groupStyles?: Styles;\n orientation?: 'horizontal' | 'vertical';\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /* Size for all radio buttons in the group */\n size?: Omit<CubeItemProps['size'], 'inline'>;\n /* Button type for all button-style radios (ignored in tabs mode). When set to 'primary', selected buttons use 'primary' and non-selected use 'outline' with isSelected appearance */\n buttonType?: CubeItemProps['type'];\n /* Visual type for all radios in the group: radio (default), button, or tabs */\n type?: 'radio' | 'button' | 'tabs';\n}\n\nconst RadioGroupElement = tasty({\n qa: 'RadioGroup',\n styles: {\n display: 'flex',\n placeItems: 'stretch',\n placeContent: 'stretch',\n flow: {\n '': 'column',\n horizontal: 'row wrap',\n 'horizontal & tabs': 'row',\n },\n padding: {\n '': '0',\n tabs: '.5x',\n },\n // The tabs layout is the only one with padding, and a caller that gives the\n // group an explicit width (`width: 100%` inside a popover, say) means the\n // box it can see. Without this the padding is added on top and the group\n // overhangs its container by `1x`.\n boxSizing: 'border-box',\n radius: true,\n fill: {\n '': '#clear',\n 'tabs | disabled': '#surface-4',\n },\n width: 'max-content max-content initial',\n flexShrink: 0,\n gap: {\n '': '1x',\n button: 0,\n tabs: '.5x',\n },\n whiteSpace: 'nowrap',\n // Keyboard focus ring on the group, shown only for button/tabs layouts\n // where individual items are visually merged (button-group) or share a\n // single chrome (tabs) — the classic vertical radio list already shows\n // a per-item focus ring on the radio circle.\n outline: {\n '': '1bw #primary-text.0 / 1bw',\n 'focused & (button | tabs)': '1bw #primary-text / 1bw',\n },\n },\n});\n\nfunction RadioGroup(props: WithNullableValue<CubeRadioGroupProps>, ref) {\n let orientation = props.orientation;\n\n props = castNullableStringValue(props);\n props = useFieldProps(props, { defaultValidationTrigger: 'onChange' });\n\n let {\n qa,\n id,\n isDisabled,\n isRequired,\n labelPosition = 'top',\n isInvalid,\n isValid,\n children,\n styles,\n groupStyles,\n insideForm,\n // orientation, // ignore orientation since it came from the form context\n labelProps: baseLabelProps,\n size,\n buttonType,\n type,\n form,\n ...otherProps\n } = props;\n let domRef = useObjectRef(ref);\n\n styles = extractStyles(otherProps, CONTAINER_STYLES, styles);\n\n let state = useRadioGroupState(props);\n\n // Set default orientation based on type\n if (orientation == null) {\n orientation =\n type === 'button' || type === 'tabs' ? 'horizontal' : 'vertical';\n }\n\n let { radioGroupProps: fieldProps, labelProps } = useRadioGroup(\n { ...props, orientation },\n state,\n );\n\n // Keyboard-only focus ring on the group container (button/tabs layouts).\n // `within: true` tracks focus on any descendant radio. We read\n // `isFocusVisible` (not `isFocused`), which is keyboard-gated — mouse\n // clicks on a radio focus the input but leave `isFocusVisible` false.\n let { isFocusVisible: isFocusWithinVisible, focusProps: groupFocusProps } =\n useFocusRing({ within: true });\n\n let radioGroup = (\n <RadioGroupElement\n id={id}\n qa={qa || 'RadioGroup'}\n styles={styles}\n data-input-type=\"radiogroup\"\n data-radio-button-group={type === 'button' ? '' : undefined}\n mods={{\n horizontal: orientation === 'horizontal',\n 'inside-form': insideForm,\n 'side-label': labelPosition === 'side',\n button: type === 'button',\n tabs: type === 'tabs',\n focused: isFocusWithinVisible,\n }}\n {...groupFocusProps}\n >\n <FormScopeMask\n value={{\n isRequired,\n isInvalid,\n isValid,\n isDisabled,\n }}\n >\n <RadioContext.Provider\n value={{\n state,\n name: props.name,\n size,\n buttonType,\n type,\n isDisabled,\n }}\n >\n {children}\n </RadioContext.Provider>\n </FormScopeMask>\n </RadioGroupElement>\n );\n\n return wrapWithField(radioGroup, domRef, {\n ...props,\n fieldProps,\n labelProps: mergeProps(baseLabelProps, labelProps),\n });\n}\n\n/**\n * Radio groups allow users to select a single option from a list of mutually exclusive options.\n * All possible options are exposed up front for users to compare.\n */\nconst _RadioGroup = forwardRef(RadioGroup);\n\n(_RadioGroup as any).cubeInputType = 'RadioGroup';\n_RadioGroup.displayName = 'RadioGroup';\n\nexport { _RadioGroup as RadioGroup };\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,MAAM,oBAAoB,MAAM;CAC9B,IAAI;CACJ,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,cAAc;EACd,MAAM;GACJ,IAAI;GACJ,YAAY;GACZ,qBAAqB;GACtB;EACD,SAAS;GACP,IAAI;GACJ,MAAM;GACP;EAKD,WAAW;EACX,QAAQ;EACR,MAAM;GACJ,IAAI;GACJ,mBAAmB;GACpB;EACD,OAAO;EACP,YAAY;EACZ,KAAK;GACH,IAAI;GACJ,QAAQ;GACR,MAAM;GACP;EACD,YAAY;EAKZ,SAAS;GACP,IAAI;GACJ,6BAA6B;GAC9B;EACF;CACF,CAAC;AAEF,SAAS,WAAW,OAA+C,KAAK;CACtE,IAAI,cAAc,MAAM;AAExB,SAAQ,wBAAwB,MAAM;AACtC,SAAQ,cAAc,OAAO,EAAE,0BAA0B,YAAY,CAAC;CAEtE,IAAI,EACF,IACA,IACA,YACA,YACA,gBAAgB,OAChB,WACA,SACA,UACA,QACA,aACA,YAEA,YAAY,gBACZ,MACA,YACA,MACA,MACA,GAAG,eACD;CACJ,IAAI,SAAS,aAAa,IAAI;AAE9B,UAAS,cAAc,YAAY,kBAAkB,OAAO;CAE5D,IAAI,QAAQ,mBAAmB,MAAM;AAGrC,KAAI,eAAe,KACjB,eACE,SAAS,YAAY,SAAS,SAAS,eAAe;CAG1D,IAAI,EAAE,iBAAiB,YAAY,eAAe,cAChD;EAAE,GAAG;EAAO;EAAa,EACzB,MACD;CAMD,IAAI,EAAE,gBAAgB,sBAAsB,YAAY,oBACtD,aAAa,EAAE,QAAQ,MAAM,CAAC;AA2ChC,QAAO,cAxCL,oBAAC;EACK;EACJ,IAAI,MAAM;EACF;EACR,mBAAgB;EAChB,2BAAyB,SAAS,WAAW,KAAK;EAClD,MAAM;GACJ,YAAY,gBAAgB;GAC5B,eAAe;GACf,cAAc,kBAAkB;GAChC,QAAQ,SAAS;GACjB,MAAM,SAAS;GACf,SAAS;GACV;EACD,GAAI;YAEJ,oBAAC;GACC,OAAO;IACL;IACA;IACA;IACA;IACD;aAED,oBAAC,aAAa;IACZ,OAAO;KACL;KACA,MAAM,MAAM;KACZ;KACA;KACA;KACA;KACD;IAEA;KACqB;IACV;GACE,EAGW,QAAQ;EACvC,GAAG;EACH;EACA,YAAYA,aAAW,gBAAgB,WAAW;EACnD,CAAC;;;;;;AAOJ,MAAM,cAAc,WAAW,WAAW;AAE1C,AAAC,YAAoB,gBAAgB;AACrC,YAAY,cAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { useCombinedRefs } from "../../../utils/react/useCombinedRefs.js";
|
|
4
4
|
import { usePopoverSync } from "../../../utils/react/usePopoverSync.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { chain } from "../../../utils/react/chain.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { useBufferedValue } from "../../../utils/react/useBufferedValue.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { forwardRefWithGenerics } from "../../../utils/react/forwardRefWithGenerics.js";
|
|
4
4
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { __Slider } from "./Slider.js";
|
|
3
3
|
import { forwardRef, useCallback, useMemo, useState } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { Gradation } from "./Gradation.js";
|
|
3
3
|
import { _SliderBase } from "./SliderBase.js";
|
|
4
4
|
import { SliderThumb } from "./SliderThumb.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { Gradation } from "./Gradation.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.180.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { forwardRefWithGenerics } from "../../../utils/react/forwardRefWithGenerics.js";
|
|
4
4
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
@@ -97,8 +97,8 @@ function SliderBase(allProps, ref) {
|
|
|
97
97
|
styles = extractStyles(otherProps, OUTER_STYLES, styles);
|
|
98
98
|
return wrapWithField(/* @__PURE__ */ jsx(SliderElement, {
|
|
99
99
|
ref: domRef,
|
|
100
|
-
id: props.id,
|
|
101
100
|
...groupProps,
|
|
101
|
+
id: props.id ?? groupProps.id,
|
|
102
102
|
mods,
|
|
103
103
|
styles,
|
|
104
104
|
"data-input-type": "slider",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderBase.js","names":["Text","mergeProps"],"sources":["../../../../src/components/fields/Slider/SliderBase.tsx"],"sourcesContent":["import { useFocusableRef } from '@react-spectrum/utils';\nimport { DOMRef, FocusableRef } from '@react-types/shared';\nimport { OUTER_STYLES, tasty } from '@tenphi/tasty';\nimport {\n ForwardedRef,\n forwardRef,\n ReactNode,\n RefObject,\n useMemo,\n useRef,\n} from 'react';\nimport { useNumberFormatter, useSlider } from 'react-aria';\nimport { useSliderState } from 'react-stately';\n\nimport { forwardRefWithGenerics, mergeProps } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { Text } from '../../content/Text';\nimport { getValidationMods, useFieldProps, wrapWithField } from '../../form';\n\nimport { SliderControlsElement, SliderElement } from './elements';\n\nimport type { SliderState } from 'react-stately';\nimport type { CubeSliderBaseProps } from './types';\n\nexport interface SliderBaseChildArguments {\n inputRef: RefObject<HTMLInputElement | null>;\n trackRef: RefObject<HTMLElement | null>;\n state: SliderState;\n /** Resolved validation state. It is only known here, after `useFieldProps` merged the form state in. */\n isInvalid?: boolean;\n isValid?: boolean;\n}\n\nexport interface SliderBaseProps<T = number[]> extends CubeSliderBaseProps<T> {\n children: (opts: SliderBaseChildArguments) => ReactNode;\n}\n\nconst LabelValueElement = tasty(Text, {\n styles: {\n display: 'block',\n textAlign: 'right',\n },\n});\n\nfunction SliderBase(allProps: SliderBaseProps, ref: DOMRef<HTMLDivElement>) {\n let props = useFieldProps(allProps, {\n defaultValidationTrigger: 'onChange',\n valuePropsMapper: ({ value, onChange }) => ({\n value: value != null ? value : undefined,\n onChange: onChange,\n }),\n });\n\n let {\n labelPosition,\n label,\n extra,\n styles,\n isRequired,\n message,\n description,\n requiredMark,\n labelSuffix,\n labelStyles,\n necessityIndicator,\n gradation,\n isDisabled,\n isInvalid,\n isValid,\n inputStyles,\n minValue = 0,\n maxValue = 100,\n inputWidth,\n formatOptions,\n getValueLabel,\n onChange,\n onChangeEnd,\n children,\n showValueLabel = true,\n orientation: formOrientation,\n form,\n labelProps: userLabelProps,\n ...otherProps\n } = props;\n\n let orientation = allProps.orientation || 'horizontal';\n\n // `Math.abs(Math.sign(a) - Math.sign(b)) === 2` is true if the values have a different sign.\n let alwaysDisplaySign =\n Math.abs(Math.sign(minValue) - Math.sign(maxValue)) === 2;\n if (alwaysDisplaySign) {\n if (formatOptions != null) {\n if (!('signDisplay' in formatOptions)) {\n formatOptions = {\n ...formatOptions,\n signDisplay: 'exceptZero',\n };\n }\n } else {\n formatOptions = { signDisplay: 'exceptZero' };\n }\n }\n\n const formatter = useNumberFormatter(formatOptions);\n\n const state = useSliderState({\n ...props,\n orientation,\n numberFormatter: formatter,\n minValue,\n maxValue,\n });\n\n const trackRef = useRef<HTMLElement>(null);\n\n let { groupProps, trackProps, labelProps, outputProps } = useSlider(\n props,\n state,\n trackRef,\n );\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n let domRef = useFocusableRef(ref as any, inputRef);\n\n let displayValue = '';\n let maxLabelLength = 0;\n\n if (typeof getValueLabel === 'function') {\n displayValue = getValueLabel(state.values);\n switch (state.values.length) {\n case 1:\n maxLabelLength = Math.max(\n getValueLabel([minValue]).length,\n getValueLabel([maxValue]).length,\n );\n break;\n case 2:\n // Try all possible combinations of min and max values.\n maxLabelLength = Math.max(\n getValueLabel([minValue, minValue]).length,\n getValueLabel([minValue, maxValue]).length,\n getValueLabel([maxValue, minValue]).length,\n getValueLabel([maxValue, maxValue]).length,\n );\n break;\n default:\n throw new Error('Only sliders with 1 or 2 handles are supported!');\n }\n } else {\n maxLabelLength = Math.max(\n [...formatter.format(minValue)].length,\n [...formatter.format(maxValue)].length,\n );\n switch (state.values.length) {\n case 1:\n displayValue = state.getThumbValueLabel(0);\n break;\n case 2:\n // This should really use the NumberFormat#formatRange proposal...\n // https://github.com/tc39/ecma402/issues/393\n // https://github.com/tc39/proposal-intl-numberformat-v3#formatrange-ecma-402-393\n displayValue = `${state.getThumbValueLabel(\n 0,\n )} – ${state.getThumbValueLabel(1)}`;\n maxLabelLength =\n 3 +\n 2 *\n Math.max(\n maxLabelLength,\n [...formatter.format(minValue)].length,\n [...formatter.format(maxValue)].length,\n );\n break;\n default:\n throw new Error('Only sliders with 1 or 2 handles are supported!');\n }\n }\n\n extra =\n extra != null || !showValueLabel ? (\n extra\n ) : (\n <LabelValueElement\n {...outputProps}\n style={\n maxLabelLength\n ? {\n width: `${maxLabelLength + 1}ch`,\n minWidth: `${maxLabelLength + 1}ch`,\n }\n : undefined\n }\n >\n {displayValue}\n </LabelValueElement>\n );\n\n const mods = useMemo(\n () => ({\n 'side-label': labelPosition === 'side',\n horizontal: orientation === 'horizontal',\n ...getValidationMods({ isInvalid, isValid }),\n }),\n [labelPosition, orientation, isInvalid, isValid],\n );\n\n styles = extractStyles(otherProps, OUTER_STYLES, styles);\n\n const sliderField = (\n <SliderElement\n ref={domRef}\n id={props.id
|
|
1
|
+
{"version":3,"file":"SliderBase.js","names":["Text","mergeProps"],"sources":["../../../../src/components/fields/Slider/SliderBase.tsx"],"sourcesContent":["import { useFocusableRef } from '@react-spectrum/utils';\nimport { DOMRef, FocusableRef } from '@react-types/shared';\nimport { OUTER_STYLES, tasty } from '@tenphi/tasty';\nimport {\n ForwardedRef,\n forwardRef,\n ReactNode,\n RefObject,\n useMemo,\n useRef,\n} from 'react';\nimport { useNumberFormatter, useSlider } from 'react-aria';\nimport { useSliderState } from 'react-stately';\n\nimport { forwardRefWithGenerics, mergeProps } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { Text } from '../../content/Text';\nimport { getValidationMods, useFieldProps, wrapWithField } from '../../form';\n\nimport { SliderControlsElement, SliderElement } from './elements';\n\nimport type { SliderState } from 'react-stately';\nimport type { CubeSliderBaseProps } from './types';\n\nexport interface SliderBaseChildArguments {\n inputRef: RefObject<HTMLInputElement | null>;\n trackRef: RefObject<HTMLElement | null>;\n state: SliderState;\n /** Resolved validation state. It is only known here, after `useFieldProps` merged the form state in. */\n isInvalid?: boolean;\n isValid?: boolean;\n}\n\nexport interface SliderBaseProps<T = number[]> extends CubeSliderBaseProps<T> {\n children: (opts: SliderBaseChildArguments) => ReactNode;\n}\n\nconst LabelValueElement = tasty(Text, {\n styles: {\n display: 'block',\n textAlign: 'right',\n },\n});\n\nfunction SliderBase(allProps: SliderBaseProps, ref: DOMRef<HTMLDivElement>) {\n let props = useFieldProps(allProps, {\n defaultValidationTrigger: 'onChange',\n valuePropsMapper: ({ value, onChange }) => ({\n value: value != null ? value : undefined,\n onChange: onChange,\n }),\n });\n\n let {\n labelPosition,\n label,\n extra,\n styles,\n isRequired,\n message,\n description,\n requiredMark,\n labelSuffix,\n labelStyles,\n necessityIndicator,\n gradation,\n isDisabled,\n isInvalid,\n isValid,\n inputStyles,\n minValue = 0,\n maxValue = 100,\n inputWidth,\n formatOptions,\n getValueLabel,\n onChange,\n onChangeEnd,\n children,\n showValueLabel = true,\n orientation: formOrientation,\n form,\n labelProps: userLabelProps,\n ...otherProps\n } = props;\n\n let orientation = allProps.orientation || 'horizontal';\n\n // `Math.abs(Math.sign(a) - Math.sign(b)) === 2` is true if the values have a different sign.\n let alwaysDisplaySign =\n Math.abs(Math.sign(minValue) - Math.sign(maxValue)) === 2;\n if (alwaysDisplaySign) {\n if (formatOptions != null) {\n if (!('signDisplay' in formatOptions)) {\n formatOptions = {\n ...formatOptions,\n signDisplay: 'exceptZero',\n };\n }\n } else {\n formatOptions = { signDisplay: 'exceptZero' };\n }\n }\n\n const formatter = useNumberFormatter(formatOptions);\n\n const state = useSliderState({\n ...props,\n orientation,\n numberFormatter: formatter,\n minValue,\n maxValue,\n });\n\n const trackRef = useRef<HTMLElement>(null);\n\n let { groupProps, trackProps, labelProps, outputProps } = useSlider(\n props,\n state,\n trackRef,\n );\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n let domRef = useFocusableRef(ref as any, inputRef);\n\n let displayValue = '';\n let maxLabelLength = 0;\n\n if (typeof getValueLabel === 'function') {\n displayValue = getValueLabel(state.values);\n switch (state.values.length) {\n case 1:\n maxLabelLength = Math.max(\n getValueLabel([minValue]).length,\n getValueLabel([maxValue]).length,\n );\n break;\n case 2:\n // Try all possible combinations of min and max values.\n maxLabelLength = Math.max(\n getValueLabel([minValue, minValue]).length,\n getValueLabel([minValue, maxValue]).length,\n getValueLabel([maxValue, minValue]).length,\n getValueLabel([maxValue, maxValue]).length,\n );\n break;\n default:\n throw new Error('Only sliders with 1 or 2 handles are supported!');\n }\n } else {\n maxLabelLength = Math.max(\n [...formatter.format(minValue)].length,\n [...formatter.format(maxValue)].length,\n );\n switch (state.values.length) {\n case 1:\n displayValue = state.getThumbValueLabel(0);\n break;\n case 2:\n // This should really use the NumberFormat#formatRange proposal...\n // https://github.com/tc39/ecma402/issues/393\n // https://github.com/tc39/proposal-intl-numberformat-v3#formatrange-ecma-402-393\n displayValue = `${state.getThumbValueLabel(\n 0,\n )} – ${state.getThumbValueLabel(1)}`;\n maxLabelLength =\n 3 +\n 2 *\n Math.max(\n maxLabelLength,\n [...formatter.format(minValue)].length,\n [...formatter.format(maxValue)].length,\n );\n break;\n default:\n throw new Error('Only sliders with 1 or 2 handles are supported!');\n }\n }\n\n extra =\n extra != null || !showValueLabel ? (\n extra\n ) : (\n <LabelValueElement\n {...outputProps}\n style={\n maxLabelLength\n ? {\n width: `${maxLabelLength + 1}ch`,\n minWidth: `${maxLabelLength + 1}ch`,\n }\n : undefined\n }\n >\n {displayValue}\n </LabelValueElement>\n );\n\n const mods = useMemo(\n () => ({\n 'side-label': labelPosition === 'side',\n horizontal: orientation === 'horizontal',\n ...getValidationMods({ isInvalid, isValid }),\n }),\n [labelPosition, orientation, isInvalid, isValid],\n );\n\n styles = extractStyles(otherProps, OUTER_STYLES, styles);\n\n const sliderField = (\n <SliderElement\n ref={domRef}\n {...groupProps}\n // `useSlider` seeds the group id once; the current id follows the form\n // binding, and the label points at it.\n id={props.id ?? groupProps.id}\n mods={mods}\n styles={styles}\n data-input-type=\"slider\"\n >\n <SliderControlsElement {...trackProps} ref={trackRef} mods={mods}>\n {children({\n trackRef,\n inputRef,\n state,\n isInvalid,\n isValid,\n })}\n </SliderControlsElement>\n </SliderElement>\n );\n\n return wrapWithField(sliderField, ref, {\n ...props,\n extra,\n labelProps: mergeProps(labelProps, userLabelProps),\n });\n}\n\nconst _SliderBase = forwardRefWithGenerics(SliderBase);\n\n(_SliderBase as any).displayName = 'SliderBase';\n\nexport { _SliderBase as SliderBase };\nexport { useSlider };\n"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
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 as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { getValidationMods } from "../../form/validation/resolve-validation-props.js";
|
|
4
4
|
import { SliderThumbElement } from "./elements.js";
|