@cube-dev/ui-kit 0.157.3 → 0.159.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 +155 -0
- package/dist/_internal/hooks/use-chained-callback.js +1 -1
- package/dist/_internal/hooks/use-debounced-value.js +1 -1
- package/dist/_internal/hooks/use-deprecation-warning.js +1 -1
- package/dist/_internal/hooks/use-event.js +1 -1
- package/dist/_internal/hooks/use-is-first-render.js +1 -1
- package/dist/_internal/hooks/use-sync-ref.js +1 -1
- package/dist/_internal/hooks/use-timer/timer.js +1 -1
- package/dist/_internal/hooks/use-timer/use-timer.js +1 -1
- package/dist/_internal/hooks/use-warn.js +1 -1
- package/dist/components/Block.js +1 -1
- package/dist/components/CollectionItem.js +1 -1
- package/dist/components/GlobalStyles.js +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/Button.js +10 -4
- package/dist/components/actions/Button/Button.js.map +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/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/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.d.ts +7 -0
- package/dist/components/content/Item/Item.js +13 -6
- package/dist/components/content/Item/Item.js.map +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.js +1 -1
- package/dist/components/content/ItemCard/ItemCard.js +1 -1
- package/dist/components/content/Layout/GridLayout.js +1 -1
- package/dist/components/content/Layout/Layout.js +1 -1
- package/dist/components/content/Layout/LayoutBlock.js +1 -1
- package/dist/components/content/Layout/LayoutCenter.js +1 -1
- package/dist/components/content/Layout/LayoutContainer.js +1 -1
- package/dist/components/content/Layout/LayoutContent.js +1 -1
- package/dist/components/content/Layout/LayoutContext.js +1 -1
- package/dist/components/content/Layout/LayoutFlex.js +1 -1
- package/dist/components/content/Layout/LayoutFooter.js +1 -1
- package/dist/components/content/Layout/LayoutGrid.js +1 -1
- package/dist/components/content/Layout/LayoutHeader.js +1 -1
- package/dist/components/content/Layout/LayoutPane.js +1 -1
- package/dist/components/content/Layout/LayoutPanel.js +1 -1
- package/dist/components/content/Layout/LayoutPanelHeader.js +1 -1
- package/dist/components/content/Layout/LayoutToolbar.js +1 -1
- package/dist/components/content/Layout/hooks/useTinyScrollbar.js +1 -1
- package/dist/components/content/Layout/index.js +1 -1
- package/dist/components/content/Layout/utils.js +1 -1
- package/dist/components/content/Paragraph.js +1 -1
- package/dist/components/content/Placeholder/Placeholder.js +1 -1
- package/dist/components/content/PrismCode/PrismCode.js +1 -1
- package/dist/components/content/PrismCode/prismSetup.js +1 -1
- package/dist/components/content/PrismDiffCode/PrismDiffCode.js +1 -1
- package/dist/components/content/Result/Result.js +1 -1
- package/dist/components/content/Skeleton/Skeleton.js +1 -1
- package/dist/components/content/Tag/Tag.js +1 -1
- package/dist/components/content/Text.d.ts +14 -14
- package/dist/components/content/Text.js +1 -1
- package/dist/components/content/TextItem/TextItem.js +1 -1
- package/dist/components/content/Title.js +1 -1
- package/dist/components/content/Tree/Tree.js +1 -1
- package/dist/components/content/Tree/TreeNode.js +1 -1
- package/dist/components/content/Tree/styled.js +1 -1
- package/dist/components/content/Tree/tree-index.js +1 -1
- package/dist/components/content/Tree/use-checkbox-tree.js +1 -1
- package/dist/components/content/Tree/use-load-data.js +1 -1
- package/dist/components/content/highlightText.js +1 -1
- package/dist/components/content/use-auto-tooltip.js +41 -32
- package/dist/components/content/use-auto-tooltip.js.map +1 -1
- package/dist/components/data/DataTable/DataTable.js +82 -24
- package/dist/components/data/DataTable/DataTable.js.map +1 -1
- package/dist/components/data/DataTable/types.d.ts +56 -1
- package/dist/components/data/ItemTable/ItemTable.js +13 -5
- package/dist/components/data/ItemTable/ItemTable.js.map +1 -1
- package/dist/components/data/ItemTable/ItemTableBulkBar.js +3 -7
- package/dist/components/data/ItemTable/ItemTableBulkBar.js.map +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/ItemTable/types.d.ts +19 -0
- package/dist/components/data/TableBase/ColumnResizer.js +1 -1
- package/dist/components/data/TableBase/RowCollection.js +5 -3
- package/dist/components/data/TableBase/RowCollection.js.map +1 -1
- package/dist/components/data/TableBase/TableHeaderCell.js +115 -0
- package/dist/components/data/TableBase/TableHeaderCell.js.map +1 -0
- package/dist/components/data/TableBase/TableRow.js +1 -1
- package/dist/components/data/TableBase/TableView.js +195 -33
- package/dist/components/data/TableBase/TableView.js.map +1 -1
- package/dist/components/data/TableBase/column-menu.d.ts +36 -0
- package/dist/components/data/TableBase/column-menu.js +104 -0
- package/dist/components/data/TableBase/column-menu.js.map +1 -0
- package/dist/components/data/TableBase/column-tint.js +168 -0
- package/dist/components/data/TableBase/column-tint.js.map +1 -0
- package/dist/components/data/TableBase/index.d.ts +3 -2
- package/dist/components/data/TableBase/row-menu.js +11 -6
- package/dist/components/data/TableBase/row-menu.js.map +1 -1
- package/dist/components/data/TableBase/styled.js +45 -16
- package/dist/components/data/TableBase/styled.js.map +1 -1
- package/dist/components/data/TableBase/types.d.ts +104 -6
- package/dist/components/data/TableBase/types.js +1 -1
- package/dist/components/data/TableBase/types.js.map +1 -1
- package/dist/components/data/TableBase/use-cell-selection.js +0 -0
- package/dist/components/data/TableBase/use-column-order.js +100 -0
- package/dist/components/data/TableBase/use-column-order.js.map +1 -0
- 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 +24 -2
- package/dist/components/data/TableBase/use-table-columns.js.map +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 +20 -1
- package/dist/components/data/TableBase/use-table-sort.js.map +1 -1
- package/dist/components/data/TableBase/use-table-sorts.js +40 -1
- package/dist/components/data/TableBase/use-table-sorts.js.map +1 -1
- package/dist/components/data/TableBase/use-table-storage.d.ts +1 -1
- package/dist/components/data/TableBase/use-table-storage.js +6 -2
- package/dist/components/data/TableBase/use-table-storage.js.map +1 -1
- package/dist/components/data/index.d.ts +2 -1
- package/dist/components/fields/Checkbox/Checkbox.js +1 -1
- package/dist/components/fields/Checkbox/CheckboxGroup.js +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/ColorSwatchGroup/ColorSwatchGroup.js +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +1 -1
- package/dist/components/fields/CommandTextArea/CommandTextArea.js +1 -1
- package/dist/components/fields/CommandTextArea/caretPosition.js +1 -1
- package/dist/components/fields/CommandTextArea/useCaretAnchor.js +1 -1
- package/dist/components/fields/DatePicker/DateInput.js +1 -1
- package/dist/components/fields/DatePicker/DateInputBase.js +1 -1
- package/dist/components/fields/DatePicker/DatePicker.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerButton.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerElement.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerInput.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerSegment.js +1 -1
- package/dist/components/fields/DatePicker/DateRangePicker.js +1 -1
- package/dist/components/fields/DatePicker/DateRangeSeparatedPicker.js +1 -1
- package/dist/components/fields/DatePicker/MonthPicker.js +1 -1
- package/dist/components/fields/DatePicker/PeriodPicker.js +1 -1
- package/dist/components/fields/DatePicker/QuarterPicker.js +1 -1
- package/dist/components/fields/DatePicker/TimeInput.js +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.js +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/listNavigation.js +1 -1
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.js +1 -1
- package/dist/components/fields/NumberInput/NumberInput.js +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.js +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 +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/Switch/Switch.js +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.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/fields/color/ColorPanel.js +1 -1
- package/dist/components/fields/color/ColorSwatch.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.js +1 -1
- package/dist/components/form/Form/ResetButton/ResetButton.js +1 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.js +1 -1
- package/dist/components/form/Form/SubmitError.js +1 -1
- package/dist/components/form/Form/index.js +1 -1
- package/dist/components/form/Form/use-field/use-field-props.js +1 -1
- package/dist/components/form/Form/use-field/use-field.js +1 -1
- package/dist/components/form/Form/use-form.js +1 -1
- package/dist/components/form/Form/validation.js +1 -1
- package/dist/components/form/Label.js +1 -1
- package/dist/components/form/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.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/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/PeriodCalendar.js +1 -1
- package/dist/components/other/Calendar/RangeCalendar.js +1 -1
- package/dist/components/other/CubeLogo/CubeLogo.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogApiProvider.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogZone.js +1 -1
- package/dist/components/overlays/Dialog/Dialog.js +1 -1
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +1 -1
- package/dist/components/overlays/Dialog/DialogTrigger.js +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Modal/Modal.js +1 -1
- package/dist/components/overlays/Modal/OpenTransitionContext.js +1 -1
- package/dist/components/overlays/Modal/Overlay.js +1 -1
- package/dist/components/overlays/Modal/Popover.js +1 -1
- package/dist/components/overlays/Modal/Tray.js +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +1 -1
- package/dist/components/overlays/Notifications/NotificationCard.js +1 -1
- package/dist/components/overlays/Notifications/NotificationContext.js +1 -1
- package/dist/components/overlays/Notifications/NotificationItem.js +1 -1
- package/dist/components/overlays/Notifications/OverlayContainer.js +1 -1
- package/dist/components/overlays/Notifications/OverlayProvider.js +1 -1
- package/dist/components/overlays/Notifications/PersistentNotificationsList.js +1 -1
- package/dist/components/overlays/Notifications/dismissed-storage.js +1 -1
- package/dist/components/overlays/Notifications/format-relative-time.js +1 -1
- package/dist/components/overlays/Notifications/index.js +1 -1
- package/dist/components/overlays/Notifications/use-notification-state.js +1 -1
- package/dist/components/overlays/Notifications/use-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-overlay-timers.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-state.js +1 -1
- package/dist/components/overlays/Notifications/use-toast-state.js +1 -1
- package/dist/components/overlays/Toast/ToastItem.js +1 -1
- package/dist/components/overlays/Toast/index.js +1 -1
- package/dist/components/overlays/Toast/useProgressToast.js +1 -1
- package/dist/components/overlays/Toast/useToast.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipProvider.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipTrigger.js +1 -1
- package/dist/components/overlays/Tooltip/context.js +1 -1
- package/dist/components/portal/Portal.js +1 -1
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +1 -1
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/Spin/Cube.js +1 -1
- package/dist/components/status/Spin/InternalSpinner.js +1 -1
- package/dist/components/status/Spin/Spin.js +1 -1
- package/dist/components/status/Spin/SpinsContainer.js +1 -1
- package/dist/data/item-themes.js +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/eslint-plugin/defaults.generated.js +13 -1
- package/dist/eslint-plugin/defaults.generated.js.map +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 +5 -1
- package/dist/i18n/locales/en-US/uikit.js +5 -1
- package/dist/i18n/locales/en-US/uikit.json.d.ts +4 -0
- package/dist/i18n/locales/es-ES/uikit.js +5 -1
- package/dist/i18n/locales/es-MX/uikit.js +5 -1
- package/dist/i18n/locales/fr-FR/uikit.js +5 -1
- package/dist/i18n/locales/it-IT/uikit.js +5 -1
- package/dist/i18n/locales/ja-JP/uikit.js +5 -1
- package/dist/i18n/locales/nb-NO/uikit.js +5 -1
- package/dist/i18n/locales/pt-BR/uikit.js +5 -1
- package/dist/i18n/locales/pt-PT/uikit.js +5 -1
- package/dist/i18n/locales/sv-SE/uikit.js +5 -1
- package/dist/i18n/locales/vi-VN/uikit.js +5 -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.d.ts +12 -0
- package/dist/icons/ArrowNarrowDownIcon.js +11 -0
- package/dist/icons/ArrowNarrowDownIcon.js.map +1 -0
- package/dist/icons/ArrowNarrowUpIcon.d.ts +12 -0
- package/dist/icons/ArrowNarrowUpIcon.js +11 -0
- package/dist/icons/ArrowNarrowUpIcon.js.map +1 -0
- 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/index.d.ts +2 -0
- package/dist/icons/wrap-icon.js +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.js +7 -2
- package/dist/index.js.map +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/tokens/base.js +1 -1
- package/dist/tokens/color-theme.d.ts +86 -0
- package/dist/tokens/color-theme.js +156 -0
- package/dist/tokens/color-theme.js.map +1 -0
- package/dist/tokens/colors.js +1 -1
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.js +2 -1
- package/dist/tokens/index.js.map +1 -1
- package/dist/tokens/layout.js +1 -1
- package/dist/tokens/lazy-styles.js +1 -1
- package/dist/tokens/palette-config.d.ts +1 -1
- package/dist/tokens/palette-config.js +17 -5
- package/dist/tokens/palette-config.js.map +1 -1
- package/dist/tokens/palette.d.ts +1 -1
- package/dist/tokens/palette.js +44 -2
- package/dist/tokens/palette.js.map +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/index.d.ts +1 -0
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/modules.js +1 -1
- package/dist/utils/promise.js +1 -1
- package/dist/utils/raf.js +1 -1
- package/dist/utils/random.js +1 -1
- package/dist/utils/range.js +1 -1
- package/dist/utils/react/RenderCache.js +1 -1
- package/dist/utils/react/Slots.js +1 -1
- package/dist/utils/react/chain.js +1 -1
- package/dist/utils/react/disabledProps.d.ts +49 -0
- package/dist/utils/react/disabledProps.js +82 -0
- package/dist/utils/react/disabledProps.js.map +1 -0
- package/dist/utils/react/forwardRefWithGenerics.js +1 -1
- package/dist/utils/react/index.d.ts +1 -0
- package/dist/utils/react/index.js +2 -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/useViewportSize.js +1 -1
- package/dist/utils/react/wrapNodeIfPlain.js +1 -1
- package/dist/utils/selection.js +1 -1
- package/dist/utils/styles.js +1 -1
- package/dist/utils/tree.js +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/version.js +2 -2
- package/docs/Theming.md +20 -13
- package/docs/components/actions/Button.md +17 -0
- package/docs/components/content/Item.md +8 -1
- package/docs/components/data/DataTable.md +118 -2
- package/docs/components/data/ItemTable.md +37 -5
- package/package.json +1 -1
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/data/TableBase/use-table-columns.ts
|
|
5
5
|
/** @default when a column declares neither `width` nor `minWidth`. */
|
|
6
6
|
const DEFAULT_MIN_WIDTH = 150;
|
|
7
7
|
/**
|
|
8
|
+
* Every column's current width, so a resize can change exactly one of them.
|
|
9
|
+
*
|
|
10
|
+
* A column with no explicit width is `flex: 1` and shares the leftover (see the
|
|
11
|
+
* spec builder below). Making only the DRAGGED column fixed leaves every other
|
|
12
|
+
* one in the flex pool, re-splitting a leftover that just changed — so one
|
|
13
|
+
* divider moved all of them, including columns to the LEFT of the handle, which
|
|
14
|
+
* cannot be what dragging a right edge means. Measured before this existed:
|
|
15
|
+
* dragging column B by +8px took 3px off A, C and D each.
|
|
16
|
+
*
|
|
17
|
+
* Freezing first means a drag changes one width. Columns after it are pushed
|
|
18
|
+
* along, which is what being after it means, and the table grows or shrinks
|
|
19
|
+
* rather than the neighbours absorbing the difference.
|
|
20
|
+
*
|
|
21
|
+
* Structural columns are skipped — they are sized by the table, not the user.
|
|
22
|
+
*/
|
|
23
|
+
function freezeColumnWidths(layout, base) {
|
|
24
|
+
return (layout?.columns ?? []).reduce((widths, column) => {
|
|
25
|
+
if (!column.isStructural && column.width != null) widths[column.key] = Math.round(column.width);
|
|
26
|
+
return widths;
|
|
27
|
+
}, { ...base });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
8
30
|
* Reads `key` as a data path. A plain key is a single property lookup; dots
|
|
9
31
|
* walk nested objects (`'owner.name'`). Anything richer belongs in `getValue`.
|
|
10
32
|
*/
|
|
@@ -162,5 +184,5 @@ function useTableColumns({ columns, containerWidth, columnWidths, leadingColumns
|
|
|
162
184
|
}
|
|
163
185
|
|
|
164
186
|
//#endregion
|
|
165
|
-
export { getColumnText, getColumnValue, useTableColumns };
|
|
187
|
+
export { freezeColumnWidths, getColumnText, getColumnValue, useTableColumns };
|
|
166
188
|
//# sourceMappingURL=use-table-columns.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-columns.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-columns.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport type {\n CubeResolvedColumn,\n CubeTableColumn,\n CubeTableColumnLayout,\n} from './types';\n\n/** @default when a column declares neither `width` nor `minWidth`. */\nexport const DEFAULT_MIN_WIDTH = 150;\n\n/**\n * Reads `key` as a data path. A plain key is a single property lookup; dots\n * walk nested objects (`'owner.name'`). Anything richer belongs in `getValue`.\n */\nexport function readPath(row: any, path: string): unknown {\n if (row == null) return undefined;\n if (!path.includes('.')) return row[path];\n\n let current: any = row;\n\n for (const part of path.split('.')) {\n if (current == null) return undefined;\n current = current[part];\n }\n\n return current;\n}\n\n/** Only the value-pipeline members, so both raw and resolved columns fit. */\ntype ValueColumn<T> = Pick<CubeTableColumn<T>, 'key' | 'getValue' | 'format'>;\n\nexport function getColumnValue<T>(\n column: ValueColumn<T>,\n row: T,\n rowIndex: number,\n): unknown {\n return column.getValue\n ? column.getValue(row, rowIndex)\n : readPath(row, column.key);\n}\n\n/**\n * Display text for a cell — what client sort, client search and TSV copy all\n * operate on. Deliberately NOT the rendered output: `render` may return\n * arbitrary React, and stringifying that is how cloud's filter ended up\n * matching `\"[object Object]\"` against the query `\"object\"`.\n *\n * Returns `null` when the column cannot produce text, so callers can skip it\n * rather than coerce a non-primitive.\n */\nexport function getColumnText<T>(\n column: ValueColumn<T>,\n row: T,\n rowIndex: number,\n): string | null {\n const value = getColumnValue(column, row, rowIndex);\n\n if (column.format) return column.format(value, row, rowIndex);\n if (value == null) return '';\n\n const type = typeof value;\n\n if (type === 'string') return value as string;\n if (type === 'number' || type === 'boolean' || type === 'bigint') {\n return String(value);\n }\n if (value instanceof Date) return value.toISOString();\n\n return null;\n}\n\nfunction clamp(value: number, min: number, max: number | null): number {\n return Math.min(Math.max(value, min), max ?? Number.POSITIVE_INFINITY);\n}\n\nexport interface UseTableColumnsOptions<T> {\n columns: CubeTableColumn<T>[];\n /** Content-box width of the scroller, or `null` before the first measure. */\n containerWidth: number | null;\n /** User-resized widths, keyed by column key. Wins over `column.width`. */\n columnWidths?: Record<string, number>;\n /** Extra leading columns owned by the table (selection, drag handle). */\n leadingColumns?: CubeTableColumn<T>[];\n /** Extra trailing columns owned by the table (row menu). */\n trailingColumns?: CubeTableColumn<T>[];\n}\n\n/**\n * Normalizes the public column list into resolved leaves: visual order, ARIA\n * indices, pixel widths, and sticky offsets for pinned columns.\n *\n * Width resolution mirrors ag-grid's `fitGridWidth`: fixed columns take their\n * width, the remainder is split across flex columns by weight, and each result\n * is clamped to `[minWidth, maxWidth]`. Clamping perturbs the sum, so the\n * residual is redistributed across the still-unclamped columns until it\n * settles. When even the minimums do not fit, every column takes its minimum\n * and the table scrolls horizontally.\n */\nexport function useTableColumns<T>({\n columns,\n containerWidth,\n columnWidths,\n leadingColumns,\n trailingColumns,\n}: UseTableColumnsOptions<T>): CubeTableColumnLayout<T> {\n return useMemo(() => {\n const visible = [\n ...(leadingColumns ?? []),\n ...columns,\n ...(trailingColumns ?? []),\n ].filter((column) => !column.isHidden);\n\n // Pinned columns lead and trail regardless of their position in the source\n // array, so `aria-colindex` and DOM order agree and nothing needs CSS\n // `order:` to be reshuffled.\n const ordered = [\n ...visible.filter((c) => c.pin === 'start'),\n ...visible.filter((c) => !c.pin),\n ...visible.filter((c) => c.pin === 'end'),\n ];\n\n const structuralKeys = new Set(\n [...(leadingColumns ?? []), ...(trailingColumns ?? [])].map((c) => c.key),\n );\n\n const specs = ordered.map((column) => {\n const isStructural = structuralKeys.has(column.key);\n const explicit = columnWidths?.[column.key] ?? column.width;\n const minWidth =\n column.minWidth ??\n (explicit != null ? explicit : isStructural ? 0 : DEFAULT_MIN_WIDTH);\n\n return {\n column,\n isStructural,\n fixed: explicit ?? null,\n minWidth,\n maxWidth: column.maxWidth ?? null,\n flex: explicit != null ? null : column.flex ?? 1,\n };\n });\n\n const resolved = new Map<string, number>();\n let isOverflowing = false;\n\n if (containerWidth != null && containerWidth > 0) {\n const fixedTotal = specs.reduce((sum, s) => sum + (s.fixed ?? 0), 0);\n const flexSpecs = specs.filter((s) => s.fixed == null);\n const minTotal = specs.reduce(\n (sum, s) => sum + (s.fixed ?? s.minWidth),\n 0,\n );\n\n if (minTotal > containerWidth) {\n isOverflowing = true;\n for (const spec of specs) {\n resolved.set(spec.column.key, spec.fixed ?? spec.minWidth);\n }\n } else {\n let remaining = containerWidth - fixedTotal;\n let pool = flexSpecs;\n\n // Each pass assigns proportional widths, freezes whatever hit a bound,\n // and re-splits the leftover among the rest.\n while (pool.length > 0) {\n const totalFlex = pool.reduce((sum, s) => sum + (s.flex ?? 1), 0);\n const nextPool: typeof pool = [];\n let consumed = 0;\n\n for (const spec of pool) {\n const ideal = (remaining * (spec.flex ?? 1)) / (totalFlex || 1);\n const clamped = clamp(ideal, spec.minWidth, spec.maxWidth);\n\n if (clamped !== ideal) {\n resolved.set(spec.column.key, clamped);\n consumed += clamped;\n } else {\n nextPool.push(spec);\n }\n }\n\n if (nextPool.length === pool.length) {\n // Nothing was clamped this pass — the proportional split stands.\n const totalLeft = nextPool.reduce(\n (sum, s) => sum + (s.flex ?? 1),\n 0,\n );\n for (const spec of nextPool) {\n resolved.set(\n spec.column.key,\n (remaining * (spec.flex ?? 1)) / (totalLeft || 1),\n );\n }\n break;\n }\n\n remaining -= consumed;\n pool = nextPool;\n }\n\n for (const spec of specs) {\n if (spec.fixed != null) resolved.set(spec.column.key, spec.fixed);\n }\n }\n }\n\n let pinnedStartWidth = 0;\n let pinnedEndWidth = 0;\n\n const out: CubeResolvedColumn<T>[] = specs.map((spec, index) => ({\n ...spec.column,\n index,\n ariaColIndex: index + 1,\n width: resolved.get(spec.column.key) ?? null,\n minWidth: spec.minWidth,\n maxWidth: spec.maxWidth,\n flex: spec.flex,\n align: spec.column.align ?? 'start',\n pinOffset: null,\n isPinEdge: false,\n isStructural: spec.isStructural,\n }));\n\n // Sticky offsets accumulate inwards from each edge.\n for (const column of out) {\n if (column.pin !== 'start') continue;\n column.pinOffset = pinnedStartWidth;\n pinnedStartWidth += column.width ?? column.minWidth;\n }\n\n for (let i = out.length - 1; i >= 0; i--) {\n const column = out[i];\n if (column.pin !== 'end') continue;\n column.pinOffset = pinnedEndWidth;\n pinnedEndWidth += column.width ?? column.minWidth;\n }\n\n const lastPinnedStart = out.filter((c) => c.pin === 'start').at(-1);\n const firstPinnedEnd = out.find((c) => c.pin === 'end');\n\n if (lastPinnedStart) lastPinnedStart.isPinEdge = true;\n if (firstPinnedEnd) firstPinnedEnd.isPinEdge = true;\n\n const totalWidth = out.every((c) => c.width != null)\n ? out.reduce((sum, c) => sum + (c.width ?? 0), 0)\n : null;\n\n return {\n columns: out,\n pinnedStartWidth,\n pinnedEndWidth,\n totalWidth,\n isOverflowing,\n };\n }, [columns, containerWidth, columnWidths, leadingColumns, trailingColumns]);\n}\n"],"mappings":";;;;;AASA,MAAa,oBAAoB;;;;;AAMjC,SAAgB,SAAS,KAAU,MAAuB;AACxD,KAAI,OAAO,KAAM,QAAO;AACxB,KAAI,CAAC,KAAK,SAAS,IAAI,CAAE,QAAO,IAAI;CAEpC,IAAI,UAAe;AAEnB,MAAK,MAAM,QAAQ,KAAK,MAAM,IAAI,EAAE;AAClC,MAAI,WAAW,KAAM,QAAO;AAC5B,YAAU,QAAQ;;AAGpB,QAAO;;AAMT,SAAgB,eACd,QACA,KACA,UACS;AACT,QAAO,O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,YAAO;;AAGT,SAAK,MAAM,QAAQ,MACjB,KAAI,KAAK,SAAS,KAAM,UAAS,IAAI,KAAK,OAAO,KAAK,KAAK,MAAM;;;EAKvE,IAAI,mBAAmB;EACvB,IAAI,iBAAiB;EAErB,MAAM,MAA+B,MAAM,KAAK,MAAM,WAAW;GAC/D,GAAG,KAAK;GACR;GACA,cAAc,QAAQ;GACtB,OAAO,SAAS,IAAI,KAAK,OAAO,IAAI,IAAI;GACxC,UAAU,KAAK;GACf,UAAU,KAAK;GACf,MAAM,KAAK;GACX,OAAO,KAAK,OAAO,SAAS;GAC5B,WAAW;GACX,WAAW;GACX,cAAc,KAAK;GACpB,EAAE;AAGH,OAAK,MAAM,UAAU,KAAK;AACxB,OAAI,OAAO,QAAQ,QAAS;AAC5B,UAAO,YAAY;AACnB,uBAAoB,OAAO,SAAS,OAAO;;AAG7C,OAAK,IAAI,IAAI,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK;GACxC,MAAM,SAAS,IAAI;AACnB,OAAI,OAAO,QAAQ,MAAO;AAC1B,UAAO,YAAY;AACnB,qBAAkB,OAAO,SAAS,OAAO;;EAG3C,MAAM,kBAAkB,IAAI,QAAQ,MAAM,EAAE,QAAQ,QAAQ,CAAC,GAAG,GAAG;EACnE,MAAM,iBAAiB,IAAI,MAAM,MAAM,EAAE,QAAQ,MAAM;AAEvD,MAAI,gBAAiB,iBAAgB,YAAY;AACjD,MAAI,eAAgB,gBAAe,YAAY;EAE/C,MAAM,aAAa,IAAI,OAAO,MAAM,EAAE,SAAS,KAAK,GAChD,IAAI,QAAQ,KAAK,MAAM,OAAO,EAAE,SAAS,IAAI,EAAE,GAC/C;AAEJ,SAAO;GACL,SAAS;GACT;GACA;GACA;GACA;GACD;IACA;EAAC;EAAS;EAAgB;EAAc;EAAgB;EAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"use-table-columns.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-columns.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport type {\n CubeResolvedColumn,\n CubeTableColumn,\n CubeTableColumnLayout,\n} from './types';\n\n/** @default when a column declares neither `width` nor `minWidth`. */\nexport const DEFAULT_MIN_WIDTH = 150;\n\n/**\n * Every column's current width, so a resize can change exactly one of them.\n *\n * A column with no explicit width is `flex: 1` and shares the leftover (see the\n * spec builder below). Making only the DRAGGED column fixed leaves every other\n * one in the flex pool, re-splitting a leftover that just changed — so one\n * divider moved all of them, including columns to the LEFT of the handle, which\n * cannot be what dragging a right edge means. Measured before this existed:\n * dragging column B by +8px took 3px off A, C and D each.\n *\n * Freezing first means a drag changes one width. Columns after it are pushed\n * along, which is what being after it means, and the table grows or shrinks\n * rather than the neighbours absorbing the difference.\n *\n * Structural columns are skipped — they are sized by the table, not the user.\n */\nexport function freezeColumnWidths<T>(\n layout: CubeTableColumnLayout<T> | null,\n base: Record<string, number>,\n): Record<string, number> {\n return (layout?.columns ?? []).reduce<Record<string, number>>(\n (widths, column) => {\n if (!column.isStructural && column.width != null) {\n widths[column.key] = Math.round(column.width);\n }\n\n return widths;\n },\n { ...base },\n );\n}\n\n/**\n * Reads `key` as a data path. A plain key is a single property lookup; dots\n * walk nested objects (`'owner.name'`). Anything richer belongs in `getValue`.\n */\nexport function readPath(row: any, path: string): unknown {\n if (row == null) return undefined;\n if (!path.includes('.')) return row[path];\n\n let current: any = row;\n\n for (const part of path.split('.')) {\n if (current == null) return undefined;\n current = current[part];\n }\n\n return current;\n}\n\n/** Only the value-pipeline members, so both raw and resolved columns fit. */\ntype ValueColumn<T> = Pick<CubeTableColumn<T>, 'key' | 'getValue' | 'format'>;\n\nexport function getColumnValue<T>(\n column: ValueColumn<T>,\n row: T,\n rowIndex: number,\n): unknown {\n return column.getValue\n ? column.getValue(row, rowIndex)\n : readPath(row, column.key);\n}\n\n/**\n * Display text for a cell — what client sort, client search and TSV copy all\n * operate on. Deliberately NOT the rendered output: `render` may return\n * arbitrary React, and stringifying that is how cloud's filter ended up\n * matching `\"[object Object]\"` against the query `\"object\"`.\n *\n * Returns `null` when the column cannot produce text, so callers can skip it\n * rather than coerce a non-primitive.\n */\nexport function getColumnText<T>(\n column: ValueColumn<T>,\n row: T,\n rowIndex: number,\n): string | null {\n const value = getColumnValue(column, row, rowIndex);\n\n if (column.format) return column.format(value, row, rowIndex);\n if (value == null) return '';\n\n const type = typeof value;\n\n if (type === 'string') return value as string;\n if (type === 'number' || type === 'boolean' || type === 'bigint') {\n return String(value);\n }\n if (value instanceof Date) return value.toISOString();\n\n return null;\n}\n\nfunction clamp(value: number, min: number, max: number | null): number {\n return Math.min(Math.max(value, min), max ?? Number.POSITIVE_INFINITY);\n}\n\nexport interface UseTableColumnsOptions<T> {\n columns: CubeTableColumn<T>[];\n /** Content-box width of the scroller, or `null` before the first measure. */\n containerWidth: number | null;\n /** User-resized widths, keyed by column key. Wins over `column.width`. */\n columnWidths?: Record<string, number>;\n /** Extra leading columns owned by the table (selection, drag handle). */\n leadingColumns?: CubeTableColumn<T>[];\n /** Extra trailing columns owned by the table (row menu). */\n trailingColumns?: CubeTableColumn<T>[];\n}\n\n/**\n * Normalizes the public column list into resolved leaves: visual order, ARIA\n * indices, pixel widths, and sticky offsets for pinned columns.\n *\n * Width resolution mirrors ag-grid's `fitGridWidth`: fixed columns take their\n * width, the remainder is split across flex columns by weight, and each result\n * is clamped to `[minWidth, maxWidth]`. Clamping perturbs the sum, so the\n * residual is redistributed across the still-unclamped columns until it\n * settles. When even the minimums do not fit, every column takes its minimum\n * and the table scrolls horizontally.\n */\nexport function useTableColumns<T>({\n columns,\n containerWidth,\n columnWidths,\n leadingColumns,\n trailingColumns,\n}: UseTableColumnsOptions<T>): CubeTableColumnLayout<T> {\n return useMemo(() => {\n const visible = [\n ...(leadingColumns ?? []),\n ...columns,\n ...(trailingColumns ?? []),\n ].filter((column) => !column.isHidden);\n\n // Pinned columns lead and trail regardless of their position in the source\n // array, so `aria-colindex` and DOM order agree and nothing needs CSS\n // `order:` to be reshuffled.\n const ordered = [\n ...visible.filter((c) => c.pin === 'start'),\n ...visible.filter((c) => !c.pin),\n ...visible.filter((c) => c.pin === 'end'),\n ];\n\n const structuralKeys = new Set(\n [...(leadingColumns ?? []), ...(trailingColumns ?? [])].map((c) => c.key),\n );\n\n const specs = ordered.map((column) => {\n const isStructural = structuralKeys.has(column.key);\n const explicit = columnWidths?.[column.key] ?? column.width;\n const minWidth =\n column.minWidth ??\n (explicit != null ? explicit : isStructural ? 0 : DEFAULT_MIN_WIDTH);\n\n return {\n column,\n isStructural,\n fixed: explicit ?? null,\n minWidth,\n maxWidth: column.maxWidth ?? null,\n flex: explicit != null ? null : column.flex ?? 1,\n };\n });\n\n const resolved = new Map<string, number>();\n let isOverflowing = false;\n\n if (containerWidth != null && containerWidth > 0) {\n const fixedTotal = specs.reduce((sum, s) => sum + (s.fixed ?? 0), 0);\n const flexSpecs = specs.filter((s) => s.fixed == null);\n const minTotal = specs.reduce(\n (sum, s) => sum + (s.fixed ?? s.minWidth),\n 0,\n );\n\n if (minTotal > containerWidth) {\n isOverflowing = true;\n for (const spec of specs) {\n resolved.set(spec.column.key, spec.fixed ?? spec.minWidth);\n }\n } else {\n let remaining = containerWidth - fixedTotal;\n let pool = flexSpecs;\n\n // Each pass assigns proportional widths, freezes whatever hit a bound,\n // and re-splits the leftover among the rest.\n while (pool.length > 0) {\n const totalFlex = pool.reduce((sum, s) => sum + (s.flex ?? 1), 0);\n const nextPool: typeof pool = [];\n let consumed = 0;\n\n for (const spec of pool) {\n const ideal = (remaining * (spec.flex ?? 1)) / (totalFlex || 1);\n const clamped = clamp(ideal, spec.minWidth, spec.maxWidth);\n\n if (clamped !== ideal) {\n resolved.set(spec.column.key, clamped);\n consumed += clamped;\n } else {\n nextPool.push(spec);\n }\n }\n\n if (nextPool.length === pool.length) {\n // Nothing was clamped this pass — the proportional split stands.\n const totalLeft = nextPool.reduce(\n (sum, s) => sum + (s.flex ?? 1),\n 0,\n );\n for (const spec of nextPool) {\n resolved.set(\n spec.column.key,\n (remaining * (spec.flex ?? 1)) / (totalLeft || 1),\n );\n }\n break;\n }\n\n remaining -= consumed;\n pool = nextPool;\n }\n\n for (const spec of specs) {\n if (spec.fixed != null) resolved.set(spec.column.key, spec.fixed);\n }\n }\n }\n\n let pinnedStartWidth = 0;\n let pinnedEndWidth = 0;\n\n const out: CubeResolvedColumn<T>[] = specs.map((spec, index) => ({\n ...spec.column,\n index,\n ariaColIndex: index + 1,\n width: resolved.get(spec.column.key) ?? null,\n minWidth: spec.minWidth,\n maxWidth: spec.maxWidth,\n flex: spec.flex,\n align: spec.column.align ?? 'start',\n pinOffset: null,\n isPinEdge: false,\n isStructural: spec.isStructural,\n }));\n\n // Sticky offsets accumulate inwards from each edge.\n for (const column of out) {\n if (column.pin !== 'start') continue;\n column.pinOffset = pinnedStartWidth;\n pinnedStartWidth += column.width ?? column.minWidth;\n }\n\n for (let i = out.length - 1; i >= 0; i--) {\n const column = out[i];\n if (column.pin !== 'end') continue;\n column.pinOffset = pinnedEndWidth;\n pinnedEndWidth += column.width ?? column.minWidth;\n }\n\n const lastPinnedStart = out.filter((c) => c.pin === 'start').at(-1);\n const firstPinnedEnd = out.find((c) => c.pin === 'end');\n\n if (lastPinnedStart) lastPinnedStart.isPinEdge = true;\n if (firstPinnedEnd) firstPinnedEnd.isPinEdge = true;\n\n const totalWidth = out.every((c) => c.width != null)\n ? out.reduce((sum, c) => sum + (c.width ?? 0), 0)\n : null;\n\n return {\n columns: out,\n pinnedStartWidth,\n pinnedEndWidth,\n totalWidth,\n isOverflowing,\n };\n }, [columns, containerWidth, columnWidths, leadingColumns, trailingColumns]);\n}\n"],"mappings":";;;;;AASA,MAAa,oBAAoB;;;;;;;;;;;;;;;;;AAkBjC,SAAgB,mBACd,QACA,MACwB;AACxB,SAAQ,QAAQ,WAAW,EAAE,EAAE,QAC5B,QAAQ,WAAW;AAClB,MAAI,CAAC,OAAO,gBAAgB,OAAO,SAAS,KAC1C,QAAO,OAAO,OAAO,KAAK,MAAM,OAA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D,MAAI,eAAgB,gBAAe,YAAY;EAE/C,MAAM,aAAa,IAAI,OAAO,MAAM,EAAE,SAAS,KAAK,GAChD,IAAI,QAAQ,KAAK,MAAM,OAAO,EAAE,SAAS,IAAI,EAAE,GAC/C;AAEJ,SAAO;GACL,SAAS;GACT;GACA;GACA;GACA;GACD;IACA;EAAC;EAAS;EAAgB;EAAc;EAAgB;EAAgB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
3
3
|
import { useDebouncedValue } from "../../../_internal/hooks/use-debounced-value.js";
|
|
4
4
|
import { getColumnText } from "./use-table-columns.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
3
3
|
import { RowCollection } from "./RowCollection.js";
|
|
4
4
|
import { useCallback, useMemo, useRef } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
3
3
|
import { getColumnText, getColumnValue } from "./use-table-columns.js";
|
|
4
4
|
import { useMemo } from "react";
|
|
@@ -45,6 +45,24 @@ function useTableSort({ columns, rows, mode, sort: sortProp, defaultSort, onSort
|
|
|
45
45
|
direction: "asc"
|
|
46
46
|
} : null);
|
|
47
47
|
});
|
|
48
|
+
/**
|
|
49
|
+
* Set the column's direction outright instead of advancing the cycle — see
|
|
50
|
+
* `use-table-sorts.ts` for why the column menu cannot reuse `toggleSort`.
|
|
51
|
+
*/
|
|
52
|
+
const setColumnSort = useEvent((columnKey, direction) => {
|
|
53
|
+
const column = columns.find((entry) => entry.key === columnKey);
|
|
54
|
+
if (!column || !isSortable(column)) return;
|
|
55
|
+
if (direction == null) {
|
|
56
|
+
if (sort?.columnKey !== columnKey || column.disallowSortRemoval) return;
|
|
57
|
+
setSort(null);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (sort?.columnKey === columnKey && sort.direction === direction) return;
|
|
61
|
+
setSort({
|
|
62
|
+
columnKey,
|
|
63
|
+
direction
|
|
64
|
+
});
|
|
65
|
+
});
|
|
48
66
|
return {
|
|
49
67
|
sort,
|
|
50
68
|
sortedRows: useMemo(() => {
|
|
@@ -67,6 +85,7 @@ function useTableSort({ columns, rows, mode, sort: sortProp, defaultSort, onSort
|
|
|
67
85
|
collator
|
|
68
86
|
]),
|
|
69
87
|
toggleSort,
|
|
88
|
+
setColumnSort,
|
|
70
89
|
isSortable,
|
|
71
90
|
mode: resolvedMode
|
|
72
91
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-sort.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-sort.ts"],"sourcesContent":["import { useControlledState } from '@react-stately/utils';\nimport { useMemo } from 'react';\nimport { useCollator } from 'react-aria';\n\nimport { useEvent } from '../../../_internal/hooks';\n\nimport { getColumnText, getColumnValue } from './use-table-columns';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"use-table-sort.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-sort.ts"],"sourcesContent":["import { useControlledState } from '@react-stately/utils';\nimport { useMemo } from 'react';\nimport { useCollator } from 'react-aria';\n\nimport { useEvent } from '../../../_internal/hooks';\n\nimport { getColumnText, getColumnValue } from './use-table-columns';\n\nimport type {\n CubeTableColumn,\n CubeTableSort,\n CubeTableSortDirection,\n} from './types';\n\nexport type CubeTableSortMode = 'client' | 'server' | 'off';\n\nexport interface UseTableSortOptions<T> {\n columns: CubeTableColumn<T>[];\n rows: readonly T[];\n /** @default 'client' when any column is sortable, else 'off' */\n mode?: CubeTableSortMode;\n sort?: CubeTableSort | null;\n defaultSort?: CubeTableSort | null;\n onSortChange?: (sort: CubeTableSort | null) => void;\n}\n\nexport interface UseTableSortResult<T> {\n sort: CubeTableSort | null;\n /** `rows` reordered in client mode; the original array otherwise. */\n sortedRows: readonly T[];\n /** Advances a column through the sort cycle. */\n toggleSort: (columnKey: string) => void;\n /**\n * Sets a column's direction outright. `null` clears it.\n *\n * For the column menu's reserved sort keys, which have to reach a specific\n * direction in one step rather than cycling to it.\n */\n setColumnSort: (\n columnKey: string,\n direction: CubeTableSortDirection | null,\n ) => void;\n isSortable: (column: CubeTableColumn<T>) => boolean;\n /**\n * The mode after defaulting. The renderer needs this exact answer to decide\n * whether a header is clickable, and deriving it a second time at the call\n * site is how `DataTable` ended up sorting on `defaultSorts` but ignoring\n * every click.\n */\n mode: CubeTableSortMode;\n}\n\n/**\n * Sort state plus, in client mode, the reordered rows.\n *\n * The cycle is tri-state — `asc → desc → unsorted` — matching ag-grid's default\n * `sortingOrder`, because losing the ability to get back to the source order is\n * a real loss when the source order is meaningful. `disallowSortRemoval` on a\n * column reduces it to `asc ↔ desc`.\n */\nexport function useTableSort<T>({\n columns,\n rows,\n mode,\n sort: sortProp,\n defaultSort,\n onSortChange,\n}: UseTableSortOptions<T>): UseTableSortResult<T> {\n // A collator gives locale-correct, case-insensitive ordering — \"Ä\" sorts next\n // to \"A\" rather than after \"Z\", which a raw `<` comparison gets wrong.\n const collator = useCollator({ numeric: true, sensitivity: 'base' });\n\n const [sort, setSort] = useControlledState<CubeTableSort | null>(\n sortProp as CubeTableSort | null,\n defaultSort ?? null,\n onSortChange as (value: CubeTableSort | null) => void,\n );\n\n const hasSortableColumn = columns.some((column) => column.isSortable);\n const resolvedMode: CubeTableSortMode =\n mode ?? (hasSortableColumn ? 'client' : 'off');\n\n const isSortable = useEvent(\n (column: CubeTableColumn<T>) =>\n resolvedMode !== 'off' && column.isSortable === true,\n );\n\n const toggleSort = useEvent((columnKey: string) => {\n const column = columns.find((entry) => entry.key === columnKey);\n\n if (!column || !isSortable(column)) return;\n\n if (sort?.columnKey !== columnKey) {\n setSort({ columnKey, direction: 'asc' });\n\n return;\n }\n\n if (sort.direction === 'asc') {\n setSort({ columnKey, direction: 'desc' });\n\n return;\n }\n\n setSort(\n column.disallowSortRemoval ? { columnKey, direction: 'asc' } : null,\n );\n });\n\n /**\n * Set the column's direction outright instead of advancing the cycle — see\n * `use-table-sorts.ts` for why the column menu cannot reuse `toggleSort`.\n */\n const setColumnSort = useEvent(\n (columnKey: string, direction: CubeTableSortDirection | null) => {\n const column = columns.find((entry) => entry.key === columnKey);\n\n if (!column || !isSortable(column)) return;\n\n if (direction == null) {\n // Clearing a column that is not the sorted one is a no-op rather than a\n // reset, and `disallowSortRemoval` refuses the clear outright.\n if (sort?.columnKey !== columnKey || column.disallowSortRemoval) return;\n\n setSort(null);\n\n return;\n }\n\n if (sort?.columnKey === columnKey && sort.direction === direction) return;\n\n setSort({ columnKey, direction });\n },\n );\n\n const sortedRows = useMemo(() => {\n if (resolvedMode !== 'client' || !sort) return rows;\n\n const column = columns.find((entry) => entry.key === sort.columnKey);\n\n if (!column) return rows;\n\n const direction = sort.direction === 'asc' ? 1 : -1;\n\n // `map`/`sort`/`map` rather than sorting in place: `rows` is the caller's\n // array and `Array.prototype.sort` mutates. Carrying the original index also\n // makes the sort stable across engines.\n return rows\n .map((row, index) => ({ row, index }))\n .sort((a, b) => {\n const result = compareByColumn(\n column,\n collator,\n a.row,\n a.index,\n b.row,\n b.index,\n );\n\n return result !== 0 ? result * direction : a.index - b.index;\n })\n .map((entry) => entry.row);\n }, [resolvedMode, sort, rows, columns, collator]);\n\n // The resolved mode is returned rather than left for the caller to derive\n // again: the renderer needs the same answer to decide whether a header is\n // clickable, and two independent derivations drift.\n return {\n sort,\n sortedRows,\n toggleSort,\n setColumnSort,\n isSortable,\n mode: resolvedMode,\n };\n}\n\nexport function compareByColumn<T>(\n column: CubeTableColumn<T>,\n collator: Intl.Collator,\n rowA: T,\n indexA: number,\n rowB: T,\n indexB: number,\n): number {\n const valueA = getColumnValue(column, rowA, indexA);\n const valueB = getColumnValue(column, rowB, indexB);\n\n if (column.compare) return column.compare(valueA, valueB, rowA, rowB);\n\n // Nullish always sorts first, then gets flipped with the direction. Mixing\n // them into the value comparison instead produces an unstable order.\n if (valueA == null && valueB == null) return 0;\n if (valueA == null) return -1;\n if (valueB == null) return 1;\n\n if (typeof valueA === 'number' && typeof valueB === 'number') {\n return valueA - valueB;\n }\n if (typeof valueA === 'boolean' && typeof valueB === 'boolean') {\n return Number(valueA) - Number(valueB);\n }\n if (valueA instanceof Date && valueB instanceof Date) {\n return valueA.getTime() - valueB.getTime();\n }\n\n // Fall back to display text, so a column with a `format` sorts the way it\n // reads rather than the way it is stored.\n const textA = getColumnText(column, rowA, indexA) ?? String(valueA);\n const textB = getColumnText(column, rowB, indexB) ?? String(valueB);\n\n return collator.compare(textA, textB);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4DA,SAAgB,aAAgB,EAC9B,SACA,MACA,MACA,MAAM,UACN,aACA,gBACgD;CAGhD,MAAM,WAAW,YAAY;EAAE,SAAS;EAAM,aAAa;EAAQ,CAAC;CAEpE,MAAM,CAAC,MAAM,WAAW,mBACtB,UACA,eAAe,MACf,aACD;CAED,MAAM,oBAAoB,QAAQ,MAAM,WAAW,OAAO,WAAW;CACrE,MAAM,eACJ,SAAS,oBAAoB,WAAW;CAE1C,MAAM,aAAa,UAChB,WACC,iBAAiB,SAAS,OAAO,eAAe,KACnD;CAED,MAAM,aAAa,UAAU,cAAsB;EACjD,MAAM,SAAS,QAAQ,MAAM,UAAU,MAAM,QAAQ,UAAU;AAE/D,MAAI,CAAC,UAAU,CAAC,WAAW,OAAO,CAAE;AAEpC,MAAI,MAAM,cAAc,WAAW;AACjC,WAAQ;IAAE;IAAW,WAAW;IAAO,CAAC;AAExC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Q,QAAQ,QAAQ,MAAM,KAAK;AAIrE,KAAI,UAAU,QAAQ,UAAU,KAAM,QAAO;AAC7C,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,UAAU,KAAM,QAAO;AAE3B,KAAI,OAAO,WAAW,YAAY,OAAO,WAAW,SAClD,QAAO,SAAS;AAElB,KAAI,OAAO,WAAW,aAAa,OAAO,WAAW,UACnD,QAAO,OAAO,OAAO,GAAG,OAAO,OAAO;AAExC,KAAI,kBAAkB,QAAQ,kBAAkB,KAC9C,QAAO,OAAO,SAAS,GAAG,OAAO,SAAS;CAK5C,MAAM,QAAQ,cAAc,QAAQ,MAAM,OAAO,IAAI,OAAO,OAAO;CACnE,MAAM,QAAQ,cAAc,QAAQ,MAAM,OAAO,IAAI,OAAO,OAAO;AAEnE,QAAO,SAAS,QAAQ,OAAO,MAAM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
3
3
|
import { compareByColumn } from "./use-table-sort.js";
|
|
4
4
|
import { useMemo } from "react";
|
|
@@ -59,6 +59,44 @@ function useTableSorts({ columns, rows, mode, sorts: sortsProp, defaultSorts, on
|
|
|
59
59
|
next.splice(index, 1);
|
|
60
60
|
setSorts(next);
|
|
61
61
|
});
|
|
62
|
+
/**
|
|
63
|
+
* Set one column's direction outright instead of advancing the cycle.
|
|
64
|
+
*
|
|
65
|
+
* The column menu's `sort-desc` has to reach `desc` in one step. Reaching it
|
|
66
|
+
* by calling `toggleSort` twice cannot work here: under `disallowSortRemoval`
|
|
67
|
+
* the cycle never leaves `asc`/`desc`, and a column that was unsorted would
|
|
68
|
+
* be appended and then re-read, so every intermediate state is observable.
|
|
69
|
+
*
|
|
70
|
+
* Precedence is preserved — an already-sorted column keeps its slot, and a
|
|
71
|
+
* newly sorted one is appended as the least significant, the same rule
|
|
72
|
+
* `toggleSort` follows.
|
|
73
|
+
*/
|
|
74
|
+
const setColumnSort = useEvent((columnKey, direction) => {
|
|
75
|
+
const column = columns.find((entry) => entry.key === columnKey);
|
|
76
|
+
if (!column || !isSortable(column)) return;
|
|
77
|
+
const index = sorts.findIndex((entry) => entry.columnKey === columnKey);
|
|
78
|
+
if (direction == null) {
|
|
79
|
+
if (index === -1 || column.disallowSortRemoval) return;
|
|
80
|
+
const next = [...sorts];
|
|
81
|
+
next.splice(index, 1);
|
|
82
|
+
setSorts(next);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (index === -1) {
|
|
86
|
+
setSorts([...sorts, {
|
|
87
|
+
columnKey,
|
|
88
|
+
direction
|
|
89
|
+
}]);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (sorts[index].direction === direction) return;
|
|
93
|
+
const next = [...sorts];
|
|
94
|
+
next[index] = {
|
|
95
|
+
columnKey,
|
|
96
|
+
direction
|
|
97
|
+
};
|
|
98
|
+
setSorts(next);
|
|
99
|
+
});
|
|
62
100
|
return {
|
|
63
101
|
sorts,
|
|
64
102
|
sortedRows: useMemo(() => {
|
|
@@ -86,6 +124,7 @@ function useTableSorts({ columns, rows, mode, sorts: sortsProp, defaultSorts, on
|
|
|
86
124
|
collator
|
|
87
125
|
]),
|
|
88
126
|
toggleSort,
|
|
127
|
+
setColumnSort,
|
|
89
128
|
isSortable,
|
|
90
129
|
sortRank: useEvent((columnKey) => sorts.findIndex((entry) => entry.columnKey === columnKey) + 1),
|
|
91
130
|
mode: resolvedMode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-sorts.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-sorts.ts"],"sourcesContent":["import { useCollator } from '@react-aria/i18n';\nimport { useControlledState } from '@react-stately/utils';\nimport { useMemo } from 'react';\n\nimport { useEvent } from '../../../_internal/hooks';\n\nimport { compareByColumn } from './use-table-sort';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"use-table-sorts.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-sorts.ts"],"sourcesContent":["import { useCollator } from '@react-aria/i18n';\nimport { useControlledState } from '@react-stately/utils';\nimport { useMemo } from 'react';\n\nimport { useEvent } from '../../../_internal/hooks';\n\nimport { compareByColumn } from './use-table-sort';\n\nimport type {\n CubeTableColumn,\n CubeTableSort,\n CubeTableSortDirection,\n} from './types';\n\nexport interface UseTableSortsOptions<T> {\n columns: CubeTableColumn<T>[];\n rows: readonly T[];\n mode?: 'client' | 'server' | 'off';\n sorts?: CubeTableSort[];\n defaultSorts?: CubeTableSort[];\n onSortsChange?: (sorts: CubeTableSort[]) => void;\n}\n\nconst EMPTY: CubeTableSort[] = [];\n\n/**\n * Multi-column sorting.\n *\n * `ItemTable` sorts by one column, which is right for a list. An analytical\n * grid is routinely ordered by one dimension and then another, and Cloud's\n * reports send an array of sorts to the query — so the order of the array is\n * the sort precedence, and it has to survive round-tripping.\n *\n * Clicking a header cycles that column `asc → desc → off` exactly as the single\n * version does; the difference is that it edits its entry in place rather than\n * replacing the whole sort, so the other columns keep their precedence.\n */\nexport function useTableSorts<T>({\n columns,\n rows,\n mode,\n sorts: sortsProp,\n defaultSorts,\n onSortsChange,\n}: UseTableSortsOptions<T>) {\n const collator = useCollator({ numeric: true, sensitivity: 'base' });\n\n const [sorts, setSorts] = useControlledState<CubeTableSort[]>(\n sortsProp as CubeTableSort[],\n defaultSorts ?? EMPTY,\n onSortsChange as (value: CubeTableSort[]) => void,\n );\n\n const hasSortableColumn = columns.some((column) => column.isSortable);\n const resolvedMode = mode ?? (hasSortableColumn ? 'client' : 'off');\n\n const isSortable = useEvent(\n (column: CubeTableColumn<T>) =>\n resolvedMode !== 'off' && column.isSortable === true,\n );\n\n const toggleSort = useEvent((columnKey: string) => {\n const column = columns.find((entry) => entry.key === columnKey);\n\n if (!column || !isSortable(column)) return;\n\n const index = sorts.findIndex((entry) => entry.columnKey === columnKey);\n\n if (index === -1) {\n // Appended, not prepended: a newly sorted column is the least\n // significant, so the ordering the user already established still leads.\n setSorts([...sorts, { columnKey, direction: 'asc' }]);\n\n return;\n }\n\n const next = [...sorts];\n\n if (next[index].direction === 'asc') {\n next[index] = { columnKey, direction: 'desc' };\n setSorts(next);\n\n return;\n }\n\n if (column.disallowSortRemoval) {\n next[index] = { columnKey, direction: 'asc' };\n setSorts(next);\n\n return;\n }\n\n next.splice(index, 1);\n setSorts(next);\n });\n\n /**\n * Set one column's direction outright instead of advancing the cycle.\n *\n * The column menu's `sort-desc` has to reach `desc` in one step. Reaching it\n * by calling `toggleSort` twice cannot work here: under `disallowSortRemoval`\n * the cycle never leaves `asc`/`desc`, and a column that was unsorted would\n * be appended and then re-read, so every intermediate state is observable.\n *\n * Precedence is preserved — an already-sorted column keeps its slot, and a\n * newly sorted one is appended as the least significant, the same rule\n * `toggleSort` follows.\n */\n const setColumnSort = useEvent(\n (columnKey: string, direction: CubeTableSortDirection | null) => {\n const column = columns.find((entry) => entry.key === columnKey);\n\n if (!column || !isSortable(column)) return;\n\n const index = sorts.findIndex((entry) => entry.columnKey === columnKey);\n\n if (direction == null) {\n // `disallowSortRemoval` means the column is never *left* unsorted, so an\n // explicit clear is refused too rather than quietly re-sorting.\n if (index === -1 || column.disallowSortRemoval) return;\n\n const next = [...sorts];\n\n next.splice(index, 1);\n setSorts(next);\n\n return;\n }\n\n if (index === -1) {\n setSorts([...sorts, { columnKey, direction }]);\n\n return;\n }\n\n if (sorts[index].direction === direction) return;\n\n const next = [...sorts];\n\n next[index] = { columnKey, direction };\n setSorts(next);\n },\n );\n\n const sortedRows = useMemo(() => {\n if (resolvedMode !== 'client' || !sorts.length) return rows;\n\n const active = sorts\n .map((sort) => ({\n sort,\n column: columns.find((entry) => entry.key === sort.columnKey),\n }))\n .filter(\n (entry): entry is { sort: CubeTableSort; column: CubeTableColumn<T> } =>\n entry.column != null,\n );\n\n if (!active.length) return rows;\n\n // Not sorted in place: `rows` belongs to the caller and `sort` mutates.\n // The original index is carried so the result is stable when every sort\n // ties.\n return rows\n .map((row, index) => ({ row, index }))\n .sort((a, b) => {\n for (const { sort, column } of active) {\n const result = compareByColumn(\n column,\n collator,\n a.row,\n a.index,\n b.row,\n b.index,\n );\n\n if (result !== 0) {\n return result * (sort.direction === 'asc' ? 1 : -1);\n }\n }\n\n return a.index - b.index;\n })\n .map((entry) => entry.row);\n }, [resolvedMode, sorts, rows, columns, collator]);\n\n /** Where a column sits in the precedence, 1-based. `0` when unsorted. */\n const sortRank = useEvent(\n (columnKey: string) =>\n sorts.findIndex((entry) => entry.columnKey === columnKey) + 1,\n );\n\n // Returned for the same reason as the single-column hook: the renderer needs\n // this exact answer to decide whether a header is clickable.\n return {\n sorts,\n sortedRows,\n toggleSort,\n setColumnSort,\n isSortable,\n sortRank,\n mode: resolvedMode,\n };\n}\n"],"mappings":";;;;;;;;AAuBA,MAAM,QAAyB,EAAE;;;;;;;;;;;;;AAcjC,SAAgB,cAAiB,EAC/B,SACA,MACA,MACA,OAAO,WACP,cACA,iBAC0B;CAC1B,MAAM,WAAW,YAAY;EAAE,SAAS;EAAM,aAAa;EAAQ,CAAC;CAEpE,MAAM,CAAC,OAAO,YAAY,mBACxB,WACA,gBAAgB,OAChB,cACD;CAED,MAAM,oBAAoB,QAAQ,MAAM,WAAW,OAAO,WAAW;CACrE,MAAM,eAAe,SAAS,oBAAoB,WAAW;CAE7D,MAAM,aAAa,UAChB,WACC,iBAAiB,SAAS,OAAO,eAAe,KACnD;CAED,MAAM,aAAa,UAAU,cAAsB;EACjD,MAAM,SAAS,QAAQ,MAAM,UAAU,MAAM,QAAQ,UAAU;AAE/D,MAAI,CAAC,UAAU,CAAC,WAAW,OAAO,CAAE;EAEpC,MAAM,QAAQ,MAAM,WAAW,UAAU,MAAM,cAAc,UAAU;AAEvE,MAAI,UAAU,IAAI;AAGhB,YAAS,CAAC,GAAG,OAAO;IAAE;IAAW,WAAW;IAAO,CAAC,CAA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AO,EAAE,CACrC,MAAM,GAAG,MAAM;AACd,SAAK,MAAM,EAAE,MAAM,YAAY,QAAQ;KACrC,MAAM,SAAS,gBACb,QACA,UACA,EAAE,KACF,EAAE,OACF,EAAE,KACF,EAAE,MACH;AAED,SAAI,WAAW,EACb,QAAO,UAAU,KAAK,cAAc,QAAQ,IAAI;;AAIpD,WAAO,EAAE,QAAQ,EAAE;KACnB,CACD,KAAK,UAAU,MAAM,IAAI;KAC3B;GAAC;GAAc;GAAO;GAAM;GAAS;GAAS,CAAC;EAahD;EACA;EACA;EACA,UAbe,UACd,cACC,MAAM,WAAW,UAAU,MAAM,cAAc,UAAU,GAAG,EAC/D;EAWC,MAAM;EACP"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "./types.js";
|
|
3
3
|
|
|
4
4
|
//#region src/components/data/TableBase/use-table-storage.d.ts
|
|
5
|
-
type CubeTablePersistKey = 'pageSize' | 'columnWidths' | 'sort';
|
|
5
|
+
type CubeTablePersistKey = 'pageSize' | 'columnWidths' | 'columnOrder' | 'sort';
|
|
6
6
|
//#endregion
|
|
7
7
|
export { CubeTablePersistKey };
|
|
8
8
|
//# sourceMappingURL=use-table-storage.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { useCallback, useRef, useState } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/data/TableBase/use-table-storage.ts
|
|
@@ -8,7 +8,11 @@ import { useCallback, useRef, useState } from "react";
|
|
|
8
8
|
* cleared as a group later.
|
|
9
9
|
*/
|
|
10
10
|
const PREFIX = "cube-ui-kit:table:";
|
|
11
|
-
const DEFAULT_PERSIST_KEYS = [
|
|
11
|
+
const DEFAULT_PERSIST_KEYS = [
|
|
12
|
+
"pageSize",
|
|
13
|
+
"columnWidths",
|
|
14
|
+
"columnOrder"
|
|
15
|
+
];
|
|
12
16
|
function read(storageKey) {
|
|
13
17
|
if (!storageKey || typeof window === "undefined") return {};
|
|
14
18
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-storage.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-storage.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nimport type { CubeTableSort } from './types';\n\n/**\n * Namespaced so a `storageKey` cannot collide with whatever else the host app\n * keeps in `localStorage`, and so the kit's own stored shape can be migrated or\n * cleared as a group later.\n */\nconst PREFIX = 'cube-ui-kit:table:';\n\nexport type CubeTablePersistKey
|
|
1
|
+
{"version":3,"file":"use-table-storage.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-storage.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nimport type { CubeTableSort } from './types';\n\n/**\n * Namespaced so a `storageKey` cannot collide with whatever else the host app\n * keeps in `localStorage`, and so the kit's own stored shape can be migrated or\n * cleared as a group later.\n */\nconst PREFIX = 'cube-ui-kit:table:';\n\nexport type CubeTablePersistKey =\n | 'pageSize'\n | 'columnWidths'\n | 'columnOrder'\n | 'sort';\n\nexport interface CubeTableStoredState {\n pageSize?: number;\n sort?: CubeTableSort | null;\n columnWidths?: Record<string, number>;\n /** Every column key in order, including hidden and pinned ones. */\n columnOrder?: string[];\n}\n\nexport const DEFAULT_PERSIST_KEYS: CubeTablePersistKey[] = [\n 'pageSize',\n 'columnWidths',\n // A column layout the user arranged by hand is the same kind of state as the\n // widths they dragged — losing it on reload would be as surprising.\n 'columnOrder',\n];\n\nfunction read(storageKey: string | undefined): CubeTableStoredState {\n // No `storageKey` means the feature is off; no `window` means SSR. Both are\n // normal, not errors.\n if (!storageKey || typeof window === 'undefined') return {};\n\n try {\n const raw = window.localStorage.getItem(PREFIX + storageKey);\n\n if (!raw) return {};\n\n const parsed = JSON.parse(raw);\n\n // Anything could be under that key — a hand-edited value, a stale shape\n // from an older version. A non-object is simply ignored.\n return parsed && typeof parsed === 'object' ? parsed : {};\n } catch {\n // Private mode, a disabled store, or malformed JSON. Persistence is a\n // convenience; losing it must never take the table down with it.\n return {};\n }\n}\n\n/**\n * Persists the parts of the table's own state that a user expects to survive a\n * reload. Only state the table *owns* is stored: a controlled `pageSize` or\n * `sort` belongs to the page, so restoring it would fight the page's own source\n * of truth.\n *\n * Returns the state read at mount — a one-shot snapshot, deliberately, so a\n * second table sharing the key cannot yank this one's page size mid-session.\n */\nexport function useTableStorage(\n storageKey: string | undefined,\n persist: CubeTablePersistKey[] = DEFAULT_PERSIST_KEYS,\n) {\n const [initial] = useState(() => read(storageKey));\n const persistRef = useRef(persist);\n\n persistRef.current = persist;\n\n const write = useCallback(\n (patch: CubeTableStoredState) => {\n if (!storageKey || typeof window === 'undefined') return;\n\n const allowed = persistRef.current;\n const entries = Object.entries(patch).filter(([key]) =>\n allowed.includes(key as CubeTablePersistKey),\n );\n\n if (!entries.length) return;\n\n try {\n const next = {\n ...read(storageKey),\n ...Object.fromEntries(entries),\n };\n\n window.localStorage.setItem(PREFIX + storageKey, JSON.stringify(next));\n } catch {\n // Quota exceeded or a disabled store — nothing to do but carry on.\n }\n },\n [storageKey],\n );\n\n return {\n initial: storageKey ? initial : {},\n /** `true` when this key is persisted, so callers can skip the work. */\n has: (key: CubeTablePersistKey) => !!storageKey && persist.includes(key),\n write,\n };\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,SAAS;AAgBf,MAAa,uBAA8C;CACzD;CACA;CAGA;CACD;AAED,SAAS,KAAK,YAAsD;AAGlE,KAAI,CAAC,cAAc,OAAO,WAAW,YAAa,QAAO,EAAE;AAE3D,KAAI;EACF,MAAM,MAAM,OAAO,aAAa,QAAQ,SAAS,WAAW;AAE5D,MAAI,CAAC,IAAK,QAAO,EAAE;EAEnB,MAAM,SAAS,KAAK,MAAM,IAAI;AAI9B,SAAO,UAAU,OAAO,WAAW,WAAW,SAAS,EAAE;SACnD;AAGN,SAAO,EAAE;;;;;;;;;;;;AAab,SAAgB,gBACd,YACA,UAAiC,sBACjC;CACA,MAAM,CAAC,WAAW,eAAe,KAAK,WAAW,CAAC;CAClD,MAAM,aAAa,OAAO,QAAQ;AAElC,YAAW,UAAU;CAErB,MAAM,QAAQ,aACX,UAAgC;AAC/B,MAAI,CAAC,cAAc,OAAO,WAAW,YAAa;EAElD,MAAM,UAAU,WAAW;EAC3B,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,SAC7C,QAAQ,SAAS,IAA2B,CAC7C;AAED,MAAI,CAAC,QAAQ,OAAQ;AAErB,MAAI;GACF,MAAM,OAAO;IACX,GAAG,KAAK,WAAW;IACnB,GAAG,OAAO,YAAY,QAAQ;IAC/B;AAED,UAAO,aAAa,QAAQ,SAAS,YAAY,KAAK,UAAU,KAAK,CAAC;UAChE;IAIV,CAAC,WAAW,CACb;AAED,QAAO;EACL,SAAS,aAAa,UAAU,EAAE;EAElC,MAAM,QAA6B,CAAC,CAAC,cAAc,QAAQ,SAAS,IAAI;EACxE;EACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { CubeTableAlign, CubeTableCellContext, CubeTableColumn, CubeTableColumnHeader, CubeTableHeaderContext, CubeTableRowContext, CubeTableRowSection, CubeTableSort, CubeTableSortDirection } from "./TableBase/types.js";
|
|
2
|
+
import { CubeTableAlign, CubeTableCellContext, CubeTableColumn, CubeTableColumnHeader, CubeTableHeaderContext, CubeTableRowContext, CubeTableRowSection, CubeTableRowSize, CubeTableSort, CubeTableSortDirection } from "./TableBase/types.js";
|
|
3
3
|
import { CubeDataTableColumn, CubeDataTableProps } from "./DataTable/types.js";
|
|
4
4
|
import { _DataTable } from "./DataTable/DataTable.js";
|
|
5
5
|
import "./DataTable/index.js";
|
|
@@ -7,4 +7,5 @@ import { CubeTableRowRenderProps } from "./TableBase/TableView.js";
|
|
|
7
7
|
import { CubeItemTableColumn, CubeItemTableProps } from "./ItemTable/types.js";
|
|
8
8
|
import { _ItemTable } from "./ItemTable/ItemTable.js";
|
|
9
9
|
import "./ItemTable/index.js";
|
|
10
|
+
import { COLUMN_MENU_SORT_KEYS, CubeColumnMenuSortKey, columnSortMenu } from "./TableBase/column-menu.js";
|
|
10
11
|
import "./TableBase/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.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 { _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.159.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 { FormContext } from "../../form/Form/Form.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
4
4
|
import { ItemAction } from "../../actions/ItemAction/ItemAction.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.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.159.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 { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { useLayoutEffect as useLayoutEffect$1 } from "../../../utils/react/useLayoutEffect.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.159.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 { 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.159.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,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.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 { getValidationMods } from "../../form/validation/resolve-validation-props.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.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 { useI18n } from "../../../i18n/useI18n.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { ItemAction } from "../../actions/ItemAction/ItemAction.js";
|
|
3
3
|
import { CalendarIcon } from "../../../icons/CalendarIcon.js";
|
|
4
4
|
import { tasty } from "@tenphi/tasty";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { DatePickerSegment } from "./DatePickerSegment.js";
|
|
4
4
|
import { formatSegments } from "./utils.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.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 { Space } from "../../layout/Space.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.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 { useI18n } from "../../../i18n/useI18n.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.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,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.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,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.159.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.159.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";
|