@cube-dev/ui-kit 0.0.0-canary-26f6469 → 0.0.0-canary-434a15e
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 +12 -0
- package/dist/_internal/hooks/use-debounced-value.js +1 -1
- package/dist/_internal/hooks/use-deprecation-warning.js +1 -1
- package/dist/_internal/hooks/use-event.js +1 -1
- package/dist/_internal/hooks/use-is-first-render.js +1 -1
- package/dist/_internal/hooks/use-sync-ref.js +1 -1
- package/dist/_internal/hooks/use-timer/timer.js +1 -1
- package/dist/_internal/hooks/use-timer/use-timer.js +1 -1
- package/dist/_internal/hooks/use-warn.js +1 -1
- package/dist/components/Block.js +1 -1
- package/dist/components/CollectionItem.js +1 -1
- package/dist/components/GlobalStyles.js +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/Button.d.ts +1 -0
- package/dist/components/actions/Button/Button.js +1 -1
- package/dist/components/actions/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/actions/ButtonSplit/ButtonSplit.js +1 -1
- package/dist/components/actions/ButtonSplit/context.js +1 -1
- package/dist/components/actions/CommandMenu/CommandMenu.js +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 +1 -1
- package/dist/components/actions/Link/Link.js +1 -1
- package/dist/components/actions/Menu/Menu.js +1 -1
- package/dist/components/actions/Menu/MenuItem.js +1 -1
- package/dist/components/actions/Menu/MenuSection.js +1 -1
- package/dist/components/actions/Menu/MenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubMenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubmenuTriggerContext.js +1 -1
- package/dist/components/actions/Menu/context.js +1 -1
- package/dist/components/actions/Menu/styled.js +1 -1
- package/dist/components/actions/index.js +1 -1
- package/dist/components/actions/use-action.js +1 -1
- package/dist/components/actions/use-anchored-menu.js +1 -1
- package/dist/components/actions/use-context-menu.js +1 -1
- package/dist/components/content/ActiveZone/ActiveZone.js +1 -1
- package/dist/components/content/Alert/Alert.js +1 -1
- package/dist/components/content/Alert/use-alert.js +1 -1
- package/dist/components/content/Avatar/Avatar.js +1 -1
- package/dist/components/content/Badge/Badge.js +1 -1
- package/dist/components/content/Card/Card.js +1 -1
- package/dist/components/content/Content.js +1 -1
- package/dist/components/content/CopyPasteBlock/CopyPasteBlock.js +1 -1
- package/dist/components/content/CopySnippet/CopySnippet.js +1 -1
- package/dist/components/content/Disclosure/Disclosure.js +1 -1
- package/dist/components/content/Divider.js +1 -1
- package/dist/components/content/Footer.js +1 -1
- package/dist/components/content/Header.js +1 -1
- package/dist/components/content/HotKeys/HotKeys.js +1 -1
- package/dist/components/content/InfoBadge/InfoBadge.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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/content/Layout/LayoutPanel.js +1 -1
- package/dist/components/content/Layout/LayoutPanelHeader.js +2 -2
- 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 +2 -2
- 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 +44 -14
- package/dist/components/content/use-auto-tooltip.js.map +1 -1
- package/dist/components/data/DataTable/DataTable.js +1 -1
- package/dist/components/data/ItemTable/ItemTable.js +1 -1
- package/dist/components/data/ItemTable/ItemTableBulkBar.js +1 -1
- package/dist/components/data/ItemTable/ItemTableDragPreview.js +1 -1
- package/dist/components/data/ItemTable/ItemTableFooter.js +1 -1
- package/dist/components/data/ItemTable/ItemTableToolbar.js +1 -1
- package/dist/components/data/TableBase/ColumnResizer.js +1 -1
- package/dist/components/data/TableBase/RowCollection.js +1 -1
- package/dist/components/data/TableBase/TableHeaderCell.js +1 -1
- package/dist/components/data/TableBase/TableRow.js +1 -1
- package/dist/components/data/TableBase/TableView.js +2 -2
- package/dist/components/data/TableBase/column-menu.js +1 -1
- package/dist/components/data/TableBase/column-tint.js +1 -1
- package/dist/components/data/TableBase/row-menu.js +1 -1
- package/dist/components/data/TableBase/styled.d.ts +2 -1
- package/dist/components/data/TableBase/styled.js +1 -1
- package/dist/components/data/TableBase/table-tree.js +1 -1
- package/dist/components/data/TableBase/types.js +1 -1
- package/dist/components/data/TableBase/use-cell-selection.d.ts +1 -0
- package/dist/components/data/TableBase/use-cell-selection.js +0 -0
- package/dist/components/data/TableBase/use-column-order.js +1 -1
- package/dist/components/data/TableBase/use-container-width.js +1 -1
- package/dist/components/data/TableBase/use-row-move-animation.js +1 -1
- package/dist/components/data/TableBase/use-scrollability.js +1 -1
- package/dist/components/data/TableBase/use-table-columns.js +1 -1
- package/dist/components/data/TableBase/use-table-search.js +1 -1
- package/dist/components/data/TableBase/use-table-selection.js +1 -1
- package/dist/components/data/TableBase/use-table-sort.js +1 -1
- package/dist/components/data/TableBase/use-table-sorts.js +1 -1
- package/dist/components/data/TableBase/use-table-storage.js +1 -1
- package/dist/components/data/TableBase/use-table-tree-state.js +1 -1
- package/dist/components/fields/Checkbox/Checkbox.js +2 -2
- package/dist/components/fields/Checkbox/CheckboxGroup.js +2 -2
- package/dist/components/fields/Checkbox/context.js +1 -1
- package/dist/components/fields/ColorInput/ColorInput.js +2 -2
- package/dist/components/fields/ColorPicker/ColorPicker.js +2 -2
- package/dist/components/fields/ColorSwatch/ColorSwatch.js +1 -1
- package/dist/components/fields/ColorSwatchGroup/ColorSwatchGroup.js +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +1 -1
- package/dist/components/fields/CommandTextArea/CommandTextArea.js +2 -2
- package/dist/components/fields/CommandTextArea/caretPosition.js +1 -1
- package/dist/components/fields/CommandTextArea/useCaretAnchor.js +1 -1
- package/dist/components/fields/DatePicker/DateInput.js +1 -1
- package/dist/components/fields/DatePicker/DateInputBase.js +1 -1
- package/dist/components/fields/DatePicker/DatePicker.js +2 -2
- 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 +2 -2
- package/dist/components/fields/DatePicker/DateRangeSeparatedPicker.js +2 -2
- package/dist/components/fields/DatePicker/MonthPicker.js +1 -1
- package/dist/components/fields/DatePicker/PeriodPicker.js +2 -2
- package/dist/components/fields/DatePicker/QuarterPicker.js +1 -1
- package/dist/components/fields/DatePicker/TimeInput.js +1 -1
- package/dist/components/fields/DatePicker/WeekPicker.js +1 -1
- package/dist/components/fields/DatePicker/YearPicker.js +1 -1
- package/dist/components/fields/DatePicker/parseDate.js +1 -1
- package/dist/components/fields/DatePicker/period.js +1 -1
- package/dist/components/fields/DatePicker/props.js +1 -1
- package/dist/components/fields/DatePicker/utils.js +1 -1
- package/dist/components/fields/FileInput/FileInput.js +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.js +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.js +3 -3
- 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 +4 -4
- package/dist/components/fields/ListBoxPopover/ListBoxPopover.js +1 -1
- package/dist/components/fields/ListBoxPopover/index.d.ts +1 -0
- package/dist/components/fields/ListBoxPopover/listNavigation.js +1 -1
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.d.ts +2 -0
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.js +1 -1
- package/dist/components/fields/NumberInput/NumberInput.js +2 -2
- package/dist/components/fields/NumberInput/StepButton.js +1 -1
- package/dist/components/fields/PasswordInput/PasswordInput.js +2 -2
- package/dist/components/fields/Picker/Picker.js +3 -3
- package/dist/components/fields/RadioGroup/Radio.js +2 -2
- package/dist/components/fields/RadioGroup/RadioGroup.js +2 -2
- package/dist/components/fields/RadioGroup/context.js +1 -1
- package/dist/components/fields/SearchComboBox/SearchComboBox.js +1 -1
- package/dist/components/fields/SearchInput/SearchInput.js +2 -2
- package/dist/components/fields/Select/Select.js +1 -1
- package/dist/components/fields/Slider/Gradation.js +1 -1
- package/dist/components/fields/Slider/HueSlider.js +1 -1
- package/dist/components/fields/Slider/RangeSlider.js +1 -1
- package/dist/components/fields/Slider/Slider.js +1 -1
- package/dist/components/fields/Slider/SliderBase.js +1 -1
- package/dist/components/fields/Slider/SliderThumb.js +1 -1
- package/dist/components/fields/Slider/SliderTrack.js +1 -1
- package/dist/components/fields/Slider/elements.js +1 -1
- package/dist/components/fields/Slider/index.js +1 -1
- package/dist/components/fields/Switch/Switch.js +2 -2
- package/dist/components/fields/TextArea/TextArea.js +2 -2
- package/dist/components/fields/TextInput/TextInput.js +2 -2
- package/dist/components/fields/TextInput/TextInputBase.js +1 -1
- package/dist/components/fields/TextInput/useAutoSizeTextArea.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/fields/color/ColorPanel.js +1 -1
- package/dist/components/fields/color/channels.js +1 -1
- package/dist/components/fields/color/color.js +1 -1
- package/dist/components/fields/color/context.js +1 -1
- package/dist/components/form/FieldWrapper/FieldWrapper.js +1 -1
- package/dist/components/form/Form/Field.js +1 -1
- package/dist/components/form/Form/Form.js +1 -1
- package/dist/components/form/Form/ResetButton/ResetButton.js +1 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.js +1 -1
- package/dist/components/form/Form/SubmitError.js +1 -1
- package/dist/components/form/Form/index.js +1 -1
- package/dist/components/form/Form/use-field/use-field-props.js +1 -1
- package/dist/components/form/Form/use-field/use-field.js +1 -1
- package/dist/components/form/Form/use-form.js +1 -1
- package/dist/components/form/Form/validation.js +1 -1
- package/dist/components/form/Label.js +1 -1
- package/dist/components/form/validation/ValidationIndicator.js +1 -1
- package/dist/components/form/validation/resolve-validation-props.js +1 -1
- package/dist/components/form/validation/use-validation-props.js +1 -1
- package/dist/components/form/wrapper.js +1 -1
- package/dist/components/helpers/DisplayTransition/DisplayTransition.js +1 -1
- package/dist/components/helpers/IconSwitch/IconSwitch.js +1 -1
- package/dist/components/layout/Board/Board.js +1 -1
- package/dist/components/layout/Board/BoardProvider.js +1 -1
- package/dist/components/layout/Board/BoardResponsive.js +1 -1
- package/dist/components/layout/Board/Widget.js +1 -1
- package/dist/components/layout/Board/WidgetHost.js +1 -1
- package/dist/components/layout/Board/board-context.js +1 -1
- package/dist/components/layout/Board/board-store.js +1 -1
- package/dist/components/layout/Board/grid-core/calculate.js +1 -1
- package/dist/components/layout/Board/grid-core/collision-modes.js +1 -1
- package/dist/components/layout/Board/grid-core/collision.js +1 -1
- package/dist/components/layout/Board/grid-core/compactors.js +1 -1
- package/dist/components/layout/Board/grid-core/constraints.js +1 -1
- package/dist/components/layout/Board/grid-core/group-move.js +1 -1
- package/dist/components/layout/Board/grid-core/layout.js +1 -1
- package/dist/components/layout/Board/grid-core/placement.js +1 -1
- package/dist/components/layout/Board/grid-core/sort.js +1 -1
- package/dist/components/layout/Board/index.js +1 -1
- package/dist/components/layout/Board/responsive-utils.js +1 -1
- package/dist/components/layout/Board/use-board-layout.js +1 -1
- package/dist/components/layout/Board/use-board-registry.js +1 -1
- package/dist/components/layout/Board/use-board-select-modifier-key.js +1 -1
- package/dist/components/layout/Board/use-board-selection.js +1 -1
- package/dist/components/layout/Dashboard/Dashboard.d.ts +199 -0
- package/dist/components/layout/Dashboard/Dashboard.js +2049 -0
- package/dist/components/layout/Dashboard/Dashboard.js.map +1 -0
- package/dist/components/layout/Dashboard/index.d.ts +2 -0
- package/dist/components/layout/Flex.js +1 -1
- package/dist/components/layout/Flow.js +1 -1
- package/dist/components/layout/Grid.js +1 -1
- package/dist/components/layout/Panel.js +1 -1
- package/dist/components/layout/Prefix.js +1 -1
- package/dist/components/layout/ResizablePanel.js +1 -1
- package/dist/components/layout/Space.js +1 -1
- package/dist/components/layout/Suffix.js +1 -1
- package/dist/components/navigation/Pagination/Pagination.js +1 -1
- package/dist/components/navigation/Pagination/use-pagination.js +1 -1
- package/dist/components/navigation/Tabs/DraggableTabList.js +1 -1
- package/dist/components/navigation/Tabs/TabButton.js +3 -3
- 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 +2 -2
- package/dist/components/navigation/Tabs/TabsAction.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/popover-placement.js +1 -1
- package/dist/components/navigation/Tabs/styled.js +1 -1
- package/dist/components/navigation/Tabs/types.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-editing.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-indicator.js +1 -1
- package/dist/components/organisms/StatsCard/StatsCard.js +1 -1
- package/dist/components/other/Calendar/Calendar.js +1 -1
- package/dist/components/other/Calendar/CalendarCell.js +1 -1
- package/dist/components/other/Calendar/CalendarGrid.js +1 -1
- package/dist/components/other/Calendar/CalendarHeader.js +1 -1
- package/dist/components/other/Calendar/CalendarPanel.js +1 -1
- package/dist/components/other/Calendar/PeriodCalendar.js +1 -1
- package/dist/components/other/Calendar/PeriodGrid.js +1 -1
- package/dist/components/other/Calendar/RangeCalendar.js +1 -1
- package/dist/components/other/Calendar/styled.js +1 -1
- package/dist/components/other/CubeLogo/CubeLogo.js +1 -1
- package/dist/components/other/NoDataIcon/NoDataIcon.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialog.js +2 -2
- package/dist/components/overlays/AlertDialog/AlertDialogApiProvider.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogZone.js +1 -1
- package/dist/components/overlays/Dialog/Dialog.js +2 -2
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +4 -4
- package/dist/components/overlays/Dialog/DialogTrigger.js +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Modal/Modal.d.ts +2 -1
- package/dist/components/overlays/Modal/Modal.js +1 -1
- package/dist/components/overlays/Modal/OpenTransitionContext.js +1 -1
- package/dist/components/overlays/Modal/Overlay.d.ts +1 -0
- package/dist/components/overlays/Modal/Overlay.js +1 -1
- package/dist/components/overlays/Modal/Popover.js +1 -1
- package/dist/components/overlays/Modal/Tray.js +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Modal/types.d.ts +1 -0
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +1 -1
- package/dist/components/overlays/Notifications/NotificationCard.js +1 -1
- package/dist/components/overlays/Notifications/NotificationContext.d.ts +2 -0
- 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 +5 -7
- package/dist/components/overlays/Tooltip/TooltipProvider.js.map +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.d.ts +2 -0
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/index.d.ts +1 -0
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +1 -1
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/Spin/Cube.js +1 -1
- package/dist/components/status/Spin/InternalSpinner.js +1 -1
- package/dist/components/status/Spin/Spin.js +1 -1
- package/dist/components/status/Spin/SpinsContainer.js +1 -1
- package/dist/data/item-themes.js +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/eslint-plugin/defaults.generated.js +1 -1
- package/dist/eslint-plugin/index.js +1 -1
- package/dist/eslint-plugin/rules/no-redundant-default-prop.js +1 -1
- package/dist/i18n/I18nProvider.js +1 -1
- package/dist/i18n/createFormatter.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/instance.js +1 -1
- package/dist/i18n/locales/de-DE/uikit.js +16 -1
- package/dist/i18n/locales/en-US/uikit.js +16 -1
- package/dist/i18n/locales/en-US/uikit.json.d.ts +17 -1
- package/dist/i18n/locales/es-ES/uikit.js +16 -1
- package/dist/i18n/locales/es-MX/uikit.js +16 -1
- package/dist/i18n/locales/fr-FR/uikit.js +16 -1
- package/dist/i18n/locales/it-IT/uikit.js +16 -1
- package/dist/i18n/locales/ja-JP/uikit.js +16 -1
- package/dist/i18n/locales/nb-NO/uikit.js +16 -1
- package/dist/i18n/locales/pt-BR/uikit.js +16 -1
- package/dist/i18n/locales/pt-PT/uikit.js +16 -1
- package/dist/i18n/locales/sv-SE/uikit.js +16 -1
- package/dist/i18n/locales/vi-VN/uikit.js +16 -1
- package/dist/i18n/locales.js +1 -1
- package/dist/i18n/useFormatter.js +1 -1
- package/dist/i18n/useI18n.js +1 -1
- package/dist/icons/AdjustmentsHorizontalIcon.js +1 -1
- package/dist/icons/AdjustmentsIcon.js +1 -1
- package/dist/icons/AiIcon.js +1 -1
- package/dist/icons/AreaChartIcon.js +1 -1
- package/dist/icons/ArrowNarrowDownIcon.js +1 -1
- package/dist/icons/ArrowNarrowUpIcon.js +1 -1
- package/dist/icons/BackwardIcon.js +1 -1
- package/dist/icons/BarChartIcon.js +1 -1
- package/dist/icons/BellFilledIcon.js +1 -1
- package/dist/icons/BellIcon.js +1 -1
- package/dist/icons/BooleanIcon.js +1 -1
- package/dist/icons/CalendarEditIcon.js +1 -1
- package/dist/icons/CalendarIcon.js +1 -1
- package/dist/icons/CaretDownIcon.js +1 -1
- package/dist/icons/CaretUpIcon.js +1 -1
- package/dist/icons/ChartAreaStackedIcon.js +1 -1
- package/dist/icons/ChartAreaStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBarGroupedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarGroupedIcon.js +1 -1
- package/dist/icons/ChartBarHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarLineIcon.js +1 -1
- package/dist/icons/ChartBarStackedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBoxPlot2Icon.js +1 -1
- package/dist/icons/ChartBoxPlotIcon.js +1 -1
- package/dist/icons/ChartBubbleIcon.js +1 -1
- package/dist/icons/ChartDonut2Icon.js +1 -1
- package/dist/icons/ChartFunnelIcon.js +1 -1
- package/dist/icons/ChartHeatmapIcon.js +1 -1
- package/dist/icons/ChartKPIIcon.js +1 -1
- package/dist/icons/ChartPie2Icon.js +1 -1
- package/dist/icons/ChartScatterIcon.js +1 -1
- package/dist/icons/CheckCircleFilledIcon.js +1 -1
- package/dist/icons/CheckCircleIcon.js +1 -1
- package/dist/icons/CheckIcon.js +1 -1
- package/dist/icons/CircleFilledIcon.js +1 -1
- package/dist/icons/CirclePlusIcon.d.ts +12 -0
- package/dist/icons/CirclePlusIcon.js +11 -0
- package/dist/icons/CirclePlusIcon.js.map +1 -0
- package/dist/icons/ClearIcon.js +1 -1
- package/dist/icons/CloseCircleFilledIcon.js +1 -1
- package/dist/icons/CloseCircleIcon.js +1 -1
- package/dist/icons/CloseIcon.js +1 -1
- package/dist/icons/CodeIcon.js +1 -1
- package/dist/icons/ColumnTotalIcon.js +1 -1
- package/dist/icons/CopyIcon.js +1 -1
- package/dist/icons/CountIcon.js +1 -1
- package/dist/icons/CubeIcon.js +1 -1
- package/dist/icons/CubePauseIcon.js +1 -1
- package/dist/icons/CubePlayIcon.js +1 -1
- package/dist/icons/CurrencyDollarIcon.js +1 -1
- package/dist/icons/DangerIcon.js +1 -1
- package/dist/icons/DashboardIcon.js +1 -1
- package/dist/icons/DatabaseIcon.js +1 -1
- package/dist/icons/DecimalDecreaseIcon.js +1 -1
- package/dist/icons/DecimalIncreaseIcon.js +1 -1
- package/dist/icons/DirectionIcon.js +1 -1
- package/dist/icons/DonutIcon.js +1 -1
- package/dist/icons/DownIcon.js +1 -1
- package/dist/icons/EditIcon.js +1 -1
- package/dist/icons/ExclamationCircleFilledIcon.js +1 -1
- package/dist/icons/ExclamationCircleIcon.js +1 -1
- package/dist/icons/ExclamationIcon.js +1 -1
- package/dist/icons/EyeIcon.js +1 -1
- package/dist/icons/EyeInvisibleIcon.js +1 -1
- package/dist/icons/FilterIcon.js +1 -1
- package/dist/icons/FolderFilledIcon.js +1 -1
- package/dist/icons/FolderIcon.js +1 -1
- package/dist/icons/FolderOpenFilledIcon.js +1 -1
- package/dist/icons/FolderOpenIcon.js +1 -1
- package/dist/icons/ForwardIcon.js +1 -1
- package/dist/icons/GripVerticalIcon.js +1 -1
- package/dist/icons/HierarchyIcon.js +1 -1
- package/dist/icons/HierarchyOpenIcon.js +1 -1
- package/dist/icons/Icon.js +1 -1
- package/dist/icons/InfoCircleIcon.js +1 -1
- package/dist/icons/InfoIcon.js +1 -1
- package/dist/icons/KeyIcon.js +1 -1
- package/dist/icons/LeftIcon.js +1 -1
- package/dist/icons/LineChartIcon.js +1 -1
- package/dist/icons/LoadingIcon.js +1 -1
- package/dist/icons/LockFilledIcon.js +1 -1
- package/dist/icons/LockIcon.js +1 -1
- package/dist/icons/MoreIcon.js +1 -1
- package/dist/icons/NotAllowedIcon.js +1 -1
- package/dist/icons/Number123Icon.js +1 -1
- package/dist/icons/NumberIcon.js +1 -1
- package/dist/icons/PauseCircleFilledIcon.js +1 -1
- package/dist/icons/PauseCircleIcon.js +1 -1
- package/dist/icons/PauseIcon.js +1 -1
- package/dist/icons/PercentageIcon.js +1 -1
- package/dist/icons/PieChartIcon.js +1 -1
- package/dist/icons/PipetteIcon.js +1 -1
- package/dist/icons/PlayCircleIcon.js +1 -1
- package/dist/icons/PlayIcon.js +1 -1
- package/dist/icons/PlusIcon.js +1 -1
- package/dist/icons/ProgressBarIcon.js +1 -1
- package/dist/icons/ReloadIcon.js +1 -1
- package/dist/icons/ReportIcon.js +1 -1
- package/dist/icons/ReturnIcon.js +1 -1
- package/dist/icons/RightIcon.js +1 -1
- package/dist/icons/RowTotalsIcon.js +1 -1
- package/dist/icons/SchemeIcon.js +1 -1
- package/dist/icons/SearchIcon.js +1 -1
- package/dist/icons/SemanticQueryIcon.js +1 -1
- package/dist/icons/SettingsIcon.js +1 -1
- package/dist/icons/ShieldFilledIcon.js +1 -1
- package/dist/icons/ShieldIcon.js +1 -1
- package/dist/icons/SlashIcon.js +1 -1
- package/dist/icons/SparklesIcon.js +1 -1
- package/dist/icons/SqlIcon.js +1 -1
- package/dist/icons/StatsIcon.js +1 -1
- package/dist/icons/StopIcon.js +1 -1
- package/dist/icons/StringIcon.js +1 -1
- package/dist/icons/SubtotalsIcon.js +1 -1
- package/dist/icons/SwitchIcon.js +1 -1
- package/dist/icons/TableIcon.js +1 -1
- package/dist/icons/ThumbsDownIcon.js +1 -1
- package/dist/icons/ThumbsUpIcon.js +1 -1
- package/dist/icons/ThunderboltCrossedIcon.js +1 -1
- package/dist/icons/ThunderboltFilledIcon.js +1 -1
- package/dist/icons/ThunderboltIcon.js +1 -1
- package/dist/icons/TimeIcon.js +1 -1
- package/dist/icons/TrashIcon.js +1 -1
- package/dist/icons/UnlockIcon.js +1 -1
- package/dist/icons/UpIcon.js +1 -1
- package/dist/icons/UserGroupIcon.js +1 -1
- package/dist/icons/UserIcon.js +1 -1
- package/dist/icons/UserLockIcon.js +1 -1
- package/dist/icons/ViewIcon.js +1 -1
- package/dist/icons/WarningFilledIcon.js +1 -1
- package/dist/icons/WarningIcon.js +1 -1
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/wrap-icon.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +50 -48
- package/dist/index.js.map +1 -1
- package/dist/probe/canonicalize.js +1 -1
- package/dist/probe/css.js +1 -1
- package/dist/probe/index.js +1 -1
- package/dist/provider.js +1 -1
- package/dist/providers/TrackingProvider.js +1 -1
- package/dist/providers/navigationAdapter.default.js +1 -1
- package/dist/tokens/all-tokens.js +2 -2
- package/dist/tokens/base.js +1 -1
- package/dist/tokens/color-seed.js +1 -1
- package/dist/tokens/color-theme.js +1 -1
- package/dist/tokens/colors.js +2 -2
- package/dist/tokens/layout.js +1 -1
- package/dist/tokens/lazy-styles.js +1 -1
- package/dist/tokens/palette-config.js +1 -1
- package/dist/tokens/palette.js +2 -2
- package/dist/tokens/resolve.js +1 -1
- package/dist/tokens/shadows.js +1 -1
- package/dist/tokens/sizes.js +1 -1
- package/dist/tokens/spacing.js +1 -1
- package/dist/tokens/typography.js +1 -1
- package/dist/utils/ResizeSensor.js +1 -1
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/modules.js +1 -1
- package/dist/utils/promise.js +1 -1
- package/dist/utils/raf.js +1 -1
- package/dist/utils/random.js +1 -1
- package/dist/utils/range.js +1 -1
- package/dist/utils/react/RenderCache.js +1 -1
- package/dist/utils/react/Slots.js +1 -1
- package/dist/utils/react/chain.js +1 -1
- package/dist/utils/react/disabledProps.js +1 -1
- package/dist/utils/react/forwardRefWithGenerics.js +1 -1
- package/dist/utils/react/index.js +1 -1
- package/dist/utils/react/interactions.js +1 -1
- package/dist/utils/react/isTextOnly.js +1 -1
- package/dist/utils/react/mapProps.js +1 -1
- package/dist/utils/react/mergeProps.js +1 -1
- package/dist/utils/react/nullableValue.js +1 -1
- package/dist/utils/react/resolveIcon.js +1 -1
- package/dist/utils/react/sharedStore.js +1 -1
- package/dist/utils/react/useBufferedValue.js +1 -1
- package/dist/utils/react/useCombinedRefs.js +1 -1
- package/dist/utils/react/useControlledFocusVisible.js +1 -1
- package/dist/utils/react/useEventBus.js +1 -1
- package/dist/utils/react/useId.js +1 -1
- package/dist/utils/react/useIsDarwin.js +1 -1
- package/dist/utils/react/useKeySymbols.js +1 -1
- package/dist/utils/react/useLayoutEffect.js +1 -1
- package/dist/utils/react/useLocalStorage.js +1 -1
- package/dist/utils/react/useMergeStyles.js +1 -1
- package/dist/utils/react/usePopoverSync.js +1 -1
- package/dist/utils/react/useQaProps.js +1 -1
- package/dist/utils/react/useScheme.js +1 -1
- package/dist/utils/react/useViewportSize.js +1 -1
- package/dist/utils/react/wrapNodeIfPlain.js +1 -1
- package/dist/utils/selection.js +1 -1
- package/dist/utils/styles.js +1 -1
- package/dist/utils/tree.js +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/version.js +2 -2
- package/docs/components/layout/Dashboard.md +385 -0
- package/package.json +1 -5
|
@@ -0,0 +1,2049 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-434a15e | Cube Dev Team */
|
|
2
|
+
import { extractStyles } from "../../../utils/styles.js";
|
|
3
|
+
import { useLayoutEffect as useLayoutEffect$1 } from "../../../utils/react/useLayoutEffect.js";
|
|
4
|
+
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
5
|
+
import { useCombinedRefs } from "../../../utils/react/useCombinedRefs.js";
|
|
6
|
+
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
7
|
+
import { useI18n } from "../../../i18n/useI18n.js";
|
|
8
|
+
import { Button } from "../../actions/Button/Button.js";
|
|
9
|
+
import { __Menu } from "../../actions/Menu/Menu.js";
|
|
10
|
+
import { CirclePlusIcon } from "../../../icons/CirclePlusIcon.js";
|
|
11
|
+
import { GripVerticalIcon } from "../../../icons/GripVerticalIcon.js";
|
|
12
|
+
import { SettingsIcon } from "../../../icons/SettingsIcon.js";
|
|
13
|
+
import { TrashIcon } from "../../../icons/TrashIcon.js";
|
|
14
|
+
import { Tab, Tabs } from "../../navigation/Tabs/Tabs.js";
|
|
15
|
+
import { CONTAINER_STYLES, filterBaseProps, tasty } from "@tenphi/tasty";
|
|
16
|
+
import { Children, createContext, forwardRef, isValidElement, useContext, useMemo, useRef, useState } from "react";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { useFocusWithin, useHover, useMove } from "react-aria";
|
|
19
|
+
import { createPortal } from "react-dom";
|
|
20
|
+
|
|
21
|
+
//#region src/components/layout/Dashboard/Dashboard.tsx
|
|
22
|
+
const DashboardElement = tasty({
|
|
23
|
+
qa: "Dashboard",
|
|
24
|
+
styles: {
|
|
25
|
+
position: "relative",
|
|
26
|
+
display: "grid",
|
|
27
|
+
gridColumns: "minmax(0, 1fr)",
|
|
28
|
+
width: "100%",
|
|
29
|
+
minWidth: 0,
|
|
30
|
+
boxSizing: "border-box"
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const ContainerElement = tasty({
|
|
34
|
+
qa: "DashboardContainer",
|
|
35
|
+
styles: {
|
|
36
|
+
position: "relative",
|
|
37
|
+
display: "grid",
|
|
38
|
+
gridRows: {
|
|
39
|
+
"": "minmax(0, 1fr)",
|
|
40
|
+
titled: "auto minmax(0, 1fr)"
|
|
41
|
+
},
|
|
42
|
+
minWidth: 0,
|
|
43
|
+
boxSizing: "border-box",
|
|
44
|
+
fill: false,
|
|
45
|
+
border: false,
|
|
46
|
+
radius: true,
|
|
47
|
+
padding: {
|
|
48
|
+
"": "1x",
|
|
49
|
+
"depth=2": "5px",
|
|
50
|
+
"depth=3": "2px"
|
|
51
|
+
},
|
|
52
|
+
margin: {
|
|
53
|
+
"": "-8px",
|
|
54
|
+
"depth=2": "-5px",
|
|
55
|
+
"depth=3": "-2px"
|
|
56
|
+
},
|
|
57
|
+
shadow: {
|
|
58
|
+
"": false,
|
|
59
|
+
"editing & empty": "0 0 0 1px #dark.30",
|
|
60
|
+
"editing & hovered": "0 0 0 1px #dark.30",
|
|
61
|
+
"editing & resizing": "0 0 0 1px #dark.30",
|
|
62
|
+
"editing & arriving": "0 0 0 1px #dark.30",
|
|
63
|
+
dragging: "0 0 0 1px #dark.30",
|
|
64
|
+
"editing & focus-visible": "0 0 0 2px #primary-text",
|
|
65
|
+
"selected | moving": "0 0 0 2px #primary"
|
|
66
|
+
},
|
|
67
|
+
outline: "none",
|
|
68
|
+
zIndex: {
|
|
69
|
+
"": 1,
|
|
70
|
+
"hovered | dragging | arriving": 2,
|
|
71
|
+
"focus-within | selected | moving | :has([data-selected])": 3
|
|
72
|
+
},
|
|
73
|
+
cursor: {
|
|
74
|
+
"": "auto",
|
|
75
|
+
movable: "grab",
|
|
76
|
+
moving: "grabbing"
|
|
77
|
+
},
|
|
78
|
+
transition: "shadow, theme",
|
|
79
|
+
touchAction: {
|
|
80
|
+
"": "auto",
|
|
81
|
+
movable: "none"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const ContainerHeaderElement = tasty({ styles: {
|
|
86
|
+
display: "flex",
|
|
87
|
+
placeContent: "space-between",
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
gap: "1x",
|
|
90
|
+
minWidth: 0,
|
|
91
|
+
padding: "0.5x 0.5x 1x",
|
|
92
|
+
preset: "h6",
|
|
93
|
+
color: "#dark",
|
|
94
|
+
userSelect: "none"
|
|
95
|
+
} });
|
|
96
|
+
const ContentGridElement = tasty({
|
|
97
|
+
qa: "DashboardContainerContent",
|
|
98
|
+
styles: {
|
|
99
|
+
position: "relative",
|
|
100
|
+
display: "grid",
|
|
101
|
+
alignItems: "stretch",
|
|
102
|
+
minWidth: 0,
|
|
103
|
+
boxSizing: "border-box"
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
const FreeCellsLayerElement = tasty({ styles: {
|
|
107
|
+
position: "absolute",
|
|
108
|
+
inset: 0,
|
|
109
|
+
zIndex: 0,
|
|
110
|
+
display: "grid",
|
|
111
|
+
minWidth: 0,
|
|
112
|
+
pointerEvents: "none"
|
|
113
|
+
} });
|
|
114
|
+
const FreeCellElement = tasty({
|
|
115
|
+
qa: "DashboardFreeCell",
|
|
116
|
+
styles: {
|
|
117
|
+
minWidth: 0,
|
|
118
|
+
minHeight: 0,
|
|
119
|
+
boxSizing: "border-box",
|
|
120
|
+
pointerEvents: "auto",
|
|
121
|
+
fill: "#primary.06",
|
|
122
|
+
shadow: "inset 0 0 0 1px #primary.12",
|
|
123
|
+
radius: true,
|
|
124
|
+
opacity: {
|
|
125
|
+
"": 0,
|
|
126
|
+
highlighted: 1
|
|
127
|
+
},
|
|
128
|
+
transition: "opacity 100ms ease-in-out, theme"
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const ADD_CELL_BUTTON_STYLES = {
|
|
132
|
+
alignSelf: "stretch",
|
|
133
|
+
justifySelf: "stretch",
|
|
134
|
+
minWidth: 0,
|
|
135
|
+
minHeight: 0,
|
|
136
|
+
padding: 0,
|
|
137
|
+
fill: {
|
|
138
|
+
"": "#primary.06",
|
|
139
|
+
"hovered | focused": "#primary.12",
|
|
140
|
+
pressed: "#primary.18"
|
|
141
|
+
},
|
|
142
|
+
color: "#primary-text",
|
|
143
|
+
border: "0",
|
|
144
|
+
outline: {
|
|
145
|
+
"": false,
|
|
146
|
+
focused: false
|
|
147
|
+
},
|
|
148
|
+
shadow: {
|
|
149
|
+
"": "inset 0 0 0 1px #primary.12",
|
|
150
|
+
"hovered | focused": "inset 0 0 0 1px #primary"
|
|
151
|
+
},
|
|
152
|
+
radius: true,
|
|
153
|
+
transition: "opacity 100ms ease-in-out, theme",
|
|
154
|
+
visibility: {
|
|
155
|
+
"": "visible",
|
|
156
|
+
"@parent(:has(> [data-dashboard-drop-covers-add-slot]))": "hidden"
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const RootAddButtonElement = tasty(Button, {
|
|
160
|
+
qa: "DashboardRootAddButton",
|
|
161
|
+
styles: {
|
|
162
|
+
width: "100%",
|
|
163
|
+
minHeight: "6x",
|
|
164
|
+
padding: 0,
|
|
165
|
+
fill: "#surface-2",
|
|
166
|
+
border: "0",
|
|
167
|
+
shadow: "inset 0 0 0 1px #border",
|
|
168
|
+
radius: true
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
const DropPlaceholderElement = tasty({
|
|
172
|
+
qa: "DashboardDropPlaceholder",
|
|
173
|
+
styles: {
|
|
174
|
+
position: "absolute",
|
|
175
|
+
boxSizing: "border-box",
|
|
176
|
+
pointerEvents: "none",
|
|
177
|
+
zIndex: 4,
|
|
178
|
+
fill: {
|
|
179
|
+
"": "#primary.10",
|
|
180
|
+
danger: "#danger.10"
|
|
181
|
+
},
|
|
182
|
+
shadow: {
|
|
183
|
+
"": "0 0 0 1px #primary",
|
|
184
|
+
danger: "0 0 0 1px #danger"
|
|
185
|
+
},
|
|
186
|
+
radius: true,
|
|
187
|
+
transition: "inset 80ms linear, width 80ms linear, height 80ms linear"
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const WidgetElement = tasty({
|
|
191
|
+
qa: "DashboardWidget",
|
|
192
|
+
styles: {
|
|
193
|
+
position: "relative",
|
|
194
|
+
minWidth: 0,
|
|
195
|
+
minHeight: 0,
|
|
196
|
+
boxSizing: "border-box",
|
|
197
|
+
outline: "none",
|
|
198
|
+
visibility: {
|
|
199
|
+
"": "visible",
|
|
200
|
+
"add-slot & @parent(:has(> [data-dashboard-drop-covers-add-slot]))": "hidden"
|
|
201
|
+
},
|
|
202
|
+
zIndex: {
|
|
203
|
+
"": 1,
|
|
204
|
+
"hovered | focus-within": 2,
|
|
205
|
+
selected: 3
|
|
206
|
+
},
|
|
207
|
+
cursor: {
|
|
208
|
+
"": "auto",
|
|
209
|
+
movable: "grab",
|
|
210
|
+
moving: "grabbing"
|
|
211
|
+
},
|
|
212
|
+
touchAction: {
|
|
213
|
+
"": "auto",
|
|
214
|
+
movable: "none"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
const WidgetSurfaceElement = tasty({ styles: {
|
|
219
|
+
position: "relative",
|
|
220
|
+
width: "100%",
|
|
221
|
+
height: "100%",
|
|
222
|
+
minWidth: 0,
|
|
223
|
+
minHeight: 0,
|
|
224
|
+
boxSizing: "border-box",
|
|
225
|
+
overflow: "hidden",
|
|
226
|
+
fill: "#surface-2",
|
|
227
|
+
radius: true,
|
|
228
|
+
shadow: {
|
|
229
|
+
"": false,
|
|
230
|
+
card: "0 0 0 1px #border",
|
|
231
|
+
hovered: "0 0 0 1px #dark.30",
|
|
232
|
+
"focus-within": "0 0 0 2px #primary-text",
|
|
233
|
+
"selected | moving": "0 0 0 2px #primary"
|
|
234
|
+
},
|
|
235
|
+
transition: "shadow, theme"
|
|
236
|
+
} });
|
|
237
|
+
const NodeActionsElement = tasty({ styles: {
|
|
238
|
+
position: "absolute",
|
|
239
|
+
top: 0,
|
|
240
|
+
right: "(-1 * $size-sm / 2)",
|
|
241
|
+
zIndex: 6,
|
|
242
|
+
display: "flex",
|
|
243
|
+
gap: "0.5x",
|
|
244
|
+
transform: "translateY(-50%)",
|
|
245
|
+
opacity: {
|
|
246
|
+
"": 0,
|
|
247
|
+
selected: 1
|
|
248
|
+
},
|
|
249
|
+
pointerEvents: {
|
|
250
|
+
"": "none",
|
|
251
|
+
selected: "auto"
|
|
252
|
+
},
|
|
253
|
+
transition: "opacity 120ms ease-in-out"
|
|
254
|
+
} });
|
|
255
|
+
const CornerResizeGripElement = tasty({
|
|
256
|
+
qa: "DashboardResizeCornerGrip",
|
|
257
|
+
styles: {
|
|
258
|
+
width: "10px",
|
|
259
|
+
height: "10px",
|
|
260
|
+
boxSizing: "border-box",
|
|
261
|
+
borderRight: "2px solid #dark.40",
|
|
262
|
+
borderBottom: "2px solid #dark.40",
|
|
263
|
+
radius: "4px bottom-right"
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
const ResizeHandleElement = tasty({
|
|
267
|
+
qa: "DashboardResizeHandle",
|
|
268
|
+
as: "button",
|
|
269
|
+
styles: {
|
|
270
|
+
position: "absolute",
|
|
271
|
+
right: 0,
|
|
272
|
+
bottom: 0,
|
|
273
|
+
top: {
|
|
274
|
+
"": "auto",
|
|
275
|
+
"axis=x": "50%"
|
|
276
|
+
},
|
|
277
|
+
zIndex: 5,
|
|
278
|
+
display: "grid",
|
|
279
|
+
placeItems: "center",
|
|
280
|
+
width: {
|
|
281
|
+
"": "3.5x",
|
|
282
|
+
"axis=x": "2x"
|
|
283
|
+
},
|
|
284
|
+
height: {
|
|
285
|
+
"": "3.5x",
|
|
286
|
+
"axis=y": "2x"
|
|
287
|
+
},
|
|
288
|
+
padding: 0,
|
|
289
|
+
transform: {
|
|
290
|
+
"": "translate(50%, 50%)",
|
|
291
|
+
"axis=x": "translate(50%, -50%)"
|
|
292
|
+
},
|
|
293
|
+
fill: "#surface",
|
|
294
|
+
color: "#dark",
|
|
295
|
+
border: "1bw #border",
|
|
296
|
+
radius: "round",
|
|
297
|
+
shadow: "$item-shadow",
|
|
298
|
+
cursor: {
|
|
299
|
+
"": "nwse-resize",
|
|
300
|
+
"axis=x": "col-resize",
|
|
301
|
+
"axis=y": "row-resize"
|
|
302
|
+
},
|
|
303
|
+
opacity: {
|
|
304
|
+
"": 0,
|
|
305
|
+
"selected | resizing": 1
|
|
306
|
+
},
|
|
307
|
+
pointerEvents: {
|
|
308
|
+
"": "none",
|
|
309
|
+
"selected | resizing": "auto"
|
|
310
|
+
},
|
|
311
|
+
outline: {
|
|
312
|
+
"": "1bw #primary-text.0",
|
|
313
|
+
"focus-visible": "1bw #primary-text"
|
|
314
|
+
},
|
|
315
|
+
outlineOffset: "1bw",
|
|
316
|
+
transition: "opacity, theme",
|
|
317
|
+
touchAction: "none",
|
|
318
|
+
Icon: {
|
|
319
|
+
display: "flex",
|
|
320
|
+
placeContent: "center",
|
|
321
|
+
alignItems: "center",
|
|
322
|
+
lineHeight: 0,
|
|
323
|
+
transform: {
|
|
324
|
+
"": "rotate(-45deg)",
|
|
325
|
+
corner: "none",
|
|
326
|
+
"axis=x": "rotate(0deg)",
|
|
327
|
+
"axis=y": "rotate(90deg)"
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
const TopLevelResizeHandleElement = tasty(ResizeHandleElement, { styles: {
|
|
333
|
+
left: "50%",
|
|
334
|
+
right: "auto",
|
|
335
|
+
transform: "translate(-50%, 50%)"
|
|
336
|
+
} });
|
|
337
|
+
const DashboardMetricsContext = createContext({
|
|
338
|
+
rowHeight: 80,
|
|
339
|
+
columnGap: 16,
|
|
340
|
+
rowGap: 16
|
|
341
|
+
});
|
|
342
|
+
const DashboardTreeContext = createContext({
|
|
343
|
+
containerDepth: 0,
|
|
344
|
+
parentKind: "root",
|
|
345
|
+
parentId: null,
|
|
346
|
+
layoutParentId: null,
|
|
347
|
+
parentColumns: 12,
|
|
348
|
+
parentRows: 1,
|
|
349
|
+
ancestorIds: []
|
|
350
|
+
});
|
|
351
|
+
const DashboardSelectionContext = createContext({
|
|
352
|
+
selectionMode: "none",
|
|
353
|
+
selectedKeys: /* @__PURE__ */ new Set(),
|
|
354
|
+
register: () => () => {},
|
|
355
|
+
select: () => {}
|
|
356
|
+
});
|
|
357
|
+
const DashboardEditingContext = createContext({
|
|
358
|
+
isEditing: false,
|
|
359
|
+
movingId: null,
|
|
360
|
+
arrivingIds: /* @__PURE__ */ new Set(),
|
|
361
|
+
markArriving: () => {},
|
|
362
|
+
startMoving: () => {},
|
|
363
|
+
stopMoving: () => {}
|
|
364
|
+
});
|
|
365
|
+
const DashboardAuthoringContext = createContext({ addItems: [] });
|
|
366
|
+
const INTERACTIVE_SELECTOR = "button,input,textarea,select,a,[role=\"button\"],[role=\"menuitem\"],[role=\"checkbox\"],[role=\"switch\"],[role=\"tab\"],[contenteditable=\"true\"],[data-dashboard-no-select],[data-dashboard-no-move]";
|
|
367
|
+
function normalizeGap(gap) {
|
|
368
|
+
if (Array.isArray(gap)) return gap;
|
|
369
|
+
const value = gap ?? 16;
|
|
370
|
+
return [value, value];
|
|
371
|
+
}
|
|
372
|
+
function clampSpan(value, fallback) {
|
|
373
|
+
return Math.max(1, Math.min(12, Math.floor(value ?? fallback)));
|
|
374
|
+
}
|
|
375
|
+
function clampRows(value, fallback) {
|
|
376
|
+
return Math.max(1, Math.floor(value ?? fallback));
|
|
377
|
+
}
|
|
378
|
+
function clampOrigin(value) {
|
|
379
|
+
return Math.max(0, Math.min(11, Math.floor(value ?? 0)));
|
|
380
|
+
}
|
|
381
|
+
function clampRowOrigin(value) {
|
|
382
|
+
return Math.max(0, Math.floor(value ?? 0));
|
|
383
|
+
}
|
|
384
|
+
function clamp(value, min, max) {
|
|
385
|
+
return Math.max(min, Math.min(max, value));
|
|
386
|
+
}
|
|
387
|
+
function normalizePlacement(placement, parentColumns, parentRows) {
|
|
388
|
+
const columns = Math.min(clampSpan(placement.columns, parentColumns), parentColumns);
|
|
389
|
+
const rows = Math.min(clampRows(placement.rows, 1), parentRows);
|
|
390
|
+
return {
|
|
391
|
+
column: Math.min(clampOrigin(placement.column), parentColumns - columns),
|
|
392
|
+
row: Math.min(clampRowOrigin(placement.row), parentRows - rows),
|
|
393
|
+
columns,
|
|
394
|
+
rows
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function isSamePlacement(first, second) {
|
|
398
|
+
return first.column === second.column && first.row === second.row && first.columns === second.columns && first.rows === second.rows;
|
|
399
|
+
}
|
|
400
|
+
function getPlacementStyle(tree, placement) {
|
|
401
|
+
if (tree.parentKind === "root") return { gridColumn: "1 / -1" };
|
|
402
|
+
const columns = Math.min(clampSpan(placement.columns, tree.parentColumns), tree.parentColumns);
|
|
403
|
+
const rows = Math.min(clampRows(placement.rows, 1), tree.parentRows);
|
|
404
|
+
if (tree.parentKind === "horizontal-stack") return {
|
|
405
|
+
gridColumn: `span ${columns}`,
|
|
406
|
+
gridRow: `1 / span ${rows}`
|
|
407
|
+
};
|
|
408
|
+
if (tree.parentKind === "vertical-stack") return {
|
|
409
|
+
gridColumn: `1 / span ${columns}`,
|
|
410
|
+
gridRow: `span ${rows}`
|
|
411
|
+
};
|
|
412
|
+
return {
|
|
413
|
+
gridColumn: `${Math.min(clampOrigin(placement.column), tree.parentColumns - columns) + 1} / span ${columns}`,
|
|
414
|
+
gridRow: `${Math.min(clampRowOrigin(placement.row), tree.parentRows - rows) + 1} / span ${rows}`
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function getContentGridStyle(kind, columns, rows, metrics) {
|
|
418
|
+
return {
|
|
419
|
+
gap: `${metrics.rowGap}px ${metrics.columnGap}px`,
|
|
420
|
+
gridTemplateColumns: `repeat(${Math.max(1, Math.floor(columns))}, minmax(0, 1fr))`,
|
|
421
|
+
gridTemplateRows: `repeat(${Math.max(1, Math.floor(rows))}, minmax(${metrics.rowHeight}px, auto))`,
|
|
422
|
+
gridAutoFlow: kind === "horizontal-stack" ? "row" : void 0
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function getDashboardChildPlacements(kind, children, columns, rows) {
|
|
426
|
+
const childPlacements = Children.toArray(children).flatMap((child) => {
|
|
427
|
+
if (!isValidElement(child)) return [];
|
|
428
|
+
const props = child.props;
|
|
429
|
+
if (props["data-dashboard-add-slot"] !== void 0) return [];
|
|
430
|
+
return [normalizePlacement(props, columns, rows)];
|
|
431
|
+
});
|
|
432
|
+
if (kind === "horizontal-stack") {
|
|
433
|
+
let nextColumn = 0;
|
|
434
|
+
return childPlacements.map((placement) => {
|
|
435
|
+
const next = {
|
|
436
|
+
...placement,
|
|
437
|
+
column: nextColumn,
|
|
438
|
+
row: 0
|
|
439
|
+
};
|
|
440
|
+
nextColumn += placement.columns;
|
|
441
|
+
return next;
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
if (kind === "vertical-stack") {
|
|
445
|
+
let nextRow = 0;
|
|
446
|
+
return childPlacements.map((placement) => {
|
|
447
|
+
const next = {
|
|
448
|
+
...placement,
|
|
449
|
+
column: 0,
|
|
450
|
+
row: nextRow
|
|
451
|
+
};
|
|
452
|
+
nextRow += placement.rows;
|
|
453
|
+
return next;
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
return childPlacements;
|
|
457
|
+
}
|
|
458
|
+
function getDashboardFreeCells(kind, placements, columns, rows) {
|
|
459
|
+
if (kind === "horizontal-stack") {
|
|
460
|
+
const column = placements.reduce((end, placement) => Math.max(end, placement.column + placement.columns), 0);
|
|
461
|
+
return column < columns ? [{
|
|
462
|
+
column,
|
|
463
|
+
row: 0
|
|
464
|
+
}] : [];
|
|
465
|
+
}
|
|
466
|
+
if (kind === "vertical-stack") {
|
|
467
|
+
const row = placements.reduce((end, placement) => Math.max(end, placement.row + placement.rows), 0);
|
|
468
|
+
return row < rows ? [{
|
|
469
|
+
column: 0,
|
|
470
|
+
row
|
|
471
|
+
}] : [];
|
|
472
|
+
}
|
|
473
|
+
if (kind === "tabs") return placements.length === 0 ? [{
|
|
474
|
+
column: 0,
|
|
475
|
+
row: 0
|
|
476
|
+
}] : [];
|
|
477
|
+
const cells = [];
|
|
478
|
+
for (let row = 0; row < rows; row += 1) for (let column = 0; column < columns; column += 1) if (!placements.some((placement) => column >= placement.column && column < placement.column + placement.columns && row >= placement.row && row < placement.row + placement.rows)) cells.push({
|
|
479
|
+
column,
|
|
480
|
+
row
|
|
481
|
+
});
|
|
482
|
+
return cells;
|
|
483
|
+
}
|
|
484
|
+
function getDashboardAddPlacement(definition, cell, kind, placements, parentColumns, parentRows, parentDepth) {
|
|
485
|
+
if (definition.isDisabled || kind === "tabs" && (!definition.kind || definition.kind === "widget" || definition.kind === "tabs") || definition.kind && definition.kind !== "widget" && parentDepth >= 3) return null;
|
|
486
|
+
const minColumns = clampSpan(definition.minColumns, 1);
|
|
487
|
+
const maxColumns = Math.max(minColumns, clampSpan(definition.maxColumns, parentColumns));
|
|
488
|
+
const minRows = clampRows(definition.minRows, 1);
|
|
489
|
+
const maxRows = Math.max(minRows, clampRows(definition.maxRows, parentRows));
|
|
490
|
+
let resolvedColumns = clamp(clampSpan(definition.defaultColumns, minColumns), minColumns, maxColumns);
|
|
491
|
+
let resolvedRows = clamp(clampRows(definition.defaultRows, minRows), minRows, maxRows);
|
|
492
|
+
if (kind === "horizontal-stack") resolvedRows = Math.min(parentRows, maxRows);
|
|
493
|
+
else if (kind === "vertical-stack") resolvedColumns = Math.min(parentColumns, maxColumns);
|
|
494
|
+
else if (kind === "tabs") {
|
|
495
|
+
resolvedColumns = parentColumns;
|
|
496
|
+
resolvedRows = Math.min(parentRows, maxRows);
|
|
497
|
+
}
|
|
498
|
+
if (resolvedColumns < minColumns || resolvedRows < minRows || resolvedColumns > parentColumns || resolvedRows > parentRows) return null;
|
|
499
|
+
const placement = {
|
|
500
|
+
column: kind === "vertical-stack" || kind === "tabs" ? 0 : cell.column,
|
|
501
|
+
row: kind === "horizontal-stack" || kind === "tabs" ? 0 : cell.row,
|
|
502
|
+
columns: resolvedColumns,
|
|
503
|
+
rows: resolvedRows
|
|
504
|
+
};
|
|
505
|
+
if (placement.column + placement.columns > parentColumns || placement.row + placement.rows > parentRows) return null;
|
|
506
|
+
return placements.some((occupied) => {
|
|
507
|
+
if (kind === "horizontal-stack") return !(placement.column + placement.columns <= occupied.column || occupied.column + occupied.columns <= placement.column);
|
|
508
|
+
if (kind === "vertical-stack") return !(placement.row + placement.rows <= occupied.row || occupied.row + occupied.rows <= placement.row);
|
|
509
|
+
return placementsOverlap(placement, occupied);
|
|
510
|
+
}) ? null : placement;
|
|
511
|
+
}
|
|
512
|
+
function DashboardContainerContent({ id, kind, columns, rows, depth, ancestorIds, tabsId, tabId, children }) {
|
|
513
|
+
const { t } = useI18n();
|
|
514
|
+
const metrics = useContext(DashboardMetricsContext);
|
|
515
|
+
const editing = useContext(DashboardEditingContext);
|
|
516
|
+
const authoring = useContext(DashboardAuthoringContext);
|
|
517
|
+
const [isOwnHovered, setIsOwnHovered] = useState(false);
|
|
518
|
+
const [activeCell, setActiveCell] = useState(null);
|
|
519
|
+
const [isAddMenuOpen, setIsAddMenuOpen] = useState(false);
|
|
520
|
+
const [openAddCell, setOpenAddCell] = useState(null);
|
|
521
|
+
const openAddCellRef = useRef(null);
|
|
522
|
+
const placements = useMemo(() => getDashboardChildPlacements(kind, children, columns, rows), [
|
|
523
|
+
children,
|
|
524
|
+
columns,
|
|
525
|
+
kind,
|
|
526
|
+
rows
|
|
527
|
+
]);
|
|
528
|
+
const freeCells = useMemo(() => getDashboardFreeCells(kind, placements, columns, rows), [
|
|
529
|
+
columns,
|
|
530
|
+
kind,
|
|
531
|
+
placements,
|
|
532
|
+
rows
|
|
533
|
+
]);
|
|
534
|
+
const availableItems = useMemo(() => kind === "tabs" ? authoring.addItems.filter((definition) => definition.kind !== void 0 && definition.kind !== "widget" && definition.kind !== "tabs") : authoring.addItems.filter((definition) => definition.kind !== "tabs"), [authoring.addItems, kind]);
|
|
535
|
+
const rememberedActiveCell = activeCell && freeCells.some((cell) => cell.column === activeCell.column && cell.row === activeCell.row) ? activeCell : null;
|
|
536
|
+
const resolvedActiveCell = kind === "tabs" || kind === "horizontal-stack" || kind === "vertical-stack" ? freeCells[0] ?? null : rememberedActiveCell;
|
|
537
|
+
const addButtonCell = openAddCell ?? resolvedActiveCell ?? freeCells[0] ?? null;
|
|
538
|
+
const activePlacements = useMemo(() => new Map(availableItems.map((definition) => [definition.id, addButtonCell ? getDashboardAddPlacement(definition, addButtonCell, kind, placements, columns, rows, depth) : null])), [
|
|
539
|
+
availableItems,
|
|
540
|
+
columns,
|
|
541
|
+
depth,
|
|
542
|
+
kind,
|
|
543
|
+
placements,
|
|
544
|
+
addButtonCell,
|
|
545
|
+
rows
|
|
546
|
+
]);
|
|
547
|
+
const disabledKeys = useMemo(() => availableItems.filter((definition) => !activePlacements.get(definition.id)).map((definition) => definition.id), [activePlacements, availableItems]);
|
|
548
|
+
const isPermanentAdd = kind === "tabs";
|
|
549
|
+
const isAuthoringVisible = isPermanentAdd || isOwnHovered || isAddMenuOpen;
|
|
550
|
+
const hasAddTarget = !!addButtonCell && !!authoring.onAddItem && availableItems.length > 0;
|
|
551
|
+
const isAddButtonVisible = hasAddTarget && (isPermanentAdd || isOwnHovered || isAddMenuOpen);
|
|
552
|
+
const updateHover = useEvent((event) => {
|
|
553
|
+
if (isAddMenuOpen) return;
|
|
554
|
+
const target = event.target;
|
|
555
|
+
const content = event.currentTarget;
|
|
556
|
+
if (target.closest("[data-dashboard-drop-target]") !== content) {
|
|
557
|
+
setIsOwnHovered(false);
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
setIsOwnHovered(true);
|
|
561
|
+
const freeCell = target.closest("[data-dashboard-free-cell], [data-dashboard-add-slot]");
|
|
562
|
+
if (freeCell?.dataset.dashboardParentId === id) {
|
|
563
|
+
const next = {
|
|
564
|
+
column: Number(freeCell.dataset.dashboardColumn),
|
|
565
|
+
row: Number(freeCell.dataset.dashboardRow)
|
|
566
|
+
};
|
|
567
|
+
setActiveCell((current) => current?.column === next.column && current.row === next.row ? current : next);
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
const handlePointerLeave = useEvent(() => {
|
|
571
|
+
setIsOwnHovered(false);
|
|
572
|
+
});
|
|
573
|
+
const lockAddCell = useEvent(() => {
|
|
574
|
+
openAddCellRef.current = addButtonCell;
|
|
575
|
+
setOpenAddCell(addButtonCell);
|
|
576
|
+
});
|
|
577
|
+
const handleAddMenuOpenChange = useEvent((isOpen) => {
|
|
578
|
+
setIsAddMenuOpen(isOpen);
|
|
579
|
+
if (isOpen) lockAddCell();
|
|
580
|
+
else setOpenAddCell(null);
|
|
581
|
+
});
|
|
582
|
+
const handleAction = useEvent((key) => {
|
|
583
|
+
const itemId = String(key);
|
|
584
|
+
const definition = availableItems.find((item) => item.id === itemId);
|
|
585
|
+
const targetCell = openAddCellRef.current ?? addButtonCell;
|
|
586
|
+
const placement = definition && targetCell ? getDashboardAddPlacement(definition, targetCell, kind, placements, columns, rows, depth) : null;
|
|
587
|
+
if (!placement) return;
|
|
588
|
+
authoring.onAddItem?.(itemId, {
|
|
589
|
+
parentId: id,
|
|
590
|
+
parentKind: kind,
|
|
591
|
+
parentDepth: depth,
|
|
592
|
+
placement,
|
|
593
|
+
...tabsId && { tabsId },
|
|
594
|
+
...tabId && { tabId }
|
|
595
|
+
});
|
|
596
|
+
openAddCellRef.current = null;
|
|
597
|
+
});
|
|
598
|
+
const gridStyle = getContentGridStyle(kind, columns, rows, metrics);
|
|
599
|
+
return /* @__PURE__ */ jsxs(ContentGridElement, {
|
|
600
|
+
"data-dashboard-drop-target": "",
|
|
601
|
+
"data-dashboard-parent-id": id,
|
|
602
|
+
"data-dashboard-container-kind": kind,
|
|
603
|
+
"data-dashboard-columns": columns,
|
|
604
|
+
"data-dashboard-rows": rows,
|
|
605
|
+
"data-dashboard-depth": depth,
|
|
606
|
+
"data-dashboard-ancestor-ids": JSON.stringify(ancestorIds),
|
|
607
|
+
"data-dashboard-tabs-id": tabsId,
|
|
608
|
+
"data-dashboard-tab-id": tabId,
|
|
609
|
+
"data-dashboard-own-hover": isOwnHovered || void 0,
|
|
610
|
+
style: gridStyle,
|
|
611
|
+
onPointerOver: updateHover,
|
|
612
|
+
onPointerMove: updateHover,
|
|
613
|
+
onPointerLeave: handlePointerLeave,
|
|
614
|
+
children: [
|
|
615
|
+
editing.isEditing ? /* @__PURE__ */ jsx(FreeCellsLayerElement, {
|
|
616
|
+
"aria-hidden": "true",
|
|
617
|
+
style: gridStyle,
|
|
618
|
+
children: freeCells.map((cell) => /* @__PURE__ */ jsx(FreeCellElement, {
|
|
619
|
+
"data-dashboard-free-cell": "",
|
|
620
|
+
"data-dashboard-parent-id": id,
|
|
621
|
+
"data-dashboard-column": cell.column,
|
|
622
|
+
"data-dashboard-row": cell.row,
|
|
623
|
+
"data-highlighted": isAuthoringVisible || void 0,
|
|
624
|
+
mods: { highlighted: isAuthoringVisible },
|
|
625
|
+
style: kind === "tabs" ? {
|
|
626
|
+
gridColumn: "1 / -1",
|
|
627
|
+
gridRow: "1 / -1"
|
|
628
|
+
} : {
|
|
629
|
+
gridColumn: `${cell.column + 1} / span 1`,
|
|
630
|
+
gridRow: `${cell.row + 1} / span 1`
|
|
631
|
+
}
|
|
632
|
+
}, `${cell.column}:${cell.row}`))
|
|
633
|
+
}) : null,
|
|
634
|
+
children,
|
|
635
|
+
editing.isEditing && hasAddTarget ? /* @__PURE__ */ jsxs(__Menu.Trigger, {
|
|
636
|
+
onOpenChange: handleAddMenuOpenChange,
|
|
637
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
638
|
+
qa: "DashboardAddButton",
|
|
639
|
+
type: "clear",
|
|
640
|
+
icon: isAddButtonVisible ? /* @__PURE__ */ jsx(CirclePlusIcon, {}) : null,
|
|
641
|
+
"aria-label": t("dashboard.addItem", "Add an item at column {{column}}, row {{row}} in {{container}}", {
|
|
642
|
+
column: addButtonCell.column + 1,
|
|
643
|
+
row: addButtonCell.row + 1,
|
|
644
|
+
container: id
|
|
645
|
+
}),
|
|
646
|
+
"data-dashboard-add-slot": "",
|
|
647
|
+
"data-dashboard-parent-id": id,
|
|
648
|
+
"data-dashboard-column": addButtonCell.column,
|
|
649
|
+
"data-dashboard-row": addButtonCell.row,
|
|
650
|
+
"data-dashboard-columns": kind === "tabs" ? columns : 1,
|
|
651
|
+
"data-dashboard-rows": kind === "tabs" ? rows : 1,
|
|
652
|
+
width: "100%",
|
|
653
|
+
height: "100%",
|
|
654
|
+
zIndex: 3,
|
|
655
|
+
opacity: isAddButtonVisible ? 1 : 0,
|
|
656
|
+
"aria-hidden": !isAddButtonVisible || void 0,
|
|
657
|
+
tabIndex: isAddButtonVisible ? void 0 : -1,
|
|
658
|
+
styles: ADD_CELL_BUTTON_STYLES,
|
|
659
|
+
onPressStart: lockAddCell,
|
|
660
|
+
style: kind === "tabs" ? {
|
|
661
|
+
gridColumn: "1 / -1",
|
|
662
|
+
gridRow: "1 / -1",
|
|
663
|
+
border: 0,
|
|
664
|
+
outline: "none"
|
|
665
|
+
} : {
|
|
666
|
+
gridColumn: `${addButtonCell.column + 1} / span 1`,
|
|
667
|
+
gridRow: `${addButtonCell.row + 1} / span 1`,
|
|
668
|
+
border: 0,
|
|
669
|
+
outline: "none"
|
|
670
|
+
}
|
|
671
|
+
}), /* @__PURE__ */ jsx(__Menu, {
|
|
672
|
+
"aria-label": t("dashboard.addMenu", "Items available for {{container}}", { container: id }),
|
|
673
|
+
width: "280px",
|
|
674
|
+
disabledKeys,
|
|
675
|
+
onAction: handleAction,
|
|
676
|
+
children: availableItems.map((definition) => /* @__PURE__ */ jsx(__Menu.Item, {
|
|
677
|
+
icon: definition.icon,
|
|
678
|
+
description: definition.description,
|
|
679
|
+
textValue: typeof definition.name === "string" ? definition.name : definition.id,
|
|
680
|
+
children: definition.name
|
|
681
|
+
}, definition.id))
|
|
682
|
+
})]
|
|
683
|
+
}) : null
|
|
684
|
+
]
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
function DashboardRootAddControl({ row }) {
|
|
688
|
+
const { t } = useI18n();
|
|
689
|
+
const authoring = useContext(DashboardAuthoringContext);
|
|
690
|
+
const containerItems = useMemo(() => authoring.addItems.filter((definition) => definition.kind !== void 0 && definition.kind !== "widget"), [authoring.addItems]);
|
|
691
|
+
const disabledKeys = useMemo(() => containerItems.filter((definition) => definition.isDisabled).map((definition) => definition.id), [containerItems]);
|
|
692
|
+
const handleAction = useEvent((key) => {
|
|
693
|
+
const itemId = String(key);
|
|
694
|
+
const definition = containerItems.find((item) => item.id === itemId);
|
|
695
|
+
if (!definition || definition.isDisabled) return;
|
|
696
|
+
const minRows = clampRows(definition.minRows, 1);
|
|
697
|
+
const maxRows = Math.max(minRows, clampRows(definition.maxRows, Math.max(12, minRows)));
|
|
698
|
+
const rows = clamp(clampRows(definition.defaultRows, minRows), minRows, maxRows);
|
|
699
|
+
authoring.onAddItem?.(itemId, {
|
|
700
|
+
parentId: null,
|
|
701
|
+
parentKind: "root",
|
|
702
|
+
parentDepth: 0,
|
|
703
|
+
placement: {
|
|
704
|
+
column: 0,
|
|
705
|
+
row,
|
|
706
|
+
columns: 12,
|
|
707
|
+
rows
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
if (!authoring.onAddItem || containerItems.length === 0) return null;
|
|
712
|
+
return /* @__PURE__ */ jsxs(__Menu.Trigger, { children: [/* @__PURE__ */ jsx(RootAddButtonElement, {
|
|
713
|
+
type: "clear",
|
|
714
|
+
icon: /* @__PURE__ */ jsx(CirclePlusIcon, {}),
|
|
715
|
+
"aria-label": t("dashboard.addTopLevelContainer", "Add top-level dashboard container"),
|
|
716
|
+
"data-dashboard-root-add-slot": "",
|
|
717
|
+
style: { border: 0 }
|
|
718
|
+
}), /* @__PURE__ */ jsx(__Menu, {
|
|
719
|
+
"aria-label": t("dashboard.addTopLevelMenu", "Top-level dashboard containers"),
|
|
720
|
+
width: "280px",
|
|
721
|
+
disabledKeys,
|
|
722
|
+
onAction: handleAction,
|
|
723
|
+
children: containerItems.map((definition) => /* @__PURE__ */ jsx(__Menu.Item, {
|
|
724
|
+
icon: definition.icon,
|
|
725
|
+
description: definition.description,
|
|
726
|
+
textValue: typeof definition.name === "string" ? definition.name : definition.id,
|
|
727
|
+
children: definition.name
|
|
728
|
+
}, definition.id))
|
|
729
|
+
})] });
|
|
730
|
+
}
|
|
731
|
+
function useDashboardNodeInteraction({ id, isContainer, isSelectable = true }) {
|
|
732
|
+
const tree = useContext(DashboardTreeContext);
|
|
733
|
+
const selection = useContext(DashboardSelectionContext);
|
|
734
|
+
const editing = useContext(DashboardEditingContext);
|
|
735
|
+
const [isFocusWithin, setIsFocusWithin] = useState(false);
|
|
736
|
+
const { hoverProps, isHovered } = useHover({});
|
|
737
|
+
const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setIsFocusWithin });
|
|
738
|
+
const containerDepth = isContainer ? tree.containerDepth + 1 : tree.containerDepth;
|
|
739
|
+
const canSelect = isSelectable && selection.selectionMode !== "none";
|
|
740
|
+
const isSelected = selection.selectedKeys.has(id);
|
|
741
|
+
useLayoutEffect$1(() => selection.register(id, {
|
|
742
|
+
parentId: tree.parentId,
|
|
743
|
+
ancestorIds: tree.ancestorIds
|
|
744
|
+
}));
|
|
745
|
+
const selectSelf = useEvent((additive = false) => {
|
|
746
|
+
if (canSelect) selection.select(id, additive);
|
|
747
|
+
});
|
|
748
|
+
return {
|
|
749
|
+
tree,
|
|
750
|
+
editing,
|
|
751
|
+
containerDepth,
|
|
752
|
+
canSelect,
|
|
753
|
+
isSelected,
|
|
754
|
+
isHovered,
|
|
755
|
+
isFocusWithin,
|
|
756
|
+
interactionProps: mergeProps$1(hoverProps, focusWithinProps, {
|
|
757
|
+
onClick: useEvent((event) => {
|
|
758
|
+
if (!canSelect) return;
|
|
759
|
+
if (event.target.closest(INTERACTIVE_SELECTOR)) return;
|
|
760
|
+
event.stopPropagation();
|
|
761
|
+
selectSelf(event.shiftKey || event.metaKey || event.ctrlKey);
|
|
762
|
+
}),
|
|
763
|
+
onKeyDown: useEvent((event) => {
|
|
764
|
+
if (!canSelect || event.target !== event.currentTarget) return;
|
|
765
|
+
if (event.key !== " " && event.key !== "Spacebar") return;
|
|
766
|
+
event.preventDefault();
|
|
767
|
+
event.stopPropagation();
|
|
768
|
+
selectSelf(selection.selectionMode === "multiple");
|
|
769
|
+
})
|
|
770
|
+
}),
|
|
771
|
+
selectSelf
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
function isDashboardActionTarget(target) {
|
|
775
|
+
return !!target?.closest?.(INTERACTIVE_SELECTOR);
|
|
776
|
+
}
|
|
777
|
+
function getSurfaceMoveProps(moveProps, canMove, focusRef, onPointerStart) {
|
|
778
|
+
if (!canMove) return {};
|
|
779
|
+
return {
|
|
780
|
+
...moveProps,
|
|
781
|
+
...moveProps.onPointerDown && { onPointerDown(event) {
|
|
782
|
+
if (isDashboardActionTarget(event.target)) return;
|
|
783
|
+
onPointerStart(event.clientX, event.clientY);
|
|
784
|
+
focusRef.current?.focus({ preventScroll: true });
|
|
785
|
+
moveProps.onPointerDown?.(event);
|
|
786
|
+
} },
|
|
787
|
+
...moveProps.onMouseDown && { onMouseDown(event) {
|
|
788
|
+
if (isDashboardActionTarget(event.target)) return;
|
|
789
|
+
onPointerStart(event.clientX, event.clientY);
|
|
790
|
+
focusRef.current?.focus({ preventScroll: true });
|
|
791
|
+
moveProps.onMouseDown?.(event);
|
|
792
|
+
} },
|
|
793
|
+
...moveProps.onTouchStart && { onTouchStart(event) {
|
|
794
|
+
if (isDashboardActionTarget(event.target)) return;
|
|
795
|
+
const touch = event.touches[0];
|
|
796
|
+
if (touch) onPointerStart(touch.clientX, touch.clientY);
|
|
797
|
+
moveProps.onTouchStart?.(event);
|
|
798
|
+
} },
|
|
799
|
+
...moveProps.onKeyDown && { onKeyDown(event) {
|
|
800
|
+
if (event.target !== event.currentTarget) return;
|
|
801
|
+
moveProps.onKeyDown?.(event);
|
|
802
|
+
} }
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function parseDashboardAncestorIds(element) {
|
|
806
|
+
const value = element.dataset.dashboardAncestorIds;
|
|
807
|
+
if (!value) return [];
|
|
808
|
+
try {
|
|
809
|
+
const parsed = JSON.parse(value);
|
|
810
|
+
return Array.isArray(parsed) ? parsed.filter((id) => typeof id === "string") : [];
|
|
811
|
+
} catch {
|
|
812
|
+
return [];
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
function findDashboardDropTarget(node, clientX, clientY, movingId, isContainer, maximumContainerParentDepth = 2) {
|
|
816
|
+
const root = node.closest("[data-dashboard-root]");
|
|
817
|
+
if (!root) return null;
|
|
818
|
+
const candidates = [root, ...Array.from(root.querySelectorAll("[data-dashboard-drop-target]"))].flatMap((element) => {
|
|
819
|
+
const rect = element.getBoundingClientRect();
|
|
820
|
+
if (rect.width <= 0 || rect.height <= 0 || clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom) return [];
|
|
821
|
+
const parentId = element.dataset.dashboardParentId || null;
|
|
822
|
+
const kind = element.dataset.dashboardContainerKind ?? "root";
|
|
823
|
+
const depth = Number(element.dataset.dashboardDepth ?? 0);
|
|
824
|
+
const ancestorIds = parseDashboardAncestorIds(element);
|
|
825
|
+
if (!isContainer && kind === "root") return [];
|
|
826
|
+
if (isContainer && (depth > maximumContainerParentDepth || parentId === movingId || ancestorIds.includes(movingId))) return [];
|
|
827
|
+
return [{
|
|
828
|
+
parentId,
|
|
829
|
+
kind,
|
|
830
|
+
columns: Math.max(1, Number(element.dataset.dashboardColumns ?? 12)),
|
|
831
|
+
rows: Math.max(1, Number(element.dataset.dashboardRows ?? 1)),
|
|
832
|
+
depth,
|
|
833
|
+
rect,
|
|
834
|
+
element
|
|
835
|
+
}];
|
|
836
|
+
});
|
|
837
|
+
candidates.sort((first, second) => second.depth - first.depth || first.rect.width * first.rect.height - second.rect.width * second.rect.height);
|
|
838
|
+
return candidates[0] ?? null;
|
|
839
|
+
}
|
|
840
|
+
function getCrossParentPlacement(target, gesture, minColumns, minRows, isContainer, metrics) {
|
|
841
|
+
if (target.kind === "root") {
|
|
842
|
+
if (!isContainer) return null;
|
|
843
|
+
const siblingMidpoints = Array.from(target.element.children).filter((child) => child instanceof HTMLElement && child.dataset.dashboardNode === "container" && child.dataset.dashboardNodeId !== void 0).map((child) => {
|
|
844
|
+
const rect = child.getBoundingClientRect();
|
|
845
|
+
return rect.top + rect.height / 2;
|
|
846
|
+
}).filter((midpoint) => Number.isFinite(midpoint));
|
|
847
|
+
const pointerY = gesture.pointerY + gesture.deltaY;
|
|
848
|
+
return {
|
|
849
|
+
column: 0,
|
|
850
|
+
row: siblingMidpoints.filter((midpoint) => midpoint < pointerY).length,
|
|
851
|
+
columns: 12,
|
|
852
|
+
rows: gesture.origin.rows
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
const grabbedItem = gesture.items[0];
|
|
856
|
+
const columns = Math.min(target.kind === "vertical-stack" ? grabbedItem.maxColumns : gesture.origin.columns, target.columns);
|
|
857
|
+
const rows = Math.min(target.kind === "horizontal-stack" ? grabbedItem.maxRows : gesture.origin.rows, target.rows);
|
|
858
|
+
if (columns < minColumns || rows < minRows) return null;
|
|
859
|
+
const columnWidth = (target.rect.width - metrics.columnGap * (target.columns - 1)) / target.columns;
|
|
860
|
+
const columnStep = Math.max(1, columnWidth + metrics.columnGap);
|
|
861
|
+
const rowStep = Math.max(1, metrics.rowHeight + metrics.rowGap);
|
|
862
|
+
const desiredLeft = gesture.pointerX + gesture.deltaX - gesture.grabOffsetX;
|
|
863
|
+
const desiredTop = gesture.pointerY + gesture.deltaY - gesture.grabOffsetY;
|
|
864
|
+
const column = clamp(Math.round((desiredLeft - target.rect.left) / columnStep), 0, target.columns - columns);
|
|
865
|
+
const row = clamp(Math.round((desiredTop - target.rect.top) / rowStep), 0, target.rows - rows);
|
|
866
|
+
return {
|
|
867
|
+
column: target.kind === "vertical-stack" ? 0 : column,
|
|
868
|
+
row: target.kind === "horizontal-stack" ? 0 : row,
|
|
869
|
+
columns,
|
|
870
|
+
rows
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
function placementsOverlap(first, second) {
|
|
874
|
+
return first.column < second.column + second.columns && first.column + first.columns > second.column && first.row < second.row + second.rows && first.row + first.rows > second.row;
|
|
875
|
+
}
|
|
876
|
+
function readDashboardNodePlacement(element) {
|
|
877
|
+
const column = Number(element.dataset.dashboardColumn);
|
|
878
|
+
const row = Number(element.dataset.dashboardRow);
|
|
879
|
+
const columns = Number(element.dataset.dashboardColumns);
|
|
880
|
+
const rows = Number(element.dataset.dashboardRows);
|
|
881
|
+
if (![
|
|
882
|
+
column,
|
|
883
|
+
row,
|
|
884
|
+
columns,
|
|
885
|
+
rows
|
|
886
|
+
].every(Number.isFinite)) return null;
|
|
887
|
+
return {
|
|
888
|
+
column,
|
|
889
|
+
row,
|
|
890
|
+
columns,
|
|
891
|
+
rows
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
function getDashboardGestureItem(id, origin, element) {
|
|
895
|
+
const readConstraint = (value, fallback) => {
|
|
896
|
+
const parsed = Number(value);
|
|
897
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
898
|
+
};
|
|
899
|
+
return {
|
|
900
|
+
id,
|
|
901
|
+
origin,
|
|
902
|
+
element,
|
|
903
|
+
minColumns: readConstraint(element.dataset.dashboardMinColumns, origin.columns),
|
|
904
|
+
maxColumns: readConstraint(element.dataset.dashboardMaxColumns, origin.columns),
|
|
905
|
+
minRows: readConstraint(element.dataset.dashboardMinRows, origin.rows),
|
|
906
|
+
maxRows: readConstraint(element.dataset.dashboardMaxRows, origin.rows)
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
function getDashboardDropSiblings(target, movingIds) {
|
|
910
|
+
return Array.from(target.element.children).flatMap((child) => {
|
|
911
|
+
if (!(child instanceof HTMLElement)) return [];
|
|
912
|
+
if (!child.dataset.dashboardNode) return [];
|
|
913
|
+
if (movingIds.has(child.dataset.dashboardNodeId ?? "")) return [];
|
|
914
|
+
if (child.dataset.dashboardAddSlot !== void 0) return [];
|
|
915
|
+
const placement = readDashboardNodePlacement(child);
|
|
916
|
+
return placement ? [placement] : [];
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
function canSwapGridBlocker(target, movedPlacement, movingOrigin, blockers, remaining) {
|
|
920
|
+
if (blockers.length !== 1) return false;
|
|
921
|
+
const blocker = blockers[0];
|
|
922
|
+
for (let row = movingOrigin.row; row <= movingOrigin.row + movingOrigin.rows - blocker.rows; row += 1) for (let column = movingOrigin.column; column <= movingOrigin.column + movingOrigin.columns - blocker.columns; column += 1) {
|
|
923
|
+
const candidate = {
|
|
924
|
+
column,
|
|
925
|
+
row,
|
|
926
|
+
columns: blocker.columns,
|
|
927
|
+
rows: blocker.rows
|
|
928
|
+
};
|
|
929
|
+
if (candidate.column + candidate.columns <= target.columns && candidate.row + candidate.rows <= target.rows && !placementsOverlap(candidate, movedPlacement) && !remaining.some((placement) => placementsOverlap(candidate, placement))) return true;
|
|
930
|
+
}
|
|
931
|
+
return false;
|
|
932
|
+
}
|
|
933
|
+
function getDashboardDropStatus(target, items, movingIds, sourceParentId, movingOrigins) {
|
|
934
|
+
if (target.kind === "root") return "valid";
|
|
935
|
+
const siblings = getDashboardDropSiblings(target, movingIds);
|
|
936
|
+
if (target.kind === "horizontal-stack") return siblings.reduce((total, sibling) => total + sibling.columns, 0) + items.reduce((total, item) => total + item.placement.columns, 0) <= target.columns && items.every((item) => item.placement.rows <= target.rows) ? "valid" : "danger";
|
|
937
|
+
if (target.kind === "vertical-stack") return siblings.reduce((total, sibling) => total + sibling.rows, 0) + items.reduce((total, item) => total + item.placement.rows, 0) <= target.rows ? "valid" : "danger";
|
|
938
|
+
const blockers = siblings.filter((sibling) => items.some((item) => placementsOverlap(sibling, item.placement)));
|
|
939
|
+
if (blockers.length === 0) return "valid";
|
|
940
|
+
if (target.parentId !== sourceParentId || items.length !== 1) return "danger";
|
|
941
|
+
const remaining = siblings.filter((sibling) => !blockers.includes(sibling));
|
|
942
|
+
return canSwapGridBlocker(target, items[0].placement, movingOrigins[0], blockers, remaining) ? "valid" : "danger";
|
|
943
|
+
}
|
|
944
|
+
function getDashboardDropPreviewStyle(target, placement, movingElement, metrics, movingIds) {
|
|
945
|
+
if (target.kind === "root") {
|
|
946
|
+
const rootRect = target.element.getBoundingClientRect();
|
|
947
|
+
const siblings = Array.from(target.element.children).filter((child) => child instanceof HTMLElement && child.dataset.dashboardNode === "container" && !movingIds.has(child.dataset.dashboardNodeId ?? ""));
|
|
948
|
+
const index = clamp(placement.row, 0, siblings.length);
|
|
949
|
+
const previousRect = siblings[index - 1]?.getBoundingClientRect();
|
|
950
|
+
const nextRect = siblings[index]?.getBoundingClientRect();
|
|
951
|
+
return {
|
|
952
|
+
left: 0,
|
|
953
|
+
top: nextRect ? nextRect.top - rootRect.top : previousRect ? previousRect.bottom - rootRect.top + metrics.rowGap : 0,
|
|
954
|
+
width: rootRect.width,
|
|
955
|
+
height: movingElement.getBoundingClientRect().height
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
return {
|
|
959
|
+
inset: 0,
|
|
960
|
+
gridColumn: target.kind === "vertical-stack" ? "1 / -1" : `${placement.column + 1} / span ${placement.columns}`,
|
|
961
|
+
gridRow: target.kind === "horizontal-stack" ? `1 / span ${placement.rows}` : `${placement.row + 1} / span ${placement.rows}`
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function getDashboardGestureItems(movingElement, movingId, movingOrigin, isSelected) {
|
|
965
|
+
const ownItem = getDashboardGestureItem(movingId, movingOrigin, movingElement);
|
|
966
|
+
if (!isSelected || !movingElement.parentElement) return [ownItem];
|
|
967
|
+
return [ownItem, ...Array.from(movingElement.parentElement.children).flatMap((child) => {
|
|
968
|
+
if (!(child instanceof HTMLElement)) return [];
|
|
969
|
+
const id = child.dataset.dashboardNodeId;
|
|
970
|
+
if (!id || id === movingId || child.dataset.selected === void 0) return [];
|
|
971
|
+
const origin = readDashboardNodePlacement(child);
|
|
972
|
+
return origin ? [getDashboardGestureItem(id, origin, child)] : [];
|
|
973
|
+
})];
|
|
974
|
+
}
|
|
975
|
+
function getDashboardGesturePlacements(target, gesture, grabbedPlacement) {
|
|
976
|
+
if (gesture.items.length === 1) return [{
|
|
977
|
+
id: gesture.items[0].id,
|
|
978
|
+
placement: grabbedPlacement
|
|
979
|
+
}];
|
|
980
|
+
if (target.kind === "root") {
|
|
981
|
+
if (gesture.items.some((item) => item.element.dataset.dashboardNode !== "container")) return null;
|
|
982
|
+
return gesture.items.map((item, index) => ({
|
|
983
|
+
id: item.id,
|
|
984
|
+
placement: {
|
|
985
|
+
...item.origin,
|
|
986
|
+
column: 0,
|
|
987
|
+
row: grabbedPlacement.row + index,
|
|
988
|
+
columns: 12
|
|
989
|
+
}
|
|
990
|
+
}));
|
|
991
|
+
}
|
|
992
|
+
const columnDelta = grabbedPlacement.column - gesture.origin.column;
|
|
993
|
+
const rowDelta = grabbedPlacement.row - gesture.origin.row;
|
|
994
|
+
const placements = gesture.items.map((item) => ({
|
|
995
|
+
id: item.id,
|
|
996
|
+
placement: {
|
|
997
|
+
...item.origin,
|
|
998
|
+
column: target.kind === "vertical-stack" ? 0 : item.origin.column + columnDelta,
|
|
999
|
+
row: target.kind === "horizontal-stack" ? 0 : item.origin.row + rowDelta,
|
|
1000
|
+
columns: Math.min(target.kind === "vertical-stack" ? item.maxColumns : item.origin.columns, target.columns),
|
|
1001
|
+
rows: Math.min(target.kind === "horizontal-stack" ? item.maxRows : item.origin.rows, target.rows)
|
|
1002
|
+
}
|
|
1003
|
+
}));
|
|
1004
|
+
if (placements.some((item, index) => {
|
|
1005
|
+
const constraints = gesture.items[index];
|
|
1006
|
+
return item.placement.columns < constraints.minColumns || item.placement.rows < constraints.minRows;
|
|
1007
|
+
})) return null;
|
|
1008
|
+
const minimumColumn = Math.min(...placements.map((item) => item.placement.column));
|
|
1009
|
+
const minimumRow = Math.min(...placements.map((item) => item.placement.row));
|
|
1010
|
+
const maximumColumn = Math.max(...placements.map((item) => item.placement.column + item.placement.columns));
|
|
1011
|
+
const maximumRow = Math.max(...placements.map((item) => item.placement.row + item.placement.rows));
|
|
1012
|
+
const groupColumns = maximumColumn - minimumColumn;
|
|
1013
|
+
const groupRows = maximumRow - minimumRow;
|
|
1014
|
+
if (groupColumns > target.columns || groupRows > target.rows) return null;
|
|
1015
|
+
const shiftColumn = minimumColumn < 0 ? -minimumColumn : maximumColumn > target.columns ? target.columns - maximumColumn : 0;
|
|
1016
|
+
const shiftRow = minimumRow < 0 ? -minimumRow : maximumRow > target.rows ? target.rows - maximumRow : 0;
|
|
1017
|
+
return placements.map((item) => ({
|
|
1018
|
+
...item,
|
|
1019
|
+
placement: {
|
|
1020
|
+
...item.placement,
|
|
1021
|
+
column: item.placement.column + shiftColumn,
|
|
1022
|
+
row: item.placement.row + shiftRow
|
|
1023
|
+
}
|
|
1024
|
+
}));
|
|
1025
|
+
}
|
|
1026
|
+
function createDashboardDropPreviews(target, items, gestureItems, metrics, sourceParentId) {
|
|
1027
|
+
const movingIds = new Set(items.map((item) => item.id));
|
|
1028
|
+
const status = getDashboardDropStatus(target, items, movingIds, sourceParentId, gestureItems.map((item) => item.origin));
|
|
1029
|
+
let rootOffset = 0;
|
|
1030
|
+
const addSlotPlacement = Array.from(target.element.children).flatMap((child) => {
|
|
1031
|
+
if (!(child instanceof HTMLElement)) return [];
|
|
1032
|
+
if (child.dataset.dashboardAddSlot === void 0) return [];
|
|
1033
|
+
const placement = readDashboardNodePlacement(child);
|
|
1034
|
+
return placement ? [placement] : [];
|
|
1035
|
+
})[0];
|
|
1036
|
+
return items.map((item) => {
|
|
1037
|
+
const gestureItem = gestureItems.find((candidate) => candidate.id === item.id);
|
|
1038
|
+
const style = getDashboardDropPreviewStyle(target, item.placement, gestureItem?.element ?? gestureItems[0].element, metrics, movingIds);
|
|
1039
|
+
if (target.kind === "root") {
|
|
1040
|
+
style.top = Number(style.top ?? 0) + rootOffset;
|
|
1041
|
+
rootOffset += Number(style.height ?? 0) + metrics.rowGap;
|
|
1042
|
+
}
|
|
1043
|
+
return {
|
|
1044
|
+
id: item.id,
|
|
1045
|
+
target: target.element,
|
|
1046
|
+
placement: item.placement,
|
|
1047
|
+
status,
|
|
1048
|
+
coversAddSlot: addSlotPlacement !== void 0 && placementsOverlap(item.placement, addSlotPlacement),
|
|
1049
|
+
style
|
|
1050
|
+
};
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
function useDashboardDropPreview() {
|
|
1054
|
+
const [preview, setPreview] = useState([]);
|
|
1055
|
+
return [preview, useEvent((next) => {
|
|
1056
|
+
setPreview(next ?? []);
|
|
1057
|
+
})];
|
|
1058
|
+
}
|
|
1059
|
+
function renderDashboardDropPreview(previews) {
|
|
1060
|
+
return previews.map((preview) => createPortal(/* @__PURE__ */ jsx(DropPlaceholderElement, {
|
|
1061
|
+
"aria-hidden": "true",
|
|
1062
|
+
"data-dashboard-drop-status": preview.status,
|
|
1063
|
+
"data-dashboard-drop-item-id": preview.id,
|
|
1064
|
+
"data-dashboard-drop-covers-add-slot": preview.coversAddSlot || void 0,
|
|
1065
|
+
mods: { danger: preview.status === "danger" },
|
|
1066
|
+
style: preview.style
|
|
1067
|
+
}, preview.id), preview.target, preview.id));
|
|
1068
|
+
}
|
|
1069
|
+
function getDashboardDescendantContainerDepth(children) {
|
|
1070
|
+
return Children.toArray(children).reduce((maximumDepth, child) => {
|
|
1071
|
+
if (!isValidElement(child)) return maximumDepth;
|
|
1072
|
+
if (child.type === DashboardGrid || child.type === DashboardHorizontalStack || child.type === DashboardVerticalStack || child.type === DashboardTabs) {
|
|
1073
|
+
const descendantDepth = getDashboardDescendantContainerDepth(child.props.children);
|
|
1074
|
+
return Math.max(maximumDepth, 1 + descendantDepth);
|
|
1075
|
+
}
|
|
1076
|
+
if (child.type === DashboardTab) return Math.max(maximumDepth, getDashboardDescendantContainerDepth(child.props.children));
|
|
1077
|
+
return maximumDepth;
|
|
1078
|
+
}, 0);
|
|
1079
|
+
}
|
|
1080
|
+
function getContainerChildMinimum(kind, children, capacityColumns, capacityRows) {
|
|
1081
|
+
const placements = (kind === "tabs" ? Children.toArray(children).flatMap((tab) => {
|
|
1082
|
+
if (!isValidElement(tab)) return [];
|
|
1083
|
+
return Children.toArray(tab.props.children);
|
|
1084
|
+
}) : Children.toArray(children)).flatMap((child) => {
|
|
1085
|
+
if (!isValidElement(child)) return [];
|
|
1086
|
+
const props = child.props;
|
|
1087
|
+
if (props["data-dashboard-add-slot"] !== void 0) return [];
|
|
1088
|
+
return [normalizePlacement(props, capacityColumns, capacityRows)];
|
|
1089
|
+
});
|
|
1090
|
+
if (placements.length === 0) return {
|
|
1091
|
+
columns: 1,
|
|
1092
|
+
rows: 1
|
|
1093
|
+
};
|
|
1094
|
+
if (kind === "horizontal-stack") return {
|
|
1095
|
+
columns: Math.min(capacityColumns, placements.reduce((total, placement) => total + placement.columns, 0)),
|
|
1096
|
+
rows: Math.min(capacityRows, Math.max(...placements.map((placement) => placement.rows)))
|
|
1097
|
+
};
|
|
1098
|
+
if (kind === "vertical-stack") return {
|
|
1099
|
+
columns: Math.min(capacityColumns, Math.max(...placements.map((placement) => placement.columns))),
|
|
1100
|
+
rows: Math.min(capacityRows, placements.reduce((total, placement) => total + placement.rows, 0))
|
|
1101
|
+
};
|
|
1102
|
+
return {
|
|
1103
|
+
columns: Math.min(capacityColumns, Math.max(...placements.map((placement) => placement.column + placement.columns))),
|
|
1104
|
+
rows: Math.min(capacityRows, Math.max(...placements.map((placement) => placement.row + placement.rows)))
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
function hasContainerLayoutChildren(kind, children) {
|
|
1108
|
+
return (kind === "tabs" ? Children.toArray(children).flatMap((tab) => {
|
|
1109
|
+
if (!isValidElement(tab)) return [];
|
|
1110
|
+
return Children.toArray(tab.props.children);
|
|
1111
|
+
}) : Children.toArray(children)).some((child) => {
|
|
1112
|
+
if (!isValidElement(child)) return child !== null && child !== void 0;
|
|
1113
|
+
return child.props["data-dashboard-add-slot"] === void 0;
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
const DashboardContainerShell = forwardRef(function DashboardContainerShell(props, ref) {
|
|
1117
|
+
const { id, title, kind, content, isSelectable, isMovable = false, isResizable = false, minColumns = 1, maxColumns = 12, minRows = 1, maxRows, onPlacementChange, moveLabel, resizeLabel, onSettingsPress, settingsLabel, onDeletePress, deleteLabel, column, row, columns, rows = 1, children, mods, styles: explicitStyles, style, "aria-label": ariaLabel, ...otherProps } = props;
|
|
1118
|
+
const { t } = useI18n();
|
|
1119
|
+
const metrics = useContext(DashboardMetricsContext);
|
|
1120
|
+
const localRef = useRef(null);
|
|
1121
|
+
const combinedRef = useCombinedRefs(ref, localRef);
|
|
1122
|
+
const moveSessionRef = useRef(null);
|
|
1123
|
+
const resizeSessionRef = useRef(null);
|
|
1124
|
+
const pointerStartRef = useRef({
|
|
1125
|
+
clientX: 0,
|
|
1126
|
+
clientY: 0
|
|
1127
|
+
});
|
|
1128
|
+
const [isMoving, setIsMoving] = useState(false);
|
|
1129
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
1130
|
+
const [dropPreview, updateDropPreview] = useDashboardDropPreview();
|
|
1131
|
+
const node = useDashboardNodeInteraction({
|
|
1132
|
+
id,
|
|
1133
|
+
isContainer: true,
|
|
1134
|
+
isSelectable
|
|
1135
|
+
});
|
|
1136
|
+
useLayoutEffect$1(() => {
|
|
1137
|
+
node.editing.markArriving(id);
|
|
1138
|
+
}, [id, node.editing.markArriving]);
|
|
1139
|
+
if (node.containerDepth > 3) throw new Error(`Dashboard container "${id}" exceeds the maximum nesting depth of 3.`);
|
|
1140
|
+
const styles = {
|
|
1141
|
+
...extractStyles(props, CONTAINER_STYLES),
|
|
1142
|
+
...explicitStyles
|
|
1143
|
+
};
|
|
1144
|
+
const normalizedPlacement = node.tree.parentKind === "root" ? {
|
|
1145
|
+
column: 0,
|
|
1146
|
+
row: clampRowOrigin(row),
|
|
1147
|
+
columns: 12,
|
|
1148
|
+
rows: clampRows(rows, 1)
|
|
1149
|
+
} : normalizePlacement({
|
|
1150
|
+
column,
|
|
1151
|
+
row,
|
|
1152
|
+
columns,
|
|
1153
|
+
rows
|
|
1154
|
+
}, node.tree.parentColumns, node.tree.parentRows);
|
|
1155
|
+
const placementStyle = getPlacementStyle(node.tree, normalizedPlacement);
|
|
1156
|
+
const childMinimum = getContainerChildMinimum(kind, children, normalizedPlacement.columns, normalizedPlacement.rows);
|
|
1157
|
+
const descendantContainerDepth = getDashboardDescendantContainerDepth(children);
|
|
1158
|
+
const isEmpty = !hasContainerLayoutChildren(kind, children);
|
|
1159
|
+
const columnLimit = node.tree.parentColumns;
|
|
1160
|
+
const rowLimit = node.tree.parentKind === "root" ? Math.max(childMinimum.rows, clampRows(maxRows, Math.max(12, normalizedPlacement.rows))) : node.tree.parentRows;
|
|
1161
|
+
const resolvedMinColumns = clamp(Math.max(clampSpan(minColumns, 1), childMinimum.columns), 1, columnLimit);
|
|
1162
|
+
const resolvedMaxColumns = clamp(clampSpan(maxColumns, columnLimit), resolvedMinColumns, columnLimit);
|
|
1163
|
+
const resolvedMinRows = clamp(Math.max(clampRows(minRows, 1), childMinimum.rows), 1, rowLimit);
|
|
1164
|
+
const resolvedMaxRows = clamp(clampRows(maxRows, rowLimit), resolvedMinRows, rowLimit);
|
|
1165
|
+
const canMove = isMovable && !!onPlacementChange;
|
|
1166
|
+
const canMoveColumns = canMove && node.tree.parentKind !== "root" && node.tree.parentKind !== "vertical-stack";
|
|
1167
|
+
const canMoveRows = canMove && node.tree.parentKind !== "horizontal-stack";
|
|
1168
|
+
const canResizeColumns = isResizable && !!onPlacementChange && node.tree.parentKind !== "root" && node.tree.parentKind !== "vertical-stack" && resolvedMaxColumns > resolvedMinColumns;
|
|
1169
|
+
const canResizeRows = isResizable && !!onPlacementChange && node.tree.parentKind !== "horizontal-stack" && resolvedMaxRows > resolvedMinRows;
|
|
1170
|
+
const canResize = canResizeColumns || canResizeRows;
|
|
1171
|
+
const resizeAxis = canResizeColumns ? canResizeRows ? "both" : "x" : "y";
|
|
1172
|
+
const shouldRenderTitle = kind === "tabs" && !!title;
|
|
1173
|
+
const label = ariaLabel ?? (typeof title === "string" ? title : id);
|
|
1174
|
+
const baseProps = filterBaseProps(otherProps, {
|
|
1175
|
+
eventProps: true,
|
|
1176
|
+
labelable: true
|
|
1177
|
+
});
|
|
1178
|
+
const reportPlacement = useEvent((placement, reason, phase, input, sourceParentId = node.tree.layoutParentId, destinationParentId = sourceParentId, items) => {
|
|
1179
|
+
onPlacementChange?.(placement, {
|
|
1180
|
+
reason,
|
|
1181
|
+
phase,
|
|
1182
|
+
input,
|
|
1183
|
+
...destinationParentId !== sourceParentId && {
|
|
1184
|
+
sourceParentId,
|
|
1185
|
+
destinationParentId
|
|
1186
|
+
},
|
|
1187
|
+
...items && items.length > 1 && { items }
|
|
1188
|
+
});
|
|
1189
|
+
});
|
|
1190
|
+
const createGesture = useEvent((input, reason) => {
|
|
1191
|
+
const columnWidth = ((localRef.current?.parentElement?.getBoundingClientRect().width ?? 0) - metrics.columnGap * (node.tree.parentColumns - 1)) / node.tree.parentColumns + metrics.columnGap;
|
|
1192
|
+
const ownHeight = localRef.current?.getBoundingClientRect().height ?? 0;
|
|
1193
|
+
const ownRect = localRef.current?.getBoundingClientRect();
|
|
1194
|
+
const pointerX = pointerStartRef.current.clientX;
|
|
1195
|
+
const pointerY = pointerStartRef.current.clientY;
|
|
1196
|
+
const gestureItems = reason === "move" && input === "pointer" && localRef.current ? getDashboardGestureItems(localRef.current, id, normalizedPlacement, node.isSelected) : localRef.current ? [getDashboardGestureItem(id, normalizedPlacement, localRef.current)] : [];
|
|
1197
|
+
return {
|
|
1198
|
+
origin: normalizedPlacement,
|
|
1199
|
+
current: normalizedPlacement,
|
|
1200
|
+
currentItems: gestureItems.map((item) => ({
|
|
1201
|
+
id: item.id,
|
|
1202
|
+
placement: item.origin
|
|
1203
|
+
})),
|
|
1204
|
+
sourceParentId: node.tree.layoutParentId,
|
|
1205
|
+
destinationParentId: node.tree.layoutParentId,
|
|
1206
|
+
deltaX: 0,
|
|
1207
|
+
deltaY: 0,
|
|
1208
|
+
pointerX,
|
|
1209
|
+
pointerY,
|
|
1210
|
+
grabOffsetX: ownRect ? pointerX - ownRect.left : 0,
|
|
1211
|
+
grabOffsetY: ownRect ? pointerY - ownRect.top : 0,
|
|
1212
|
+
keyboardColumns: 0,
|
|
1213
|
+
keyboardRows: 0,
|
|
1214
|
+
columnStep: Math.max(1, columnWidth),
|
|
1215
|
+
rowStep: Math.max(1, reason === "move" && node.tree.parentKind === "root" ? ownHeight + metrics.rowGap : metrics.rowHeight + metrics.rowGap),
|
|
1216
|
+
input,
|
|
1217
|
+
canCommit: true,
|
|
1218
|
+
items: gestureItems
|
|
1219
|
+
};
|
|
1220
|
+
});
|
|
1221
|
+
const updateGestureDeltas = useEvent((gesture, deltaX, deltaY, input) => {
|
|
1222
|
+
gesture.input = input;
|
|
1223
|
+
if (input === "keyboard") {
|
|
1224
|
+
gesture.keyboardColumns += Math.sign(deltaX);
|
|
1225
|
+
gesture.keyboardRows += Math.sign(deltaY);
|
|
1226
|
+
} else {
|
|
1227
|
+
gesture.deltaX += deltaX;
|
|
1228
|
+
gesture.deltaY += deltaY;
|
|
1229
|
+
}
|
|
1230
|
+
return {
|
|
1231
|
+
columns: input === "keyboard" ? gesture.keyboardColumns : Math.round(gesture.deltaX / gesture.columnStep),
|
|
1232
|
+
rows: input === "keyboard" ? gesture.keyboardRows : Math.round(gesture.deltaY / gesture.rowStep)
|
|
1233
|
+
};
|
|
1234
|
+
});
|
|
1235
|
+
const { moveProps } = useMove({
|
|
1236
|
+
onMoveStart(event) {
|
|
1237
|
+
if (!canMove) return;
|
|
1238
|
+
if (!node.isSelected) node.selectSelf(false);
|
|
1239
|
+
node.editing.startMoving(id);
|
|
1240
|
+
setIsMoving(true);
|
|
1241
|
+
updateDropPreview(null);
|
|
1242
|
+
moveSessionRef.current = createGesture(event.pointerType === "keyboard" ? "keyboard" : "pointer", "move");
|
|
1243
|
+
},
|
|
1244
|
+
onMove(event) {
|
|
1245
|
+
const gesture = moveSessionRef.current;
|
|
1246
|
+
if (!canMove || !gesture) return;
|
|
1247
|
+
const input = event.pointerType === "keyboard" ? "keyboard" : "pointer";
|
|
1248
|
+
const delta = updateGestureDeltas(gesture, input === "pointer" || canMoveColumns ? event.deltaX : 0, input === "pointer" || canMoveRows ? event.deltaY : 0, input);
|
|
1249
|
+
let nextPlacement = {
|
|
1250
|
+
...gesture.origin,
|
|
1251
|
+
column: canMoveColumns ? clamp(gesture.origin.column + delta.columns, 0, node.tree.parentColumns - gesture.origin.columns) : gesture.origin.column,
|
|
1252
|
+
row: canMoveRows ? node.tree.parentKind === "root" ? Math.max(0, gesture.origin.row + delta.rows) : clamp(gesture.origin.row + delta.rows, 0, node.tree.parentRows - gesture.origin.rows) : gesture.origin.row
|
|
1253
|
+
};
|
|
1254
|
+
let destinationParentId = gesture.sourceParentId;
|
|
1255
|
+
let currentItems = [{
|
|
1256
|
+
id,
|
|
1257
|
+
placement: nextPlacement
|
|
1258
|
+
}];
|
|
1259
|
+
if (input === "pointer" && localRef.current) {
|
|
1260
|
+
const target = findDashboardDropTarget(localRef.current, gesture.pointerX + gesture.deltaX, gesture.pointerY + gesture.deltaY, id, true, Math.max(0, 2 - descendantContainerDepth));
|
|
1261
|
+
let preview = null;
|
|
1262
|
+
if (target) {
|
|
1263
|
+
if (target.parentId === gesture.sourceParentId) {
|
|
1264
|
+
currentItems = getDashboardGesturePlacements(target, gesture, nextPlacement) ?? [];
|
|
1265
|
+
preview = currentItems.length ? createDashboardDropPreviews(target, currentItems, gesture.items, metrics, gesture.sourceParentId) : null;
|
|
1266
|
+
} else if (kind !== "tabs" || target.kind === "root") {
|
|
1267
|
+
const crossParentPlacement = getCrossParentPlacement(target, gesture, resolvedMinColumns, resolvedMinRows, true, metrics);
|
|
1268
|
+
if (crossParentPlacement) {
|
|
1269
|
+
currentItems = getDashboardGesturePlacements(target, gesture, crossParentPlacement) ?? [];
|
|
1270
|
+
if (currentItems.length) {
|
|
1271
|
+
nextPlacement = currentItems.find((item) => item.id === id)?.placement ?? crossParentPlacement;
|
|
1272
|
+
destinationParentId = target.parentId;
|
|
1273
|
+
preview = createDashboardDropPreviews(target, currentItems, gesture.items, metrics, gesture.sourceParentId);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
updateDropPreview(preview);
|
|
1279
|
+
gesture.canCommit = !!preview?.length && preview.every((item) => item.status === "valid");
|
|
1280
|
+
if (!preview?.length) return;
|
|
1281
|
+
} else {
|
|
1282
|
+
updateDropPreview(null);
|
|
1283
|
+
gesture.canCommit = true;
|
|
1284
|
+
}
|
|
1285
|
+
if (isSamePlacement(nextPlacement, gesture.current) && destinationParentId === gesture.destinationParentId) return;
|
|
1286
|
+
gesture.current = nextPlacement;
|
|
1287
|
+
gesture.currentItems = currentItems;
|
|
1288
|
+
gesture.destinationParentId = destinationParentId;
|
|
1289
|
+
reportPlacement(nextPlacement, "move", "preview", gesture.input, gesture.sourceParentId, destinationParentId, currentItems);
|
|
1290
|
+
},
|
|
1291
|
+
onMoveEnd() {
|
|
1292
|
+
const gesture = moveSessionRef.current;
|
|
1293
|
+
moveSessionRef.current = null;
|
|
1294
|
+
node.editing.stopMoving(id);
|
|
1295
|
+
setIsMoving(false);
|
|
1296
|
+
updateDropPreview(null);
|
|
1297
|
+
if (!canMove || !gesture || !gesture.canCommit || isSamePlacement(gesture.current, gesture.origin) && gesture.destinationParentId === gesture.sourceParentId) return;
|
|
1298
|
+
reportPlacement(gesture.current, "move", "commit", gesture.input, gesture.sourceParentId, gesture.destinationParentId, gesture.currentItems);
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
const surfaceMoveProps = getSurfaceMoveProps(moveProps, canMove, localRef, (clientX, clientY) => {
|
|
1302
|
+
pointerStartRef.current = {
|
|
1303
|
+
clientX,
|
|
1304
|
+
clientY
|
|
1305
|
+
};
|
|
1306
|
+
});
|
|
1307
|
+
const { moveProps: resizeProps } = useMove({
|
|
1308
|
+
onMoveStart(event) {
|
|
1309
|
+
if (!canResize) return;
|
|
1310
|
+
node.selectSelf(false);
|
|
1311
|
+
setIsResizing(true);
|
|
1312
|
+
resizeSessionRef.current = createGesture(event.pointerType === "keyboard" ? "keyboard" : "pointer", "resize");
|
|
1313
|
+
},
|
|
1314
|
+
onMove(event) {
|
|
1315
|
+
const gesture = resizeSessionRef.current;
|
|
1316
|
+
if (!canResize || !gesture) return;
|
|
1317
|
+
gesture.input = event.pointerType === "keyboard" ? "keyboard" : "pointer";
|
|
1318
|
+
if (gesture.input === "keyboard") {
|
|
1319
|
+
gesture.keyboardColumns += canResizeColumns ? Math.sign(event.deltaX) : 0;
|
|
1320
|
+
gesture.keyboardRows += canResizeRows ? Math.sign(event.deltaY) : 0;
|
|
1321
|
+
} else {
|
|
1322
|
+
gesture.deltaX += canResizeColumns ? event.deltaX : 0;
|
|
1323
|
+
gesture.deltaY += canResizeRows ? event.deltaY : 0;
|
|
1324
|
+
}
|
|
1325
|
+
const columnDelta = gesture.input === "keyboard" ? gesture.keyboardColumns : Math.round(gesture.deltaX / gesture.columnStep);
|
|
1326
|
+
const rowDelta = gesture.input === "keyboard" ? gesture.keyboardRows : Math.round(gesture.deltaY / gesture.rowStep);
|
|
1327
|
+
const maxColumnsAtOrigin = Math.min(resolvedMaxColumns, node.tree.parentColumns - gesture.origin.column);
|
|
1328
|
+
const maxRowsAtOrigin = node.tree.parentKind === "root" ? resolvedMaxRows : Math.min(resolvedMaxRows, node.tree.parentRows - gesture.origin.row);
|
|
1329
|
+
const nextPlacement = {
|
|
1330
|
+
...gesture.origin,
|
|
1331
|
+
columns: canResizeColumns ? clamp(gesture.origin.columns + columnDelta, resolvedMinColumns, maxColumnsAtOrigin) : gesture.origin.columns,
|
|
1332
|
+
rows: canResizeRows ? clamp(gesture.origin.rows + rowDelta, resolvedMinRows, maxRowsAtOrigin) : gesture.origin.rows
|
|
1333
|
+
};
|
|
1334
|
+
if (isSamePlacement(nextPlacement, gesture.current)) return;
|
|
1335
|
+
gesture.current = nextPlacement;
|
|
1336
|
+
reportPlacement(nextPlacement, "resize", "preview", gesture.input);
|
|
1337
|
+
},
|
|
1338
|
+
onMoveEnd() {
|
|
1339
|
+
const gesture = resizeSessionRef.current;
|
|
1340
|
+
resizeSessionRef.current = null;
|
|
1341
|
+
setIsResizing(false);
|
|
1342
|
+
if (!canResize || !gesture || isSamePlacement(gesture.current, gesture.origin)) return;
|
|
1343
|
+
reportPlacement(gesture.current, "resize", "commit", gesture.input);
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
const handleSettingsPress = useEvent((event) => {
|
|
1347
|
+
node.selectSelf(false);
|
|
1348
|
+
onSettingsPress?.(event);
|
|
1349
|
+
});
|
|
1350
|
+
const handleDeletePress = useEvent((event) => {
|
|
1351
|
+
node.selectSelf(false);
|
|
1352
|
+
onDeletePress?.(event);
|
|
1353
|
+
});
|
|
1354
|
+
const resolvedMods = {
|
|
1355
|
+
...mods,
|
|
1356
|
+
depth: String(node.containerDepth),
|
|
1357
|
+
titled: shouldRenderTitle,
|
|
1358
|
+
selected: node.isSelected,
|
|
1359
|
+
arriving: node.editing.arrivingIds.has(id),
|
|
1360
|
+
hovered: node.isHovered,
|
|
1361
|
+
"focus-within": node.isFocusWithin,
|
|
1362
|
+
editing: node.editing.isEditing,
|
|
1363
|
+
empty: isEmpty,
|
|
1364
|
+
dragging: node.editing.movingId !== null,
|
|
1365
|
+
movable: canMove,
|
|
1366
|
+
moving: isMoving,
|
|
1367
|
+
resizing: isResizing
|
|
1368
|
+
};
|
|
1369
|
+
const ContainerResizeHandleElement = node.tree.parentKind === "root" ? TopLevelResizeHandleElement : ResizeHandleElement;
|
|
1370
|
+
return /* @__PURE__ */ jsxs(ContainerElement, {
|
|
1371
|
+
...mergeProps$1(baseProps, node.interactionProps, surfaceMoveProps),
|
|
1372
|
+
ref: combinedRef,
|
|
1373
|
+
role: "group",
|
|
1374
|
+
"aria-label": moveLabel ?? label,
|
|
1375
|
+
"aria-roledescription": t("dashboard.container", "Dashboard container"),
|
|
1376
|
+
tabIndex: node.canSelect || canMove ? 0 : void 0,
|
|
1377
|
+
"data-dashboard-node": "container",
|
|
1378
|
+
"data-dashboard-node-id": id,
|
|
1379
|
+
"data-dashboard-depth": node.containerDepth,
|
|
1380
|
+
"data-dashboard-column": normalizedPlacement.column,
|
|
1381
|
+
"data-dashboard-row": normalizedPlacement.row,
|
|
1382
|
+
"data-dashboard-columns": normalizedPlacement.columns,
|
|
1383
|
+
"data-dashboard-rows": normalizedPlacement.rows,
|
|
1384
|
+
"data-dashboard-min-columns": resolvedMinColumns,
|
|
1385
|
+
"data-dashboard-max-columns": Math.max(resolvedMinColumns, clampSpan(maxColumns, 12)),
|
|
1386
|
+
"data-dashboard-min-rows": resolvedMinRows,
|
|
1387
|
+
"data-dashboard-max-rows": maxRows === void 0 ? Number.MAX_SAFE_INTEGER : Math.max(resolvedMinRows, clampRows(maxRows, resolvedMinRows)),
|
|
1388
|
+
"data-selected": node.isSelected || void 0,
|
|
1389
|
+
"data-arriving": node.editing.arrivingIds.has(id) || void 0,
|
|
1390
|
+
"data-moving": isMoving || void 0,
|
|
1391
|
+
"data-resizing": isResizing || void 0,
|
|
1392
|
+
"data-dashboard-empty": isEmpty || void 0,
|
|
1393
|
+
mods: resolvedMods,
|
|
1394
|
+
styles,
|
|
1395
|
+
style: {
|
|
1396
|
+
...placementStyle,
|
|
1397
|
+
...style
|
|
1398
|
+
},
|
|
1399
|
+
children: [
|
|
1400
|
+
shouldRenderTitle ? /* @__PURE__ */ jsx(ContainerHeaderElement, {
|
|
1401
|
+
"data-dashboard-drag-handle": "",
|
|
1402
|
+
children: title
|
|
1403
|
+
}) : null,
|
|
1404
|
+
content,
|
|
1405
|
+
onSettingsPress || onDeletePress ? /* @__PURE__ */ jsxs(NodeActionsElement, {
|
|
1406
|
+
"aria-hidden": !node.isSelected || void 0,
|
|
1407
|
+
mods: resolvedMods,
|
|
1408
|
+
"data-dashboard-container-actions": "",
|
|
1409
|
+
children: [onDeletePress ? /* @__PURE__ */ jsx(Button, {
|
|
1410
|
+
size: "small",
|
|
1411
|
+
theme: "danger",
|
|
1412
|
+
radius: "round",
|
|
1413
|
+
icon: /* @__PURE__ */ jsx(TrashIcon, {}),
|
|
1414
|
+
"aria-label": deleteLabel ?? t("dashboard.deleteContainer", "Delete {{container}}", { container: label }),
|
|
1415
|
+
tabIndex: node.isSelected ? void 0 : -1,
|
|
1416
|
+
onPress: handleDeletePress
|
|
1417
|
+
}) : null, onSettingsPress ? /* @__PURE__ */ jsx(Button, {
|
|
1418
|
+
size: "small",
|
|
1419
|
+
type: "primary",
|
|
1420
|
+
radius: "round",
|
|
1421
|
+
icon: /* @__PURE__ */ jsx(SettingsIcon, {}),
|
|
1422
|
+
"aria-label": settingsLabel ?? t("dashboard.settingsContainer", "Settings for {{container}}", { container: label }),
|
|
1423
|
+
tabIndex: node.isSelected ? void 0 : -1,
|
|
1424
|
+
onPress: handleSettingsPress
|
|
1425
|
+
}) : null]
|
|
1426
|
+
}) : null,
|
|
1427
|
+
canResize ? /* @__PURE__ */ jsx(ContainerResizeHandleElement, {
|
|
1428
|
+
...resizeProps,
|
|
1429
|
+
type: "button",
|
|
1430
|
+
"aria-label": resizeLabel ?? t("dashboard.resizeContainer", "Resize dashboard container"),
|
|
1431
|
+
"data-dashboard-container-resize-handle": "",
|
|
1432
|
+
"data-dashboard-resize-axis": resizeAxis,
|
|
1433
|
+
"data-dashboard-no-select": "",
|
|
1434
|
+
"aria-hidden": !node.isSelected || void 0,
|
|
1435
|
+
tabIndex: node.isSelected ? void 0 : -1,
|
|
1436
|
+
mods: {
|
|
1437
|
+
...resolvedMods,
|
|
1438
|
+
axis: resizeAxis,
|
|
1439
|
+
corner: resizeAxis === "both"
|
|
1440
|
+
},
|
|
1441
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1442
|
+
"data-element": "Icon",
|
|
1443
|
+
children: resizeAxis === "both" ? /* @__PURE__ */ jsx(CornerResizeGripElement, {}) : /* @__PURE__ */ jsx(GripVerticalIcon, { size: "1.5x" })
|
|
1444
|
+
})
|
|
1445
|
+
}) : null,
|
|
1446
|
+
renderDashboardDropPreview(dropPreview)
|
|
1447
|
+
]
|
|
1448
|
+
});
|
|
1449
|
+
});
|
|
1450
|
+
function DashboardContainer(kind, props, ref) {
|
|
1451
|
+
const { id, columns, rows = 1, children } = props;
|
|
1452
|
+
const tree = useContext(DashboardTreeContext);
|
|
1453
|
+
const containerDepth = tree.containerDepth + 1;
|
|
1454
|
+
const resolvedColumns = tree.parentKind === "root" ? 12 : Math.min(clampSpan(columns, tree.parentColumns), tree.parentColumns);
|
|
1455
|
+
const resolvedRows = tree.parentKind === "root" ? clampRows(rows, 1) : Math.min(clampRows(rows, 1), tree.parentRows);
|
|
1456
|
+
const childTree = useMemo(() => ({
|
|
1457
|
+
containerDepth,
|
|
1458
|
+
parentKind: kind,
|
|
1459
|
+
parentId: id,
|
|
1460
|
+
layoutParentId: id,
|
|
1461
|
+
parentColumns: resolvedColumns,
|
|
1462
|
+
parentRows: resolvedRows,
|
|
1463
|
+
ancestorIds: [...tree.ancestorIds, id]
|
|
1464
|
+
}), [
|
|
1465
|
+
containerDepth,
|
|
1466
|
+
id,
|
|
1467
|
+
kind,
|
|
1468
|
+
resolvedColumns,
|
|
1469
|
+
resolvedRows,
|
|
1470
|
+
tree.ancestorIds
|
|
1471
|
+
]);
|
|
1472
|
+
const content = /* @__PURE__ */ jsx(DashboardTreeContext.Provider, {
|
|
1473
|
+
value: childTree,
|
|
1474
|
+
children: /* @__PURE__ */ jsx(DashboardContainerContent, {
|
|
1475
|
+
id,
|
|
1476
|
+
kind,
|
|
1477
|
+
columns: resolvedColumns,
|
|
1478
|
+
rows: resolvedRows,
|
|
1479
|
+
depth: containerDepth,
|
|
1480
|
+
ancestorIds: [...tree.ancestorIds, id],
|
|
1481
|
+
children
|
|
1482
|
+
})
|
|
1483
|
+
});
|
|
1484
|
+
return /* @__PURE__ */ jsx(DashboardContainerShell, {
|
|
1485
|
+
...props,
|
|
1486
|
+
ref,
|
|
1487
|
+
kind,
|
|
1488
|
+
content
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
const DashboardHorizontalStack = forwardRef(function DashboardHorizontalStack(props, ref) {
|
|
1492
|
+
return DashboardContainer("horizontal-stack", props, ref);
|
|
1493
|
+
});
|
|
1494
|
+
DashboardHorizontalStack.displayName = "DashboardHorizontalStack";
|
|
1495
|
+
const DashboardVerticalStack = forwardRef(function DashboardVerticalStack(props, ref) {
|
|
1496
|
+
return DashboardContainer("vertical-stack", props, ref);
|
|
1497
|
+
});
|
|
1498
|
+
DashboardVerticalStack.displayName = "DashboardVerticalStack";
|
|
1499
|
+
const DashboardGrid = forwardRef(function DashboardGrid(props, ref) {
|
|
1500
|
+
return DashboardContainer("grid", props, ref);
|
|
1501
|
+
});
|
|
1502
|
+
DashboardGrid.displayName = "DashboardGrid";
|
|
1503
|
+
const DashboardWidget = forwardRef(function DashboardWidget(props, ref) {
|
|
1504
|
+
const { id, children, isCard = false, isSelectable, onSettingsPress, settingsLabel, onDeletePress, deleteLabel, isMovable = false, isResizable = false, minColumns = 1, maxColumns = 12, minRows = 1, maxRows, onPlacementChange, moveLabel, resizeLabel, column, row, columns, rows, mods, styles: explicitStyles, style, "aria-label": ariaLabel, ...otherProps } = props;
|
|
1505
|
+
const { t } = useI18n();
|
|
1506
|
+
const metrics = useContext(DashboardMetricsContext);
|
|
1507
|
+
const localRef = useRef(null);
|
|
1508
|
+
const combinedRef = useCombinedRefs(ref, localRef);
|
|
1509
|
+
const moveSessionRef = useRef(null);
|
|
1510
|
+
const resizeSessionRef = useRef(null);
|
|
1511
|
+
const pointerStartRef = useRef({
|
|
1512
|
+
clientX: 0,
|
|
1513
|
+
clientY: 0
|
|
1514
|
+
});
|
|
1515
|
+
const [isMoving, setIsMoving] = useState(false);
|
|
1516
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
1517
|
+
const [dropPreview, updateDropPreview] = useDashboardDropPreview();
|
|
1518
|
+
const node = useDashboardNodeInteraction({
|
|
1519
|
+
id,
|
|
1520
|
+
isContainer: false,
|
|
1521
|
+
isSelectable
|
|
1522
|
+
});
|
|
1523
|
+
if (node.tree.parentKind === "root") throw new Error(`Dashboard.Widget "${id}" must be placed inside a Dashboard container.`);
|
|
1524
|
+
const resolvedMinColumns = clamp(clampSpan(minColumns, 1), 1, node.tree.parentColumns);
|
|
1525
|
+
const resolvedMaxColumns = clamp(clampSpan(maxColumns, node.tree.parentColumns), resolvedMinColumns, node.tree.parentColumns);
|
|
1526
|
+
const resolvedMinRows = Math.min(clampRows(minRows, 1), node.tree.parentRows);
|
|
1527
|
+
const resolvedMaxRows = clamp(clampRows(maxRows, node.tree.parentRows), resolvedMinRows, node.tree.parentRows);
|
|
1528
|
+
const normalizedPlacement = normalizePlacement({
|
|
1529
|
+
column,
|
|
1530
|
+
row,
|
|
1531
|
+
columns: clamp(clampSpan(columns, node.tree.parentColumns), resolvedMinColumns, resolvedMaxColumns),
|
|
1532
|
+
rows: clamp(clampRows(rows, 1), resolvedMinRows, resolvedMaxRows)
|
|
1533
|
+
}, node.tree.parentColumns, node.tree.parentRows);
|
|
1534
|
+
const canMove = isMovable && !!onPlacementChange;
|
|
1535
|
+
const canMoveColumns = canMove && node.tree.parentKind !== "vertical-stack";
|
|
1536
|
+
const canMoveRows = canMove && node.tree.parentKind !== "horizontal-stack";
|
|
1537
|
+
const canResizeColumns = isResizable && !!onPlacementChange && node.tree.parentKind !== "vertical-stack" && resolvedMaxColumns > resolvedMinColumns;
|
|
1538
|
+
const canResizeRows = isResizable && !!onPlacementChange && node.tree.parentKind !== "horizontal-stack" && resolvedMaxRows > resolvedMinRows;
|
|
1539
|
+
const canResize = canResizeColumns || canResizeRows;
|
|
1540
|
+
const resizeAxis = canResizeColumns ? canResizeRows ? "both" : "x" : "y";
|
|
1541
|
+
const styles = {
|
|
1542
|
+
...extractStyles(props, CONTAINER_STYLES),
|
|
1543
|
+
...explicitStyles
|
|
1544
|
+
};
|
|
1545
|
+
const placementStyle = getPlacementStyle(node.tree, normalizedPlacement);
|
|
1546
|
+
const baseProps = filterBaseProps(otherProps, {
|
|
1547
|
+
eventProps: true,
|
|
1548
|
+
labelable: true
|
|
1549
|
+
});
|
|
1550
|
+
const resolvedLabel = ariaLabel ?? id;
|
|
1551
|
+
const isAddSlot = props["data-dashboard-add-slot"] !== void 0;
|
|
1552
|
+
const resolvedMods = {
|
|
1553
|
+
...mods,
|
|
1554
|
+
"add-slot": isAddSlot,
|
|
1555
|
+
card: isCard,
|
|
1556
|
+
selected: node.isSelected,
|
|
1557
|
+
hovered: node.isHovered,
|
|
1558
|
+
"focus-within": node.isFocusWithin,
|
|
1559
|
+
editing: node.editing.isEditing,
|
|
1560
|
+
dragging: node.editing.movingId !== null,
|
|
1561
|
+
movable: canMove,
|
|
1562
|
+
moving: isMoving,
|
|
1563
|
+
resizing: isResizing
|
|
1564
|
+
};
|
|
1565
|
+
const reportPlacement = useEvent((placement, reason, phase, input, sourceParentId = node.tree.layoutParentId, destinationParentId = sourceParentId, items) => {
|
|
1566
|
+
onPlacementChange?.(placement, {
|
|
1567
|
+
reason,
|
|
1568
|
+
phase,
|
|
1569
|
+
input,
|
|
1570
|
+
...destinationParentId !== sourceParentId && {
|
|
1571
|
+
sourceParentId,
|
|
1572
|
+
destinationParentId
|
|
1573
|
+
},
|
|
1574
|
+
...items && items.length > 1 && { items }
|
|
1575
|
+
});
|
|
1576
|
+
});
|
|
1577
|
+
const createGesture = useEvent((input) => {
|
|
1578
|
+
const columnWidth = ((localRef.current?.parentElement?.getBoundingClientRect().width ?? 0) - metrics.columnGap * (node.tree.parentColumns - 1)) / node.tree.parentColumns + metrics.columnGap;
|
|
1579
|
+
const ownRect = localRef.current?.getBoundingClientRect();
|
|
1580
|
+
const pointerX = pointerStartRef.current.clientX;
|
|
1581
|
+
const pointerY = pointerStartRef.current.clientY;
|
|
1582
|
+
const gestureItems = input === "pointer" && localRef.current ? getDashboardGestureItems(localRef.current, id, normalizedPlacement, node.isSelected) : localRef.current ? [getDashboardGestureItem(id, normalizedPlacement, localRef.current)] : [];
|
|
1583
|
+
return {
|
|
1584
|
+
origin: normalizedPlacement,
|
|
1585
|
+
current: normalizedPlacement,
|
|
1586
|
+
currentItems: gestureItems.map((item) => ({
|
|
1587
|
+
id: item.id,
|
|
1588
|
+
placement: item.origin
|
|
1589
|
+
})),
|
|
1590
|
+
sourceParentId: node.tree.layoutParentId,
|
|
1591
|
+
destinationParentId: node.tree.layoutParentId,
|
|
1592
|
+
deltaX: 0,
|
|
1593
|
+
deltaY: 0,
|
|
1594
|
+
pointerX,
|
|
1595
|
+
pointerY,
|
|
1596
|
+
grabOffsetX: ownRect ? pointerX - ownRect.left : 0,
|
|
1597
|
+
grabOffsetY: ownRect ? pointerY - ownRect.top : 0,
|
|
1598
|
+
keyboardColumns: 0,
|
|
1599
|
+
keyboardRows: 0,
|
|
1600
|
+
columnStep: Math.max(1, columnWidth),
|
|
1601
|
+
rowStep: Math.max(1, metrics.rowHeight + metrics.rowGap),
|
|
1602
|
+
input,
|
|
1603
|
+
canCommit: true,
|
|
1604
|
+
items: gestureItems
|
|
1605
|
+
};
|
|
1606
|
+
});
|
|
1607
|
+
const updateGestureDeltas = useEvent((gesture, deltaX, deltaY, input) => {
|
|
1608
|
+
gesture.input = input;
|
|
1609
|
+
if (input === "keyboard") {
|
|
1610
|
+
gesture.keyboardColumns += Math.sign(deltaX);
|
|
1611
|
+
gesture.keyboardRows += Math.sign(deltaY);
|
|
1612
|
+
} else {
|
|
1613
|
+
gesture.deltaX += deltaX;
|
|
1614
|
+
gesture.deltaY += deltaY;
|
|
1615
|
+
}
|
|
1616
|
+
return {
|
|
1617
|
+
columns: input === "keyboard" ? gesture.keyboardColumns : Math.round(gesture.deltaX / gesture.columnStep),
|
|
1618
|
+
rows: input === "keyboard" ? gesture.keyboardRows : Math.round(gesture.deltaY / gesture.rowStep)
|
|
1619
|
+
};
|
|
1620
|
+
});
|
|
1621
|
+
const { moveProps } = useMove({
|
|
1622
|
+
onMoveStart(event) {
|
|
1623
|
+
if (!canMove) return;
|
|
1624
|
+
if (!node.isSelected) node.selectSelf(false);
|
|
1625
|
+
node.editing.startMoving(id);
|
|
1626
|
+
setIsMoving(true);
|
|
1627
|
+
updateDropPreview(null);
|
|
1628
|
+
moveSessionRef.current = createGesture(event.pointerType === "keyboard" ? "keyboard" : "pointer");
|
|
1629
|
+
},
|
|
1630
|
+
onMove(event) {
|
|
1631
|
+
const gesture = moveSessionRef.current;
|
|
1632
|
+
if (!canMove || !gesture) return;
|
|
1633
|
+
const input = event.pointerType === "keyboard" ? "keyboard" : "pointer";
|
|
1634
|
+
const delta = updateGestureDeltas(gesture, input === "pointer" || canMoveColumns ? event.deltaX : 0, input === "pointer" || canMoveRows ? event.deltaY : 0, input);
|
|
1635
|
+
let nextPlacement = {
|
|
1636
|
+
...gesture.origin,
|
|
1637
|
+
column: canMoveColumns ? clamp(gesture.origin.column + delta.columns, 0, node.tree.parentColumns - gesture.origin.columns) : gesture.origin.column,
|
|
1638
|
+
row: canMoveRows ? clamp(gesture.origin.row + delta.rows, 0, node.tree.parentRows - gesture.origin.rows) : gesture.origin.row
|
|
1639
|
+
};
|
|
1640
|
+
let destinationParentId = gesture.sourceParentId;
|
|
1641
|
+
let currentItems = [{
|
|
1642
|
+
id,
|
|
1643
|
+
placement: nextPlacement
|
|
1644
|
+
}];
|
|
1645
|
+
if (input === "pointer" && localRef.current) {
|
|
1646
|
+
const target = findDashboardDropTarget(localRef.current, gesture.pointerX + gesture.deltaX, gesture.pointerY + gesture.deltaY, id, false);
|
|
1647
|
+
let preview = null;
|
|
1648
|
+
if (target) if (target.parentId === gesture.sourceParentId) {
|
|
1649
|
+
currentItems = getDashboardGesturePlacements(target, gesture, nextPlacement) ?? [];
|
|
1650
|
+
preview = currentItems.length ? createDashboardDropPreviews(target, currentItems, gesture.items, metrics, gesture.sourceParentId) : null;
|
|
1651
|
+
} else {
|
|
1652
|
+
const crossParentPlacement = getCrossParentPlacement(target, gesture, resolvedMinColumns, resolvedMinRows, false, metrics);
|
|
1653
|
+
if (crossParentPlacement) {
|
|
1654
|
+
currentItems = getDashboardGesturePlacements(target, gesture, crossParentPlacement) ?? [];
|
|
1655
|
+
if (currentItems.length) {
|
|
1656
|
+
nextPlacement = currentItems.find((item) => item.id === id)?.placement ?? crossParentPlacement;
|
|
1657
|
+
destinationParentId = target.parentId;
|
|
1658
|
+
preview = createDashboardDropPreviews(target, currentItems, gesture.items, metrics, gesture.sourceParentId);
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
updateDropPreview(preview);
|
|
1663
|
+
gesture.canCommit = !!preview?.length && preview.every((item) => item.status === "valid");
|
|
1664
|
+
if (!preview?.length) return;
|
|
1665
|
+
} else {
|
|
1666
|
+
updateDropPreview(null);
|
|
1667
|
+
gesture.canCommit = true;
|
|
1668
|
+
}
|
|
1669
|
+
if (isSamePlacement(nextPlacement, gesture.current) && destinationParentId === gesture.destinationParentId) return;
|
|
1670
|
+
gesture.current = nextPlacement;
|
|
1671
|
+
gesture.currentItems = currentItems;
|
|
1672
|
+
gesture.destinationParentId = destinationParentId;
|
|
1673
|
+
reportPlacement(nextPlacement, "move", "preview", gesture.input, gesture.sourceParentId, destinationParentId, currentItems);
|
|
1674
|
+
},
|
|
1675
|
+
onMoveEnd() {
|
|
1676
|
+
const gesture = moveSessionRef.current;
|
|
1677
|
+
moveSessionRef.current = null;
|
|
1678
|
+
node.editing.stopMoving(id);
|
|
1679
|
+
setIsMoving(false);
|
|
1680
|
+
updateDropPreview(null);
|
|
1681
|
+
if (!canMove || !gesture || !gesture.canCommit || isSamePlacement(gesture.current, gesture.origin) && gesture.destinationParentId === gesture.sourceParentId) return;
|
|
1682
|
+
reportPlacement(gesture.current, "move", "commit", gesture.input, gesture.sourceParentId, gesture.destinationParentId, gesture.currentItems);
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
const surfaceMoveProps = getSurfaceMoveProps(moveProps, canMove, localRef, (clientX, clientY) => {
|
|
1686
|
+
pointerStartRef.current = {
|
|
1687
|
+
clientX,
|
|
1688
|
+
clientY
|
|
1689
|
+
};
|
|
1690
|
+
});
|
|
1691
|
+
const { moveProps: resizeProps } = useMove({
|
|
1692
|
+
onMoveStart(event) {
|
|
1693
|
+
if (!canResize) return;
|
|
1694
|
+
node.selectSelf(false);
|
|
1695
|
+
setIsResizing(true);
|
|
1696
|
+
resizeSessionRef.current = createGesture(event.pointerType === "keyboard" ? "keyboard" : "pointer");
|
|
1697
|
+
},
|
|
1698
|
+
onMove(event) {
|
|
1699
|
+
const gesture = resizeSessionRef.current;
|
|
1700
|
+
if (!canResize || !gesture) return;
|
|
1701
|
+
const delta = updateGestureDeltas(gesture, canResizeColumns ? event.deltaX : 0, canResizeRows ? event.deltaY : 0, event.pointerType === "keyboard" ? "keyboard" : "pointer");
|
|
1702
|
+
const maxColumnsAtOrigin = Math.min(resolvedMaxColumns, node.tree.parentColumns - gesture.origin.column);
|
|
1703
|
+
const maxRowsAtOrigin = Math.min(resolvedMaxRows, node.tree.parentRows - gesture.origin.row);
|
|
1704
|
+
const nextPlacement = {
|
|
1705
|
+
...gesture.origin,
|
|
1706
|
+
columns: canResizeColumns ? clamp(gesture.origin.columns + delta.columns, resolvedMinColumns, maxColumnsAtOrigin) : gesture.origin.columns,
|
|
1707
|
+
rows: canResizeRows ? clamp(gesture.origin.rows + delta.rows, resolvedMinRows, maxRowsAtOrigin) : gesture.origin.rows
|
|
1708
|
+
};
|
|
1709
|
+
if (isSamePlacement(nextPlacement, gesture.current)) return;
|
|
1710
|
+
gesture.current = nextPlacement;
|
|
1711
|
+
reportPlacement(nextPlacement, "resize", "preview", gesture.input);
|
|
1712
|
+
},
|
|
1713
|
+
onMoveEnd() {
|
|
1714
|
+
const gesture = resizeSessionRef.current;
|
|
1715
|
+
resizeSessionRef.current = null;
|
|
1716
|
+
setIsResizing(false);
|
|
1717
|
+
if (!canResize || !gesture || isSamePlacement(gesture.current, gesture.origin)) return;
|
|
1718
|
+
reportPlacement(gesture.current, "resize", "commit", gesture.input);
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1721
|
+
const handleSettingsPress = useEvent((event) => {
|
|
1722
|
+
node.selectSelf(false);
|
|
1723
|
+
onSettingsPress?.(event);
|
|
1724
|
+
});
|
|
1725
|
+
const handleDeletePress = useEvent((event) => {
|
|
1726
|
+
node.selectSelf(false);
|
|
1727
|
+
onDeletePress?.(event);
|
|
1728
|
+
});
|
|
1729
|
+
return /* @__PURE__ */ jsxs(WidgetElement, {
|
|
1730
|
+
...mergeProps$1(baseProps, node.interactionProps, surfaceMoveProps),
|
|
1731
|
+
ref: combinedRef,
|
|
1732
|
+
role: "group",
|
|
1733
|
+
"aria-label": moveLabel ?? resolvedLabel,
|
|
1734
|
+
"aria-roledescription": t(canMove ? "dashboard.movableWidget" : "dashboard.widget", canMove ? "Movable dashboard widget" : "Dashboard widget"),
|
|
1735
|
+
tabIndex: node.canSelect || canMove ? 0 : void 0,
|
|
1736
|
+
"data-dashboard-node": "widget",
|
|
1737
|
+
"data-dashboard-node-id": id,
|
|
1738
|
+
"data-dashboard-column": normalizedPlacement.column,
|
|
1739
|
+
"data-dashboard-row": normalizedPlacement.row,
|
|
1740
|
+
"data-dashboard-columns": normalizedPlacement.columns,
|
|
1741
|
+
"data-dashboard-rows": normalizedPlacement.rows,
|
|
1742
|
+
"data-dashboard-min-columns": clampSpan(minColumns, 1),
|
|
1743
|
+
"data-dashboard-max-columns": Math.max(clampSpan(minColumns, 1), clampSpan(maxColumns, 12)),
|
|
1744
|
+
"data-dashboard-min-rows": clampRows(minRows, 1),
|
|
1745
|
+
"data-dashboard-max-rows": maxRows === void 0 ? Number.MAX_SAFE_INTEGER : Math.max(clampRows(minRows, 1), clampRows(maxRows, 1)),
|
|
1746
|
+
"data-selected": node.isSelected || void 0,
|
|
1747
|
+
"data-moving": isMoving || void 0,
|
|
1748
|
+
"data-resizing": isResizing || void 0,
|
|
1749
|
+
mods: resolvedMods,
|
|
1750
|
+
style: {
|
|
1751
|
+
...placementStyle,
|
|
1752
|
+
...style
|
|
1753
|
+
},
|
|
1754
|
+
children: [
|
|
1755
|
+
/* @__PURE__ */ jsx(WidgetSurfaceElement, {
|
|
1756
|
+
mods: resolvedMods,
|
|
1757
|
+
styles,
|
|
1758
|
+
children
|
|
1759
|
+
}),
|
|
1760
|
+
onSettingsPress || onDeletePress ? /* @__PURE__ */ jsxs(NodeActionsElement, {
|
|
1761
|
+
"aria-hidden": !node.isSelected || void 0,
|
|
1762
|
+
mods: resolvedMods,
|
|
1763
|
+
"data-dashboard-widget-actions": "",
|
|
1764
|
+
children: [onDeletePress ? /* @__PURE__ */ jsx(Button, {
|
|
1765
|
+
size: "small",
|
|
1766
|
+
theme: "danger",
|
|
1767
|
+
radius: "round",
|
|
1768
|
+
icon: /* @__PURE__ */ jsx(TrashIcon, {}),
|
|
1769
|
+
"aria-label": deleteLabel ?? t("dashboard.deleteWidget", "Delete {{widget}}", { widget: resolvedLabel }),
|
|
1770
|
+
tabIndex: node.isSelected ? void 0 : -1,
|
|
1771
|
+
onPress: handleDeletePress
|
|
1772
|
+
}) : null, onSettingsPress ? /* @__PURE__ */ jsx(Button, {
|
|
1773
|
+
size: "small",
|
|
1774
|
+
type: "primary",
|
|
1775
|
+
radius: "round",
|
|
1776
|
+
icon: /* @__PURE__ */ jsx(SettingsIcon, {}),
|
|
1777
|
+
"aria-label": settingsLabel ?? resolvedLabel,
|
|
1778
|
+
tabIndex: node.isSelected ? void 0 : -1,
|
|
1779
|
+
onPress: handleSettingsPress
|
|
1780
|
+
}) : null]
|
|
1781
|
+
}) : null,
|
|
1782
|
+
canResize ? /* @__PURE__ */ jsx(ResizeHandleElement, {
|
|
1783
|
+
...resizeProps,
|
|
1784
|
+
type: "button",
|
|
1785
|
+
"aria-label": resizeLabel ?? t("dashboard.resizeWidget", "Resize dashboard widget"),
|
|
1786
|
+
"data-dashboard-resize-handle": "",
|
|
1787
|
+
"data-dashboard-resize-axis": resizeAxis,
|
|
1788
|
+
"data-dashboard-no-select": "",
|
|
1789
|
+
"aria-hidden": !node.isSelected || void 0,
|
|
1790
|
+
tabIndex: node.isSelected ? void 0 : -1,
|
|
1791
|
+
mods: {
|
|
1792
|
+
...resolvedMods,
|
|
1793
|
+
axis: resizeAxis,
|
|
1794
|
+
corner: resizeAxis === "both"
|
|
1795
|
+
},
|
|
1796
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1797
|
+
"data-element": "Icon",
|
|
1798
|
+
children: resizeAxis === "both" ? /* @__PURE__ */ jsx(CornerResizeGripElement, {}) : /* @__PURE__ */ jsx(GripVerticalIcon, { size: "1.5x" })
|
|
1799
|
+
})
|
|
1800
|
+
}) : null,
|
|
1801
|
+
renderDashboardDropPreview(dropPreview)
|
|
1802
|
+
]
|
|
1803
|
+
});
|
|
1804
|
+
});
|
|
1805
|
+
function DashboardTab(_props) {
|
|
1806
|
+
return null;
|
|
1807
|
+
}
|
|
1808
|
+
DashboardTab.displayName = "DashboardTab";
|
|
1809
|
+
function isDashboardTab(child) {
|
|
1810
|
+
return isValidElement(child) && (child.type === DashboardTab || child.type.displayName === DashboardTab.displayName);
|
|
1811
|
+
}
|
|
1812
|
+
function isDashboardTabLayoutContainer(child) {
|
|
1813
|
+
if (!isValidElement(child)) return false;
|
|
1814
|
+
const displayName = child.type.displayName;
|
|
1815
|
+
return child.type === DashboardGrid || child.type === DashboardHorizontalStack || child.type === DashboardVerticalStack || displayName === DashboardGrid.displayName || displayName === DashboardHorizontalStack.displayName || displayName === DashboardVerticalStack.displayName;
|
|
1816
|
+
}
|
|
1817
|
+
const DashboardTabs = forwardRef(function DashboardTabs(props, ref) {
|
|
1818
|
+
const { id, children, rows = 1, activeKey, defaultActiveKey, onActiveChange, ...containerProps } = props;
|
|
1819
|
+
const tree = useContext(DashboardTreeContext);
|
|
1820
|
+
if (tree.parentKind !== "root") throw new Error(`Dashboard.Tabs "${id}" is only allowed directly inside Dashboard.`);
|
|
1821
|
+
const tabs = Children.toArray(children).filter(isDashboardTab);
|
|
1822
|
+
const content = /* @__PURE__ */ jsx(Tabs, {
|
|
1823
|
+
activeKey,
|
|
1824
|
+
defaultActiveKey: defaultActiveKey ?? tabs[0]?.props.id,
|
|
1825
|
+
onChange: onActiveChange,
|
|
1826
|
+
keepMounted: true,
|
|
1827
|
+
label: props["aria-label"] ?? (typeof props.title === "string" ? props.title : id),
|
|
1828
|
+
height: "100%",
|
|
1829
|
+
barStyles: {
|
|
1830
|
+
borderBottom: "1bw #border",
|
|
1831
|
+
marginBottom: "1x"
|
|
1832
|
+
},
|
|
1833
|
+
children: tabs.map((tab) => {
|
|
1834
|
+
const tabLayoutId = `${id}:${tab.props.id}`;
|
|
1835
|
+
const tabLayoutChildren = Children.toArray(tab.props.children);
|
|
1836
|
+
if (tabLayoutChildren.length > 1 || tabLayoutChildren.some((child) => !isDashboardTabLayoutContainer(child))) throw new Error(`Dashboard.Tab "${tab.props.id}" inside "${id}" accepts one Grid, HorizontalStack, or VerticalStack layout container only.`);
|
|
1837
|
+
const tabTree = {
|
|
1838
|
+
containerDepth: 1,
|
|
1839
|
+
parentKind: "tabs",
|
|
1840
|
+
parentId: tabLayoutId,
|
|
1841
|
+
layoutParentId: tabLayoutId,
|
|
1842
|
+
parentColumns: 12,
|
|
1843
|
+
parentRows: Math.max(1, Math.floor(rows)),
|
|
1844
|
+
ancestorIds: [...tree.ancestorIds, id]
|
|
1845
|
+
};
|
|
1846
|
+
return /* @__PURE__ */ jsx(Tab, {
|
|
1847
|
+
title: tab.props.title,
|
|
1848
|
+
keepMounted: tab.props.keepMounted ?? true,
|
|
1849
|
+
children: /* @__PURE__ */ jsx(DashboardTreeContext.Provider, {
|
|
1850
|
+
value: tabTree,
|
|
1851
|
+
children: /* @__PURE__ */ jsx(DashboardContainerContent, {
|
|
1852
|
+
id: tabLayoutId,
|
|
1853
|
+
kind: "tabs",
|
|
1854
|
+
columns: 12,
|
|
1855
|
+
rows: Math.max(1, Math.floor(rows)),
|
|
1856
|
+
depth: 1,
|
|
1857
|
+
ancestorIds: [...tree.ancestorIds, id],
|
|
1858
|
+
tabsId: id,
|
|
1859
|
+
tabId: tab.props.id,
|
|
1860
|
+
children: tab.props.children
|
|
1861
|
+
})
|
|
1862
|
+
})
|
|
1863
|
+
}, tab.props.id);
|
|
1864
|
+
})
|
|
1865
|
+
});
|
|
1866
|
+
return /* @__PURE__ */ jsx(DashboardContainerShell, {
|
|
1867
|
+
...containerProps,
|
|
1868
|
+
ref,
|
|
1869
|
+
id,
|
|
1870
|
+
rows,
|
|
1871
|
+
kind: "tabs",
|
|
1872
|
+
content,
|
|
1873
|
+
children
|
|
1874
|
+
});
|
|
1875
|
+
});
|
|
1876
|
+
const DashboardRoot = forwardRef(function DashboardRoot(props, ref) {
|
|
1877
|
+
const { children, rowHeight = 80, gap = 16, isEditing = false, selectionMode = "multiple", selectedKeys: controlledSelectedKeys, defaultSelectedKeys = [], onSelectionChange, addItems = [], onAddItem, styles: explicitStyles, style, ...otherProps } = props;
|
|
1878
|
+
const [columnGap, rowGap] = normalizeGap(gap);
|
|
1879
|
+
const [uncontrolledSelectedKeys, setUncontrolledSelectedKeys] = useState(defaultSelectedKeys);
|
|
1880
|
+
const [movingId, setMovingId] = useState(null);
|
|
1881
|
+
const [arrivingIds, setArrivingIds] = useState(() => /* @__PURE__ */ new Set());
|
|
1882
|
+
const acceptsArrivalsRef = useRef(false);
|
|
1883
|
+
const arrivalTimerRef = useRef(null);
|
|
1884
|
+
const registrationsRef = useRef(/* @__PURE__ */ new Map());
|
|
1885
|
+
const isControlled = controlledSelectedKeys !== void 0;
|
|
1886
|
+
const selectedKeys = selectionMode === "none" ? [] : controlledSelectedKeys ?? uncontrolledSelectedKeys;
|
|
1887
|
+
const selectedKeySet = useMemo(() => new Set(selectedKeys), [selectedKeys]);
|
|
1888
|
+
const commitSelection = useEvent((next) => {
|
|
1889
|
+
if (!isControlled) setUncontrolledSelectedKeys(next);
|
|
1890
|
+
onSelectionChange?.(next);
|
|
1891
|
+
});
|
|
1892
|
+
const register = useEvent((id, registration) => {
|
|
1893
|
+
registrationsRef.current.set(id, registration);
|
|
1894
|
+
return () => {
|
|
1895
|
+
if (registrationsRef.current.get(id) === registration) registrationsRef.current.delete(id);
|
|
1896
|
+
};
|
|
1897
|
+
});
|
|
1898
|
+
const select = useEvent((id, additive) => {
|
|
1899
|
+
if (selectionMode === "none") return;
|
|
1900
|
+
const registration = registrationsRef.current.get(id);
|
|
1901
|
+
if (!registration) return;
|
|
1902
|
+
if (selectionMode === "single" || !additive) {
|
|
1903
|
+
commitSelection([id]);
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
const current = new Set(selectedKeySet);
|
|
1907
|
+
if (current.has(id)) {
|
|
1908
|
+
current.delete(id);
|
|
1909
|
+
commitSelection([...current]);
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
for (const selectedId of current) {
|
|
1913
|
+
const selected = registrationsRef.current.get(selectedId);
|
|
1914
|
+
if (!selected) continue;
|
|
1915
|
+
if (registration.ancestorIds.includes(selectedId)) return;
|
|
1916
|
+
if (selected.parentId !== registration.parentId) return;
|
|
1917
|
+
if (selected.ancestorIds.includes(id)) current.delete(selectedId);
|
|
1918
|
+
}
|
|
1919
|
+
current.add(id);
|
|
1920
|
+
commitSelection([...current]);
|
|
1921
|
+
});
|
|
1922
|
+
const handleRootClick = useEvent((event) => {
|
|
1923
|
+
if (event.target.closest("[data-dashboard-node]")) return;
|
|
1924
|
+
if (selectedKeySet.size > 0) commitSelection([]);
|
|
1925
|
+
});
|
|
1926
|
+
const startMoving = useEvent((id) => setMovingId(id));
|
|
1927
|
+
const stopMoving = useEvent((id) => {
|
|
1928
|
+
setMovingId((current) => current === id ? null : current);
|
|
1929
|
+
});
|
|
1930
|
+
const markArriving = useEvent((id) => {
|
|
1931
|
+
if (!acceptsArrivalsRef.current) return;
|
|
1932
|
+
if (arrivalTimerRef.current !== null) clearTimeout(arrivalTimerRef.current);
|
|
1933
|
+
setArrivingIds((current) => new Set(current).add(id));
|
|
1934
|
+
arrivalTimerRef.current = setTimeout(() => {
|
|
1935
|
+
setArrivingIds(/* @__PURE__ */ new Set());
|
|
1936
|
+
arrivalTimerRef.current = null;
|
|
1937
|
+
}, 1e3);
|
|
1938
|
+
});
|
|
1939
|
+
useLayoutEffect$1(() => {
|
|
1940
|
+
acceptsArrivalsRef.current = true;
|
|
1941
|
+
return () => {
|
|
1942
|
+
acceptsArrivalsRef.current = false;
|
|
1943
|
+
if (arrivalTimerRef.current !== null) clearTimeout(arrivalTimerRef.current);
|
|
1944
|
+
};
|
|
1945
|
+
}, []);
|
|
1946
|
+
const metrics = useMemo(() => ({
|
|
1947
|
+
rowHeight: Math.max(1, rowHeight),
|
|
1948
|
+
columnGap: Math.max(0, columnGap),
|
|
1949
|
+
rowGap: Math.max(0, rowGap)
|
|
1950
|
+
}), [
|
|
1951
|
+
columnGap,
|
|
1952
|
+
rowGap,
|
|
1953
|
+
rowHeight
|
|
1954
|
+
]);
|
|
1955
|
+
const selection = useMemo(() => ({
|
|
1956
|
+
selectionMode,
|
|
1957
|
+
selectedKeys: selectedKeySet,
|
|
1958
|
+
register,
|
|
1959
|
+
select
|
|
1960
|
+
}), [
|
|
1961
|
+
register,
|
|
1962
|
+
select,
|
|
1963
|
+
selectedKeySet,
|
|
1964
|
+
selectionMode
|
|
1965
|
+
]);
|
|
1966
|
+
const editing = useMemo(() => ({
|
|
1967
|
+
isEditing,
|
|
1968
|
+
movingId,
|
|
1969
|
+
arrivingIds,
|
|
1970
|
+
markArriving,
|
|
1971
|
+
startMoving,
|
|
1972
|
+
stopMoving
|
|
1973
|
+
}), [
|
|
1974
|
+
arrivingIds,
|
|
1975
|
+
isEditing,
|
|
1976
|
+
markArriving,
|
|
1977
|
+
movingId,
|
|
1978
|
+
startMoving,
|
|
1979
|
+
stopMoving
|
|
1980
|
+
]);
|
|
1981
|
+
const authoring = useMemo(() => ({
|
|
1982
|
+
addItems,
|
|
1983
|
+
onAddItem
|
|
1984
|
+
}), [addItems, onAddItem]);
|
|
1985
|
+
const rootTree = useMemo(() => ({
|
|
1986
|
+
containerDepth: 0,
|
|
1987
|
+
parentKind: "root",
|
|
1988
|
+
parentId: null,
|
|
1989
|
+
layoutParentId: null,
|
|
1990
|
+
parentColumns: 12,
|
|
1991
|
+
parentRows: 1,
|
|
1992
|
+
ancestorIds: []
|
|
1993
|
+
}), []);
|
|
1994
|
+
const styles = {
|
|
1995
|
+
...extractStyles(props, CONTAINER_STYLES),
|
|
1996
|
+
...explicitStyles
|
|
1997
|
+
};
|
|
1998
|
+
const baseProps = filterBaseProps(otherProps, {
|
|
1999
|
+
eventProps: true,
|
|
2000
|
+
labelable: true
|
|
2001
|
+
});
|
|
2002
|
+
return /* @__PURE__ */ jsx(DashboardMetricsContext.Provider, {
|
|
2003
|
+
value: metrics,
|
|
2004
|
+
children: /* @__PURE__ */ jsx(DashboardSelectionContext.Provider, {
|
|
2005
|
+
value: selection,
|
|
2006
|
+
children: /* @__PURE__ */ jsx(DashboardEditingContext.Provider, {
|
|
2007
|
+
value: editing,
|
|
2008
|
+
children: /* @__PURE__ */ jsx(DashboardAuthoringContext.Provider, {
|
|
2009
|
+
value: authoring,
|
|
2010
|
+
children: /* @__PURE__ */ jsx(DashboardTreeContext.Provider, {
|
|
2011
|
+
value: rootTree,
|
|
2012
|
+
children: /* @__PURE__ */ jsxs(DashboardElement, {
|
|
2013
|
+
...mergeProps$1(baseProps, { onClick: handleRootClick }),
|
|
2014
|
+
ref,
|
|
2015
|
+
styles,
|
|
2016
|
+
style: {
|
|
2017
|
+
gap: `${metrics.rowGap}px`,
|
|
2018
|
+
...style
|
|
2019
|
+
},
|
|
2020
|
+
"data-editing": isEditing || void 0,
|
|
2021
|
+
"data-dragging": movingId !== null || void 0,
|
|
2022
|
+
"data-dashboard-root": "",
|
|
2023
|
+
"data-dashboard-drop-target": "",
|
|
2024
|
+
"data-dashboard-parent-id": "",
|
|
2025
|
+
"data-dashboard-container-kind": "root",
|
|
2026
|
+
"data-dashboard-columns": 12,
|
|
2027
|
+
"data-dashboard-rows": Math.max(1, Children.count(children)),
|
|
2028
|
+
"data-dashboard-depth": 0,
|
|
2029
|
+
"data-dashboard-ancestor-ids": "[]",
|
|
2030
|
+
children: [children, isEditing ? /* @__PURE__ */ jsx(DashboardRootAddControl, { row: Children.count(children) }) : null]
|
|
2031
|
+
})
|
|
2032
|
+
})
|
|
2033
|
+
})
|
|
2034
|
+
})
|
|
2035
|
+
})
|
|
2036
|
+
});
|
|
2037
|
+
});
|
|
2038
|
+
const Dashboard = Object.assign(DashboardRoot, {
|
|
2039
|
+
HorizontalStack: DashboardHorizontalStack,
|
|
2040
|
+
VerticalStack: DashboardVerticalStack,
|
|
2041
|
+
Grid: DashboardGrid,
|
|
2042
|
+
Tabs: DashboardTabs,
|
|
2043
|
+
Tab: DashboardTab,
|
|
2044
|
+
Widget: DashboardWidget
|
|
2045
|
+
});
|
|
2046
|
+
|
|
2047
|
+
//#endregion
|
|
2048
|
+
export { Dashboard, DashboardGrid, DashboardHorizontalStack, DashboardTab, DashboardTabs, DashboardVerticalStack, DashboardWidget };
|
|
2049
|
+
//# sourceMappingURL=Dashboard.js.map
|