@cube-dev/ui-kit 0.0.0-canary-d8ebfc2 → 0.0.0-canary-2615f95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_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 +10 -1
- package/dist/components/GlobalStyles.js.map +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/AutoCollapseObserver.js +1 -1
- package/dist/components/actions/Button/Button.js +4 -5
- package/dist/components/actions/Button/Button.js.map +1 -1
- package/dist/components/actions/Button/index.js +1 -1
- package/dist/components/actions/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/actions/ButtonSplit/ButtonSplit.js +1 -1
- package/dist/components/actions/ButtonSplit/context.js +1 -1
- package/dist/components/actions/CommandMenu/CommandMenu.d.ts +0 -7
- package/dist/components/actions/CommandMenu/CommandMenu.js +85 -94
- package/dist/components/actions/CommandMenu/CommandMenu.js.map +1 -1
- package/dist/components/actions/CommandMenu/styled.js +1 -1
- package/dist/components/actions/ItemAction/ItemAction.js +5 -6
- package/dist/components/actions/ItemAction/ItemAction.js.map +1 -1
- package/dist/components/actions/ItemActionContext.js +1 -1
- package/dist/components/actions/ItemActionsWrapper.js +1 -1
- package/dist/components/actions/ItemButton/ItemButton.js +2 -4
- 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/MenuCollectionItem.js +1 -1
- package/dist/components/actions/Menu/MenuItem.js +1 -1
- package/dist/components/actions/Menu/MenuSection.js +1 -1
- package/dist/components/actions/Menu/MenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubMenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubmenuTriggerContext.js +1 -1
- package/dist/components/actions/Menu/context.js +1 -1
- package/dist/components/actions/Menu/styled.js +1 -1
- package/dist/components/actions/actions-run.js +1 -1
- package/dist/components/actions/touch-context-menu.js +145 -0
- package/dist/components/actions/touch-context-menu.js.map +1 -0
- package/dist/components/actions/use-action.js +4 -2
- package/dist/components/actions/use-action.js.map +1 -1
- package/dist/components/actions/use-anchored-menu.js +1 -1
- package/dist/components/actions/use-context-menu.d.ts +4 -1
- package/dist/components/actions/use-context-menu.js +6 -1
- 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.js +1 -1
- package/dist/components/content/Disclosure/Disclosure.js +1 -1
- package/dist/components/content/Divider/Divider.js +1 -1
- package/dist/components/content/Footer.js +1 -1
- package/dist/components/content/Header.js +1 -1
- package/dist/components/content/HotKeys/HotKeys.js +1 -1
- package/dist/components/content/InfoBadge/InfoBadge.js +1 -1
- package/dist/components/content/InlineInput/InlineInput.js +1 -1
- package/dist/components/content/Item/Item.js +6 -9
- package/dist/components/content/Item/Item.js.map +1 -1
- package/dist/components/content/Item/ItemWithNativeLinks.js +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.js +1 -1
- package/dist/components/content/ItemCard/ItemCard.js +1 -1
- package/dist/components/content/Layout/GridLayout.js +1 -1
- package/dist/components/content/Layout/Layout.js +1 -1
- package/dist/components/content/Layout/LayoutBlock.js +1 -1
- package/dist/components/content/Layout/LayoutCenter.js +1 -1
- package/dist/components/content/Layout/LayoutContainer.js +1 -1
- package/dist/components/content/Layout/LayoutContent.js +1 -1
- package/dist/components/content/Layout/LayoutContext.js +1 -1
- package/dist/components/content/Layout/LayoutFlex.js +1 -1
- package/dist/components/content/Layout/LayoutFooter.js +1 -1
- package/dist/components/content/Layout/LayoutGrid.js +1 -1
- package/dist/components/content/Layout/LayoutHeader.js +1 -1
- package/dist/components/content/Layout/LayoutPane.js +1 -1
- package/dist/components/content/Layout/LayoutPanel.js +1 -1
- package/dist/components/content/Layout/LayoutPanelHeader.js +1 -1
- package/dist/components/content/Layout/LayoutPanelTransition.js +1 -1
- package/dist/components/content/Layout/LayoutToolbar.js +1 -1
- package/dist/components/content/Layout/hooks/useTinyScrollbar.js +1 -1
- package/dist/components/content/Layout/index.js +1 -1
- package/dist/components/content/Layout/utils.js +1 -1
- package/dist/components/content/Paragraph.js +1 -1
- package/dist/components/content/Placeholder/Placeholder.js +1 -1
- package/dist/components/content/PrismCode/PrismCode.js +1 -1
- package/dist/components/content/PrismCode/prismSetup.js +1 -1
- package/dist/components/content/PrismDiffCode/PrismDiffCode.js +1 -1
- package/dist/components/content/Result/Result.js +1 -1
- package/dist/components/content/Skeleton/Skeleton.js +1 -1
- package/dist/components/content/Tag/Tag.js +1 -1
- package/dist/components/content/Text.js +1 -1
- package/dist/components/content/TextItem/TextItem.js +1 -1
- package/dist/components/content/Title.js +1 -1
- package/dist/components/content/Tree/Tree.js +1 -1
- package/dist/components/content/Tree/TreeNode.js +1 -1
- package/dist/components/content/Tree/checked-keys.js +1 -1
- package/dist/components/content/Tree/rowId.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/types.d.ts +6 -4
- 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/DataTable/types.d.ts +4 -2
- package/dist/components/data/ItemTable/ItemTable.js +1 -1
- package/dist/components/data/ItemTable/ItemTableBulkBar.js +1 -1
- package/dist/components/data/ItemTable/ItemTableDragPreview.js +1 -1
- package/dist/components/data/ItemTable/ItemTableFooter.js +1 -1
- package/dist/components/data/ItemTable/ItemTableToolbar.js +1 -1
- package/dist/components/data/ItemTable/item-table-sections.js +1 -1
- package/dist/components/data/ItemTable/types.d.ts +8 -4
- package/dist/components/data/ItemTable/use-item-table-column-widths.js +1 -1
- package/dist/components/data/ItemTable/use-item-table-drag-drop.js +1 -1
- package/dist/components/data/ItemTable/use-item-table-pagination.js +1 -1
- package/dist/components/data/ItemTable/use-item-table-selection.js +1 -1
- package/dist/components/data/ItemTable/use-item-table-sort.js +1 -1
- package/dist/components/data/ItemTable/use-item-table-tree-model.js +1 -1
- package/dist/components/data/TableBase/ColumnResizer.js +1 -1
- package/dist/components/data/TableBase/RowCollection.js +1 -1
- package/dist/components/data/TableBase/TableHeaderCell.js +1 -1
- package/dist/components/data/TableBase/TableRow.js +1 -1
- package/dist/components/data/TableBase/TableRowLink.js +1 -1
- package/dist/components/data/TableBase/TableView.js +13 -2
- package/dist/components/data/TableBase/TableView.js.map +1 -1
- package/dist/components/data/TableBase/TreeGridTable.js +1 -1
- package/dist/components/data/TableBase/column-header.js +1 -1
- package/dist/components/data/TableBase/column-menu.js +1 -1
- package/dist/components/data/TableBase/column-styles.js +1 -1
- package/dist/components/data/TableBase/column-tint.js +1 -1
- package/dist/components/data/TableBase/row-menu.js +1 -1
- package/dist/components/data/TableBase/styled.js +1 -1
- package/dist/components/data/TableBase/table-body-sections.js +1 -1
- package/dist/components/data/TableBase/table-tree.js +1 -1
- package/dist/components/data/TableBase/types.js +1 -1
- package/dist/components/data/TableBase/use-cell-selection.js +0 -0
- package/dist/components/data/TableBase/use-column-menu.js +1 -1
- package/dist/components/data/TableBase/use-column-order.js +1 -1
- package/dist/components/data/TableBase/use-column-window.js +1 -1
- package/dist/components/data/TableBase/use-container-width.js +1 -1
- package/dist/components/data/TableBase/use-row-move-animation.js +1 -1
- package/dist/components/data/TableBase/use-scrollability.js +1 -1
- package/dist/components/data/TableBase/use-table-columns.js +1 -1
- package/dist/components/data/TableBase/use-table-search.js +1 -1
- package/dist/components/data/TableBase/use-table-selection.js +1 -1
- package/dist/components/data/TableBase/use-table-sort.js +1 -1
- package/dist/components/data/TableBase/use-table-sorts.js +1 -1
- package/dist/components/data/TableBase/use-table-storage.js +1 -1
- package/dist/components/data/TableBase/use-table-tooltip-refresh.js +1 -1
- package/dist/components/data/TableBase/use-table-tree-state.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 +1 -3
- package/dist/components/fields/ColorInput/ColorInput.js.map +1 -1
- package/dist/components/fields/ColorPicker/ColorPicker.js +1 -1
- package/dist/components/fields/ColorSwatch/ColorSwatch.js +1 -1
- package/dist/components/fields/ColorSwatchGroup/ColorSwatchGroup.js +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +1 -1
- package/dist/components/fields/ComboBox/comboBoxOptions.js +1 -1
- package/dist/components/fields/CommandTextArea/CommandTextArea.js +1 -1
- package/dist/components/fields/CommandTextArea/caretPosition.js +1 -1
- package/dist/components/fields/CommandTextArea/useCaretAnchor.js +1 -1
- package/dist/components/fields/DatePicker/CalendarPopover.js +1 -1
- package/dist/components/fields/DatePicker/DateInput.js +1 -1
- package/dist/components/fields/DatePicker/DateInputBase.js +1 -1
- package/dist/components/fields/DatePicker/DatePicker.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerButton.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerElement.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerInput.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerSegment.js +1 -1
- package/dist/components/fields/DatePicker/DateRangePicker.js +1 -1
- package/dist/components/fields/DatePicker/DateRangeSeparatedPicker.js +1 -1
- package/dist/components/fields/DatePicker/MonthPicker.js +1 -1
- package/dist/components/fields/DatePicker/PeriodPicker.js +1 -1
- package/dist/components/fields/DatePicker/QuarterPicker.js +1 -1
- package/dist/components/fields/DatePicker/TimeInput.js +1 -1
- package/dist/components/fields/DatePicker/WeekPicker.js +1 -1
- package/dist/components/fields/DatePicker/YearPicker.js +1 -1
- package/dist/components/fields/DatePicker/parseDate.js +1 -1
- package/dist/components/fields/DatePicker/period.js +1 -1
- package/dist/components/fields/DatePicker/props.js +1 -1
- package/dist/components/fields/DatePicker/utils.js +1 -1
- package/dist/components/fields/FileInput/FileInput.js +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.d.ts +0 -7
- package/dist/components/fields/FilterListBox/FilterListBox.js +2 -4
- package/dist/components/fields/FilterListBox/FilterListBox.js.map +1 -1
- package/dist/components/fields/FilterListBox/styled.js +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.js +2 -4
- package/dist/components/fields/FilterPicker/FilterPicker.js.map +1 -1
- package/dist/components/fields/FilterPicker/FilterTree.js +43 -52
- package/dist/components/fields/FilterPicker/FilterTree.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/ListBox/empty-row.js +1 -1
- package/dist/components/fields/ListBox/optionId.js +1 -1
- package/dist/components/fields/ListBoxPopover/ListBoxPopover.js +1 -1
- package/dist/components/fields/ListBoxPopover/listNavigation.js +1 -1
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.js +1 -1
- package/dist/components/fields/NumberInput/NumberInput.js +1 -1
- package/dist/components/fields/NumberInput/StepButton.js +1 -1
- package/dist/components/fields/PasswordInput/PasswordInput.js +1 -1
- package/dist/components/fields/Picker/Picker.js +1 -1
- package/dist/components/fields/RadioGroup/Radio.js +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.js +1 -1
- package/dist/components/fields/RadioGroup/context.js +1 -1
- package/dist/components/fields/RadioGroup/joined-styles.js +1 -1
- package/dist/components/fields/SearchComboBox/SearchComboBox.d.ts +0 -7
- package/dist/components/fields/SearchComboBox/SearchComboBox.js +3 -7
- package/dist/components/fields/SearchComboBox/SearchComboBox.js.map +1 -1
- package/dist/components/fields/SearchInput/SearchInput.js +2 -3
- package/dist/components/fields/SearchInput/SearchInput.js.map +1 -1
- package/dist/components/fields/Select/Select.js +1 -1
- package/dist/components/fields/Slider/Gradation.js +1 -1
- package/dist/components/fields/Slider/HueSlider.js +1 -1
- package/dist/components/fields/Slider/RangeSlider.js +1 -1
- package/dist/components/fields/Slider/Slider.js +1 -1
- package/dist/components/fields/Slider/SliderBase.js +1 -1
- package/dist/components/fields/Slider/SliderThumb.js +1 -1
- package/dist/components/fields/Slider/SliderTrack.js +1 -1
- package/dist/components/fields/Slider/elements.js +1 -1
- package/dist/components/fields/Slider/index.js +1 -1
- package/dist/components/fields/Switch/Switch.js +1 -1
- package/dist/components/fields/TagInput/TagInput.js +1 -1
- package/dist/components/fields/TagInput/TagList.js +1 -1
- package/dist/components/fields/TagInput/useActiveOption.js +1 -1
- package/dist/components/fields/TagInput/useSuffixSpace.js +1 -1
- package/dist/components/fields/TagInput/useTagError.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/TextInput/displayed-validation.js +1 -1
- package/dist/components/fields/TextInput/identifier-text-services.js +1 -1
- package/dist/components/fields/TextInput/password-manager-ignore.js +1 -1
- package/dist/components/fields/TextInput/useAutoSizeTextArea.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/fields/ToggleGroup/ToggleGroup.js +1 -1
- package/dist/components/fields/ToggleGroup/ToggleGroupItem.js +1 -1
- package/dist/components/fields/ToggleGroup/context.js +1 -1
- package/dist/components/fields/TriggerActions.js +1 -1
- package/dist/components/fields/color/ColorPanel.js +1 -1
- package/dist/components/fields/color/channels.js +1 -1
- package/dist/components/fields/color/color.js +1 -1
- package/dist/components/fields/color/context.js +1 -1
- package/dist/components/fields/index.d.ts +1 -2
- package/dist/components/fields/option-origin-press.js +1 -1
- package/dist/components/form/FieldWrapper/FieldWrapper.js +1 -1
- package/dist/components/form/FieldWrapper/field-description.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/FormContext.js +1 -1
- package/dist/components/form/Form/FormElement.js +1 -1
- package/dist/components/form/Form/ModernFormRoot.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/backend.js +1 -1
- package/dist/components/form/Form/index.js +1 -1
- package/dist/components/form/Form/modern/actions.js +1 -1
- package/dist/components/form/Form/modern/context.js +1 -1
- package/dist/components/form/Form/modern/controller.js +1 -1
- package/dist/components/form/Form/modern/field-binding.js +1 -1
- package/dist/components/form/Form/modern/field.js +1 -1
- package/dist/components/form/Form/modern/react.js +1 -1
- package/dist/components/form/Form/modern/store.js +1 -1
- package/dist/components/form/Form/modern/validation.js +1 -1
- package/dist/components/form/Form/modern/values.js +1 -1
- package/dist/components/form/Form/reset-unbound-controls.js +1 -1
- package/dist/components/form/Form/use-field/use-field-binding.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/field-chrome.js +1 -1
- package/dist/components/form/field-layout.js +1 -1
- package/dist/components/form/legacy-tooltip.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/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/NavTabs/NavTabs.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/BoardDragActiveProvider.js +1 -1
- package/dist/components/navigation/Tabs/DraggableTabList.js +1 -1
- package/dist/components/navigation/Tabs/TabButton.js +1 -1
- package/dist/components/navigation/Tabs/TabDropIndicator.js +1 -1
- package/dist/components/navigation/Tabs/TabPanel.js +1 -1
- package/dist/components/navigation/Tabs/TabPicker.js +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +1 -1
- package/dist/components/navigation/Tabs/TabsAction.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/popover-placement.js +1 -1
- package/dist/components/navigation/Tabs/scroll-tab-into-strip.js +1 -1
- package/dist/components/navigation/Tabs/segmented-styles.js +1 -1
- package/dist/components/navigation/Tabs/styled.js +1 -1
- package/dist/components/navigation/Tabs/types.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-editing.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-indicator.js +1 -1
- package/dist/components/organisms/StatsCard/StatsCard.js +1 -1
- package/dist/components/other/Calendar/Calendar.js +1 -1
- package/dist/components/other/Calendar/CalendarCell.js +1 -1
- package/dist/components/other/Calendar/CalendarGrid.js +1 -1
- package/dist/components/other/Calendar/CalendarHeader.js +1 -1
- package/dist/components/other/Calendar/CalendarPanel.js +1 -1
- package/dist/components/other/Calendar/PeriodCalendar.js +1 -1
- package/dist/components/other/Calendar/PeriodGrid.js +1 -1
- package/dist/components/other/Calendar/RangeCalendar.js +1 -1
- package/dist/components/other/Calendar/styled.js +1 -1
- package/dist/components/other/CubeLogo/CubeLogo.js +1 -1
- package/dist/components/other/NoDataIcon/NoDataIcon.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogApiProvider.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogZone.js +1 -1
- package/dist/components/overlays/Dialog/Dialog.js +1 -1
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +1 -1
- package/dist/components/overlays/Dialog/DialogTrigger.js +1 -1
- package/dist/components/overlays/Dialog/ModernDialogForm.js +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/default-button-text.js +1 -1
- package/dist/components/overlays/Dialog/use-content-overflow.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-open-sync.js +1 -1
- package/dist/components/overlays/Dialog/use-dismiss-confirmation.js +1 -1
- package/dist/components/overlays/Dialog/use-retained-dialog-focus.js +1 -1
- package/dist/components/overlays/Modal/Modal.js +1 -1
- package/dist/components/overlays/Modal/OpenTransitionContext.js +1 -1
- package/dist/components/overlays/Modal/Overlay.js +1 -1
- package/dist/components/overlays/Modal/Popover.js +1 -1
- package/dist/components/overlays/Modal/Tray.js +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Modal/modal-containment.js +1 -1
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +1 -1
- package/dist/components/overlays/Notifications/NotificationCard.js +1 -1
- package/dist/components/overlays/Notifications/NotificationContext.js +1 -1
- package/dist/components/overlays/Notifications/NotificationItem.js +1 -1
- package/dist/components/overlays/Notifications/OverlayContainer.js +1 -1
- package/dist/components/overlays/Notifications/OverlayProvider.js +1 -1
- package/dist/components/overlays/Notifications/PersistentNotificationsList.js +1 -1
- package/dist/components/overlays/Notifications/dismissed-storage.js +1 -1
- package/dist/components/overlays/Notifications/format-relative-time.js +1 -1
- package/dist/components/overlays/Notifications/index.js +1 -1
- package/dist/components/overlays/Notifications/use-notification-state.js +1 -1
- package/dist/components/overlays/Notifications/use-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-overlay-timers.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-state.js +1 -1
- package/dist/components/overlays/Notifications/use-toast-state.js +1 -1
- package/dist/components/overlays/Toast/ToastItem.js +1 -1
- package/dist/components/overlays/Toast/index.js +1 -1
- package/dist/components/overlays/Toast/useProgressToast.js +1 -1
- package/dist/components/overlays/Toast/useToast.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipProvider.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipTrigger.js +1 -1
- package/dist/components/overlays/Tooltip/context.js +1 -1
- package/dist/components/overlays/Tooltip/split-trigger-props.js +1 -1
- package/dist/components/portal/Portal.js +1 -1
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +1 -1
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/Spin/Cube.js +1 -1
- package/dist/components/status/Spin/InternalSpinner.js +1 -1
- package/dist/components/status/Spin/Spin.js +1 -1
- package/dist/components/status/Spin/SpinsContainer.js +1 -1
- package/dist/data/item-themes.js +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/eslint-plugin/defaults.generated.js +1 -1
- package/dist/eslint-plugin/index.js +1 -1
- package/dist/eslint-plugin/rules/no-redundant-default-prop.js +1 -1
- package/dist/i18n/I18nProvider.js +1 -1
- package/dist/i18n/createFormatter.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/instance.js +1 -1
- package/dist/i18n/locales/de-DE/uikit.js +1 -1
- package/dist/i18n/locales/en-US/uikit.js +1 -1
- package/dist/i18n/locales/es-ES/uikit.js +1 -1
- package/dist/i18n/locales/es-MX/uikit.js +1 -1
- package/dist/i18n/locales/fr-FR/uikit.js +1 -1
- package/dist/i18n/locales/it-IT/uikit.js +1 -1
- package/dist/i18n/locales/ja-JP/uikit.js +1 -1
- package/dist/i18n/locales/nb-NO/uikit.js +1 -1
- package/dist/i18n/locales/pt-BR/uikit.js +1 -1
- package/dist/i18n/locales/pt-PT/uikit.js +1 -1
- package/dist/i18n/locales/sv-SE/uikit.js +1 -1
- package/dist/i18n/locales/vi-VN/uikit.js +1 -1
- package/dist/i18n/locales.js +1 -1
- package/dist/i18n/namespace.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 +1 -2
- package/dist/index.js +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/navigation-url.js +1 -1
- package/dist/providers/navigationAdapter.default.js +1 -1
- package/dist/providers/use-navigation.js +1 -1
- package/dist/tokens/all-tokens.js +1 -1
- package/dist/tokens/base.js +1 -1
- package/dist/tokens/color-seed.js +1 -1
- package/dist/tokens/color-theme.js +1 -1
- package/dist/tokens/colors.js +1 -1
- package/dist/tokens/layout.js +1 -1
- package/dist/tokens/lazy-styles.js +1 -1
- package/dist/tokens/legacy-color.js +1 -1
- package/dist/tokens/palette-config.js +1 -1
- package/dist/tokens/palette.js +1 -1
- package/dist/tokens/resolve.js +1 -1
- package/dist/tokens/shadows.js +1 -1
- package/dist/tokens/sizes.js +1 -1
- package/dist/tokens/spacing.js +1 -1
- package/dist/tokens/typography.js +1 -1
- package/dist/utils/ResizeSensor.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/dotize.js +1 -1
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/layout-scale.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/componentBaseProps.js +1 -1
- package/dist/utils/react/disabledProps.d.ts +9 -3
- package/dist/utils/react/disabledProps.js +9 -5
- package/dist/utils/react/disabledProps.js.map +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/overlayKeyPropagation.js +1 -1
- package/dist/utils/react/pickBaseCustomizationProps.js +1 -1
- package/dist/utils/react/programmaticFocus.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/useOverlayEscapeGuard.js +1 -1
- package/dist/utils/react/useOverlayPosition.js +1 -1
- package/dist/utils/react/usePopoverSync.js +1 -1
- package/dist/utils/react/useQaProps.js +1 -1
- package/dist/utils/react/useScheme.js +1 -1
- package/dist/utils/react/useViewportSize.js +1 -1
- package/dist/utils/react/wrapNodeIfPlain.js +1 -1
- package/dist/utils/selection.js +1 -1
- package/dist/utils/styles.js +1 -1
- package/dist/utils/tree.js +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/version.js +2 -2
- package/docs/CreateComponent.md +11 -2
- package/docs/components/actions/CommandMenu.md +0 -1
- package/docs/components/actions/use-context-menu.md +17 -4
- package/docs/components/content/Item.md +1 -1
- package/docs/components/content/Tree.md +4 -4
- package/docs/components/data/DataTable.md +1 -1
- package/docs/components/data/ItemTable.md +9 -7
- package/docs/components/fields/FilterListBox.md +0 -1
- package/docs/components/fields/FilterPicker.md +0 -1
- package/docs/components/fields/SearchComboBox.md +0 -1
- package/docs/components/fields/SearchInput.md +1 -1
- package/docs/components/navigation/Tabs.md +2 -2
- package/docs/llms.txt +1 -1
- package/package.json +1 -1
- package/dist/components/fields/search-text-services.d.ts +0 -14
- package/dist/components/fields/search-text-services.js +0 -18
- package/dist/components/fields/search-text-services.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import { DisplayTransition } from "../helpers/DisplayTransition/DisplayTransition.js";
|
|
3
3
|
import { ITEM_RESTING_COLOR_VARIANTS, ROW_STATE_ALIASES, resolveItemVariant } from "../../data/item-themes.js";
|
|
4
4
|
import { ItemActionProvider } from "./ItemActionContext.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import { mergeProps } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { mergeRefs } from "../../../utils/react/useCombinedRefs.js";
|
|
4
4
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
@@ -22,7 +22,7 @@ const StyledItem = tasty(_Item, {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
const ItemButton = forwardRef(function ItemButton(allProps, ref) {
|
|
25
|
-
const { mods, to, htmlType, as, type = "item", theme = "default", onPress, onPressStart: _onPressStart, onPressEnd: _onPressEnd, onPressChange: _onPressChange, onPressUp: _onPressUp, navigationOptions: _navigationOptions, label: _label, actions, actionsProps, size = "medium", wrapperStyles, autoHideActions = false,
|
|
25
|
+
const { mods, to, htmlType, as, type = "item", theme = "default", onPress, onPressStart: _onPressStart, onPressEnd: _onPressEnd, onPressChange: _onPressChange, onPressUp: _onPressUp, navigationOptions: _navigationOptions, label: _label, actions, actionsProps, size = "medium", wrapperStyles, autoHideActions = false, disableActionsFocus = false, isDisabled, isLoading = false, ...rest } = allProps;
|
|
26
26
|
const finalIsDisabled = isDisabled === true || isLoading && isDisabled !== false;
|
|
27
27
|
const dismissParentPopover = useDismissParentPopover();
|
|
28
28
|
const buttonElementRef = useRef(null);
|
|
@@ -52,7 +52,6 @@ const ItemButton = forwardRef(function ItemButton(allProps, ref) {
|
|
|
52
52
|
insideWrapper: withWrapper,
|
|
53
53
|
showActions,
|
|
54
54
|
skipActionsWidthTransition,
|
|
55
|
-
preserveActionsSpace,
|
|
56
55
|
actions: actions ? true : void 0,
|
|
57
56
|
...mergeProps(rest, actionProps),
|
|
58
57
|
"aria-pressed": ariaPressed,
|
|
@@ -74,7 +73,6 @@ const ItemButton = forwardRef(function ItemButton(allProps, ref) {
|
|
|
74
73
|
actions,
|
|
75
74
|
actionsProps,
|
|
76
75
|
autoHideActions,
|
|
77
|
-
preserveActionsSpace,
|
|
78
76
|
disableActionsFocus,
|
|
79
77
|
isDisabled: finalIsDisabled,
|
|
80
78
|
children: ({ showActions: showActions_0, skipActionsWidthTransition: skipActionsWidthTransition_0 }) => renderButton(showActions_0, skipActionsWidthTransition_0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemButton.js","names":["FocusableRef","PressEvent","Styles","tasty","forwardRef","HTMLAttributes","ReactNode","useMemo","useRef","useEvent","mergeProps","mergeRefs","useDismissParentPopover","CubeItemProps","Item","ItemBadge","CubeItemActionProps","ItemAction","ItemActionsWrapper","CubeUseActionProps","useAction","CubeItemButtonProps","Omit","actions","size","wrapperStyles","actionsProps","HTMLDivElement","StyledItem","as","type","theme","styles","recipe","placeContent","ItemButton","allProps","ref","HTMLElement","mods","to","htmlType","onPress","onPressStart","_onPressStart","onPressEnd","_onPressEnd","onPressChange","_onPressChange","onPressUp","_onPressUp","navigationOptions","_navigationOptions","label","_label","autoHideActions","preserveActionsSpace","disableActionsFocus","isDisabled","isLoading","rest","finalIsDisabled","dismissParentPopover","buttonElementRef","wrappedOnPress","e","el","current","hasAttribute","closest","actionProps","combinedRef","hasHadActions","undefined","withWrapper","ariaPressed","isSelected","role","renderButton","showActions","skipActionsWidthTransition","_ItemButton","Object","assign","Action","Badge","ItemButtonProps","ItemActionProps","Item"],"sources":["../../../../src/components/actions/ItemButton/ItemButton.tsx"],"sourcesContent":["import { FocusableRef, PressEvent } from '@react-types/shared';\nimport { Styles, tasty } from '@tenphi/tasty';\nimport { forwardRef, HTMLAttributes, ReactNode, useMemo, useRef } from 'react';\n\nimport { useEvent } from '../../../_internal/hooks/use-event';\nimport { mergeProps } from '../../../utils/react/mergeProps';\nimport { mergeRefs } from '../../../utils/react/useCombinedRefs';\nimport { useDismissParentPopover } from '../../../utils/react/usePopoverSync';\nimport { CubeItemProps, Item } from '../../content/Item/Item';\nimport { ItemBadge } from '../../content/ItemBadge/ItemBadge';\nimport { CubeItemActionProps, ItemAction } from '../ItemAction/ItemAction';\nimport { ItemActionsWrapper } from '../ItemActionsWrapper';\nimport { CubeUseActionProps, useAction } from '../use-action';\n\nexport interface CubeItemButtonProps\n extends\n Omit<CubeItemProps, 'size'>,\n Omit<CubeUseActionProps, keyof CubeItemProps | 'as'> {\n /**\n * The row's trailing controls, rendered beside the button rather than inside\n * it. Pass `null` to keep an empty run — the row reserves no space for it, and\n * the button is not remounted when the actions arrive later.\n */\n actions?: ReactNode;\n size?: Omit<CubeItemProps['size'], 'inline'>;\n wrapperStyles?: Styles;\n /**\n * Extra props spread on the actions run's container, e.g. event handlers.\n * Only meaningful together with `actions`.\n */\n actionsProps?: HTMLAttributes<HTMLDivElement>;\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 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 // Consumed by useAction (it reads `allProps`); kept off the DOM element.\n navigationOptions: _navigationOptions,\n label: _label,\n actions,\n actionsProps,\n size = 'medium',\n wrapperStyles,\n autoHideActions = false,\n preserveActionsSpace = 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 // 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` or `data-popover-keep-on-press` (presses only, see\n // Button) 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], [data-popover-keep-on-press]')) {\n return;\n }\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 // 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 // Once a row has had actions it keeps the wrapper, even after they go away.\n // Adding or removing a DOM level around the button remounts it — losing focus,\n // any running transition, and the element every ref in the tree is holding —\n // and a row whose actions come and go with a permission or a loading flag\n // would do that on every flip. The empty run reserves nothing: it publishes\n // a width of 0, so the row keeps no space for it, and costs one entry in a\n // shared size observer.\n //\n // `null` is how a caller asks for the run up front — \"there is a run here, it\n // just has nothing in it right now\" — so a row that knows its actions are\n // coming never has to remount to receive them. Only `undefined` means the row\n // has no run at all.\n const hasHadActions = useRef(false);\n\n if (actions !== undefined) {\n hasHadActions.current = true;\n }\n\n const withWrapper = hasHadActions.current;\n\n // `isSelected` on a button is a toggle state, so it reads as `aria-pressed`,\n // as `Button` does. Skipped on a link (`to`), for a call site's own `role` (a\n // tab or option wants `aria-selected`), and on a trigger that reports\n // `aria-expanded`, which is its state instead. An explicit value still wins.\n //\n // Set after the spread: `useButton` always returns an `aria-pressed` key,\n // undefined when the caller passed none, which would overwrite it.\n const ariaPressed =\n allProps['aria-pressed'] ??\n (allProps.isSelected != null &&\n actionProps.as !== 'a' &&\n allProps.role == null &&\n allProps['aria-expanded'] == null\n ? allProps.isSelected\n : undefined);\n\n const renderButton = (\n showActions: boolean,\n skipActionsWidthTransition = false,\n ) => (\n <StyledItem\n // Two different questions. `insideWrapper` is \"am I laid out for a\n // sibling run\", which stays true so the DOM does not restructure;\n // `actions` is \"is there anything in that run to reserve width for\",\n // which must go back to false when the run empties — it drives the\n // two-square minimum width and the suffix's padding, and a row that\n // reserved space for nothing would sit wider than it needs to.\n insideWrapper={withWrapper}\n showActions={showActions}\n skipActionsWidthTransition={skipActionsWidthTransition}\n preserveActionsSpace={preserveActionsSpace}\n actions={actions ? true : undefined}\n {...(mergeProps(rest, actionProps) as any)}\n aria-pressed={ariaPressed}\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 (withWrapper) {\n return (\n <ItemActionsWrapper\n type={type}\n theme={theme}\n size={size as CubeItemProps['size']}\n mods={mods}\n styles={wrapperStyles}\n actions={actions}\n actionsProps={actionsProps}\n autoHideActions={autoHideActions}\n preserveActionsSpace={preserveActionsSpace}\n disableActionsFocus={disableActionsFocus}\n isDisabled={finalIsDisabled}\n >\n {({ showActions, skipActionsWidthTransition }) =>\n renderButton(showActions, skipActionsWidthTransition)\n }\n </ItemActionsWrapper>\n );\n }\n\n return renderButton(false);\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":";;;;;;;;;;;;;;AAiCA,MAAM4B,aAAazB,MAAMW,OAAM;CAC7Be,IAAI;CACJC,MAAM;CACNC,OAAO;CACPC,QAAQ;EACNC,QAAQ;EACRC,cAAc;CAChB;AACF,CAAC;AAED,MAAMC,aAAa/B,WAAW,SAAS+B,WACrCC,UACAC,KACA;CACA,MAAM,EACJE,MACAC,IACAC,UACAZ,IACAC,OAAO,QACPC,QAAQ,WACRW,SAGAC,cAAcC,eACdC,YAAYC,aACZC,eAAeC,gBACfC,WAAWC,YAEXC,mBAAmBC,oBACnBC,OAAOC,QACP/B,SACAG,cACAF,OAAO,UACPC,eACA8B,kBAAkB,OAClBC,uBAAuB,OACvBC,sBAAsB,OACtBC,YACAC,YAAY,OACZ,GAAGC,SACDxB;CAKJ,MAAMyB,kBACJH,eAAe,QAASC,aAAaD,eAAe;CAOtD,MAAMI,uBAAuBlD,wBAAwB;CACrD,MAAMmD,mBAAmBvD,OAA2B,IAAI;CAExD,MAAMwD,iBAAiBvD,UAAUwD,MAAkB;EACjDvB,UAAUuB,CAAC;EACX,MAAMC,KAAKH,iBAAiBI;EAC5B,IAAI,CAACD,IAAI;EACT,IAAIA,GAAGE,aAAa,sBAAsB,GAAG;EAC7C,IAAIF,GAAGG,QAAQ,mDAAmD,GAChE;EAEFP,qBAAqBI,EAAE;CACzB,CAAC;CAED,MAAM,EAAEI,gBAAgBlD,UACtB;EACE,GAAIgB;EACJK;EACAD;EACAX;EACAU;EACAmB,YAAYG;EACZnB,SAASsB;CACX,GACA3B,GACF;CAIA,MAAMkC,cAAchE,cACZI,UAAU2D,YAAYjC,KAAY0B,gBAAgB,GACxD,CAACO,YAAYjC,GAAG,CAClB;CAcA,MAAMmC,gBAAgBhE,OAAO,KAAK;CAElC,IAAIe,YAAYkD,KAAAA,GACdD,cAAcL,UAAU;CAG1B,MAAMO,cAAcF,cAAcL;CASlC,MAAMQ,cACJvC,SAAS,oBACRA,SAASwC,cAAc,QACxBN,YAAYzC,OAAO,OACnBO,SAASyC,QAAQ,QACjBzC,SAAS,oBAAoB,OACzBA,SAASwC,aACTH,KAAAA;CAEN,MAAMK,gBACJC,aACAC,6BAA6B,UAE7B,oBAAC,YAAD;EAOE,eAAeN;EACFK;EACeC;EACNxB;EACtB,SAASjC,UAAU,OAAOkD,KAAAA;EAC1B,GAAK/D,WAAWkD,MAAMU,WAAW;EACjC,gBAAcK;EACd,KAAKJ;EACL,wBAAqB;EACrB,UAAUD,YAAYxC;EAChBA;EACCC;EACDP;EACKmC;EACCD;CAAW,CAAA;CAI3B,IAAIgB,aACF,OACE,oBAAC,oBAAD;EACQ5C;EACCC;EACDP;EACAe;EACN,QAAQd;EACCF;EACKG;EACG6B;EACKC;EACDC;EACrB,YAAYI;EAEV,WAAA,EAAEkB,aAAAA,eAAaC,4BAAAA,mCACfF,aAAaC,eAAaC,4BAA0B;CAEpC,CAAA;CAIxB,OAAOF,aAAa,KAAK;AAC3B,CAAC;AAED,MAAMG,cAAcC,OAAOC,OAAOhD,YAAY;CAC5CiD,QAAQnE;CACRoE,OAAOtE;AACT,CAAC"}
|
|
1
|
+
{"version":3,"file":"ItemButton.js","names":["FocusableRef","PressEvent","Styles","tasty","forwardRef","HTMLAttributes","ReactNode","useMemo","useRef","useEvent","mergeProps","mergeRefs","useDismissParentPopover","CubeItemProps","Item","ItemBadge","CubeItemActionProps","ItemAction","ItemActionsWrapper","CubeUseActionProps","useAction","CubeItemButtonProps","Omit","actions","size","wrapperStyles","actionsProps","HTMLDivElement","StyledItem","as","type","theme","styles","recipe","placeContent","ItemButton","allProps","ref","HTMLElement","mods","to","htmlType","onPress","onPressStart","_onPressStart","onPressEnd","_onPressEnd","onPressChange","_onPressChange","onPressUp","_onPressUp","navigationOptions","_navigationOptions","label","_label","autoHideActions","disableActionsFocus","isDisabled","isLoading","rest","finalIsDisabled","dismissParentPopover","buttonElementRef","wrappedOnPress","e","el","current","hasAttribute","closest","actionProps","combinedRef","hasHadActions","undefined","withWrapper","ariaPressed","isSelected","role","renderButton","showActions","skipActionsWidthTransition","_ItemButton","Object","assign","Action","Badge","ItemButtonProps","ItemActionProps","Item"],"sources":["../../../../src/components/actions/ItemButton/ItemButton.tsx"],"sourcesContent":["import { FocusableRef, PressEvent } from '@react-types/shared';\nimport { Styles, tasty } from '@tenphi/tasty';\nimport { forwardRef, HTMLAttributes, ReactNode, useMemo, useRef } from 'react';\n\nimport { useEvent } from '../../../_internal/hooks/use-event';\nimport { mergeProps } from '../../../utils/react/mergeProps';\nimport { mergeRefs } from '../../../utils/react/useCombinedRefs';\nimport { useDismissParentPopover } from '../../../utils/react/usePopoverSync';\nimport { CubeItemProps, Item } from '../../content/Item/Item';\nimport { ItemBadge } from '../../content/ItemBadge/ItemBadge';\nimport { CubeItemActionProps, ItemAction } from '../ItemAction/ItemAction';\nimport { ItemActionsWrapper } from '../ItemActionsWrapper';\nimport { CubeUseActionProps, useAction } from '../use-action';\n\nexport interface CubeItemButtonProps\n extends\n Omit<CubeItemProps, 'size'>,\n Omit<CubeUseActionProps, keyof CubeItemProps | 'as'> {\n /**\n * The row's trailing controls, rendered beside the button rather than inside\n * it. Pass `null` to keep an empty run — the row reserves no space for it, and\n * the button is not remounted when the actions arrive later.\n */\n actions?: ReactNode;\n size?: Omit<CubeItemProps['size'], 'inline'>;\n wrapperStyles?: Styles;\n /**\n * Extra props spread on the actions run's container, e.g. event handlers.\n * Only meaningful together with `actions`.\n */\n actionsProps?: HTMLAttributes<HTMLDivElement>;\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 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 // Consumed by useAction (it reads `allProps`); kept off the DOM element.\n navigationOptions: _navigationOptions,\n label: _label,\n actions,\n actionsProps,\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 // 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` or `data-popover-keep-on-press` (presses only, see\n // Button) 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], [data-popover-keep-on-press]')) {\n return;\n }\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 // 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 // Once a row has had actions it keeps the wrapper, even after they go away.\n // Adding or removing a DOM level around the button remounts it — losing focus,\n // any running transition, and the element every ref in the tree is holding —\n // and a row whose actions come and go with a permission or a loading flag\n // would do that on every flip. The empty run reserves nothing: it publishes\n // a width of 0, so the row keeps no space for it, and costs one entry in a\n // shared size observer.\n //\n // `null` is how a caller asks for the run up front — \"there is a run here, it\n // just has nothing in it right now\" — so a row that knows its actions are\n // coming never has to remount to receive them. Only `undefined` means the row\n // has no run at all.\n const hasHadActions = useRef(false);\n\n if (actions !== undefined) {\n hasHadActions.current = true;\n }\n\n const withWrapper = hasHadActions.current;\n\n // `isSelected` on a button is a toggle state, so it reads as `aria-pressed`,\n // as `Button` does. Skipped on a link (`to`), for a call site's own `role` (a\n // tab or option wants `aria-selected`), and on a trigger that reports\n // `aria-expanded`, which is its state instead. An explicit value still wins.\n //\n // Set after the spread: `useButton` always returns an `aria-pressed` key,\n // undefined when the caller passed none, which would overwrite it.\n const ariaPressed =\n allProps['aria-pressed'] ??\n (allProps.isSelected != null &&\n actionProps.as !== 'a' &&\n allProps.role == null &&\n allProps['aria-expanded'] == null\n ? allProps.isSelected\n : undefined);\n\n const renderButton = (\n showActions: boolean,\n skipActionsWidthTransition = false,\n ) => (\n <StyledItem\n // Two different questions. `insideWrapper` is \"am I laid out for a\n // sibling run\", which stays true so the DOM does not restructure;\n // `actions` is \"is there anything in that run to reserve width for\",\n // which must go back to false when the run empties — it drives the\n // two-square minimum width and the suffix's padding, and a row that\n // reserved space for nothing would sit wider than it needs to.\n insideWrapper={withWrapper}\n showActions={showActions}\n skipActionsWidthTransition={skipActionsWidthTransition}\n actions={actions ? true : undefined}\n {...(mergeProps(rest, actionProps) as any)}\n aria-pressed={ariaPressed}\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 (withWrapper) {\n return (\n <ItemActionsWrapper\n type={type}\n theme={theme}\n size={size as CubeItemProps['size']}\n mods={mods}\n styles={wrapperStyles}\n actions={actions}\n actionsProps={actionsProps}\n autoHideActions={autoHideActions}\n disableActionsFocus={disableActionsFocus}\n isDisabled={finalIsDisabled}\n >\n {({ showActions, skipActionsWidthTransition }) =>\n renderButton(showActions, skipActionsWidthTransition)\n }\n </ItemActionsWrapper>\n );\n }\n\n return renderButton(false);\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":";;;;;;;;;;;;;;AAiCA,MAAM4B,aAAazB,MAAMW,OAAM;CAC7Be,IAAI;CACJC,MAAM;CACNC,OAAO;CACPC,QAAQ;EACNC,QAAQ;EACRC,cAAc;CAChB;AACF,CAAC;AAED,MAAMC,aAAa/B,WAAW,SAAS+B,WACrCC,UACAC,KACA;CACA,MAAM,EACJE,MACAC,IACAC,UACAZ,IACAC,OAAO,QACPC,QAAQ,WACRW,SAGAC,cAAcC,eACdC,YAAYC,aACZC,eAAeC,gBACfC,WAAWC,YAEXC,mBAAmBC,oBACnBC,OAAOC,QACP/B,SACAG,cACAF,OAAO,UACPC,eACA8B,kBAAkB,OAClBC,sBAAsB,OACtBC,YACAC,YAAY,OACZ,GAAGC,SACDvB;CAKJ,MAAMwB,kBACJH,eAAe,QAASC,aAAaD,eAAe;CAOtD,MAAMI,uBAAuBjD,wBAAwB;CACrD,MAAMkD,mBAAmBtD,OAA2B,IAAI;CAExD,MAAMuD,iBAAiBtD,UAAUuD,MAAkB;EACjDtB,UAAUsB,CAAC;EACX,MAAMC,KAAKH,iBAAiBI;EAC5B,IAAI,CAACD,IAAI;EACT,IAAIA,GAAG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-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import { Button } from "../Button/Button.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { forwardRef } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | 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 { useMenuContext } from "./context.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import { normalizeNavigationUrl } from "../../../providers/navigation-url.js";
|
|
3
3
|
import { parseTo } from "../use-action.js";
|
|
4
4
|
import { COLLECTION_ITEM_CLICK, CollectionItem as _CollectionItem } from "../../CollectionItem.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { isExternalUrl, normalizeNavigationUrl } from "../../../providers/navigation-url.js";
|
|
4
4
|
import { useNavigation } from "../../../providers/use-navigation.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import { getMenuItemReactKey } from "./MenuCollectionItem.js";
|
|
3
3
|
import { MenuItem } from "./MenuItem.js";
|
|
4
4
|
import { StyledMenu, StyledSection, StyledSectionHeading } from "./styled.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import { SlotProvider } from "../../../utils/react/Slots.js";
|
|
3
3
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
4
4
|
import { usePopoverSync } from "../../../utils/react/usePopoverSync.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
3
3
|
import { usePopoverSync } from "../../../utils/react/usePopoverSync.js";
|
|
4
4
|
import { MenuContext, useMenuContext } from "./context.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import React from "react";
|
|
3
3
|
//#region src/components/actions/Menu/SubmenuTriggerContext.tsx
|
|
4
4
|
const SubmenuTriggerContext = React.createContext(null);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
//#region src/components/actions/Menu/context.ts
|
|
4
4
|
const MenuContext = React.createContext({});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
2
|
//#region src/components/actions/actions-run.ts
|
|
3
3
|
/**
|
|
4
4
|
* Whether `element` — the node react-aria hands an overlay's dismiss predicate
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | Cube Dev Team */
|
|
2
|
+
//#region src/components/actions/touch-context-menu.ts
|
|
3
|
+
/** React Aria's `useLongPress` threshold. */
|
|
4
|
+
const LONG_PRESS_DELAY = 500;
|
|
5
|
+
/**
|
|
6
|
+
* How long after a long press its own `click` can still arrive. React Aria's
|
|
7
|
+
* `useLongPress` waits the same.
|
|
8
|
+
*/
|
|
9
|
+
const LATE_CLICK_WINDOW = 100;
|
|
10
|
+
/** How far a finger may drift and still count as held still (iOS allows 10 pt). */
|
|
11
|
+
const MOVE_TOLERANCE = 10;
|
|
12
|
+
/** A text field keeps its own long press: placing the caret, selecting, pasting. */
|
|
13
|
+
const TEXT_FIELD = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])";
|
|
14
|
+
/**
|
|
15
|
+
* Marks an element whose touch long press opens its context menu. `GlobalStyles`
|
|
16
|
+
* turns iOS's own long-press callout off on it.
|
|
17
|
+
*/
|
|
18
|
+
const TOUCH_CONTEXT_MENU_ATTRIBUTE = "data-context-menu";
|
|
19
|
+
/**
|
|
20
|
+
* Opens context menus on a touch long press, on every platform.
|
|
21
|
+
*
|
|
22
|
+
* iOS fires no `contextmenu` on a long press (WebKit bug 213953), so a menu that
|
|
23
|
+
* only answers that event can't be opened there at all. Inside `container`, a
|
|
24
|
+
* touch held still for 500 ms on an element marked `data-context-menu` fires
|
|
25
|
+
* one at the touch point, and the menu opens through the same handler as a
|
|
26
|
+
* right-click. Android fires its own earlier (~400 ms); that one claims the
|
|
27
|
+
* press instead, so the menu opens once.
|
|
28
|
+
*
|
|
29
|
+
* Once a menu opens, the long press owns the gesture, as React Aria's
|
|
30
|
+
* `useLongPress` does: a bubbling `pointercancel` ends every `usePress` in and
|
|
31
|
+
* around the element, and the `click` some platforms still fire on release is
|
|
32
|
+
* swallowed, so lifting the finger does not also activate the row. A text
|
|
33
|
+
* selection can't start during the press.
|
|
34
|
+
*
|
|
35
|
+
* No long press starts in a text field, moves more than 10 px, or starts on a
|
|
36
|
+
* handle that took the press itself by preventing its `pointerdown`, such as
|
|
37
|
+
* React Aria's `useMove` on a column resizer or a slider.
|
|
38
|
+
*
|
|
39
|
+
* Returns the cleanup.
|
|
40
|
+
*/
|
|
41
|
+
function bindTouchContextMenu(container) {
|
|
42
|
+
if (typeof PointerEvent === "undefined") return () => {};
|
|
43
|
+
const doc = container.ownerDocument;
|
|
44
|
+
let press = null;
|
|
45
|
+
let isSwallowingClick = false;
|
|
46
|
+
let clickTimer;
|
|
47
|
+
function release(event) {
|
|
48
|
+
if (!press) return;
|
|
49
|
+
if (event instanceof PointerEvent) {
|
|
50
|
+
if (event.pointerId !== press.down.pointerId) return;
|
|
51
|
+
if (event.type === "pointercancel" && !event.isTrusted) return;
|
|
52
|
+
}
|
|
53
|
+
clearTimeout(press.timer);
|
|
54
|
+
if (press.isClaimed) {
|
|
55
|
+
isSwallowingClick = true;
|
|
56
|
+
clickTimer = setTimeout(() => {
|
|
57
|
+
isSwallowingClick = false;
|
|
58
|
+
}, LATE_CLICK_WINDOW);
|
|
59
|
+
}
|
|
60
|
+
press = null;
|
|
61
|
+
doc.removeEventListener("pointerup", release, true);
|
|
62
|
+
doc.removeEventListener("pointercancel", release, true);
|
|
63
|
+
doc.removeEventListener("pointermove", onPointerMove, true);
|
|
64
|
+
}
|
|
65
|
+
function onPointerMove(event) {
|
|
66
|
+
if (!press || press.isClaimed) return;
|
|
67
|
+
if (event.pointerId !== press.down.pointerId) return;
|
|
68
|
+
const { clientX, clientY } = press.down;
|
|
69
|
+
if (Math.hypot(event.clientX - clientX, event.clientY - clientY) > MOVE_TOLERANCE) release();
|
|
70
|
+
}
|
|
71
|
+
function claim(current) {
|
|
72
|
+
current.isClaimed = true;
|
|
73
|
+
current.down.target?.dispatchEvent(new PointerEvent("pointercancel", { bubbles: true }));
|
|
74
|
+
}
|
|
75
|
+
function onPointerDown(event) {
|
|
76
|
+
if (event.pointerType !== "touch" || !event.isPrimary) return;
|
|
77
|
+
const target = event.target instanceof Element ? event.target.closest(`[${TOUCH_CONTEXT_MENU_ATTRIBUTE}]`) : null;
|
|
78
|
+
if (!target || !container.contains(target)) return;
|
|
79
|
+
if (event.target.closest(TEXT_FIELD)) return;
|
|
80
|
+
release();
|
|
81
|
+
clearTimeout(clickTimer);
|
|
82
|
+
isSwallowingClick = false;
|
|
83
|
+
const current = {
|
|
84
|
+
down: event,
|
|
85
|
+
isClaimed: false
|
|
86
|
+
};
|
|
87
|
+
current.timer = setTimeout(() => {
|
|
88
|
+
const origin = event.target;
|
|
89
|
+
if (event.defaultPrevented || !(origin instanceof Element) || !origin.isConnected) {
|
|
90
|
+
release();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const { clientX, clientY, screenX, screenY } = event;
|
|
94
|
+
if (!origin.dispatchEvent(new MouseEvent("contextmenu", {
|
|
95
|
+
bubbles: true,
|
|
96
|
+
cancelable: true,
|
|
97
|
+
clientX,
|
|
98
|
+
clientY,
|
|
99
|
+
screenX,
|
|
100
|
+
screenY
|
|
101
|
+
})) && press === current) claim(current);
|
|
102
|
+
}, LONG_PRESS_DELAY);
|
|
103
|
+
press = current;
|
|
104
|
+
doc.addEventListener("pointerup", release, true);
|
|
105
|
+
doc.addEventListener("pointercancel", release, true);
|
|
106
|
+
doc.addEventListener("pointermove", onPointerMove, true);
|
|
107
|
+
}
|
|
108
|
+
function onContextMenu(event) {
|
|
109
|
+
if (!press) return;
|
|
110
|
+
if (press.isClaimed) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
event.stopImmediatePropagation();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
clearTimeout(press.timer);
|
|
116
|
+
if (event.isTrusted) claim(press);
|
|
117
|
+
}
|
|
118
|
+
function onClick(event) {
|
|
119
|
+
if (!isSwallowingClick) return;
|
|
120
|
+
isSwallowingClick = false;
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
event.stopPropagation();
|
|
123
|
+
}
|
|
124
|
+
function onSelectStart(event) {
|
|
125
|
+
if (press) event.preventDefault();
|
|
126
|
+
}
|
|
127
|
+
container.addEventListener("pointerdown", onPointerDown, true);
|
|
128
|
+
container.addEventListener("contextmenu", onContextMenu, true);
|
|
129
|
+
container.addEventListener("click", onClick, true);
|
|
130
|
+
container.addEventListener("selectstart", onSelectStart);
|
|
131
|
+
container.addEventListener("dragstart", release);
|
|
132
|
+
return () => {
|
|
133
|
+
release();
|
|
134
|
+
clearTimeout(clickTimer);
|
|
135
|
+
container.removeEventListener("pointerdown", onPointerDown, true);
|
|
136
|
+
container.removeEventListener("contextmenu", onContextMenu, true);
|
|
137
|
+
container.removeEventListener("click", onClick, true);
|
|
138
|
+
container.removeEventListener("selectstart", onSelectStart);
|
|
139
|
+
container.removeEventListener("dragstart", release);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { TOUCH_CONTEXT_MENU_ATTRIBUTE, bindTouchContextMenu };
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=touch-context-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch-context-menu.js","names":["LONG_PRESS_DELAY","LATE_CLICK_WINDOW","MOVE_TOLERANCE","TEXT_FIELD","TOUCH_CONTEXT_MENU_ATTRIBUTE","Press","down","PointerEvent","timer","ReturnType","setTimeout","isClaimed","bindTouchContextMenu","container","HTMLElement","doc","ownerDocument","press","isSwallowingClick","clickTimer","release","event","Event","pointerId","type","isTrusted","clearTimeout","removeEventListener","onPointerMove","clientX","clientY","Math","hypot","claim","current","target","dispatchEvent","bubbles","onPointerDown","pointerType","isPrimary","Element","closest","contains","origin","defaultPrevented","isConnected","screenX","screenY","isOpened","MouseEvent","cancelable","addEventListener","onContextMenu","preventDefault","stopImmediatePropagation","onClick","stopPropagation","onSelectStart"],"sources":["../../../src/components/actions/touch-context-menu.ts"],"sourcesContent":["/** React Aria's `useLongPress` threshold. */\nconst LONG_PRESS_DELAY = 500;\n\n/**\n * How long after a long press its own `click` can still arrive. React Aria's\n * `useLongPress` waits the same.\n */\nconst LATE_CLICK_WINDOW = 100;\n\n/** How far a finger may drift and still count as held still (iOS allows 10 pt). */\nconst MOVE_TOLERANCE = 10;\n\n/** A text field keeps its own long press: placing the caret, selecting, pasting. */\nconst TEXT_FIELD =\n 'input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])';\n\n/**\n * Marks an element whose touch long press opens its context menu. `GlobalStyles`\n * turns iOS's own long-press callout off on it.\n */\nexport const TOUCH_CONTEXT_MENU_ATTRIBUTE = 'data-context-menu';\n\ninterface Press {\n down: PointerEvent;\n timer?: ReturnType<typeof setTimeout>;\n /** A menu opened: the long press owns the rest of the gesture. */\n isClaimed: boolean;\n}\n\n/**\n * Opens context menus on a touch long press, on every platform.\n *\n * iOS fires no `contextmenu` on a long press (WebKit bug 213953), so a menu that\n * only answers that event can't be opened there at all. Inside `container`, a\n * touch held still for 500 ms on an element marked `data-context-menu` fires\n * one at the touch point, and the menu opens through the same handler as a\n * right-click. Android fires its own earlier (~400 ms); that one claims the\n * press instead, so the menu opens once.\n *\n * Once a menu opens, the long press owns the gesture, as React Aria's\n * `useLongPress` does: a bubbling `pointercancel` ends every `usePress` in and\n * around the element, and the `click` some platforms still fire on release is\n * swallowed, so lifting the finger does not also activate the row. A text\n * selection can't start during the press.\n *\n * No long press starts in a text field, moves more than 10 px, or starts on a\n * handle that took the press itself by preventing its `pointerdown`, such as\n * React Aria's `useMove` on a column resizer or a slider.\n *\n * Returns the cleanup.\n */\nexport function bindTouchContextMenu(container: HTMLElement): () => void {\n // Every supported browser has `PointerEvent`; older jsdom (Cloud runs 26)\n // does not, while user-event still dispatches touch pointer events there.\n if (typeof PointerEvent === 'undefined') return () => {};\n\n const doc = container.ownerDocument;\n let press: Press | null = null;\n let isSwallowingClick = false;\n let clickTimer: ReturnType<typeof setTimeout> | undefined;\n\n function release(event?: Event) {\n if (!press) return;\n if (event instanceof PointerEvent) {\n // Another pointer's release, such as a mouse's, doesn't end this touch.\n if (event.pointerId !== press.down.pointerId) return;\n // A synthetic `pointercancel`, ours included, ends somebody's press, not\n // the finger's contact: only the browser cancels that.\n if (event.type === 'pointercancel' && !event.isTrusted) return;\n }\n\n clearTimeout(press.timer);\n if (press.isClaimed) {\n isSwallowingClick = true;\n clickTimer = setTimeout(() => {\n isSwallowingClick = false;\n }, LATE_CLICK_WINDOW);\n }\n press = null;\n doc.removeEventListener('pointerup', release, true);\n doc.removeEventListener('pointercancel', release, true);\n doc.removeEventListener('pointermove', onPointerMove, true);\n }\n\n // A finger that moves is not holding still. A scroll ends the touch with a\n // `pointercancel`, but a drag inside `touch-action: none` sends none.\n function onPointerMove(event: PointerEvent) {\n if (!press || press.isClaimed) return;\n if (event.pointerId !== press.down.pointerId) return;\n\n const { clientX, clientY } = press.down;\n\n if (\n Math.hypot(event.clientX - clientX, event.clientY - clientY) >\n MOVE_TOLERANCE\n )\n release();\n }\n\n function claim(current: Press) {\n current.isClaimed = true;\n current.down.target?.dispatchEvent(\n new PointerEvent('pointercancel', { bubbles: true }),\n );\n }\n\n function onPointerDown(event: PointerEvent) {\n if (event.pointerType !== 'touch' || !event.isPrimary) return;\n\n const target =\n event.target instanceof Element\n ? event.target.closest(`[${TOUCH_CONTEXT_MENU_ATTRIBUTE}]`)\n : null;\n\n if (!target || !container.contains(target)) return;\n if ((event.target as Element).closest(TEXT_FIELD)) return;\n\n release();\n clearTimeout(clickTimer);\n isSwallowingClick = false;\n\n const current: Press = { down: event, isClaimed: false };\n\n current.timer = setTimeout(() => {\n const origin = event.target;\n\n // A handle that took the press, such as `useMove`'s, prevented it.\n if (\n event.defaultPrevented ||\n !(origin instanceof Element) ||\n !origin.isConnected\n ) {\n release();\n\n return;\n }\n\n const { clientX, clientY, screenX, screenY } = event;\n const isOpened = !origin.dispatchEvent(\n new MouseEvent('contextmenu', {\n bubbles: true,\n cancelable: true,\n clientX,\n clientY,\n screenX,\n screenY,\n }),\n );\n\n if (isOpened && press === current) claim(current);\n }, LONG_PRESS_DELAY);\n press = current;\n doc.addEventListener('pointerup', release, true);\n doc.addEventListener('pointercancel', release, true);\n doc.addEventListener('pointermove', onPointerMove, true);\n }\n\n function onContextMenu(event: MouseEvent) {\n if (!press) return;\n\n // The platform's own long-press menu, after one has already opened.\n if (press.isClaimed) {\n event.preventDefault();\n event.stopImmediatePropagation();\n\n return;\n }\n\n // This press has its `contextmenu` now: ours, a nested binding's, or the\n // platform's. A native one is the platform's long press; when no handler\n // takes it, the browser shows its own menu and ends the touch anyway.\n clearTimeout(press.timer);\n if (event.isTrusted) claim(press);\n }\n\n function onClick(event: MouseEvent) {\n if (!isSwallowingClick) return;\n\n isSwallowingClick = false;\n event.preventDefault();\n event.stopPropagation();\n }\n\n function onSelectStart(event: Event) {\n if (press) event.preventDefault();\n }\n\n container.addEventListener('pointerdown', onPointerDown, true);\n container.addEventListener('contextmenu', onContextMenu, true);\n container.addEventListener('click', onClick, true);\n container.addEventListener('selectstart', onSelectStart);\n // A native drag takes the press over: reorderable tabs and columns start one\n // on a touch long press too.\n container.addEventListener('dragstart', release);\n\n return () => {\n release();\n clearTimeout(clickTimer);\n container.removeEventListener('pointerdown', onPointerDown, true);\n container.removeEventListener('contextmenu', onContextMenu, true);\n container.removeEventListener('click', onClick, true);\n container.removeEventListener('selectstart', onSelectStart);\n container.removeEventListener('dragstart', release);\n };\n}\n"],"mappings":";;;AACA,MAAMA,mBAAmB;;;;;AAMzB,MAAMC,oBAAoB;;AAG1B,MAAMC,iBAAiB;;AAGvB,MAAMC,aACJ;;;;;AAMF,MAAaC,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;AA+B5C,SAAgBQ,qBAAqBC,WAAoC;CAGvE,IAAI,OAAON,iBAAiB,aAAa,aAAa,CAAC;CAEvD,MAAMQ,MAAMF,UAAUG;CACtB,IAAIC,QAAsB;CAC1B,IAAIC,oBAAoB;CACxB,IAAIC;CAEJ,SAASC,QAAQC,OAAe;EAC9B,IAAI,CAACJ,OAAO;EACZ,IAAII,iBAAiBd,cAAc;GAEjC,IAAIc,MAAME,cAAcN,MAAMX,KAAKiB,WAAW;GAG9C,IAAIF,MAAMG,SAAS,mBAAmB,CAACH,MAAMI,WAAW;EAC1D;EAEAC,aAAaT,MAAMT,KAAK;EACxB,IAAIS,MAAMN,WAAW;GACnBO,oBAAoB;GACpBC,aAAaT,iBAAiB;IAC5BQ,oBAAoB;GACtB,GAAGjB,iBAAiB;EACtB;EACAgB,QAAQ;EACRF,IAAIY,oBAAoB,aAAaP,SAAS,IAAI;EAClDL,IAAIY,oBAAoB,iBAAiBP,SAAS,IAAI;EACtDL,IAAIY,oBAAoB,eAAeC,eAAe,IAAI;CAC5D;CAIA,SAASA,cAAcP,OAAqB;EAC1C,IAAI,CAACJ,SAASA,MAAMN,WAAW;EAC/B,IAAIU,MAAME,cAAcN,MAAMX,KAAKiB,WAAW;EAE9C,MAAM,EAAEM,SAASC,YAAYb,MAAMX;EAEnC,IACEyB,KAAKC,MAAMX,MAAMQ,UAAUA,SAASR,MAAMS,UAAUA,OAAO,IAC3D5B,gBAEAkB,QAAQ;CACZ;CAEA,SAASa,MAAMC,SAAgB;EAC7BA,QAAQvB,YAAY;EACpBuB,QAAQ5B,KAAK6B,QAAQC,c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A,SAASuC,QAAQnC,OAAmB;EAClC,IAAI,CAACH,mBAAmB;EAExBA,oBAAoB;EACpBG,MAAMiC,eAAe;EACrBjC,MAAMoC,gBAAgB;CACxB;CAEA,SAASC,cAAcrC,OAAc;EACnC,IAAIJ,OAAOI,MAAMiC,eAAe;CAClC;CAEAzC,UAAUuC,iBAAiB,eAAed,eAAe,IAAI;CAC7DzB,UAAUuC,iBAAiB,eAAeC,eAAe,IAAI;CAC7DxC,UAAUuC,iBAAiB,SAASI,SAAS,IAAI;CACjD3C,UAAUuC,iBAAiB,eAAeM,aAAa;CAGvD7C,UAAUuC,iBAAiB,aAAahC,OAAO;CAE/C,aAAa;EACXA,QAAQ;EACRM,aAAaP,UAAU;EACvBN,UAAUc,oBAAoB,eAAeW,eAAe,IAAI;EAChEzB,UAAUc,oBAAoB,eAAe0B,eAAe,IAAI;EAChExC,UAAUc,oBAAoB,SAAS6B,SAAS,IAAI;EACpD3C,UAAUc,oBAAoB,eAAe+B,aAAa;EAC1D7C,UAAUc,oBAAoB,aAAaP,OAAO;CACpD;AACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | 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";
|
|
5
|
+
import { omitActivationEventProps } from "../../utils/react/disabledProps.js";
|
|
5
6
|
import { useWarn } from "../../_internal/hooks/use-warn.js";
|
|
6
7
|
import { isExternalUrl, normalizeNavigationUrl } from "../../providers/navigation-url.js";
|
|
7
8
|
import { useTracking } from "../../providers/TrackingProvider.js";
|
|
@@ -236,6 +237,7 @@ const useAction = function useAction(t0, ref) {
|
|
|
236
237
|
}, domRef);
|
|
237
238
|
const { hoverProps, isHovered } = useHover({ isDisabled });
|
|
238
239
|
const { focusProps, isFocused } = useFocus$1(true);
|
|
240
|
+
const pressProps = isDisabled ? omitActivationEventProps(buttonProps) : buttonProps;
|
|
239
241
|
const customProps = cleanTo !== void 0 ? { onClick(evt_0) {
|
|
240
242
|
evt_0.preventDefault();
|
|
241
243
|
} } : {};
|
|
@@ -255,7 +257,7 @@ const useAction = function useAction(t0, ref) {
|
|
|
255
257
|
disabled: isDisabled,
|
|
256
258
|
...mods
|
|
257
259
|
},
|
|
258
|
-
...mergeProps$1(
|
|
260
|
+
...mergeProps$1(pressProps, hoverProps, focusProps, customProps, filterBaseProps(props, FILTER_OPTIONS)),
|
|
259
261
|
ref: domRef,
|
|
260
262
|
type: as === "button" ? htmlType || "button" : void 0,
|
|
261
263
|
...t4,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-action.js","names":["useFocusableRef","FocusableRef","PressEvent","AllBaseProps","filterBaseProps","TagName","AriaButtonProps","useButton","useHover","useEvent","useWarn","isExternalUrl","normalizeNavigationUrl","useTracking","useNavigation","useFocus","mergeProps","NavigateArg","NavigateOptions","Path","To","LINK_PRESS_EVENT","BUTTON_PRESS_EVENT","NavigateLike","RelativeRoutingType","CubeUseActionProps","T","Omit","to","label","htmlType","navigationOptions","FILTER_OPTIONS","propNames","Set","openLink","href","target","link","document","createElement","rel","body","appendChild","click","removeChild","parseTo","newTab","nativeRoute","cleanTo","isHistoryNavigation","historyDelta","isHashNavigation","isExternal","undefined","value","startsWith","slice","SanitizedPressEvent","type","pointerType","shiftKey","metaKey","ctrlKey","altKey","key","sanitizePressEvent","evt","safeEvt","Object","defineProperty","enumerable","configurable","e","performClickHandler","navigate","resolvedHref","onPress","tracking","element","qa","getAttribute","event","delta","id","targetElement","getElementById","scrollIntoView","behavior","block","inline","window","location","reload","assign","useAction","t0","ref","$","_c","as","mods","props","t1","Symbol","for","args","isDisabled","t2","domRef","mergedNavigationOptions","t3","customOnPress","buttonProps","isPressed","hoverProps","isHovered","focusProps","isFocused","customProps","onClick","evt_0","preventDefault","t4","autoFocus","actionProps","hovered","pressed","focused","disabled","_c","useFocus","mergeProps"],"sources":["../../../src/components/actions/use-action.ts"],"sourcesContent":["import { useFocusableRef } from '@react-spectrum/utils';\nimport { FocusableRef, PressEvent } from '@react-types/shared';\nimport { AllBaseProps, filterBaseProps, TagName } from '@tenphi/tasty';\nimport { AriaButtonProps, useButton, useHover } from 'react-aria';\n\nimport { useEvent } from '../../_internal/hooks/use-event';\nimport { useWarn } from '../../_internal/hooks/use-warn';\nimport {\n isExternalUrl,\n normalizeNavigationUrl,\n} from '../../providers/navigation-url';\nimport { useTracking } from '../../providers/TrackingProvider';\nimport { useNavigation } from '../../providers/use-navigation';\nimport { useFocus } from '../../utils/react/interactions';\nimport { mergeProps } from '../../utils/react/mergeProps';\n\n// Import specific types for internal usage\nimport type {\n NavigateArg,\n NavigateOptions,\n Path,\n To,\n} from '../../providers/navigation.types';\n\nconst LINK_PRESS_EVENT = 'Link Press';\nconst BUTTON_PRESS_EVENT = 'Button Press';\n\n// Re-export types for convenience\nexport type {\n NavigateLike,\n Path,\n To,\n NavigateArg,\n NavigateOptions,\n RelativeRoutingType,\n} from '../../providers/navigation.types';\n\nexport interface CubeUseActionProps<\n T extends TagName = 'a' | 'button' | 'span' | 'div',\n>\n extends\n AllBaseProps<T>,\n Omit<AriaButtonProps, keyof AllBaseProps<T> | 'type'> {\n to?: NavigateArg;\n /**\n * @deprecated Use `aria-label` for the accessible name, and `children` for\n * visible text. Not every action honours it: `ItemAction` ignores it.\n */\n label?: string;\n htmlType?: 'button' | 'submit' | 'reset' | undefined;\n navigationOptions?: NavigateOptions;\n}\n\nconst FILTER_OPTIONS = { propNames: new Set(['onMouseEnter', 'onMouseLeave']) };\n\n/**\n * Helper to open link.\n * @param {String} href\n * @param {String|Boolean} [target]\n */\nexport function openLink(href, target?) {\n const link = document.createElement('a');\n\n link.href = href;\n\n if (target) {\n link.target = target === true ? '_blank' : target;\n // Prevent reverse tabnabbing when opening in a new tab\n link.rel = 'noopener noreferrer';\n }\n\n document.body.appendChild(link);\n\n link.click();\n\n document.body.removeChild(link);\n}\n\nexport function parseTo(to: NavigateArg | undefined): {\n newTab: boolean;\n nativeRoute: boolean;\n cleanTo: To | undefined;\n isHistoryNavigation: boolean;\n historyDelta?: number;\n isHashNavigation: boolean;\n isExternal: boolean;\n} {\n // Handle number (history navigation)\n if (typeof to === 'number') {\n return {\n newTab: false,\n nativeRoute: false,\n cleanTo: undefined,\n isHistoryNavigation: true,\n historyDelta: to,\n isHashNavigation: false,\n isExternal: false,\n };\n }\n\n // Handle object path\n if (to && typeof to === 'object') {\n return {\n newTab: false,\n nativeRoute: false,\n cleanTo: to,\n isHistoryNavigation: false,\n isHashNavigation: false,\n isExternal: false,\n };\n }\n\n // Handle string. Clean it first, as the URL parser does, so ` !https://…`\n // still opens a tab and a blank value counts as no destination.\n const value = typeof to === 'string' ? normalizeNavigationUrl(to) : '';\n\n if (!value) {\n return {\n newTab: false,\n nativeRoute: false,\n cleanTo: undefined,\n isHistoryNavigation: false,\n isHashNavigation: false,\n isExternal: false,\n };\n }\n\n const newTab = value.startsWith('!');\n const nativeRoute = value.startsWith('@');\n const isHashNavigation = value.startsWith('#');\n const cleanTo =\n newTab || nativeRoute ? normalizeNavigationUrl(value.slice(1)) : value;\n const isExternal = isExternalUrl(cleanTo);\n\n return {\n newTab,\n nativeRoute,\n cleanTo,\n isHistoryNavigation: false,\n isHashNavigation,\n isExternal,\n };\n}\n\ninterface SanitizedPressEvent {\n type?: string;\n pointerType?: string;\n shiftKey: boolean;\n metaKey: boolean;\n ctrlKey: boolean;\n altKey: boolean;\n // target is defined as a non-enumerable property below\n [key: string]: unknown; // allow non-enumerable 'target'\n}\n\nfunction sanitizePressEvent(evt: PressEvent): SanitizedPressEvent {\n const safeEvt: SanitizedPressEvent = {\n type: 'type' in evt ? evt.type : undefined,\n pointerType:\n 'pointerType' in evt\n ? (evt as { pointerType?: string }).pointerType\n : undefined,\n shiftKey:\n 'shiftKey' in evt ? !!(evt as { shiftKey?: boolean }).shiftKey : false,\n metaKey:\n 'metaKey' in evt ? !!(evt as { metaKey?: boolean }).metaKey : false,\n ctrlKey:\n 'ctrlKey' in evt ? !!(evt as { ctrlKey?: boolean }).ctrlKey : false,\n altKey: 'altKey' in evt ? !!(evt as { altKey?: boolean }).altKey : false,\n };\n try {\n Object.defineProperty(safeEvt, 'target', {\n value: 'target' in evt ? (evt as { target?: unknown }).target : undefined,\n enumerable: false,\n configurable: true,\n });\n } catch (e) {\n // Failed to define target property - continue without it\n }\n return safeEvt;\n}\n\nexport function performClickHandler(\n evt,\n { navigate, resolvedHref, to, onPress, tracking, navigationOptions },\n) {\n const {\n newTab,\n nativeRoute,\n cleanTo,\n isHistoryNavigation,\n historyDelta,\n isHashNavigation,\n isExternal,\n } = parseTo(to);\n const element = evt.target;\n const qa = element?.getAttribute('data-qa');\n\n onPress?.(sanitizePressEvent(evt));\n\n if (to == null) {\n // Allow 0 as valid navigation (go to current page)\n tracking.event(BUTTON_PRESS_EVENT, { qa }, element);\n return;\n }\n\n // Handle history navigation (back/forward)\n if (isHistoryNavigation && typeof historyDelta === 'number') {\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, delta: historyDelta, type: 'router-history' },\n element,\n );\n navigate(historyDelta);\n return;\n }\n\n // Handle hash navigation (smooth scroll)\n if (isHashNavigation && typeof cleanTo === 'string') {\n const id = cleanTo.slice(1);\n const targetElement = document.getElementById(id);\n\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: cleanTo, type: 'hash', target: id },\n element,\n );\n\n if (targetElement) {\n targetElement.scrollIntoView({\n behavior: 'smooth',\n block: 'start',\n inline: 'nearest',\n });\n }\n return;\n }\n\n // Handle new tab (via ! prefix or user modifiers)\n if (evt.shiftKey || evt.metaKey || (evt as any).ctrlKey || newTab) {\n openLink(resolvedHref, true);\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: resolvedHref, type: 'tab' },\n element,\n );\n return;\n }\n\n // Handle @ prefix (native navigation)\n if (nativeRoute) {\n if (cleanTo === '' || cleanTo === undefined) {\n // @'' or @ -> reload current page\n tracking.event(LINK_PRESS_EVENT, { qa, type: 'native' }, element);\n window.location.reload();\n } else {\n // @path -> navigate to resolved path natively\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: resolvedHref, type: 'native' },\n element,\n );\n window.location.assign(resolvedHref);\n }\n return;\n }\n\n // Handle external URLs (always native)\n if (isExternal && typeof cleanTo === 'string') {\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: cleanTo, type: 'native' },\n element,\n );\n window.location.assign(cleanTo);\n return;\n }\n\n // Handle router navigation\n if (cleanTo !== undefined) {\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: resolvedHref, type: 'router' },\n element,\n );\n navigate(cleanTo, navigationOptions);\n }\n}\n\nexport const useAction = function useAction(\n {\n to,\n as,\n htmlType,\n label,\n mods,\n onPress,\n navigationOptions,\n ...props\n }: CubeUseActionProps,\n ref: FocusableRef<HTMLElement>,\n) {\n useWarn(label !== undefined, {\n key: 'action-label-deprecated',\n args: [\n 'The \"label\" property of Button, ItemButton, ItemAction and Action is deprecated. Use \"aria-label\" for the accessible name and \"children\" for visible text.',\n ],\n });\n\n const tracking = useTracking();\n const isDisabled = props.isDisabled;\n\n const {\n newTab,\n nativeRoute,\n cleanTo,\n isHistoryNavigation,\n isHashNavigation,\n isExternal,\n } = parseTo(to);\n\n // Resolve the path with its `!` / `@` prefix stripped, and only that. Also\n // resolving the raw `to` put `!https://…` through the router as a route,\n // which a HashRouter warned about on every render.\n const { navigate, resolvedHref } = useNavigation(cleanTo || '.');\n\n // Determine element type: 'a' for navigation, 'button' for actions\n as = cleanTo !== undefined ? 'a' : as || 'button';\n\n // Compute target (prefixes override explicit target prop per spec)\n const target = newTab ? '_blank' : props.target;\n\n // Compute href for anchor elements\n let href: string | undefined;\n if (as === 'a' && cleanTo !== undefined) {\n if (newTab || nativeRoute) {\n // For ! and @ prefixes, resolve the clean path\n href =\n typeof cleanTo === 'string' && isExternal\n ? cleanTo // External URLs as-is\n : resolvedHref;\n } else {\n // Regular navigation\n href = resolvedHref;\n }\n }\n\n const domRef = useFocusableRef(ref);\n\n // Use navigation options directly\n const mergedNavigationOptions = navigationOptions;\n\n const customOnPress = useEvent((evt: PressEvent) => {\n performClickHandler(evt, {\n navigate,\n resolvedHref: href || resolvedHref,\n to,\n onPress,\n tracking,\n navigationOptions: mergedNavigationOptions,\n });\n });\n\n // Native DOM props keep their HTML event targets and value types. Aria\n // handles the same element and forwards value without changing it.\n let { buttonProps, isPressed } = useButton(\n {\n 'aria-label': label, // deprecated, see `CubeUseActionProps.label`\n ...props,\n onPress: customOnPress,\n type: htmlType ?? 'button',\n } as AriaButtonProps,\n domRef,\n );\n let { hoverProps, isHovered } = useHover({ isDisabled });\n let { focusProps, isFocused } = useFocus(true);\n\n const customProps =\n cleanTo !== undefined\n ? {\n onClick(evt) {\n evt.preventDefault();\n },\n }\n : {};\n\n return {\n isPressed,\n actionProps: {\n mods: {\n hovered: isHovered && !isDisabled,\n pressed: isPressed && !isDisabled,\n // A disabled action that keeps focus (`aria-disabled`, see\n // `getDisabledElementProps`) still shows where focus is.\n focused: isFocused,\n disabled: isDisabled,\n ...mods,\n },\n ...(mergeProps(\n buttonProps,\n hoverProps,\n focusProps,\n customProps,\n filterBaseProps(props, FILTER_OPTIONS),\n ) as object),\n ref: domRef,\n // Only a button has a `type`: on a link it would name the linked\n // resource's MIME type. This also overrides the one `useButton` adds.\n type: as === 'button' ? htmlType || 'button' : undefined,\n // `autoFocus` acts when the action mounts, and a dialog kept mounted\n // while closed (`hideOnClose`) mounts hidden: it focuses the marked\n // control on every open instead.\n ...(props.autoFocus ? { 'data-autofocus': '' } : undefined),\n rel: as === 'a' && newTab ? 'noopener noreferrer' : undefined,\n as,\n isDisabled,\n target,\n href,\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAw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CACvC;GAAWiE,KACNY;GAAMlD,MAGLyC,OAAO,WAAWtE,YAAA,WAAlBwB,KAAAA;GAAkD,GAIpDqE;GAAsDlF,KACrD2D,OAAO,OAAPrD,SAAA,wBAAAO,KAAAA;GAAwD8C;GAAAO;GAAAtE;GAAAD;EAK/D;CACF;AAAC"}
|
|
1
|
+
{"version":3,"file":"use-action.js","names":["useFocusableRef","FocusableRef","PressEvent","AllBaseProps","filterBaseProps","TagName","AriaButtonProps","useButton","useHover","useEvent","useWarn","isExternalUrl","normalizeNavigationUrl","useTracking","useNavigation","omitActivationEventProps","useFocus","mergeProps","NavigateArg","NavigateOptions","Path","To","LINK_PRESS_EVENT","BUTTON_PRESS_EVENT","NavigateLike","RelativeRoutingType","CubeUseActionProps","T","Omit","to","label","htmlType","navigationOptions","FILTER_OPTIONS","propNames","Set","openLink","href","target","link","document","createElement","rel","body","appendChild","click","removeChild","parseTo","newTab","nativeRoute","cleanTo","isHistoryNavigation","historyDelta","isHashNavigation","isExternal","undefined","value","startsWith","slice","SanitizedPressEvent","type","pointerType","shiftKey","metaKey","ctrlKey","altKey","key","sanitizePressEvent","evt","safeEvt","Object","defineProperty","enumerable","configurable","e","performClickHandler","navigate","resolvedHref","onPress","tracking","element","qa","getAttribute","event","delta","id","targetElement","getElementById","scrollIntoView","behavior","block","inline","window","location","reload","assign","useAction","t0","ref","$","_c","as","mods","props","t1","Symbol","for","args","isDisabled","t2","domRef","mergedNavigationOptions","t3","customOnPress","buttonProps","isPressed","hoverProps","isHovered","focusProps","isFocused","pressProps","customProps","onClick","evt_0","preventDefault","t4","autoFocus","actionProps","hovered","pressed","focused","disabled","_c","useFocus","mergeProps"],"sources":["../../../src/components/actions/use-action.ts"],"sourcesContent":["import { useFocusableRef } from '@react-spectrum/utils';\nimport { FocusableRef, PressEvent } from '@react-types/shared';\nimport { AllBaseProps, filterBaseProps, TagName } from '@tenphi/tasty';\nimport { AriaButtonProps, useButton, useHover } from 'react-aria';\n\nimport { useEvent } from '../../_internal/hooks/use-event';\nimport { useWarn } from '../../_internal/hooks/use-warn';\nimport {\n isExternalUrl,\n normalizeNavigationUrl,\n} from '../../providers/navigation-url';\nimport { useTracking } from '../../providers/TrackingProvider';\nimport { useNavigation } from '../../providers/use-navigation';\nimport { omitActivationEventProps } from '../../utils/react/disabledProps';\nimport { useFocus } from '../../utils/react/interactions';\nimport { mergeProps } from '../../utils/react/mergeProps';\n\n// Import specific types for internal usage\nimport type {\n NavigateArg,\n NavigateOptions,\n Path,\n To,\n} from '../../providers/navigation.types';\n\nconst LINK_PRESS_EVENT = 'Link Press';\nconst BUTTON_PRESS_EVENT = 'Button Press';\n\n// Re-export types for convenience\nexport type {\n NavigateLike,\n Path,\n To,\n NavigateArg,\n NavigateOptions,\n RelativeRoutingType,\n} from '../../providers/navigation.types';\n\nexport interface CubeUseActionProps<\n T extends TagName = 'a' | 'button' | 'span' | 'div',\n>\n extends\n AllBaseProps<T>,\n Omit<AriaButtonProps, keyof AllBaseProps<T> | 'type'> {\n to?: NavigateArg;\n /**\n * @deprecated Use `aria-label` for the accessible name, and `children` for\n * visible text. Not every action honours it: `ItemAction` ignores it.\n */\n label?: string;\n htmlType?: 'button' | 'submit' | 'reset' | undefined;\n navigationOptions?: NavigateOptions;\n}\n\nconst FILTER_OPTIONS = { propNames: new Set(['onMouseEnter', 'onMouseLeave']) };\n\n/**\n * Helper to open link.\n * @param {String} href\n * @param {String|Boolean} [target]\n */\nexport function openLink(href, target?) {\n const link = document.createElement('a');\n\n link.href = href;\n\n if (target) {\n link.target = target === true ? '_blank' : target;\n // Prevent reverse tabnabbing when opening in a new tab\n link.rel = 'noopener noreferrer';\n }\n\n document.body.appendChild(link);\n\n link.click();\n\n document.body.removeChild(link);\n}\n\nexport function parseTo(to: NavigateArg | undefined): {\n newTab: boolean;\n nativeRoute: boolean;\n cleanTo: To | undefined;\n isHistoryNavigation: boolean;\n historyDelta?: number;\n isHashNavigation: boolean;\n isExternal: boolean;\n} {\n // Handle number (history navigation)\n if (typeof to === 'number') {\n return {\n newTab: false,\n nativeRoute: false,\n cleanTo: undefined,\n isHistoryNavigation: true,\n historyDelta: to,\n isHashNavigation: false,\n isExternal: false,\n };\n }\n\n // Handle object path\n if (to && typeof to === 'object') {\n return {\n newTab: false,\n nativeRoute: false,\n cleanTo: to,\n isHistoryNavigation: false,\n isHashNavigation: false,\n isExternal: false,\n };\n }\n\n // Handle string. Clean it first, as the URL parser does, so ` !https://…`\n // still opens a tab and a blank value counts as no destination.\n const value = typeof to === 'string' ? normalizeNavigationUrl(to) : '';\n\n if (!value) {\n return {\n newTab: false,\n nativeRoute: false,\n cleanTo: undefined,\n isHistoryNavigation: false,\n isHashNavigation: false,\n isExternal: false,\n };\n }\n\n const newTab = value.startsWith('!');\n const nativeRoute = value.startsWith('@');\n const isHashNavigation = value.startsWith('#');\n const cleanTo =\n newTab || nativeRoute ? normalizeNavigationUrl(value.slice(1)) : value;\n const isExternal = isExternalUrl(cleanTo);\n\n return {\n newTab,\n nativeRoute,\n cleanTo,\n isHistoryNavigation: false,\n isHashNavigation,\n isExternal,\n };\n}\n\ninterface SanitizedPressEvent {\n type?: string;\n pointerType?: string;\n shiftKey: boolean;\n metaKey: boolean;\n ctrlKey: boolean;\n altKey: boolean;\n // target is defined as a non-enumerable property below\n [key: string]: unknown; // allow non-enumerable 'target'\n}\n\nfunction sanitizePressEvent(evt: PressEvent): SanitizedPressEvent {\n const safeEvt: SanitizedPressEvent = {\n type: 'type' in evt ? evt.type : undefined,\n pointerType:\n 'pointerType' in evt\n ? (evt as { pointerType?: string }).pointerType\n : undefined,\n shiftKey:\n 'shiftKey' in evt ? !!(evt as { shiftKey?: boolean }).shiftKey : false,\n metaKey:\n 'metaKey' in evt ? !!(evt as { metaKey?: boolean }).metaKey : false,\n ctrlKey:\n 'ctrlKey' in evt ? !!(evt as { ctrlKey?: boolean }).ctrlKey : false,\n altKey: 'altKey' in evt ? !!(evt as { altKey?: boolean }).altKey : false,\n };\n try {\n Object.defineProperty(safeEvt, 'target', {\n value: 'target' in evt ? (evt as { target?: unknown }).target : undefined,\n enumerable: false,\n configurable: true,\n });\n } catch (e) {\n // Failed to define target property - continue without it\n }\n return safeEvt;\n}\n\nexport function performClickHandler(\n evt,\n { navigate, resolvedHref, to, onPress, tracking, navigationOptions },\n) {\n const {\n newTab,\n nativeRoute,\n cleanTo,\n isHistoryNavigation,\n historyDelta,\n isHashNavigation,\n isExternal,\n } = parseTo(to);\n const element = evt.target;\n const qa = element?.getAttribute('data-qa');\n\n onPress?.(sanitizePressEvent(evt));\n\n if (to == null) {\n // Allow 0 as valid navigation (go to current page)\n tracking.event(BUTTON_PRESS_EVENT, { qa }, element);\n return;\n }\n\n // Handle history navigation (back/forward)\n if (isHistoryNavigation && typeof historyDelta === 'number') {\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, delta: historyDelta, type: 'router-history' },\n element,\n );\n navigate(historyDelta);\n return;\n }\n\n // Handle hash navigation (smooth scroll)\n if (isHashNavigation && typeof cleanTo === 'string') {\n const id = cleanTo.slice(1);\n const targetElement = document.getElementById(id);\n\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: cleanTo, type: 'hash', target: id },\n element,\n );\n\n if (targetElement) {\n targetElement.scrollIntoView({\n behavior: 'smooth',\n block: 'start',\n inline: 'nearest',\n });\n }\n return;\n }\n\n // Handle new tab (via ! prefix or user modifiers)\n if (evt.shiftKey || evt.metaKey || (evt as any).ctrlKey || newTab) {\n openLink(resolvedHref, true);\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: resolvedHref, type: 'tab' },\n element,\n );\n return;\n }\n\n // Handle @ prefix (native navigation)\n if (nativeRoute) {\n if (cleanTo === '' || cleanTo === undefined) {\n // @'' or @ -> reload current page\n tracking.event(LINK_PRESS_EVENT, { qa, type: 'native' }, element);\n window.location.reload();\n } else {\n // @path -> navigate to resolved path natively\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: resolvedHref, type: 'native' },\n element,\n );\n window.location.assign(resolvedHref);\n }\n return;\n }\n\n // Handle external URLs (always native)\n if (isExternal && typeof cleanTo === 'string') {\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: cleanTo, type: 'native' },\n element,\n );\n window.location.assign(cleanTo);\n return;\n }\n\n // Handle router navigation\n if (cleanTo !== undefined) {\n tracking.event(\n LINK_PRESS_EVENT,\n { qa, href: resolvedHref, type: 'router' },\n element,\n );\n navigate(cleanTo, navigationOptions);\n }\n}\n\nexport const useAction = function useAction(\n {\n to,\n as,\n htmlType,\n label,\n mods,\n onPress,\n navigationOptions,\n ...props\n }: CubeUseActionProps,\n ref: FocusableRef<HTMLElement>,\n) {\n useWarn(label !== undefined, {\n key: 'action-label-deprecated',\n args: [\n 'The \"label\" property of Button, ItemButton, ItemAction and Action is deprecated. Use \"aria-label\" for the accessible name and \"children\" for visible text.',\n ],\n });\n\n const tracking = useTracking();\n const isDisabled = props.isDisabled;\n\n const {\n newTab,\n nativeRoute,\n cleanTo,\n isHistoryNavigation,\n isHashNavigation,\n isExternal,\n } = parseTo(to);\n\n // Resolve the path with its `!` / `@` prefix stripped, and only that. Also\n // resolving the raw `to` put `!https://…` through the router as a route,\n // which a HashRouter warned about on every render.\n const { navigate, resolvedHref } = useNavigation(cleanTo || '.');\n\n // Determine element type: 'a' for navigation, 'button' for actions\n as = cleanTo !== undefined ? 'a' : as || 'button';\n\n // Compute target (prefixes override explicit target prop per spec)\n const target = newTab ? '_blank' : props.target;\n\n // Compute href for anchor elements\n let href: string | undefined;\n if (as === 'a' && cleanTo !== undefined) {\n if (newTab || nativeRoute) {\n // For ! and @ prefixes, resolve the clean path\n href =\n typeof cleanTo === 'string' && isExternal\n ? cleanTo // External URLs as-is\n : resolvedHref;\n } else {\n // Regular navigation\n href = resolvedHref;\n }\n }\n\n const domRef = useFocusableRef(ref);\n\n // Use navigation options directly\n const mergedNavigationOptions = navigationOptions;\n\n const customOnPress = useEvent((evt: PressEvent) => {\n performClickHandler(evt, {\n navigate,\n resolvedHref: href || resolvedHref,\n to,\n onPress,\n tracking,\n navigationOptions: mergedNavigationOptions,\n });\n });\n\n // Native DOM props keep their HTML event targets and value types. Aria\n // handles the same element and forwards value without changing it.\n let { buttonProps, isPressed } = useButton(\n {\n 'aria-label': label, // deprecated, see `CubeUseActionProps.label`\n ...props,\n onPress: customOnPress,\n type: htmlType ?? 'button',\n } as AriaButtonProps,\n domRef,\n );\n let { hoverProps, isHovered } = useHover({ isDisabled });\n let { focusProps, isFocused } = useFocus(true);\n\n // A disabled action takes no press handlers, as `omitActivationEventProps`\n // explains: a press on a natively disabled `<button>` would otherwise make the\n // first press after it is enabled do nothing.\n const pressProps = isDisabled\n ? omitActivationEventProps(buttonProps)\n : buttonProps;\n\n const customProps =\n cleanTo !== undefined\n ? {\n onClick(evt) {\n evt.preventDefault();\n },\n }\n : {};\n\n return {\n isPressed,\n actionProps: {\n mods: {\n hovered: isHovered && !isDisabled,\n pressed: isPressed && !isDisabled,\n // A disabled action that keeps focus (`aria-disabled`, see\n // `getDisabledElementProps`) still shows where focus is.\n focused: isFocused,\n disabled: isDisabled,\n ...mods,\n },\n ...(mergeProps(\n pressProps,\n hoverProps,\n focusProps,\n customProps,\n filterBaseProps(props, FILTER_OPTIONS),\n ) as object),\n ref: domRef,\n // Only a button has a `type`: on a link it would name the linked\n // resource's MIME type. This also overrides the one `useButton` adds.\n type: as === 'button' ? htmlType || 'button' : undefined,\n // `autoFocus` acts when the action mounts, and a dialog kept mounted\n // while closed (`hideOnClose`) mounts hidden: it focuses the marked\n // control on every open instead.\n ...(props.autoFocus ? { 'data-autofocus': '' } : undefined),\n rel: as === 'a' && newTab ? 'noopener noreferrer' : undefined,\n as,\n isDisabled,\n target,\n href,\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAMsB,mBAAmB;AACzB,MAAMC,qBAAqB;AA4B3B,MAAMU,iBAAiB,EAAEC,2BAAW,IAAIC,IAAI,CAAC,gBAAgB,cAAc,CAAC,EAAE;;;;;;A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D,GAIpDsE;GAAsDnF,KACrD2D,OAAO,OAAPrD,SAAA,wBAAAO,KAAAA;GAAwD8C;GAAAO;GAAAtE;GAAAD;EAK/D;CACF;AAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | 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 { useI18n } from "../../i18n/useI18n.js";
|
|
@@ -5,7 +5,10 @@ import { ComponentProps, ComponentType, MouseEvent, PointerEvent, ReactElement,
|
|
|
5
5
|
type NativeMouseEvent = globalThis.MouseEvent;
|
|
6
6
|
type NativePointerEvent = globalThis.PointerEvent;
|
|
7
7
|
export interface UseContextMenuReturn<E extends HTMLElement = HTMLElement, P extends object = {}, T = ComponentProps<typeof _MenuTrigger>> {
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Container element that receives `contextmenu` events: a right-click or a
|
|
10
|
+
* touch long press. Attach this ref to your target element.
|
|
11
|
+
*/
|
|
9
12
|
targetRef: RefObject<E | null>;
|
|
10
13
|
/**
|
|
11
14
|
* Programmatically opens the menu at the specified coordinates or element center.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-2615f95 | 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 { useI18n } from "../../i18n/useI18n.js";
|
|
5
5
|
import { usePopoverSync } from "../../utils/react/usePopoverSync.js";
|
|
6
6
|
import { generateRandomId } from "../../utils/random.js";
|
|
7
7
|
import { MenuTrigger as _MenuTrigger } from "./Menu/MenuTrigger.js";
|
|
8
|
+
import { TOUCH_CONTEXT_MENU_ATTRIBUTE, bindTouchContextMenu } from "./touch-context-menu.js";
|
|
8
9
|
import { tasty } from "@tenphi/tasty";
|
|
9
10
|
import { createRef, useEffect, useMemo, useRef, useState } from "react";
|
|
10
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -153,8 +154,12 @@ function useContextMenu(Component, defaultTriggerProps, defaultMenuProps) {
|
|
|
153
154
|
const element = targetRef.current;
|
|
154
155
|
if (!element) return;
|
|
155
156
|
element.addEventListener("contextmenu", onContextMenu);
|
|
157
|
+
element.setAttribute(TOUCH_CONTEXT_MENU_ATTRIBUTE, "");
|
|
158
|
+
const unbindTouch = bindTouchContextMenu(element);
|
|
156
159
|
return () => {
|
|
157
160
|
element.removeEventListener("contextmenu", onContextMenu);
|
|
161
|
+
element.removeAttribute(TOUCH_CONTEXT_MENU_ATTRIBUTE);
|
|
162
|
+
unbindTouch();
|
|
158
163
|
};
|
|
159
164
|
}, [onContextMenu]);
|
|
160
165
|
const renderedMenu = useMemo(() => {
|