@cube-dev/ui-kit 0.138.6 → 0.140.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CHANGELOG.md +67 -0
- package/dist/_internal/hooks/use-chained-callback.js +1 -1
- package/dist/_internal/hooks/use-debounced-value.js +1 -1
- package/dist/_internal/hooks/use-deprecation-warning.js +1 -1
- package/dist/_internal/hooks/use-event.js +1 -1
- package/dist/_internal/hooks/use-is-first-render.js +1 -1
- package/dist/_internal/hooks/use-sync-ref.js +1 -1
- package/dist/_internal/hooks/use-timer/timer.js +1 -1
- package/dist/_internal/hooks/use-timer/use-timer.js +1 -1
- package/dist/_internal/hooks/use-warn.js +1 -1
- package/dist/components/Block.js +1 -1
- package/dist/components/CollectionItem.js +1 -1
- package/dist/components/GlobalStyles.js +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/Button.d.ts +2 -2
- package/dist/components/actions/Button/Button.js +11 -17
- package/dist/components/actions/Button/Button.js.map +1 -1
- package/dist/components/actions/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/actions/ButtonSplit/ButtonSplit.js +1 -1
- package/dist/components/actions/ButtonSplit/context.js +1 -1
- package/dist/components/actions/CommandMenu/CommandMenu.js +1 -1
- package/dist/components/actions/CommandMenu/styled.js +1 -1
- package/dist/components/actions/ItemAction/ItemAction.d.ts +2 -2
- package/dist/components/actions/ItemAction/ItemAction.js +8 -22
- package/dist/components/actions/ItemAction/ItemAction.js.map +1 -1
- package/dist/components/actions/ItemActionContext.js +2 -2
- package/dist/components/actions/ItemActionContext.js.map +1 -1
- package/dist/components/actions/ItemButton/ItemButton.js +3 -3
- package/dist/components/actions/ItemButton/ItemButton.js.map +1 -1
- package/dist/components/actions/Link/Link.js +1 -1
- package/dist/components/actions/Menu/Menu.js +1 -1
- package/dist/components/actions/Menu/MenuItem.js +1 -1
- package/dist/components/actions/Menu/MenuSection.js +1 -1
- package/dist/components/actions/Menu/MenuTrigger.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 +3 -3
- package/dist/components/actions/Menu/styled.js.map +1 -1
- package/dist/components/actions/index.js +1 -1
- package/dist/components/actions/use-action.js +1 -1
- package/dist/components/actions/use-anchored-menu.js +1 -1
- package/dist/components/actions/use-context-menu.js +1 -1
- package/dist/components/content/ActiveZone/ActiveZone.js +1 -1
- package/dist/components/content/Alert/Alert.js +1 -1
- package/dist/components/content/Alert/use-alert.js +1 -1
- package/dist/components/content/Avatar/Avatar.js +1 -1
- package/dist/components/content/Badge/Badge.js +1 -1
- package/dist/components/content/Card/Card.js +1 -1
- package/dist/components/content/Content.js +1 -1
- package/dist/components/content/CopyPasteBlock/CopyPasteBlock.js +1 -1
- package/dist/components/content/CopySnippet/CopySnippet.js +1 -1
- package/dist/components/content/Disclosure/Disclosure.js +1 -1
- package/dist/components/content/Divider.js +1 -1
- package/dist/components/content/Footer.js +1 -1
- package/dist/components/content/Header.js +1 -1
- package/dist/components/content/HotKeys/HotKeys.js +1 -1
- package/dist/components/content/InlineInput/InlineInput.js +1 -1
- package/dist/components/content/Item/Item.d.ts +3 -3
- package/dist/components/content/Item/Item.js +19 -25
- package/dist/components/content/Item/Item.js.map +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.d.ts +2 -2
- package/dist/components/content/ItemBadge/ItemBadge.js +12 -18
- package/dist/components/content/ItemBadge/ItemBadge.js.map +1 -1
- package/dist/components/content/ItemCard/ItemCard.js +1 -1
- package/dist/components/content/Layout/GridLayout.js +1 -1
- package/dist/components/content/Layout/Layout.js +1 -1
- package/dist/components/content/Layout/LayoutBlock.js +1 -1
- package/dist/components/content/Layout/LayoutCenter.js +1 -1
- package/dist/components/content/Layout/LayoutContainer.js +1 -1
- package/dist/components/content/Layout/LayoutContent.js +1 -1
- package/dist/components/content/Layout/LayoutContext.js +1 -1
- package/dist/components/content/Layout/LayoutFlex.js +1 -1
- package/dist/components/content/Layout/LayoutFooter.js +1 -1
- package/dist/components/content/Layout/LayoutGrid.js +1 -1
- package/dist/components/content/Layout/LayoutHeader.js +2 -2
- package/dist/components/content/Layout/LayoutHeader.js.map +1 -1
- package/dist/components/content/Layout/LayoutPane.js +1 -1
- package/dist/components/content/Layout/LayoutPanel.js +1 -1
- package/dist/components/content/Layout/LayoutPanelHeader.js +1 -1
- package/dist/components/content/Layout/LayoutToolbar.js +1 -1
- package/dist/components/content/Layout/hooks/useTinyScrollbar.js +1 -1
- package/dist/components/content/Layout/index.js +1 -1
- package/dist/components/content/Layout/utils.js +1 -1
- package/dist/components/content/Paragraph.js +1 -1
- package/dist/components/content/Placeholder/Placeholder.js +1 -1
- package/dist/components/content/PrismCode/PrismCode.js +1 -1
- package/dist/components/content/PrismCode/prismSetup.js +1 -1
- package/dist/components/content/PrismDiffCode/PrismDiffCode.js +1 -1
- package/dist/components/content/Result/Result.js +1 -1
- package/dist/components/content/Skeleton/Skeleton.js +1 -1
- package/dist/components/content/Tag/Tag.js +1 -1
- package/dist/components/content/Text.js +1 -1
- package/dist/components/content/TextItem/TextItem.js +1 -1
- package/dist/components/content/Title.js +1 -1
- package/dist/components/content/Tree/Tree.js +1 -1
- package/dist/components/content/Tree/TreeNode.js +1 -1
- package/dist/components/content/Tree/styled.js +1 -1
- package/dist/components/content/Tree/tree-index.js +1 -1
- package/dist/components/content/Tree/use-checkbox-tree.js +1 -1
- package/dist/components/content/Tree/use-load-data.js +1 -1
- package/dist/components/content/highlightText.js +1 -1
- package/dist/components/content/use-auto-tooltip.js +1 -1
- package/dist/components/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/ComboBox/ComboBox.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/TimeInput.js +1 -1
- package/dist/components/fields/DatePicker/intl.js +1 -1
- package/dist/components/fields/DatePicker/parseDate.js +1 -1
- package/dist/components/fields/DatePicker/props.js +1 -1
- package/dist/components/fields/DatePicker/utils.js +1 -1
- package/dist/components/fields/FileInput/FileInput.js +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.js +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.d.ts +8 -0
- package/dist/components/fields/FilterPicker/FilterPicker.js +14 -10
- package/dist/components/fields/FilterPicker/FilterPicker.js.map +1 -1
- package/dist/components/fields/Input/Input.js +1 -1
- package/dist/components/fields/ListBox/DraggableListBox.js +1 -1
- package/dist/components/fields/ListBox/ListBox.js +1 -1
- package/dist/components/fields/NumberInput/NumberInput.js +1 -1
- package/dist/components/fields/NumberInput/StepButton.js +3 -3
- package/dist/components/fields/NumberInput/StepButton.js.map +1 -1
- package/dist/components/fields/PasswordInput/PasswordInput.js +2 -2
- package/dist/components/fields/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/components/fields/Picker/Picker.js +12 -8
- package/dist/components/fields/Picker/Picker.js.map +1 -1
- package/dist/components/fields/RadioGroup/Radio.d.ts +1 -1
- package/dist/components/fields/RadioGroup/Radio.js +40 -12
- package/dist/components/fields/RadioGroup/Radio.js.map +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.js +15 -5
- package/dist/components/fields/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/fields/RadioGroup/context.js +1 -1
- package/dist/components/fields/SearchInput/SearchInput.js +2 -2
- package/dist/components/fields/SearchInput/SearchInput.js.map +1 -1
- package/dist/components/fields/Select/Select.d.ts +1 -1
- package/dist/components/fields/Select/Select.js +11 -7
- package/dist/components/fields/Select/Select.js.map +1 -1
- package/dist/components/fields/Slider/Gradation.js +1 -1
- package/dist/components/fields/Slider/HueSlider.js +1 -1
- package/dist/components/fields/Slider/RangeSlider.js +1 -1
- package/dist/components/fields/Slider/Slider.js +1 -1
- package/dist/components/fields/Slider/SliderBase.js +1 -1
- package/dist/components/fields/Slider/SliderThumb.js +1 -1
- package/dist/components/fields/Slider/SliderTrack.js +1 -1
- package/dist/components/fields/Slider/elements.js +1 -1
- package/dist/components/fields/Slider/index.js +1 -1
- package/dist/components/fields/Switch/Switch.js +1 -1
- package/dist/components/fields/TextArea/TextArea.js +1 -1
- package/dist/components/fields/TextInput/TextInput.js +1 -1
- package/dist/components/fields/TextInput/TextInputBase.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/form/FieldWrapper/FieldWrapper.js +1 -1
- package/dist/components/form/FieldWrapper/extract-field-wrapper-props.js +1 -1
- package/dist/components/form/Form/Field.js +1 -1
- package/dist/components/form/Form/Form.js +1 -1
- package/dist/components/form/Form/ResetButton/ResetButton.js +1 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.js +1 -1
- package/dist/components/form/Form/SubmitError.js +1 -1
- package/dist/components/form/Form/index.js +1 -1
- package/dist/components/form/Form/use-field/use-field-props.js +1 -1
- package/dist/components/form/Form/use-field/use-field.js +1 -1
- package/dist/components/form/Form/use-form.js +1 -1
- package/dist/components/form/Form/validation.js +1 -1
- package/dist/components/form/Label.js +1 -1
- package/dist/components/form/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/Tabs/DraggableTabList.js +6 -4
- package/dist/components/navigation/Tabs/DraggableTabList.js.map +1 -1
- package/dist/components/navigation/Tabs/TabButton.js +12 -7
- package/dist/components/navigation/Tabs/TabButton.js.map +1 -1
- package/dist/components/navigation/Tabs/TabDropIndicator.js +9 -4
- package/dist/components/navigation/Tabs/TabDropIndicator.js.map +1 -1
- package/dist/components/navigation/Tabs/TabPanel.js +1 -1
- package/dist/components/navigation/Tabs/TabPicker.js +11 -6
- package/dist/components/navigation/Tabs/TabPicker.js.map +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +137 -104
- package/dist/components/navigation/Tabs/Tabs.js.map +1 -1
- package/dist/components/navigation/Tabs/TabsAction.js +14 -6
- package/dist/components/navigation/Tabs/TabsAction.js.map +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js.map +1 -1
- package/dist/components/navigation/Tabs/popover-placement.js +21 -0
- package/dist/components/navigation/Tabs/popover-placement.js.map +1 -0
- package/dist/components/navigation/Tabs/styled.js +201 -70
- package/dist/components/navigation/Tabs/styled.js.map +1 -1
- package/dist/components/navigation/Tabs/types.d.ts +16 -2
- package/dist/components/navigation/Tabs/types.js +1 -1
- package/dist/components/navigation/Tabs/types.js.map +1 -1
- package/dist/components/navigation/Tabs/use-tab-editing.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-indicator.js +26 -14
- package/dist/components/navigation/Tabs/use-tab-indicator.js.map +1 -1
- package/dist/components/organisms/FileTabs/FileTabs.js +2 -2
- package/dist/components/organisms/FileTabs/FileTabs.js.map +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/RangeCalendar.js +1 -1
- package/dist/components/other/CloudLogo/CloudLogo.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 +2 -2
- package/dist/components/overlays/Dialog/Dialog.js.map +1 -1
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +1 -1
- package/dist/components/overlays/Dialog/DialogTrigger.js +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Modal/Modal.js +1 -1
- package/dist/components/overlays/Modal/OpenTransitionContext.js +1 -1
- package/dist/components/overlays/Modal/Overlay.js +1 -1
- package/dist/components/overlays/Modal/Popover.js +1 -1
- package/dist/components/overlays/Modal/Tray.js +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.d.ts +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +4 -3
- package/dist/components/overlays/Notifications/NotificationAction.js.map +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 +3 -2
- package/dist/components/overlays/Toast/useProgressToast.js.map +1 -1
- package/dist/components/overlays/Toast/useToast.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipProvider.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipTrigger.js +1 -1
- package/dist/components/overlays/Tooltip/context.js +1 -1
- package/dist/components/portal/Portal.js +1 -1
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +9 -3
- package/dist/components/shared/DraggableCollection.js.map +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.d.ts +1 -1
- package/dist/data/item-themes.js +377 -467
- package/dist/data/item-themes.js.map +1 -1
- package/dist/data/themes.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/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/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.js +1 -1
- package/dist/provider.js +1 -1
- package/dist/providers/TrackingProvider.js +1 -1
- package/dist/providers/navigationAdapter.default.js +1 -1
- package/dist/tokens/base.js +1 -1
- package/dist/tokens/colors.js +1 -1
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/layout.js +1 -1
- package/dist/tokens/palette.js +52 -22
- package/dist/tokens/palette.js.map +1 -1
- package/dist/tokens/shadows.js +1 -1
- package/dist/tokens/sizes.js +1 -1
- package/dist/tokens/spacing.js +1 -1
- package/dist/tokens/typography.js +1 -1
- package/dist/utils/ResizeSensor.js +1 -1
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/modules.js +1 -1
- package/dist/utils/promise.js +1 -1
- package/dist/utils/raf.js +1 -1
- package/dist/utils/random.js +1 -1
- package/dist/utils/range.js +1 -1
- package/dist/utils/react/RenderCache.js +1 -1
- package/dist/utils/react/Slots.js +1 -1
- package/dist/utils/react/chain.js +1 -1
- package/dist/utils/react/forwardRefWithGenerics.js +1 -1
- package/dist/utils/react/index.js +1 -1
- package/dist/utils/react/interactions.js +1 -1
- package/dist/utils/react/isTextOnly.js +1 -1
- package/dist/utils/react/mapProps.js +1 -1
- package/dist/utils/react/mergeProps.js +1 -1
- package/dist/utils/react/nullableValue.js +1 -1
- package/dist/utils/react/resolveIcon.js +1 -1
- package/dist/utils/react/sharedStore.js +1 -1
- package/dist/utils/react/useCombinedRefs.js +1 -1
- package/dist/utils/react/useControlledFocusVisible.js +1 -1
- package/dist/utils/react/useEventBus.js +1 -1
- package/dist/utils/react/useId.js +1 -1
- package/dist/utils/react/useIsDarwin.js +1 -1
- package/dist/utils/react/useKeySymbols.js +1 -1
- package/dist/utils/react/useLayoutEffect.js +1 -1
- package/dist/utils/react/useLocalStorage.js +1 -1
- package/dist/utils/react/useMergeStyles.js +1 -1
- package/dist/utils/react/usePopoverSync.js +1 -1
- package/dist/utils/react/useQaProps.js +1 -1
- package/dist/utils/react/useViewportSize.js +1 -1
- package/dist/utils/react/wrapNodeIfPlain.js +1 -1
- package/dist/utils/selection.js +1 -1
- package/dist/utils/styles.js +1 -1
- package/dist/utils/tree.js +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/version.js +2 -2
- package/docs/ComplexLayout.md +2 -2
- package/docs/components/CollectionItem.md +1 -1
- package/docs/components/actions/Banner.md +1 -1
- package/docs/components/actions/Button.md +3 -5
- package/docs/components/actions/ButtonGroup.md +1 -1
- package/docs/components/actions/ButtonSplit.md +1 -2
- package/docs/components/actions/ItemAction.md +5 -5
- package/docs/components/actions/ItemButton.md +4 -6
- package/docs/components/content/Item.md +9 -10
- package/docs/components/content/ItemBadge.md +4 -4
- package/docs/components/content/ItemCard.md +1 -1
- package/docs/components/content/Layout.md +2 -2
- package/docs/components/content/Tag.md +1 -1
- package/docs/components/fields/FilterListBox.md +1 -1
- package/docs/components/fields/FilterPicker.md +3 -5
- package/docs/components/fields/ListBox.md +1 -1
- package/docs/components/fields/Picker.md +3 -5
- package/docs/components/fields/RadioGroup.md +7 -9
- package/docs/components/fields/Select.md +2 -4
- package/docs/components/navigation/Tabs.md +33 -8
- package/docs/components/organisms/FileTabs.md +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/navigation/Tabs/types.ts"],"sourcesContent":["import type { BaseProps, OuterStyleProps, Styles } from '@tenphi/tasty';\nimport type { ReactNode } from 'react';\nimport type { CubeItemActionProps } from '../../actions/ItemAction';\nimport type { CubeMenuProps } from '../../actions/Menu';\nimport type { CubeItemProps } from '../../content/Item';\n\n// =============================================================================\n// Core Types\n// =============================================================================\n\n/** Visual appearance type for tabs */\nexport type TabType = 'default' | 'narrow' | 'file' | 'radio';\n\n/** Position for TabPicker and scroll arrows */\nexport type TabsActionPosition = 'prefix' | 'suffix';\n\n/**\n * Tab size options.\n * Radio type only supports 'medium' | 'large' (mapped to smaller Item sizes).\n */\nexport type TabSize = 'xsmall' | 'small' | 'medium' | 'large';\n\n/**\n * Size mapping for radio type tabs.\n * API sizes mapped to Item button sizes:\n * medium (default) -> xsmall (32px total), large -> medium (40px total).\n */\nexport const RADIO_SIZE_MAP: Record<'medium' | 'large', TabSize> = {\n medium: 'xsmall',\n large: 'medium',\n};\n\n/** How the tab `menu` is exposed alongside or instead of the overflow trigger. */\nexport type TabContextMenu = boolean | 'context-only';\n\n// =============================================================================\n// Shared Props Interfaces\n// =============================================================================\n\n/** Common props for panel rendering behavior */\nexport interface PanelBehaviorProps {\n /** If true, panel is rendered but hidden when not active. */\n prerender?: boolean;\n /** If true, once visited the panel stays in DOM. */\n keepMounted?: boolean;\n}\n\n/** Common props for QA attributes */\nexport interface QAProps {\n /** QA selector attribute. */\n qa?: string;\n /** Additional QA value attribute. */\n qaVal?: string;\n}\n\n// =============================================================================\n// Tab Style Props\n// =============================================================================\n\n/** Props from CubeItemProps that don't apply to Tab */\ntype OmittedItemProps =\n | 'id' // Tab has its own id as Key type\n | 'type' // Tab has its own TabType\n | 'size' // Tab has its own TabSize\n | 'theme' // Tabs have internal theming\n | 'shape' // Tabs have internal shape logic\n | 'description' // Tabs don't have descriptions\n | 'descriptionPlacement'\n | 'descriptionProps'\n | 'hotkeys' // Tabs have their own keyboard navigation\n | 'keyboardShortcutProps'\n | 'labelProps' // Tabs use title prop instead\n | 'labelRef'\n | 'level' // Tabs don't use heading levels\n | 'highlight' // Tabs don't use highlighting\n | 'highlightCaseSensitive'\n | 'highlightStyles'\n | 'variant' // Tabs have internal variant logic\n | 'htmlType' // Tab is always a button\n | 'isSelected' // Handled internally by state\n | 'preserveActionsSpace' // Set internally in TabButton\n | 'disableActionsFocus' // Not used in Tab\n | 'actions' // Tab has its own actions definition\n | 'autoHideActions' // Tab has its own autoHideActions\n | 'insideWrapper' // Internal Item wrapper prop\n | 'showActions'; // Internal Item wrapper prop\n\n/** Common styling props for tabs - inherits style props from CubeItemProps */\nexport interface TabStyleProps extends Omit<CubeItemProps, OmittedItemProps> {\n /**\n * Tab size. Supports 'xsmall', 'small', 'medium', 'large'.\n * Radio type supports 'large' (default, 40px) and 'medium' (32px),\n * mapped to Item button sizes medium (32px) and xsmall (24px).\n */\n size?: TabSize;\n /** Visual appearance type. */\n type?: TabType;\n /** Whether to show actions only on hover. */\n autoHideActions?: boolean;\n}\n\n// =============================================================================\n// Component Props\n// =============================================================================\n\n/** Cache key type - primitives only for reliable comparison */\nexport type CacheKeyValue = string | number | boolean | null | undefined;\n\nexport interface CubeTabsProps\n extends BaseProps,\n OuterStyleProps,\n PanelBehaviorProps {\n /** Controlled active tab key. When provided, component is controlled. */\n activeKey?: string;\n /** Initial active tab key for uncontrolled mode. */\n defaultActiveKey?: string;\n /**\n * Visual appearance type for tabs.\n * - `default` - Standard tabs with selection indicator below (default)\n * - `narrow` - Same as default but with collapsed vertical padding on labels\n * - `file` - File-style tabs with border bottom highlight on selection, delimiter between tabs\n * - `radio` - Radio button style for tab selection\n * @default 'default'\n */\n type?: TabType;\n /**\n * Tab size. Supports 'xsmall', 'small', 'medium', 'large'.\n * Radio type supports 'large' (default, 40px) and 'medium' (32px),\n * mapped to Item button sizes medium (32px) and xsmall (24px).\n * @default 'medium'\n */\n size?: TabSize;\n /** Accessible label for the tab list. */\n label?: string;\n /** Content rendered before the tab list. */\n prefix?: ReactNode;\n /** Content rendered after the tab list. */\n suffix?: ReactNode;\n /** Callback when active tab changes. */\n onChange?: (key: string) => void;\n /** Callback when tab delete button is clicked. Presence enables delete buttons. */\n onDelete?: (key: string) => void;\n /** Callback when a tab title is changed. Enables title editing on tabs with isEditable. */\n onTitleChange?: (key: string, newTitle: string) => void;\n /** Whether to show tab actions only on hover. Can be overridden per-tab. */\n autoHideActions?: boolean;\n /**\n * Whether tabs are editable by default.\n * Can be overridden per-tab via Tab's isEditable prop.\n * @default false\n */\n isEditable?: boolean;\n /**\n * Default menu items for all tabs.\n * Can be overridden per-tab via Tab's menu prop.\n * Set to `null` on individual Tab to disable menu for that tab.\n */\n menu?: ReactNode;\n /**\n * Default props for the menu trigger button.\n * Can be overridden per-tab via Tab's menuTriggerProps prop.\n * @default { icon: <MoreIcon /> }\n */\n menuTriggerProps?: Partial<CubeItemActionProps>;\n /**\n * Default props passed to the Menu component.\n * Can be overridden per-tab via Tab's menuProps prop.\n */\n menuProps?: Partial<CubeMenuProps<object>>;\n /**\n * Context menu / overflow behavior for tab `menu` items.\n * - `false` (default) — overflow trigger only; no right-click menu\n * - `true` — overflow trigger and right-click menu\n * - `'context-only'` — right-click menu only; no overflow trigger. Inline close\n * (`onDelete`) shows even when `menu` is non-empty, like tabs without a menu.\n * Can be overridden per-tab via Tab's contextMenu prop.\n * @default false\n */\n contextMenu?: TabContextMenu;\n /**\n * Callback when a menu action is triggered on any tab.\n * Called with the action key and the tab key.\n * Tab-level onAction is called first, then this.\n */\n onAction?: (action: string, tabKey: string) => void;\n /** Custom tasty styles for the tab bar container. */\n styles?: Styles;\n /** QA selector attribute. */\n qa?: string;\n /** Tab components or Tabs.List with Tabs.Panel. */\n children?: ReactNode;\n /**\n * Functional content renderer for optimized lazy evaluation.\n * When provided, panel content is only evaluated for the active tab,\n * while inactive tabs use cached content.\n */\n renderPanel?: (key: string) => ReactNode;\n /**\n * Cache keys for individual panels. Enables caching for specified panels.\n */\n panelCacheKeys?: Record<string | number, CacheKeyValue>;\n /**\n * Enable drag-and-drop tab reordering.\n * When a tab picker is shown (`showTabPicker`), reordering is automatically\n * enabled in the picker dropdown as well.\n * @default false\n */\n isReorderable?: boolean;\n /**\n * Controlled order of tab keys.\n * When provided, tabs are displayed in this order.\n */\n keyOrder?: string[];\n /**\n * Callback when tabs are reordered via drag-and-drop.\n */\n onReorder?: (newOrder: string[]) => void;\n /**\n * Whether to show a tab picker dropdown in the suffix area.\n * - `true` - always show the tab picker\n * - `false` - never show the tab picker (default)\n * - `'auto'` - show only when tabs overflow (has horizontal scroll)\n * @default false\n */\n showTabPicker?: boolean | 'auto';\n /**\n * Whether to show scroll arrow buttons in the suffix area.\n * - `true` - always show scroll arrows\n * - `false` - never show scroll arrows (default)\n * - `'auto'` - show only when tabs overflow (has horizontal scroll)\n * @default false\n */\n showScrollArrows?: boolean | 'auto';\n /**\n * Position of the tab picker dropdown.\n * - `'prefix'` - render in the prefix slot (before tab list)\n * - `'suffix'` - render in the suffix slot (after tab list)\n * @default 'suffix'\n */\n tabPickerPosition?: TabsActionPosition;\n /**\n * Position of the scroll arrow buttons.\n * - `'prefix'` - render in the prefix slot (before tab list)\n * - `'suffix'` - render in the suffix slot (after tab list)\n * @default 'suffix'\n */\n scrollArrowsPosition?: TabsActionPosition;\n /**\n * Visually hide the custom horizontal scrollbar in the tab list\n * and skip its tracking logic. Does not affect tab picker, scroll arrows,\n * or fade indicators — only the tiny scrollbar visual.\n * @default false\n */\n hideTabListScroll?: boolean;\n /**\n * Inline padding for the tab list container.\n * Sets horizontal padding only (e.g., \"2x\" → padding: \"0 2x\").\n */\n tabListPadding?: string;\n /** Custom tasty styles for the TabList sub-element. */\n tabListStyles?: Styles;\n /** Custom tasty styles for the Prefix sub-element. */\n prefixStyles?: Styles;\n /** Custom tasty styles for the Suffix sub-element. */\n suffixStyles?: Styles;\n}\n\nexport interface CubeTabProps extends TabStyleProps, PanelBehaviorProps {\n /**\n * Unique identifier for the tab.\n * Auto-injected from the React `key` prop (converted to string).\n */\n id?: string;\n /** Content displayed in the tab button. */\n title: ReactNode;\n /** Panel content rendered when tab is active. */\n children?: ReactNode;\n /** Disables the tab (cannot be selected). */\n isDisabled?: boolean;\n /** Actions to render in the tab. Rendered before menu trigger if tab has menu. */\n actions?: ReactNode;\n /** Whether the tab title can be edited. Overrides the Tabs-level isEditable default. */\n isEditable?: boolean;\n /** Callback when this tab's title is changed. Overrides parent's onTitleChange. */\n onTitleChange?: (newTitle: string) => void;\n /**\n * Menu items to display in a dropdown menu on the tab.\n * Pass Menu.Item elements directly - they will be wrapped in a Menu internally.\n * Overrides the Tabs-level menu default. Set to `null` to disable menu.\n */\n menu?: ReactNode | null;\n /**\n * Props to customize the menu trigger button.\n * Overrides the Tabs-level menuTriggerProps default.\n */\n menuTriggerProps?: Partial<CubeItemActionProps>;\n /**\n * Props passed to the Menu component.\n * Overrides the Tabs-level menuProps default.\n */\n menuProps?: Partial<CubeMenuProps<object>>;\n /**\n * Context menu / overflow behavior. Same values as Tabs `contextMenu`.\n * Uses the same menu items as `menu` prop.\n * @default false\n */\n contextMenu?: TabContextMenu;\n /**\n * Callback when a menu action is triggered.\n * Called with the action key from Menu.Item.\n */\n onAction?: (action: string) => void;\n}\n\nexport interface CubeTabPanelProps extends PanelBehaviorProps, QAProps {\n /**\n * Panel identifier. Must match a Tab's id.\n * Auto-injected from the React `key` prop (converted to string).\n */\n id?: string;\n /** Panel content. */\n children?: ReactNode;\n /** Custom tasty styles for the panel container. */\n styles?: Styles;\n}\n\nexport interface CubeTabListProps {\n /** Tab components. */\n children?: ReactNode;\n}\n\n// =============================================================================\n// Internal Types\n// =============================================================================\n\n/**\n * Internal representation of a parsed Tab.\n * Uses `content` instead of `children` to distinguish panel content.\n */\nexport interface ParsedTab extends Omit<CubeTabProps, 'id' | 'children'> {\n /** Tab key (always a string internally for React Aria compatibility) */\n key: string;\n /** Panel content extracted from Tab's children prop */\n content: ReactNode;\n}\n\n/**\n * Internal representation of a parsed TabPanel.\n */\nexport interface ParsedPanel\n extends Omit<CubeTabPanelProps, 'id' | 'children'> {\n /** Panel key (always a string internally for React Aria compatibility) */\n key: string;\n /** Panel content extracted from TabPanel's children prop */\n content: ReactNode;\n}\n"],"mappings":";;;;;;;AA2BA,MAAa,iBAAsD;CACjE,QAAQ;CACR,OAAO;CACR"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/navigation/Tabs/types.ts"],"sourcesContent":["import type { BaseProps, OuterStyleProps, Styles } from '@tenphi/tasty';\nimport type { ReactNode } from 'react';\nimport type { CubeItemActionProps } from '../../actions/ItemAction';\nimport type { CubeMenuProps } from '../../actions/Menu';\nimport type { CubeItemProps } from '../../content/Item';\n\n// =============================================================================\n// Core Types\n// =============================================================================\n\n/** Visual appearance type for tabs */\nexport type TabType = 'default' | 'narrow' | 'file' | 'radio';\n\n/**\n * Where the tab bar sits relative to its panels.\n * - `'top'` / `'bottom'` keep the bar horizontal.\n * - `'left'` / `'right'` switch it to a vertical strip.\n */\nexport type TabPlacement = 'top' | 'bottom' | 'left' | 'right';\n\n/** Position for TabPicker and scroll arrows */\nexport type TabsActionPosition = 'prefix' | 'suffix';\n\n/**\n * Tab size options.\n * Radio type only supports 'medium' | 'large' (mapped to smaller Item sizes).\n */\nexport type TabSize = 'xsmall' | 'small' | 'medium' | 'large';\n\n/**\n * Size mapping for radio type tabs.\n * API sizes mapped to Item button sizes:\n * medium (default) -> xsmall (32px total), large -> medium (40px total).\n */\nexport const RADIO_SIZE_MAP: Record<'medium' | 'large', TabSize> = {\n medium: 'xsmall',\n large: 'medium',\n};\n\n/** How the tab `menu` is exposed alongside or instead of the overflow trigger. */\nexport type TabContextMenu = boolean | 'context-only';\n\n// =============================================================================\n// Shared Props Interfaces\n// =============================================================================\n\n/** Common props for panel rendering behavior */\nexport interface PanelBehaviorProps {\n /** If true, panel is rendered but hidden when not active. */\n prerender?: boolean;\n /** If true, once visited the panel stays in DOM. */\n keepMounted?: boolean;\n}\n\n/** Common props for QA attributes */\nexport interface QAProps {\n /** QA selector attribute. */\n qa?: string;\n /** Additional QA value attribute. */\n qaVal?: string;\n}\n\n// =============================================================================\n// Tab Style Props\n// =============================================================================\n\n/** Props from CubeItemProps that don't apply to Tab */\ntype OmittedItemProps =\n | 'id' // Tab has its own id as Key type\n | 'type' // Type is decided at the Tabs level, never per-tab\n | 'size' // Tab has its own TabSize\n | 'theme' // Tabs have internal theming\n | 'shape' // Tabs have internal shape logic\n | 'description' // Tabs don't have descriptions\n | 'descriptionPlacement'\n | 'descriptionProps'\n | 'hotkeys' // Tabs have their own keyboard navigation\n | 'keyboardShortcutProps'\n | 'labelProps' // Tabs use title prop instead\n | 'labelRef'\n | 'level' // Tabs don't use heading levels\n | 'highlight' // Tabs don't use highlighting\n | 'highlightCaseSensitive'\n | 'highlightStyles'\n | 'variant' // Tabs have internal variant logic\n | 'htmlType' // Tab is always a button\n | 'isSelected' // Handled internally by state\n | 'preserveActionsSpace' // Set internally in TabButton\n | 'disableActionsFocus' // Not used in Tab\n | 'actions' // Tab has its own actions definition\n | 'autoHideActions' // Tab has its own autoHideActions\n | 'insideWrapper' // Internal Item wrapper prop\n | 'showActions'; // Internal Item wrapper prop\n\n/** Common styling props for tabs - inherits style props from CubeItemProps */\nexport interface TabStyleProps extends Omit<CubeItemProps, OmittedItemProps> {\n /**\n * Tab size. Supports 'xsmall', 'small', 'medium', 'large'.\n * Radio type supports 'large' (default, 40px) and 'medium' (32px),\n * mapped to Item button sizes medium (32px) and xsmall (24px).\n */\n size?: TabSize;\n /** Whether to show actions only on hover. */\n autoHideActions?: boolean;\n}\n\n// =============================================================================\n// Component Props\n// =============================================================================\n\n/** Cache key type - primitives only for reliable comparison */\nexport type CacheKeyValue = string | number | boolean | null | undefined;\n\nexport interface CubeTabsProps\n extends BaseProps,\n OuterStyleProps,\n PanelBehaviorProps {\n /** Controlled active tab key. When provided, component is controlled. */\n activeKey?: string;\n /** Initial active tab key for uncontrolled mode. */\n defaultActiveKey?: string;\n /**\n * Visual appearance type for tabs.\n * - `default` - Standard tabs with selection indicator below (default)\n * - `narrow` - Same as default but with collapsed vertical padding on labels\n * - `file` - File-style tabs with border bottom highlight on selection, delimiter between tabs\n * - `radio` - Radio button style for tab selection\n * @default 'default'\n */\n type?: TabType;\n /**\n * Where the tab bar sits relative to its panels.\n * `'top'` / `'bottom'` keep the bar horizontal; `'left'` / `'right'`\n * switch it to a vertical strip. The selection indicator, scroll behavior,\n * fades, and per-type visuals all adapt automatically.\n * @default 'top'\n */\n placement?: TabPlacement;\n /**\n * Tab size. Supports 'xsmall', 'small', 'medium', 'large'.\n * Radio type supports 'large' (default, 40px) and 'medium' (32px),\n * mapped to Item button sizes medium (32px) and xsmall (24px).\n * @default 'medium'\n */\n size?: TabSize;\n /** Accessible label for the tab list. */\n label?: string;\n /** Content rendered before the tab list. */\n prefix?: ReactNode;\n /** Content rendered after the tab list. */\n suffix?: ReactNode;\n /** Callback when active tab changes. */\n onChange?: (key: string) => void;\n /** Callback when tab delete button is clicked. Presence enables delete buttons. */\n onDelete?: (key: string) => void;\n /** Callback when a tab title is changed. Enables title editing on tabs with isEditable. */\n onTitleChange?: (key: string, newTitle: string) => void;\n /** Whether to show tab actions only on hover. Can be overridden per-tab. */\n autoHideActions?: boolean;\n /**\n * Whether tabs are editable by default.\n * Can be overridden per-tab via Tab's isEditable prop.\n * @default false\n */\n isEditable?: boolean;\n /**\n * Default menu items for all tabs.\n * Can be overridden per-tab via Tab's menu prop.\n * Set to `null` on individual Tab to disable menu for that tab.\n */\n menu?: ReactNode;\n /**\n * Default props for the menu trigger button.\n * Can be overridden per-tab via Tab's menuTriggerProps prop.\n * @default { icon: <MoreIcon /> }\n */\n menuTriggerProps?: Partial<CubeItemActionProps>;\n /**\n * Default props passed to the Menu component.\n * Can be overridden per-tab via Tab's menuProps prop.\n */\n menuProps?: Partial<CubeMenuProps<object>>;\n /**\n * Context menu / overflow behavior for tab `menu` items.\n * - `false` (default) — overflow trigger only; no right-click menu\n * - `true` — overflow trigger and right-click menu\n * - `'context-only'` — right-click menu only; no overflow trigger. Inline close\n * (`onDelete`) shows even when `menu` is non-empty, like tabs without a menu.\n * Can be overridden per-tab via Tab's contextMenu prop.\n * @default false\n */\n contextMenu?: TabContextMenu;\n /**\n * Callback when a menu action is triggered on any tab.\n * Called with the action key and the tab key.\n * Tab-level onAction is called first, then this.\n */\n onAction?: (action: string, tabKey: string) => void;\n /** Custom tasty styles for the tab bar container. */\n styles?: Styles;\n /** QA selector attribute. */\n qa?: string;\n /** Tab components or Tabs.List with Tabs.Panel. */\n children?: ReactNode;\n /**\n * Functional content renderer for optimized lazy evaluation.\n * When provided, panel content is only evaluated for the active tab,\n * while inactive tabs use cached content.\n */\n renderPanel?: (key: string) => ReactNode;\n /**\n * Cache keys for individual panels. Enables caching for specified panels.\n */\n panelCacheKeys?: Record<string | number, CacheKeyValue>;\n /**\n * Enable drag-and-drop tab reordering.\n * When a tab picker is shown (`showTabPicker`), reordering is automatically\n * enabled in the picker dropdown as well.\n * @default false\n */\n isReorderable?: boolean;\n /**\n * Controlled order of tab keys.\n * When provided, tabs are displayed in this order.\n */\n keyOrder?: string[];\n /**\n * Callback when tabs are reordered via drag-and-drop.\n */\n onReorder?: (newOrder: string[]) => void;\n /**\n * Whether to show a tab picker dropdown in the suffix area.\n * - `true` - always show the tab picker\n * - `false` - never show the tab picker (default)\n * - `'auto'` - show only when tabs overflow (has horizontal scroll)\n * @default false\n */\n showTabPicker?: boolean | 'auto';\n /**\n * Whether to show scroll arrow buttons in the suffix area.\n * - `true` - always show scroll arrows\n * - `false` - never show scroll arrows (default)\n * - `'auto'` - show only when tabs overflow (has horizontal scroll)\n * @default false\n */\n showScrollArrows?: boolean | 'auto';\n /**\n * Position of the tab picker dropdown.\n * - `'prefix'` - render in the prefix slot (before tab list)\n * - `'suffix'` - render in the suffix slot (after tab list)\n * @default 'suffix'\n */\n tabPickerPosition?: TabsActionPosition;\n /**\n * Position of the scroll arrow buttons.\n * - `'prefix'` - render in the prefix slot (before tab list)\n * - `'suffix'` - render in the suffix slot (after tab list)\n * @default 'suffix'\n */\n scrollArrowsPosition?: TabsActionPosition;\n /**\n * Visually hide the custom horizontal scrollbar in the tab list\n * and skip its tracking logic. Does not affect tab picker, scroll arrows,\n * or fade indicators — only the tiny scrollbar visual.\n * @default false\n */\n hideTabListScroll?: boolean;\n /**\n * Inline padding for the tab list container.\n * Sets horizontal padding only (e.g., \"2x\" → padding: \"0 2x\").\n */\n tabListPadding?: string;\n /** Custom tasty styles for the tab bar (Bar sub-element). */\n barStyles?: Styles;\n /** Custom tasty styles for the TabList sub-element. */\n tabListStyles?: Styles;\n /** Custom tasty styles for the Prefix sub-element. */\n prefixStyles?: Styles;\n /** Custom tasty styles for the Suffix sub-element. */\n suffixStyles?: Styles;\n}\n\nexport interface CubeTabProps extends TabStyleProps, PanelBehaviorProps {\n /**\n * Unique identifier for the tab.\n * Auto-injected from the React `key` prop (converted to string).\n */\n id?: string;\n /** Content displayed in the tab button. */\n title: ReactNode;\n /** Panel content rendered when tab is active. */\n children?: ReactNode;\n /** Disables the tab (cannot be selected). */\n isDisabled?: boolean;\n /** Actions to render in the tab. Rendered before menu trigger if tab has menu. */\n actions?: ReactNode;\n /** Whether the tab title can be edited. Overrides the Tabs-level isEditable default. */\n isEditable?: boolean;\n /** Callback when this tab's title is changed. Overrides parent's onTitleChange. */\n onTitleChange?: (newTitle: string) => void;\n /**\n * Menu items to display in a dropdown menu on the tab.\n * Pass Menu.Item elements directly - they will be wrapped in a Menu internally.\n * Overrides the Tabs-level menu default. Set to `null` to disable menu.\n */\n menu?: ReactNode | null;\n /**\n * Props to customize the menu trigger button.\n * Overrides the Tabs-level menuTriggerProps default.\n */\n menuTriggerProps?: Partial<CubeItemActionProps>;\n /**\n * Props passed to the Menu component.\n * Overrides the Tabs-level menuProps default.\n */\n menuProps?: Partial<CubeMenuProps<object>>;\n /**\n * Context menu / overflow behavior. Same values as Tabs `contextMenu`.\n * Uses the same menu items as `menu` prop.\n * @default false\n */\n contextMenu?: TabContextMenu;\n /**\n * Callback when a menu action is triggered.\n * Called with the action key from Menu.Item.\n */\n onAction?: (action: string) => void;\n}\n\nexport interface CubeTabPanelProps extends PanelBehaviorProps, QAProps {\n /**\n * Panel identifier. Must match a Tab's id.\n * Auto-injected from the React `key` prop (converted to string).\n */\n id?: string;\n /** Panel content. */\n children?: ReactNode;\n /** Custom tasty styles for the panel container. */\n styles?: Styles;\n}\n\nexport interface CubeTabListProps {\n /** Tab components. */\n children?: ReactNode;\n}\n\n// =============================================================================\n// Internal Types\n// =============================================================================\n\n/**\n * Internal representation of a parsed Tab.\n * Uses `content` instead of `children` to distinguish panel content.\n */\nexport interface ParsedTab extends Omit<CubeTabProps, 'id' | 'children'> {\n /** Tab key (always a string internally for React Aria compatibility) */\n key: string;\n /** Panel content extracted from Tab's children prop */\n content: ReactNode;\n}\n\n/**\n * Internal representation of a parsed TabPanel.\n */\nexport interface ParsedPanel\n extends Omit<CubeTabPanelProps, 'id' | 'children'> {\n /** Panel key (always a string internally for React Aria compatibility) */\n key: string;\n /** Panel content extracted from TabPanel's children prop */\n content: ReactNode;\n}\n"],"mappings":";;;;;;;AAkCA,MAAa,iBAAsD;CACjE,QAAQ;CACR,OAAO;CACR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { chainRaf } from "../../../utils/raf.js";
|
|
3
3
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
|
|
@@ -6,17 +6,18 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react
|
|
|
6
6
|
/**
|
|
7
7
|
* Hook to track and animate tab indicator position.
|
|
8
8
|
*
|
|
9
|
-
* Calculates the position and
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Calculates the start position and size of the selection indicator
|
|
10
|
+
* along the orientation axis. Returns null if disabled (e.g., for
|
|
11
|
+
* non-default/narrow tab types).
|
|
12
12
|
*
|
|
13
13
|
* @param containerRef - Ref to the tab container element
|
|
14
14
|
* @param selectedKey - Currently selected tab key
|
|
15
15
|
* @param enabled - Whether the indicator should be shown
|
|
16
|
+
* @param orientation - Axis along which the indicator moves
|
|
16
17
|
* @param orderToken - Optional token that changes when tab order changes (triggers recalculation)
|
|
17
|
-
* @returns Indicator style (
|
|
18
|
+
* @returns Indicator style (`start`, `size`) or null if disabled/not ready
|
|
18
19
|
*/
|
|
19
|
-
function useTabIndicator(containerRef, selectedKey, enabled, orderToken) {
|
|
20
|
+
function useTabIndicator(containerRef, selectedKey, enabled, orientation = "horizontal", orderToken) {
|
|
20
21
|
const [style, setStyle] = useState(null);
|
|
21
22
|
const cancelRef = useRef(null);
|
|
22
23
|
const updateIndicator = useCallback(() => {
|
|
@@ -31,14 +32,20 @@ function useTabIndicator(containerRef, selectedKey, enabled, orderToken) {
|
|
|
31
32
|
}
|
|
32
33
|
const containerRect = containerRef.current.getBoundingClientRect();
|
|
33
34
|
const tabRect = selectedTab.getBoundingClientRect();
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
if (orientation === "vertical") {
|
|
36
|
+
if (tabRect.height > 0) setStyle({
|
|
37
|
+
start: tabRect.top - containerRect.top + containerRef.current.scrollTop,
|
|
38
|
+
size: tabRect.height
|
|
39
|
+
});
|
|
40
|
+
} else if (tabRect.width > 0) setStyle({
|
|
41
|
+
start: tabRect.left - containerRect.left + containerRef.current.scrollLeft,
|
|
42
|
+
size: tabRect.width
|
|
37
43
|
});
|
|
38
44
|
}, [
|
|
39
45
|
containerRef,
|
|
40
46
|
selectedKey,
|
|
41
47
|
enabled,
|
|
48
|
+
orientation,
|
|
42
49
|
orderToken
|
|
43
50
|
]);
|
|
44
51
|
useLayoutEffect(() => {
|
|
@@ -60,17 +67,22 @@ function useTabIndicator(containerRef, selectedKey, enabled, orderToken) {
|
|
|
60
67
|
if (!enabled) return;
|
|
61
68
|
const container = containerRef.current;
|
|
62
69
|
if (!container) return;
|
|
63
|
-
|
|
70
|
+
const getAxisSize = (rect) => orientation === "vertical" ? rect.height : rect.width;
|
|
71
|
+
let prevSize = getAxisSize(container.getBoundingClientRect());
|
|
64
72
|
const observer = new ResizeObserver((entries) => {
|
|
65
73
|
const entry = entries[0];
|
|
66
74
|
if (!entry) return;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
|
|
75
|
+
const newSize = getAxisSize(entry.contentRect);
|
|
76
|
+
if (prevSize === 0 && newSize > 0) updateIndicator();
|
|
77
|
+
prevSize = newSize;
|
|
70
78
|
});
|
|
71
79
|
observer.observe(container);
|
|
72
80
|
return () => observer.disconnect();
|
|
73
|
-
}, [
|
|
81
|
+
}, [
|
|
82
|
+
enabled,
|
|
83
|
+
orientation,
|
|
84
|
+
updateIndicator
|
|
85
|
+
]);
|
|
74
86
|
return enabled ? style : null;
|
|
75
87
|
}
|
|
76
88
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tab-indicator.js","names":[],"sources":["../../../../src/components/navigation/Tabs/use-tab-indicator.ts"],"sourcesContent":["import {\n RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { chainRaf } from '../../../utils/raf';\n\nimport type { Key } from '@react-types/shared';\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface IndicatorStyle {\n
|
|
1
|
+
{"version":3,"file":"use-tab-indicator.js","names":[],"sources":["../../../../src/components/navigation/Tabs/use-tab-indicator.ts"],"sourcesContent":["import {\n RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { chainRaf } from '../../../utils/raf';\n\nimport type { Key } from '@react-types/shared';\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/**\n * Axis-agnostic indicator geometry.\n * For horizontal orientation: `start` is `left`, `size` is `width`.\n * For vertical orientation: `start` is `top`, `size` is `height`.\n */\nexport interface IndicatorStyle {\n start: number;\n size: number;\n}\n\nexport type IndicatorOrientation = 'horizontal' | 'vertical';\n\n// =============================================================================\n// Hook\n// =============================================================================\n\n/**\n * Hook to track and animate tab indicator position.\n *\n * Calculates the start position and size of the selection indicator\n * along the orientation axis. Returns null if disabled (e.g., for\n * non-default/narrow tab types).\n *\n * @param containerRef - Ref to the tab container element\n * @param selectedKey - Currently selected tab key\n * @param enabled - Whether the indicator should be shown\n * @param orientation - Axis along which the indicator moves\n * @param orderToken - Optional token that changes when tab order changes (triggers recalculation)\n * @returns Indicator style (`start`, `size`) or null if disabled/not ready\n */\nexport function useTabIndicator(\n containerRef: RefObject<HTMLElement | null>,\n selectedKey: Key | null,\n enabled: boolean,\n orientation: IndicatorOrientation = 'horizontal',\n orderToken?: string,\n): IndicatorStyle | null {\n const [style, setStyle] = useState<IndicatorStyle | null>(null);\n const cancelRef = useRef<(() => void) | null>(null);\n\n const updateIndicator = useCallback(() => {\n if (!enabled || !containerRef.current || selectedKey == null) {\n setStyle(null);\n return;\n }\n\n // Find the selected tab button within the container\n const selectedTab = containerRef.current.querySelector(\n '[aria-selected=\"true\"]',\n ) as HTMLElement | null;\n\n if (!selectedTab) {\n setStyle(null);\n return;\n }\n\n const containerRect = containerRef.current.getBoundingClientRect();\n const tabRect = selectedTab.getBoundingClientRect();\n\n if (orientation === 'vertical') {\n // Only update if dimensions are valid (element has been painted)\n if (tabRect.height > 0) {\n setStyle({\n start:\n tabRect.top - containerRect.top + containerRef.current.scrollTop,\n size: tabRect.height,\n });\n }\n } else {\n if (tabRect.width > 0) {\n setStyle({\n start:\n tabRect.left - containerRect.left + containerRef.current.scrollLeft,\n size: tabRect.width,\n });\n }\n }\n }, [containerRef, selectedKey, enabled, orientation, orderToken]);\n\n // Update on selectedKey change - use chainRaf to ensure DOM is fully painted\n useLayoutEffect(() => {\n // Cancel any pending RAF chain\n if (cancelRef.current) {\n cancelRef.current();\n }\n\n // Schedule update after 2 frames to ensure layout is complete\n cancelRef.current = chainRaf(() => {\n updateIndicator();\n }, 2);\n\n return () => {\n if (cancelRef.current) {\n cancelRef.current();\n }\n };\n }, [updateIndicator]);\n\n // Update on window resize\n useEffect(() => {\n if (!enabled) return;\n\n const handleResize = () => updateIndicator();\n\n window.addEventListener('resize', handleResize);\n\n return () => window.removeEventListener('resize', handleResize);\n }, [enabled, updateIndicator]);\n\n // Recalculate when container becomes visible (0 -> non-zero size along the axis)\n useEffect(() => {\n if (!enabled) return;\n\n const container = containerRef.current;\n if (!container) return;\n\n const getAxisSize = (rect: { width: number; height: number }) =>\n orientation === 'vertical' ? rect.height : rect.width;\n\n let prevSize = getAxisSize(container.getBoundingClientRect());\n\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (!entry) return;\n\n const newSize = getAxisSize(entry.contentRect);\n\n if (prevSize === 0 && newSize > 0) {\n updateIndicator();\n }\n\n prevSize = newSize;\n });\n\n observer.observe(container);\n\n return () => observer.disconnect();\n }, [enabled, orientation, updateIndicator]);\n\n return enabled ? style : null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,gBACd,cACA,aACA,SACA,cAAoC,cACpC,YACuB;CACvB,MAAM,CAAC,OAAO,YAAY,SAAgC,KAAK;CAC/D,MAAM,YAAY,OAA4B,KAAK;CAEnD,MAAM,kBAAkB,kBAAkB;AACxC,MAAI,CAAC,WAAW,CAAC,aAAa,WAAW,eAAe,MAAM;AAC5D,YAAS,KAAK;AACd;;EAIF,MAAM,cAAc,aAAa,QAAQ,cACvC,2BACD;AAED,MAAI,CAAC,aAAa;AAChB,YAAS,KAAK;AACd;;EAGF,MAAM,gBAAgB,aAAa,QAAQ,uBAAuB;EAClE,MAAM,UAAU,YAAY,uBAAuB;AAEnD,MAAI,gBAAgB,YAElB;OAAI,QAAQ,SAAS,EACnB,UAAS;IACP,OACE,QAAQ,MAAM,cAAc,MAAM,aAAa,QAAQ;IACzD,MAAM,QAAQ;IACf,CAAC;aAGA,QAAQ,QAAQ,EAClB,UAAS;GACP,OACE,QAAQ,OAAO,cAAc,OAAO,aAAa,QAAQ;GAC3D,MAAM,QAAQ;GACf,CAAC;IAGL;EAAC;EAAc;EAAa;EAAS;EAAa;EAAW,CAAC;AAGjE,uBAAsB;AAEpB,MAAI,UAAU,QACZ,WAAU,SAAS;AAIrB,YAAU,UAAU,eAAe;AACjC,oBAAiB;KAChB,EAAE;AAEL,eAAa;AACX,OAAI,UAAU,QACZ,WAAU,SAAS;;IAGtB,CAAC,gBAAgB,CAAC;AAGrB,iBAAgB;AACd,MAAI,CAAC,QAAS;EAEd,MAAM,qBAAqB,iBAAiB;AAE5C,SAAO,iBAAiB,UAAU,aAAa;AAE/C,eAAa,OAAO,oBAAoB,UAAU,aAAa;IAC9D,CAAC,SAAS,gBAAgB,CAAC;AAG9B,iBAAgB;AACd,MAAI,CAAC,QAAS;EAEd,MAAM,YAAY,aAAa;AAC/B,MAAI,CAAC,UAAW;EAEhB,MAAM,eAAe,SACnB,gBAAgB,aAAa,KAAK,SAAS,KAAK;EAElD,IAAI,WAAW,YAAY,UAAU,uBAAuB,CAAC;EAE7D,MAAM,WAAW,IAAI,gBAAgB,YAAY;GAC/C,MAAM,QAAQ,QAAQ;AACtB,OAAI,CAAC,MAAO;GAEZ,MAAM,UAAU,YAAY,MAAM,YAAY;AAE9C,OAAI,aAAa,KAAK,UAAU,EAC9B,kBAAiB;AAGnB,cAAW;IACX;AAEF,WAAS,QAAQ,UAAU;AAE3B,eAAa,SAAS,YAAY;IACjC;EAAC;EAAS;EAAa;EAAgB,CAAC;AAE3C,QAAO,UAAU,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { useLayoutEffect as useLayoutEffect$1 } from "../../../utils/react/useLayoutEffect.js";
|
|
3
3
|
import { Block } from "../../Block.js";
|
|
4
4
|
import { Space } from "../../layout/Space.js";
|
|
@@ -108,7 +108,7 @@ const TabElement = tasty(Action, { styles: {
|
|
|
108
108
|
} });
|
|
109
109
|
const CloseButton = tasty(Button, {
|
|
110
110
|
element: "CloseButton",
|
|
111
|
-
type: "
|
|
111
|
+
type: "clear",
|
|
112
112
|
icon: /* @__PURE__ */ jsx(CloseIcon, {}),
|
|
113
113
|
label: "Close Tab",
|
|
114
114
|
styles: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTabs.js","names":[],"sources":["../../../../src/components/organisms/FileTabs/FileTabs.tsx"],"sourcesContent":["import { Styles, tasty } from '@tenphi/tasty';\nimport {\n createContext,\n ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CloseIcon } from '../../../icons';\nimport { useLayoutEffect } from '../../../utils/react';\nimport { Action, Button, CubeActionProps } from '../../actions';\nimport { Block } from '../../Block';\nimport { CubeFlexProps, Flex } from '../../layout/Flex';\nimport { Space } from '../../layout/Space';\n\ninterface TabData {\n id: string | number;\n title?: string;\n isDirty?: boolean;\n}\n\ninterface FileTabContextValue {\n addTab: (tab: TabData) => void;\n setTab: (id: string | number) => void;\n removeTab: (tab: TabData) => void;\n currentTab?: string | number;\n setDirtyTab: (id: string | number, isDirty: boolean) => void;\n}\n\nconst FileTabsContext = createContext<FileTabContextValue>({\n addTab() {},\n removeTab() {},\n setTab() {},\n setDirtyTab() {},\n});\n\nconst TabsPanelElement = tasty(Space, {\n qa: 'TabsPanel',\n styles: {\n position: 'relative',\n overflow: 'auto hidden',\n top: '1bw',\n gap: '.5x',\n flexShrink: 0,\n whiteSpace: 'nowrap',\n scrollbar: 'styled',\n padding: '1ow 1ow 0 1ow',\n fade: {\n '': false,\n 'left-fade': '3x left',\n 'right-fade': '3x right',\n 'right-fade & left-fade': '3x left right',\n },\n transition: 'fade',\n '--scrollbar-radius': '1ow',\n '--scrollbar-width': '.75x',\n '--scrollbar-outline-width': '1px',\n },\n});\n\nconst TabsContainerElement = tasty(Flex, {\n qa: 'TabsContainer',\n styles: {\n flow: 'column',\n height: 'max 100%',\n width: 'max 100%',\n position: 'relative',\n },\n});\n\nconst DirtyBadge = tasty({\n element: 'DirtyBadge',\n styles: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n width: '1x',\n height: '1x',\n fill: '#dark.30',\n radius: 'round',\n },\n});\n\nconst TabElement = tasty(Action, {\n styles: {\n radius: '1r 1r 0 0',\n padding: '1x 1.5x',\n border: {\n '': 'left top right #clear',\n disabled: 'left top right #border',\n },\n fill: {\n '': '#dark.04',\n hovered: '#dark.08',\n 'disabled, disabled & hover': '#surface',\n },\n color: {\n '': '#dark-02',\n 'disabled, hovered, hovered & disabled': '#dark',\n },\n cursor: {\n '': '$pointer',\n disabled: 'default',\n },\n fontWeight: 500,\n opacity: 1,\n preset: 'default',\n transform: {\n '': 'translate(0, 0)',\n disabled: 'translate(0, 1bw)',\n },\n transition: 'theme 0.2s',\n margin: '1bw bottom',\n\n DirtyBadge: {\n opacity: {\n '': 1,\n 'dirty & :hover': 0,\n },\n pointerEvents: {\n '': 'auto',\n 'dirty & :hover': 'none',\n },\n },\n\n CloseButton: {\n opacity: {\n '': 0,\n '!dirty | :hover': 1,\n },\n },\n },\n});\n\nconst CloseButton = tasty(Button, {\n element: 'CloseButton',\n type: 'neutral',\n icon: <CloseIcon />,\n label: 'Close Tab',\n styles: {\n width: '3x',\n height: '3x',\n padding: 0,\n },\n});\n\n/**\n * @deprecated consider using <Tabs /> instead\n */\nexport interface FileTabProps extends Omit<CubeActionProps, 'id'> {\n isDirty?: boolean;\n isDisabled?: boolean;\n children?: ReactNode;\n isClosable?: boolean;\n onClose?: () => void;\n}\n\nfunction Tab({\n isDirty,\n isDisabled,\n children,\n isClosable,\n onClose,\n ...props\n}: FileTabProps) {\n return (\n <TabElement\n mods={{\n dirty: isDirty,\n }}\n isDisabled={isDisabled}\n {...props}\n >\n <Space gap=\".75x\">\n <Block>{children}</Block>\n {(isClosable || isDirty) && (\n <Flex placeItems=\"center\" style={{ position: 'relative' }}>\n {isClosable ? <CloseButton onPress={onClose} /> : <div></div>}\n {isDirty ? <DirtyBadge /> : null}\n </Flex>\n )}\n </Space>\n </TabElement>\n );\n}\n\nexport interface CubeFileTabsProps extends CubeFlexProps {\n /** The initial active key in the tabs (uncontrolled). */\n defaultActiveKey?: string;\n /** The currently active key in the tabs (controlled). */\n activeKey?: string | number;\n /** Handler that is called when the tab is clicked. */\n onTabClick?: (string) => void;\n /** Handler that is called when the tab is closed. */\n onTabClose?: (string) => void;\n /** Styles for each tab pane */\n paneStyles?: Styles;\n /** Whether the tabs are closable */\n isClosable?: boolean;\n children?: ReactNode;\n}\n\nexport function FileTabs({\n defaultActiveKey,\n activeKey: activeKeyProp,\n onTabClick,\n onTabClose,\n paneStyles,\n isClosable = true,\n children,\n ...props\n}: CubeFileTabsProps) {\n const tabsRef = useRef<HTMLButtonElement>(null);\n const [tabs, setTabs] = useState<TabData[]>([]);\n const [activeKey, setActiveKey] = useState<string | number | undefined>(\n activeKeyProp || defaultActiveKey,\n );\n\n const [leftFade, setLeftFade] = useState(false);\n const [rightFade, setRightFade] = useState(false);\n\n function updateScroll() {\n const el = tabsRef && tabsRef.current;\n\n if (!el) return;\n\n setLeftFade(!!el.scrollLeft);\n setRightFade(\n el.scrollWidth !== el.offsetWidth &&\n !!(el.scrollWidth - el.offsetWidth - el.scrollLeft),\n );\n }\n\n useLayoutEffect(updateScroll, [tabs]);\n\n function scrollCurrentIntoView() {\n const el = tabsRef && tabsRef.current;\n\n if (!el) return;\n\n const current = el.querySelector('button[disabled]');\n\n if (!current) return;\n\n current.scrollIntoView({ behavior: 'smooth', inline: 'end', block: 'end' });\n }\n\n useEffect(() => {\n function update() {\n updateScroll();\n }\n\n if (tabsRef && tabsRef.current) {\n tabsRef.current.addEventListener('scroll', update);\n tabsRef.current.addEventListener('mousewheel', update);\n window.addEventListener('resize', update);\n }\n\n return () => {\n if (tabsRef && tabsRef.current) {\n tabsRef.current.removeEventListener('scroll', update);\n tabsRef.current.removeEventListener('mousewheel', update);\n }\n\n window.removeEventListener('resize', update);\n };\n }, [tabsRef]);\n\n useEffect(scrollCurrentIntoView, [activeKey]);\n\n useEffect(() => {\n setActiveKey(activeKeyProp);\n }, [activeKeyProp]);\n\n function getTab(tabs: TabData[], key: string | number): TabData | undefined {\n return tabs.find((tab) => tab.id === key);\n }\n\n function setTab(key: string | number) {\n if (getTab(tabs, key)) {\n setActiveKey(key);\n }\n }\n\n function addTab(tab: TabData) {\n setTabs((tabs) => {\n if (!getTab(tabs, tab.id)) {\n return [...tabs, tab];\n }\n\n return tabs;\n });\n }\n\n function setDirtyTab(id: string | number, isDirty: boolean) {\n setTabs((tabs) => {\n const tab = getTab(tabs, id);\n\n if (tab) {\n tab.isDirty = isDirty;\n\n return [...tabs];\n }\n\n return tabs;\n });\n }\n\n function handleClose(tab) {\n if (getTab(tabs, tab.id)) {\n onTabClose && onTabClose(tab.id);\n }\n }\n\n function removeTab(tab) {\n setTabs((tabs) => {\n const _tabs = tabs.filter((_tab) => _tab.id !== tab.id);\n\n setActiveKey((prevActiveKey) => {\n if (prevActiveKey === tab.id) {\n return _tabs[0] && _tabs[0].id;\n }\n\n return prevActiveKey;\n });\n\n return _tabs;\n });\n }\n\n function onPress(tab) {\n setTab(tab.id);\n onTabClick && onTabClick(tab.id);\n }\n\n return (\n <TabsContainerElement {...props}>\n <FileTabsContext.Provider\n value={{\n addTab,\n setTab,\n removeTab,\n setDirtyTab,\n currentTab: activeKey,\n }}\n >\n <TabsPanelElement\n ref={tabsRef}\n data-left-fade={leftFade || null}\n data-right-fade={rightFade || null}\n >\n {tabs.map((tab) => {\n return (\n <Tab\n key={tab.id}\n isClosable={isClosable}\n isDisabled={tab.id === activeKey || false}\n isDirty={tab.isDirty}\n onPress={() => onPress(tab)}\n onClose={() => isClosable && handleClose(tab)}\n >\n {tab.title}\n </Tab>\n );\n })}\n </TabsPanelElement>\n <Flex flexGrow={1} border=\"top\" {...(paneStyles || {})}>\n {children}\n </Flex>\n </FileTabsContext.Provider>\n </TabsContainerElement>\n );\n}\n\nexport interface CubeFileTabProps extends FileTabProps {\n id: string | number;\n title: string;\n}\n\nFileTabs.TabPane = function FileTabPane(allProps: CubeFileTabProps) {\n let { id, title, isDirty, children, ...props } = allProps;\n const { addTab, removeTab, currentTab, setDirtyTab } =\n useContext(FileTabsContext);\n\n useEffect(() => {\n const tabData = {\n id,\n title,\n isDirty,\n };\n\n addTab(tabData);\n\n return () => {\n removeTab(tabData);\n };\n }, [id, title]);\n\n useEffect(() => {\n setDirtyTab(id, isDirty || false);\n }, [isDirty]);\n\n const isCurrent = id === currentTab;\n\n return (\n <Block\n style={{ display: isCurrent ? 'block' : 'none', maxWidth: '100%' }}\n flexGrow={1}\n {...props}\n >\n {children}\n </Block>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,kBAAkB,cAAmC;CACzD,SAAS;CACT,YAAY;CACZ,SAAS;CACT,cAAc;CACf,CAAC;AAEF,MAAM,mBAAmB,MAAM,OAAO;CACpC,IAAI;CACJ,QAAQ;EACN,UAAU;EACV,UAAU;EACV,KAAK;EACL,KAAK;EACL,YAAY;EACZ,YAAY;EACZ,WAAW;EACX,SAAS;EACT,MAAM;GACJ,IAAI;GACJ,aAAa;GACb,cAAc;GACd,0BAA0B;GAC3B;EACD,YAAY;EACZ,sBAAsB;EACtB,qBAAqB;EACrB,6BAA6B;EAC9B;CACF,CAAC;AAEF,MAAM,uBAAuB,MAAM,MAAM;CACvC,IAAI;CACJ,QAAQ;EACN,MAAM;EACN,QAAQ;EACR,OAAO;EACP,UAAU;EACX;CACF,CAAC;AAEF,MAAM,aAAa,MAAM;CACvB,SAAS;CACT,QAAQ;EACN,UAAU;EACV,KAAK;EACL,MAAM;EACN,WAAW;EACX,OAAO;EACP,QAAQ;EACR,MAAM;EACN,QAAQ;EACT;CACF,CAAC;AAEF,MAAM,aAAa,MAAM,QAAQ,EAC/B,QAAQ;CACN,QAAQ;CACR,SAAS;CACT,QAAQ;EACN,IAAI;EACJ,UAAU;EACX;CACD,MAAM;EACJ,IAAI;EACJ,SAAS;EACT,8BAA8B;EAC/B;CACD,OAAO;EACL,IAAI;EACJ,yCAAyC;EAC1C;CACD,QAAQ;E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C,QAAQ,CAAC;AAIb,QACE,oBAAC;EACC,OAAO;GAAE,SAJK,OAAO,aAIS,UAAU;GAAQ,UAAU;GAAQ;EAClE,UAAU;EACV,GAAI;EAEH;GACK"}
|
|
1
|
+
{"version":3,"file":"FileTabs.js","names":[],"sources":["../../../../src/components/organisms/FileTabs/FileTabs.tsx"],"sourcesContent":["import { Styles, tasty } from '@tenphi/tasty';\nimport {\n createContext,\n ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CloseIcon } from '../../../icons';\nimport { useLayoutEffect } from '../../../utils/react';\nimport { Action, Button, CubeActionProps } from '../../actions';\nimport { Block } from '../../Block';\nimport { CubeFlexProps, Flex } from '../../layout/Flex';\nimport { Space } from '../../layout/Space';\n\ninterface TabData {\n id: string | number;\n title?: string;\n isDirty?: boolean;\n}\n\ninterface FileTabContextValue {\n addTab: (tab: TabData) => void;\n setTab: (id: string | number) => void;\n removeTab: (tab: TabData) => void;\n currentTab?: string | number;\n setDirtyTab: (id: string | number, isDirty: boolean) => void;\n}\n\nconst FileTabsContext = createContext<FileTabContextValue>({\n addTab() {},\n removeTab() {},\n setTab() {},\n setDirtyTab() {},\n});\n\nconst TabsPanelElement = tasty(Space, {\n qa: 'TabsPanel',\n styles: {\n position: 'relative',\n overflow: 'auto hidden',\n top: '1bw',\n gap: '.5x',\n flexShrink: 0,\n whiteSpace: 'nowrap',\n scrollbar: 'styled',\n padding: '1ow 1ow 0 1ow',\n fade: {\n '': false,\n 'left-fade': '3x left',\n 'right-fade': '3x right',\n 'right-fade & left-fade': '3x left right',\n },\n transition: 'fade',\n '--scrollbar-radius': '1ow',\n '--scrollbar-width': '.75x',\n '--scrollbar-outline-width': '1px',\n },\n});\n\nconst TabsContainerElement = tasty(Flex, {\n qa: 'TabsContainer',\n styles: {\n flow: 'column',\n height: 'max 100%',\n width: 'max 100%',\n position: 'relative',\n },\n});\n\nconst DirtyBadge = tasty({\n element: 'DirtyBadge',\n styles: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n width: '1x',\n height: '1x',\n fill: '#dark.30',\n radius: 'round',\n },\n});\n\nconst TabElement = tasty(Action, {\n styles: {\n radius: '1r 1r 0 0',\n padding: '1x 1.5x',\n border: {\n '': 'left top right #clear',\n disabled: 'left top right #border',\n },\n fill: {\n '': '#dark.04',\n hovered: '#dark.08',\n 'disabled, disabled & hover': '#surface',\n },\n color: {\n '': '#dark-02',\n 'disabled, hovered, hovered & disabled': '#dark',\n },\n cursor: {\n '': '$pointer',\n disabled: 'default',\n },\n fontWeight: 500,\n opacity: 1,\n preset: 'default',\n transform: {\n '': 'translate(0, 0)',\n disabled: 'translate(0, 1bw)',\n },\n transition: 'theme 0.2s',\n margin: '1bw bottom',\n\n DirtyBadge: {\n opacity: {\n '': 1,\n 'dirty & :hover': 0,\n },\n pointerEvents: {\n '': 'auto',\n 'dirty & :hover': 'none',\n },\n },\n\n CloseButton: {\n opacity: {\n '': 0,\n '!dirty | :hover': 1,\n },\n },\n },\n});\n\nconst CloseButton = tasty(Button, {\n element: 'CloseButton',\n type: 'clear',\n icon: <CloseIcon />,\n label: 'Close Tab',\n styles: {\n width: '3x',\n height: '3x',\n padding: 0,\n },\n});\n\n/**\n * @deprecated consider using <Tabs /> instead\n */\nexport interface FileTabProps extends Omit<CubeActionProps, 'id'> {\n isDirty?: boolean;\n isDisabled?: boolean;\n children?: ReactNode;\n isClosable?: boolean;\n onClose?: () => void;\n}\n\nfunction Tab({\n isDirty,\n isDisabled,\n children,\n isClosable,\n onClose,\n ...props\n}: FileTabProps) {\n return (\n <TabElement\n mods={{\n dirty: isDirty,\n }}\n isDisabled={isDisabled}\n {...props}\n >\n <Space gap=\".75x\">\n <Block>{children}</Block>\n {(isClosable || isDirty) && (\n <Flex placeItems=\"center\" style={{ position: 'relative' }}>\n {isClosable ? <CloseButton onPress={onClose} /> : <div></div>}\n {isDirty ? <DirtyBadge /> : null}\n </Flex>\n )}\n </Space>\n </TabElement>\n );\n}\n\nexport interface CubeFileTabsProps extends CubeFlexProps {\n /** The initial active key in the tabs (uncontrolled). */\n defaultActiveKey?: string;\n /** The currently active key in the tabs (controlled). */\n activeKey?: string | number;\n /** Handler that is called when the tab is clicked. */\n onTabClick?: (string) => void;\n /** Handler that is called when the tab is closed. */\n onTabClose?: (string) => void;\n /** Styles for each tab pane */\n paneStyles?: Styles;\n /** Whether the tabs are closable */\n isClosable?: boolean;\n children?: ReactNode;\n}\n\nexport function FileTabs({\n defaultActiveKey,\n activeKey: activeKeyProp,\n onTabClick,\n onTabClose,\n paneStyles,\n isClosable = true,\n children,\n ...props\n}: CubeFileTabsProps) {\n const tabsRef = useRef<HTMLButtonElement>(null);\n const [tabs, setTabs] = useState<TabData[]>([]);\n const [activeKey, setActiveKey] = useState<string | number | undefined>(\n activeKeyProp || defaultActiveKey,\n );\n\n const [leftFade, setLeftFade] = useState(false);\n const [rightFade, setRightFade] = useState(false);\n\n function updateScroll() {\n const el = tabsRef && tabsRef.current;\n\n if (!el) return;\n\n setLeftFade(!!el.scrollLeft);\n setRightFade(\n el.scrollWidth !== el.offsetWidth &&\n !!(el.scrollWidth - el.offsetWidth - el.scrollLeft),\n );\n }\n\n useLayoutEffect(updateScroll, [tabs]);\n\n function scrollCurrentIntoView() {\n const el = tabsRef && tabsRef.current;\n\n if (!el) return;\n\n const current = el.querySelector('button[disabled]');\n\n if (!current) return;\n\n current.scrollIntoView({ behavior: 'smooth', inline: 'end', block: 'end' });\n }\n\n useEffect(() => {\n function update() {\n updateScroll();\n }\n\n if (tabsRef && tabsRef.current) {\n tabsRef.current.addEventListener('scroll', update);\n tabsRef.current.addEventListener('mousewheel', update);\n window.addEventListener('resize', update);\n }\n\n return () => {\n if (tabsRef && tabsRef.current) {\n tabsRef.current.removeEventListener('scroll', update);\n tabsRef.current.removeEventListener('mousewheel', update);\n }\n\n window.removeEventListener('resize', update);\n };\n }, [tabsRef]);\n\n useEffect(scrollCurrentIntoView, [activeKey]);\n\n useEffect(() => {\n setActiveKey(activeKeyProp);\n }, [activeKeyProp]);\n\n function getTab(tabs: TabData[], key: string | number): TabData | undefined {\n return tabs.find((tab) => tab.id === key);\n }\n\n function setTab(key: string | number) {\n if (getTab(tabs, key)) {\n setActiveKey(key);\n }\n }\n\n function addTab(tab: TabData) {\n setTabs((tabs) => {\n if (!getTab(tabs, tab.id)) {\n return [...tabs, tab];\n }\n\n return tabs;\n });\n }\n\n function setDirtyTab(id: string | number, isDirty: boolean) {\n setTabs((tabs) => {\n const tab = getTab(tabs, id);\n\n if (tab) {\n tab.isDirty = isDirty;\n\n return [...tabs];\n }\n\n return tabs;\n });\n }\n\n function handleClose(tab) {\n if (getTab(tabs, tab.id)) {\n onTabClose && onTabClose(tab.id);\n }\n }\n\n function removeTab(tab) {\n setTabs((tabs) => {\n const _tabs = tabs.filter((_tab) => _tab.id !== tab.id);\n\n setActiveKey((prevActiveKey) => {\n if (prevActiveKey === tab.id) {\n return _tabs[0] && _tabs[0].id;\n }\n\n return prevActiveKey;\n });\n\n return _tabs;\n });\n }\n\n function onPress(tab) {\n setTab(tab.id);\n onTabClick && onTabClick(tab.id);\n }\n\n return (\n <TabsContainerElement {...props}>\n <FileTabsContext.Provider\n value={{\n addTab,\n setTab,\n removeTab,\n setDirtyTab,\n currentTab: activeKey,\n }}\n >\n <TabsPanelElement\n ref={tabsRef}\n data-left-fade={leftFade || null}\n data-right-fade={rightFade || null}\n >\n {tabs.map((tab) => {\n return (\n <Tab\n key={tab.id}\n isClosable={isClosable}\n isDisabled={tab.id === activeKey || false}\n isDirty={tab.isDirty}\n onPress={() => onPress(tab)}\n onClose={() => isClosable && handleClose(tab)}\n >\n {tab.title}\n </Tab>\n );\n })}\n </TabsPanelElement>\n <Flex flexGrow={1} border=\"top\" {...(paneStyles || {})}>\n {children}\n </Flex>\n </FileTabsContext.Provider>\n </TabsContainerElement>\n );\n}\n\nexport interface CubeFileTabProps extends FileTabProps {\n id: string | number;\n title: string;\n}\n\nFileTabs.TabPane = function FileTabPane(allProps: CubeFileTabProps) {\n let { id, title, isDirty, children, ...props } = allProps;\n const { addTab, removeTab, currentTab, setDirtyTab } =\n useContext(FileTabsContext);\n\n useEffect(() => {\n const tabData = {\n id,\n title,\n isDirty,\n };\n\n addTab(tabData);\n\n return () => {\n removeTab(tabData);\n };\n }, [id, title]);\n\n useEffect(() => {\n setDirtyTab(id, isDirty || false);\n }, [isDirty]);\n\n const isCurrent = id === currentTab;\n\n return (\n <Block\n style={{ display: isCurrent ? 'block' : 'none', maxWidth: '100%' }}\n flexGrow={1}\n {...props}\n >\n {children}\n </Block>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,kBAAkB,cAAmC;CACzD,SAAS;CACT,YAAY;CACZ,SAAS;CACT,cAAc;CACf,CAAC;AAEF,MAAM,mBAAmB,MAAM,OAAO;CACpC,IAAI;CACJ,QAAQ;EACN,UAAU;EACV,UAAU;EACV,KAAK;EACL,KAAK;EACL,YAAY;EACZ,YAAY;EACZ,WAAW;EACX,SAAS;EACT,MAAM;GACJ,IAAI;GACJ,aAAa;GACb,cAAc;GACd,0BAA0B;GAC3B;EACD,YAAY;EACZ,sBAAsB;EACtB,qBAAqB;EACrB,6BAA6B;EAC9B;CACF,CAAC;AAEF,MAAM,uBAAuB,MAAM,MAAM;CACvC,IAAI;CACJ,QAAQ;EACN,MAAM;EACN,QAAQ;EACR,OAAO;EACP,UAAU;EACX;CACF,CAAC;AAEF,MAAM,aAAa,MAAM;CACvB,SAAS;CACT,QAAQ;EACN,UAAU;EACV,KAAK;EACL,MAAM;EACN,WAAW;EACX,OAAO;EACP,QAAQ;EACR,MAAM;EACN,QAAQ;EACT;CACF,CAAC;AAEF,MAAM,aAAa,MAAM,QAAQ,EAC/B,QAAQ;CACN,QAAQ;CACR,SAAS;CACT,QAAQ;EACN,IAAI;EACJ,UAAU;EACX;CACD,MAAM;EACJ,IAAI;EACJ,SAAS;EACT,8BAA8B;EAC/B;CACD,OAAO;EAC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AgB;AACd,cAAY,IAAI,WAAW,MAAM;IAChC,CAAC,QAAQ,CAAC;AAIb,QACE,oBAAC;EACC,OAAO;GAAE,SAJK,OAAO,aAIS,UAAU;GAAQ,UAAU;GAAQ;EAClE,UAAU;EACV,GAAI;EAEH;GACK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { _Text } from "../../content/Text.js";
|
|
3
3
|
import { _Title } from "../../content/Title.js";
|
|
4
4
|
import { Card } from "../../content/Card/Card.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { _Title } from "../../content/Title.js";
|
|
3
3
|
import { useProviderProps } from "../../../provider.js";
|
|
4
4
|
import { Space } from "../../layout/Space.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { _Title } from "../../content/Title.js";
|
|
3
3
|
import { useProviderProps } from "../../../provider.js";
|
|
4
4
|
import { Space } from "../../layout/Space.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { chain } from "../../../utils/react/chain.js";
|
|
3
3
|
import { Paragraph } from "../../content/Paragraph.js";
|
|
4
4
|
import { _Title } from "../../content/Title.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { AlertDialogZone } from "./AlertDialogZone.js";
|
|
3
3
|
import { createContext, useContext, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { Portal } from "../../portal/Portal.js";
|
|
3
3
|
import { DialogContainer } from "../Dialog/DialogContainer.js";
|
|
4
4
|
import { _AlertDialog } from "./AlertDialog.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { SlotProvider } from "../../../utils/react/Slots.js";
|
|
@@ -87,7 +87,7 @@ const DialogElement = tasty({
|
|
|
87
87
|
});
|
|
88
88
|
const CloseButton = tasty(_ItemButton, {
|
|
89
89
|
qa: "ModalCloseButton",
|
|
90
|
-
type: "
|
|
90
|
+
type: "clear",
|
|
91
91
|
styles: {
|
|
92
92
|
position: "absolute",
|
|
93
93
|
top: "1x",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["ItemButton","mergeProps"],"sources":["../../../../src/components/overlays/Dialog/Dialog.tsx"],"sourcesContent":["import { createFocusManager } from '@react-aria/focus';\nimport { useDOMRef } from '@react-spectrum/utils';\nimport { DOMRef } from '@react-types/shared';\nimport {\n BASE_STYLES,\n BaseProps,\n BaseStyleProps,\n BLOCK_STYLES,\n BlockStyleProps,\n DIMENSION_STYLES,\n DimensionStyleProps,\n FLOW_STYLES,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport { forwardRef, ReactElement, useEffect, useMemo } from 'react';\nimport {\n AriaDialogProps,\n DismissButton,\n FocusScope,\n useDialog,\n useMessageFormatter,\n} from 'react-aria';\n\nimport { CloseIcon } from '../../../icons';\nimport { mergeProps, SlotProvider } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { ItemButton } from '../../actions';\nimport { useOpenTransitionContext } from '../Modal/OpenTransitionContext';\n\nimport { useDialogContext } from './context';\n\nconst STYLES_LIST = [\n ...BASE_STYLES,\n ...DIMENSION_STYLES,\n ...BLOCK_STYLES,\n ...FLOW_STYLES,\n];\n\nconst DialogElement = tasty({\n as: 'section',\n styles: {\n display: 'flex',\n flow: 'column',\n fill: '#surface',\n pointerEvents: 'auto',\n outline: 0,\n position: {\n '': 'relative',\n 'type=panel': 'absolute',\n },\n width: {\n '': '$min-dialog-size $dialog-size (100dvw - 8x)',\n 'type=fullscreen': '(100dvw - 8x) (100dvw - 8x)',\n 'type=fullscreenTakeover': '100dvw 100dvw',\n 'type=panel': 'auto',\n },\n height: {\n '': 'auto (100dvh - 8x)',\n 'type=fullscreen': '(100dvh - 8x) (100dvh - 8x)',\n 'type=fullscreenTakeover | type=panel': '100dvh 100dvh',\n 'type=popover': 'initial initial (50dvh - 5x)',\n },\n gap: 0,\n border: {\n '': false,\n 'type=popover': true,\n },\n radius: {\n '': '1cr',\n 'type=tray': '1cr top',\n 'type=fullscreenTakeover': '0r',\n },\n shadow: {\n '': '$dialog-shadow',\n 'type=popover | type=panel': '$shadow',\n },\n top: {\n '': false,\n 'type=modal': '((50vh - 50%) / -3)',\n 'type=panel': 'auto',\n },\n '$dialog-title-padding-v': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n '$dialog-content-padding-v': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n '$dialog-padding-h': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n '$dialog-footer-v': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n '$dialog-content-gap': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n },\n});\n\nconst CloseButton = tasty(ItemButton, {\n qa: 'ModalCloseButton',\n type: 'neutral',\n styles: {\n position: 'absolute',\n top: '1x',\n right: '1x',\n },\n});\n\nconst sizeMap = {\n S: 'small',\n M: 'medium',\n L: 'large',\n};\nconst sizePxMap = {\n small: 360,\n medium: 479,\n large: 798,\n};\n\nconst intlMessages = {\n 'en-US': {\n dismiss: 'Dismiss',\n alert: 'Alert',\n },\n};\n\nexport interface CubeDialogProps\n extends Omit<BaseProps, 'role'>,\n AriaDialogProps,\n BaseStyleProps,\n BlockStyleProps,\n DimensionStyleProps {\n /** The size of the dialog */\n size?: 'S' | 'M' | 'L' | 'small' | 'medium' | 'large';\n /** Whether the dialog is dismissable */\n isDismissable?: boolean;\n /** Trigger when the dialog is dismissed */\n onDismiss?: (arg?: any) => void;\n /** That you can replace the close icon with */\n closeIcon?: ReactElement;\n closeButtonStyles?: Styles;\n role?: 'dialog' | 'alertdialog';\n}\n\n/**\n * Dialogs are windows containing contextual information, tasks, or workflows that appear over the user interface.\n * Depending on the kind of Dialog, further interactions may be blocked until the Dialog is acknowledged.\n */\nexport const Dialog = forwardRef(function Dialog(\n props: CubeDialogProps,\n ref: DOMRef<HTMLDivElement>,\n) {\n const transitionContext = useOpenTransitionContext();\n\n const isEntered = transitionContext?.transitionState === 'entered';\n\n const context = useDialogContext();\n\n const content = useMemo(() => {\n return <DialogContent key=\"content\" {...props} ref={ref} />;\n }, [props, ref]);\n\n const shouldContainFocus =\n isEntered && !!context.isOpen && context.type !== 'panel';\n\n return (\n // This component traps the focus inside the dialog and restores it on close.\n <FocusScope restoreFocus contain={shouldContainFocus}>\n {content}\n </FocusScope>\n );\n});\n\nconst DialogContent = forwardRef(function DialogContent(\n props: CubeDialogProps,\n ref: DOMRef<HTMLDivElement>,\n) {\n let { type = 'modal', ...contextProps } = useDialogContext();\n\n let {\n qa,\n children,\n size = 'M',\n isDismissable = contextProps.isDismissable,\n onDismiss = contextProps.onClose,\n closeIcon,\n closeButtonStyles,\n style,\n ...otherProps\n } = props;\n\n size = sizeMap[size.toUpperCase()] || size;\n\n const styles: Styles = extractStyles(otherProps, STYLES_LIST);\n\n let formatMessage = useMessageFormatter(intlMessages);\n\n let domRef = useDOMRef(ref);\n let { dialogProps, titleProps } = useDialog(\n mergeProps(contextProps, props),\n domRef,\n );\n\n // If rendered in a popover or tray there won't be a visible dismiss button,\n // so we render a hidden one for screen readers.\n let dismissButton;\n if (type === 'popover' || type === 'tray') {\n dismissButton = <DismissButton onDismiss={onDismiss} />;\n }\n\n // Focus the first focusable element in the dialog when it opens.\n //\n // We also re-run the priority focus logic when the dialog <section>\n // itself is the active element. This recovers from a race that occurs\n // when a popover-based component (FilterPicker, Picker, Select, …) opens\n // inside another contained Dialog: React's native `autoFocus` on the\n // inner control fires during the mutation phase, before the popover's\n // FocusScope registers in react-aria's focus-scope tree, so the outer\n // FocusScope yanks focus back. useDialog then defaults focus to the\n // dialog <section>; without re-promoting it here, the priority element\n // (e.g. the search input) is never focused.\n useEffect(() => {\n if (contextProps.isOpen) {\n setTimeout(() => {\n if (!domRef.current) return;\n\n const activeElement = document.activeElement;\n const isFocusOutsideDialog = !domRef.current.contains(activeElement);\n const isFocusOnDialogShell = activeElement === domRef.current;\n\n // Priority 1: autofocus input or primary button\n const priorityElement = domRef.current.querySelector(\n 'input[data-autofocus], button[type=\"submit\"], button[data-type=\"primary\"]',\n ) as HTMLElement | null;\n\n if (priorityElement && (isFocusOutsideDialog || isFocusOnDialogShell)) {\n priorityElement.focus();\n return;\n }\n\n if (isFocusOutsideDialog) {\n // Fallback: focus first tabbable element, or dialog itself\n const focusManager = createFocusManager(domRef);\n\n if (!focusManager.focusFirst({ tabbable: true })) {\n domRef.current.focus();\n }\n }\n });\n }\n }, [contextProps.isOpen]);\n\n // let hasHeader = useHasChild('[data-id=\"Header\"]', domRef);\n // let hasFooter = useHasChild('[data-id=\"Footer\"]', domRef);\n\n let slots = {\n title: {\n level: 2,\n preset: 'h4',\n ...titleProps,\n },\n content: {\n styles: {\n flexGrow: 1,\n padding: '$dialog-content-padding-v $dialog-padding-h',\n gap: '$dialog-content-gap',\n height: {\n '': 'max (100% - (2 * $dialog-content-padding-v))',\n ':last-child': 'max (100% - $dialog-content-padding-v)',\n },\n },\n },\n header: {\n ellipsis: true,\n styles: {\n display: 'flex',\n flow: 'row',\n gap: '1x',\n placeItems: 'center stretch',\n placeContent: 'space-between',\n padding: `$dialog-title-padding-v ${\n isDismissable ? '($dialog-padding-h + 4x)' : '$dialog-padding-h'\n } $dialog-title-padding-v $dialog-padding-h`,\n border: 'bottom',\n },\n },\n footer: {\n styles: {\n display: 'flex',\n gap: '1x',\n flow: 'row-reverse',\n placeItems: 'baseline stretch',\n placeContent: 'space-between',\n padding: '$dialog-footer-v $dialog-padding-h',\n },\n },\n buttonGroup: {\n styles: {\n flow: 'row-reverse',\n },\n },\n };\n\n return (\n <DialogElement\n ref={domRef}\n data-id=\"Dialog\"\n data-qa={qa || 'Dialog'}\n styles={styles}\n as=\"section\"\n {...dialogProps}\n mods={{ dismissable: isDismissable }}\n style={{\n '--dialog-size': `${sizePxMap[size] || sizePxMap.small}px`,\n ...style,\n }}\n data-type={type}\n data-size={size}\n >\n {dismissButton}\n\n <SlotProvider slots={slots}>\n {isDismissable && (\n <CloseButton\n icon={closeIcon || <CloseIcon size={20} />}\n label={formatMessage('dismiss')}\n onPress={() => onDismiss && onDismiss()}\n />\n )}\n {children}\n </SlotProvider>\n </DialogElement>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAM,cAAc;CAClB,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,MAAM,gBAAgB,MAAM;CAC1B,IAAI;CACJ,QAAQ;EACN,SAAS;EACT,MAAM;EACN,MAAM;EACN,eAAe;EACf,SAAS;EACT,UAAU;GACR,IAAI;GACJ,cAAc;GACf;EACD,OAAO;GACL,IAAI;GACJ,mBAAmB;GACnB,2BAA2B;GAC3B,cAAc;GACf;EACD,QAAQ;GACN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Y;GACZ,cAAc;GACd,SAAS;GACV,EACF;EACD,aAAa,EACX,QAAQ,EACN,MAAM,eACP,EACF;EACF;AAED,QACE,qBAAC;EACC,KAAK;EACL,WAAQ;EACR,WAAS,MAAM;EACP;EACR,IAAG;EACH,GAAI;EACJ,MAAM,EAAE,aAAa,eAAe;EACpC,OAAO;GACL,iBAAiB,GAAG,UAAU,SAAS,UAAU,MAAM;GACvD,GAAG;GACJ;EACD,aAAW;EACX,aAAW;aAEV,eAED,qBAAC;GAAoB;cAClB,iBACC,oBAAC;IACC,MAAM,aAAa,oBAAC,aAAU,MAAM,KAAM;IAC1C,OAAO,cAAc,UAAU;IAC/B,eAAe,aAAa,WAAW;KACvC,EAEH;IACY;GACD;EAElB"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["ItemButton","mergeProps"],"sources":["../../../../src/components/overlays/Dialog/Dialog.tsx"],"sourcesContent":["import { createFocusManager } from '@react-aria/focus';\nimport { useDOMRef } from '@react-spectrum/utils';\nimport { DOMRef } from '@react-types/shared';\nimport {\n BASE_STYLES,\n BaseProps,\n BaseStyleProps,\n BLOCK_STYLES,\n BlockStyleProps,\n DIMENSION_STYLES,\n DimensionStyleProps,\n FLOW_STYLES,\n Styles,\n tasty,\n} from '@tenphi/tasty';\nimport { forwardRef, ReactElement, useEffect, useMemo } from 'react';\nimport {\n AriaDialogProps,\n DismissButton,\n FocusScope,\n useDialog,\n useMessageFormatter,\n} from 'react-aria';\n\nimport { CloseIcon } from '../../../icons';\nimport { mergeProps, SlotProvider } from '../../../utils/react';\nimport { extractStyles } from '../../../utils/styles';\nimport { ItemButton } from '../../actions';\nimport { useOpenTransitionContext } from '../Modal/OpenTransitionContext';\n\nimport { useDialogContext } from './context';\n\nconst STYLES_LIST = [\n ...BASE_STYLES,\n ...DIMENSION_STYLES,\n ...BLOCK_STYLES,\n ...FLOW_STYLES,\n];\n\nconst DialogElement = tasty({\n as: 'section',\n styles: {\n display: 'flex',\n flow: 'column',\n fill: '#surface',\n pointerEvents: 'auto',\n outline: 0,\n position: {\n '': 'relative',\n 'type=panel': 'absolute',\n },\n width: {\n '': '$min-dialog-size $dialog-size (100dvw - 8x)',\n 'type=fullscreen': '(100dvw - 8x) (100dvw - 8x)',\n 'type=fullscreenTakeover': '100dvw 100dvw',\n 'type=panel': 'auto',\n },\n height: {\n '': 'auto (100dvh - 8x)',\n 'type=fullscreen': '(100dvh - 8x) (100dvh - 8x)',\n 'type=fullscreenTakeover | type=panel': '100dvh 100dvh',\n 'type=popover': 'initial initial (50dvh - 5x)',\n },\n gap: 0,\n border: {\n '': false,\n 'type=popover': true,\n },\n radius: {\n '': '1cr',\n 'type=tray': '1cr top',\n 'type=fullscreenTakeover': '0r',\n },\n shadow: {\n '': '$dialog-shadow',\n 'type=popover | type=panel': '$shadow',\n },\n top: {\n '': false,\n 'type=modal': '((50vh - 50%) / -3)',\n 'type=panel': 'auto',\n },\n '$dialog-title-padding-v': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n '$dialog-content-padding-v': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n '$dialog-padding-h': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n '$dialog-footer-v': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n '$dialog-content-gap': {\n '': '1.5x',\n 'type=popover': '1x',\n },\n },\n});\n\nconst CloseButton = tasty(ItemButton, {\n qa: 'ModalCloseButton',\n type: 'clear',\n styles: {\n position: 'absolute',\n top: '1x',\n right: '1x',\n },\n});\n\nconst sizeMap = {\n S: 'small',\n M: 'medium',\n L: 'large',\n};\nconst sizePxMap = {\n small: 360,\n medium: 479,\n large: 798,\n};\n\nconst intlMessages = {\n 'en-US': {\n dismiss: 'Dismiss',\n alert: 'Alert',\n },\n};\n\nexport interface CubeDialogProps\n extends Omit<BaseProps, 'role'>,\n AriaDialogProps,\n BaseStyleProps,\n BlockStyleProps,\n DimensionStyleProps {\n /** The size of the dialog */\n size?: 'S' | 'M' | 'L' | 'small' | 'medium' | 'large';\n /** Whether the dialog is dismissable */\n isDismissable?: boolean;\n /** Trigger when the dialog is dismissed */\n onDismiss?: (arg?: any) => void;\n /** That you can replace the close icon with */\n closeIcon?: ReactElement;\n closeButtonStyles?: Styles;\n role?: 'dialog' | 'alertdialog';\n}\n\n/**\n * Dialogs are windows containing contextual information, tasks, or workflows that appear over the user interface.\n * Depending on the kind of Dialog, further interactions may be blocked until the Dialog is acknowledged.\n */\nexport const Dialog = forwardRef(function Dialog(\n props: CubeDialogProps,\n ref: DOMRef<HTMLDivElement>,\n) {\n const transitionContext = useOpenTransitionContext();\n\n const isEntered = transitionContext?.transitionState === 'entered';\n\n const context = useDialogContext();\n\n const content = useMemo(() => {\n return <DialogContent key=\"content\" {...props} ref={ref} />;\n }, [props, ref]);\n\n const shouldContainFocus =\n isEntered && !!context.isOpen && context.type !== 'panel';\n\n return (\n // This component traps the focus inside the dialog and restores it on close.\n <FocusScope restoreFocus contain={shouldContainFocus}>\n {content}\n </FocusScope>\n );\n});\n\nconst DialogContent = forwardRef(function DialogContent(\n props: CubeDialogProps,\n ref: DOMRef<HTMLDivElement>,\n) {\n let { type = 'modal', ...contextProps } = useDialogContext();\n\n let {\n qa,\n children,\n size = 'M',\n isDismissable = contextProps.isDismissable,\n onDismiss = contextProps.onClose,\n closeIcon,\n closeButtonStyles,\n style,\n ...otherProps\n } = props;\n\n size = sizeMap[size.toUpperCase()] || size;\n\n const styles: Styles = extractStyles(otherProps, STYLES_LIST);\n\n let formatMessage = useMessageFormatter(intlMessages);\n\n let domRef = useDOMRef(ref);\n let { dialogProps, titleProps } = useDialog(\n mergeProps(contextProps, props),\n domRef,\n );\n\n // If rendered in a popover or tray there won't be a visible dismiss button,\n // so we render a hidden one for screen readers.\n let dismissButton;\n if (type === 'popover' || type === 'tray') {\n dismissButton = <DismissButton onDismiss={onDismiss} />;\n }\n\n // Focus the first focusable element in the dialog when it opens.\n //\n // We also re-run the priority focus logic when the dialog <section>\n // itself is the active element. This recovers from a race that occurs\n // when a popover-based component (FilterPicker, Picker, Select, …) opens\n // inside another contained Dialog: React's native `autoFocus` on the\n // inner control fires during the mutation phase, before the popover's\n // FocusScope registers in react-aria's focus-scope tree, so the outer\n // FocusScope yanks focus back. useDialog then defaults focus to the\n // dialog <section>; without re-promoting it here, the priority element\n // (e.g. the search input) is never focused.\n useEffect(() => {\n if (contextProps.isOpen) {\n setTimeout(() => {\n if (!domRef.current) return;\n\n const activeElement = document.activeElement;\n const isFocusOutsideDialog = !domRef.current.contains(activeElement);\n const isFocusOnDialogShell = activeElement === domRef.current;\n\n // Priority 1: autofocus input or primary button\n const priorityElement = domRef.current.querySelector(\n 'input[data-autofocus], button[type=\"submit\"], button[data-type=\"primary\"]',\n ) as HTMLElement | null;\n\n if (priorityElement && (isFocusOutsideDialog || isFocusOnDialogShell)) {\n priorityElement.focus();\n return;\n }\n\n if (isFocusOutsideDialog) {\n // Fallback: focus first tabbable element, or dialog itself\n const focusManager = createFocusManager(domRef);\n\n if (!focusManager.focusFirst({ tabbable: true })) {\n domRef.current.focus();\n }\n }\n });\n }\n }, [contextProps.isOpen]);\n\n // let hasHeader = useHasChild('[data-id=\"Header\"]', domRef);\n // let hasFooter = useHasChild('[data-id=\"Footer\"]', domRef);\n\n let slots = {\n title: {\n level: 2,\n preset: 'h4',\n ...titleProps,\n },\n content: {\n styles: {\n flexGrow: 1,\n padding: '$dialog-content-padding-v $dialog-padding-h',\n gap: '$dialog-content-gap',\n height: {\n '': 'max (100% - (2 * $dialog-content-padding-v))',\n ':last-child': 'max (100% - $dialog-content-padding-v)',\n },\n },\n },\n header: {\n ellipsis: true,\n styles: {\n display: 'flex',\n flow: 'row',\n gap: '1x',\n placeItems: 'center stretch',\n placeContent: 'space-between',\n padding: `$dialog-title-padding-v ${\n isDismissable ? '($dialog-padding-h + 4x)' : '$dialog-padding-h'\n } $dialog-title-padding-v $dialog-padding-h`,\n border: 'bottom',\n },\n },\n footer: {\n styles: {\n display: 'flex',\n gap: '1x',\n flow: 'row-reverse',\n placeItems: 'baseline stretch',\n placeContent: 'space-between',\n padding: '$dialog-footer-v $dialog-padding-h',\n },\n },\n buttonGroup: {\n styles: {\n flow: 'row-reverse',\n },\n },\n };\n\n return (\n <DialogElement\n ref={domRef}\n data-id=\"Dialog\"\n data-qa={qa || 'Dialog'}\n styles={styles}\n as=\"section\"\n {...dialogProps}\n mods={{ dismissable: isDismissable }}\n style={{\n '--dialog-size': `${sizePxMap[size] || sizePxMap.small}px`,\n ...style,\n }}\n data-type={type}\n data-size={size}\n >\n {dismissButton}\n\n <SlotProvider slots={slots}>\n {isDismissable && (\n <CloseButton\n icon={closeIcon || <CloseIcon size={20} />}\n label={formatMessage('dismiss')}\n onPress={() => onDismiss && onDismiss()}\n />\n )}\n {children}\n </SlotProvider>\n </DialogElement>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAM,cAAc;CAClB,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,MAAM,gBAAgB,MAAM;CAC1B,IAAI;CACJ,QAAQ;EACN,SAAS;EACT,MAAM;EACN,MAAM;EACN,eAAe;EACf,SAAS;EACT,UAAU;GACR,IAAI;GACJ,cAAc;GACf;EACD,OAAO;GACL,IAAI;GACJ,mBAAmB;GACnB,2BAA2B;GAC3B,cAAc;GACf;EACD,QAAQ;GACN,IAAI;GACJ,mBAAmB;GACnB,wCAAwC;GACxC,gBAAgB;GACjB;EACD,KAAK;EACL,QAAQ;GACN,IAAI;GACJ,gBAAgB;GACjB;EACD,QAAQ;GACN,IAAI;GACJ,aAAa;GACb,2BAA2B;GAC5B;EACD,QAAQ;GACN,IAAI;GACJ,6BAA6B;GAC9B;EACD,KAAK;GACH,IAAI;GACJ,cAAc;GACd,cAAc;GACf;EACD,2BAA2B;GACzB,IAAI;GACJ,gBAAgB;GACjB;EACD,6BAA6B;GAC3B,IAAI;GACJ,gBAAgB;GACjB;EACD,qBAAqB;GACnB,IAAI;GACJ,gBAAgB;GACjB;EACD,oBAA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B,eAAe,aAAa,WAAW;KACvC,EAEH;IACY;GACD;EAElB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { _Modal } from "../Modal/Modal.js";
|
|
3
3
|
import { DialogContext } from "./context.js";
|
|
4
4
|
import { Children, isValidElement, useRef } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { _Title } from "../../content/Title.js";
|
|
3
3
|
import { ButtonGroup } from "../../actions/ButtonGroup/ButtonGroup.js";
|
|
4
4
|
import { Button } from "../../actions/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { useCombinedRefs } from "../../../utils/react/useCombinedRefs.js";
|
|
3
3
|
import { _Modal } from "../Modal/Modal.js";
|
|
4
4
|
import { _Tray } from "../Modal/Tray.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
4
4
|
import { DialogContainer } from "./DialogContainer.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { _Overlay } from "./Overlay.js";
|
|
4
4
|
import { _Underlay } from "./Underlay.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { DisplayTransition } from "../../helpers/DisplayTransition/DisplayTransition.js";
|
|
3
3
|
import { Provider, useProviderProps } from "../../../provider.js";
|
|
4
4
|
import { OpenTransitionContext } from "./OpenTransitionContext.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { _Overlay } from "./Overlay.js";
|
|
4
4
|
import { tasty } from "@tenphi/tasty";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { _Overlay } from "./Overlay.js";
|
|
4
4
|
import { _Underlay } from "./Underlay.js";
|
|
@@ -12,7 +12,7 @@ import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
12
12
|
* - An action with no `onPress` and `closeOnPress: true` acts as a dismiss-only action.
|
|
13
13
|
* - `isDismiss` — marks this action as the dismiss button; when present, the default
|
|
14
14
|
* "Dismiss" button is auto-suppressed via context detection.
|
|
15
|
-
* - Type (primary/
|
|
15
|
+
* - Type (primary/outline/clear/etc.) is set automatically via ItemActionProvider context.
|
|
16
16
|
*/
|
|
17
17
|
declare function NotificationAction({
|
|
18
18
|
children,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.140.0 | Cube Dev Team */
|
|
2
2
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
3
3
|
import { ItemAction } from "../../actions/ItemAction/ItemAction.js";
|
|
4
4
|
import { createContext, useContext, useMemo } from "react";
|
|
@@ -37,7 +37,7 @@ const DismissActionDetectedContext = createContext(null);
|
|
|
37
37
|
* - An action with no `onPress` and `closeOnPress: true` acts as a dismiss-only action.
|
|
38
38
|
* - `isDismiss` — marks this action as the dismiss button; when present, the default
|
|
39
39
|
* "Dismiss" button is auto-suppressed via context detection.
|
|
40
|
-
* - Type (primary/
|
|
40
|
+
* - Type (primary/outline/clear/etc.) is set automatically via ItemActionProvider context.
|
|
41
41
|
*/
|
|
42
42
|
function NotificationAction({ children, onPress, closeOnPress = true, isDisabled, isDismiss }) {
|
|
43
43
|
const dismissCtx = useContext(NotificationDismissContext);
|
|
@@ -45,7 +45,8 @@ function NotificationAction({ children, onPress, closeOnPress = true, isDisabled
|
|
|
45
45
|
if (isDismiss && dismissDetectedRef) dismissDetectedRef.current = true;
|
|
46
46
|
const actionInterceptor = useContext(NotificationActionInterceptorContext);
|
|
47
47
|
return /* @__PURE__ */ jsx(ItemAction, {
|
|
48
|
-
|
|
48
|
+
isSelected: true,
|
|
49
|
+
type: "outline",
|
|
49
50
|
isDisabled,
|
|
50
51
|
onPress: useEvent(async () => {
|
|
51
52
|
actionInterceptor?.();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationAction.js","names":[],"sources":["../../../../src/components/overlays/Notifications/NotificationAction.tsx"],"sourcesContent":["import {\n createContext,\n Key,\n ReactNode,\n useContext,\n useMemo,\n useRef,\n} from 'react';\n\nimport { useEvent } from '../../../_internal';\nimport { ItemAction } from '../../actions/ItemAction/ItemAction';\n\nimport type { NotificationActionProps } from './types';\n\n// ─── Notification Action Interceptor Context ─────────────────────────\n\n/**\n * Optional callback invoked BEFORE any action's onPress handler.\n * Provided by PersistentNotificationsList so the parent (e.g. popover)\n * can close itself when an action is triggered.\n */\nconst NotificationActionInterceptorContext = createContext<(() => void) | null>(\n null,\n);\n\nexport { NotificationActionInterceptorContext };\n\n// ─── Notification Dismiss Context ────────────────────────────────────\n\ninterface NotificationDismissContextValue {\n dismiss: (reason: 'action' | 'close') => void;\n restore: () => void;\n}\n\nconst NotificationDismissContext =\n createContext<NotificationDismissContextValue | null>(null);\n\nexport interface NotificationDismissProviderProps {\n notificationId: Key;\n onDismiss: (id: Key, reason: 'action' | 'close') => void;\n onRestore?: (id: Key) => void;\n children: ReactNode;\n}\n\nexport function NotificationDismissProvider({\n notificationId,\n onDismiss,\n onRestore,\n children,\n}: NotificationDismissProviderProps) {\n const dismiss = useEvent((reason: 'action' | 'close') => {\n onDismiss(notificationId, reason);\n });\n\n const restore = useEvent(() => {\n onRestore?.(notificationId);\n });\n\n const value = useMemo(() => ({ dismiss, restore }), [dismiss, restore]);\n\n return (\n <NotificationDismissContext.Provider value={value}>\n {children}\n </NotificationDismissContext.Provider>\n );\n}\n\n// ─── Dismiss Action Detection Context ────────────────────────────────\n//\n// Allows NotificationCard to detect whether any child NotificationAction\n// has `isDismiss` set, without requiring a separate `hasDismissAction` prop.\n//\n// Mechanism:\n// - DismissActionDetector provides a ref via context and resets it each render.\n// - NotificationAction writes to the ref during render when isDismiss is true.\n// - DefaultDismissGuard reads the ref to decide whether to show the default button.\n//\n// This relies on React's left-to-right sibling render order: {actions}\n// children render before <DefaultDismissGuard />, so the ref is populated\n// before it's read. The ref is reset at the provider level each render,\n// making it safe under StrictMode double-rendering.\n\nexport const DismissActionDetectedContext = createContext<ReturnType<\n typeof useRef<boolean>\n> | null>(null);\n\n// ─── NotificationAction Component ────────────────────────────────────\n\n/**\n * Action button for use inside Notification components.\n * Wraps ItemAction with auto-dismiss behavior.\n *\n * - `closeOnPress` (default: true) — auto-dismisses the notification after `onPress`.\n * - An action with no `onPress` and `closeOnPress: true` acts as a dismiss-only action.\n * - `isDismiss` — marks this action as the dismiss button; when present, the default\n * \"Dismiss\" button is auto-suppressed via context detection.\n * - Type (primary/
|
|
1
|
+
{"version":3,"file":"NotificationAction.js","names":[],"sources":["../../../../src/components/overlays/Notifications/NotificationAction.tsx"],"sourcesContent":["import {\n createContext,\n Key,\n ReactNode,\n useContext,\n useMemo,\n useRef,\n} from 'react';\n\nimport { useEvent } from '../../../_internal';\nimport { ItemAction } from '../../actions/ItemAction/ItemAction';\n\nimport type { NotificationActionProps } from './types';\n\n// ─── Notification Action Interceptor Context ─────────────────────────\n\n/**\n * Optional callback invoked BEFORE any action's onPress handler.\n * Provided by PersistentNotificationsList so the parent (e.g. popover)\n * can close itself when an action is triggered.\n */\nconst NotificationActionInterceptorContext = createContext<(() => void) | null>(\n null,\n);\n\nexport { NotificationActionInterceptorContext };\n\n// ─── Notification Dismiss Context ────────────────────────────────────\n\ninterface NotificationDismissContextValue {\n dismiss: (reason: 'action' | 'close') => void;\n restore: () => void;\n}\n\nconst NotificationDismissContext =\n createContext<NotificationDismissContextValue | null>(null);\n\nexport interface NotificationDismissProviderProps {\n notificationId: Key;\n onDismiss: (id: Key, reason: 'action' | 'close') => void;\n onRestore?: (id: Key) => void;\n children: ReactNode;\n}\n\nexport function NotificationDismissProvider({\n notificationId,\n onDismiss,\n onRestore,\n children,\n}: NotificationDismissProviderProps) {\n const dismiss = useEvent((reason: 'action' | 'close') => {\n onDismiss(notificationId, reason);\n });\n\n const restore = useEvent(() => {\n onRestore?.(notificationId);\n });\n\n const value = useMemo(() => ({ dismiss, restore }), [dismiss, restore]);\n\n return (\n <NotificationDismissContext.Provider value={value}>\n {children}\n </NotificationDismissContext.Provider>\n );\n}\n\n// ─── Dismiss Action Detection Context ────────────────────────────────\n//\n// Allows NotificationCard to detect whether any child NotificationAction\n// has `isDismiss` set, without requiring a separate `hasDismissAction` prop.\n//\n// Mechanism:\n// - DismissActionDetector provides a ref via context and resets it each render.\n// - NotificationAction writes to the ref during render when isDismiss is true.\n// - DefaultDismissGuard reads the ref to decide whether to show the default button.\n//\n// This relies on React's left-to-right sibling render order: {actions}\n// children render before <DefaultDismissGuard />, so the ref is populated\n// before it's read. The ref is reset at the provider level each render,\n// making it safe under StrictMode double-rendering.\n\nexport const DismissActionDetectedContext = createContext<ReturnType<\n typeof useRef<boolean>\n> | null>(null);\n\n// ─── NotificationAction Component ────────────────────────────────────\n\n/**\n * Action button for use inside Notification components.\n * Wraps ItemAction with auto-dismiss behavior.\n *\n * - `closeOnPress` (default: true) — auto-dismisses the notification after `onPress`.\n * - An action with no `onPress` and `closeOnPress: true` acts as a dismiss-only action.\n * - `isDismiss` — marks this action as the dismiss button; when present, the default\n * \"Dismiss\" button is auto-suppressed via context detection.\n * - Type (primary/outline/clear/etc.) is set automatically via ItemActionProvider context.\n */\nexport function NotificationAction({\n children,\n onPress,\n closeOnPress = true,\n isDisabled,\n isDismiss,\n}: NotificationActionProps) {\n const dismissCtx = useContext(NotificationDismissContext);\n const dismissDetectedRef = useContext(DismissActionDetectedContext);\n\n // Register isDismiss during render (synchronous, before DefaultDismissGuard renders).\n // Safe under StrictMode: the ref is reset at the DismissActionDetector level each render.\n if (isDismiss && dismissDetectedRef) {\n dismissDetectedRef.current = true;\n }\n\n const actionInterceptor = useContext(NotificationActionInterceptorContext);\n\n const handlePress = useEvent(async () => {\n actionInterceptor?.();\n\n if (closeOnPress || actionInterceptor) {\n // Dismiss immediately so the notification hides before the async action\n // completes (e.g. opening a confirmation dialog).\n // isDismiss actions use 'close' reason — the notification moves to the\n // persistent list. Regular actions use 'action' reason — the notification\n // is fully dismissed and won't reappear.\n // When an actionInterceptor is present (persistent list), always dismiss\n // regardless of closeOnPress — all actions remove the item permanently.\n dismissCtx?.dismiss(isDismiss ? 'close' : 'action');\n }\n\n const result = await onPress?.();\n\n if (result === false && (closeOnPress || actionInterceptor)) {\n // The async action signalled cancellation — restore the notification.\n dismissCtx?.restore();\n }\n });\n\n return (\n <ItemAction\n isSelected\n type=\"outline\"\n isDisabled={isDisabled}\n onPress={handlePress}\n >\n {children}\n </ItemAction>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,uCAAuC,cAC3C,KACD;AAWD,MAAM,6BACJ,cAAsD,KAAK;AAS7D,SAAgB,4BAA4B,EAC1C,gBACA,WACA,WACA,YACmC;CACnC,MAAM,UAAU,UAAU,WAA+B;AACvD,YAAU,gBAAgB,OAAO;GACjC;CAEF,MAAM,UAAU,eAAe;AAC7B,cAAY,eAAe;GAC3B;CAEF,MAAM,QAAQ,eAAe;EAAE;EAAS;EAAS,GAAG,CAAC,SAAS,QAAQ,CAAC;AAEvE,QACE,oBAAC,2BAA2B;EAAgB;EACzC;GACmC;;AAmB1C,MAAa,+BAA+B,cAElC,KAAK;;;;;;;;;;;AAcf,SAAgB,mBAAmB,EACjC,UACA,SACA,eAAe,MACf,YACA,aAC0B;CAC1B,MAAM,aAAa,WAAW,2BAA2B;CACzD,MAAM,qBAAqB,WAAW,6BAA6B;AAInE,KAAI,aAAa,mBACf,oBAAmB,UAAU;CAG/B,MAAM,oBAAoB,WAAW,qCAAqC;AAwB1E,QACE,oBAAC;EACC;EACA,MAAK;EACO;EACZ,SA3BgB,SAAS,YAAY;AACvC,wBAAqB;AAErB,OAAI,gBAAgB,kBAQlB,aAAY,QAAQ,YAAY,UAAU,SAAS;AAKrD,OAFe,MAAM,WAAW,KAEjB,UAAU,gBAAgB,mBAEvC,aAAY,SAAS;IAEvB;EASG;GACU"}
|