@cube-dev/ui-kit 0.0.0-canary-1cd97ae → 0.0.0-canary-5a4d7bc
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 +6 -0
- package/dist/_internal/hooks/use-chained-callback.js +1 -1
- package/dist/_internal/hooks/use-debounced-value.js +1 -1
- package/dist/_internal/hooks/use-deprecation-warning.js +1 -1
- package/dist/_internal/hooks/use-event.js +1 -1
- package/dist/_internal/hooks/use-is-first-render.js +1 -1
- package/dist/_internal/hooks/use-sync-ref.js +1 -1
- package/dist/_internal/hooks/use-timer/timer.js +1 -1
- package/dist/_internal/hooks/use-timer/use-timer.js +1 -1
- package/dist/_internal/hooks/use-warn.js +1 -1
- package/dist/components/Block.js +1 -1
- package/dist/components/CollectionItem.js +1 -1
- package/dist/components/GlobalStyles.js +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/Button.js +17 -3
- 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 +3 -4
- package/dist/components/actions/CommandMenu/CommandMenu.js.map +1 -1
- package/dist/components/actions/CommandMenu/styled.js +1 -1
- package/dist/components/actions/ItemAction/ItemAction.js +1 -1
- package/dist/components/actions/ItemActionContext.js +1 -1
- package/dist/components/actions/ItemButton/ItemButton.js +18 -2
- 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 +3 -4
- package/dist/components/actions/Menu/Menu.js.map +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 +8 -5
- package/dist/components/actions/Menu/MenuTrigger.js.map +1 -1
- package/dist/components/actions/Menu/SubMenuTrigger.js +10 -7
- package/dist/components/actions/Menu/SubMenuTrigger.js.map +1 -1
- package/dist/components/actions/Menu/SubmenuTriggerContext.js +1 -1
- package/dist/components/actions/Menu/context.js +1 -1
- package/dist/components/actions/Menu/styled.js +1 -1
- package/dist/components/actions/index.js +1 -1
- package/dist/components/actions/use-action.js +1 -1
- package/dist/components/actions/use-anchored-menu.js +4 -3
- package/dist/components/actions/use-anchored-menu.js.map +1 -1
- package/dist/components/actions/use-context-menu.js +4 -3
- package/dist/components/actions/use-context-menu.js.map +1 -1
- package/dist/components/content/ActiveZone/ActiveZone.js +1 -1
- package/dist/components/content/Alert/Alert.js +1 -1
- package/dist/components/content/Alert/use-alert.js +1 -1
- package/dist/components/content/Avatar/Avatar.js +1 -1
- package/dist/components/content/Badge/Badge.js +1 -1
- package/dist/components/content/Card/Card.js +1 -1
- package/dist/components/content/Content.js +1 -1
- package/dist/components/content/CopyPasteBlock/CopyPasteBlock.js +1 -1
- package/dist/components/content/CopySnippet/CopySnippet.js +1 -1
- package/dist/components/content/Disclosure/Disclosure.js +1 -1
- package/dist/components/content/Divider.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.js +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.js +1 -1
- package/dist/components/content/ItemCard/ItemCard.js +1 -1
- package/dist/components/content/Layout/GridLayout.js +1 -1
- package/dist/components/content/Layout/Layout.js +1 -1
- package/dist/components/content/Layout/LayoutBlock.js +1 -1
- package/dist/components/content/Layout/LayoutCenter.js +1 -1
- package/dist/components/content/Layout/LayoutContainer.js +1 -1
- package/dist/components/content/Layout/LayoutContent.js +1 -1
- package/dist/components/content/Layout/LayoutContext.js +1 -1
- package/dist/components/content/Layout/LayoutFlex.js +1 -1
- package/dist/components/content/Layout/LayoutFooter.js +1 -1
- package/dist/components/content/Layout/LayoutGrid.js +1 -1
- package/dist/components/content/Layout/LayoutHeader.js +1 -1
- package/dist/components/content/Layout/LayoutPane.js +1 -1
- package/dist/components/content/Layout/LayoutPanel.js +1 -1
- package/dist/components/content/Layout/LayoutPanelHeader.js +1 -1
- package/dist/components/content/Layout/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 +3 -3
- package/dist/components/fields/Checkbox/CheckboxGroup.js.map +1 -1
- package/dist/components/fields/Checkbox/context.js +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +11 -7
- package/dist/components/fields/ComboBox/ComboBox.js.map +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.js +1 -9
- 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 +1 -1
- package/dist/components/fields/PasswordInput/PasswordInput.js +1 -1
- package/dist/components/fields/Picker/Picker.js +1 -9
- package/dist/components/fields/Picker/Picker.js.map +1 -1
- package/dist/components/fields/RadioGroup/Radio.js +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.js +3 -3
- 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 +1 -1
- package/dist/components/fields/Select/Select.js +10 -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.d.ts +1 -2
- package/dist/components/form/Form/Form.js +3 -3
- package/dist/components/form/Form/Form.js.map +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.d.ts +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 +3 -3
- package/dist/components/form/Label.js.map +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 +1 -1
- package/dist/components/navigation/Tabs/TabButton.js +1 -1
- package/dist/components/navigation/Tabs/TabDropIndicator.js +1 -1
- package/dist/components/navigation/Tabs/TabPanel.js +1 -1
- package/dist/components/navigation/Tabs/TabPicker.js +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +1 -1
- package/dist/components/navigation/Tabs/TabsAction.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/popover-placement.js +1 -1
- package/dist/components/navigation/Tabs/styled.js +1 -1
- package/dist/components/navigation/Tabs/types.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-editing.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-indicator.js +1 -1
- package/dist/components/organisms/FileTabs/FileTabs.js +1 -1
- package/dist/components/organisms/StatsCard/StatsCard.js +1 -1
- package/dist/components/other/Calendar/Calendar.js +1 -1
- package/dist/components/other/Calendar/CalendarCell.js +1 -1
- package/dist/components/other/Calendar/CalendarGrid.js +1 -1
- package/dist/components/other/Calendar/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.d.ts +1 -2
- package/dist/components/overlays/Dialog/Dialog.js +3 -3
- package/dist/components/overlays/Dialog/Dialog.js.map +1 -1
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +1 -1
- package/dist/components/overlays/Dialog/DialogTrigger.js +32 -3
- package/dist/components/overlays/Dialog/DialogTrigger.js.map +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 +3 -3
- package/dist/components/overlays/Modal/Modal.js.map +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 +3 -3
- package/dist/components/overlays/Modal/Tray.js.map +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +1 -1
- package/dist/components/overlays/Notifications/NotificationCard.js +1 -1
- package/dist/components/overlays/Notifications/NotificationContext.js +1 -1
- package/dist/components/overlays/Notifications/NotificationItem.js +1 -1
- package/dist/components/overlays/Notifications/OverlayContainer.js +1 -1
- package/dist/components/overlays/Notifications/OverlayProvider.js +1 -1
- package/dist/components/overlays/Notifications/PersistentNotificationsList.js +1 -1
- package/dist/components/overlays/Notifications/dismissed-storage.js +1 -1
- package/dist/components/overlays/Notifications/format-relative-time.js +1 -1
- package/dist/components/overlays/Notifications/index.js +1 -1
- package/dist/components/overlays/Notifications/use-notification-state.js +1 -1
- package/dist/components/overlays/Notifications/use-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-overlay-timers.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-state.js +1 -1
- package/dist/components/overlays/Notifications/use-toast-state.js +1 -1
- package/dist/components/overlays/Toast/ToastItem.js +1 -1
- package/dist/components/overlays/Toast/index.js +1 -1
- package/dist/components/overlays/Toast/useProgressToast.js +1 -1
- package/dist/components/overlays/Toast/useToast.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipProvider.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipTrigger.js +1 -1
- package/dist/components/overlays/Tooltip/context.js +1 -1
- package/dist/components/portal/Portal.js +1 -1
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +1 -1
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/Spin/Cube.js +1 -1
- package/dist/components/status/Spin/InternalSpinner.js +1 -1
- package/dist/components/status/Spin/Spin.js +1 -1
- package/dist/components/status/Spin/SpinsContainer.js +1 -1
- package/dist/data/item-themes.js +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/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.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/provider.js +1 -1
- package/dist/providers/TrackingProvider.js +1 -1
- package/dist/providers/navigationAdapter.default.js +1 -1
- package/dist/tokens/base.js +1 -1
- package/dist/tokens/colors.js +1 -1
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/layout.js +1 -1
- package/dist/tokens/palette.js +1 -1
- package/dist/tokens/shadows.js +1 -1
- package/dist/tokens/sizes.js +1 -1
- package/dist/tokens/spacing.js +1 -1
- package/dist/tokens/typography.js +1 -1
- package/dist/utils/ResizeSensor.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/modules.js +1 -1
- package/dist/utils/promise.js +1 -1
- package/dist/utils/raf.js +1 -1
- package/dist/utils/random.js +1 -1
- package/dist/utils/range.js +1 -1
- package/dist/utils/react/RenderCache.js +1 -1
- package/dist/utils/react/Slots.js +1 -1
- package/dist/utils/react/chain.js +1 -1
- package/dist/utils/react/forwardRefWithGenerics.js +1 -1
- package/dist/utils/react/index.d.ts +1 -0
- package/dist/utils/react/index.js +2 -1
- package/dist/utils/react/interactions.js +1 -1
- package/dist/utils/react/isTextOnly.js +1 -1
- package/dist/utils/react/mapProps.js +1 -1
- package/dist/utils/react/mergeProps.js +1 -1
- package/dist/utils/react/nullableValue.js +1 -1
- package/dist/utils/react/resolveIcon.js +1 -1
- package/dist/utils/react/sharedStore.js +1 -1
- package/dist/utils/react/useCombinedRefs.js +1 -1
- package/dist/utils/react/useControlledFocusVisible.js +1 -1
- package/dist/utils/react/useEventBus.js +25 -15
- package/dist/utils/react/useEventBus.js.map +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.d.ts +105 -0
- package/dist/utils/react/usePopoverSync.js +130 -10
- package/dist/utils/react/usePopoverSync.js.map +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/components/actions/Button.md +102 -24
- package/docs/components/actions/ItemButton.md +71 -34
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
3
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
4
4
|
import { ItemActionProvider } from "../../actions/ItemActionContext.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { DropIndicatorElement } from "./styled.js";
|
|
3
3
|
import { useTabsContext } from "./TabsContext.js";
|
|
4
4
|
import { useEffect, useRef, useState } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { TabPanelElement } from "./styled.js";
|
|
3
3
|
import { useEffect, useMemo, useRef } from "react";
|
|
4
4
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { ItemAction } from "../../actions/ItemAction/ItemAction.js";
|
|
3
3
|
import { CloseIcon } from "../../../icons/CloseIcon.js";
|
|
4
4
|
import { MoreIcon } from "../../../icons/MoreIcon.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { extractStyles } from "../../../utils/styles.js";
|
|
3
3
|
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
4
4
|
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { _ItemButton } from "../../actions/ItemButton/ItemButton.js";
|
|
3
3
|
import { useOptionalTabsContext } from "./TabsContext.js";
|
|
4
4
|
import { tasty } from "@tenphi/tasty";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
//#region src/components/navigation/Tabs/popover-placement.ts
|
|
3
3
|
/**
|
|
4
4
|
* Maps the parent Tabs `placement` to the popover placement for menus and
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { chainRaf } from "../../../utils/raf.js";
|
|
3
3
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { tasty } from "@tenphi/tasty";
|
|
3
3
|
import { useRef } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { CalendarCell } from "./CalendarCell.js";
|
|
3
3
|
import { tasty } from "@tenphi/tasty";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { Button } from "../../actions/index.js";
|
|
3
3
|
import { tasty } from "@tenphi/tasty";
|
|
4
4
|
import { forwardRef } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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";
|
|
@@ -3,7 +3,6 @@ import { BaseProps, BaseStyleProps, BlockStyleProps, DimensionStyleProps, Styles
|
|
|
3
3
|
import * as react from "react";
|
|
4
4
|
import { ReactElement } from "react";
|
|
5
5
|
import { AriaDialogProps } from "react-aria";
|
|
6
|
-
import * as _react_types_shared0 from "@react-types/shared";
|
|
7
6
|
|
|
8
7
|
//#region src/components/overlays/Dialog/Dialog.d.ts
|
|
9
8
|
interface CubeDialogProps extends Omit<BaseProps, 'role'>, AriaDialogProps, BaseStyleProps, BlockStyleProps, DimensionStyleProps {
|
|
@@ -22,7 +21,7 @@ interface CubeDialogProps extends Omit<BaseProps, 'role'>, AriaDialogProps, Base
|
|
|
22
21
|
* Dialogs are windows containing contextual information, tasks, or workflows that appear over the user interface.
|
|
23
22
|
* Depending on the kind of Dialog, further interactions may be blocked until the Dialog is acknowledged.
|
|
24
23
|
*/
|
|
25
|
-
declare const Dialog: react.ForwardRefExoticComponent<CubeDialogProps & react.RefAttributes<
|
|
24
|
+
declare const Dialog: react.ForwardRefExoticComponent<CubeDialogProps & react.RefAttributes<HTMLDivElement>>;
|
|
26
25
|
//#endregion
|
|
27
26
|
export { CubeDialogProps, Dialog };
|
|
28
27
|
//# sourceMappingURL=Dialog.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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";
|
|
@@ -10,8 +10,8 @@ import { BASE_STYLES, BLOCK_STYLES, DIMENSION_STYLES, FLOW_STYLES, tasty } from
|
|
|
10
10
|
import { forwardRef, useEffect, useMemo } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { DismissButton, FocusScope, useDialog, useMessageFormatter } from "react-aria";
|
|
13
|
-
import { useDOMRef } from "@react-spectrum/utils";
|
|
14
13
|
import { createFocusManager } from "@react-aria/focus";
|
|
14
|
+
import { useObjectRef } from "@react-aria/utils";
|
|
15
15
|
|
|
16
16
|
//#region src/components/overlays/Dialog/Dialog.tsx
|
|
17
17
|
const STYLES_LIST = [
|
|
@@ -133,7 +133,7 @@ const DialogContent = forwardRef(function DialogContent(props, ref) {
|
|
|
133
133
|
size = sizeMap[size.toUpperCase()] || size;
|
|
134
134
|
const styles = extractStyles(otherProps, STYLES_LIST);
|
|
135
135
|
let formatMessage = useMessageFormatter(intlMessages);
|
|
136
|
-
let domRef =
|
|
136
|
+
let domRef = useObjectRef(ref);
|
|
137
137
|
let { dialogProps, titleProps } = useDialog(mergeProps$1(contextProps, props), domRef);
|
|
138
138
|
let dismissButton;
|
|
139
139
|
if (type === "popover" || type === "tray") dismissButton = /* @__PURE__ */ jsx(DismissButton, { onDismiss });
|
|
@@ -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: '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,oBAAoB;GAClB,IAAI;GACJ,gBAAgB;GACjB;EACD,uBAAuB;GACrB,IAAI;GACJ,gBAAgB;GACjB;EACF;CACF,CAAC;AAEF,MAAM,cAAc,MAAMA,aAAY;CACpC,IAAI;CACJ,MAAM;CACN,QAAQ;EACN,UAAU;EACV,KAAK;EACL,OAAO;EACR;CACF,CAAC;AAEF,MAAM,UAAU;CACd,GAAG;CACH,GAA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;AACrE,oBAAgB,OAAO;AACvB;;AAGF,OAAI,sBAIF;QAAI,CAFiB,mBAAmB,OAAO,CAE7B,WAAW,EAAE,UAAU,MAAM,CAAC,CAC9C,QAAO,QAAQ,OAAO;;IAG1B;IAEH,CAAC,aAAa,OAAO,CAAC;CAKzB,IAAI,QAAQ;EACV,OAAO;GACL,OAAO;GACP,QAAQ;GACR,GAAG;GACJ;EACD,SAAS,EACP,QAAQ;GACN,UAAU;GACV,SAAS;GACT,KAAK;GACL,QAAQ;IACN,IAAI;IACJ,eAAe;IAChB;GACF,EACF;EACD,QAAQ;GACN,UAAU;GACV,QAAQ;IACN,SAAS;IACT,MAAM;IACN,KAAK;IACL,YAAY;IACZ,cAAc;IACd,SAAS,2BACP,gBAAgB,6BAA6B,oBAC9C;IACD,QAAQ;IACT;GACF;EACD,QAAQ,EACN,QAAQ;GACN,SAAS;GACT,KAAK;GACL,MAAM;GACN,YAAY;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 { useObjectRef } from '@react-aria/utils';\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, Ref, 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: Ref<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: Ref<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 = useObjectRef(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":";;;;;;;;;;;;;;;;AA+BA,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,e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Z,cAAc;IACd,SAAS,2BACP,gBAAgB,6BAA6B,oBAC9C;IACD,QAAQ;IACT;GACF;EACD,QAAQ,EACN,QAAQ;GACN,SAAS;GACT,KAAK;GACL,MAAM;GACN,YAAY;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,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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,10 +1,13 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
|
+
import { useLayoutEffect as useLayoutEffect$1 } from "../../../utils/react/useLayoutEffect.js";
|
|
2
3
|
import { useCombinedRefs } from "../../../utils/react/useCombinedRefs.js";
|
|
4
|
+
import { usePopoverSync } from "../../../utils/react/usePopoverSync.js";
|
|
5
|
+
import { generateRandomId } from "../../../utils/random.js";
|
|
3
6
|
import { _Modal } from "../Modal/Modal.js";
|
|
4
7
|
import { _Tray } from "../Modal/Tray.js";
|
|
5
8
|
import { _Popover } from "../Modal/Popover.js";
|
|
6
9
|
import { DialogContext } from "./context.js";
|
|
7
|
-
import { Fragment, useEffect, useRef } from "react";
|
|
10
|
+
import { Fragment, useEffect, useMemo, useRef } from "react";
|
|
8
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
12
|
import { useOverlayPosition, useOverlayTrigger } from "react-aria";
|
|
10
13
|
import { useMediaQuery } from "@react-spectrum/utils";
|
|
@@ -32,6 +35,17 @@ function DialogTrigger(props) {
|
|
|
32
35
|
let onExiting = () => isExiting.current = true;
|
|
33
36
|
let onExited = () => isExiting.current = false;
|
|
34
37
|
wasOpen.current = state.isOpen;
|
|
38
|
+
const dialogSyncId = useMemo(() => generateRandomId(), []);
|
|
39
|
+
const syncTriggerRef = useRef(null);
|
|
40
|
+
const syncOverlayRef = useRef(null);
|
|
41
|
+
usePopoverSync({
|
|
42
|
+
menuId: dialogSyncId,
|
|
43
|
+
isOpen: state.isOpen,
|
|
44
|
+
onClose: () => state.close(),
|
|
45
|
+
triggerRef: syncTriggerRef,
|
|
46
|
+
containerRef: syncOverlayRef,
|
|
47
|
+
dismissOnInnerButtonPress: type === "popover"
|
|
48
|
+
});
|
|
35
49
|
useEffect(() => {
|
|
36
50
|
return () => {
|
|
37
51
|
if ((wasOpen.current || isExiting.current) && type !== "popover" && type !== "tray") console.warn("CubeUIKit: A DialogTrigger unmounted while open. This is likely due to being placed within a trigger that unmounts or inside a conditional. Consider using a DialogContainer instead.");
|
|
@@ -54,6 +68,9 @@ function DialogTrigger(props) {
|
|
|
54
68
|
isKeyboardDismissDisabled,
|
|
55
69
|
hideArrow,
|
|
56
70
|
shouldCloseOnInteractOutside,
|
|
71
|
+
syncTriggerRef,
|
|
72
|
+
syncOverlayRef,
|
|
73
|
+
triggerType: type,
|
|
57
74
|
onClose
|
|
58
75
|
});
|
|
59
76
|
let renderOverlay = () => {
|
|
@@ -62,6 +79,7 @@ function DialogTrigger(props) {
|
|
|
62
79
|
case "fullscreen":
|
|
63
80
|
case "fullscreenTakeover":
|
|
64
81
|
case "modal": return /* @__PURE__ */ jsx(_Modal, {
|
|
82
|
+
ref: syncOverlayRef,
|
|
65
83
|
hideOnClose,
|
|
66
84
|
isOpen: state.isOpen,
|
|
67
85
|
isDismissable,
|
|
@@ -75,6 +93,7 @@ function DialogTrigger(props) {
|
|
|
75
93
|
children: typeof content === "function" ? content(state.close) : content
|
|
76
94
|
});
|
|
77
95
|
case "tray": return /* @__PURE__ */ jsx(_Tray, {
|
|
96
|
+
ref: syncOverlayRef,
|
|
78
97
|
hideOnClose,
|
|
79
98
|
isOpen: state.isOpen,
|
|
80
99
|
isKeyboardDismissDisabled,
|
|
@@ -91,13 +110,18 @@ function DialogTrigger(props) {
|
|
|
91
110
|
trigger,
|
|
92
111
|
overlay: renderOverlay(),
|
|
93
112
|
hideOnClose,
|
|
113
|
+
syncTriggerRef,
|
|
94
114
|
onClose
|
|
95
115
|
});
|
|
96
116
|
}
|
|
97
117
|
function PopoverTrigger(allProps) {
|
|
98
|
-
let { state, styles, targetRef, trigger, content, hideArrow, onClose, isKeyboardDismissDisabled, hideOnClose, shouldCloseOnInteractOutside, keepOpenOnScroll, ...props } = allProps;
|
|
118
|
+
let { state, styles, targetRef, trigger, content, hideArrow, onClose, isKeyboardDismissDisabled, hideOnClose, shouldCloseOnInteractOutside, keepOpenOnScroll, syncTriggerRef, syncOverlayRef, triggerType, ...props } = allProps;
|
|
99
119
|
let triggerRef = useRef(null);
|
|
100
120
|
let overlayRef = useRef(null);
|
|
121
|
+
useLayoutEffect$1(() => {
|
|
122
|
+
if (syncTriggerRef) syncTriggerRef.current = targetRef?.current ?? triggerRef.current ?? null;
|
|
123
|
+
if (syncOverlayRef) syncOverlayRef.current = overlayRef.current ?? null;
|
|
124
|
+
});
|
|
101
125
|
let { overlayProps: popoverProps, placement, arrowProps, updatePosition } = useOverlayPosition({
|
|
102
126
|
targetRef: targetRef || triggerRef,
|
|
103
127
|
overlayRef,
|
|
@@ -144,6 +168,9 @@ function PopoverTrigger(allProps) {
|
|
|
144
168
|
function DialogTriggerBase(props) {
|
|
145
169
|
const ref = useCombinedRefs(props.ref);
|
|
146
170
|
const wasOpenRef = useRef(false);
|
|
171
|
+
useLayoutEffect$1(() => {
|
|
172
|
+
if (props.syncTriggerRef) props.syncTriggerRef.current = ref.current ?? null;
|
|
173
|
+
});
|
|
147
174
|
let { type, state, onClose, isDismissable, dialogProps = {}, triggerProps = {}, overlay, trigger } = props;
|
|
148
175
|
let context = {
|
|
149
176
|
type,
|
|
@@ -158,9 +185,11 @@ function DialogTriggerBase(props) {
|
|
|
158
185
|
ref.current?.focus();
|
|
159
186
|
} else if (state.isOpen) wasOpenRef.current = true;
|
|
160
187
|
}, [state.isOpen]);
|
|
188
|
+
const triggerExtraProps = type === "popover" ? { "data-popover-trigger": "" } : {};
|
|
161
189
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(PressResponder, {
|
|
162
190
|
ref,
|
|
163
191
|
...triggerProps,
|
|
192
|
+
...triggerExtraProps,
|
|
164
193
|
isPressed: state.isOpen && type !== "modal" && type !== "fullscreen" && type !== "fullscreenTakeover",
|
|
165
194
|
onPress: state.toggle,
|
|
166
195
|
children: trigger
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogTrigger.js","names":["Modal","Tray","Popover"],"sources":["../../../../src/components/overlays/Dialog/DialogTrigger.tsx"],"sourcesContent":["import { PressResponder } from '@react-aria/interactions';\nimport { useMediaQuery } from '@react-spectrum/utils';\nimport { Styles } from '@tenphi/tasty';\nimport { Fragment, ReactElement, RefObject, useEffect, useRef } from 'react';\nimport {\n OverlayTriggerProps,\n Placement,\n PositionProps,\n useOverlayPosition,\n useOverlayTrigger,\n} from 'react-aria';\nimport { OverlayTriggerState, useOverlayTriggerState } from 'react-stately';\n\nimport { useCombinedRefs } from '../../../utils/react/index';\nimport { Modal, Popover, Tray, WithCloseBehavior } from '../Modal';\n\nimport { DialogContext } from './context';\n\nexport type CubeDialogClose = (close: () => void) => ReactElement;\n\nexport interface CubeDialogTriggerProps\n extends OverlayTriggerProps,\n PositionProps,\n WithCloseBehavior {\n /** The Dialog and its trigger element. See the DialogTrigger [Content section](#content) for more information on what to provide as children. */\n children: [\n ReactElement | ((state: OverlayTriggerState) => ReactElement),\n CubeDialogClose | ReactElement,\n ];\n /**\n * The type of Dialog that should be rendered. See the DialogTrigger [types section](#dialog-types) for an explanation on each.\n * @default 'modal'\n */\n type?:\n | 'modal'\n | 'popover'\n | 'tray'\n | 'fullscreen'\n | 'fullscreenTakeover'\n | 'panel';\n /** The type of Dialog that should be rendered when on a mobile device. See DialogTrigger [types section](#dialog-types) for an explanation on each. */\n mobileType?:\n | 'modal'\n | 'tray'\n | 'fullscreen'\n | 'fullscreenTakeover'\n | 'panel'\n | 'popover';\n placement?: Placement;\n /**\n * Whether a popover type Dialog's arrow should be hidden.\n */\n hideArrow?: boolean;\n /** The ref of the element the Dialog should visually attach itself to. Defaults to the trigger button if not defined. */\n targetRef?: RefObject<HTMLElement | null>;\n /** Whether a modal type Dialog should be dismissable. */\n isDismissable?: boolean;\n /** Whether pressing the escape key to close the dialog should be disabled. */\n isKeyboardDismissDisabled?: boolean;\n /** The screen breakpoint for the mobile type */\n mobileViewport?: number;\n /** The style map for the overlay **/\n styles?: Styles;\n shouldCloseOnInteractOutside?: (element: Element) => boolean;\n onDismiss?: (action?: string) => void;\n isOpen?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n defaultOpen?: boolean;\n shouldFlip?: boolean;\n shouldUpdatePosition?: boolean;\n /** Minimum padding in pixels between the popover and viewport edges */\n containerPadding?: number;\n}\n\n/**\n * DialogTrigger serves as a wrapper around a Dialog and its associated trigger, linking the Dialog's\n * open state with the trigger's press state. Additionally, it allows you to customize the type and\n * positioning of the Dialog.\n */\nexport function DialogTrigger(props: CubeDialogTriggerProps) {\n let {\n children,\n type = 'modal',\n mobileType = type === 'popover' ? 'modal' : type,\n hideArrow,\n targetRef,\n onDismiss,\n isDismissable = true,\n isKeyboardDismissDisabled,\n styles,\n mobileViewport = 700,\n hideOnClose,\n shouldCloseOnInteractOutside,\n ...positionProps\n } = props;\n\n if (!Array.isArray(children) || children.length > 2) {\n throw new Error('DialogTrigger must have exactly 2 children');\n }\n // if a function is passed as the second child, it won't appear in toArray\n let [trigger, content] = children;\n\n // On small devices, show a modal or tray instead of a popover.\n let isMobile = useMediaQuery(`(max-width: ${mobileViewport}px)`);\n if (isMobile) {\n // handle cases where desktop popovers need a close button for the mobile modal view\n if (type !== 'modal' && mobileType === 'modal') {\n isDismissable = true;\n }\n\n type = mobileType;\n }\n\n let state = useOverlayTriggerState(props);\n\n if (typeof trigger === 'function') {\n trigger = trigger(state);\n }\n\n let wasOpen = useRef(false);\n let isExiting = useRef(false);\n let onExiting = () => (isExiting.current = true);\n let onExited = () => (isExiting.current = false);\n\n wasOpen.current = state.isOpen;\n\n useEffect(() => {\n return () => {\n if (\n (wasOpen.current || isExiting.current) &&\n type !== 'popover' &&\n type !== 'tray'\n ) {\n console.warn(\n 'CubeUIKit: A DialogTrigger unmounted while open. This is likely due to being placed within a trigger that unmounts or inside a conditional. Consider using a DialogContainer instead.',\n );\n }\n };\n }, []);\n\n function onClose(action) {\n if (isDismissable) {\n onDismiss && onDismiss(action);\n state.close();\n }\n }\n\n if (type === 'popover') {\n return (\n <PopoverTrigger\n {...positionProps}\n hideOnClose={hideOnClose}\n state={state}\n styles={styles}\n targetRef={targetRef}\n trigger={trigger}\n content={content}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n hideArrow={hideArrow}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n onClose={onClose}\n />\n );\n }\n\n let renderOverlay = () => {\n switch (type) {\n case 'panel':\n case 'fullscreen':\n case 'fullscreenTakeover':\n case 'modal':\n return (\n <Modal\n hideOnClose={hideOnClose}\n isOpen={state.isOpen}\n isDismissable={isDismissable}\n type={type}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n styles={styles}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n onClose={onClose}\n onExiting={onExiting}\n onExited={onExited}\n >\n {typeof content === 'function' ? content(state.close) : content}\n </Modal>\n );\n case 'tray':\n return (\n <Tray\n hideOnClose={hideOnClose}\n isOpen={state.isOpen}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n styles={styles}\n onClose={onClose}\n >\n {typeof content === 'function' ? content(state.close) : content}\n </Tray>\n );\n }\n };\n\n return (\n <DialogTriggerBase\n type={type}\n state={state}\n isDismissable={isDismissable}\n trigger={trigger}\n overlay={renderOverlay()}\n hideOnClose={hideOnClose}\n onClose={onClose}\n />\n );\n}\n\nfunction PopoverTrigger(allProps) {\n let {\n state,\n styles,\n targetRef,\n trigger,\n content,\n hideArrow,\n onClose,\n isKeyboardDismissDisabled,\n hideOnClose,\n shouldCloseOnInteractOutside,\n keepOpenOnScroll,\n ...props\n } = allProps;\n\n let triggerRef = useRef<HTMLButtonElement>(null);\n let overlayRef = useRef<HTMLDivElement>(null);\n\n let {\n overlayProps: popoverProps,\n placement,\n arrowProps,\n updatePosition,\n } = useOverlayPosition({\n targetRef: targetRef || triggerRef,\n overlayRef: overlayRef,\n placement: props.placement,\n containerPadding: props.containerPadding,\n offset: props.offset || 8,\n crossOffset: props.crossOffset,\n shouldFlip: props.shouldFlip,\n shouldUpdatePosition: props.shouldUpdatePosition,\n isOpen: state.isOpen,\n });\n\n let overlayTriggerState = state;\n\n if (keepOpenOnScroll) {\n overlayTriggerState = { ...state, close: updatePosition };\n }\n\n let { triggerProps, overlayProps } = useOverlayTrigger(\n { type: 'dialog' },\n overlayTriggerState,\n triggerRef,\n );\n\n let triggerPropsWithRef = {\n ...triggerProps,\n ref: targetRef ? undefined : triggerRef,\n };\n\n let overlay = (\n <Popover\n ref={overlayRef}\n styles={styles}\n hideOnClose={hideOnClose}\n isOpen={state.isOpen}\n style={popoverProps.style}\n placement={placement}\n arrowProps={arrowProps}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n hideArrow={hideArrow}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n onClose={onClose}\n >\n {typeof content === 'function' ? content(state.close) : content}\n </Popover>\n );\n\n return (\n <DialogTriggerBase\n type=\"popover\"\n state={state}\n triggerProps={triggerPropsWithRef}\n dialogProps={overlayProps}\n trigger={trigger}\n overlay={overlay}\n onClose={onClose}\n />\n );\n}\n\nfunction DialogTriggerBase(props: any) {\n const ref = useCombinedRefs<HTMLElement>(props.ref);\n const wasOpenRef = useRef(false);\n\n let {\n type,\n state,\n onClose,\n isDismissable,\n dialogProps = {},\n triggerProps = {},\n overlay,\n trigger,\n } = props;\n\n let context = {\n type,\n onClose,\n isDismissable,\n isOpen: state.isOpen,\n ...dialogProps,\n };\n\n // Restore focus manually when the dialog closes\n useEffect(() => {\n if (!state.isOpen && wasOpenRef.current) {\n wasOpenRef.current = false;\n ref.current?.focus();\n } else if (state.isOpen) {\n wasOpenRef.current = true;\n }\n }, [state.isOpen]);\n\n return (\n <Fragment>\n <PressResponder\n ref={ref}\n {...triggerProps}\n isPressed={\n state.isOpen &&\n type !== 'modal' &&\n type !== 'fullscreen' &&\n type !== 'fullscreenTakeover'\n }\n onPress={state.toggle}\n >\n {trigger}\n </PressResponder>\n <DialogContext.Provider value={context}>{overlay}</DialogContext.Provider>\n </Fragment>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,cAAc,OAA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AM,UAAU,WAAW,SAAS;AACvC,cAAW,UAAU;AACrB,OAAI,SAAS,OAAO;aACX,MAAM,OACf,YAAW,UAAU;IAEtB,CAAC,MAAM,OAAO,CAAC;AAElB,QACE,qBAAC,uBACC,oBAAC;EACM;EACL,GAAI;EACJ,WACE,MAAM,UACN,SAAS,WACT,SAAS,gBACT,SAAS;EAEX,SAAS,MAAM;YAEd;GACc,EACjB,oBAAC,cAAc;EAAS,OAAO;YAAU;GAAiC,IACjE"}
|
|
1
|
+
{"version":3,"file":"DialogTrigger.js","names":["Modal","Tray","Popover"],"sources":["../../../../src/components/overlays/Dialog/DialogTrigger.tsx"],"sourcesContent":["import { PressResponder } from '@react-aria/interactions';\nimport { useMediaQuery } from '@react-spectrum/utils';\nimport { Styles } from '@tenphi/tasty';\nimport {\n Fragment,\n ReactElement,\n RefObject,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport {\n OverlayTriggerProps,\n Placement,\n PositionProps,\n useOverlayPosition,\n useOverlayTrigger,\n} from 'react-aria';\nimport { OverlayTriggerState, useOverlayTriggerState } from 'react-stately';\n\nimport { generateRandomId } from '../../../utils/random';\nimport { useCombinedRefs, useLayoutEffect } from '../../../utils/react/index';\nimport { usePopoverSync } from '../../../utils/react/usePopoverSync';\nimport { Modal, Popover, Tray, WithCloseBehavior } from '../Modal';\n\nimport { DialogContext } from './context';\n\nexport type CubeDialogClose = (close: () => void) => ReactElement;\n\nexport interface CubeDialogTriggerProps\n extends OverlayTriggerProps,\n PositionProps,\n WithCloseBehavior {\n /** The Dialog and its trigger element. See the DialogTrigger [Content section](#content) for more information on what to provide as children. */\n children: [\n ReactElement | ((state: OverlayTriggerState) => ReactElement),\n CubeDialogClose | ReactElement,\n ];\n /**\n * The type of Dialog that should be rendered. See the DialogTrigger [types section](#dialog-types) for an explanation on each.\n * @default 'modal'\n */\n type?:\n | 'modal'\n | 'popover'\n | 'tray'\n | 'fullscreen'\n | 'fullscreenTakeover'\n | 'panel';\n /** The type of Dialog that should be rendered when on a mobile device. See DialogTrigger [types section](#dialog-types) for an explanation on each. */\n mobileType?:\n | 'modal'\n | 'tray'\n | 'fullscreen'\n | 'fullscreenTakeover'\n | 'panel'\n | 'popover';\n placement?: Placement;\n /**\n * Whether a popover type Dialog's arrow should be hidden.\n */\n hideArrow?: boolean;\n /** The ref of the element the Dialog should visually attach itself to. Defaults to the trigger button if not defined. */\n targetRef?: RefObject<HTMLElement | null>;\n /** Whether a modal type Dialog should be dismissable. */\n isDismissable?: boolean;\n /** Whether pressing the escape key to close the dialog should be disabled. */\n isKeyboardDismissDisabled?: boolean;\n /** The screen breakpoint for the mobile type */\n mobileViewport?: number;\n /** The style map for the overlay **/\n styles?: Styles;\n shouldCloseOnInteractOutside?: (element: Element) => boolean;\n onDismiss?: (action?: string) => void;\n isOpen?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n defaultOpen?: boolean;\n shouldFlip?: boolean;\n shouldUpdatePosition?: boolean;\n /** Minimum padding in pixels between the popover and viewport edges */\n containerPadding?: number;\n}\n\n/**\n * DialogTrigger serves as a wrapper around a Dialog and its associated trigger, linking the Dialog's\n * open state with the trigger's press state. Additionally, it allows you to customize the type and\n * positioning of the Dialog.\n */\nexport function DialogTrigger(props: CubeDialogTriggerProps) {\n let {\n children,\n type = 'modal',\n mobileType = type === 'popover' ? 'modal' : type,\n hideArrow,\n targetRef,\n onDismiss,\n isDismissable = true,\n isKeyboardDismissDisabled,\n styles,\n mobileViewport = 700,\n hideOnClose,\n shouldCloseOnInteractOutside,\n ...positionProps\n } = props;\n\n if (!Array.isArray(children) || children.length > 2) {\n throw new Error('DialogTrigger must have exactly 2 children');\n }\n // if a function is passed as the second child, it won't appear in toArray\n let [trigger, content] = children;\n\n // On small devices, show a modal or tray instead of a popover.\n let isMobile = useMediaQuery(`(max-width: ${mobileViewport}px)`);\n if (isMobile) {\n // handle cases where desktop popovers need a close button for the mobile modal view\n if (type !== 'modal' && mobileType === 'modal') {\n isDismissable = true;\n }\n\n type = mobileType;\n }\n\n let state = useOverlayTriggerState(props);\n\n if (typeof trigger === 'function') {\n trigger = trigger(state);\n }\n\n let wasOpen = useRef(false);\n let isExiting = useRef(false);\n let onExiting = () => (isExiting.current = true);\n let onExited = () => (isExiting.current = false);\n\n wasOpen.current = state.isOpen;\n\n // Shared identity + refs for `usePopoverSync`. Allocating here (rather than\n // inside the branch-specific sub-trees) keeps a single sync registration for\n // the lifetime of the trigger, even when `type` flips between popover and\n // modal at the mobile breakpoint. The refs are then threaded into the\n // appropriate branch so existing positioning / useOverlayTrigger hooks keep\n // their original ref targets and `usePopoverSync`'s `contains()` check has a\n // real DOM node to query.\n const dialogSyncId = useMemo(() => generateRandomId(), []);\n const syncTriggerRef = useRef<HTMLElement | null>(null);\n const syncOverlayRef = useRef<HTMLElement | null>(null);\n\n // Only popover-type Dialogs participate in the \"press inside dismisses\n // me\" behaviour: modals/trays/fullscreen Dialogs are persistent workspaces\n // and buttons inside them should NOT auto-close them.\n usePopoverSync({\n menuId: dialogSyncId,\n isOpen: state.isOpen,\n onClose: () => state.close(),\n triggerRef: syncTriggerRef,\n containerRef: syncOverlayRef,\n dismissOnInnerButtonPress: type === 'popover',\n });\n\n useEffect(() => {\n return () => {\n if (\n (wasOpen.current || isExiting.current) &&\n type !== 'popover' &&\n type !== 'tray'\n ) {\n console.warn(\n 'CubeUIKit: A DialogTrigger unmounted while open. This is likely due to being placed within a trigger that unmounts or inside a conditional. Consider using a DialogContainer instead.',\n );\n }\n };\n }, []);\n\n function onClose(action) {\n if (isDismissable) {\n onDismiss && onDismiss(action);\n state.close();\n }\n }\n\n if (type === 'popover') {\n return (\n <PopoverTrigger\n {...positionProps}\n hideOnClose={hideOnClose}\n state={state}\n styles={styles}\n targetRef={targetRef}\n trigger={trigger}\n content={content}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n hideArrow={hideArrow}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n syncTriggerRef={syncTriggerRef}\n syncOverlayRef={syncOverlayRef}\n triggerType={type}\n onClose={onClose}\n />\n );\n }\n\n let renderOverlay = () => {\n switch (type) {\n case 'panel':\n case 'fullscreen':\n case 'fullscreenTakeover':\n case 'modal':\n return (\n <Modal\n ref={syncOverlayRef}\n hideOnClose={hideOnClose}\n isOpen={state.isOpen}\n isDismissable={isDismissable}\n type={type}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n styles={styles}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n onClose={onClose}\n onExiting={onExiting}\n onExited={onExited}\n >\n {typeof content === 'function' ? content(state.close) : content}\n </Modal>\n );\n case 'tray':\n return (\n <Tray\n ref={syncOverlayRef}\n hideOnClose={hideOnClose}\n isOpen={state.isOpen}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n styles={styles}\n onClose={onClose}\n >\n {typeof content === 'function' ? content(state.close) : content}\n </Tray>\n );\n }\n };\n\n return (\n <DialogTriggerBase\n type={type}\n state={state}\n isDismissable={isDismissable}\n trigger={trigger}\n overlay={renderOverlay()}\n hideOnClose={hideOnClose}\n syncTriggerRef={syncTriggerRef}\n onClose={onClose}\n />\n );\n}\n\nfunction PopoverTrigger(allProps) {\n let {\n state,\n styles,\n targetRef,\n trigger,\n content,\n hideArrow,\n onClose,\n isKeyboardDismissDisabled,\n hideOnClose,\n shouldCloseOnInteractOutside,\n keepOpenOnScroll,\n syncTriggerRef,\n syncOverlayRef,\n triggerType,\n ...props\n } = allProps;\n\n let triggerRef = useRef<HTMLButtonElement>(null);\n let overlayRef = useRef<HTMLDivElement>(null);\n\n // Mirror the trigger/overlay DOM nodes into the parent-owned sync refs.\n //\n // We deliberately do NOT use `useCombinedRefs` here: that hook returns a\n // brand new internal ref and propagates to the passed refs via a regular\n // `useEffect` (post-commit). `useOverlayPosition` below reads\n // `triggerRef.current` in its own layout effect during the SAME commit, so\n // if `triggerRef` only receives the DOM node via a delayed effect, the\n // first measurement sees `null` and the popover positions at the document\n // origin until something forces a re-measure.\n //\n // Keeping `triggerRef`/`overlayRef` as the direct React refs preserves\n // synchronous assignment for `useOverlayPosition`. The sync refs are only\n // ever read inside `popover:open` handlers, which fire via setTimeout(0),\n // so a layout-effect mirror is more than fast enough.\n useLayoutEffect(() => {\n if (syncTriggerRef) {\n syncTriggerRef.current = targetRef?.current ?? triggerRef.current ?? null;\n }\n if (syncOverlayRef) {\n syncOverlayRef.current = overlayRef.current ?? null;\n }\n });\n\n let {\n overlayProps: popoverProps,\n placement,\n arrowProps,\n updatePosition,\n } = useOverlayPosition({\n targetRef: targetRef || triggerRef,\n overlayRef: overlayRef,\n placement: props.placement,\n containerPadding: props.containerPadding,\n offset: props.offset || 8,\n crossOffset: props.crossOffset,\n shouldFlip: props.shouldFlip,\n shouldUpdatePosition: props.shouldUpdatePosition,\n isOpen: state.isOpen,\n });\n\n let overlayTriggerState = state;\n\n if (keepOpenOnScroll) {\n overlayTriggerState = { ...state, close: updatePosition };\n }\n\n let { triggerProps, overlayProps } = useOverlayTrigger(\n { type: 'dialog' },\n overlayTriggerState,\n triggerRef,\n );\n\n let triggerPropsWithRef = {\n ...triggerProps,\n ref: targetRef ? undefined : triggerRef,\n };\n\n let overlay = (\n <Popover\n ref={overlayRef}\n styles={styles}\n hideOnClose={hideOnClose}\n isOpen={state.isOpen}\n style={popoverProps.style}\n placement={placement}\n arrowProps={arrowProps}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n hideArrow={hideArrow}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}\n onClose={onClose}\n >\n {typeof content === 'function' ? content(state.close) : content}\n </Popover>\n );\n\n return (\n <DialogTriggerBase\n type=\"popover\"\n state={state}\n triggerProps={triggerPropsWithRef}\n dialogProps={overlayProps}\n trigger={trigger}\n overlay={overlay}\n onClose={onClose}\n />\n );\n}\n\nfunction DialogTriggerBase(props: any) {\n const ref = useCombinedRefs<HTMLElement>(props.ref);\n const wasOpenRef = useRef(false);\n\n // Mirror the press-responder DOM node into the parent's sync trigger ref.\n // Done via `useLayoutEffect` rather than threading through `useCombinedRefs`\n // for consistency with `PopoverTrigger` (see comment there) — keeps the\n // sync-ref population deterministic regardless of branch.\n useLayoutEffect(() => {\n if (props.syncTriggerRef) {\n props.syncTriggerRef.current = ref.current ?? null;\n }\n });\n\n let {\n type,\n state,\n onClose,\n isDismissable,\n dialogProps = {},\n triggerProps = {},\n overlay,\n trigger,\n } = props;\n\n let context = {\n type,\n onClose,\n isDismissable,\n isOpen: state.isOpen,\n ...dialogProps,\n };\n\n // Restore focus manually when the dialog closes\n useEffect(() => {\n if (!state.isOpen && wasOpenRef.current) {\n wasOpenRef.current = false;\n ref.current?.focus();\n } else if (state.isOpen) {\n wasOpenRef.current = true;\n }\n }, [state.isOpen]);\n\n // Mark popover-type DialogTrigger children with `data-popover-trigger` so\n // `Button` / `ItemButton`'s default dismiss-on-press behaviour treats them\n // as popover triggers (skips the dismiss). Modal/tray/fullscreen children\n // intentionally stay UNMARKED — when a modal-type DialogTrigger lives\n // inside a popover footer, pressing it should dismiss the parent popover\n // (matching the \"modal takes over\" native UX).\n const triggerExtraProps =\n type === 'popover' ? { 'data-popover-trigger': '' } : {};\n\n return (\n <Fragment>\n <PressResponder\n ref={ref}\n {...triggerProps}\n {...triggerExtraProps}\n isPressed={\n state.isOpen &&\n type !== 'modal' &&\n type !== 'fullscreen' &&\n type !== 'fullscreenTakeover'\n }\n onPress={state.toggle}\n >\n {trigger}\n </PressResponder>\n <DialogContext.Provider value={context}>{overlay}</DialogContext.Provider>\n </Fragment>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwFA,SAAgB,cAAc,OAA+B;CAC3D,IAAI,EACF,UACA,OAAO,SACP,aAAa,SAAS,YAAY,UAAU,MAC5C,WACA,WACA,WACA,gBAAgB,MAChB,2BACA,QACA,iBAAiB,KACjB,aACA,8BACA,GAAG,kBACD;AAEJ,KAAI,CAAC,MAAM,QAAQ,SAAS,IAAI,SAAS,SAAS,EAChD,OAAM,IAAI,MAA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,aAAa,OAAO,MAAM;AAMhC,yBAAsB;AACpB,MAAI,MAAM,eACR,OAAM,eAAe,UAAU,IAAI,WAAW;GAEhD;CAEF,IAAI,EACF,MACA,OACA,SACA,eACA,cAAc,EAAE,EAChB,eAAe,EAAE,EACjB,SACA,YACE;CAEJ,IAAI,UAAU;EACZ;EACA;EACA;EACA,QAAQ,MAAM;EACd,GAAG;EACJ;AAGD,iBAAgB;AACd,MAAI,CAAC,MAAM,UAAU,WAAW,SAAS;AACvC,cAAW,UAAU;AACrB,OAAI,SAAS,OAAO;aACX,MAAM,OACf,YAAW,UAAU;IAEtB,CAAC,MAAM,OAAO,CAAC;CAQlB,MAAM,oBACJ,SAAS,YAAY,EAAE,wBAAwB,IAAI,GAAG,EAAE;AAE1D,QACE,qBAAC,uBACC,oBAAC;EACM;EACL,GAAI;EACJ,GAAI;EACJ,WACE,MAAM,UACN,SAAS,WACT,SAAS,gBACT,SAAS;EAEX,SAAS,MAAM;YAEd;GACc,EACjB,oBAAC,cAAc;EAAS,OAAO;YAAU;GAAiC,IACjE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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";
|
|
@@ -6,7 +6,7 @@ import { tasty } from "@tenphi/tasty";
|
|
|
6
6
|
import { forwardRef } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { useModal, useOverlay, usePreventScroll } from "react-aria";
|
|
9
|
-
import {
|
|
9
|
+
import { useObjectRef } from "@react-aria/utils";
|
|
10
10
|
|
|
11
11
|
//#region src/components/overlays/Modal/Modal.tsx
|
|
12
12
|
const OVERLAY_WRAPPER_STYLES = {
|
|
@@ -65,7 +65,7 @@ const ModalElement = tasty({ styles: {
|
|
|
65
65
|
} });
|
|
66
66
|
function Modal(props, ref) {
|
|
67
67
|
let { qa, children, onClose, type, styles, ...otherProps } = props;
|
|
68
|
-
let domRef =
|
|
68
|
+
let domRef = useObjectRef(ref);
|
|
69
69
|
let { overlayProps, underlayProps } = useOverlay({ ...props }, domRef);
|
|
70
70
|
return /* @__PURE__ */ jsxs(_Overlay, {
|
|
71
71
|
...otherProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","names":["Overlay","Underlay","mergeProps"],"sources":["../../../../src/components/overlays/Modal/Modal.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Modal.js","names":["Overlay","Underlay","mergeProps"],"sources":["../../../../src/components/overlays/Modal/Modal.tsx"],"sourcesContent":["import { useObjectRef } from '@react-aria/utils';\nimport { BaseProps, Props, Styles, tasty } from '@tenphi/tasty';\nimport { forwardRef, ReactNode } from 'react';\nimport { useModal, useOverlay, usePreventScroll } from 'react-aria';\n\nimport { mergeProps } from '../../../utils/react';\n\nimport { Overlay } from './Overlay';\nimport { ModalProps, TransitionState, WithCloseBehavior } from './types';\nimport { Underlay } from './Underlay';\n\nexport const OVERLAY_WRAPPER_STYLES: Styles = {\n position: 'fixed',\n display: 'grid',\n left: 0,\n top: 0,\n placeItems: {\n '': 'center',\n 'type=fullscreen': 'center',\n 'type=fullscreenTakeover | type=panel': 'stretch',\n },\n boxSizing: 'border-box',\n width: '100vw',\n height: '100dvh',\n pointerEvents: 'none',\n zIndex: 10,\n transition: {\n '': 'visibility .5s steps(2, start)',\n open: 'visibility 0s linear',\n },\n};\n\nconst ModalWrapperElement = tasty({\n qa: 'ModalWrapper',\n styles: OVERLAY_WRAPPER_STYLES,\n});\n\nconst ModalElement = tasty({\n styles: {\n display: {\n '': 'none',\n 'enter | entered': 'grid',\n exit: 'grid',\n unmounted: 'none',\n },\n zIndex: 10,\n height: {\n '': 'max 90dvh',\n 'type=fullscreenTakeover | type=panel': '100dvh 100dvh',\n 'type=fullscreen': '(100dvh - 8x) (100dvh - 8x)',\n 'type=panel': 'auto',\n },\n width: {\n '': '$min-dialog-size (100dvw - 8x)',\n 'type=panel': 'auto',\n },\n pointerEvents: 'none',\n transition: 'opacity .25s linear, transform .25s ease-in-out',\n transform: {\n '': 'initial',\n 'type=modal & !open': 'translate(0, -3x) scale(1, 1)',\n '(type^=fullscreen | type=panel) & !open':\n 'translate(0, 0) scale(1.02, 1.02)',\n },\n opacity: {\n '': 0,\n open: 0.9999,\n },\n },\n});\n\nexport interface CubeModalProps\n extends Omit<ModalProps, 'container' | 'type' | 'nodeRef'>,\n WithCloseBehavior {\n container?: HTMLElement;\n qa?: BaseProps['qa'];\n onClose?: (action?: string) => void;\n type?: 'modal' | 'fullscreen' | 'fullscreenTakeover' | 'panel';\n styles?: Styles;\n shouldCloseOnInteractOutside?: (element: Element) => boolean;\n}\n\nfunction Modal(props: CubeModalProps, ref) {\n let { qa, children, onClose, type, styles, ...otherProps } = props;\n let domRef = useObjectRef(ref);\n\n let { overlayProps, underlayProps } = useOverlay({ ...props }, domRef);\n\n return (\n <Overlay {...otherProps}>\n {type !== 'fullscreenTakeover' && type !== 'panel' && (\n <Underlay {...underlayProps} />\n )}\n <ModalWrapper\n ref={domRef}\n qa={qa}\n type={type}\n overlayProps={overlayProps}\n styles={styles}\n onClose={onClose}\n >\n {children}\n </ModalWrapper>\n </Overlay>\n );\n}\n\ninterface ModalWrapperProps extends TransitionState {\n children?: ReactNode;\n qa?: BaseProps['qa'];\n isOpen?: boolean;\n type?: 'modal' | 'fullscreen' | 'fullscreenTakeover' | 'panel';\n placement?: 'top' | 'bottom';\n styles?: Styles;\n overlayProps?: Props;\n onClose?: () => void;\n}\n\nlet ModalWrapper = forwardRef(function ModalWrapper(\n props: ModalWrapperProps,\n ref,\n) {\n let {\n qa,\n children,\n isOpen,\n type,\n placement,\n styles,\n overlayProps,\n transitionState,\n ...otherProps\n } = props;\n\n usePreventScroll({ isDisabled: transitionState !== 'entered' });\n\n let { modalProps } = useModal({ isDisabled: transitionState !== 'entered' });\n\n return (\n <ModalWrapperElement data-type={type} data-placement={placement}>\n <ModalElement\n qa={qa || 'Modal'}\n styles={styles}\n mods={{\n open: isOpen,\n enter: transitionState === 'enter',\n exit: transitionState === 'exit',\n unmounted: transitionState === 'unmounted',\n entered: transitionState === 'entered',\n }}\n data-type={type}\n data-placement={placement}\n {...mergeProps(otherProps, overlayProps, modalProps)}\n ref={ref}\n >\n {children}\n </ModalElement>\n </ModalWrapperElement>\n );\n});\n\nlet _Modal = forwardRef(Modal);\n\n_Modal.displayName = 'Modal';\n\nexport { _Modal as Modal };\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,yBAAiC;CAC5C,UAAU;CACV,SAAS;CACT,MAAM;CACN,KAAK;CACL,YAAY;EACV,IAAI;EACJ,mBAAmB;EACnB,wCAAwC;EACzC;CACD,WAAW;CACX,OAAO;CACP,QAAQ;CACR,eAAe;CACf,QAAQ;CACR,YAAY;EACV,IAAI;EACJ,MAAM;EACP;CACF;AAED,MAAM,sBAAsB,MAAM;CAChC,IAAI;CACJ,QAAQ;CACT,CAAC;AAEF,MAAM,eAAe,MAAM,EACzB,QAAQ;CACN,SAAS;EACP,IAAI;EACJ,mBAAmB;EACnB,MAAM;EACN,WAAW;EACZ;CACD,QAAQ;CACR,QAAQ;EACN,IAAI;EACJ,wCAAwC;EACxC,mBAAmB;EACnB,cAAc;EACf;CACD,OAAO;EACL,IAAI;EACJ,cAAc;EACf;CACD,eAAe;CACf,YAAY;CACZ,WAAW;EACT,IAAI;EACJ,sBAAsB;EACtB,2CACE;EACH;CACD,SAAS;EACP,IAAI;EACJ,MAAM;EACP;CACF,EACF,CAAC;AAaF,SAAS,MAAM,OAAuB,KAAK;CACzC,IAAI,EAAE,IAAI,UAAU,SAAS,MAAM,QAAQ,GAAG,eAAe;CAC7D,IAAI,SAAS,aAAa,IAAI;CAE9B,IAAI,EAAE,cAAc,kBAAkB,WAAW,EAAE,GAAG,OAAO,EAAE,OAAO;AAEtE,QACE,qBAACA;EAAQ,GAAI;aACV,SAAS,wBAAwB,SAAS,WACzC,oBAACC,aAAS,GAAI,gBAAiB,EAEjC,oBAAC;GACC,KAAK;GACD;GACE;GACQ;GACN;GACC;GAER;IACY;GACP;;AAed,IAAI,eAAe,WAAW,SAAS,aACrC,OACA,KACA;CACA,IAAI,EACF,IACA,UACA,QACA,MACA,WACA,QACA,cACA,iBACA,GAAG,eACD;AAEJ,kBAAiB,EAAE,YAAY,oBAAoB,WAAW,CAAC;CAE/D,IAAI,EAAE,eAAe,SAAS,EAAE,YAAY,oBAAoB,WAAW,CAAC;AAE5E,QACE,oBAAC;EAAoB,aAAW;EAAM,kBAAgB;YACpD,oBAAC;GACC,IAAI,MAAM;GACF;GACR,MAAM;IACJ,MAAM;IACN,OAAO,oBAAoB;IAC3B,MAAM,oBAAoB;IAC1B,WAAW,oBAAoB;IAC/B,SAAS,oBAAoB;IAC9B;GACD,aAAW;GACX,kBAAgB;GAChB,GAAIC,aAAW,YAAY,cAAc,WAAW;GAC/C;GAEJ;IACY;GACK;EAExB;AAEF,IAAI,SAAS,WAAW,MAAM;AAE9B,OAAO,cAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | Cube Dev Team */
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/overlays/Modal/OpenTransitionContext.tsx
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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.0.0-canary-
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-5a4d7bc | 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";
|
|
@@ -7,7 +7,7 @@ import { tasty } from "@tenphi/tasty";
|
|
|
7
7
|
import { forwardRef } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { useModal, useOverlay, usePreventScroll } from "react-aria";
|
|
10
|
-
import {
|
|
10
|
+
import { useObjectRef } from "@react-aria/utils";
|
|
11
11
|
|
|
12
12
|
//#region src/components/overlays/Modal/Tray.tsx
|
|
13
13
|
const TrayWrapperElement = tasty({
|
|
@@ -37,7 +37,7 @@ const TrayElement = tasty({ styles: {
|
|
|
37
37
|
} });
|
|
38
38
|
function Tray(props, ref) {
|
|
39
39
|
let { qa, children, onClose, isFixedHeight, isNonModal, styles, shouldCloseOnInteractOutside, ...otherProps } = props;
|
|
40
|
-
let domRef =
|
|
40
|
+
let domRef = useObjectRef(ref);
|
|
41
41
|
let { overlayProps, underlayProps } = useOverlay({
|
|
42
42
|
...props,
|
|
43
43
|
isDismissable: true,
|