@cube-dev/ui-kit 0.162.0 → 0.164.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 +420 -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 -2
- 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 -2
- package/dist/components/actions/use-anchored-menu.js.map +1 -1
- package/dist/components/actions/use-context-menu.js +1 -2
- package/dist/components/actions/use-context-menu.js.map +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 +28 -28
- package/dist/components/content/Text.js +1 -1
- package/dist/components/content/TextItem/TextItem.js +1 -1
- package/dist/components/content/Title.js +1 -1
- package/dist/components/content/Tree/Tree.js +1 -1
- package/dist/components/content/Tree/TreeNode.js +1 -1
- package/dist/components/content/Tree/styled.js +1 -1
- package/dist/components/content/Tree/tree-index.js +1 -1
- package/dist/components/content/Tree/use-checkbox-tree.js +1 -1
- package/dist/components/content/Tree/use-load-data.js +1 -1
- package/dist/components/content/highlightText.js +1 -1
- package/dist/components/content/use-auto-tooltip.js +1 -1
- package/dist/components/data/DataTable/DataTable.js +1 -1
- package/dist/components/data/ItemTable/ItemTable.js +1 -1
- package/dist/components/data/ItemTable/ItemTableBulkBar.js +1 -1
- package/dist/components/data/ItemTable/ItemTableDragPreview.js +1 -1
- package/dist/components/data/ItemTable/ItemTableFooter.js +1 -1
- package/dist/components/data/ItemTable/ItemTableToolbar.js +1 -2
- package/dist/components/data/ItemTable/ItemTableToolbar.js.map +1 -1
- package/dist/components/data/TableBase/ColumnResizer.js +1 -1
- package/dist/components/data/TableBase/RowCollection.js +1 -1
- package/dist/components/data/TableBase/TableHeaderCell.js +1 -1
- package/dist/components/data/TableBase/TableRow.js +1 -1
- package/dist/components/data/TableBase/TableView.js +2 -2
- 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/row-menu.js +1 -1
- package/dist/components/data/TableBase/styled.js +1 -1
- package/dist/components/data/TableBase/types.js +1 -1
- package/dist/components/data/TableBase/use-cell-selection.js +0 -0
- package/dist/components/data/TableBase/use-column-order.js +1 -1
- package/dist/components/data/TableBase/use-container-width.js +1 -1
- package/dist/components/data/TableBase/use-row-move-animation.js +1 -1
- package/dist/components/data/TableBase/use-scrollability.js +1 -1
- package/dist/components/data/TableBase/use-table-columns.js +1 -1
- package/dist/components/data/TableBase/use-table-search.js +1 -1
- package/dist/components/data/TableBase/use-table-selection.js +1 -1
- package/dist/components/data/TableBase/use-table-sort.js +1 -1
- package/dist/components/data/TableBase/use-table-sorts.js +1 -1
- package/dist/components/data/TableBase/use-table-storage.js +1 -1
- package/dist/components/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 +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 -2
- package/dist/components/fields/FilterListBox/FilterListBox.js.map +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.js +1 -2
- 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 -4
- package/dist/components/fields/ListBoxPopover/ListBoxPopover.js.map +1 -1
- package/dist/components/fields/ListBoxPopover/listNavigation.js +1 -1
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.js +1 -1
- package/dist/components/fields/NumberInput/NumberInput.js +1 -1
- package/dist/components/fields/NumberInput/StepButton.js +1 -1
- package/dist/components/fields/PasswordInput/PasswordInput.js +9 -6
- package/dist/components/fields/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/components/fields/Picker/Picker.js +1 -3
- package/dist/components/fields/Picker/Picker.js.map +1 -1
- package/dist/components/fields/RadioGroup/Radio.d.ts +31 -9
- package/dist/components/fields/RadioGroup/Radio.js +57 -14
- package/dist/components/fields/RadioGroup/Radio.js.map +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 -4
- 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 +1 -1
- package/dist/components/fields/TextInput/TextInput.js +1 -1
- package/dist/components/fields/TextInput/TextInputBase.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/fields/color/ColorPanel.js +1 -1
- package/dist/components/fields/color/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 +35 -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 +183 -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 +17 -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 +57 -9
- 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 -2
- package/dist/components/navigation/Tabs/TabPicker.js.map +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.js +1 -1
- package/dist/components/overlays/Modal/OpenTransitionContext.js +1 -1
- package/dist/components/overlays/Modal/Overlay.js +1 -2
- package/dist/components/overlays/Modal/Overlay.js.map +1 -1
- package/dist/components/overlays/Modal/Popover.js +1 -1
- package/dist/components/overlays/Modal/Tray.js +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +1 -1
- package/dist/components/overlays/Notifications/NotificationCard.js +1 -1
- package/dist/components/overlays/Notifications/NotificationContext.js +1 -1
- package/dist/components/overlays/Notifications/NotificationItem.js +1 -1
- package/dist/components/overlays/Notifications/OverlayContainer.js +1 -2
- package/dist/components/overlays/Notifications/OverlayContainer.js.map +1 -1
- package/dist/components/overlays/Notifications/OverlayProvider.js +1 -1
- package/dist/components/overlays/Notifications/PersistentNotificationsList.js +1 -1
- package/dist/components/overlays/Notifications/dismissed-storage.js +1 -1
- package/dist/components/overlays/Notifications/format-relative-time.js +1 -1
- package/dist/components/overlays/Notifications/index.js +1 -1
- package/dist/components/overlays/Notifications/use-notification-state.js +1 -1
- package/dist/components/overlays/Notifications/use-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-overlay-timers.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-state.js +1 -1
- package/dist/components/overlays/Notifications/use-toast-state.js +1 -1
- package/dist/components/overlays/Toast/ToastItem.js +1 -1
- package/dist/components/overlays/Toast/index.js +1 -1
- package/dist/components/overlays/Toast/useProgressToast.js +1 -1
- package/dist/components/overlays/Toast/useToast.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipProvider.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipTrigger.js +1 -1
- package/dist/components/overlays/Tooltip/context.js +1 -1
- package/dist/components/portal/Portal.js +1 -1
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +1 -1
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/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 +247 -47
- package/dist/data/item-themes.js.map +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/eslint-plugin/defaults.generated.js +2022 -1970
- package/dist/eslint-plugin/defaults.generated.js.map +1 -1
- package/dist/eslint-plugin/index.d.ts +6 -0
- package/dist/eslint-plugin/index.js +9 -5
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/eslint-plugin/rules/no-redundant-default-prop.d.ts +17 -0
- package/dist/eslint-plugin/rules/no-redundant-default-prop.js +17 -11
- package/dist/eslint-plugin/rules/no-redundant-default-prop.js.map +1 -1
- package/dist/eslint-plugin/types.d.ts +22 -3
- package/dist/i18n/I18nProvider.js +1 -1
- package/dist/i18n/createFormatter.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/instance.js +1 -1
- package/dist/i18n/locales/de-DE/uikit.js +1 -1
- package/dist/i18n/locales/en-US/uikit.js +1 -1
- package/dist/i18n/locales/es-ES/uikit.js +1 -1
- package/dist/i18n/locales/es-MX/uikit.js +1 -1
- package/dist/i18n/locales/fr-FR/uikit.js +1 -1
- package/dist/i18n/locales/it-IT/uikit.js +1 -1
- package/dist/i18n/locales/ja-JP/uikit.js +1 -1
- package/dist/i18n/locales/nb-NO/uikit.js +1 -1
- package/dist/i18n/locales/pt-BR/uikit.js +1 -1
- package/dist/i18n/locales/pt-PT/uikit.js +1 -1
- package/dist/i18n/locales/sv-SE/uikit.js +1 -1
- package/dist/i18n/locales/vi-VN/uikit.js +1 -1
- package/dist/i18n/locales.js +1 -1
- package/dist/i18n/useFormatter.js +1 -1
- package/dist/i18n/useI18n.js +1 -1
- package/dist/icons/AdjustmentsHorizontalIcon.js +1 -1
- package/dist/icons/AdjustmentsIcon.js +1 -1
- package/dist/icons/AiIcon.js +1 -1
- package/dist/icons/AreaChartIcon.js +1 -1
- package/dist/icons/ArrowNarrowDownIcon.js +1 -1
- package/dist/icons/ArrowNarrowUpIcon.js +1 -1
- package/dist/icons/BackwardIcon.js +1 -1
- package/dist/icons/BarChartIcon.js +1 -1
- package/dist/icons/BellFilledIcon.js +1 -1
- package/dist/icons/BellIcon.js +1 -1
- package/dist/icons/BooleanIcon.js +1 -1
- package/dist/icons/CalendarEditIcon.js +1 -1
- package/dist/icons/CalendarIcon.js +1 -1
- package/dist/icons/CaretDownIcon.js +1 -1
- package/dist/icons/CaretUpIcon.js +1 -1
- package/dist/icons/ChartAreaStackedIcon.js +1 -1
- package/dist/icons/ChartAreaStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBarGroupedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarGroupedIcon.js +1 -1
- package/dist/icons/ChartBarHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarLineIcon.js +1 -1
- package/dist/icons/ChartBarStackedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBoxPlot2Icon.js +1 -1
- package/dist/icons/ChartBoxPlotIcon.js +1 -1
- package/dist/icons/ChartBubbleIcon.js +1 -1
- package/dist/icons/ChartDonut2Icon.js +1 -1
- package/dist/icons/ChartFunnelIcon.js +1 -1
- package/dist/icons/ChartHeatmapIcon.js +1 -1
- package/dist/icons/ChartKPIIcon.js +1 -1
- package/dist/icons/ChartPie2Icon.js +1 -1
- package/dist/icons/ChartScatterIcon.js +1 -1
- package/dist/icons/CheckCircleFilledIcon.js +1 -1
- package/dist/icons/CheckCircleIcon.js +1 -1
- package/dist/icons/CheckIcon.js +1 -1
- package/dist/icons/CircleFilledIcon.js +1 -1
- package/dist/icons/ClearIcon.js +1 -1
- package/dist/icons/CloseCircleFilledIcon.js +1 -1
- package/dist/icons/CloseCircleIcon.js +1 -1
- package/dist/icons/CloseIcon.js +1 -1
- package/dist/icons/CodeIcon.js +1 -1
- package/dist/icons/ColumnTotalIcon.js +1 -1
- package/dist/icons/CopyIcon.js +1 -1
- package/dist/icons/CountIcon.js +1 -1
- package/dist/icons/CubeIcon.js +1 -1
- package/dist/icons/CubePauseIcon.js +1 -1
- package/dist/icons/CubePlayIcon.js +1 -1
- package/dist/icons/CurrencyDollarIcon.js +1 -1
- package/dist/icons/DangerIcon.js +1 -1
- package/dist/icons/DashboardIcon.js +1 -1
- package/dist/icons/DatabaseIcon.js +1 -1
- package/dist/icons/DecimalDecreaseIcon.js +1 -1
- package/dist/icons/DecimalIncreaseIcon.js +1 -1
- package/dist/icons/DirectionIcon.js +1 -1
- package/dist/icons/DonutIcon.js +1 -1
- package/dist/icons/DownIcon.js +1 -1
- package/dist/icons/EditIcon.js +1 -1
- package/dist/icons/ExclamationCircleFilledIcon.js +1 -1
- package/dist/icons/ExclamationCircleIcon.js +1 -1
- package/dist/icons/ExclamationIcon.js +1 -1
- package/dist/icons/EyeIcon.js +1 -1
- package/dist/icons/EyeInvisibleIcon.js +1 -1
- package/dist/icons/FilterIcon.js +1 -1
- package/dist/icons/FolderFilledIcon.js +1 -1
- package/dist/icons/FolderIcon.js +1 -1
- package/dist/icons/FolderOpenFilledIcon.js +1 -1
- package/dist/icons/FolderOpenIcon.js +1 -1
- package/dist/icons/ForwardIcon.js +1 -1
- package/dist/icons/GripVerticalIcon.js +1 -1
- package/dist/icons/HierarchyIcon.js +1 -1
- package/dist/icons/HierarchyOpenIcon.js +1 -1
- package/dist/icons/Icon.js +1 -1
- package/dist/icons/InfoCircleIcon.js +1 -1
- package/dist/icons/InfoIcon.js +1 -1
- package/dist/icons/KeyIcon.js +1 -1
- package/dist/icons/LeftIcon.js +1 -1
- package/dist/icons/LineChartIcon.js +1 -1
- package/dist/icons/LoadingIcon.js +1 -1
- package/dist/icons/LockFilledIcon.js +1 -1
- package/dist/icons/LockIcon.js +1 -1
- package/dist/icons/MoreIcon.js +1 -1
- package/dist/icons/NotAllowedIcon.js +1 -1
- package/dist/icons/Number123Icon.js +1 -1
- package/dist/icons/NumberIcon.js +1 -1
- package/dist/icons/PauseCircleFilledIcon.js +1 -1
- package/dist/icons/PauseCircleIcon.js +1 -1
- package/dist/icons/PauseIcon.js +1 -1
- package/dist/icons/PercentageIcon.js +1 -1
- package/dist/icons/PieChartIcon.js +1 -1
- package/dist/icons/PipetteIcon.js +1 -1
- package/dist/icons/PlayCircleIcon.js +1 -1
- package/dist/icons/PlayIcon.js +1 -1
- package/dist/icons/PlusIcon.js +1 -1
- package/dist/icons/ProgressBarIcon.js +1 -1
- package/dist/icons/ReloadIcon.js +1 -1
- package/dist/icons/ReportIcon.js +1 -1
- package/dist/icons/ReturnIcon.js +1 -1
- package/dist/icons/RightIcon.js +1 -1
- package/dist/icons/RowTotalsIcon.js +1 -1
- package/dist/icons/SchemeIcon.js +1 -1
- package/dist/icons/SearchIcon.js +1 -1
- package/dist/icons/SemanticQueryIcon.js +1 -1
- package/dist/icons/SettingsIcon.js +1 -1
- package/dist/icons/ShieldFilledIcon.js +1 -1
- package/dist/icons/ShieldIcon.js +1 -1
- package/dist/icons/SlashIcon.js +1 -1
- package/dist/icons/SparklesIcon.js +1 -1
- package/dist/icons/SqlIcon.js +1 -1
- package/dist/icons/StatsIcon.js +1 -1
- package/dist/icons/StopIcon.js +1 -1
- package/dist/icons/StringIcon.js +1 -1
- package/dist/icons/SubtotalsIcon.js +1 -1
- package/dist/icons/SwitchIcon.js +1 -1
- package/dist/icons/TableIcon.js +1 -1
- package/dist/icons/ThumbsDownIcon.js +1 -1
- package/dist/icons/ThumbsUpIcon.js +1 -1
- package/dist/icons/ThunderboltCrossedIcon.js +1 -1
- package/dist/icons/ThunderboltFilledIcon.js +1 -1
- package/dist/icons/ThunderboltIcon.js +1 -1
- package/dist/icons/TimeIcon.js +1 -1
- package/dist/icons/TrashIcon.js +1 -1
- package/dist/icons/UnlockIcon.js +1 -1
- package/dist/icons/UpIcon.js +1 -1
- package/dist/icons/UserGroupIcon.js +1 -1
- package/dist/icons/UserIcon.js +1 -1
- package/dist/icons/UserLockIcon.js +1 -1
- package/dist/icons/ViewIcon.js +1 -1
- package/dist/icons/WarningFilledIcon.js +1 -1
- package/dist/icons/WarningIcon.js +1 -1
- package/dist/icons/wrap-icon.js +1 -1
- package/dist/index.d.ts +8 -5
- 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/Theming.md +471 -83
- package/docs/Usage.md +37 -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/fields/ColorSwatch.md +155 -0
- package/docs/components/fields/RadioGroup.md +39 -5
- package/docs/components/layout/Board.md +20 -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 +1 -0
- package/package.json +6 -3
- package/dist/components/fields/color/ColorSwatch.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { mergeRefs } from "../../../utils/react/useCombinedRefs.js";
|
|
4
4
|
import { useDismissParentPopover } from "../../../utils/react/usePopoverSync.js";
|
|
5
5
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
6
6
|
import { DisplayTransition } from "../../helpers/DisplayTransition/DisplayTransition.js";
|
|
7
|
+
import { ITEM_RESTING_COLOR_VARIANTS, resolveItemVariant } from "../../../data/item-themes.js";
|
|
7
8
|
import { ItemActionProvider } from "../ItemActionContext.js";
|
|
8
9
|
import { useAction } from "../use-action.js";
|
|
9
10
|
import { ItemAction } from "../ItemAction/ItemAction.js";
|
|
@@ -24,49 +25,52 @@ const StyledItem = tasty(_Item, {
|
|
|
24
25
|
placeContent: "center stretch"
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
|
-
const ActionsWrapper = tasty({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
$: ">",
|
|
42
|
-
position: "absolute",
|
|
43
|
-
inset: {
|
|
44
|
-
"": "1bw 1bw auto auto",
|
|
45
|
-
"type=card": "(1bw + .5x) (1bw + .5x) auto auto"
|
|
46
|
-
},
|
|
47
|
-
display: "flex",
|
|
48
|
-
gap: "1bw",
|
|
49
|
-
placeItems: "center",
|
|
50
|
-
placeContent: "center end",
|
|
51
|
-
pointerEvents: {
|
|
52
|
-
"": "auto",
|
|
53
|
-
"!actions-shown": "none"
|
|
54
|
-
},
|
|
55
|
-
padding: "0 $side-padding",
|
|
56
|
-
height: "min ($size - 2bw)",
|
|
57
|
-
opacity: {
|
|
58
|
-
"": 1,
|
|
59
|
-
"!actions-shown": 0
|
|
60
|
-
},
|
|
61
|
-
translate: {
|
|
62
|
-
"": "0 0",
|
|
63
|
-
"!actions-shown": ".5x 0"
|
|
28
|
+
const ActionsWrapper = tasty({
|
|
29
|
+
variants: ITEM_RESTING_COLOR_VARIANTS,
|
|
30
|
+
styles: {
|
|
31
|
+
display: "grid",
|
|
32
|
+
position: "relative",
|
|
33
|
+
placeContent: "stretch",
|
|
34
|
+
placeItems: "stretch",
|
|
35
|
+
$size: {
|
|
36
|
+
"": "$size-md",
|
|
37
|
+
"size=xsmall": "$size-xs",
|
|
38
|
+
"size=small": "$size-sm",
|
|
39
|
+
"size=medium": "$size-md",
|
|
40
|
+
"size=large": "$size-lg",
|
|
41
|
+
"size=xlarge": "$size-xl"
|
|
64
42
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
43
|
+
Actions: {
|
|
44
|
+
$: ">",
|
|
45
|
+
position: "absolute",
|
|
46
|
+
inset: {
|
|
47
|
+
"": "1bw 1bw auto auto",
|
|
48
|
+
"type=card": "(1bw + .5x) (1bw + .5x) auto auto"
|
|
49
|
+
},
|
|
50
|
+
display: "flex",
|
|
51
|
+
gap: "1bw",
|
|
52
|
+
placeItems: "center",
|
|
53
|
+
placeContent: "center end",
|
|
54
|
+
pointerEvents: {
|
|
55
|
+
"": "auto",
|
|
56
|
+
"!actions-shown": "none"
|
|
57
|
+
},
|
|
58
|
+
padding: "0 $side-padding",
|
|
59
|
+
height: "min ($size - 2bw)",
|
|
60
|
+
opacity: {
|
|
61
|
+
"": 1,
|
|
62
|
+
"!actions-shown": 0
|
|
63
|
+
},
|
|
64
|
+
translate: {
|
|
65
|
+
"": "0 0",
|
|
66
|
+
"!actions-shown": ".5x 0"
|
|
67
|
+
},
|
|
68
|
+
transition: "theme, translate",
|
|
69
|
+
"$action-size": "min(max((2x + 2bw), ($size - 1x - 2bw)), (3x - 2bw))",
|
|
70
|
+
"$side-padding": "(($size - $action-size - 2bw) / 2)"
|
|
71
|
+
}
|
|
68
72
|
}
|
|
69
|
-
}
|
|
73
|
+
});
|
|
70
74
|
const ItemButton = forwardRef(function ItemButton(allProps, ref) {
|
|
71
75
|
const { mods, to, htmlType, as, type = "item", theme = "default", onPress, onPressStart: _onPressStart, onPressEnd: _onPressEnd, onPressChange: _onPressChange, onPressUp: _onPressUp, actions, size = "medium", wrapperStyles, autoHideActions = false, disableActionsFocus = false, isDisabled, isLoading = false, ...rest } = allProps;
|
|
72
76
|
const finalIsDisabled = isDisabled === true || isLoading && isDisabled !== false;
|
|
@@ -120,11 +124,16 @@ const ItemButton = forwardRef(function ItemButton(allProps, ref) {
|
|
|
120
124
|
onPress: wrappedOnPress
|
|
121
125
|
}, ref);
|
|
122
126
|
const finalMods = useMemo(() => {
|
|
123
|
-
return
|
|
127
|
+
return {
|
|
124
128
|
...mods,
|
|
125
|
-
"actions-shown": true
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
...shouldShowActions ? { "actions-shown": true } : null,
|
|
130
|
+
disabled: finalIsDisabled
|
|
131
|
+
};
|
|
132
|
+
}, [
|
|
133
|
+
mods,
|
|
134
|
+
shouldShowActions,
|
|
135
|
+
finalIsDisabled
|
|
136
|
+
]);
|
|
128
137
|
const combinedRef = useMemo(() => mergeRefs(actionProps.ref, buttonElementRef), [actionProps.ref]);
|
|
129
138
|
const button = /* @__PURE__ */ jsx(StyledItem, {
|
|
130
139
|
insideWrapper: !!actions,
|
|
@@ -142,6 +151,7 @@ const ItemButton = forwardRef(function ItemButton(allProps, ref) {
|
|
|
142
151
|
});
|
|
143
152
|
if (actions) return /* @__PURE__ */ jsxs(ActionsWrapper, {
|
|
144
153
|
...hoverProps,
|
|
154
|
+
variant: resolveItemVariant(theme, type),
|
|
145
155
|
"data-size": size,
|
|
146
156
|
"data-type": type,
|
|
147
157
|
"data-theme": theme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemButton.js","names":["Item","mergeProps"],"sources":["../../../../src/components/actions/ItemButton/ItemButton.tsx"],"sourcesContent":["import { FocusableRef, PressEvent } from '@react-types/shared';\nimport { Styles, tasty } from '@tenphi/tasty';\nimport {\n CSSProperties,\n forwardRef,\n ReactNode,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFocusWithin, useHover } from 'react-aria';\n\nimport { useEvent } from '../../../_internal';\nimport {\n mergeProps,\n mergeRefs,\n useDismissParentPopover,\n} from '../../../utils/react';\nimport { CubeItemProps, Item } from '../../content/Item';\nimport { ItemBadge } from '../../content/ItemBadge';\nimport { DisplayTransition } from '../../helpers';\nimport { CubeItemActionProps, ItemAction } from '../ItemAction';\nimport { ItemActionProvider } from '../ItemActionContext';\nimport { CubeUseActionProps, useAction } from '../use-action';\n\nexport interface CubeItemButtonProps\n extends Omit<CubeItemProps, 'size'>,\n Omit<CubeUseActionProps, 'as'> {\n actions?: ReactNode;\n size?: Omit<CubeItemProps['size'], 'inline'>;\n wrapperStyles?: Styles;\n}\n\nconst StyledItem = tasty(Item, {\n as: 'button',\n type: 'item',\n theme: 'default',\n styles: {\n recipe: 'reset button',\n placeContent: 'center stretch',\n },\n});\n\nconst ActionsWrapper = tasty({\n styles: {\n display: 'grid',\n position: 'relative',\n placeContent: 'stretch',\n placeItems: 'stretch',\n\n $size: {\n '': '$size-md',\n 'size=xsmall': '$size-xs',\n 'size=small': '$size-sm',\n 'size=medium': '$size-md',\n 'size=large': '$size-lg',\n 'size=xlarge': '$size-xl',\n },\n\n Actions: {\n $: '>',\n position: 'absolute',\n inset: {\n '': '1bw 1bw auto auto',\n 'type=card': '(1bw + .5x) (1bw + .5x) auto auto',\n },\n display: 'flex',\n gap: '1bw',\n placeItems: 'center',\n placeContent: 'center end',\n pointerEvents: {\n '': 'auto',\n '!actions-shown': 'none',\n },\n padding: '0 $side-padding',\n height: 'min ($size - 2bw)',\n opacity: {\n '': 1,\n '!actions-shown': 0,\n },\n translate: {\n '': '0 0',\n '!actions-shown': '.5x 0',\n },\n transition: 'theme, translate',\n\n // Size for the action buttons\n '$action-size': 'min(max((2x + 2bw), ($size - 1x - 2bw)), (3x - 2bw))',\n // Side padding for the button\n '$side-padding': '(($size - $action-size - 2bw) / 2)',\n },\n },\n});\n\nconst ItemButton = forwardRef(function ItemButton(\n allProps: CubeItemButtonProps,\n ref: FocusableRef<HTMLElement>,\n) {\n const {\n mods,\n to,\n htmlType,\n as,\n type = 'item',\n theme = 'default',\n onPress,\n // Extract react-aria press callbacks to prevent them from leaking to DOM via rest.\n // These are handled by useButton inside useAction.\n onPressStart: _onPressStart,\n onPressEnd: _onPressEnd,\n onPressChange: _onPressChange,\n onPressUp: _onPressUp,\n actions,\n size = 'medium',\n wrapperStyles,\n autoHideActions = false,\n disableActionsFocus = false,\n isDisabled,\n isLoading = false,\n ...rest\n } = allProps as CubeItemButtonProps & {\n as?: 'a' | 'button' | 'div' | 'span';\n };\n\n // Loading state makes the component disabled (same logic as Item)\n const finalIsDisabled =\n isDisabled === true || (isLoading && isDisabled !== false);\n\n const actionsRef = useRef<HTMLDivElement>(null);\n const [actionsWidth, setActionsWidth] = useState(0);\n const [areActionsVisible, setAreActionsVisible] = useState(false);\n const [areActionsShown, setAreActionsShown] = useState(false);\n\n useLayoutEffect(() => {\n if (actions && actionsRef.current) {\n const width = Math.round(actionsRef.current.offsetWidth);\n if (width !== actionsWidth) {\n setActionsWidth(width);\n }\n }\n }, [actions, areActionsVisible]);\n\n const [isFocusWithin, setIsFocusWithin] = useState(false);\n const [hasPressed, setHasPressed] = useState(false);\n const { hoverProps, isHovered } = useHover({});\n const { focusWithinProps } = useFocusWithin({\n onFocusWithinChange: setIsFocusWithin,\n });\n\n // Watch for data-pressed attribute on any descendant element\n useLayoutEffect(() => {\n const actionsEl = actionsRef.current;\n\n if (!actionsEl || !autoHideActions) return;\n\n const checkPressed = () => {\n setHasPressed(actionsEl.querySelector('[data-pressed]') !== null);\n };\n\n const observer = new MutationObserver(checkPressed);\n\n observer.observe(actionsEl, {\n attributes: true,\n attributeFilter: ['data-pressed'],\n subtree: true,\n });\n\n checkPressed();\n\n return () => observer.disconnect();\n }, [areActionsVisible, autoHideActions]);\n\n const shouldShowActions =\n isHovered || isFocusWithin || hasPressed || !autoHideActions;\n\n // Default: pressing an ItemButton inside an open popover closes that\n // popover. Opt-outs: `data-popover-trigger` on self (applied by\n // FilterPicker / Picker / Select / MenuTrigger for their own triggers) and\n // `data-popover-keep` on self or any ancestor. Modals don't subscribe.\n const dismissParentPopover = useDismissParentPopover();\n const buttonElementRef = useRef<HTMLElement | null>(null);\n\n const wrappedOnPress = useEvent((e: PressEvent) => {\n onPress?.(e);\n const el = buttonElementRef.current;\n if (!el) return;\n if (el.hasAttribute('data-popover-trigger')) return;\n if (el.closest('[data-popover-keep]')) return;\n dismissParentPopover(el);\n });\n\n const { actionProps } = useAction(\n {\n ...(allProps as any),\n htmlType,\n to,\n as,\n mods,\n isDisabled: finalIsDisabled,\n onPress: wrappedOnPress,\n },\n ref,\n );\n\n const finalMods = useMemo(() => {\n return shouldShowActions ? { ...mods, 'actions-shown': true } : mods;\n }, [mods, shouldShowActions]);\n\n // Merge the useAction-supplied ref with our internal ref so the dismiss\n // wrapper can read the rendered DOM node at press time.\n const combinedRef = useMemo(\n () => mergeRefs(actionProps.ref as any, buttonElementRef),\n [actionProps.ref],\n );\n\n const button = (\n <StyledItem\n insideWrapper={!!actions}\n showActions={shouldShowActions}\n actions={actions ? true : undefined}\n {...(mergeProps(rest, actionProps) as any)}\n ref={combinedRef}\n data-popover-dismiss=\"\"\n htmlType={actionProps.type}\n type={type}\n theme={theme}\n size={size}\n isLoading={isLoading}\n isDisabled={isDisabled}\n />\n );\n\n if (actions) {\n return (\n <ActionsWrapper\n {...hoverProps}\n data-size={size}\n data-type={type}\n data-theme={theme}\n mods={finalMods}\n styles={wrapperStyles}\n style={\n {\n '--actions-width':\n areActionsVisible || !autoHideActions\n ? `${actionsWidth}px`\n : '0px',\n ...(typeof size === 'number' && { '--size': `${size}px` }),\n } as CSSProperties\n }\n >\n {button}\n <ItemActionProvider\n type={type}\n theme={theme}\n disableActionsFocus={disableActionsFocus}\n isDisabled={finalIsDisabled}\n >\n {autoHideActions ? (\n <DisplayTransition\n exposeUnmounted\n isShown={shouldShowActions}\n onPhaseChange={(phase) => {\n setAreActionsVisible(phase !== 'unmounted');\n }}\n onToggle={(isShown) => {\n setAreActionsShown(isShown);\n }}\n >\n {({ ref: transitionRef }) => {\n return (\n <div\n {...focusWithinProps}\n ref={(node: any) => {\n actionsRef.current = node;\n transitionRef(node);\n }}\n data-element=\"Actions\"\n >\n {actions}\n </div>\n );\n }}\n </DisplayTransition>\n ) : (\n <div ref={actionsRef} data-element=\"Actions\">\n {actions}\n </div>\n )}\n </ItemActionProvider>\n </ActionsWrapper>\n );\n }\n\n return button;\n});\n\nconst _ItemButton = Object.assign(ItemButton, {\n Action: ItemAction,\n Badge: ItemBadge,\n});\n\nexport { _ItemButton as ItemButton };\nexport type {\n CubeItemButtonProps as ItemButtonProps,\n CubeItemActionProps as ItemActionProps,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,MAAM,aAAa,MAAMA,OAAM;CAC7B,IAAI;CACJ,MAAM;CACN,OAAO;CACP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BAAqB;EACrB,UAAU,YAAY;EAChB;EACC;EACD;EACK;EACC;GACZ;AAGJ,KAAI,QACF,QACE,qBAAC;EACC,GAAI;EACJ,aAAW;EACX,aAAW;EACX,cAAY;EACZ,MAAM;EACN,QAAQ;EACR,OACE;GACE,mBACE,qBAAqB,CAAC,kBAClB,GAAG,aAAa,MAChB;GACN,GAAI,OAAO,SAAS,YAAY,EAAE,UAAU,GAAG,KAAK,KAAK;GAC1D;aAGF,QACD,oBAAC;GACO;GACC;GACc;GACrB,YAAY;aAEX,kBACC,oBAAC;IACC;IACA,SAAS;IACT,gBAAgB,UAAU;AACxB,0BAAqB,UAAU,YAAY;;IAE7C,WAAW,YAAY;AACrB,wBAAmB,QAAQ;;eAG3B,EAAE,KAAK,oBAAoB;AAC3B,YACE,oBAAC;MACC,GAAI;MACJ,MAAM,SAAc;AAClB,kBAAW,UAAU;AACrB,qBAAc,KAAK;;MAErB,gBAAa;gBAEZ;OACG;;KAGQ,GAEpB,oBAAC;IAAI,KAAK;IAAY,gBAAa;cAChC;KACG;IAEW;GACN;AAIrB,QAAO;EACP;AAEF,MAAM,cAAc,OAAO,OAAO,YAAY;CAC5C,QAAQ;CACR,OAAO;CACR,CAAC"}
|
|
1
|
+
{"version":3,"file":"ItemButton.js","names":["Item","mergeProps"],"sources":["../../../../src/components/actions/ItemButton/ItemButton.tsx"],"sourcesContent":["import { FocusableRef, PressEvent } from '@react-types/shared';\nimport { Styles, tasty } from '@tenphi/tasty';\nimport {\n CSSProperties,\n forwardRef,\n ReactNode,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFocusWithin, useHover } from 'react-aria';\n\nimport { useEvent } from '../../../_internal';\nimport {\n ITEM_RESTING_COLOR_VARIANTS,\n resolveItemVariant,\n} from '../../../data/item-themes';\nimport {\n mergeProps,\n mergeRefs,\n useDismissParentPopover,\n} from '../../../utils/react';\nimport { CubeItemProps, Item } from '../../content/Item';\nimport { ItemBadge } from '../../content/ItemBadge';\nimport { DisplayTransition } from '../../helpers';\nimport { CubeItemActionProps, ItemAction } from '../ItemAction';\nimport { ItemActionProvider } from '../ItemActionContext';\nimport { CubeUseActionProps, useAction } from '../use-action';\n\nexport interface CubeItemButtonProps\n extends Omit<CubeItemProps, 'size'>,\n Omit<CubeUseActionProps, 'as'> {\n actions?: ReactNode;\n size?: Omit<CubeItemProps['size'], 'inline'>;\n wrapperStyles?: Styles;\n}\n\nconst StyledItem = tasty(Item, {\n as: 'button',\n type: 'item',\n theme: 'default',\n styles: {\n recipe: 'reset button',\n placeContent: 'center stretch',\n },\n});\n\nconst ActionsWrapper = tasty({\n // Actions default to the `current` type, which paints from the inherited\n // `currentcolor` — but they are rendered as a SIBLING of the button here, not\n // inside it, so without this they would inherit the page color instead of the\n // row's. Harmless on the default theme (the two match) and plainly wrong on\n // any other: a `special` row would hand its actions the page's dark text to\n // tint with, on a dark purple surface. The variant carries the row's resting\n // color down so `currentcolor` means the same thing it does inside an `Item`.\n variants: ITEM_RESTING_COLOR_VARIANTS,\n styles: {\n display: 'grid',\n position: 'relative',\n placeContent: 'stretch',\n placeItems: 'stretch',\n\n $size: {\n '': '$size-md',\n 'size=xsmall': '$size-xs',\n 'size=small': '$size-sm',\n 'size=medium': '$size-md',\n 'size=large': '$size-lg',\n 'size=xlarge': '$size-xl',\n },\n\n Actions: {\n $: '>',\n position: 'absolute',\n inset: {\n '': '1bw 1bw auto auto',\n 'type=card': '(1bw + .5x) (1bw + .5x) auto auto',\n },\n display: 'flex',\n gap: '1bw',\n placeItems: 'center',\n placeContent: 'center end',\n pointerEvents: {\n '': 'auto',\n '!actions-shown': 'none',\n },\n padding: '0 $side-padding',\n height: 'min ($size - 2bw)',\n opacity: {\n '': 1,\n '!actions-shown': 0,\n },\n translate: {\n '': '0 0',\n '!actions-shown': '.5x 0',\n },\n transition: 'theme, translate',\n\n // Size for the action buttons\n '$action-size': 'min(max((2x + 2bw), ($size - 1x - 2bw)), (3x - 2bw))',\n // Side padding for the button\n '$side-padding': '(($size - $action-size - 2bw) / 2)',\n },\n },\n});\n\nconst ItemButton = forwardRef(function ItemButton(\n allProps: CubeItemButtonProps,\n ref: FocusableRef<HTMLElement>,\n) {\n const {\n mods,\n to,\n htmlType,\n as,\n type = 'item',\n theme = 'default',\n onPress,\n // Extract react-aria press callbacks to prevent them from leaking to DOM via rest.\n // These are handled by useButton inside useAction.\n onPressStart: _onPressStart,\n onPressEnd: _onPressEnd,\n onPressChange: _onPressChange,\n onPressUp: _onPressUp,\n actions,\n size = 'medium',\n wrapperStyles,\n autoHideActions = false,\n disableActionsFocus = false,\n isDisabled,\n isLoading = false,\n ...rest\n } = allProps as CubeItemButtonProps & {\n as?: 'a' | 'button' | 'div' | 'span';\n };\n\n // Loading state makes the component disabled (same logic as Item)\n const finalIsDisabled =\n isDisabled === true || (isLoading && isDisabled !== false);\n\n const actionsRef = useRef<HTMLDivElement>(null);\n const [actionsWidth, setActionsWidth] = useState(0);\n const [areActionsVisible, setAreActionsVisible] = useState(false);\n const [areActionsShown, setAreActionsShown] = useState(false);\n\n useLayoutEffect(() => {\n if (actions && actionsRef.current) {\n const width = Math.round(actionsRef.current.offsetWidth);\n if (width !== actionsWidth) {\n setActionsWidth(width);\n }\n }\n }, [actions, areActionsVisible]);\n\n const [isFocusWithin, setIsFocusWithin] = useState(false);\n const [hasPressed, setHasPressed] = useState(false);\n const { hoverProps, isHovered } = useHover({});\n const { focusWithinProps } = useFocusWithin({\n onFocusWithinChange: setIsFocusWithin,\n });\n\n // Watch for data-pressed attribute on any descendant element\n useLayoutEffect(() => {\n const actionsEl = actionsRef.current;\n\n if (!actionsEl || !autoHideActions) return;\n\n const checkPressed = () => {\n setHasPressed(actionsEl.querySelector('[data-pressed]') !== null);\n };\n\n const observer = new MutationObserver(checkPressed);\n\n observer.observe(actionsEl, {\n attributes: true,\n attributeFilter: ['data-pressed'],\n subtree: true,\n });\n\n checkPressed();\n\n return () => observer.disconnect();\n }, [areActionsVisible, autoHideActions]);\n\n const shouldShowActions =\n isHovered || isFocusWithin || hasPressed || !autoHideActions;\n\n // Default: pressing an ItemButton inside an open popover closes that\n // popover. Opt-outs: `data-popover-trigger` on self (applied by\n // FilterPicker / Picker / Select / MenuTrigger for their own triggers) and\n // `data-popover-keep` on self or any ancestor. Modals don't subscribe.\n const dismissParentPopover = useDismissParentPopover();\n const buttonElementRef = useRef<HTMLElement | null>(null);\n\n const wrappedOnPress = useEvent((e: PressEvent) => {\n onPress?.(e);\n const el = buttonElementRef.current;\n if (!el) return;\n if (el.hasAttribute('data-popover-trigger')) return;\n if (el.closest('[data-popover-keep]')) return;\n dismissParentPopover(el);\n });\n\n const { actionProps } = useAction(\n {\n ...(allProps as any),\n htmlType,\n to,\n as,\n mods,\n isDisabled: finalIsDisabled,\n onPress: wrappedOnPress,\n },\n ref,\n );\n\n // `disabled` is on the wrapper so its variant can paint the row's DISABLED\n // label color, not just the resting one. Actions default to the `current` type\n // and suppress their own fade when the disabled state is inherited — on the\n // grounds that the host already faded the color they paint from — so without\n // this the wrapper would hand them a full-strength color and a disabled button\n // would sit next to full-strength actions. See `ITEM_RESTING_COLOR_VARIANTS`.\n const finalMods = useMemo(() => {\n return {\n ...mods,\n ...(shouldShowActions ? { 'actions-shown': true } : null),\n disabled: finalIsDisabled,\n };\n }, [mods, shouldShowActions, finalIsDisabled]);\n\n // Merge the useAction-supplied ref with our internal ref so the dismiss\n // wrapper can read the rendered DOM node at press time.\n const combinedRef = useMemo(\n () => mergeRefs(actionProps.ref as any, buttonElementRef),\n [actionProps.ref],\n );\n\n const button = (\n <StyledItem\n insideWrapper={!!actions}\n showActions={shouldShowActions}\n actions={actions ? true : undefined}\n {...(mergeProps(rest, actionProps) as any)}\n ref={combinedRef}\n data-popover-dismiss=\"\"\n htmlType={actionProps.type}\n type={type}\n theme={theme}\n size={size}\n isLoading={isLoading}\n isDisabled={isDisabled}\n />\n );\n\n if (actions) {\n return (\n <ActionsWrapper\n {...hoverProps}\n // The same resolver `Item` uses, so the wrapper cannot land on a\n // different variant than the row it wraps.\n variant={resolveItemVariant(theme, type)}\n data-size={size}\n data-type={type}\n data-theme={theme}\n mods={finalMods}\n styles={wrapperStyles}\n style={\n {\n '--actions-width':\n areActionsVisible || !autoHideActions\n ? `${actionsWidth}px`\n : '0px',\n ...(typeof size === 'number' && { '--size': `${size}px` }),\n } as CSSProperties\n }\n >\n {button}\n <ItemActionProvider\n type={type}\n theme={theme}\n disableActionsFocus={disableActionsFocus}\n isDisabled={finalIsDisabled}\n >\n {autoHideActions ? (\n <DisplayTransition\n exposeUnmounted\n isShown={shouldShowActions}\n onPhaseChange={(phase) => {\n setAreActionsVisible(phase !== 'unmounted');\n }}\n onToggle={(isShown) => {\n setAreActionsShown(isShown);\n }}\n >\n {({ ref: transitionRef }) => {\n return (\n <div\n {...focusWithinProps}\n ref={(node: any) => {\n actionsRef.current = node;\n transitionRef(node);\n }}\n data-element=\"Actions\"\n >\n {actions}\n </div>\n );\n }}\n </DisplayTransition>\n ) : (\n <div ref={actionsRef} data-element=\"Actions\">\n {actions}\n </div>\n )}\n </ItemActionProvider>\n </ActionsWrapper>\n );\n }\n\n return button;\n});\n\nconst _ItemButton = Object.assign(ItemButton, {\n Action: ItemAction,\n Badge: ItemBadge,\n});\n\nexport { _ItemButton as ItemButton };\nexport type {\n CubeItemButtonProps as ItemButtonProps,\n CubeItemActionProps as ItemActionProps,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsCA,MAAM,aAAa,MAAMA,OAAM;CAC7B,IAAI;CACJ,MAAM;CACN,OAAO;CACP,QAAQ;EACN,QAAQ;EACR,cAAc;EACf;CACF,CAAC;AAEF,MAAM,iBAAiB,MAAM;CAQ3B,UAAU;CACV,QAAQ;EACN,SAAS;EACT,UAAU;EACV,cAAc;EACd,YAAY;EAEZ,OAAO;GACL,IAAI;GACJ,eAAe;GACf,cAAc;GACd,eAAe;GACf,cAAc;GACd,eAAe;GAChB;EAED,SAAS;GACP,GAAG;GACH,UAAU;GACV,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,kBAClB,GAAG,aAAa,MAChB;GACN,GAAI,OAAO,SAAS,YAAY,EAAE,UAAU,GAAG,KAAK,KAAK;GAC1D;aAGF,QACD,oBAAC;GACO;GACC;GACc;GACrB,YAAY;aAEX,kBACC,oBAAC;IACC;IACA,SAAS;IACT,gBAAgB,UAAU;AACxB,0BAAqB,UAAU,YAAY;;IAE7C,WAAW,YAAY;AACrB,wBAAmB,QAAQ;;eAG3B,EAAE,KAAK,oBAAoB;AAC3B,YACE,oBAAC;MACC,GAAI;MACJ,MAAM,SAAc;AAClB,kBAAW,UAAU;AACrB,qBAAc,KAAK;;MAErB,gBAAa;gBAEZ;OACG;;KAGQ,GAEpB,oBAAC;IAAI,KAAK;IAAY,gBAAa;cAChC;KACG;IAEW;GACN;AAIrB,QAAO;EACP;AAEF,MAAM,cAAc,OAAO,OAAO,YAAY;CAC5C,QAAQ;CACR,OAAO;CACR,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { _CollectionItem } from "../../CollectionItem.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { filterCollectionItemProps } from "../../CollectionItem.js";
|
|
4
4
|
import { _Item } from "../../content/Item/Item.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { TooltipProvider } from "../../overlays/Tooltip/TooltipProvider.js";
|
|
3
3
|
import { MenuItem } from "./MenuItem.js";
|
|
4
4
|
import { StyledMenu, StyledSection, StyledSectionHeading } from "./styled.js";
|
|
@@ -10,6 +10,19 @@ type CubeMenuTriggerProps = AriaMenuTriggerProps$1 & PositionProps & {
|
|
|
10
10
|
children: [ReactElement | ((state: MenuTriggerState) => ReactElement), ReactElement];
|
|
11
11
|
closeOnSelect?: boolean;
|
|
12
12
|
isDummy?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether focus returns to the trigger when the menu closes. Defaults to
|
|
15
|
+
* `true`.
|
|
16
|
+
*
|
|
17
|
+
* The restore is skipped automatically whenever the action that closed the
|
|
18
|
+
* menu has already moved focus somewhere else, so an item that opens a
|
|
19
|
+
* panel/dialog/inline editor and focuses it needs nothing here. Pass
|
|
20
|
+
* `false` for the remaining case: a surface that claims focus *later* than
|
|
21
|
+
* the menu's own restore (after an async load, an entry animation, or a
|
|
22
|
+
* `requestAnimationFrame`), where the trigger would otherwise take focus
|
|
23
|
+
* first and produce a visible flash.
|
|
24
|
+
*/
|
|
25
|
+
shouldRestoreFocus?: boolean;
|
|
13
26
|
/**
|
|
14
27
|
* External ref to the popover container element. When provided, it is
|
|
15
28
|
* aliased to the internal `menuPopoverRef`, letting consumers (e.g.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { SlotProvider } from "../../../utils/react/Slots.js";
|
|
3
3
|
import { usePopoverSync } from "../../../utils/react/usePopoverSync.js";
|
|
4
4
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
@@ -18,12 +18,13 @@ import { PressResponder } from "@react-aria/interactions";
|
|
|
18
18
|
function MenuTrigger(props, ref) {
|
|
19
19
|
const internalPopoverRef = useRef(null);
|
|
20
20
|
const menuPopoverRef = props.popoverRef ?? internalPopoverRef;
|
|
21
|
+
const trayRef = useRef(null);
|
|
21
22
|
const triggerRef = useRef(null);
|
|
22
23
|
const domRef = useObjectRef(ref);
|
|
23
24
|
const menuTriggerRef = props.targetRef || domRef || triggerRef;
|
|
24
25
|
const menuRef = useRef(null);
|
|
25
26
|
const wasOpenRef = useRef(false);
|
|
26
|
-
const { children, shouldFlip = true, closeOnSelect, trigger = "press", isDisabled, isDummy, mobileType = "popover" } = props;
|
|
27
|
+
const { children, shouldFlip = true, closeOnSelect, trigger = "press", isDisabled, isDummy, mobileType = "popover", shouldRestoreFocus = true } = props;
|
|
27
28
|
const menuId = useMemo(() => generateRandomId(), []);
|
|
28
29
|
if (!Array.isArray(children) || children.length > 2) throw new Error("MenuTrigger must have exactly 2 children");
|
|
29
30
|
let [menuTrigger, menu] = children;
|
|
@@ -36,18 +37,6 @@ function MenuTrigger(props, ref) {
|
|
|
36
37
|
triggerRef: menuTriggerRef,
|
|
37
38
|
containerRef: menuPopoverRef
|
|
38
39
|
});
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (!state.isOpen && wasOpenRef.current && !isDummy) {
|
|
41
|
-
wasOpenRef.current = false;
|
|
42
|
-
setTimeout(() => {
|
|
43
|
-
menuTriggerRef.current?.focus();
|
|
44
|
-
}, 0);
|
|
45
|
-
} else if (state.isOpen) wasOpenRef.current = true;
|
|
46
|
-
}, [
|
|
47
|
-
state.isOpen,
|
|
48
|
-
menuTriggerRef,
|
|
49
|
-
isDummy
|
|
50
|
-
]);
|
|
51
40
|
if (typeof menuTrigger === "function") menuTrigger = menuTrigger(state);
|
|
52
41
|
const { menuTriggerProps, menuProps } = useMenuTrigger({ isDisabled }, state, menuTriggerRef);
|
|
53
42
|
let initialPlacement = props.placement ?? "bottom start";
|
|
@@ -65,6 +54,28 @@ function MenuTrigger(props, ref) {
|
|
|
65
54
|
offset: props.offset ?? 8,
|
|
66
55
|
crossOffset: props.crossOffset ?? 0
|
|
67
56
|
});
|
|
57
|
+
const hasFocusMovedOutsideMenu = useEvent(() => {
|
|
58
|
+
const activeElement = document.activeElement;
|
|
59
|
+
if (!activeElement || activeElement === document.body) return false;
|
|
60
|
+
if (!activeElement.isConnected) return false;
|
|
61
|
+
return !((isTray ? trayRef.current : menuPopoverRef.current)?.contains(activeElement) || menuRef.current?.contains(activeElement) || menuTriggerRef.current?.contains(activeElement));
|
|
62
|
+
});
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!state.isOpen && wasOpenRef.current && !isDummy) {
|
|
65
|
+
wasOpenRef.current = false;
|
|
66
|
+
if (!shouldRestoreFocus) return;
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
if (hasFocusMovedOutsideMenu()) return;
|
|
69
|
+
menuTriggerRef.current?.focus();
|
|
70
|
+
}, 0);
|
|
71
|
+
} else if (state.isOpen) wasOpenRef.current = true;
|
|
72
|
+
}, [
|
|
73
|
+
state.isOpen,
|
|
74
|
+
menuTriggerRef,
|
|
75
|
+
isDummy,
|
|
76
|
+
shouldRestoreFocus,
|
|
77
|
+
hasFocusMovedOutsideMenu
|
|
78
|
+
]);
|
|
68
79
|
const menuContext = {
|
|
69
80
|
...menuProps,
|
|
70
81
|
ref: menuRef,
|
|
@@ -82,7 +93,7 @@ function MenuTrigger(props, ref) {
|
|
|
82
93
|
isClosing: !state.isOpen
|
|
83
94
|
};
|
|
84
95
|
const contents = /* @__PURE__ */ jsxs(FocusScope, {
|
|
85
|
-
restoreFocus:
|
|
96
|
+
restoreFocus: shouldRestoreFocus,
|
|
86
97
|
children: [
|
|
87
98
|
/* @__PURE__ */ jsx(DismissButton, { onDismiss: state.close }),
|
|
88
99
|
menu,
|
|
@@ -106,6 +117,7 @@ function MenuTrigger(props, ref) {
|
|
|
106
117
|
});
|
|
107
118
|
let overlay;
|
|
108
119
|
if (isTray) overlay = /* @__PURE__ */ jsx(_Tray, {
|
|
120
|
+
ref: trayRef,
|
|
109
121
|
isOpen: state.isOpen,
|
|
110
122
|
shouldCloseOnInteractOutside,
|
|
111
123
|
onClose: state.close,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuTrigger.js","names":["Tray","Popover"],"sources":["../../../../src/components/actions/Menu/MenuTrigger.tsx"],"sourcesContent":["import { PressResponder } from '@react-aria/interactions';\nimport { useObjectRef } from '@react-aria/utils';\nimport { useIsMobileDevice } from '@react-spectrum/utils';\nimport {\n forwardRef,\n Fragment,\n MutableRefObject,\n ReactElement,\n Ref,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport {\n AriaMenuTriggerProps,\n DismissButton,\n FocusScope,\n Placement,\n PositionProps,\n useMenuTrigger,\n useOverlayPosition,\n} from 'react-aria';\nimport { MenuTriggerState, useMenuTriggerState } from 'react-stately';\n\nimport { useEvent } from '../../../_internal';\nimport { generateRandomId } from '../../../utils/random';\nimport { SlotProvider } from '../../../utils/react';\nimport { usePopoverSync } from '../../../utils/react/usePopoverSync';\nimport { Popover, Tray } from '../../overlays/Modal';\n\nimport { MenuContext, MenuContextValue } from './context';\n\nexport type { AriaMenuTriggerProps };\n\nexport type CubeMenuTriggerProps = AriaMenuTriggerProps &\n PositionProps & {\n isDisabled?: boolean;\n children: [\n ReactElement | ((state: MenuTriggerState) => ReactElement),\n ReactElement,\n ];\n\n closeOnSelect?: boolean;\n isDummy?: boolean;\n /**\n * External ref to the popover container element. When provided, it is\n * aliased to the internal `menuPopoverRef`, letting consumers (e.g.\n * `useAnchoredMenu` / `useContextMenu`) feed the popover container into\n * their own `usePopoverSync` so the nested-popover guard can recognize\n * submenus opened inside this menu. Optional.\n */\n popoverRef?: MutableRefObject<HTMLDivElement | null>;\n /**\n * Overlay variant to use on mobile screens. Defaults to `'popover'`, which\n * keeps the desktop overlay even on small viewports. Pass `'tray'` to opt\n * into the bottom-sheet `Tray` overlay on mobile (the previous implicit\n * default). Mirrors the `mobileType` API on `DialogTrigger`.\n */\n mobileType?: 'popover' | 'tray';\n };\n\nfunction MenuTrigger(props: CubeMenuTriggerProps, ref: Ref<HTMLElement>) {\n const internalPopoverRef = useRef<HTMLDivElement>(null);\n const menuPopoverRef = props.popoverRef ?? internalPopoverRef;\n const triggerRef = useRef<HTMLElement>(null);\n const domRef = useObjectRef(ref);\n const menuTriggerRef = props.targetRef || domRef || triggerRef;\n const menuRef = useRef<HTMLUListElement>(null);\n const wasOpenRef = useRef(false);\n const {\n children,\n shouldFlip = true,\n closeOnSelect,\n trigger = 'press',\n isDisabled,\n isDummy,\n mobileType = 'popover',\n } = props;\n\n // Generate a unique ID for this menu instance\n const menuId = useMemo(() => generateRandomId(), []);\n\n if (!Array.isArray(children) || children.length > 2) {\n throw new Error('MenuTrigger must have exactly 2 children');\n }\n\n let [menuTrigger, menu] = children;\n const state: MenuTriggerState = useMenuTriggerState(props);\n\n usePopoverSync({\n menuId,\n isOpen: state.isOpen,\n onClose: () => state.close(),\n enabled: !isDummy,\n triggerRef: menuTriggerRef,\n containerRef: menuPopoverRef,\n });\n\n // Restore focus manually when the menu closes\n useEffect(() => {\n if (!state.isOpen && wasOpenRef.current && !isDummy) {\n wasOpenRef.current = false;\n // Use setTimeout to ensure focus restoration happens after any animations\n setTimeout(() => {\n menuTriggerRef.current?.focus();\n }, 0);\n } else if (state.isOpen) {\n wasOpenRef.current = true;\n }\n }, [state.isOpen, menuTriggerRef, isDummy]);\n\n if (typeof menuTrigger === 'function') {\n menuTrigger = (menuTrigger as CubeMenuTriggerProps['children'][0])(state);\n }\n\n const { menuTriggerProps, menuProps } = useMenuTrigger(\n { isDisabled },\n state,\n menuTriggerRef,\n );\n\n let initialPlacement: Placement = props.placement ?? 'bottom start';\n\n // Tray rendering is now opt-in via `mobileType=\"tray\"` (matches DialogTrigger).\n // Without that opt-in, MenuTrigger always renders a Popover so that environments\n // like jsdom (where `window.screen.width === 0` makes useIsMobileDevice() true)\n // don't accidentally swap in the tray overlay.\n const isMobileDevice = useIsMobileDevice();\n const isTray = mobileType === 'tray' && isMobileDevice;\n const { overlayProps: positionProps, placement } = useOverlayPosition({\n targetRef: menuTriggerRef,\n overlayRef: menuPopoverRef,\n scrollRef: menuRef,\n placement: initialPlacement,\n shouldFlip: shouldFlip,\n isOpen: state.isOpen && !isTray,\n onClose: state.close,\n containerPadding: props.containerPadding,\n offset: props.offset ?? 8,\n crossOffset: props.crossOffset ?? 0,\n });\n\n const menuContext = {\n ...menuProps,\n ref: menuRef,\n onClose: state.close,\n closeOnSelect,\n autoFocus: (state.focusStrategy as any) ?? 'first',\n style: isTray\n ? {\n width: '100%',\n maxHeight: 'inherit',\n }\n : undefined,\n mods: {\n popover: !isTray,\n tray: isTray,\n },\n isClosing: !state.isOpen,\n } as MenuContextValue;\n\n // Wrap in a FocusScope so the menu popover registers as a child of any\n // outer contained FocusScope (e.g. a parent Dialog/Popover). Without this,\n // when the menu opens inside an outer contained FocusScope, the outer\n // scope rejects focus moving into the menu items (which live in a portal\n // and would otherwise belong to no scope) and yanks focus back to the\n // menu trigger.\n const contents = (\n <FocusScope restoreFocus>\n <DismissButton onDismiss={state.close} />\n {menu}\n <DismissButton onDismiss={state.close} />\n </FocusScope>\n );\n\n // Shared between the Popover and Tray branches so both react-aria\n // `useOverlay` calls see the same predicate. Without this, the Tray branch\n // falls back to unconditional dismiss-on-outside-interaction, which\n // `useOverlay` translates into stopPropagation/preventDefault in the\n // capture phase — that swallows clicks on sibling triggers (see Menu\n // rapid-open test).\n //\n // `useEvent` gives us a single stable callback reference for the lifetime\n // of the component while always reading the latest closure values. This\n // matters because `useMenuTriggerState` returns a fresh `state` object on\n // every render, so a vanilla `useCallback([..., state])` would produce a\n // new function every render and defeat any stability guarantees consumers\n // rely on.\n const shouldCloseOnInteractOutside = useEvent((el: Element) => {\n // While `Popover` is animating out, `useInteractOutside`'s capture-phase\n // listener is still attached (jsdom 29+ uses pointerdown/click capture).\n // The animation lasts ~350ms; without this guard, clicks on a sibling\n // trigger during the exit window get stopPropagation()'d and the\n // sibling's `onClick` never runs — breaking rapid-open and \"open menu\n // again with new props\" flows. Reading `state.isOpen` directly is safe\n // because `useEvent` always sees the latest closure.\n if (!state.isOpen) return false;\n\n const menuTriggerEl = el.closest('[data-popover-trigger]');\n if (!menuTriggerEl) {\n if (el.closest('[data-popover-keep]')) return false;\n // Plain interactive controls (Button, ItemButton) opt in via\n // `data-popover-dismiss`. We schedule the close via setTimeout(0) so\n // it lands AFTER the click event finishes — the button's onPress\n // fires first, then the popover closes. Without this, useOverlay\n // would stopPropagation() the click and the user would need a second\n // click to actually press the button.\n if (el.closest('[data-popover-dismiss]')) {\n setTimeout(() => state.close(), 0);\n return false;\n }\n return true;\n }\n if (\n isDummy &&\n (menuTriggerEl === menuTriggerRef.current ||\n menuTriggerRef.current?.contains(el))\n ) {\n return true;\n }\n if (menuTriggerEl === menuTriggerRef.current) return true;\n return false;\n });\n\n let overlay;\n if (isTray) {\n overlay = (\n <Tray\n isOpen={state.isOpen}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n onClose={state.close}\n >\n {contents}\n </Tray>\n );\n } else {\n overlay = (\n <Popover\n ref={menuPopoverRef}\n hideArrow\n isNonModal\n isOpen={state.isOpen}\n style={positionProps.style}\n placement={placement}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n onClose={state.close}\n >\n {contents}\n </Popover>\n );\n }\n\n return (\n <Fragment>\n <SlotProvider\n slots={{ actionButton: { holdAffordance: trigger === 'longPress' } }}\n >\n {!isDummy ? (\n <PressResponder\n {...menuTriggerProps}\n ref={menuTriggerRef}\n data-popover-trigger\n isPressed={state.isOpen}\n >\n {menuTrigger}\n </PressResponder>\n ) : null}\n </SlotProvider>\n <MenuContext.Provider value={menuContext}>{overlay}</MenuContext.Provider>\n </Fragment>\n );\n}\n\n/**\n * The MenuTrigger serves as a wrapper around a Menu and its associated trigger,\n * linking the Menu's open state with the trigger's press state.\n */\nlet _MenuTrigger = forwardRef(MenuTrigger);\n\n_MenuTrigger.displayName = 'MenuTrigger';\n\nexport { _MenuTrigger as MenuTrigger };\n"],"mappings":";;;;;;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BAAC,YAAY;EAAS,OAAO;YAAc;GAA+B,IACjE;;;;;;AAQf,IAAI,eAAe,WAAW,YAAY;AAE1C,aAAa,cAAc"}
|
|
1
|
+
{"version":3,"file":"MenuTrigger.js","names":["Tray","Popover"],"sources":["../../../../src/components/actions/Menu/MenuTrigger.tsx"],"sourcesContent":["import { PressResponder } from '@react-aria/interactions';\nimport { useObjectRef } from '@react-aria/utils';\nimport { useIsMobileDevice } from '@react-spectrum/utils';\nimport {\n forwardRef,\n Fragment,\n MutableRefObject,\n ReactElement,\n Ref,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport {\n AriaMenuTriggerProps,\n DismissButton,\n FocusScope,\n Placement,\n PositionProps,\n useMenuTrigger,\n useOverlayPosition,\n} from 'react-aria';\nimport { MenuTriggerState, useMenuTriggerState } from 'react-stately';\n\nimport { useEvent } from '../../../_internal';\nimport { generateRandomId } from '../../../utils/random';\nimport { SlotProvider } from '../../../utils/react';\nimport { usePopoverSync } from '../../../utils/react/usePopoverSync';\nimport { Popover, Tray } from '../../overlays/Modal';\n\nimport { MenuContext, MenuContextValue } from './context';\n\nexport type { AriaMenuTriggerProps };\n\nexport type CubeMenuTriggerProps = AriaMenuTriggerProps &\n PositionProps & {\n isDisabled?: boolean;\n children: [\n ReactElement | ((state: MenuTriggerState) => ReactElement),\n ReactElement,\n ];\n\n closeOnSelect?: boolean;\n isDummy?: boolean;\n /**\n * Whether focus returns to the trigger when the menu closes. Defaults to\n * `true`.\n *\n * The restore is skipped automatically whenever the action that closed the\n * menu has already moved focus somewhere else, so an item that opens a\n * panel/dialog/inline editor and focuses it needs nothing here. Pass\n * `false` for the remaining case: a surface that claims focus *later* than\n * the menu's own restore (after an async load, an entry animation, or a\n * `requestAnimationFrame`), where the trigger would otherwise take focus\n * first and produce a visible flash.\n */\n shouldRestoreFocus?: boolean;\n /**\n * External ref to the popover container element. When provided, it is\n * aliased to the internal `menuPopoverRef`, letting consumers (e.g.\n * `useAnchoredMenu` / `useContextMenu`) feed the popover container into\n * their own `usePopoverSync` so the nested-popover guard can recognize\n * submenus opened inside this menu. Optional.\n */\n popoverRef?: MutableRefObject<HTMLDivElement | null>;\n /**\n * Overlay variant to use on mobile screens. Defaults to `'popover'`, which\n * keeps the desktop overlay even on small viewports. Pass `'tray'` to opt\n * into the bottom-sheet `Tray` overlay on mobile (the previous implicit\n * default). Mirrors the `mobileType` API on `DialogTrigger`.\n */\n mobileType?: 'popover' | 'tray';\n };\n\nfunction MenuTrigger(props: CubeMenuTriggerProps, ref: Ref<HTMLElement>) {\n const internalPopoverRef = useRef<HTMLDivElement>(null);\n const menuPopoverRef = props.popoverRef ?? internalPopoverRef;\n const trayRef = useRef<HTMLElement>(null);\n const triggerRef = useRef<HTMLElement>(null);\n const domRef = useObjectRef(ref);\n const menuTriggerRef = props.targetRef || domRef || triggerRef;\n const menuRef = useRef<HTMLUListElement>(null);\n const wasOpenRef = useRef(false);\n const {\n children,\n shouldFlip = true,\n closeOnSelect,\n trigger = 'press',\n isDisabled,\n isDummy,\n mobileType = 'popover',\n shouldRestoreFocus = true,\n } = props;\n\n // Generate a unique ID for this menu instance\n const menuId = useMemo(() => generateRandomId(), []);\n\n if (!Array.isArray(children) || children.length > 2) {\n throw new Error('MenuTrigger must have exactly 2 children');\n }\n\n let [menuTrigger, menu] = children;\n const state: MenuTriggerState = useMenuTriggerState(props);\n\n usePopoverSync({\n menuId,\n isOpen: state.isOpen,\n onClose: () => state.close(),\n enabled: !isDummy,\n triggerRef: menuTriggerRef,\n containerRef: menuPopoverRef,\n });\n\n if (typeof menuTrigger === 'function') {\n menuTrigger = (menuTrigger as CubeMenuTriggerProps['children'][0])(state);\n }\n\n const { menuTriggerProps, menuProps } = useMenuTrigger(\n { isDisabled },\n state,\n menuTriggerRef,\n );\n\n let initialPlacement: Placement = props.placement ?? 'bottom start';\n\n // Tray rendering is now opt-in via `mobileType=\"tray\"` (matches DialogTrigger).\n // Without that opt-in, MenuTrigger always renders a Popover so that environments\n // like jsdom (where `window.screen.width === 0` makes useIsMobileDevice() true)\n // don't accidentally swap in the tray overlay.\n const isMobileDevice = useIsMobileDevice();\n const isTray = mobileType === 'tray' && isMobileDevice;\n const { overlayProps: positionProps, placement } = useOverlayPosition({\n targetRef: menuTriggerRef,\n overlayRef: menuPopoverRef,\n scrollRef: menuRef,\n placement: initialPlacement,\n shouldFlip: shouldFlip,\n isOpen: state.isOpen && !isTray,\n onClose: state.close,\n containerPadding: props.containerPadding,\n offset: props.offset ?? 8,\n crossOffset: props.crossOffset ?? 0,\n });\n\n // Whether focus has been claimed by something outside the closing menu —\n // the signal that a menu action handed focus off and the trigger must not\n // take it back.\n //\n // Focus still inside the menu overlay means nobody claimed it: the pressed\n // item keeps focus while the popover plays its ~350ms exit animation. Focus\n // on `<body>` (or on a detached element) means the focused node went away\n // with the menu. Both are cases where the trigger is where focus belongs.\n const hasFocusMovedOutsideMenu = useEvent(() => {\n const activeElement = document.activeElement;\n\n if (!activeElement || activeElement === document.body) return false;\n if (!activeElement.isConnected) return false;\n\n // `menuPopoverRef` is only wired to the `Popover` branch, so the overlay\n // container is `trayRef` when `mobileType=\"tray\"` is in effect.\n const overlay = isTray ? trayRef.current : menuPopoverRef.current;\n\n return !(\n overlay?.contains(activeElement) ||\n menuRef.current?.contains(activeElement) ||\n menuTriggerRef.current?.contains(activeElement)\n );\n });\n\n // Restore focus manually when the menu closes\n useEffect(() => {\n if (!state.isOpen && wasOpenRef.current && !isDummy) {\n wasOpenRef.current = false;\n\n if (!shouldRestoreFocus) return;\n\n // Use setTimeout to ensure focus restoration happens after any animations\n setTimeout(() => {\n // An action that opened a panel, a dialog or an inline editor has\n // already focused it by now — taking focus back to the trigger would\n // undo the hand-off, which consumers previously had to out-race by\n // re-focusing on every animation frame (CUB-3962).\n if (hasFocusMovedOutsideMenu()) return;\n\n menuTriggerRef.current?.focus();\n }, 0);\n } else if (state.isOpen) {\n wasOpenRef.current = true;\n }\n }, [\n state.isOpen,\n menuTriggerRef,\n isDummy,\n shouldRestoreFocus,\n hasFocusMovedOutsideMenu,\n ]);\n\n const menuContext = {\n ...menuProps,\n ref: menuRef,\n onClose: state.close,\n closeOnSelect,\n autoFocus: (state.focusStrategy as any) ?? 'first',\n style: isTray\n ? {\n width: '100%',\n maxHeight: 'inherit',\n }\n : undefined,\n mods: {\n popover: !isTray,\n tray: isTray,\n },\n isClosing: !state.isOpen,\n } as MenuContextValue;\n\n // Wrap in a FocusScope so the menu popover registers as a child of any\n // outer contained FocusScope (e.g. a parent Dialog/Popover). Without this,\n // when the menu opens inside an outer contained FocusScope, the outer\n // scope rejects focus moving into the menu items (which live in a portal\n // and would otherwise belong to no scope) and yanks focus back to the\n // menu trigger.\n //\n // `restoreFocus` follows `shouldRestoreFocus`, so opting out silences the\n // scope's own unmount restore too. Scope registration (and therefore the\n // guarantee above) is unaffected — `FocusScope` joins the tree and tracks\n // the active scope regardless of `restoreFocus`.\n const contents = (\n <FocusScope restoreFocus={shouldRestoreFocus}>\n <DismissButton onDismiss={state.close} />\n {menu}\n <DismissButton onDismiss={state.close} />\n </FocusScope>\n );\n\n // Shared between the Popover and Tray branches so both react-aria\n // `useOverlay` calls see the same predicate. Without this, the Tray branch\n // falls back to unconditional dismiss-on-outside-interaction, which\n // `useOverlay` translates into stopPropagation/preventDefault in the\n // capture phase — that swallows clicks on sibling triggers (see Menu\n // rapid-open test).\n //\n // `useEvent` gives us a single stable callback reference for the lifetime\n // of the component while always reading the latest closure values. This\n // matters because `useMenuTriggerState` returns a fresh `state` object on\n // every render, so a vanilla `useCallback([..., state])` would produce a\n // new function every render and defeat any stability guarantees consumers\n // rely on.\n const shouldCloseOnInteractOutside = useEvent((el: Element) => {\n // While `Popover` is animating out, `useInteractOutside`'s capture-phase\n // listener is still attached (jsdom 29+ uses pointerdown/click capture).\n // The animation lasts ~350ms; without this guard, clicks on a sibling\n // trigger during the exit window get stopPropagation()'d and the\n // sibling's `onClick` never runs — breaking rapid-open and \"open menu\n // again with new props\" flows. Reading `state.isOpen` directly is safe\n // because `useEvent` always sees the latest closure.\n if (!state.isOpen) return false;\n\n const menuTriggerEl = el.closest('[data-popover-trigger]');\n if (!menuTriggerEl) {\n if (el.closest('[data-popover-keep]')) return false;\n // Plain interactive controls (Button, ItemButton) opt in via\n // `data-popover-dismiss`. We schedule the close via setTimeout(0) so\n // it lands AFTER the click event finishes — the button's onPress\n // fires first, then the popover closes. Without this, useOverlay\n // would stopPropagation() the click and the user would need a second\n // click to actually press the button.\n if (el.closest('[data-popover-dismiss]')) {\n setTimeout(() => state.close(), 0);\n return false;\n }\n return true;\n }\n if (\n isDummy &&\n (menuTriggerEl === menuTriggerRef.current ||\n menuTriggerRef.current?.contains(el))\n ) {\n return true;\n }\n if (menuTriggerEl === menuTriggerRef.current) return true;\n return false;\n });\n\n let overlay;\n if (isTray) {\n overlay = (\n <Tray\n ref={trayRef}\n isOpen={state.isOpen}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n onClose={state.close}\n >\n {contents}\n </Tray>\n );\n } else {\n overlay = (\n <Popover\n ref={menuPopoverRef}\n hideArrow\n isNonModal\n isOpen={state.isOpen}\n style={positionProps.style}\n placement={placement}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n onClose={state.close}\n >\n {contents}\n </Popover>\n );\n }\n\n return (\n <Fragment>\n <SlotProvider\n slots={{ actionButton: { holdAffordance: trigger === 'longPress' } }}\n >\n {!isDummy ? (\n <PressResponder\n {...menuTriggerProps}\n ref={menuTriggerRef}\n data-popover-trigger\n isPressed={state.isOpen}\n >\n {menuTrigger}\n </PressResponder>\n ) : null}\n </SlotProvider>\n <MenuContext.Provider value={menuContext}>{overlay}</MenuContext.Provider>\n </Fragment>\n );\n}\n\n/**\n * The MenuTrigger serves as a wrapper around a Menu and its associated trigger,\n * linking the Menu's open state with the trigger's press state.\n */\nlet _MenuTrigger = forwardRef(MenuTrigger);\n\n_MenuTrigger.displayName = 'MenuTrigger';\n\nexport { _MenuTrigger as MenuTrigger };\n"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AAO;GACP;CAEF,IAAI;AACJ,KAAI,OACF,WACE,oBAACA;EACC,KAAK;EACL,QAAQ,MAAM;EACgB;EAC9B,SAAS,MAAM;YAEd;GACI;KAGT,WACE,oBAACC;EACC,KAAK;EACL;EACA;EACA,QAAQ,MAAM;EACd,OAAO,cAAc;EACV;EACmB;EAC9B,SAAS,MAAM;YAEd;GACO;AAId,QACE,qBAAC,uBACC,oBAAC;EACC,OAAO,EAAE,cAAc,EAAE,gBAAgB,YAAY,aAAa,EAAE;YAEnE,CAAC,UACA,oBAAC;GACC,GAAI;GACJ,KAAK;GACL;GACA,WAAW,MAAM;aAEhB;IACc,GACf;GACS,EACf,oBAAC,YAAY;EAAS,OAAO;YAAc;GAA+B,IACjE;;;;;;AAQf,IAAI,eAAe,WAAW,YAAY;AAE1C,aAAa,cAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { usePopoverSync } from "../../../utils/react/usePopoverSync.js";
|
|
3
3
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
4
4
|
import { MenuContext, useMenuContext } from "./context.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { DEFAULT_CLEAR_STYLES } from "../../../data/item-themes.js";
|
|
3
3
|
import { Space } from "../../layout/Space.js";
|
|
4
4
|
import { DEFAULT_BUTTON_STYLES } from "../Button/Button.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { ItemActionProvider, useItemActionContext } from "./ItemActionContext.js";
|
|
3
3
|
import { openLink, parseTo, performClickHandler, useAction } from "./use-action.js";
|
|
4
4
|
import { ItemAction } from "./ItemAction/ItemAction.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../utils/react/mergeProps.js";
|
|
3
3
|
import { useEvent } from "../../_internal/hooks/use-event.js";
|
|
4
4
|
import { useFocus as useFocus$1 } from "../../utils/react/interactions.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../utils/react/mergeProps.js";
|
|
3
3
|
import { usePopoverSync } from "../../utils/react/usePopoverSync.js";
|
|
4
4
|
import { useEvent } from "../../_internal/hooks/use-event.js";
|
|
@@ -69,7 +69,6 @@ function useAnchoredMenu(Component, defaultTriggerProps, defaultMenuProps) {
|
|
|
69
69
|
const renderedMenu = useMemo(() => {
|
|
70
70
|
if (!componentProps) return null;
|
|
71
71
|
return /* @__PURE__ */ jsxs(_MenuTrigger, {
|
|
72
|
-
placement: "bottom start",
|
|
73
72
|
...mergeProps$1(defaultTriggerProps, triggerProps || void 0),
|
|
74
73
|
isDummy: true,
|
|
75
74
|
isOpen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-anchored-menu.js","names":["MenuTrigger","mergeProps"],"sources":["../../../src/components/actions/use-anchored-menu.tsx"],"sourcesContent":["import { Pressable } from '@react-aria/interactions';\nimport {\n ComponentProps,\n ComponentType,\n ReactElement,\n RefObject,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { VisuallyHidden } from 'react-aria';\n\nimport { useEvent } from '../../_internal';\nimport { useI18n } from '../../i18n';\nimport { generateRandomId } from '../../utils/random';\nimport { mergeProps } from '../../utils/react';\nimport { usePopoverSync } from '../../utils/react/usePopoverSync';\n\nimport { MenuTrigger } from './Menu';\n\nexport interface UseAnchoredMenuReturn<P, T> {\n /** Ref to attach to the anchor element for positioning the menu. */\n anchorRef: RefObject<HTMLElement | null>;\n\n /**\n * Programmatically opens the menu with the provided props.\n * @param props - Props to pass to the menu component\n * @param triggerProps - Additional props for MenuTrigger (merged with defaultTriggerProps)\n */\n open(props?: P, triggerProps?: T): void;\n\n /**\n * Updates the props of the currently open menu.\n * Props are merged if defaults are provided.\n */\n update(props: P, triggerProps?: T): void;\n\n /** Closes the menu programmatically. */\n close(): void;\n\n /** Current open/closed state of the menu. */\n isOpen: boolean;\n\n /**\n * JSX element that must be rendered in your component tree.\n * Contains the MenuTrigger and positioning logic.\n */\n get rendered(): ReactElement | null;\n}\n\n/**\n * Generic hook to manage an anchored menu component.\n *\n * @param Component - A React component that represents the menu content (Menu or CommandMenu).\n * @param defaultTriggerProps - Default props to pass to the MenuTrigger.\n * @param defaultMenuProps - Default props to pass to the Menu component.\n * @returns An object with `anchorRef` to position the menu, `open` function to open the menu with provided props, `close` function to close the menu, and `rendered` JSX element to include in your component tree.\n */\nexport function useAnchoredMenu<P, T = ComponentProps<typeof MenuTrigger>>(\n Component: ComponentType<P>,\n defaultTriggerProps?: Omit<\n ComponentProps<typeof MenuTrigger>,\n 'children' | 'isOpen' | 'onOpenChange' | 'targetRef'\n >,\n defaultMenuProps?: P,\n): UseAnchoredMenuReturn<P, T> {\n const { t } = useI18n();\n const [isOpen, setIsOpen] = useState(false);\n const [componentProps, setComponentProps] = useState<P | null>(null);\n const [triggerProps, setTriggerProps] = useState<T | null>(null);\n const anchorRef = useRef<HTMLElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const setupRef = useRef(false);\n\n useEffect(() => {\n const el = anchorRef.current;\n if (el) {\n el.dataset.popoverTrigger = '';\n return () => {\n delete el.dataset.popoverTrigger;\n };\n }\n }, []);\n\n // Generate a unique ID for this menu instance\n const menuId = useMemo(() => generateRandomId(), []);\n\n // Feed both the anchor (`triggerRef`) and the popover container\n // (`containerRef`) into the sync. The container ref is shared with the\n // rendered `MenuTrigger` via its `popoverRef` prop — the dummy `MenuTrigger`\n // opts out of `usePopoverSync` (`enabled: !isDummy`), so without this the\n // nested-popover guard would have no container to match against and a\n // `SubMenuTrigger` opened inside this menu would close the whole menu.\n usePopoverSync({\n menuId,\n isOpen,\n onClose: () => setIsOpen(false),\n triggerRef: anchorRef,\n containerRef: popoverRef,\n });\n\n function setupCheck() {\n if (!setupRef.current) {\n throw new Error(\n 'useAnchoredMenu: MenuTrigger must be rendered. Use `rendered` property to include it in your component tree.',\n );\n }\n }\n\n // 'open' accepts props required by the Component and opens the menu\n const open = useEvent((props: P = {} as P, triggerProps?: T) => {\n setupCheck();\n\n // Merge defaultMenuProps with provided props\n const finalProps = defaultMenuProps\n ? { ...defaultMenuProps, ...props }\n : props;\n\n setComponentProps(finalProps);\n setTriggerProps(triggerProps ?? null);\n setIsOpen(true);\n });\n\n const update = useEvent((props: P, triggerProps?: T) => {\n setupCheck();\n\n // Merge defaultMenuProps with provided props\n const finalProps = defaultMenuProps\n ? { ...defaultMenuProps, ...props }\n : props;\n\n setComponentProps(finalProps);\n setTriggerProps(triggerProps ?? null);\n });\n\n const close = useEvent(() => {\n setIsOpen(false);\n });\n\n // Render the menu only when componentProps is set\n const renderedMenu = useMemo(() => {\n if (!componentProps) return null;\n\n return (\n <MenuTrigger\n
|
|
1
|
+
{"version":3,"file":"use-anchored-menu.js","names":["MenuTrigger","mergeProps"],"sources":["../../../src/components/actions/use-anchored-menu.tsx"],"sourcesContent":["import { Pressable } from '@react-aria/interactions';\nimport {\n ComponentProps,\n ComponentType,\n ReactElement,\n RefObject,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { VisuallyHidden } from 'react-aria';\n\nimport { useEvent } from '../../_internal';\nimport { useI18n } from '../../i18n';\nimport { generateRandomId } from '../../utils/random';\nimport { mergeProps } from '../../utils/react';\nimport { usePopoverSync } from '../../utils/react/usePopoverSync';\n\nimport { MenuTrigger } from './Menu';\n\nexport interface UseAnchoredMenuReturn<P, T> {\n /** Ref to attach to the anchor element for positioning the menu. */\n anchorRef: RefObject<HTMLElement | null>;\n\n /**\n * Programmatically opens the menu with the provided props.\n * @param props - Props to pass to the menu component\n * @param triggerProps - Additional props for MenuTrigger (merged with defaultTriggerProps)\n */\n open(props?: P, triggerProps?: T): void;\n\n /**\n * Updates the props of the currently open menu.\n * Props are merged if defaults are provided.\n */\n update(props: P, triggerProps?: T): void;\n\n /** Closes the menu programmatically. */\n close(): void;\n\n /** Current open/closed state of the menu. */\n isOpen: boolean;\n\n /**\n * JSX element that must be rendered in your component tree.\n * Contains the MenuTrigger and positioning logic.\n */\n get rendered(): ReactElement | null;\n}\n\n/**\n * Generic hook to manage an anchored menu component.\n *\n * @param Component - A React component that represents the menu content (Menu or CommandMenu).\n * @param defaultTriggerProps - Default props to pass to the MenuTrigger.\n * @param defaultMenuProps - Default props to pass to the Menu component.\n * @returns An object with `anchorRef` to position the menu, `open` function to open the menu with provided props, `close` function to close the menu, and `rendered` JSX element to include in your component tree.\n */\nexport function useAnchoredMenu<P, T = ComponentProps<typeof MenuTrigger>>(\n Component: ComponentType<P>,\n defaultTriggerProps?: Omit<\n ComponentProps<typeof MenuTrigger>,\n 'children' | 'isOpen' | 'onOpenChange' | 'targetRef'\n >,\n defaultMenuProps?: P,\n): UseAnchoredMenuReturn<P, T> {\n const { t } = useI18n();\n const [isOpen, setIsOpen] = useState(false);\n const [componentProps, setComponentProps] = useState<P | null>(null);\n const [triggerProps, setTriggerProps] = useState<T | null>(null);\n const anchorRef = useRef<HTMLElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const setupRef = useRef(false);\n\n useEffect(() => {\n const el = anchorRef.current;\n if (el) {\n el.dataset.popoverTrigger = '';\n return () => {\n delete el.dataset.popoverTrigger;\n };\n }\n }, []);\n\n // Generate a unique ID for this menu instance\n const menuId = useMemo(() => generateRandomId(), []);\n\n // Feed both the anchor (`triggerRef`) and the popover container\n // (`containerRef`) into the sync. The container ref is shared with the\n // rendered `MenuTrigger` via its `popoverRef` prop — the dummy `MenuTrigger`\n // opts out of `usePopoverSync` (`enabled: !isDummy`), so without this the\n // nested-popover guard would have no container to match against and a\n // `SubMenuTrigger` opened inside this menu would close the whole menu.\n usePopoverSync({\n menuId,\n isOpen,\n onClose: () => setIsOpen(false),\n triggerRef: anchorRef,\n containerRef: popoverRef,\n });\n\n function setupCheck() {\n if (!setupRef.current) {\n throw new Error(\n 'useAnchoredMenu: MenuTrigger must be rendered. Use `rendered` property to include it in your component tree.',\n );\n }\n }\n\n // 'open' accepts props required by the Component and opens the menu\n const open = useEvent((props: P = {} as P, triggerProps?: T) => {\n setupCheck();\n\n // Merge defaultMenuProps with provided props\n const finalProps = defaultMenuProps\n ? { ...defaultMenuProps, ...props }\n : props;\n\n setComponentProps(finalProps);\n setTriggerProps(triggerProps ?? null);\n setIsOpen(true);\n });\n\n const update = useEvent((props: P, triggerProps?: T) => {\n setupCheck();\n\n // Merge defaultMenuProps with provided props\n const finalProps = defaultMenuProps\n ? { ...defaultMenuProps, ...props }\n : props;\n\n setComponentProps(finalProps);\n setTriggerProps(triggerProps ?? null);\n });\n\n const close = useEvent(() => {\n setIsOpen(false);\n });\n\n // Render the menu only when componentProps is set\n const renderedMenu = useMemo(() => {\n if (!componentProps) return null;\n\n return (\n <MenuTrigger\n {...mergeProps(defaultTriggerProps, triggerProps || undefined)}\n isDummy\n isOpen={isOpen}\n targetRef={anchorRef}\n popoverRef={popoverRef}\n onOpenChange={setIsOpen}\n >\n <VisuallyHidden>\n <Pressable>\n <button aria-label={t('contextMenu.contextMenu', 'context-menu')} />\n </Pressable>\n </VisuallyHidden>\n <Component {...componentProps} />\n </MenuTrigger>\n );\n }, [componentProps, triggerProps, isOpen, defaultTriggerProps, t]);\n\n return {\n anchorRef,\n open,\n update,\n close,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AAU;GAC9D;GACQ;GACR,WAAW;GACC;GACZ,cAAc;cAEd,oBAAC,4BACC,oBAAC,uBACC,oBAAC,YAAO,cAAY,EAAE,2BAA2B,eAAe,GAAI,GAC1D,GACG,EACjB,oBAAC,aAAU,GAAI,iBAAkB;IACrB;IAEf;EAAC;EAAgB;EAAc;EAAQ;EAAqB;EAAE,CAAC;AAElE,QAAO;EACL;EACA;EACA;EACA;EACA;EACA,IAAI,WAAW;AACb,YAAS,UAAU;AAEnB,UAAO;;EAEV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../utils/react/mergeProps.js";
|
|
3
3
|
import { usePopoverSync } from "../../utils/react/usePopoverSync.js";
|
|
4
4
|
import { useEvent } from "../../_internal/hooks/use-event.js";
|
|
@@ -149,7 +149,6 @@ function useContextMenu(Component, defaultTriggerProps, defaultMenuProps) {
|
|
|
149
149
|
})
|
|
150
150
|
}), document.body), /* @__PURE__ */ jsxs(_MenuTrigger, {
|
|
151
151
|
offset: 0,
|
|
152
|
-
crossOffset: 0,
|
|
153
152
|
placement: triggerProps?.placement || defaultTriggerProps?.placement || "bottom start",
|
|
154
153
|
...mergeProps$1(defaultTriggerProps, triggerProps || void 0),
|
|
155
154
|
isDummy: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-context-menu.js","names":["MenuTrigger","mergeProps"],"sources":["../../../src/components/actions/use-context-menu.tsx"],"sourcesContent":["import { Pressable } from '@react-aria/interactions';\nimport {\n ComponentProps,\n ComponentType,\n MouseEvent,\n PointerEvent,\n ReactElement,\n RefObject,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { VisuallyHidden } from 'react-aria';\nimport { createPortal } from 'react-dom';\n\nimport { useEvent } from '../../_internal';\nimport { useI18n } from '../../i18n';\nimport { generateRandomId } from '../../utils/random';\nimport { mergeProps } from '../../utils/react';\nimport { usePopoverSync } from '../../utils/react/usePopoverSync';\n\nimport { MenuTrigger } from './Menu';\n\ntype NativeMouseEvent = globalThis.MouseEvent;\ntype NativePointerEvent = globalThis.PointerEvent;\n\nexport interface UseContextMenuReturn<\n E extends HTMLElement = HTMLElement,\n P extends object = {},\n T = ComponentProps<typeof MenuTrigger>,\n> {\n /** Container element that receives context menu events. Attach this ref to your target element. */\n targetRef: RefObject<E | null>;\n\n /**\n * Programmatically opens the menu at the specified coordinates or element center.\n * Runtime props are merged with defaultMenuProps (runtime props take precedence).\n *\n * @param props - Props to pass to the menu component (optional, defaults to defaultMenuProps)\n * @param triggerProps - Additional props for MenuTrigger (merged with defaultTriggerProps)\n * @param event - The pointer/mouse event containing coordinates for positioning (optional, centers on element if not provided)\n */\n open(\n props?: P,\n triggerProps?: T,\n event?: NativeMouseEvent | NativePointerEvent | MouseEvent | PointerEvent,\n ): void;\n\n /**\n * Updates the props of the currently open menu without repositioning.\n * Props are merged with defaultMenuProps.\n */\n update(props: P, triggerProps?: T): void;\n\n /** Closes the menu programmatically. */\n close(): void;\n\n /** Current open/closed state of the menu. */\n isOpen: boolean;\n\n /**\n * JSX element that must be rendered in your component tree.\n * Contains the MenuTrigger and positioning logic.\n * IMPORTANT: Must be placed directly inside the target container (the element with targetRef).\n */\n get rendered(): ReactElement | null;\n}\n\n/**\n * Generic hook to manage a context menu component that opens at pointer coordinates.\n *\n * @param Component - A React component that represents the menu content (Menu or CommandMenu).\n * @param defaultTriggerProps - Default props to pass to the MenuTrigger.\n * @param defaultMenuProps - Default props to pass to the Menu component.\n * @returns An object with `targetRef` to attach to the container element, `open` function to open the menu at event coordinates, `close` function to close the menu, and `rendered` JSX element to include in your component tree.\n */\nexport function useContextMenu<\n E extends HTMLElement = HTMLElement,\n P extends object = {},\n T = ComponentProps<typeof MenuTrigger>,\n>(\n Component: ComponentType<P>,\n defaultTriggerProps?: Omit<\n ComponentProps<typeof MenuTrigger>,\n 'children' | 'isOpen' | 'onOpenChange' | 'targetRef'\n >,\n defaultMenuProps?: P,\n): UseContextMenuReturn<E, P, T> {\n const { t } = useI18n();\n const [isOpen, setIsOpen] = useState(false);\n const [componentProps, setComponentProps] = useState<P | null>(null);\n const [triggerProps, setTriggerProps] = useState<T | null>(null);\n const [anchorPosition, setAnchorPosition] = useState<{\n x: number;\n y: number;\n } | null>(null);\n const targetRef = useRef<E>(null);\n const invisibleAnchorRef = useRef<HTMLSpanElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const setupRef = useRef(false);\n\n // Mark the container as a popover trigger so that other open menus' close-on-\n // outside predicates treat clicks inside it (including programmatic\n // open buttons rendered alongside a context-menu target) as a legitimate\n // trigger interaction instead of a generic outside click. This mirrors the\n // pattern in `useAnchoredMenu`.\n useEffect(() => {\n const el = targetRef.current;\n if (el) {\n el.dataset.popoverTrigger = '';\n return () => {\n delete el.dataset.popoverTrigger;\n };\n }\n }, []);\n\n // Generate a unique ID for this menu instance\n const menuId = useMemo(() => generateRandomId(), []);\n\n // Feed both the context-menu target (`triggerRef`) and the popover\n // container (`containerRef`) into the sync. The container ref is shared with\n // the rendered `MenuTrigger` via its `popoverRef` prop — the dummy\n // `MenuTrigger` opts out of `usePopoverSync` (`enabled: !isDummy`), so\n // without this the nested-popover guard would have no container to match\n // against and a `SubMenuTrigger` opened inside this menu would close the\n // whole menu.\n usePopoverSync({\n menuId,\n isOpen,\n onClose: () => {\n setIsOpen(false);\n setAnchorPosition(null);\n },\n triggerRef: targetRef as RefObject<HTMLElement | null>,\n containerRef: popoverRef,\n });\n\n function setupCheck() {\n if (!setupRef.current) {\n throw new Error(\n 'useContextMenu: MenuTrigger must be rendered. Use `rendered` property to include it in your component tree.',\n );\n }\n }\n\n /**\n * Where to put the invisible anchor, in **viewport** coordinates.\n *\n * Viewport rather than container-relative on purpose. The anchor is rendered\n * into a fixed-position host pinned to the viewport origin (see\n * `renderedMenu`), so the two agree by construction. Computing coordinates\n * against the target element while the anchor's containing block was\n * whichever positioned ancestor happened to enclose `rendered` is what used\n * to open the menu one ancestor-origin away from the pointer.\n */\n const calculatePosition = (\n event?: NativeMouseEvent | NativePointerEvent | MouseEvent | PointerEvent,\n ) => {\n if (event) {\n const { clientX = 0, clientY = 0 } = event;\n\n return { x: clientX, y: clientY };\n }\n\n // No event — a keyboard opening, which has no coordinates. Anchor on the\n // target element's centre instead.\n const container = targetRef.current;\n\n if (!container) return { x: 0, y: 0 };\n\n const rect = container.getBoundingClientRect();\n\n return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };\n };\n\n // 'open' accepts props, trigger props, and optional event for positioning, then opens the menu\n const open = useEvent(\n (\n props: P = {} as P,\n triggerProps?: T,\n event?: NativeMouseEvent | NativePointerEvent | MouseEvent | PointerEvent,\n ) => {\n setupCheck();\n\n // Ensure the target element can serve as a positioning context for the\n // invisible target element. If the consumer hasn't explicitly set\n // `position: relative | absolute | fixed | sticky` we switch it to\n // `relative` so that absolutely-positioned children are laid out correctly.\n if (targetRef.current) {\n const computedStyle = window.getComputedStyle(targetRef.current);\n\n if (computedStyle.position === 'static') {\n targetRef.current.style.position = 'relative';\n }\n }\n\n // Prevent default context menu if it's a context menu event\n if (\n event &&\n 'preventDefault' in event &&\n typeof event.preventDefault === 'function'\n ) {\n event.preventDefault();\n }\n\n const { x, y } = calculatePosition(event);\n setAnchorPosition({ x, y });\n\n // Merge defaultMenuProps with provided props\n const finalProps = defaultMenuProps\n ? { ...defaultMenuProps, ...props }\n : props;\n\n setComponentProps(finalProps);\n setTriggerProps(triggerProps ?? null);\n setIsOpen(true);\n },\n );\n\n const update = useEvent((props: P, triggerProps?: T) => {\n setupCheck();\n\n // Merge defaultMenuProps with provided props\n const finalProps = defaultMenuProps\n ? { ...defaultMenuProps, ...props }\n : props;\n\n setComponentProps(finalProps as P);\n setTriggerProps(triggerProps ?? null);\n });\n\n const close = useEvent(() => {\n setIsOpen(false);\n setAnchorPosition(null);\n });\n\n // Context menu event handler\n const onContextMenu = useEvent(\n (event: MouseEvent | PointerEvent | MouseEvent | PointerEvent) => {\n event.preventDefault();\n if (isOpen) {\n const pos = calculatePosition(event);\n setAnchorPosition(pos);\n } else {\n open(defaultMenuProps, undefined, event);\n }\n },\n );\n\n // Bind the onContextMenu event to targetRef\n useEffect(() => {\n const element = targetRef.current;\n if (!element) return;\n\n element.addEventListener('contextmenu', onContextMenu as any);\n\n return () => {\n element.removeEventListener('contextmenu', onContextMenu as any);\n };\n }, [onContextMenu]);\n\n // Render the menu only when componentProps is set\n const renderedMenu = useMemo(() => {\n if (!componentProps || !anchorPosition) return null;\n\n return (\n <>\n {/*\n Invisible anchor at the click coordinates.\n\n Two things make those coordinates mean what they say:\n\n 1. A `fixed` host, so the containing block's origin is the viewport\n rather than whichever positioned ancestor encloses `rendered` — the\n table root, the tree row — which is what used to open the menu one\n ancestor-origin away from the pointer.\n 2. A portal to `body`, because `position: fixed` is captured by any\n ancestor carrying a transform, filter or `will-change`. A\n virtualized row is usually translated, so the `fixed` host alone\n would still be anchored to the row.\n */}\n {createPortal(\n <div\n style={{\n position: 'fixed',\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n }}\n >\n <span\n ref={invisibleAnchorRef}\n style={{\n position: 'absolute',\n left: `${anchorPosition.x}px`,\n top: `${anchorPosition.y}px`,\n width: '0px',\n height: '0px',\n lineHeight: '0',\n pointerEvents: 'none',\n visibility: 'hidden',\n }}\n />\n </div>,\n document.body,\n )}\n <MenuTrigger\n offset={0}\n crossOffset={0}\n placement={\n (triggerProps as ComponentProps<typeof MenuTrigger>)?.placement ||\n defaultTriggerProps?.placement ||\n 'bottom start'\n }\n {...mergeProps(defaultTriggerProps, triggerProps || undefined)}\n isDummy\n isOpen={isOpen}\n targetRef={invisibleAnchorRef}\n popoverRef={popoverRef}\n onOpenChange={setIsOpen}\n >\n <VisuallyHidden>\n <Pressable>\n <button\n aria-label={t(\n 'contextMenu.openContextMenu',\n 'Open context menu',\n )}\n />\n </Pressable>\n </VisuallyHidden>\n <Component {...componentProps} />\n </MenuTrigger>\n </>\n );\n }, [\n componentProps,\n triggerProps,\n isOpen,\n defaultTriggerProps,\n anchorPosition,\n t,\n ]);\n\n return {\n targetRef,\n open,\n update,\n close,\n isOpen,\n get rendered() {\n setupRef.current = true;\n\n return renderedMenu;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6EA,SAAgB,eAKd,WACA,qBAIA,kBAC+B;CAC/B,MAAM,EAAE,MAAM,SAAS;CACvB,MAAM,CAAC,QAAQ,aAAa,SAAS,MAAM;CAC3C,MAAM,CAAC,gBAAgB,qBAAqB,SAAmB,KAAK;CACpE,MAAM,CAAC,cAAc,mBAAmB,SAAmB,KAAK;CAChE,MAAM,CAAC,gBAAgB,qBAAqB,SAGlC,KAAK;CACf,MAAM,YAAY,OAAU,KAAK;CACjC,MAAM,qBAAqB,OAAwB,KAAK;CACxD,MAAM,aAAa,OAAuB,KAAK;CAC/C,MAAM,WAAW,OAAO,MAAM;AAO9B,iBAAgB;EACd,MAAM,KAAK,UAAU;AACrB,MAAI,IAAI;AACN,MAAG,QAAQ,iBAAiB;AAC5B,gBAAa;AACX,WAAO,GAAG,QAAQ;;;IAGrB,EAAE,CAAC;AAYN,gBAAe;EACb,QAVa,cAAc,kBAAkB,EAAE,EAAE,CAAC;EAWlD;EACA,eAAe;AACb,aAAU,MAAM;AAChB,qBAAkB,KAAK;;EAEzB,YAAY;EACZ,cAAc;EACf,CAAC;CAEF,SAAS,aAAa;AACpB,MAAI,CAAC,SAAS,QACZ,OAAM,IAAI,MACR,8GACD;;;;;;;;;;;;CAcL,MAAM,qBACJ,UACG;AACH,MAAI,OAAO;GACT,MAAM,EAAE,UAAU,GAAG,UAAU,MAAM;AAErC,UAAO;IAAE,GAAG;IAAS,GAAG;IAAS;;EAKnC,MAAM,YAAY,UAAU;AAE5B,MAAI,CAAC,UAAW,QAAO;GAAE,GAAG;GAAG,GAAG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AU;IACV,MAAM;IACN,KAAK;IACL,OAAO;IACP,QAAQ;IACT;aAED,oBAAC;IACC,KAAK;IACL,OAAO;KACL,UAAU;KACV,MAAM,GAAG,eAAe,EAAE;KAC1B,KAAK,GAAG,eAAe,EAAE;KACzB,OAAO;KACP,QAAQ;KACR,YAAY;KACZ,eAAe;KACf,YAAY;KACb;KACD;IACE,EACN,SAAS,KACV,EACD,qBAACA;GACC,QAAQ;GACR,aAAa;GACb,WACG,cAAqD,aACtD,qBAAqB,aACrB;GAEF,GAAIC,aAAW,qBAAqB,gBAAgB,OAAU;GAC9D;GACQ;GACR,WAAW;GACC;GACZ,cAAc;cAEd,oBAAC,4BACC,oBAAC,uBACC,oBAAC,YACC,cAAY,EACV,+BACA,oBACD,GACD,GACQ,GACG,EACjB,oBAAC,aAAU,GAAI,iBAAkB;IACrB,IACb;IAEJ;EACD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QAAO;EACL;EACA;EACA;EACA;EACA;EACA,IAAI,WAAW;AACb,YAAS,UAAU;AAEnB,UAAO;;EAEV"}
|
|
1
|
+
{"version":3,"file":"use-context-menu.js","names":["MenuTrigger","mergeProps"],"sources":["../../../src/components/actions/use-context-menu.tsx"],"sourcesContent":["import { Pressable } from '@react-aria/interactions';\nimport {\n ComponentProps,\n ComponentType,\n MouseEvent,\n PointerEvent,\n ReactElement,\n RefObject,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { VisuallyHidden } from 'react-aria';\nimport { createPortal } from 'react-dom';\n\nimport { useEvent } from '../../_internal';\nimport { useI18n } from '../../i18n';\nimport { generateRandomId } from '../../utils/random';\nimport { mergeProps } from '../../utils/react';\nimport { usePopoverSync } from '../../utils/react/usePopoverSync';\n\nimport { MenuTrigger } from './Menu';\n\ntype NativeMouseEvent = globalThis.MouseEvent;\ntype NativePointerEvent = globalThis.PointerEvent;\n\nexport interface UseContextMenuReturn<\n E extends HTMLElement = HTMLElement,\n P extends object = {},\n T = ComponentProps<typeof MenuTrigger>,\n> {\n /** Container element that receives context menu events. Attach this ref to your target element. */\n targetRef: RefObject<E | null>;\n\n /**\n * Programmatically opens the menu at the specified coordinates or element center.\n * Runtime props are merged with defaultMenuProps (runtime props take precedence).\n *\n * @param props - Props to pass to the menu component (optional, defaults to defaultMenuProps)\n * @param triggerProps - Additional props for MenuTrigger (merged with defaultTriggerProps)\n * @param event - The pointer/mouse event containing coordinates for positioning (optional, centers on element if not provided)\n */\n open(\n props?: P,\n triggerProps?: T,\n event?: NativeMouseEvent | NativePointerEvent | MouseEvent | PointerEvent,\n ): void;\n\n /**\n * Updates the props of the currently open menu without repositioning.\n * Props are merged with defaultMenuProps.\n */\n update(props: P, triggerProps?: T): void;\n\n /** Closes the menu programmatically. */\n close(): void;\n\n /** Current open/closed state of the menu. */\n isOpen: boolean;\n\n /**\n * JSX element that must be rendered in your component tree.\n * Contains the MenuTrigger and positioning logic.\n * IMPORTANT: Must be placed directly inside the target container (the element with targetRef).\n */\n get rendered(): ReactElement | null;\n}\n\n/**\n * Generic hook to manage a context menu component that opens at pointer coordinates.\n *\n * @param Component - A React component that represents the menu content (Menu or CommandMenu).\n * @param defaultTriggerProps - Default props to pass to the MenuTrigger.\n * @param defaultMenuProps - Default props to pass to the Menu component.\n * @returns An object with `targetRef` to attach to the container element, `open` function to open the menu at event coordinates, `close` function to close the menu, and `rendered` JSX element to include in your component tree.\n */\nexport function useContextMenu<\n E extends HTMLElement = HTMLElement,\n P extends object = {},\n T = ComponentProps<typeof MenuTrigger>,\n>(\n Component: ComponentType<P>,\n defaultTriggerProps?: Omit<\n ComponentProps<typeof MenuTrigger>,\n 'children' | 'isOpen' | 'onOpenChange' | 'targetRef'\n >,\n defaultMenuProps?: P,\n): UseContextMenuReturn<E, P, T> {\n const { t } = useI18n();\n const [isOpen, setIsOpen] = useState(false);\n const [componentProps, setComponentProps] = useState<P | null>(null);\n const [triggerProps, setTriggerProps] = useState<T | null>(null);\n const [anchorPosition, setAnchorPosition] = useState<{\n x: number;\n y: number;\n } | null>(null);\n const targetRef = useRef<E>(null);\n const invisibleAnchorRef = useRef<HTMLSpanElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const setupRef = useRef(false);\n\n // Mark the container as a popover trigger so that other open menus' close-on-\n // outside predicates treat clicks inside it (including programmatic\n // open buttons rendered alongside a context-menu target) as a legitimate\n // trigger interaction instead of a generic outside click. This mirrors the\n // pattern in `useAnchoredMenu`.\n useEffect(() => {\n const el = targetRef.current;\n if (el) {\n el.dataset.popoverTrigger = '';\n return () => {\n delete el.dataset.popoverTrigger;\n };\n }\n }, []);\n\n // Generate a unique ID for this menu instance\n const menuId = useMemo(() => generateRandomId(), []);\n\n // Feed both the context-menu target (`triggerRef`) and the popover\n // container (`containerRef`) into the sync. The container ref is shared with\n // the rendered `MenuTrigger` via its `popoverRef` prop — the dummy\n // `MenuTrigger` opts out of `usePopoverSync` (`enabled: !isDummy`), so\n // without this the nested-popover guard would have no container to match\n // against and a `SubMenuTrigger` opened inside this menu would close the\n // whole menu.\n usePopoverSync({\n menuId,\n isOpen,\n onClose: () => {\n setIsOpen(false);\n setAnchorPosition(null);\n },\n triggerRef: targetRef as RefObject<HTMLElement | null>,\n containerRef: popoverRef,\n });\n\n function setupCheck() {\n if (!setupRef.current) {\n throw new Error(\n 'useContextMenu: MenuTrigger must be rendered. Use `rendered` property to include it in your component tree.',\n );\n }\n }\n\n /**\n * Where to put the invisible anchor, in **viewport** coordinates.\n *\n * Viewport rather than container-relative on purpose. The anchor is rendered\n * into a fixed-position host pinned to the viewport origin (see\n * `renderedMenu`), so the two agree by construction. Computing coordinates\n * against the target element while the anchor's containing block was\n * whichever positioned ancestor happened to enclose `rendered` is what used\n * to open the menu one ancestor-origin away from the pointer.\n */\n const calculatePosition = (\n event?: NativeMouseEvent | NativePointerEvent | MouseEvent | PointerEvent,\n ) => {\n if (event) {\n const { clientX = 0, clientY = 0 } = event;\n\n return { x: clientX, y: clientY };\n }\n\n // No event — a keyboard opening, which has no coordinates. Anchor on the\n // target element's centre instead.\n const container = targetRef.current;\n\n if (!container) return { x: 0, y: 0 };\n\n const rect = container.getBoundingClientRect();\n\n return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };\n };\n\n // 'open' accepts props, trigger props, and optional event for positioning, then opens the menu\n const open = useEvent(\n (\n props: P = {} as P,\n triggerProps?: T,\n event?: NativeMouseEvent | NativePointerEvent | MouseEvent | PointerEvent,\n ) => {\n setupCheck();\n\n // Ensure the target element can serve as a positioning context for the\n // invisible target element. If the consumer hasn't explicitly set\n // `position: relative | absolute | fixed | sticky` we switch it to\n // `relative` so that absolutely-positioned children are laid out correctly.\n if (targetRef.current) {\n const computedStyle = window.getComputedStyle(targetRef.current);\n\n if (computedStyle.position === 'static') {\n targetRef.current.style.position = 'relative';\n }\n }\n\n // Prevent default context menu if it's a context menu event\n if (\n event &&\n 'preventDefault' in event &&\n typeof event.preventDefault === 'function'\n ) {\n event.preventDefault();\n }\n\n const { x, y } = calculatePosition(event);\n setAnchorPosition({ x, y });\n\n // Merge defaultMenuProps with provided props\n const finalProps = defaultMenuProps\n ? { ...defaultMenuProps, ...props }\n : props;\n\n setComponentProps(finalProps);\n setTriggerProps(triggerProps ?? null);\n setIsOpen(true);\n },\n );\n\n const update = useEvent((props: P, triggerProps?: T) => {\n setupCheck();\n\n // Merge defaultMenuProps with provided props\n const finalProps = defaultMenuProps\n ? { ...defaultMenuProps, ...props }\n : props;\n\n setComponentProps(finalProps as P);\n setTriggerProps(triggerProps ?? null);\n });\n\n const close = useEvent(() => {\n setIsOpen(false);\n setAnchorPosition(null);\n });\n\n // Context menu event handler\n const onContextMenu = useEvent(\n (event: MouseEvent | PointerEvent | MouseEvent | PointerEvent) => {\n event.preventDefault();\n if (isOpen) {\n const pos = calculatePosition(event);\n setAnchorPosition(pos);\n } else {\n open(defaultMenuProps, undefined, event);\n }\n },\n );\n\n // Bind the onContextMenu event to targetRef\n useEffect(() => {\n const element = targetRef.current;\n if (!element) return;\n\n element.addEventListener('contextmenu', onContextMenu as any);\n\n return () => {\n element.removeEventListener('contextmenu', onContextMenu as any);\n };\n }, [onContextMenu]);\n\n // Render the menu only when componentProps is set\n const renderedMenu = useMemo(() => {\n if (!componentProps || !anchorPosition) return null;\n\n return (\n <>\n {/*\n Invisible anchor at the click coordinates.\n\n Two things make those coordinates mean what they say:\n\n 1. A `fixed` host, so the containing block's origin is the viewport\n rather than whichever positioned ancestor encloses `rendered` — the\n table root, the tree row — which is what used to open the menu one\n ancestor-origin away from the pointer.\n 2. A portal to `body`, because `position: fixed` is captured by any\n ancestor carrying a transform, filter or `will-change`. A\n virtualized row is usually translated, so the `fixed` host alone\n would still be anchored to the row.\n */}\n {createPortal(\n <div\n style={{\n position: 'fixed',\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n }}\n >\n <span\n ref={invisibleAnchorRef}\n style={{\n position: 'absolute',\n left: `${anchorPosition.x}px`,\n top: `${anchorPosition.y}px`,\n width: '0px',\n height: '0px',\n lineHeight: '0',\n pointerEvents: 'none',\n visibility: 'hidden',\n }}\n />\n </div>,\n document.body,\n )}\n <MenuTrigger\n offset={0}\n placement={\n (triggerProps as ComponentProps<typeof MenuTrigger>)?.placement ||\n defaultTriggerProps?.placement ||\n 'bottom start'\n }\n {...mergeProps(defaultTriggerProps, triggerProps || undefined)}\n isDummy\n isOpen={isOpen}\n targetRef={invisibleAnchorRef}\n popoverRef={popoverRef}\n onOpenChange={setIsOpen}\n >\n <VisuallyHidden>\n <Pressable>\n <button\n aria-label={t(\n 'contextMenu.openContextMenu',\n 'Open context menu',\n )}\n />\n </Pressable>\n </VisuallyHidden>\n <Component {...componentProps} />\n </MenuTrigger>\n </>\n );\n }, [\n componentProps,\n triggerProps,\n isOpen,\n defaultTriggerProps,\n anchorPosition,\n t,\n ]);\n\n return {\n targetRef,\n open,\n update,\n close,\n isOpen,\n get rendered() {\n setupRef.current = true;\n\n return renderedMenu;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;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A;GACC,QAAQ;GACR,WACG,cAAqD,aACtD,qBAAqB,aACrB;GAEF,GAAIC,aAAW,qBAAqB,gBAAgB,OAAU;GAC9D;GACQ;GACR,WAAW;GACC;GACZ,cAAc;cAEd,oBAAC,4BACC,oBAAC,uBACC,oBAAC,YACC,cAAY,EACV,+BACA,oBACD,GACD,GACQ,GACG,EACjB,oBAAC,aAAU,GAAI,iBAAkB;IACrB,IACb;IAEJ;EACD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QAAO;EACL;EACA;EACA;EACA;EACA;EACA,IAAI,WAAW;AACb,YAAS,UAAU;AAEnB,UAAO;;EAEV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { useFocus as useFocus$1 } from "../../../utils/react/interactions.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.164.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { useDeprecationWarning } from "../../../_internal/hooks/use-deprecation-warning.js";
|
|
4
4
|
import { CONTAINER_STYLES, TEXT_STYLES, filterBaseProps } from "@tenphi/tasty";
|