@cube-dev/ui-kit 0.163.0 → 0.165.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/README.md +1 -1
- package/dist/CHANGELOG.md +394 -0
- package/dist/README.md +1 -1
- 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.d.ts +3 -2
- package/dist/components/Root.js +1 -1
- package/dist/components/Root.js.map +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +2 -5
- package/dist/components/actions/Banner/Banner.js.map +1 -1
- package/dist/components/actions/Button/Button.d.ts +3 -3
- package/dist/components/actions/Button/Button.js +8 -5
- 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.d.ts +2 -2
- package/dist/components/actions/ItemAction/ItemAction.js +15 -6
- package/dist/components/actions/ItemAction/ItemAction.js.map +1 -1
- package/dist/components/actions/ItemActionContext.d.ts +14 -0
- package/dist/components/actions/ItemActionContext.js +2 -2
- package/dist/components/actions/ItemActionContext.js.map +1 -1
- package/dist/components/actions/ItemButton/ItemButton.js +56 -46
- package/dist/components/actions/ItemButton/ItemButton.js.map +1 -1
- package/dist/components/actions/Link/Link.js +1 -1
- package/dist/components/actions/Menu/Menu.js +1 -1
- package/dist/components/actions/Menu/MenuItem.js +1 -1
- package/dist/components/actions/Menu/MenuSection.js +1 -1
- package/dist/components/actions/Menu/MenuTrigger.d.ts +13 -0
- package/dist/components/actions/Menu/MenuTrigger.js +27 -15
- package/dist/components/actions/Menu/MenuTrigger.js.map +1 -1
- package/dist/components/actions/Menu/SubMenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubmenuTriggerContext.js +1 -1
- package/dist/components/actions/Menu/context.js +1 -1
- package/dist/components/actions/Menu/styled.js +1 -1
- package/dist/components/actions/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.d.ts +10 -0
- package/dist/components/content/CopySnippet/CopySnippet.js +7 -4
- package/dist/components/content/CopySnippet/CopySnippet.js.map +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/InlineInput/InlineInput.js.map +1 -1
- package/dist/components/content/Item/Item.d.ts +2 -2
- package/dist/components/content/Item/Item.js +13 -58
- package/dist/components/content/Item/Item.js.map +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.d.ts +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.js +7 -4
- package/dist/components/content/ItemBadge/ItemBadge.js.map +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.d.ts +6 -0
- package/dist/components/content/PrismCode/PrismCode.js +12 -3
- package/dist/components/content/PrismCode/PrismCode.js.map +1 -1
- package/dist/components/content/PrismCode/prismSetup.js +1 -1
- package/dist/components/content/PrismDiffCode/PrismDiffCode.js +1 -1
- package/dist/components/content/Result/Result.js +1 -1
- package/dist/components/content/Skeleton/Skeleton.js +1 -1
- package/dist/components/content/Tag/Tag.js +1 -1
- package/dist/components/content/Text.d.ts +14 -14
- package/dist/components/content/Text.js +1 -1
- package/dist/components/content/TextItem/TextItem.js +1 -1
- package/dist/components/content/Title.js +1 -1
- package/dist/components/content/Tree/Tree.js +1 -1
- package/dist/components/content/Tree/TreeNode.js +1 -1
- package/dist/components/content/Tree/styled.js +1 -1
- package/dist/components/content/Tree/tree-index.js +1 -1
- package/dist/components/content/Tree/use-checkbox-tree.js +1 -1
- package/dist/components/content/Tree/use-load-data.js +1 -1
- package/dist/components/content/highlightText.js +1 -1
- package/dist/components/content/use-auto-tooltip.js +1 -1
- package/dist/components/data/DataTable/DataTable.js +140 -21
- package/dist/components/data/DataTable/DataTable.js.map +1 -1
- package/dist/components/data/DataTable/index.d.ts +1 -1
- package/dist/components/data/DataTable/types.d.ts +19 -4
- package/dist/components/data/ItemTable/ItemTable.js +169 -25
- package/dist/components/data/ItemTable/ItemTable.js.map +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/ItemTable/types.d.ts +7 -2
- 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 +30 -5
- package/dist/components/data/TableBase/TableRow.js.map +1 -1
- package/dist/components/data/TableBase/TableView.d.ts +2 -1
- package/dist/components/data/TableBase/TableView.js +299 -75
- package/dist/components/data/TableBase/TableView.js.map +1 -1
- package/dist/components/data/TableBase/column-menu.js +1 -1
- package/dist/components/data/TableBase/column-tint.js +12 -2
- package/dist/components/data/TableBase/column-tint.js.map +1 -1
- package/dist/components/data/TableBase/index.d.ts +1 -1
- package/dist/components/data/TableBase/row-menu.js +1 -1
- package/dist/components/data/TableBase/styled.d.ts +1 -2
- package/dist/components/data/TableBase/styled.js +75 -2
- package/dist/components/data/TableBase/styled.js.map +1 -1
- package/dist/components/data/TableBase/table-tree.js +129 -0
- package/dist/components/data/TableBase/table-tree.js.map +1 -0
- package/dist/components/data/TableBase/types.d.ts +46 -1
- 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.d.ts +0 -1
- package/dist/components/data/TableBase/use-cell-selection.js +0 -0
- package/dist/components/data/TableBase/use-column-order.js +1 -1
- package/dist/components/data/TableBase/use-container-width.js +1 -1
- package/dist/components/data/TableBase/use-row-move-animation.js +1 -1
- package/dist/components/data/TableBase/use-scrollability.js +1 -1
- package/dist/components/data/TableBase/use-table-columns.js +1 -1
- package/dist/components/data/TableBase/use-table-search.js +4 -4
- package/dist/components/data/TableBase/use-table-search.js.map +1 -1
- package/dist/components/data/TableBase/use-table-selection.js +124 -24
- package/dist/components/data/TableBase/use-table-selection.js.map +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 +107 -0
- package/dist/components/data/TableBase/use-table-tree-state.js.map +1 -0
- package/dist/components/data/index.d.ts +2 -2
- 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 +12 -7
- package/dist/components/fields/ColorInput/ColorInput.js.map +1 -1
- package/dist/components/fields/ColorPicker/ColorPicker.js +3 -2
- package/dist/components/fields/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/components/fields/{color → ColorSwatch}/ColorSwatch.d.ts +8 -2
- package/dist/components/fields/{color → ColorSwatch}/ColorSwatch.js +14 -6
- package/dist/components/fields/ColorSwatch/ColorSwatch.js.map +1 -0
- package/dist/components/fields/ColorSwatch/index.d.ts +2 -0
- package/dist/components/fields/ColorSwatchGroup/ColorSwatchGroup.js +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +2 -6
- package/dist/components/fields/ComboBox/ComboBox.js.map +1 -1
- package/dist/components/fields/CommandTextArea/CommandTextArea.js +8 -25
- package/dist/components/fields/CommandTextArea/CommandTextArea.js.map +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 +32 -2
- package/dist/components/fields/DatePicker/DatePickerButton.js.map +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 +3 -2
- 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.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/FilterPicker/FilterPicker.js.map +1 -1
- package/dist/components/fields/Input/Input.js +1 -1
- package/dist/components/fields/ListBox/DraggableListBox.js +1 -1
- package/dist/components/fields/ListBox/ListBox.js +1 -1
- package/dist/components/fields/ListBoxPopover/ListBoxPopover.js +1 -1
- package/dist/components/fields/ListBoxPopover/index.d.ts +0 -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 +9 -6
- package/dist/components/fields/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/components/fields/Picker/Picker.js +1 -1
- package/dist/components/fields/Picker/Picker.js.map +1 -1
- package/dist/components/fields/RadioGroup/Radio.js +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.js +2 -1
- package/dist/components/fields/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/fields/RadioGroup/context.js +1 -1
- package/dist/components/fields/SearchComboBox/SearchComboBox.js +2 -6
- package/dist/components/fields/SearchComboBox/SearchComboBox.js.map +1 -1
- package/dist/components/fields/SearchInput/SearchInput.js +18 -16
- package/dist/components/fields/SearchInput/SearchInput.js.map +1 -1
- package/dist/components/fields/Select/Select.js +3 -6
- package/dist/components/fields/Select/Select.js.map +1 -1
- package/dist/components/fields/Slider/Gradation.js +1 -1
- package/dist/components/fields/Slider/HueSlider.js +15 -2
- package/dist/components/fields/Slider/HueSlider.js.map +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 +10 -29
- package/dist/components/fields/TextArea/TextArea.js.map +1 -1
- package/dist/components/fields/TextInput/TextInput.js +1 -1
- package/dist/components/fields/TextInput/TextInputBase.js +1 -1
- package/dist/components/fields/TextInput/useAutoSizeTextArea.js +146 -0
- package/dist/components/fields/TextInput/useAutoSizeTextArea.js.map +1 -0
- package/dist/components/fields/TextInputMapper/TextInputMapper.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 +4 -4
- package/dist/components/fields/color/color.js.map +1 -1
- package/dist/components/fields/color/context.js +1 -1
- package/dist/components/fields/color/index.d.ts +0 -1
- package/dist/components/fields/index.d.ts +2 -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.d.ts +38 -5
- package/dist/components/layout/Board/Board.js +11 -5
- package/dist/components/layout/Board/Board.js.map +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.d.ts +16 -1
- package/dist/components/layout/Board/Widget.js +3 -2
- package/dist/components/layout/Board/Widget.js.map +1 -1
- package/dist/components/layout/Board/WidgetHost.js +92 -17
- package/dist/components/layout/Board/WidgetHost.js.map +1 -1
- package/dist/components/layout/Board/board-context.js +5 -5
- package/dist/components/layout/Board/board-context.js.map +1 -1
- package/dist/components/layout/Board/board-store.d.ts +1 -0
- package/dist/components/layout/Board/board-store.js +2 -2
- package/dist/components/layout/Board/board-store.js.map +1 -1
- package/dist/components/layout/Board/grid-core/calculate.js +1 -1
- package/dist/components/layout/Board/grid-core/collision-modes.js +186 -0
- package/dist/components/layout/Board/grid-core/collision-modes.js.map +1 -0
- 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 +12 -2
- package/dist/components/layout/Board/grid-core/layout.js.map +1 -1
- package/dist/components/layout/Board/grid-core/sort.js +1 -1
- package/dist/components/layout/Board/grid-core/types.d.ts +19 -1
- package/dist/components/layout/Board/index.d.ts +2 -2
- package/dist/components/layout/Board/index.js +1 -1
- package/dist/components/layout/Board/index.js.map +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 +137 -47
- package/dist/components/layout/Board/use-board-registry.js.map +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 +2 -29
- package/dist/components/navigation/Tabs/TabButton.js.map +1 -1
- package/dist/components/navigation/Tabs/TabDropIndicator.js +1 -1
- package/dist/components/navigation/Tabs/TabPanel.js +1 -1
- package/dist/components/navigation/Tabs/TabPicker.js +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +1 -1
- package/dist/components/navigation/Tabs/TabsAction.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/popover-placement.js +1 -1
- package/dist/components/navigation/Tabs/styled.js +1 -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.d.ts +37 -0
- package/dist/components/other/NoDataIcon/NoDataIcon.js +56 -0
- package/dist/components/other/NoDataIcon/NoDataIcon.js.map +1 -0
- package/dist/components/other/NoDataIcon/index.d.ts +2 -0
- 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 +4 -3
- package/dist/components/overlays/Dialog/Dialog.js.map +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.d.ts +13 -0
- package/dist/components/overlays/Dialog/DialogTrigger.js +24 -5
- package/dist/components/overlays/Dialog/DialogTrigger.js.map +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/context.js.map +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Modal/Modal.d.ts +1 -2
- 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 +0 -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/Modal/types.d.ts +0 -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.d.ts +0 -2
- 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/index.d.ts +0 -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/LoadingAnimation/LoadingAnimation.js.map +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.d.ts +1 -1
- package/dist/data/item-themes.js +217 -46
- package/dist/data/item-themes.js.map +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/eslint-plugin/defaults.generated.js +41 -13
- 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 +2 -1
- package/dist/i18n/locales/en-US/uikit.js +2 -1
- package/dist/i18n/locales/en-US/uikit.json.d.ts +1 -0
- package/dist/i18n/locales/es-ES/uikit.js +2 -1
- package/dist/i18n/locales/es-MX/uikit.js +2 -1
- package/dist/i18n/locales/fr-FR/uikit.js +2 -1
- package/dist/i18n/locales/it-IT/uikit.js +2 -1
- package/dist/i18n/locales/ja-JP/uikit.js +2 -1
- package/dist/i18n/locales/nb-NO/uikit.js +2 -1
- package/dist/i18n/locales/pt-BR/uikit.js +2 -1
- package/dist/i18n/locales/pt-PT/uikit.js +2 -1
- package/dist/i18n/locales/sv-SE/uikit.js +2 -1
- package/dist/i18n/locales/vi-VN/uikit.js +2 -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 -7
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- 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/tokens/base.js +1 -1
- package/dist/tokens/color-seed.d.ts +44 -0
- package/dist/tokens/color-seed.js +48 -0
- package/dist/tokens/color-seed.js.map +1 -0
- package/dist/tokens/color-theme.d.ts +9 -1
- package/dist/tokens/color-theme.js +20 -7
- package/dist/tokens/color-theme.js.map +1 -1
- package/dist/tokens/colors.js +20 -3
- package/dist/tokens/colors.js.map +1 -1
- package/dist/tokens/index.d.ts +2 -1
- package/dist/tokens/index.js +3 -2
- 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 +304 -77
- package/dist/tokens/palette-config.js +188 -49
- package/dist/tokens/palette-config.js.map +1 -1
- package/dist/tokens/palette.js +617 -163
- 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/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/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/Introduction.md +85 -97
- package/docs/Theming.md +471 -83
- package/docs/Usage.md +63 -2
- package/docs/components/Root.md +1 -1
- package/docs/components/actions/Button.md +9 -3
- package/docs/components/actions/ItemAction.md +3 -3
- package/docs/components/actions/MenuTrigger.md +54 -2
- package/docs/components/actions/SubMenuTrigger.md +2 -2
- package/docs/components/content/CopySnippet.md +5 -5
- package/docs/components/content/InlineInput.md +1 -1
- package/docs/components/content/Item.md +10 -10
- package/docs/components/content/ItemBadge.md +2 -2
- package/docs/components/content/PrismCode.md +1 -0
- package/docs/components/data/DataTable.md +110 -11
- package/docs/components/data/ItemTable.md +63 -1
- package/docs/components/fields/ColorSwatch.md +155 -0
- package/docs/components/layout/Board.md +21 -2
- package/docs/components/other/NoDataIcon.md +48 -0
- package/docs/components/overlays/DialogTrigger.md +3 -2
- package/docs/components/status/LoadingAnimation.md +12 -0
- package/docs/glaze/api.md +155 -47
- package/docs/glaze/methodology.md +15 -13
- package/docs/glaze/migration.md +36 -0
- package/docs/glaze/okhst.md +4 -0
- package/docs/tasty/ai-agents.md +3 -0
- package/docs/tasty/configuration.md +11 -6
- package/docs/tasty/dsl.md +99 -2
- package/docs/tasty/styles.md +3 -1
- package/package.json +3 -3
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.d.ts +0 -2
- package/dist/components/fields/color/ColorSwatch.js.map +0 -1
- package/dist/components/portal/PortalProvider.d.ts +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-tree.js","names":[],"sources":["../../../../src/components/data/TableBase/table-tree.ts"],"sourcesContent":["import type { Key } from '@react-types/shared';\n\nexport interface TableTreeNode<T> {\n key: Key;\n row: T;\n parentKey: Key | null;\n level: number;\n siblingIndex: number;\n siblingCount: number;\n sourceIndex: number;\n children: TableTreeNode<T>[];\n}\n\nexport interface TableTreeModel<T> {\n roots: TableTreeNode<T>[];\n byKey: Map<Key, TableTreeNode<T>>;\n parentOf: Map<Key, Key | null>;\n childrenOf: Map<Key, Key[]>;\n duplicateKeys: Key[];\n cyclicKeys: Key[];\n}\n\n/** Build identity and parent/child indexes without modifying consumer rows. */\nexport function buildTableTree<T>(\n rows: readonly T[],\n getChildren: (row: T) => readonly T[] | undefined,\n getKey: (row: T, sourceIndex: number) => Key,\n): TableTreeModel<T> {\n const byKey = new Map<Key, TableTreeNode<T>>();\n const parentOf = new Map<Key, Key | null>();\n const childrenOf = new Map<Key, Key[]>();\n const duplicateKeys: Key[] = [];\n const cyclicKeys: Key[] = [];\n const visiting = new Set<Key>();\n const visitingRows = new Set<T>();\n let sourceIndex = 0;\n\n const visit = (\n input: readonly T[],\n parentKey: Key | null,\n level: number,\n ): TableTreeNode<T>[] => {\n const output: TableTreeNode<T>[] = [];\n\n input.forEach((row, siblingIndex) => {\n const currentSourceIndex = sourceIndex++;\n const key = getKey(row, currentSourceIndex);\n\n if (visiting.has(key) || visitingRows.has(row)) {\n cyclicKeys.push(key);\n return;\n }\n\n if (byKey.has(key)) {\n duplicateKeys.push(key);\n return;\n }\n\n const node: TableTreeNode<T> = {\n key,\n row,\n parentKey,\n level,\n siblingIndex,\n siblingCount: input.length,\n sourceIndex: currentSourceIndex,\n children: [],\n };\n\n byKey.set(key, node);\n parentOf.set(key, parentKey);\n visiting.add(key);\n visitingRows.add(row);\n node.children = visit(getChildren(row) ?? [], key, level + 1);\n visiting.delete(key);\n visitingRows.delete(row);\n childrenOf.set(\n key,\n node.children.map((child) => child.key),\n );\n output.push(node);\n });\n\n return output;\n };\n\n const roots = visit(rows, null, 0);\n\n return {\n roots,\n byKey,\n parentOf,\n childrenOf,\n duplicateKeys,\n cyclicKeys,\n };\n}\n\nexport function sortTableTree<T>(\n nodes: readonly TableTreeNode<T>[],\n compare: (a: TableTreeNode<T>, b: TableTreeNode<T>) => number,\n): TableTreeNode<T>[] {\n const sorted = nodes\n .map((node) => ({\n ...node,\n children: sortTableTree(node.children, compare),\n }))\n .sort(compare);\n\n return sorted.map((node, siblingIndex) => ({\n ...node,\n siblingIndex,\n siblingCount: sorted.length,\n }));\n}\n\nexport interface FilteredTableTree<T> {\n roots: TableTreeNode<T>[];\n forcedExpandedKeys: Set<Key>;\n}\n\n/**\n * Keep matching rows, their ancestor paths, and the complete subtree of a row\n * that matches itself. Every retained branch is opened while filtering so a\n * match can never remain hidden behind a collapsed ancestor.\n */\nexport function filterTableTree<T>(\n nodes: readonly TableTreeNode<T>[],\n matches: (node: TableTreeNode<T>) => boolean,\n): FilteredTableTree<T> {\n const forcedExpandedKeys = new Set<Key>();\n\n const cloneComplete = (node: TableTreeNode<T>): TableTreeNode<T> => {\n const children = node.children.map(cloneComplete);\n if (children.length) forcedExpandedKeys.add(node.key);\n\n return { ...node, children: reindexTableTree(children) };\n };\n\n const visit = (node: TableTreeNode<T>): TableTreeNode<T> | null => {\n if (matches(node)) return cloneComplete(node);\n\n const children = node.children\n .map(visit)\n .filter((child): child is TableTreeNode<T> => child != null);\n\n if (!children.length) return null;\n\n forcedExpandedKeys.add(node.key);\n return { ...node, children: reindexTableTree(children) };\n };\n\n return {\n roots: reindexTableTree(\n nodes.map(visit).filter((node): node is TableTreeNode<T> => node != null),\n ),\n forcedExpandedKeys,\n };\n}\n\n/** Re-number a transformed sibling collection for its rendered treegrid. */\nexport function reindexTableTree<T>(\n nodes: readonly TableTreeNode<T>[],\n): TableTreeNode<T>[] {\n return nodes.map((node, siblingIndex) => ({\n ...node,\n siblingIndex,\n siblingCount: nodes.length,\n children: reindexTableTree(node.children),\n }));\n}\n\nexport function flattenTableTree<T>(\n nodes: readonly TableTreeNode<T>[],\n expandedKeys?: ReadonlySet<Key>,\n): TableTreeNode<T>[] {\n const output: TableTreeNode<T>[] = [];\n\n const visit = (items: readonly TableTreeNode<T>[]) => {\n for (const node of items) {\n output.push(node);\n if (expandedKeys == null || expandedKeys.has(node.key)) {\n visit(node.children);\n }\n }\n };\n\n visit(nodes);\n return output;\n}\n\nexport function tableTreeDescendantKeys<T>(node: TableTreeNode<T>): Key[] {\n return flattenTableTree(node.children).map((child) => child.key);\n}\n\nexport function isTableTreeDescendant<T>(\n model: Pick<TableTreeModel<T>, 'parentOf'>,\n possibleDescendant: Key,\n ancestor: Key,\n) {\n let parent = model.parentOf.get(possibleDescendant);\n\n while (parent != null) {\n if (parent === ancestor) return true;\n parent = model.parentOf.get(parent);\n }\n\n return false;\n}\n"],"mappings":";;;AAuBA,SAAgB,eACd,MACA,aACA,QACmB;CACnB,MAAM,wBAAQ,IAAI,KAA4B;CAC9C,MAAM,2BAAW,IAAI,KAAsB;CAC3C,MAAM,6BAAa,IAAI,KAAiB;CACxC,MAAM,gBAAuB,EAAE;CAC/B,MAAM,aAAoB,EAAE;CAC5B,MAAM,2BAAW,IAAI,KAAU;CAC/B,MAAM,+BAAe,IAAI,KAAQ;CACjC,IAAI,cAAc;CAElB,MAAM,SACJ,OACA,WACA,UACuB;EACvB,MAAM,SAA6B,EAAE;AAErC,QAAM,SAAS,KAAK,iBAAiB;GACnC,MAAM,qBAAqB;GAC3B,MAAM,MAAM,OAAO,KAAK,mBAAmB;AAE3C,OAAI,SAAS,IAAI,IAAI,IAAI,aAAa,IAAI,IAAI,EAAE;AAC9C,eAAW,KAAK,IAAI;AACpB;;AAGF,OAAI,MAAM,IAAI,IAAI,EAAE;AAClB,kBAAc,KAAK,IAAI;AACvB;;GAGF,MAAM,OAAyB;IAC7B;IACA;IACA;IACA;IACA;IACA,cAAc,MAAM;IACpB,aAAa;IACb,UAAU,EAAE;IACb;AAED,SAAM,IAAI,KAAK,KAAK;AACpB,YAAS,IAAI,KAAK,UAAU;AAC5B,YAAS,IAAI,IAAI;AACjB,gBAAa,IAAI,IAAI;AACrB,QAAK,WAAW,MAAM,YAAY,IAAI,IAAI,EAAE,EAAE,KAAK,QAAQ,EAAE;AAC7D,YAAS,OAAO,IAAI;AACpB,gBAAa,OAAO,IAAI;AACxB,cAAW,IACT,KACA,KAAK,SAAS,KAAK,UAAU,MAAM,IAAI,CACxC;AACD,UAAO,KAAK,KAAK;IACjB;AAEF,SAAO;;AAKT,QAAO;EACL,OAHY,MAAM,MAAM,MAAM,EAAE;EAIhC;EACA;EACA;EACA;EACA;EACD;;AAGH,SAAgB,cACd,OACA,SACoB;CACpB,MAAM,SAAS,MACZ,KAAK,UAAU;EACd,GAAG;EACH,UAAU,cAAc,KAAK,UAAU,QAAQ;EAChD,EAAE,CACF,KAAK,QAAQ;AAEhB,QAAO,OAAO,KAAK,MAAM,kBAAkB;EACzC,GAAG;EACH;EACA,cAAc,OAAO;EACtB,EAAE;;;;;;;AAaL,SAAgB,gBACd,OACA,SACsB;CACtB,MAAM,qCAAqB,IAAI,KAAU;CAEzC,MAAM,iBAAiB,SAA6C;EAClE,MAAM,WAAW,KAAK,SAAS,IAAI,cAAc;AACjD,MAAI,SAAS,OAAQ,oBAAmB,IAAI,KAAK,IAAI;AAErD,SAAO;GAAE,GAAG;GAAM,UAAU,iBAAiB,SAAS;GAAE;;CAG1D,MAAM,SAAS,SAAoD;AACjE,MAAI,QAAQ,KAAK,CAAE,QAAO,cAAc,KAAK;EAE7C,MAAM,WAAW,KAAK,SACnB,IAAI,MAAM,CACV,QAAQ,UAAqC,SAAS,KAAK;AAE9D,MAAI,CAAC,SAAS,OAAQ,QAAO;AAE7B,qBAAmB,IAAI,KAAK,IAAI;AAChC,SAAO;GAAE,GAAG;GAAM,UAAU,iBAAiB,SAAS;GAAE;;AAG1D,QAAO;EACL,OAAO,iBACL,MAAM,IAAI,MAAM,CAAC,QAAQ,SAAmC,QAAQ,KAAK,CAC1E;EACD;EACD;;;AAIH,SAAgB,iBACd,OACoB;AACpB,QAAO,MAAM,KAAK,MAAM,kBAAkB;EACxC,GAAG;EACH;EACA,cAAc,MAAM;EACpB,UAAU,iBAAiB,KAAK,SAAS;EAC1C,EAAE;;AAGL,SAAgB,iBACd,OACA,cACoB;CACpB,MAAM,SAA6B,EAAE;CAErC,MAAM,SAAS,UAAuC;AACpD,OAAK,MAAM,QAAQ,OAAO;AACxB,UAAO,KAAK,KAAK;AACjB,OAAI,gBAAgB,QAAQ,aAAa,IAAI,KAAK,IAAI,CACpD,OAAM,KAAK,SAAS;;;AAK1B,OAAM,MAAM;AACZ,QAAO;;AAOT,SAAgB,sBACd,OACA,oBACA,UACA;CACA,IAAI,SAAS,MAAM,SAAS,IAAI,mBAAmB;AAEnD,QAAO,UAAU,MAAM;AACrB,MAAI,WAAW,SAAU,QAAO;AAChC,WAAS,MAAM,SAAS,IAAI,OAAO;;AAGrC,QAAO"}
|
|
@@ -23,6 +23,47 @@ interface CubeTableCellRange {
|
|
|
23
23
|
fromColumnKey: string;
|
|
24
24
|
toColumnKey: string;
|
|
25
25
|
}
|
|
26
|
+
interface CubeTableTreeRowState {
|
|
27
|
+
/** Zero-based depth in the hierarchy. */
|
|
28
|
+
level: number;
|
|
29
|
+
parentKey: Key$1 | null;
|
|
30
|
+
hasChildren: boolean;
|
|
31
|
+
isExpanded: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface CubeTableRowExpandInfo<T = any> {
|
|
34
|
+
row: T;
|
|
35
|
+
rowKey: Key$1;
|
|
36
|
+
level: number;
|
|
37
|
+
parentKey: Key$1 | null;
|
|
38
|
+
expanded: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Shared root sizing contract used by both table adapters. */
|
|
41
|
+
interface CubeTableLayoutProps {
|
|
42
|
+
/**
|
|
43
|
+
* Shrink-wraps the frame to its rendered rows instead of filling the
|
|
44
|
+
* available flex pane. This mode disables virtualization because there is no
|
|
45
|
+
* bounded vertical viewport to virtualize against.
|
|
46
|
+
*
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
isAutoHeight?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Shared opt-in hierarchy contract used by both table adapters. */
|
|
52
|
+
interface CubeTableTreeProps<T = any> {
|
|
53
|
+
/**
|
|
54
|
+
* Returns a row's already-loaded children. Supplying this enables tree mode
|
|
55
|
+
* and makes `data` the top-level row collection.
|
|
56
|
+
*/
|
|
57
|
+
getRowChildren?: (row: T) => readonly T[] | undefined;
|
|
58
|
+
/** Column that owns the indentation and disclosure control. */
|
|
59
|
+
treeColumnKey?: string;
|
|
60
|
+
/** Controlled expanded row keys. */
|
|
61
|
+
expandedKeys?: Key$1[];
|
|
62
|
+
/** Initially expanded row keys. */
|
|
63
|
+
defaultExpandedKeys?: Key$1[];
|
|
64
|
+
/** Called after a user expands or collapses a row. */
|
|
65
|
+
onExpand?: (keys: Key$1[], info: CubeTableRowExpandInfo<T>) => void;
|
|
66
|
+
}
|
|
26
67
|
interface CubeTableSort {
|
|
27
68
|
/** `key` of the sorted column. */
|
|
28
69
|
columnKey: string;
|
|
@@ -49,6 +90,8 @@ interface CubeTableCellContext<T = any> {
|
|
|
49
90
|
*/
|
|
50
91
|
isRowFocused?: boolean;
|
|
51
92
|
isDropTarget?: boolean;
|
|
93
|
+
/** Present only when `getRowChildren` enables tree mode. */
|
|
94
|
+
tree?: CubeTableTreeRowState;
|
|
52
95
|
}
|
|
53
96
|
interface CubeTableRowContext<T = any> {
|
|
54
97
|
row: T;
|
|
@@ -59,6 +102,8 @@ interface CubeTableRowContext<T = any> {
|
|
|
59
102
|
/** Not yet wired — always absent. See `CubeTableCellContext` for why. */
|
|
60
103
|
isFocused?: boolean;
|
|
61
104
|
isDropTarget?: boolean;
|
|
105
|
+
/** Present only when `getRowChildren` enables tree mode. */
|
|
106
|
+
tree?: CubeTableTreeRowState;
|
|
62
107
|
}
|
|
63
108
|
interface CubeTableHeaderContext {
|
|
64
109
|
columnKey: string;
|
|
@@ -254,5 +299,5 @@ type CubeTableSelectionMode = 'none' | 'single' | 'multiple';
|
|
|
254
299
|
*/
|
|
255
300
|
type CubeTableSelectAllMode = 'page' | 'filtered' | 'all';
|
|
256
301
|
//#endregion
|
|
257
|
-
export { CubeTableAlign, CubeTableCellContext, CubeTableCellRange, CubeTableColumn, CubeTableColumnHeader, CubeTableHeaderContext, CubeTableLoadingIndicator, CubeTableRowContext, CubeTableRowSection, CubeTableRowSize, CubeTableSelectAllMode, CubeTableSelectionMode, CubeTableSort, CubeTableSortDirection };
|
|
302
|
+
export { CubeTableAlign, CubeTableCellContext, CubeTableCellRange, CubeTableColumn, CubeTableColumnHeader, CubeTableHeaderContext, CubeTableLayoutProps, CubeTableLoadingIndicator, CubeTableRowContext, CubeTableRowExpandInfo, CubeTableRowSection, CubeTableRowSize, CubeTableSelectAllMode, CubeTableSelectionMode, CubeTableSort, CubeTableSortDirection, CubeTableTreeProps, CubeTableTreeRowState };
|
|
258
303
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/data/TableBase/types.ts"],"sourcesContent":["import type { Key } from '@react-types/shared';\nimport type { Styles } from '@tenphi/tasty';\nimport type { ReactNode } from 'react';\nimport type { CubeItemProps } from '../../content/Item';\n\nexport type CubeTableSortDirection = 'asc' | 'desc';\n/**\n * Named row heights: 28px, 32px and 40px.\n *\n * A subset of the kit's size scale, and the same three steps `size` would give —\n * but `rowSize` moves only the ROWS. `size` also drives the header, so reaching\n * for a denser body through it drags the header down too.\n */\nexport type CubeTableRowSize = 'small' | 'medium' | 'large';\nexport type CubeTableAlign = 'start' | 'center' | 'end';\nexport type CubeTableRowSection = 'body' | 'pinnedTop' | 'pinnedBottom';\n\n/**\n * `asc | desc` rather than React Aria's `ascending | descending`: we do not use\n * `useTableState`, so there is no `SortDescriptor` interop to preserve, and\n * every consumer and server query parameter already speaks `asc|desc`.\n * `aria-sort` is a one-line map in the header cell.\n */\n/**\n * A rectangular block of cells, stored as two opposite corners.\n *\n * Corners rather than a set of keys so the selection survives a re-sort or a\n * page change the way a keyed row selection does: \"the block between these two\n * cells\" is re-resolved against the current order every render.\n */\n/**\n * The key a cell range identifies a row by.\n *\n * Not the consumer's row key: a pinned total is commonly the SAME record at the\n * top and the bottom (`id: 'total'`), and one flat key space collapsed the two\n * into whichever `indexOf` found first — so a range aimed at the footer total\n * resolved against the header one. The section is part of the identity here,\n * and only here; `ctx.rowKey` stays the consumer's own.\n */\nexport function selectionRowKey(\n section: CubeTableRowSection,\n rowKey: Key,\n): Key {\n return section === 'body' ? rowKey : `${section}:${rowKey}`;\n}\n\nexport interface CubeTableCellRange {\n fromRowKey: Key;\n toRowKey: Key;\n fromColumnKey: string;\n toColumnKey: string;\n}\n\nexport interface CubeTableSort {\n /** `key` of the sorted column. */\n columnKey: string;\n direction: CubeTableSortDirection;\n}\n\n/* ── render contexts ─────────────────────────────────────────────────────── */\n\nexport interface CubeTableCellContext<T = any> {\n row: T;\n rowKey: Key;\n rowIndex: number;\n columnKey: string;\n columnIndex: number;\n section: CubeTableRowSection;\n /** Whether the ROW is selected, matching `isRowFocused` below. */\n isSelected: boolean;\n /**\n * Not yet wired — always absent.\n *\n * Optional rather than `boolean`, because there is nowhere honest to compute\n * them from where this context is built. Focus lives in the DOM, and drop\n * state comes out of `useDropIndicator`, a hook that can only run inside the\n * row component — so populating either means moving the `render` / `cellStyles`\n * call sites into `TableRow`. Declaring them required and passing `false`\n * would just be a documented lie.\n */\n isRowFocused?: boolean;\n isDropTarget?: boolean;\n}\n\nexport interface CubeTableRowContext<T = any> {\n row: T;\n rowKey: Key;\n rowIndex: number;\n section: CubeTableRowSection;\n isSelected: boolean;\n /** Not yet wired — always absent. See `CubeTableCellContext` for why. */\n isFocused?: boolean;\n isDropTarget?: boolean;\n}\n\nexport interface CubeTableHeaderContext {\n columnKey: string;\n columnIndex: number;\n sort: CubeTableSortDirection | null;\n isSortable: boolean;\n isResizing: boolean;\n width: number | null;\n}\n\n/* ── column ──────────────────────────────────────────────────────────────── */\n\n/**\n * Rich header content. Every slot except `menu` maps 1:1 onto the `Item`\n * rendered inside the header `<th>`, so a header gets icon / description /\n * tooltip / suffix / actions for free; `menu` is mounted into that `Item`'s\n * `actions` slot behind a `⋮` trigger.\n */\nexport interface CubeTableColumnHeader {\n icon?: CubeItemProps['icon'];\n rightIcon?: CubeItemProps['rightIcon'];\n prefix?: ReactNode;\n suffix?: ReactNode;\n description?: ReactNode;\n descriptionPlacement?: CubeItemProps['descriptionPlacement'];\n /** `true` = auto tooltip when the label is truncated. */\n tooltip?: CubeItemProps['tooltip'];\n actions?: ReactNode;\n /** Hide `actions` until hover/focus. @default true */\n autoHideActions?: boolean;\n /**\n * A column menu, opened from a `⋮` trigger in the header's actions slot and —\n * unless the table says otherwise — by right-click or Shift+F10.\n *\n * `Menu.Item` children. Opaque: the table mounts the node and reports the\n * pressed key back through `onColumnMenuAction`, so what a \"pin\" or a \"drill\n * down\" means stays in the consuming app. The exception is the reserved sort\n * keys (`sort-asc`, `sort-desc`, `clear-sort`), which the table labels,\n * disables when redundant, and applies itself before telling the consumer.\n *\n * An empty menu renders no trigger at all, rather than one that opens nothing.\n * Ignored when `header.render` takes the cell over.\n */\n menu?: ReactNode;\n /** Props for the `⋮` trigger. Merged over the table's `columnMenuTriggerProps`. */\n menuTriggerProps?: Record<string, any>;\n /** Props for the `Menu`. Merged over the table's `columnMenuProps`. */\n menuProps?: Record<string, any>;\n /** Called before the table-level `onColumnMenuAction`. */\n onMenuAction?: (action: string) => void;\n theme?: CubeItemProps['theme'];\n /**\n * Full takeover of the header cell's content. Overrides `title` and every\n * slot — including `actions` and `menu`, which are simply not rendered. A\n * takeover that wants a menu owns the trigger too.\n */\n render?: (ctx: CubeTableHeaderContext) => ReactNode;\n /** Overrides `column.align` for the header only. */\n align?: CubeTableAlign;\n styles?: Styles;\n}\n\n/* ── column colour ───────────────────────────────────────────────────────── */\n\n/**\n * A palette theme a column can borrow its tint from.\n *\n * Resolved through the same runtime generator as a custom colour, seeded from the\n * theme's own hue and saturation in `palette-config` — so it tracks a re-seeded\n * palette, and it gets the banding step the palette itself does not define.\n *\n * `special` is absent deliberately: it is a standalone `mode: 'fixed'` theme with\n * no tinted-surface ramp to borrow.\n */\nexport type CubeTableColumnTheme =\n | 'primary'\n | 'purple'\n | 'success'\n | 'danger'\n | 'warning'\n | 'note';\n\n/**\n * How a column is tinted.\n *\n * Every form but the last is *derived*: only a hue and a saturation are kept, and\n * the tone ramp plus an `AA`/`AAA` text floor are re-solved per colour scheme. So\n * a column stays readable in light, dark and high contrast without the caller\n * checking — which is the part hand-picked hex pairs get wrong.\n */\nexport type CubeTableColumnColor =\n /** A palette theme name. */\n | CubeTableColumnTheme\n /** Any colour Glaze parses — hex, `rgb()`, `hsl()`, `okhsl()`, `oklch()`. */\n | (string & {})\n /** The seed said directly. `saturation` is 0–100. */\n | { hue: number; saturation?: number }\n /**\n * Full manual control, as tasty colour strings (`'#note-surface'`, `'#purple.10'`).\n *\n * Nothing is derived and nothing is contrast-checked — this is the escape\n * hatch, and readability in every scheme becomes the caller's problem.\n * `fillBand` defaults to `fill`, which turns banding off for the column.\n */\n | { fill: string; fillBand?: string; text?: string };\n\n/**\n * Which parts of a column `color` reaches.\n *\n * @default ['header','body','totals']\n */\nexport type CubeTableColumnColorScope = 'header' | 'body' | 'totals';\n\nexport interface CubeTableColumn<T = any> {\n /**\n * Column id. Also the default data path — dot notation is supported\n * (`'owner.name'`). Anything beyond a path needs `getValue`.\n */\n key: string;\n /** Header label. Shorthand for `header` with no extra slots. */\n title?: ReactNode;\n header?: CubeTableColumnHeader;\n /**\n * Renders `<th scope=\"row\">` instead of `<td>`, names the row for screen\n * readers, and hosts the `rowLink` anchor. Defaults to the first\n * non-structural column when a row link is present.\n */\n isRowHeader?: boolean;\n\n /* sizing */\n /** Fixed width in px. Mutually exclusive with `flex`. */\n width?: number;\n /** Weight for the leftover space. @default 1 when `width` is unset */\n flex?: number;\n /** @default 150 */\n minWidth?: number;\n maxWidth?: number;\n /** Inherits the table's `isResizable`. */\n isResizable?: boolean;\n /**\n * Inherits the table's `isColumnReorderable`; `false` pins this column in\n * place while the others still move around it.\n */\n isReorderable?: boolean;\n /** Stick to the start/end edge during horizontal scroll. */\n pin?: 'start' | 'end';\n /** Hide without losing width or order state. */\n isHidden?: boolean;\n\n /* value pipeline */\n /** @default (row) => get(row, key) */\n getValue?: (row: T, rowIndex: number) => unknown;\n /** Raw value → display text. Feeds client sort, client search and TSV copy. */\n format?: (value: any, row: T, rowIndex: number) => string;\n /** Client-side comparator over raw `getValue` results. */\n compare?: (a: any, b: any, rowA: T, rowB: T) => number;\n\n /* rendering */\n /** A returned string is wrapped in a truncating `TextItem`. */\n render?: (\n value: any,\n row: T,\n rowIndex: number,\n ctx: CubeTableCellContext<T>,\n ) => ReactNode;\n cellStyles?: Styles | ((ctx: CubeTableCellContext<T>) => Styles | undefined);\n cellProps?: (ctx: CubeTableCellContext<T>) => Record<string, any> | undefined;\n\n /**\n * Tints the column — header, cells and pinned totals — with an adaptive fill\n * and a text colour solved to stay readable on it in every scheme.\n *\n * Row banding survives: the tint carries its own band one tone step away, so\n * the stripe still reads down the column instead of being painted over.\n */\n color?: CubeTableColumnColor;\n /** Narrows what `color` reaches. @default ['header','body','totals'] */\n colorScope?: readonly CubeTableColumnColorScope[];\n\n /* behaviour */\n align?: CubeTableAlign;\n /**\n * Opt IN, per column — a table is not sortable until at least one column says\n * so, and `sortMode` then defaults to `'client'`.\n *\n * (This read `@default true` for a long time, which was never what the code\n * did: `TableView` requires `isSortable === true` before a header becomes a\n * control at all.)\n *\n * @default false\n */\n isSortable?: boolean;\n /** Two-state cycling (asc ↔ desc), never back to unsorted. @default false */\n disallowSortRemoval?: boolean;\n /** Include in the built-in client search. @default true */\n isSearchable?: boolean;\n /** Include in TSV copy. @default true */\n isCopyable?: boolean;\n /** Wrap text and let the row grow to fit. */\n autoHeight?: boolean;\n\n /** Consumer-owned bag. Never reaches the DOM. */\n meta?: Record<string, unknown>;\n}\n\n/* ── resolved layout (internal, but exported for adapters) ───────────────── */\n\nexport interface CubeResolvedColumn<T = any>\n // `width`, `minWidth`, `maxWidth`, `flex` and `align` are all resolved here,\n // so they narrow from optional to definite and must be replaced, not extended.\n extends Omit<\n CubeTableColumn<T>,\n 'width' | 'minWidth' | 'maxWidth' | 'flex' | 'align'\n > {\n /** Position among the visible leaf columns, 0-based. */\n index: number;\n /** `aria-colindex`, 1-based and document-absolute. */\n ariaColIndex: number;\n /** Resolved pixel width, or `null` while the container is unmeasured. */\n width: number | null;\n minWidth: number;\n maxWidth: number | null;\n flex: number | null;\n align: CubeTableAlign;\n /** Cumulative sticky offset in px for a pinned column. */\n pinOffset: number | null;\n /** `true` for the last pinned-start / first pinned-end column. */\n isPinEdge: boolean;\n /** Structural columns (selection, drag handle, row menu) never enter sorting,\n * search, copy, or the value pipeline. */\n isStructural: boolean;\n}\n\nexport interface CubeTableColumnLayout<T = any> {\n columns: CubeResolvedColumn<T>[];\n pinnedStartWidth: number;\n pinnedEndWidth: number;\n /** Sum of resolved widths, or `null` while unmeasured. */\n totalWidth: number | null;\n /** `true` when the columns cannot fit and the table scrolls horizontally. */\n isOverflowing: boolean;\n}\n\n/**\n * How a refresh over an existing result is presented.\n *\n * - `overlay` — keep the previous rows visible, dimmed, behind a spinner. A\n * server page or a re-sort never blanks the table.\n * - `skeleton` — discard the previous rows and show placeholders.\n * - `none` — no visuals beyond `aria-busy`; the page owns the indicator.\n */\nexport type CubeTableLoadingIndicator = 'overlay' | 'skeleton' | 'none';\n\nexport type CubeTableSelectionMode = 'none' | 'single' | 'multiple';\n\n/**\n * What the header checkbox acts on.\n *\n * - `page` — the rows on the current page.\n * - `filtered` — every row passing the current search/filter, across pages.\n * - `all` — emits the `'all'` sentinel, meaning \"everything, including rows the\n * client has not loaded\". The consumer decides what that means for its query.\n */\nexport type CubeTableSelectAllMode = 'page' | 'filtered' | 'all';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,gBACd,SACA,QACK;AACL,QAAO,YAAY,SAAS,SAAS,GAAG,QAAQ,GAAG"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/data/TableBase/types.ts"],"sourcesContent":["import type { Key } from '@react-types/shared';\nimport type { Styles } from '@tenphi/tasty';\nimport type { ReactNode } from 'react';\nimport type { CubeItemProps } from '../../content/Item';\n\nexport type CubeTableSortDirection = 'asc' | 'desc';\n/**\n * Named row heights: 28px, 32px and 40px.\n *\n * A subset of the kit's size scale, and the same three steps `size` would give —\n * but `rowSize` moves only the ROWS. `size` also drives the header, so reaching\n * for a denser body through it drags the header down too.\n */\nexport type CubeTableRowSize = 'small' | 'medium' | 'large';\nexport type CubeTableAlign = 'start' | 'center' | 'end';\nexport type CubeTableRowSection = 'body' | 'pinnedTop' | 'pinnedBottom';\n\n/**\n * `asc | desc` rather than React Aria's `ascending | descending`: we do not use\n * `useTableState`, so there is no `SortDescriptor` interop to preserve, and\n * every consumer and server query parameter already speaks `asc|desc`.\n * `aria-sort` is a one-line map in the header cell.\n */\n/**\n * A rectangular block of cells, stored as two opposite corners.\n *\n * Corners rather than a set of keys so the selection survives a re-sort or a\n * page change the way a keyed row selection does: \"the block between these two\n * cells\" is re-resolved against the current order every render.\n */\n/**\n * The key a cell range identifies a row by.\n *\n * Not the consumer's row key: a pinned total is commonly the SAME record at the\n * top and the bottom (`id: 'total'`), and one flat key space collapsed the two\n * into whichever `indexOf` found first — so a range aimed at the footer total\n * resolved against the header one. The section is part of the identity here,\n * and only here; `ctx.rowKey` stays the consumer's own.\n */\nexport function selectionRowKey(\n section: CubeTableRowSection,\n rowKey: Key,\n): Key {\n return section === 'body' ? rowKey : `${section}:${rowKey}`;\n}\n\nexport interface CubeTableCellRange {\n fromRowKey: Key;\n toRowKey: Key;\n fromColumnKey: string;\n toColumnKey: string;\n}\n\nexport interface CubeTableTreeRowState {\n /** Zero-based depth in the hierarchy. */\n level: number;\n parentKey: Key | null;\n hasChildren: boolean;\n isExpanded: boolean;\n}\n\nexport interface CubeTableRowExpandInfo<T = any> {\n row: T;\n rowKey: Key;\n level: number;\n parentKey: Key | null;\n expanded: boolean;\n}\n\n/** Shared root sizing contract used by both table adapters. */\nexport interface CubeTableLayoutProps {\n /**\n * Shrink-wraps the frame to its rendered rows instead of filling the\n * available flex pane. This mode disables virtualization because there is no\n * bounded vertical viewport to virtualize against.\n *\n * @default false\n */\n isAutoHeight?: boolean;\n}\n\n/** Shared opt-in hierarchy contract used by both table adapters. */\nexport interface CubeTableTreeProps<T = any> {\n /**\n * Returns a row's already-loaded children. Supplying this enables tree mode\n * and makes `data` the top-level row collection.\n */\n getRowChildren?: (row: T) => readonly T[] | undefined;\n /** Column that owns the indentation and disclosure control. */\n treeColumnKey?: string;\n /** Controlled expanded row keys. */\n expandedKeys?: Key[];\n /** Initially expanded row keys. */\n defaultExpandedKeys?: Key[];\n /** Called after a user expands or collapses a row. */\n onExpand?: (keys: Key[], info: CubeTableRowExpandInfo<T>) => void;\n}\n\nexport interface CubeTableSort {\n /** `key` of the sorted column. */\n columnKey: string;\n direction: CubeTableSortDirection;\n}\n\n/* ── render contexts ─────────────────────────────────────────────────────── */\n\nexport interface CubeTableCellContext<T = any> {\n row: T;\n rowKey: Key;\n rowIndex: number;\n columnKey: string;\n columnIndex: number;\n section: CubeTableRowSection;\n /** Whether the ROW is selected, matching `isRowFocused` below. */\n isSelected: boolean;\n /**\n * Not yet wired — always absent.\n *\n * Optional rather than `boolean`, because there is nowhere honest to compute\n * them from where this context is built. Focus lives in the DOM, and drop\n * state comes out of `useDropIndicator`, a hook that can only run inside the\n * row component — so populating either means moving the `render` / `cellStyles`\n * call sites into `TableRow`. Declaring them required and passing `false`\n * would just be a documented lie.\n */\n isRowFocused?: boolean;\n isDropTarget?: boolean;\n /** Present only when `getRowChildren` enables tree mode. */\n tree?: CubeTableTreeRowState;\n}\n\nexport interface CubeTableRowContext<T = any> {\n row: T;\n rowKey: Key;\n rowIndex: number;\n section: CubeTableRowSection;\n isSelected: boolean;\n /** Not yet wired — always absent. See `CubeTableCellContext` for why. */\n isFocused?: boolean;\n isDropTarget?: boolean;\n /** Present only when `getRowChildren` enables tree mode. */\n tree?: CubeTableTreeRowState;\n}\n\nexport interface CubeTableHeaderContext {\n columnKey: string;\n columnIndex: number;\n sort: CubeTableSortDirection | null;\n isSortable: boolean;\n isResizing: boolean;\n width: number | null;\n}\n\n/** Presentational path entry used to build multi-row column headers. */\nexport interface CubeTableColumnGroupHeader {\n key: string;\n title?: ReactNode;\n}\n\n/* ── column ──────────────────────────────────────────────────────────────── */\n\n/**\n * Rich header content. Every slot except `menu` maps 1:1 onto the `Item`\n * rendered inside the header `<th>`, so a header gets icon / description /\n * tooltip / suffix / actions for free; `menu` is mounted into that `Item`'s\n * `actions` slot behind a `⋮` trigger.\n */\nexport interface CubeTableColumnHeader {\n icon?: CubeItemProps['icon'];\n rightIcon?: CubeItemProps['rightIcon'];\n prefix?: ReactNode;\n suffix?: ReactNode;\n description?: ReactNode;\n descriptionPlacement?: CubeItemProps['descriptionPlacement'];\n /** `true` = auto tooltip when the label is truncated. */\n tooltip?: CubeItemProps['tooltip'];\n actions?: ReactNode;\n /** Hide `actions` until hover/focus. @default true */\n autoHideActions?: boolean;\n /**\n * A column menu, opened from a `⋮` trigger in the header's actions slot and —\n * unless the table says otherwise — by right-click or Shift+F10.\n *\n * `Menu.Item` children. Opaque: the table mounts the node and reports the\n * pressed key back through `onColumnMenuAction`, so what a \"pin\" or a \"drill\n * down\" means stays in the consuming app. The exception is the reserved sort\n * keys (`sort-asc`, `sort-desc`, `clear-sort`), which the table labels,\n * disables when redundant, and applies itself before telling the consumer.\n *\n * An empty menu renders no trigger at all, rather than one that opens nothing.\n * Ignored when `header.render` takes the cell over.\n */\n menu?: ReactNode;\n /** Props for the `⋮` trigger. Merged over the table's `columnMenuTriggerProps`. */\n menuTriggerProps?: Record<string, any>;\n /** Props for the `Menu`. Merged over the table's `columnMenuProps`. */\n menuProps?: Record<string, any>;\n /** Called before the table-level `onColumnMenuAction`. */\n onMenuAction?: (action: string) => void;\n theme?: CubeItemProps['theme'];\n /**\n * Full takeover of the header cell's content. Overrides `title` and every\n * slot — including `actions` and `menu`, which are simply not rendered. A\n * takeover that wants a menu owns the trigger too.\n */\n render?: (ctx: CubeTableHeaderContext) => ReactNode;\n /** Overrides `column.align` for the header only. */\n align?: CubeTableAlign;\n styles?: Styles;\n}\n\n/* ── column colour ───────────────────────────────────────────────────────── */\n\n/**\n * A palette theme a column can borrow its tint from.\n *\n * Resolved through the same runtime generator as a custom colour, seeded from the\n * theme's own hue and saturation in `palette-config` — so it tracks a re-seeded\n * palette, and it gets the banding step the palette itself does not define.\n *\n * `special` is absent deliberately: it is a standalone `mode: 'fixed'` theme with\n * no tinted-surface ramp to borrow.\n */\nexport type CubeTableColumnTheme =\n | 'primary'\n | 'purple'\n | 'success'\n | 'danger'\n | 'warning'\n | 'note';\n\n/**\n * How a column is tinted.\n *\n * Every form but the last is *derived*: only a hue and a saturation are kept, and\n * the tone ramp plus an `AA`/`AAA` text floor are re-solved per colour scheme. So\n * a column stays readable in light, dark and high contrast without the caller\n * checking — which is the part hand-picked hex pairs get wrong.\n */\nexport type CubeTableColumnColor =\n /** A palette theme name. */\n | CubeTableColumnTheme\n /** Any colour Glaze parses — hex, `rgb()`, `hsl()`, `okhsl()`, `oklch()`. */\n | (string & {})\n /** The seed said directly. `saturation` is 0–100. */\n | { hue: number; saturation?: number }\n /**\n * Full manual control, as tasty colour strings (`'#note-surface'`, `'#purple.10'`).\n *\n * Nothing is derived and nothing is contrast-checked — this is the escape\n * hatch, and readability in every scheme becomes the caller's problem.\n * `fillBand` defaults to `fill`, which turns banding off for the column.\n */\n | { fill: string; fillBand?: string; text?: string };\n\n/**\n * Which parts of a column `color` reaches.\n *\n * @default ['header','body','totals']\n */\nexport type CubeTableColumnColorScope = 'header' | 'body' | 'totals';\n\nexport interface CubeTableColumn<T = any> {\n /**\n * Column id. Also the default data path — dot notation is supported\n * (`'owner.name'`). Anything beyond a path needs `getValue`.\n */\n key: string;\n /** Header label. Shorthand for `header` with no extra slots. */\n title?: ReactNode;\n header?: CubeTableColumnHeader;\n /**\n * Renders `<th scope=\"row\">` instead of `<td>`, names the row for screen\n * readers, and hosts the `rowLink` anchor. Defaults to the first\n * non-structural column when a row link is present.\n */\n isRowHeader?: boolean;\n\n /* sizing */\n /** Fixed width in px. Mutually exclusive with `flex`. */\n width?: number;\n /** Weight for the leftover space. @default 1 when `width` is unset */\n flex?: number;\n /** @default 150 */\n minWidth?: number;\n maxWidth?: number;\n /** Inherits the table's `isResizable`. */\n isResizable?: boolean;\n /**\n * Inherits the table's `isColumnReorderable`; `false` pins this column in\n * place while the others still move around it.\n */\n isReorderable?: boolean;\n /** Stick to the start/end edge during horizontal scroll. */\n pin?: 'start' | 'end';\n /** Hide without losing width or order state. */\n isHidden?: boolean;\n\n /* value pipeline */\n /** @default (row) => get(row, key) */\n getValue?: (row: T, rowIndex: number) => unknown;\n /** Raw value → display text. Feeds client sort, client search and TSV copy. */\n format?: (value: any, row: T, rowIndex: number) => string;\n /** Client-side comparator over raw `getValue` results. */\n compare?: (a: any, b: any, rowA: T, rowB: T) => number;\n\n /* rendering */\n /** A returned string is wrapped in a truncating `TextItem`. */\n render?: (\n value: any,\n row: T,\n rowIndex: number,\n ctx: CubeTableCellContext<T>,\n ) => ReactNode;\n cellStyles?: Styles | ((ctx: CubeTableCellContext<T>) => Styles | undefined);\n cellProps?: (ctx: CubeTableCellContext<T>) => Record<string, any> | undefined;\n\n /**\n * Tints the column — header, cells and pinned totals — with an adaptive fill\n * and a text colour solved to stay readable on it in every scheme.\n *\n * Row banding survives: the tint carries its own band one tone step away, so\n * the stripe still reads down the column instead of being painted over.\n */\n color?: CubeTableColumnColor;\n /** Narrows what `color` reaches. @default ['header','body','totals'] */\n colorScope?: readonly CubeTableColumnColorScope[];\n\n /* behaviour */\n align?: CubeTableAlign;\n /**\n * Opt IN, per column — a table is not sortable until at least one column says\n * so, and `sortMode` then defaults to `'client'`.\n *\n * (This read `@default true` for a long time, which was never what the code\n * did: `TableView` requires `isSortable === true` before a header becomes a\n * control at all.)\n *\n * @default false\n */\n isSortable?: boolean;\n /** Two-state cycling (asc ↔ desc), never back to unsorted. @default false */\n disallowSortRemoval?: boolean;\n /** Include in the built-in client search. @default true */\n isSearchable?: boolean;\n /** Include in TSV copy. @default true */\n isCopyable?: boolean;\n /** Wrap text and let the row grow to fit. */\n autoHeight?: boolean;\n\n /** Consumer-owned bag. Never reaches the DOM. */\n meta?: Record<string, unknown>;\n}\n\n/* ── resolved layout (internal, but exported for adapters) ───────────────── */\n\nexport interface CubeResolvedColumn<T = any>\n // `width`, `minWidth`, `maxWidth`, `flex` and `align` are all resolved here,\n // so they narrow from optional to definite and must be replaced, not extended.\n extends Omit<\n CubeTableColumn<T>,\n 'width' | 'minWidth' | 'maxWidth' | 'flex' | 'align'\n > {\n /** Position among the visible leaf columns, 0-based. */\n index: number;\n /** `aria-colindex`, 1-based and document-absolute. */\n ariaColIndex: number;\n /** Resolved pixel width, or `null` while the container is unmeasured. */\n width: number | null;\n minWidth: number;\n maxWidth: number | null;\n flex: number | null;\n align: CubeTableAlign;\n /** Cumulative sticky offset in px for a pinned column. */\n pinOffset: number | null;\n /** `true` for the last pinned-start / first pinned-end column. */\n isPinEdge: boolean;\n /** Structural columns (selection, drag handle, row menu) never enter sorting,\n * search, copy, or the value pipeline. */\n isStructural: boolean;\n}\n\nexport interface CubeTableColumnLayout<T = any> {\n columns: CubeResolvedColumn<T>[];\n pinnedStartWidth: number;\n pinnedEndWidth: number;\n /** Sum of resolved widths, or `null` while unmeasured. */\n totalWidth: number | null;\n /** `true` when the columns cannot fit and the table scrolls horizontally. */\n isOverflowing: boolean;\n}\n\n/**\n * How a refresh over an existing result is presented.\n *\n * - `overlay` — keep the previous rows visible, dimmed, behind a spinner. A\n * server page or a re-sort never blanks the table.\n * - `skeleton` — discard the previous rows and show placeholders.\n * - `none` — no visuals beyond `aria-busy`; the page owns the indicator.\n */\nexport type CubeTableLoadingIndicator = 'overlay' | 'skeleton' | 'none';\n\nexport type CubeTableSelectionMode = 'none' | 'single' | 'multiple';\n\n/**\n * What the header checkbox acts on.\n *\n * - `page` — the rows on the current page.\n * - `filtered` — every row passing the current search/filter, across pages.\n * - `all` — emits the `'all'` sentinel, meaning \"everything, including rows the\n * client has not loaded\". The consumer decides what that means for its query.\n */\nexport type CubeTableSelectAllMode = 'page' | 'filtered' | 'all';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,gBACd,SACA,QACK;AACL,QAAO,YAAY,SAAS,SAAS,GAAG,QAAQ,GAAG"}
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.165.0 | Cube Dev Team */
|
|
2
2
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
4
|
import { useControlledState } from "@react-stately/utils";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.165.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";
|
|
@@ -17,7 +17,7 @@ import { useControlledState } from "@react-stately/utils";
|
|
|
17
17
|
* value. `getColumnText` returns `null` for anything it cannot honestly turn
|
|
18
18
|
* into text, and those columns are skipped rather than coerced.
|
|
19
19
|
*/
|
|
20
|
-
function
|
|
20
|
+
function matchesTableSearch(columns, row, rowIndex, query) {
|
|
21
21
|
return columns.some((column) => {
|
|
22
22
|
if (column.isSearchable === false) return false;
|
|
23
23
|
const text = getColumnText(column, row, rowIndex);
|
|
@@ -47,7 +47,7 @@ function useTableSearch({ columns, rows, mode = "client", value, defaultValue, o
|
|
|
47
47
|
query,
|
|
48
48
|
searchedRows: useMemo(() => {
|
|
49
49
|
if (mode !== "client" || !query) return rows;
|
|
50
|
-
return rows.filter((row, index) => filter ? filter(row, query) :
|
|
50
|
+
return rows.filter((row, index) => filter ? filter(row, query) : matchesTableSearch(columns, row, index, query));
|
|
51
51
|
}, [
|
|
52
52
|
mode,
|
|
53
53
|
query,
|
|
@@ -60,5 +60,5 @@ function useTableSearch({ columns, rows, mode = "client", value, defaultValue, o
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
//#endregion
|
|
63
|
-
export { useTableSearch };
|
|
63
|
+
export { matchesTableSearch, useTableSearch };
|
|
64
64
|
//# sourceMappingURL=use-table-search.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-search.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-search.ts"],"sourcesContent":["import { useControlledState } from '@react-stately/utils';\nimport { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useDebouncedValue, useEvent } from '../../../_internal/hooks';\n\nimport { getColumnText } from './use-table-columns';\n\nimport type { CubeTableColumn } from './types';\n\nexport type CubeTableSearchMode = 'client' | 'server';\n\nexport interface UseTableSearchOptions<T> {\n columns: CubeTableColumn<T>[];\n rows: readonly T[];\n /** @default 'client' */\n mode?: CubeTableSearchMode;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Debounces the filter AND the callback, in both modes. @default 500 */\n delay?: number;\n /** Replaces the default matcher in client mode. */\n filter?: (row: T, query: string) => boolean;\n}\n\nexport interface UseTableSearchResult<T> {\n /** The immediate term — what the input shows. */\n searchValue: string;\n setSearchValue: (value: string) => void;\n /** The debounced term — what the filter and the callback act on. */\n query: string;\n /** Filtered in client mode; the original array otherwise. */\n searchedRows: readonly T[];\n /** `true` when a non-empty term is narrowing the data. */\n isFiltered: boolean;\n}\n\n/**\n * Default matcher: a case-insensitive substring test against each searchable\n * column's **display text**.\n *\n * Deliberately not the raw value. Cloud's filter tested\n * `String(row[column.key])`, which meant a column rendering `owner.profile.name`\n * was unsearchable, and an object-valued column stringified to\n * `\"[object Object]\"` — so the query \"object\" matched every row with a nested\n * value. `getColumnText` returns `null` for anything it cannot honestly turn\n * into text, and those columns are skipped rather than coerced.\n */\
|
|
1
|
+
{"version":3,"file":"use-table-search.js","names":[],"sources":["../../../../src/components/data/TableBase/use-table-search.ts"],"sourcesContent":["import { useControlledState } from '@react-stately/utils';\nimport { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useDebouncedValue, useEvent } from '../../../_internal/hooks';\n\nimport { getColumnText } from './use-table-columns';\n\nimport type { CubeTableColumn } from './types';\n\nexport type CubeTableSearchMode = 'client' | 'server';\n\nexport interface UseTableSearchOptions<T> {\n columns: CubeTableColumn<T>[];\n rows: readonly T[];\n /** @default 'client' */\n mode?: CubeTableSearchMode;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Debounces the filter AND the callback, in both modes. @default 500 */\n delay?: number;\n /** Replaces the default matcher in client mode. */\n filter?: (row: T, query: string) => boolean;\n}\n\nexport interface UseTableSearchResult<T> {\n /** The immediate term — what the input shows. */\n searchValue: string;\n setSearchValue: (value: string) => void;\n /** The debounced term — what the filter and the callback act on. */\n query: string;\n /** Filtered in client mode; the original array otherwise. */\n searchedRows: readonly T[];\n /** `true` when a non-empty term is narrowing the data. */\n isFiltered: boolean;\n}\n\n/**\n * Default matcher: a case-insensitive substring test against each searchable\n * column's **display text**.\n *\n * Deliberately not the raw value. Cloud's filter tested\n * `String(row[column.key])`, which meant a column rendering `owner.profile.name`\n * was unsearchable, and an object-valued column stringified to\n * `\"[object Object]\"` — so the query \"object\" matched every row with a nested\n * value. `getColumnText` returns `null` for anything it cannot honestly turn\n * into text, and those columns are skipped rather than coerced.\n */\nexport function matchesTableSearch<T>(\n columns: CubeTableColumn<T>[],\n row: T,\n rowIndex: number,\n query: string,\n): boolean {\n return columns.some((column) => {\n if (column.isSearchable === false) return false;\n\n const text = getColumnText(column, row, rowIndex);\n\n return text != null && text.toLowerCase().includes(query);\n });\n}\n\nexport function useTableSearch<T>({\n columns,\n rows,\n mode = 'client',\n value,\n defaultValue,\n onChange,\n delay = 500,\n filter,\n}: UseTableSearchOptions<T>): UseTableSearchResult<T> {\n const [committed, setCommitted] = useControlledState<string>(\n value as string,\n defaultValue ?? '',\n onChange as (v: string) => void,\n );\n\n // What the input shows, updated on every keystroke. The committed value —\n // the one `onChange` reports and the filter runs on — trails it by `delay`.\n //\n // Two separate values rather than one, because `useControlledState` calls\n // `onChange` the moment it is set: routing keystrokes straight into it fired\n // a request per character in `searchMode=\"server\"`, which is the thing the\n // debounce exists to prevent. Debouncing the input itself instead would make\n // typing lag, so the split is the point.\n const [draft, setDraft] = useState(committed);\n const debounced = useDebouncedValue(draft, delay);\n\n // What we last pushed outward, so the sync below can tell a genuine external\n // change from the echo of our own debounce.\n const pushedRef = useRef(committed);\n\n // A controlled `searchValue` changing from OUTSIDE — a cleared filter, a\n // restored URL — wins over whatever is half-typed.\n //\n // The echo has to be filtered out or this reverts the input mid-word: with a\n // short delay the debounce commits letter 1 while letter 2 is already typed,\n // and syncing unconditionally puts letter 1 back. At `searchDelay={0}` that\n // happens on every keystroke and nothing longer than one character can ever\n // be typed.\n useEffect(() => {\n if (committed === pushedRef.current) return;\n\n pushedRef.current = committed;\n setDraft(committed);\n }, [committed]);\n\n useEffect(() => {\n if (debounced === pushedRef.current) return;\n\n pushedRef.current = debounced;\n setCommitted(debounced);\n // `committed` is deliberately not a dependency: reacting to it here would\n // fight the effect above and push a stale draft back out.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [debounced]);\n\n const searchValue = draft;\n const query = debounced.trim().toLowerCase();\n\n const setSearchValue = useEvent((next: string) => setDraft(next));\n\n const searchedRows = useMemo(() => {\n if (mode !== 'client' || !query) return rows;\n\n return rows.filter((row, index) =>\n filter\n ? filter(row, query)\n : matchesTableSearch(columns, row, index, query),\n );\n }, [mode, query, rows, columns, filter]);\n\n return {\n searchValue,\n setSearchValue,\n query,\n searchedRows,\n isFiltered: query.length > 0,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,mBACd,SACA,KACA,UACA,OACS;AACT,QAAO,QAAQ,MAAM,WAAW;AAC9B,MAAI,OAAO,iBAAiB,MAAO,QAAO;EAE1C,MAAM,OAAO,cAAc,QAAQ,KAAK,SAAS;AAEjD,SAAO,QAAQ,QAAQ,KAAK,aAAa,CAAC,SAAS,MAAM;GACzD;;AAGJ,SAAgB,eAAkB,EAChC,SACA,MACA,OAAO,UACP,OACA,cACA,UACA,QAAQ,KACR,UACoD;CACpD,MAAM,CAAC,WAAW,gBAAgB,mBAChC,OACA,gBAAgB,IAChB,SACD;CAUD,MAAM,CAAC,OAAO,YAAY,SAAS,UAAU;CAC7C,MAAM,YAAY,kBAAkB,OAAO,MAAM;CAIjD,MAAM,YAAY,OAAO,UAAU;AAUnC,iBAAgB;AACd,MAAI,cAAc,UAAU,QAAS;AAErC,YAAU,UAAU;AACpB,WAAS,UAAU;IAClB,CAAC,UAAU,CAAC;AAEf,iBAAgB;AACd,MAAI,cAAc,UAAU,QAAS;AAErC,YAAU,UAAU;AACpB,eAAa,UAAU;IAItB,CAAC,UAAU,CAAC;CAEf,MAAM,cAAc;CACpB,MAAM,QAAQ,UAAU,MAAM,CAAC,aAAa;AAc5C,QAAO;EACL;EACA,gBAdqB,UAAU,SAAiB,SAAS,KAAK,CAAC;EAe/D;EACA,cAdmB,cAAc;AACjC,OAAI,SAAS,YAAY,CAAC,MAAO,QAAO;AAExC,UAAO,KAAK,QAAQ,KAAK,UACvB,SACI,OAAO,KAAK,MAAM,GAClB,mBAAmB,SAAS,KAAK,OAAO,MAAM,CACnD;KACA;GAAC;GAAM;GAAO;GAAM;GAAS;GAAO,CAAC;EAOtC,YAAY,MAAM,SAAS;EAC5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.165.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";
|
|
@@ -26,8 +26,58 @@ function toSelection(keys) {
|
|
|
26
26
|
if (keys === void 0) return void 0;
|
|
27
27
|
return keys === "all" ? "all" : new Set(keys);
|
|
28
28
|
}
|
|
29
|
+
function deriveTreeSelection(source, rootKeys, childrenOf, isEligible) {
|
|
30
|
+
const checked = new Set(source);
|
|
31
|
+
const indeterminate = /* @__PURE__ */ new Set();
|
|
32
|
+
const visit = (key) => {
|
|
33
|
+
const children = childrenOf.get(key) ?? [];
|
|
34
|
+
const eligible = isEligible(key);
|
|
35
|
+
if (eligible && source.has(key)) checked.add(key);
|
|
36
|
+
if (!children.length) {
|
|
37
|
+
const selected = eligible && checked.has(key);
|
|
38
|
+
if (!eligible) checked.delete(key);
|
|
39
|
+
return {
|
|
40
|
+
all: !eligible || selected,
|
|
41
|
+
any: selected,
|
|
42
|
+
eligible
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
let all = true;
|
|
46
|
+
let any = false;
|
|
47
|
+
let hasEligible = false;
|
|
48
|
+
for (const child of children) {
|
|
49
|
+
const result = visit(child);
|
|
50
|
+
if (result.eligible) hasEligible = true;
|
|
51
|
+
if (!result.all) all = false;
|
|
52
|
+
if (result.any) any = true;
|
|
53
|
+
}
|
|
54
|
+
if (!eligible) {
|
|
55
|
+
checked.delete(key);
|
|
56
|
+
indeterminate.delete(key);
|
|
57
|
+
} else if (hasEligible && all) {
|
|
58
|
+
checked.add(key);
|
|
59
|
+
indeterminate.delete(key);
|
|
60
|
+
} else if (hasEligible && any) {
|
|
61
|
+
checked.delete(key);
|
|
62
|
+
indeterminate.add(key);
|
|
63
|
+
} else if (hasEligible) {
|
|
64
|
+
checked.delete(key);
|
|
65
|
+
indeterminate.delete(key);
|
|
66
|
+
} else if (!checked.has(key)) indeterminate.delete(key);
|
|
67
|
+
return {
|
|
68
|
+
all: !eligible || checked.has(key) && all,
|
|
69
|
+
any: any || checked.has(key),
|
|
70
|
+
eligible: eligible || hasEligible
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
rootKeys.forEach((key) => visit(key));
|
|
74
|
+
return {
|
|
75
|
+
checked,
|
|
76
|
+
indeterminate
|
|
77
|
+
};
|
|
78
|
+
}
|
|
29
79
|
function useTableSelection(options) {
|
|
30
|
-
const { rows, filteredRows, getRowKey, selectionMode, selectedKeys: selectedKeysProp, defaultSelectedKeys, onSelectionChange, selectAllMode, isRowSelectable, disabledKeys } = options;
|
|
80
|
+
const { rows, rowKeys, pageRows = rows, pageRowKeys, filteredRows, filteredRowKeys, getRowKey, selectionMode, selectedKeys: selectedKeysProp, defaultSelectedKeys, onSelectionChange, selectAllMode, isRowSelectable, disabledKeys, tree } = options;
|
|
31
81
|
const isEnabled = selectionMode !== "none";
|
|
32
82
|
/**
|
|
33
83
|
* Two distinct notions of "not available", deliberately kept apart:
|
|
@@ -45,28 +95,32 @@ function useTableSelection(options) {
|
|
|
45
95
|
const unselectableKeys = useMemo(() => {
|
|
46
96
|
const keys = new Set(hardDisabledKeys);
|
|
47
97
|
if (isRowSelectable) filteredRows.forEach((row, index) => {
|
|
48
|
-
if (!isRowSelectable(row)) keys.add(getRowKey(row, index));
|
|
98
|
+
if (!isRowSelectable(row)) keys.add(filteredRowKeys?.[index] ?? getRowKey(row, index));
|
|
49
99
|
});
|
|
50
100
|
return keys;
|
|
51
101
|
}, [
|
|
52
102
|
hardDisabledKeys,
|
|
53
103
|
isRowSelectable,
|
|
54
104
|
filteredRows,
|
|
105
|
+
filteredRowKeys,
|
|
55
106
|
getRowKey
|
|
56
107
|
]);
|
|
57
|
-
const
|
|
108
|
+
const visibleGetRowKey = useCallback((row, index) => rowKeys?.[index] ?? getRowKey(row, index), [rowKeys, getRowKey]);
|
|
109
|
+
const collection = useMemo(() => new RowCollection(rows, visibleGetRowKey, unselectableKeys), [
|
|
58
110
|
rows,
|
|
59
|
-
|
|
111
|
+
visibleGetRowKey,
|
|
60
112
|
unselectableKeys
|
|
61
113
|
]);
|
|
62
114
|
const rowByKey = useMemo(() => {
|
|
63
115
|
const map = /* @__PURE__ */ new Map();
|
|
64
|
-
filteredRows.forEach((row, index) => map.set(getRowKey(row, index), row));
|
|
65
|
-
rows.forEach((row, index) => map.set(getRowKey(row, index), row));
|
|
116
|
+
filteredRows.forEach((row, index) => map.set(filteredRowKeys?.[index] ?? getRowKey(row, index), row));
|
|
117
|
+
rows.forEach((row, index) => map.set(rowKeys?.[index] ?? getRowKey(row, index), row));
|
|
66
118
|
return map;
|
|
67
119
|
}, [
|
|
68
120
|
rows,
|
|
121
|
+
rowKeys,
|
|
69
122
|
filteredRows,
|
|
123
|
+
filteredRowKeys,
|
|
70
124
|
getRowKey
|
|
71
125
|
]);
|
|
72
126
|
const rowByKeyRef = useRef(rowByKey);
|
|
@@ -109,35 +163,59 @@ function useTableSelection(options) {
|
|
|
109
163
|
const selectionManager = useMemo(() => new SelectionManager(collection, state), [collection, state]);
|
|
110
164
|
const selectedKeys = state.selectedKeys;
|
|
111
165
|
const isAll = selectedKeys === "all";
|
|
112
|
-
const
|
|
113
|
-
const
|
|
166
|
+
const isCascade = tree?.behavior === "cascade" && selectionMode === "multiple";
|
|
167
|
+
const derivedSelection = useMemo(() => {
|
|
168
|
+
if (isAll) return {
|
|
169
|
+
checked: new Set([...rowByKey.keys()].filter((key) => !unselectableKeys.has(key))),
|
|
170
|
+
indeterminate: /* @__PURE__ */ new Set()
|
|
171
|
+
};
|
|
172
|
+
if (!isCascade || !tree) return {
|
|
173
|
+
checked: new Set(selectedKeys),
|
|
174
|
+
indeterminate: /* @__PURE__ */ new Set()
|
|
175
|
+
};
|
|
176
|
+
return deriveTreeSelection(selectedKeys, tree.rootKeys, tree.childrenOf, (key) => !unselectableKeys.has(key));
|
|
177
|
+
}, [
|
|
114
178
|
isAll,
|
|
179
|
+
isCascade,
|
|
115
180
|
selectedKeys,
|
|
181
|
+
tree,
|
|
182
|
+
rowByKey,
|
|
183
|
+
unselectableKeys
|
|
184
|
+
]);
|
|
185
|
+
const canSelect = useCallback((key) => isEnabled && !unselectableKeys.has(key), [isEnabled, unselectableKeys]);
|
|
186
|
+
const isSelected = useCallback((key) => isAll ? canSelect(key) : derivedSelection.checked.has(key), [
|
|
187
|
+
isAll,
|
|
188
|
+
derivedSelection,
|
|
116
189
|
canSelect
|
|
117
190
|
]);
|
|
191
|
+
const isIndeterminate = useCallback((key) => derivedSelection.indeterminate.has(key), [derivedSelection]);
|
|
118
192
|
/** Keys the header checkbox acts on, which is what `selectAllMode` decides. */
|
|
119
193
|
const scopeKeys = useMemo(() => {
|
|
120
194
|
if (!isEnabled || selectionMode === "single") return [];
|
|
121
|
-
|
|
195
|
+
const source = selectAllMode === "page" ? pageRows : filteredRows;
|
|
196
|
+
const sourceKeys = selectAllMode === "page" ? pageRowKeys : filteredRowKeys;
|
|
197
|
+
return source.map((row, index) => sourceKeys?.[index] ?? getRowKey(row, index)).filter((key) => !unselectableKeys.has(key));
|
|
122
198
|
}, [
|
|
123
199
|
isEnabled,
|
|
124
200
|
selectionMode,
|
|
125
201
|
selectAllMode,
|
|
126
|
-
|
|
202
|
+
pageRows,
|
|
203
|
+
pageRowKeys,
|
|
127
204
|
filteredRows,
|
|
205
|
+
filteredRowKeys,
|
|
128
206
|
getRowKey,
|
|
129
207
|
unselectableKeys
|
|
130
208
|
]);
|
|
131
209
|
const selectAllState = useMemo(() => {
|
|
132
210
|
if (isAll) return "all";
|
|
133
211
|
if (!scopeKeys.length) return "none";
|
|
134
|
-
const set =
|
|
212
|
+
const set = derivedSelection.checked;
|
|
135
213
|
let count = 0;
|
|
136
214
|
for (const key of scopeKeys) if (set.has(key)) count++;
|
|
137
215
|
return count === 0 ? "none" : count === scopeKeys.length ? "all" : "some";
|
|
138
216
|
}, [
|
|
139
217
|
isAll,
|
|
140
|
-
|
|
218
|
+
derivedSelection,
|
|
141
219
|
scopeKeys
|
|
142
220
|
]);
|
|
143
221
|
const toggleSelectAll = useEvent(() => {
|
|
@@ -151,9 +229,9 @@ function useTableSelection(options) {
|
|
|
151
229
|
state.setSelectedKeys("all");
|
|
152
230
|
return;
|
|
153
231
|
}
|
|
154
|
-
const next = new Set(isAll ? [] :
|
|
232
|
+
const next = new Set(isAll ? [] : derivedSelection.checked);
|
|
155
233
|
scopeKeys.forEach((key) => next.add(key));
|
|
156
|
-
state.setSelectedKeys(next);
|
|
234
|
+
state.setSelectedKeys(isCascade && tree ? deriveTreeSelection(next, tree.rootKeys, tree.childrenOf, (key) => !unselectableKeys.has(key)).checked : next);
|
|
157
235
|
});
|
|
158
236
|
const clearSelection = useEvent(() => {
|
|
159
237
|
anchorRef.current = null;
|
|
@@ -186,27 +264,48 @@ function useTableSelection(options) {
|
|
|
186
264
|
state.setSelectedKeys(isSelected(key) ? /* @__PURE__ */ new Set() : new Set([key]));
|
|
187
265
|
return;
|
|
188
266
|
}
|
|
267
|
+
const applyCascade = (set, target, value) => {
|
|
268
|
+
if (!canSelect(target)) return;
|
|
269
|
+
if (value) set.add(target);
|
|
270
|
+
else {
|
|
271
|
+
set.delete(target);
|
|
272
|
+
if (isCascade && tree) {
|
|
273
|
+
let parent = tree.parentOf.get(target);
|
|
274
|
+
while (parent != null) {
|
|
275
|
+
set.delete(parent);
|
|
276
|
+
parent = tree.parentOf.get(parent);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (!isCascade || !tree) return;
|
|
281
|
+
(tree.childrenOf.get(target) ?? []).forEach((child) => applyCascade(set, child, value));
|
|
282
|
+
};
|
|
283
|
+
const normalizeCascade = (set) => isCascade && tree ? deriveTreeSelection(set, tree.rootKeys, tree.childrenOf, (candidate) => !unselectableKeys.has(candidate)).checked : set;
|
|
189
284
|
const anchor = anchorRef.current;
|
|
190
285
|
if (shiftRef.current && anchor != null && collection.indexOf(anchor) >= 0) {
|
|
191
|
-
const next = new Set(isAll ? scopeKeys :
|
|
192
|
-
if (extentRef.current != null) keysBetween(anchor, extentRef.current).forEach((k) => next
|
|
286
|
+
const next = new Set(isAll ? scopeKeys : derivedSelection.checked);
|
|
287
|
+
if (extentRef.current != null) keysBetween(anchor, extentRef.current).forEach((k) => applyCascade(next, k, false));
|
|
193
288
|
keysBetween(anchor, key).forEach((k) => {
|
|
194
|
-
|
|
289
|
+
applyCascade(next, k, true);
|
|
195
290
|
});
|
|
196
291
|
extentRef.current = key;
|
|
197
|
-
state.setSelectedKeys(next);
|
|
292
|
+
state.setSelectedKeys(normalizeCascade(next));
|
|
198
293
|
return;
|
|
199
294
|
}
|
|
200
295
|
anchorRef.current = key;
|
|
201
296
|
extentRef.current = null;
|
|
202
|
-
|
|
297
|
+
if (isCascade) {
|
|
298
|
+
const next = new Set(derivedSelection.checked);
|
|
299
|
+
applyCascade(next, key, !derivedSelection.checked.has(key));
|
|
300
|
+
state.setSelectedKeys(normalizeCascade(next));
|
|
301
|
+
} else selectionManager.toggleSelection(key);
|
|
203
302
|
});
|
|
204
303
|
const selectedRows = useMemo(() => {
|
|
205
304
|
if (isAll) return [...rowByKey.values()];
|
|
206
|
-
return [...
|
|
305
|
+
return [...derivedSelection.checked].map((key) => rowByKey.get(key)).filter((row) => row !== void 0);
|
|
207
306
|
}, [
|
|
208
307
|
isAll,
|
|
209
|
-
|
|
308
|
+
derivedSelection,
|
|
210
309
|
rowByKey
|
|
211
310
|
]);
|
|
212
311
|
return {
|
|
@@ -215,6 +314,7 @@ function useTableSelection(options) {
|
|
|
215
314
|
selectionManager,
|
|
216
315
|
collection,
|
|
217
316
|
isSelected,
|
|
317
|
+
isIndeterminate,
|
|
218
318
|
canSelect,
|
|
219
319
|
isRowDisabled: useCallback((key) => hardDisabledKeys.has(key), [hardDisabledKeys]),
|
|
220
320
|
toggleRow,
|
|
@@ -223,8 +323,8 @@ function useTableSelection(options) {
|
|
|
223
323
|
toggleSelectAll,
|
|
224
324
|
clearSelection,
|
|
225
325
|
selectedRows,
|
|
226
|
-
selectedCount: isAll ? rowByKey.size :
|
|
227
|
-
selectedKeys: isAll ? "all" : [...
|
|
326
|
+
selectedCount: isAll ? rowByKey.size : derivedSelection.checked.size,
|
|
327
|
+
selectedKeys: isAll ? "all" : [...derivedSelection.checked]
|
|
228
328
|
};
|
|
229
329
|
}
|
|
230
330
|
|