@cube-dev/ui-kit 0.0.0-canary-054f261 → 0.0.0-canary-7b4aa61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CHANGELOG.md +6 -0
- package/dist/_internal/hooks/use-chained-callback.js +1 -1
- package/dist/_internal/hooks/use-debounced-value.js +1 -1
- package/dist/_internal/hooks/use-deprecation-warning.js +1 -1
- package/dist/_internal/hooks/use-event.js +1 -1
- package/dist/_internal/hooks/use-is-first-render.js +1 -1
- package/dist/_internal/hooks/use-sync-ref.js +1 -1
- package/dist/_internal/hooks/use-timer/timer.js +1 -1
- package/dist/_internal/hooks/use-timer/use-timer.js +1 -1
- package/dist/_internal/hooks/use-warn.js +1 -1
- package/dist/components/Block.js +1 -1
- package/dist/components/CollectionItem.js +1 -1
- package/dist/components/GlobalStyles.js +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/Button.js +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/InlineInput/InlineInput.js +1 -1
- package/dist/components/content/Item/Item.js +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.js +1 -1
- package/dist/components/content/ItemCard/ItemCard.js +1 -1
- package/dist/components/content/Layout/GridLayout.js +1 -1
- package/dist/components/content/Layout/Layout.js +1 -1
- package/dist/components/content/Layout/LayoutBlock.js +1 -1
- package/dist/components/content/Layout/LayoutCenter.js +1 -1
- package/dist/components/content/Layout/LayoutContainer.js +1 -1
- package/dist/components/content/Layout/LayoutContent.js +1 -1
- package/dist/components/content/Layout/LayoutContext.js +1 -1
- package/dist/components/content/Layout/LayoutFlex.js +1 -1
- package/dist/components/content/Layout/LayoutFooter.js +1 -1
- package/dist/components/content/Layout/LayoutGrid.js +1 -1
- package/dist/components/content/Layout/LayoutHeader.js +1 -1
- package/dist/components/content/Layout/LayoutPane.js +1 -1
- package/dist/components/content/Layout/LayoutPanel.js +1 -1
- package/dist/components/content/Layout/LayoutPanelHeader.js +1 -1
- package/dist/components/content/Layout/LayoutToolbar.js +1 -1
- package/dist/components/content/Layout/hooks/useTinyScrollbar.js +1 -1
- package/dist/components/content/Layout/index.js +1 -1
- package/dist/components/content/Layout/utils.js +1 -1
- package/dist/components/content/Paragraph.js +1 -1
- package/dist/components/content/Placeholder/Placeholder.js +1 -1
- package/dist/components/content/PrismCode/PrismCode.js +1 -1
- package/dist/components/content/PrismCode/prismSetup.js +1 -1
- package/dist/components/content/PrismDiffCode/PrismDiffCode.js +1 -1
- package/dist/components/content/Result/Result.js +1 -1
- package/dist/components/content/Skeleton/Skeleton.js +1 -1
- package/dist/components/content/Tag/Tag.js +1 -1
- package/dist/components/content/Text.js +1 -1
- package/dist/components/content/TextItem/TextItem.js +1 -1
- package/dist/components/content/Title.js +1 -1
- package/dist/components/content/Tree/Tree.js +1 -1
- package/dist/components/content/Tree/TreeNode.js +1 -1
- package/dist/components/content/Tree/styled.js +1 -1
- package/dist/components/content/Tree/tree-index.js +1 -1
- package/dist/components/content/Tree/use-checkbox-tree.js +1 -1
- package/dist/components/content/Tree/use-load-data.js +1 -1
- package/dist/components/content/highlightText.js +1 -1
- package/dist/components/content/use-auto-tooltip.js +1 -1
- package/dist/components/fields/Checkbox/Checkbox.js +1 -1
- package/dist/components/fields/Checkbox/CheckboxGroup.js +1 -1
- package/dist/components/fields/Checkbox/context.js +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +1 -1
- package/dist/components/fields/CommandTextArea/CommandTextArea.js +1 -1
- package/dist/components/fields/CommandTextArea/caretPosition.js +1 -1
- package/dist/components/fields/CommandTextArea/useCaretAnchor.js +1 -1
- package/dist/components/fields/DatePicker/DateInput.js +1 -1
- package/dist/components/fields/DatePicker/DateInputBase.js +1 -1
- package/dist/components/fields/DatePicker/DatePicker.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerButton.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerElement.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerInput.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerSegment.js +1 -1
- package/dist/components/fields/DatePicker/DateRangePicker.js +1 -1
- package/dist/components/fields/DatePicker/DateRangeSeparatedPicker.js +1 -1
- package/dist/components/fields/DatePicker/TimeInput.js +1 -1
- package/dist/components/fields/DatePicker/intl.js +1 -1
- package/dist/components/fields/DatePicker/parseDate.js +1 -1
- package/dist/components/fields/DatePicker/props.js +1 -1
- package/dist/components/fields/DatePicker/utils.js +1 -1
- package/dist/components/fields/FileInput/FileInput.js +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.js +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.js +1 -1
- package/dist/components/fields/Input/Input.js +1 -1
- package/dist/components/fields/ListBox/DraggableListBox.js +1 -1
- package/dist/components/fields/ListBox/ListBox.js +1 -1
- package/dist/components/fields/ListBoxPopover/ListBoxPopover.js +1 -1
- package/dist/components/fields/ListBoxPopover/listNavigation.js +1 -1
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.js +1 -1
- package/dist/components/fields/NumberInput/NumberInput.js +1 -1
- package/dist/components/fields/NumberInput/StepButton.js +1 -1
- package/dist/components/fields/PasswordInput/PasswordInput.js +1 -1
- package/dist/components/fields/Picker/Picker.js +1 -1
- package/dist/components/fields/RadioGroup/Radio.js +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.js +1 -1
- package/dist/components/fields/RadioGroup/context.js +1 -1
- package/dist/components/fields/SearchInput/SearchInput.js +1 -1
- package/dist/components/fields/Select/Select.js +1 -1
- package/dist/components/fields/Slider/Gradation.js +1 -1
- package/dist/components/fields/Slider/HueSlider.js +1 -1
- package/dist/components/fields/Slider/RangeSlider.js +1 -1
- package/dist/components/fields/Slider/Slider.js +1 -1
- package/dist/components/fields/Slider/SliderBase.js +1 -1
- package/dist/components/fields/Slider/SliderThumb.js +1 -1
- package/dist/components/fields/Slider/SliderTrack.js +1 -1
- package/dist/components/fields/Slider/elements.js +1 -1
- package/dist/components/fields/Slider/index.js +1 -1
- package/dist/components/fields/Switch/Switch.js +1 -1
- package/dist/components/fields/TextArea/TextArea.js +1 -1
- package/dist/components/fields/TextInput/TextInput.js +1 -1
- package/dist/components/fields/TextInput/TextInputBase.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/form/FieldWrapper/FieldWrapper.js +1 -1
- package/dist/components/form/FieldWrapper/extract-field-wrapper-props.js +1 -1
- package/dist/components/form/Form/Field.js +1 -1
- package/dist/components/form/Form/Form.js +1 -1
- package/dist/components/form/Form/ResetButton/ResetButton.js +1 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.js +1 -1
- package/dist/components/form/Form/SubmitError.js +1 -1
- package/dist/components/form/Form/index.js +1 -1
- package/dist/components/form/Form/use-field/use-field-props.js +1 -1
- package/dist/components/form/Form/use-field/use-field.js +1 -1
- package/dist/components/form/Form/use-form.js +1 -1
- package/dist/components/form/Form/validation.js +1 -1
- package/dist/components/form/Label.js +1 -1
- package/dist/components/form/wrapper.js +1 -1
- package/dist/components/helpers/DisplayTransition/DisplayTransition.js +1 -1
- package/dist/components/helpers/IconSwitch/IconSwitch.js +1 -1
- package/dist/components/layout/Board/Board.d.ts +51 -0
- package/dist/components/layout/Board/Board.js +271 -0
- package/dist/components/layout/Board/Board.js.map +1 -0
- package/dist/components/layout/Board/BoardProvider.d.ts +21 -0
- package/dist/components/layout/Board/BoardProvider.js +44 -0
- package/dist/components/layout/Board/BoardProvider.js.map +1 -0
- package/dist/components/layout/Board/Widget.d.ts +33 -0
- package/dist/components/layout/Board/Widget.js +38 -0
- package/dist/components/layout/Board/Widget.js.map +1 -0
- package/dist/components/layout/Board/WidgetHost.js +279 -0
- package/dist/components/layout/Board/WidgetHost.js.map +1 -0
- package/dist/components/layout/Board/board-context.js +12 -0
- package/dist/components/layout/Board/board-context.js.map +1 -0
- package/dist/components/layout/Board/board-store.js +49 -0
- package/dist/components/layout/Board/board-store.js.map +1 -0
- package/dist/components/layout/Board/grid-core/calculate.js +90 -0
- package/dist/components/layout/Board/grid-core/calculate.js.map +1 -0
- package/dist/components/layout/Board/grid-core/collision.js +35 -0
- package/dist/components/layout/Board/grid-core/collision.js.map +1 -0
- package/dist/components/layout/Board/grid-core/compactors.d.ts +23 -0
- package/dist/components/layout/Board/grid-core/compactors.js +166 -0
- package/dist/components/layout/Board/grid-core/compactors.js.map +1 -0
- package/dist/components/layout/Board/grid-core/constraints.d.ts +35 -0
- package/dist/components/layout/Board/grid-core/constraints.js +155 -0
- package/dist/components/layout/Board/grid-core/constraints.js.map +1 -0
- package/dist/components/layout/Board/grid-core/layout.js +155 -0
- package/dist/components/layout/Board/grid-core/layout.js.map +1 -0
- package/dist/components/layout/Board/grid-core/sort.js +37 -0
- package/dist/components/layout/Board/grid-core/sort.js.map +1 -0
- package/dist/components/layout/Board/grid-core/types.d.ts +168 -0
- package/dist/components/layout/Board/index.d.ts +17 -0
- package/dist/components/layout/Board/index.js +16 -0
- package/dist/components/layout/Board/index.js.map +1 -0
- package/dist/components/layout/Board/use-board-layout.js +46 -0
- package/dist/components/layout/Board/use-board-layout.js.map +1 -0
- package/dist/components/layout/Board/use-board-registry.js +221 -0
- package/dist/components/layout/Board/use-board-registry.js.map +1 -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/Tabs/DraggableTabList.js +1 -1
- package/dist/components/navigation/Tabs/TabButton.js +1 -1
- package/dist/components/navigation/Tabs/TabDropIndicator.js +1 -1
- package/dist/components/navigation/Tabs/TabPanel.js +1 -1
- package/dist/components/navigation/Tabs/TabPicker.js +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +1 -1
- package/dist/components/navigation/Tabs/TabsAction.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/popover-placement.js +1 -1
- package/dist/components/navigation/Tabs/styled.js +1 -1
- package/dist/components/navigation/Tabs/types.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-editing.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-indicator.js +1 -1
- package/dist/components/organisms/FileTabs/FileTabs.js +1 -1
- package/dist/components/organisms/StatsCard/StatsCard.js +1 -1
- package/dist/components/other/Calendar/Calendar.js +1 -1
- package/dist/components/other/Calendar/CalendarCell.js +1 -1
- package/dist/components/other/Calendar/CalendarGrid.js +1 -1
- package/dist/components/other/Calendar/RangeCalendar.js +1 -1
- package/dist/components/other/CloudLogo/CloudLogo.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogApiProvider.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogZone.js +1 -1
- package/dist/components/overlays/Dialog/Dialog.js +1 -1
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +1 -1
- package/dist/components/overlays/Dialog/DialogTrigger.js +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Modal/Modal.js +1 -1
- package/dist/components/overlays/Modal/OpenTransitionContext.js +1 -1
- package/dist/components/overlays/Modal/Overlay.js +1 -1
- package/dist/components/overlays/Modal/Popover.js +1 -1
- package/dist/components/overlays/Modal/Tray.js +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +1 -1
- package/dist/components/overlays/Notifications/NotificationCard.js +1 -1
- package/dist/components/overlays/Notifications/NotificationContext.js +1 -1
- package/dist/components/overlays/Notifications/NotificationItem.js +1 -1
- package/dist/components/overlays/Notifications/OverlayContainer.js +1 -1
- package/dist/components/overlays/Notifications/OverlayProvider.js +1 -1
- package/dist/components/overlays/Notifications/PersistentNotificationsList.js +1 -1
- package/dist/components/overlays/Notifications/dismissed-storage.js +1 -1
- package/dist/components/overlays/Notifications/format-relative-time.js +1 -1
- package/dist/components/overlays/Notifications/index.js +1 -1
- package/dist/components/overlays/Notifications/use-notification-state.js +1 -1
- package/dist/components/overlays/Notifications/use-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-overlay-timers.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-state.js +1 -1
- package/dist/components/overlays/Notifications/use-toast-state.js +1 -1
- package/dist/components/overlays/Toast/ToastItem.js +1 -1
- package/dist/components/overlays/Toast/index.js +1 -1
- package/dist/components/overlays/Toast/useProgressToast.js +1 -1
- package/dist/components/overlays/Toast/useToast.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipProvider.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipTrigger.js +1 -1
- package/dist/components/overlays/Tooltip/context.js +1 -1
- package/dist/components/portal/Portal.js +1 -1
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +1 -1
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/Spin/Cube.js +1 -1
- package/dist/components/status/Spin/InternalSpinner.js +1 -1
- package/dist/components/status/Spin/Spin.js +1 -1
- package/dist/components/status/Spin/SpinsContainer.js +1 -1
- package/dist/data/item-themes.js +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/icons/AdjustmentsHorizontalIcon.js +1 -1
- package/dist/icons/AdjustmentsIcon.js +1 -1
- package/dist/icons/AiIcon.js +1 -1
- package/dist/icons/AreaChartIcon.js +1 -1
- package/dist/icons/BackwardIcon.js +1 -1
- package/dist/icons/BarChartIcon.js +1 -1
- package/dist/icons/BellFilledIcon.js +1 -1
- package/dist/icons/BellIcon.js +1 -1
- package/dist/icons/BooleanIcon.js +1 -1
- package/dist/icons/CalendarEditIcon.js +1 -1
- package/dist/icons/CalendarIcon.js +1 -1
- package/dist/icons/CaretDownIcon.js +1 -1
- package/dist/icons/CaretUpIcon.js +1 -1
- package/dist/icons/ChartAreaStackedIcon.js +1 -1
- package/dist/icons/ChartAreaStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBarGroupedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarGroupedIcon.js +1 -1
- package/dist/icons/ChartBarHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarLineIcon.js +1 -1
- package/dist/icons/ChartBarStackedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBoxPlot2Icon.js +1 -1
- package/dist/icons/ChartBoxPlotIcon.js +1 -1
- package/dist/icons/ChartBubbleIcon.js +1 -1
- package/dist/icons/ChartDonut2Icon.js +1 -1
- package/dist/icons/ChartFunnelIcon.js +1 -1
- package/dist/icons/ChartHeatmapIcon.js +1 -1
- package/dist/icons/ChartKPIIcon.js +1 -1
- package/dist/icons/ChartPie2Icon.js +1 -1
- package/dist/icons/ChartScatterIcon.js +1 -1
- package/dist/icons/CheckCircleFilledIcon.js +1 -1
- package/dist/icons/CheckCircleIcon.js +1 -1
- package/dist/icons/CheckIcon.js +1 -1
- package/dist/icons/CircleFilledIcon.js +1 -1
- package/dist/icons/ClearIcon.js +1 -1
- package/dist/icons/CloseCircleFilledIcon.js +1 -1
- package/dist/icons/CloseCircleIcon.js +1 -1
- package/dist/icons/CloseIcon.js +1 -1
- package/dist/icons/CodeIcon.js +1 -1
- package/dist/icons/ColumnTotalIcon.js +1 -1
- package/dist/icons/CopyIcon.js +1 -1
- package/dist/icons/CountIcon.js +1 -1
- package/dist/icons/CubeIcon.js +1 -1
- package/dist/icons/CubePauseIcon.js +1 -1
- package/dist/icons/CubePlayIcon.js +1 -1
- package/dist/icons/CurrencyDollarIcon.js +1 -1
- package/dist/icons/DangerIcon.js +1 -1
- package/dist/icons/DashboardIcon.js +1 -1
- package/dist/icons/DatabaseIcon.js +1 -1
- package/dist/icons/DecimalDecreaseIcon.js +1 -1
- package/dist/icons/DecimalIncreaseIcon.js +1 -1
- package/dist/icons/DirectionIcon.js +1 -1
- package/dist/icons/DonutIcon.js +1 -1
- package/dist/icons/DownIcon.js +1 -1
- package/dist/icons/EditIcon.js +1 -1
- package/dist/icons/ExclamationCircleFilledIcon.js +1 -1
- package/dist/icons/ExclamationCircleIcon.js +1 -1
- package/dist/icons/ExclamationIcon.js +1 -1
- package/dist/icons/EyeIcon.js +1 -1
- package/dist/icons/EyeInvisibleIcon.js +1 -1
- package/dist/icons/FilterIcon.js +1 -1
- package/dist/icons/FolderFilledIcon.js +1 -1
- package/dist/icons/FolderIcon.js +1 -1
- package/dist/icons/FolderOpenFilledIcon.js +1 -1
- package/dist/icons/FolderOpenIcon.js +1 -1
- package/dist/icons/ForwardIcon.js +1 -1
- package/dist/icons/GripVerticalIcon.js +1 -1
- package/dist/icons/HierarchyIcon.js +1 -1
- package/dist/icons/HierarchyOpenIcon.js +1 -1
- package/dist/icons/Icon.js +1 -1
- package/dist/icons/InfoCircleIcon.js +1 -1
- package/dist/icons/InfoIcon.js +1 -1
- package/dist/icons/KeyIcon.js +1 -1
- package/dist/icons/LeftIcon.js +1 -1
- package/dist/icons/LineChartIcon.js +1 -1
- package/dist/icons/LoadingIcon.js +1 -1
- package/dist/icons/LockFilledIcon.js +1 -1
- package/dist/icons/LockIcon.js +1 -1
- package/dist/icons/MoreIcon.js +1 -1
- package/dist/icons/NotAllowedIcon.js +1 -1
- package/dist/icons/Number123Icon.js +1 -1
- package/dist/icons/NumberIcon.js +1 -1
- package/dist/icons/PauseCircleFilledIcon.js +1 -1
- package/dist/icons/PauseCircleIcon.js +1 -1
- package/dist/icons/PauseIcon.js +1 -1
- package/dist/icons/PercentageIcon.js +1 -1
- package/dist/icons/PieChartIcon.js +1 -1
- package/dist/icons/PlayCircleIcon.js +1 -1
- package/dist/icons/PlayIcon.js +1 -1
- package/dist/icons/PlusIcon.js +1 -1
- package/dist/icons/ProgressBarIcon.js +1 -1
- package/dist/icons/ReloadIcon.js +1 -1
- package/dist/icons/ReportIcon.js +1 -1
- package/dist/icons/ReturnIcon.js +1 -1
- package/dist/icons/RightIcon.js +1 -1
- package/dist/icons/RowTotalsIcon.js +1 -1
- package/dist/icons/SchemeIcon.js +1 -1
- package/dist/icons/SearchIcon.js +1 -1
- package/dist/icons/SemanticQueryIcon.js +1 -1
- package/dist/icons/SettingsIcon.js +1 -1
- package/dist/icons/ShieldFilledIcon.js +1 -1
- package/dist/icons/ShieldIcon.js +1 -1
- package/dist/icons/SlashIcon.js +1 -1
- package/dist/icons/SparklesIcon.js +1 -1
- package/dist/icons/SqlIcon.js +1 -1
- package/dist/icons/StatsIcon.js +1 -1
- package/dist/icons/StopIcon.js +1 -1
- package/dist/icons/StringIcon.js +1 -1
- package/dist/icons/SubtotalsIcon.js +1 -1
- package/dist/icons/SwitchIcon.js +1 -1
- package/dist/icons/TableIcon.js +1 -1
- package/dist/icons/ThumbsDownIcon.js +1 -1
- package/dist/icons/ThumbsUpIcon.js +1 -1
- package/dist/icons/ThunderboltCrossedIcon.js +1 -1
- package/dist/icons/ThunderboltFilledIcon.js +1 -1
- package/dist/icons/ThunderboltIcon.js +1 -1
- package/dist/icons/TimeIcon.js +1 -1
- package/dist/icons/TrashIcon.js +1 -1
- package/dist/icons/UnlockIcon.js +1 -1
- package/dist/icons/UpIcon.js +1 -1
- package/dist/icons/UserGroupIcon.js +1 -1
- package/dist/icons/UserIcon.js +1 -1
- package/dist/icons/UserLockIcon.js +1 -1
- package/dist/icons/ViewIcon.js +1 -1
- package/dist/icons/WarningFilledIcon.js +1 -1
- package/dist/icons/WarningIcon.js +1 -1
- package/dist/icons/wrap-icon.js +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/provider.js +1 -1
- package/dist/providers/TrackingProvider.js +1 -1
- package/dist/providers/navigationAdapter.default.js +1 -1
- package/dist/tokens/base.js +1 -1
- package/dist/tokens/colors.js +1 -1
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/layout.js +1 -1
- package/dist/tokens/palette.js +1 -1
- package/dist/tokens/shadows.js +1 -1
- package/dist/tokens/sizes.js +1 -1
- package/dist/tokens/spacing.js +1 -1
- package/dist/tokens/typography.js +1 -1
- package/dist/utils/ResizeSensor.js +1 -1
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/modules.js +1 -1
- package/dist/utils/promise.js +1 -1
- package/dist/utils/raf.js +1 -1
- package/dist/utils/random.js +1 -1
- package/dist/utils/range.js +1 -1
- package/dist/utils/react/RenderCache.js +1 -1
- package/dist/utils/react/Slots.js +1 -1
- package/dist/utils/react/chain.js +1 -1
- package/dist/utils/react/forwardRefWithGenerics.js +1 -1
- package/dist/utils/react/index.js +1 -1
- package/dist/utils/react/interactions.js +1 -1
- package/dist/utils/react/isTextOnly.js +1 -1
- package/dist/utils/react/mapProps.js +1 -1
- package/dist/utils/react/mergeProps.js +1 -1
- package/dist/utils/react/nullableValue.js +1 -1
- package/dist/utils/react/resolveIcon.js +1 -1
- package/dist/utils/react/sharedStore.js +1 -1
- package/dist/utils/react/useCombinedRefs.js +1 -1
- package/dist/utils/react/useControlledFocusVisible.js +1 -1
- package/dist/utils/react/useEventBus.js +1 -1
- package/dist/utils/react/useId.js +1 -1
- package/dist/utils/react/useIsDarwin.js +1 -1
- package/dist/utils/react/useKeySymbols.js +1 -1
- package/dist/utils/react/useLayoutEffect.js +1 -1
- package/dist/utils/react/useLocalStorage.js +1 -1
- package/dist/utils/react/useMergeStyles.js +1 -1
- package/dist/utils/react/usePopoverSync.js +1 -1
- package/dist/utils/react/useQaProps.js +1 -1
- package/dist/utils/react/useViewportSize.js +1 -1
- package/dist/utils/react/wrapNodeIfPlain.js +1 -1
- package/dist/utils/selection.js +1 -1
- package/dist/utils/styles.js +1 -1
- package/dist/utils/tree.js +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/version.js +2 -2
- package/docs/components/layout/Board.md +121 -0
- package/package.json +1 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-7b4aa61 | Cube Dev Team */
|
|
2
|
+
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
|
|
3
|
+
import { calcGridColWidth, calcGridItemPosition } from "./grid-core/calculate.js";
|
|
4
|
+
import { tasty } from "@tenphi/tasty";
|
|
5
|
+
import { useRef, useState } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useFocusWithin, useHover, useMove } from "react-aria";
|
|
8
|
+
import { createPortal } from "react-dom";
|
|
9
|
+
|
|
10
|
+
//#region src/components/layout/Board/WidgetHost.tsx
|
|
11
|
+
const WidgetElement = tasty({
|
|
12
|
+
qa: "BoardWidget",
|
|
13
|
+
styles: {
|
|
14
|
+
position: "absolute",
|
|
15
|
+
top: 0,
|
|
16
|
+
left: 0,
|
|
17
|
+
fill: "#surface",
|
|
18
|
+
radius: "1cr",
|
|
19
|
+
border: true,
|
|
20
|
+
shadow: {
|
|
21
|
+
"": false,
|
|
22
|
+
"drag | resizing": "0 2x 4x #dark.20"
|
|
23
|
+
},
|
|
24
|
+
zIndex: {
|
|
25
|
+
"": 1,
|
|
26
|
+
"drag | resizing": 10
|
|
27
|
+
},
|
|
28
|
+
transition: "theme, shadow",
|
|
29
|
+
boxSizing: "border-box",
|
|
30
|
+
userSelect: {
|
|
31
|
+
"": "auto",
|
|
32
|
+
"drag | resizing": "none"
|
|
33
|
+
},
|
|
34
|
+
cursor: {
|
|
35
|
+
"": "auto",
|
|
36
|
+
draggable: "grab",
|
|
37
|
+
drag: "grabbing"
|
|
38
|
+
},
|
|
39
|
+
touchAction: "none",
|
|
40
|
+
overflow: "hidden"
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const HandleElement = tasty({
|
|
44
|
+
qa: "BoardResizeHandle",
|
|
45
|
+
styles: {
|
|
46
|
+
position: "absolute",
|
|
47
|
+
zIndex: 20,
|
|
48
|
+
fill: "#clear",
|
|
49
|
+
"--handle-size": "24px",
|
|
50
|
+
"--handle-overhang": "-8px",
|
|
51
|
+
"--handle-inset": "8px",
|
|
52
|
+
width: {
|
|
53
|
+
"": "$handle-size",
|
|
54
|
+
"[data-axis=\"n\"] | [data-axis=\"s\"]": "auto"
|
|
55
|
+
},
|
|
56
|
+
height: {
|
|
57
|
+
"": "$handle-size",
|
|
58
|
+
"[data-axis=\"e\"] | [data-axis=\"w\"]": "auto"
|
|
59
|
+
},
|
|
60
|
+
top: {
|
|
61
|
+
"": "auto",
|
|
62
|
+
"[data-axis=\"n\"] | [data-axis=\"ne\"] | [data-axis=\"nw\"]": "$handle-overhang",
|
|
63
|
+
"[data-axis=\"e\"] | [data-axis=\"w\"]": "$handle-inset"
|
|
64
|
+
},
|
|
65
|
+
bottom: {
|
|
66
|
+
"": "auto",
|
|
67
|
+
"[data-axis=\"s\"] | [data-axis=\"se\"] | [data-axis=\"sw\"]": "$handle-overhang",
|
|
68
|
+
"[data-axis=\"e\"] | [data-axis=\"w\"]": "$handle-inset"
|
|
69
|
+
},
|
|
70
|
+
left: {
|
|
71
|
+
"": "auto",
|
|
72
|
+
"[data-axis=\"w\"] | [data-axis=\"nw\"] | [data-axis=\"sw\"]": "$handle-overhang",
|
|
73
|
+
"[data-axis=\"n\"] | [data-axis=\"s\"]": "$handle-inset"
|
|
74
|
+
},
|
|
75
|
+
right: {
|
|
76
|
+
"": "auto",
|
|
77
|
+
"[data-axis=\"e\"] | [data-axis=\"ne\"] | [data-axis=\"se\"]": "$handle-overhang",
|
|
78
|
+
"[data-axis=\"n\"] | [data-axis=\"s\"]": "$handle-inset"
|
|
79
|
+
},
|
|
80
|
+
cursor: {
|
|
81
|
+
"": "default",
|
|
82
|
+
"[data-axis=\"n\"] | [data-axis=\"s\"]": "ns-resize",
|
|
83
|
+
"[data-axis=\"e\"] | [data-axis=\"w\"]": "ew-resize",
|
|
84
|
+
"[data-axis=\"ne\"] | [data-axis=\"sw\"]": "nesw-resize",
|
|
85
|
+
"[data-axis=\"nw\"] | [data-axis=\"se\"]": "nwse-resize"
|
|
86
|
+
},
|
|
87
|
+
touchAction: "none"
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const GripElement = tasty({
|
|
91
|
+
qa: "BoardResizeGrip",
|
|
92
|
+
styles: {
|
|
93
|
+
position: "absolute",
|
|
94
|
+
width: "10px",
|
|
95
|
+
height: "10px",
|
|
96
|
+
boxSizing: "border-box",
|
|
97
|
+
pointerEvents: "none",
|
|
98
|
+
opacity: {
|
|
99
|
+
"": 0,
|
|
100
|
+
revealed: 1
|
|
101
|
+
},
|
|
102
|
+
transition: "opacity 120ms ease-in-out",
|
|
103
|
+
borderTop: {
|
|
104
|
+
"": "0",
|
|
105
|
+
"[data-axis=\"ne\"] | [data-axis=\"nw\"]": "2px solid #dark.40"
|
|
106
|
+
},
|
|
107
|
+
borderBottom: {
|
|
108
|
+
"": "0",
|
|
109
|
+
"[data-axis=\"se\"] | [data-axis=\"sw\"]": "2px solid #dark.40"
|
|
110
|
+
},
|
|
111
|
+
borderLeft: {
|
|
112
|
+
"": "0",
|
|
113
|
+
"[data-axis=\"nw\"] | [data-axis=\"sw\"]": "2px solid #dark.40"
|
|
114
|
+
},
|
|
115
|
+
borderRight: {
|
|
116
|
+
"": "0",
|
|
117
|
+
"[data-axis=\"ne\"] | [data-axis=\"se\"]": "2px solid #dark.40"
|
|
118
|
+
},
|
|
119
|
+
radius: {
|
|
120
|
+
"": "0",
|
|
121
|
+
"[data-axis=\"se\"]": "0 0 4px 0",
|
|
122
|
+
"[data-axis=\"sw\"]": "0 0 0 4px",
|
|
123
|
+
"[data-axis=\"ne\"]": "0 4px 0 0",
|
|
124
|
+
"[data-axis=\"nw\"]": "4px 0 0 0"
|
|
125
|
+
},
|
|
126
|
+
top: {
|
|
127
|
+
"": "auto",
|
|
128
|
+
"[data-axis=\"ne\"] | [data-axis=\"nw\"]": "4px"
|
|
129
|
+
},
|
|
130
|
+
bottom: {
|
|
131
|
+
"": "auto",
|
|
132
|
+
"[data-axis=\"se\"] | [data-axis=\"sw\"]": "4px"
|
|
133
|
+
},
|
|
134
|
+
left: {
|
|
135
|
+
"": "auto",
|
|
136
|
+
"[data-axis=\"nw\"] | [data-axis=\"sw\"]": "4px"
|
|
137
|
+
},
|
|
138
|
+
right: {
|
|
139
|
+
"": "auto",
|
|
140
|
+
"[data-axis=\"ne\"] | [data-axis=\"se\"]": "4px"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
/** Corner axes get a visible grip affordance on hover/focus/resize. */
|
|
145
|
+
function isCornerAxis(axis) {
|
|
146
|
+
return axis.length === 2;
|
|
147
|
+
}
|
|
148
|
+
function ResizeHandle({ axis, onResize }) {
|
|
149
|
+
const { moveProps } = useMove({
|
|
150
|
+
onMoveStart() {
|
|
151
|
+
onResize(axis, "start", 0, 0);
|
|
152
|
+
},
|
|
153
|
+
onMove(e) {
|
|
154
|
+
onResize(axis, "move", e.deltaX, e.deltaY);
|
|
155
|
+
},
|
|
156
|
+
onMoveEnd() {
|
|
157
|
+
onResize(axis, "end", 0, 0);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
const stopProps = {
|
|
161
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
162
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
163
|
+
onTouchStart: (e) => e.stopPropagation()
|
|
164
|
+
};
|
|
165
|
+
return /* @__PURE__ */ jsx(HandleElement, {
|
|
166
|
+
"data-axis": axis,
|
|
167
|
+
...mergeProps$1(stopProps, moveProps),
|
|
168
|
+
"aria-hidden": "true"
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The positioned, interactive wrapper a board renders for each layout item it
|
|
173
|
+
* owns. Content is pulled from the shared store (by id), so any board can host
|
|
174
|
+
* any widget. Dragging uses React Aria `useMove`; during a drag the widget
|
|
175
|
+
* renders into the shared overlay portal so it can float outside its board.
|
|
176
|
+
*/
|
|
177
|
+
function WidgetHost(props) {
|
|
178
|
+
const { boardId, item, positionParams, registration, isDraggable, isResizable, resizeHandles, registry, dragState, onResize } = props;
|
|
179
|
+
const hostRef = useRef(null);
|
|
180
|
+
const isActiveDrag = dragState?.itemId === item.i;
|
|
181
|
+
const useOverlay = isActiveDrag && dragState?.pointerType !== "keyboard";
|
|
182
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
183
|
+
const [isFocusWithin, setIsFocusWithin] = useState(false);
|
|
184
|
+
const { hoverProps, isHovered } = useHover({ isDisabled: isActiveDrag });
|
|
185
|
+
const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setIsFocusWithin });
|
|
186
|
+
const gripsRevealed = isResizable && !item.static && !isActiveDrag && (isHovered || isFocusWithin || isResizing);
|
|
187
|
+
const { moveProps } = useMove({
|
|
188
|
+
onMoveStart(e) {
|
|
189
|
+
if (!isDraggable) return;
|
|
190
|
+
const rect = hostRef.current?.getBoundingClientRect();
|
|
191
|
+
const pos = calcGridItemPosition(positionParams, item.x, item.y, item.w, item.h);
|
|
192
|
+
const vr = rect ? {
|
|
193
|
+
left: rect.left,
|
|
194
|
+
top: rect.top,
|
|
195
|
+
width: rect.width,
|
|
196
|
+
height: rect.height
|
|
197
|
+
} : {
|
|
198
|
+
left: pos.left,
|
|
199
|
+
top: pos.top,
|
|
200
|
+
width: pos.width,
|
|
201
|
+
height: pos.height
|
|
202
|
+
};
|
|
203
|
+
registry.onDragStart(boardId, item.i, vr, e.pointerType);
|
|
204
|
+
},
|
|
205
|
+
onMove(e) {
|
|
206
|
+
if (!isDraggable) return;
|
|
207
|
+
if (e.pointerType === "keyboard") {
|
|
208
|
+
const stepX = calcGridColWidth(positionParams) + positionParams.margin[0];
|
|
209
|
+
const stepY = positionParams.rowHeight + positionParams.margin[1];
|
|
210
|
+
registry.onDragMove(Math.sign(e.deltaX) * stepX, Math.sign(e.deltaY) * stepY, e.pointerType);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
registry.onDragMove(e.deltaX, e.deltaY, e.pointerType);
|
|
214
|
+
},
|
|
215
|
+
onMoveEnd() {
|
|
216
|
+
if (!isDraggable) return;
|
|
217
|
+
registry.onDragEnd();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
const a11yProps = {
|
|
221
|
+
tabIndex: isDraggable ? 0 : void 0,
|
|
222
|
+
"aria-roledescription": isDraggable ? "Draggable widget" : void 0,
|
|
223
|
+
"aria-label": registration?.qa ?? item.i
|
|
224
|
+
};
|
|
225
|
+
const handleResize = (axis, phase, dx, dy) => {
|
|
226
|
+
if (phase === "start") setIsResizing(true);
|
|
227
|
+
else if (phase === "end") setIsResizing(false);
|
|
228
|
+
onResize(item.i, axis, phase, dx, dy);
|
|
229
|
+
};
|
|
230
|
+
const mods = {
|
|
231
|
+
drag: isActiveDrag,
|
|
232
|
+
draggable: isDraggable && !isActiveDrag,
|
|
233
|
+
static: !!item.static,
|
|
234
|
+
resizing: isResizing
|
|
235
|
+
};
|
|
236
|
+
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [registration?.content, isResizable && !item.static ? /* @__PURE__ */ jsxs(Fragment$1, { children: [resizeHandles.map((axis) => /* @__PURE__ */ jsx(ResizeHandle, {
|
|
237
|
+
axis,
|
|
238
|
+
onResize: handleResize
|
|
239
|
+
}, axis)), resizeHandles.filter(isCornerAxis).map((axis) => /* @__PURE__ */ jsx(GripElement, {
|
|
240
|
+
"data-axis": axis,
|
|
241
|
+
mods: { revealed: gripsRevealed },
|
|
242
|
+
"aria-hidden": "true"
|
|
243
|
+
}, `grip-${axis}`))] }) : null] });
|
|
244
|
+
if (useOverlay && dragState) {
|
|
245
|
+
const overlayNode = registry.overlayRef.current;
|
|
246
|
+
const overlayWidget = /* @__PURE__ */ jsx(WidgetElement, {
|
|
247
|
+
...mergeProps$1(moveProps, hoverProps, focusWithinProps, a11yProps, { style: {
|
|
248
|
+
position: "absolute",
|
|
249
|
+
left: `${dragState.rect.left}px`,
|
|
250
|
+
top: `${dragState.rect.top}px`,
|
|
251
|
+
width: `${dragState.rect.width}px`,
|
|
252
|
+
height: `${dragState.rect.height}px`,
|
|
253
|
+
pointerEvents: "none"
|
|
254
|
+
} }),
|
|
255
|
+
qa: registration?.qa,
|
|
256
|
+
mods,
|
|
257
|
+
styles: registration?.styles,
|
|
258
|
+
children: content
|
|
259
|
+
});
|
|
260
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: overlayNode ? createPortal(overlayWidget, overlayNode) : overlayWidget });
|
|
261
|
+
}
|
|
262
|
+
const pos = calcGridItemPosition(positionParams, item.x, item.y, item.w, item.h);
|
|
263
|
+
return /* @__PURE__ */ jsx(WidgetElement, {
|
|
264
|
+
ref: hostRef,
|
|
265
|
+
...mergeProps$1(moveProps, hoverProps, focusWithinProps, a11yProps, { style: {
|
|
266
|
+
transform: `translate(${pos.left}px, ${pos.top}px)`,
|
|
267
|
+
width: `${pos.width}px`,
|
|
268
|
+
height: `${pos.height}px`
|
|
269
|
+
} }),
|
|
270
|
+
qa: registration?.qa,
|
|
271
|
+
mods,
|
|
272
|
+
styles: registration?.styles,
|
|
273
|
+
children: content
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
export { WidgetHost };
|
|
279
|
+
//# sourceMappingURL=WidgetHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WidgetHost.js","names":["mergeProps"],"sources":["../../../../src/components/layout/Board/WidgetHost.tsx"],"sourcesContent":["import { Styles, tasty } from '@tenphi/tasty';\nimport { CSSProperties, useRef, useState } from 'react';\nimport { useFocusWithin, useHover, useMove } from 'react-aria';\nimport { createPortal } from 'react-dom';\n\nimport { mergeProps } from '../../../utils/react';\n\nimport {\n BoardDragState,\n BoardRegistryContextValue,\n ViewportRect,\n} from './board-context';\nimport { WidgetRegistration } from './board-store';\nimport {\n calcGridColWidth,\n calcGridItemPosition,\n LayoutItem,\n PositionParams,\n ResizeHandleAxis,\n} from './grid-core';\n\nexport type ResizePhase = 'start' | 'move' | 'end';\n\nconst WidgetElement = tasty({\n qa: 'BoardWidget',\n styles: {\n position: 'absolute',\n top: 0,\n left: 0,\n fill: '#surface',\n radius: '1cr',\n border: true,\n shadow: {\n '': false,\n 'drag | resizing': '0 2x 4x #dark.20',\n },\n zIndex: {\n '': 1,\n 'drag | resizing': 10,\n },\n transition: 'theme, shadow',\n boxSizing: 'border-box',\n userSelect: {\n '': 'auto',\n 'drag | resizing': 'none',\n },\n cursor: {\n '': 'auto',\n draggable: 'grab',\n drag: 'grabbing',\n },\n touchAction: 'none',\n overflow: 'hidden',\n },\n});\n\nconst HandleElement = tasty({\n qa: 'BoardResizeHandle',\n styles: {\n position: 'absolute',\n zIndex: 20,\n fill: '#clear',\n // Overhang: how far the hit-zone extends beyond the widget edge.\n '--handle-size': '24px',\n '--handle-overhang': '-8px',\n '--handle-inset': '8px',\n width: {\n '': '$handle-size',\n '[data-axis=\"n\"] | [data-axis=\"s\"]': 'auto',\n },\n height: {\n '': '$handle-size',\n '[data-axis=\"e\"] | [data-axis=\"w\"]': 'auto',\n },\n top: {\n '': 'auto',\n '[data-axis=\"n\"] | [data-axis=\"ne\"] | [data-axis=\"nw\"]':\n '$handle-overhang',\n '[data-axis=\"e\"] | [data-axis=\"w\"]': '$handle-inset',\n },\n bottom: {\n '': 'auto',\n '[data-axis=\"s\"] | [data-axis=\"se\"] | [data-axis=\"sw\"]':\n '$handle-overhang',\n '[data-axis=\"e\"] | [data-axis=\"w\"]': '$handle-inset',\n },\n left: {\n '': 'auto',\n '[data-axis=\"w\"] | [data-axis=\"nw\"] | [data-axis=\"sw\"]':\n '$handle-overhang',\n '[data-axis=\"n\"] | [data-axis=\"s\"]': '$handle-inset',\n },\n right: {\n '': 'auto',\n '[data-axis=\"e\"] | [data-axis=\"ne\"] | [data-axis=\"se\"]':\n '$handle-overhang',\n '[data-axis=\"n\"] | [data-axis=\"s\"]': '$handle-inset',\n },\n cursor: {\n '': 'default',\n '[data-axis=\"n\"] | [data-axis=\"s\"]': 'ns-resize',\n '[data-axis=\"e\"] | [data-axis=\"w\"]': 'ew-resize',\n '[data-axis=\"ne\"] | [data-axis=\"sw\"]': 'nesw-resize',\n '[data-axis=\"nw\"] | [data-axis=\"se\"]': 'nwse-resize',\n },\n touchAction: 'none',\n },\n});\n\nconst GripElement = tasty({\n qa: 'BoardResizeGrip',\n styles: {\n position: 'absolute',\n width: '10px',\n height: '10px',\n boxSizing: 'border-box',\n pointerEvents: 'none',\n opacity: {\n '': 0,\n revealed: 1,\n },\n transition: 'opacity 120ms ease-in-out',\n borderTop: {\n '': '0',\n '[data-axis=\"ne\"] | [data-axis=\"nw\"]': '2px solid #dark.40',\n },\n borderBottom: {\n '': '0',\n '[data-axis=\"se\"] | [data-axis=\"sw\"]': '2px solid #dark.40',\n },\n borderLeft: {\n '': '0',\n '[data-axis=\"nw\"] | [data-axis=\"sw\"]': '2px solid #dark.40',\n },\n borderRight: {\n '': '0',\n '[data-axis=\"ne\"] | [data-axis=\"se\"]': '2px solid #dark.40',\n },\n radius: {\n '': '0',\n '[data-axis=\"se\"]': '0 0 4px 0',\n '[data-axis=\"sw\"]': '0 0 0 4px',\n '[data-axis=\"ne\"]': '0 4px 0 0',\n '[data-axis=\"nw\"]': '4px 0 0 0',\n },\n top: {\n '': 'auto',\n '[data-axis=\"ne\"] | [data-axis=\"nw\"]': '4px',\n },\n bottom: {\n '': 'auto',\n '[data-axis=\"se\"] | [data-axis=\"sw\"]': '4px',\n },\n left: {\n '': 'auto',\n '[data-axis=\"nw\"] | [data-axis=\"sw\"]': '4px',\n },\n right: {\n '': 'auto',\n '[data-axis=\"ne\"] | [data-axis=\"se\"]': '4px',\n },\n },\n});\n\n/** Corner axes get a visible grip affordance on hover/focus/resize. */\nfunction isCornerAxis(axis: ResizeHandleAxis): boolean {\n return axis.length === 2;\n}\n\ninterface ResizeHandleProps {\n axis: ResizeHandleAxis;\n onResize: (\n axis: ResizeHandleAxis,\n phase: ResizePhase,\n dx: number,\n dy: number,\n ) => void;\n}\n\nfunction ResizeHandle({ axis, onResize }: ResizeHandleProps) {\n const { moveProps } = useMove({\n onMoveStart() {\n onResize(axis, 'start', 0, 0);\n },\n onMove(e) {\n onResize(axis, 'move', e.deltaX, e.deltaY);\n },\n onMoveEnd() {\n onResize(axis, 'end', 0, 0);\n },\n });\n\n const stopProps = {\n onPointerDown: (e: React.PointerEvent) => e.stopPropagation(),\n onMouseDown: (e: React.MouseEvent) => e.stopPropagation(),\n onTouchStart: (e: React.TouchEvent) => e.stopPropagation(),\n };\n\n return (\n <HandleElement\n data-axis={axis}\n {...mergeProps(stopProps, moveProps)}\n aria-hidden=\"true\"\n />\n );\n}\n\nexport interface WidgetHostProps {\n boardId: string;\n item: LayoutItem;\n positionParams: PositionParams;\n registration: WidgetRegistration | undefined;\n isDraggable: boolean;\n isResizable: boolean;\n resizeHandles: ResizeHandleAxis[];\n registry: BoardRegistryContextValue;\n dragState: BoardDragState | null;\n onResize: (\n id: string,\n axis: ResizeHandleAxis,\n phase: ResizePhase,\n dx: number,\n dy: number,\n ) => void;\n}\n\n/**\n * The positioned, interactive wrapper a board renders for each layout item it\n * owns. Content is pulled from the shared store (by id), so any board can host\n * any widget. Dragging uses React Aria `useMove`; during a drag the widget\n * renders into the shared overlay portal so it can float outside its board.\n */\nexport function WidgetHost(props: WidgetHostProps) {\n const {\n boardId,\n item,\n positionParams,\n registration,\n isDraggable,\n isResizable,\n resizeHandles,\n registry,\n dragState,\n onResize,\n } = props;\n\n const hostRef = useRef<HTMLDivElement | null>(null);\n const isActiveDrag = dragState?.itemId === item.i;\n // Keyboard drags stay in place: moving the focused element into the overlay\n // portal would unmount it and stop arrow-key move events.\n const useOverlay = isActiveDrag && dragState?.pointerType !== 'keyboard';\n\n const [isResizing, setIsResizing] = useState(false);\n const [isFocusWithin, setIsFocusWithin] = useState(false);\n const { hoverProps, isHovered } = useHover({ isDisabled: isActiveDrag });\n const { focusWithinProps } = useFocusWithin({\n onFocusWithinChange: setIsFocusWithin,\n });\n\n // Reveal the resize grips when the widget is interacted with (but not while it\n // is being dragged, where the widget floats in the overlay).\n const gripsRevealed =\n isResizable &&\n !item.static &&\n !isActiveDrag &&\n (isHovered || isFocusWithin || isResizing);\n\n const { moveProps } = useMove({\n onMoveStart(e) {\n if (!isDraggable) return;\n const rect = hostRef.current?.getBoundingClientRect();\n const pos = calcGridItemPosition(\n positionParams,\n item.x,\n item.y,\n item.w,\n item.h,\n );\n const vr: ViewportRect = rect\n ? {\n left: rect.left,\n top: rect.top,\n width: rect.width,\n height: rect.height,\n }\n : {\n left: pos.left,\n top: pos.top,\n width: pos.width,\n height: pos.height,\n };\n registry.onDragStart(boardId, item.i, vr, e.pointerType);\n },\n onMove(e) {\n if (!isDraggable) return;\n if (e.pointerType === 'keyboard') {\n // Amplify arrow-key steps to a full grid cell so items actually move.\n const colWidth = calcGridColWidth(positionParams);\n const stepX = colWidth + positionParams.margin[0];\n const stepY = positionParams.rowHeight + positionParams.margin[1];\n registry.onDragMove(\n Math.sign(e.deltaX) * stepX,\n Math.sign(e.deltaY) * stepY,\n e.pointerType,\n );\n return;\n }\n registry.onDragMove(e.deltaX, e.deltaY, e.pointerType);\n },\n onMoveEnd() {\n if (!isDraggable) return;\n registry.onDragEnd();\n },\n });\n\n const a11yProps = {\n tabIndex: isDraggable ? 0 : undefined,\n 'aria-roledescription': isDraggable ? 'Draggable widget' : undefined,\n 'aria-label': registration?.qa ?? item.i,\n };\n\n const handleResize = (\n axis: ResizeHandleAxis,\n phase: ResizePhase,\n dx: number,\n dy: number,\n ) => {\n if (phase === 'start') setIsResizing(true);\n else if (phase === 'end') setIsResizing(false);\n onResize(item.i, axis, phase, dx, dy);\n };\n\n const mods = {\n drag: isActiveDrag,\n draggable: isDraggable && !isActiveDrag,\n static: !!item.static,\n resizing: isResizing,\n };\n\n const content = (\n <>\n {registration?.content}\n {isResizable && !item.static ? (\n <>\n {resizeHandles.map((axis) => (\n <ResizeHandle key={axis} axis={axis} onResize={handleResize} />\n ))}\n {resizeHandles.filter(isCornerAxis).map((axis) => (\n <GripElement\n key={`grip-${axis}`}\n data-axis={axis}\n mods={{ revealed: gripsRevealed }}\n aria-hidden=\"true\"\n />\n ))}\n </>\n ) : null}\n </>\n );\n\n // While dragging with a pointer, render the widget into the shared overlay so\n // it floats above everything (immune to ancestor overflow clipping).\n if (useOverlay && dragState) {\n const overlayNode = registry.overlayRef.current;\n const overlayStyle: CSSProperties = {\n position: 'absolute',\n left: `${dragState.rect.left}px`,\n top: `${dragState.rect.top}px`,\n width: `${dragState.rect.width}px`,\n height: `${dragState.rect.height}px`,\n pointerEvents: 'none',\n };\n\n const overlayWidget = (\n <WidgetElement\n {...mergeProps(moveProps, hoverProps, focusWithinProps, a11yProps, {\n style: overlayStyle,\n })}\n qa={registration?.qa}\n mods={mods}\n styles={registration?.styles as Styles}\n >\n {content}\n </WidgetElement>\n );\n\n return (\n <>\n {overlayNode ? createPortal(overlayWidget, overlayNode) : overlayWidget}\n </>\n );\n }\n\n const pos = calcGridItemPosition(\n positionParams,\n item.x,\n item.y,\n item.w,\n item.h,\n );\n const style: CSSProperties = {\n transform: `translate(${pos.left}px, ${pos.top}px)`,\n width: `${pos.width}px`,\n height: `${pos.height}px`,\n };\n\n return (\n <WidgetElement\n ref={hostRef}\n {...mergeProps(moveProps, hoverProps, focusWithinProps, a11yProps, {\n style,\n })}\n qa={registration?.qa}\n mods={mods}\n styles={registration?.styles as Styles}\n >\n {content}\n </WidgetElement>\n );\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-7b4aa61 | Cube Dev Team */
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/layout/Board/board-context.tsx
|
|
5
|
+
const BoardRegistryContext = createContext(null);
|
|
6
|
+
function useBoardRegistry() {
|
|
7
|
+
return useContext(BoardRegistryContext);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { BoardRegistryContext, useBoardRegistry };
|
|
12
|
+
//# sourceMappingURL=board-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board-context.js","names":[],"sources":["../../../../src/components/layout/Board/board-context.tsx"],"sourcesContent":["import { createContext, MutableRefObject, useContext } from 'react';\n\nimport type { BoardWidgetStore } from './board-store';\nimport type {\n Compactor,\n LayoutConstraint,\n LayoutItem,\n PositionParams,\n} from './grid-core';\n\n/** A rectangle in viewport (client) coordinates. */\nexport interface ViewportRect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\n/**\n * Everything the cross-board registry needs to read from / write to a single\n * board. Methods read live refs so a single stable entry can be registered once\n * per board and stay current across renders.\n */\nexport interface BoardEntry {\n id: string;\n /** Viewport rect of the content area where widgets are positioned. */\n getContentRect: () => DOMRect | null;\n /** The DOM node of the content area (used to detect nested-in-drag boards). */\n getContentNode: () => HTMLElement | null;\n getPositionParams: () => PositionParams;\n getConstraints: () => LayoutConstraint[];\n getCompactor: () => Compactor;\n getMaxRows: () => number;\n getContainerHeight: () => number;\n getLayout: () => LayoutItem[];\n /** Update the board layout. `commit` fires `onLayoutChange`. */\n applyLayout: (layout: LayoutItem[], commit: boolean) => void;\n setPlaceholder: (item: LayoutItem | null) => void;\n isDroppable: () => boolean;\n}\n\n/** Live drag state, shared across boards for overlay + placeholders. */\nexport interface BoardDragState {\n sourceBoardId: string;\n /** Board currently owning the dragged item (changes as it crosses boards). */\n currentBoardId: string;\n itemId: string;\n /** Snapshot of the dragged item (grid units; w/h preserved across boards). */\n item: LayoutItem;\n /** Dragged widget rect in viewport coordinates (follows the pointer). */\n rect: ViewportRect;\n pointerType: string;\n}\n\nexport interface BoardRegistryContextValue {\n store: BoardWidgetStore;\n overlayRef: MutableRefObject<HTMLDivElement | null>;\n registerBoard: (entry: BoardEntry) => () => void;\n onDragStart: (\n boardId: string,\n itemId: string,\n rect: ViewportRect,\n pointerType: string,\n ) => void;\n onDragMove: (deltaX: number, deltaY: number, pointerType: string) => void;\n onDragEnd: () => void;\n dragState: BoardDragState | null;\n}\n\nexport const BoardRegistryContext =\n createContext<BoardRegistryContextValue | null>(null);\n\nexport function useBoardRegistry(): BoardRegistryContextValue | null {\n return useContext(BoardRegistryContext);\n}\n"],"mappings":";;;;AAqEA,MAAa,uBACX,cAAgD,KAAK;AAEvD,SAAgB,mBAAqD;AACnE,QAAO,WAAW,qBAAqB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-7b4aa61 | Cube Dev Team */
|
|
2
|
+
//#region src/components/layout/Board/board-store.ts
|
|
3
|
+
/**
|
|
4
|
+
* A tiny external store mapping widget id -> registration.
|
|
5
|
+
*
|
|
6
|
+
* Boards read from it via `useSyncExternalStore`, so a change to any widget's
|
|
7
|
+
* content or config re-renders the hosting board without prop drilling through
|
|
8
|
+
* the (possibly cross-board) tree.
|
|
9
|
+
*/
|
|
10
|
+
var BoardWidgetStore = class {
|
|
11
|
+
map = /* @__PURE__ */ new Map();
|
|
12
|
+
owners = /* @__PURE__ */ new Map();
|
|
13
|
+
listeners = /* @__PURE__ */ new Set();
|
|
14
|
+
version = 0;
|
|
15
|
+
register(reg, owner) {
|
|
16
|
+
const prev = this.map.get(reg.id);
|
|
17
|
+
this.map.set(reg.id, reg);
|
|
18
|
+
this.owners.set(reg.id, owner);
|
|
19
|
+
if (!prev || prev.isDraggable !== reg.isDraggable || prev.isResizable !== reg.isResizable || prev.qa !== reg.qa) {
|
|
20
|
+
this.version++;
|
|
21
|
+
this.emit();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
unregister(id, owner) {
|
|
25
|
+
if (this.owners.get(id) !== owner) return;
|
|
26
|
+
this.owners.delete(id);
|
|
27
|
+
if (this.map.delete(id)) {
|
|
28
|
+
this.version++;
|
|
29
|
+
this.emit();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
get(id) {
|
|
33
|
+
return this.map.get(id);
|
|
34
|
+
}
|
|
35
|
+
getVersion = () => this.version;
|
|
36
|
+
subscribe = (listener) => {
|
|
37
|
+
this.listeners.add(listener);
|
|
38
|
+
return () => {
|
|
39
|
+
this.listeners.delete(listener);
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
emit() {
|
|
43
|
+
this.listeners.forEach((listener) => listener());
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { BoardWidgetStore };
|
|
49
|
+
//# sourceMappingURL=board-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board-store.js","names":[],"sources":["../../../../src/components/layout/Board/board-store.ts"],"sourcesContent":["import type { Styles } from '@tenphi/tasty';\nimport type { ReactNode } from 'react';\nimport type { LayoutConstraint, ResizeHandleAxis } from './grid-core';\n\n/**\n * Declarative registration for a single widget.\n *\n * Widget *content* is decoupled from widget *position*: content is registered\n * here by `Board.Widget` keyed by id, while positioning/ownership lives in a\n * board's layout state. This decoupling is what allows a widget to be hosted\n * (and transferred) between different boards under the same `BoardProvider`.\n */\nexport interface WidgetRegistration {\n id: string;\n content: ReactNode;\n isDraggable?: boolean;\n isResizable?: boolean;\n resizeHandles?: ResizeHandleAxis[];\n constraints?: LayoutConstraint[];\n qa?: string;\n styles?: Styles;\n}\n\n/**\n * A tiny external store mapping widget id -> registration.\n *\n * Boards read from it via `useSyncExternalStore`, so a change to any widget's\n * content or config re-renders the hosting board without prop drilling through\n * the (possibly cross-board) tree.\n */\nexport class BoardWidgetStore {\n private map = new Map<string, WidgetRegistration>();\n // Tracks which mounted `Board.Widget` instance currently owns each id. This\n // guards against a stale unregister from an unmounting instance clobbering a\n // freshly-mounted instance's registration - which happens when a widget's\n // subtree is relocated (e.g. dragging a container widget that hosts a nested\n // board moves it into the overlay portal, remounting the inner widgets).\n private owners = new Map<string, object>();\n private listeners = new Set<() => void>();\n private version = 0;\n\n register(reg: WidgetRegistration, owner: object): void {\n const prev = this.map.get(reg.id);\n this.map.set(reg.id, reg);\n this.owners.set(reg.id, owner);\n\n // Only notify on structural (primitive) changes. Content, styles and\n // resize handles are read fresh from the store by the hosting board on its\n // next render, so emitting for those (which change reference every render)\n // would cause an infinite register -> re-render -> register loop.\n const structuralChange =\n !prev ||\n prev.isDraggable !== reg.isDraggable ||\n prev.isResizable !== reg.isResizable ||\n prev.qa !== reg.qa;\n\n if (structuralChange) {\n this.version++;\n this.emit();\n }\n }\n\n unregister(id: string, owner: object): void {\n // Ignore unregister calls from an instance that no longer owns the id (a\n // newer instance has already taken over).\n if (this.owners.get(id) !== owner) return;\n\n this.owners.delete(id);\n if (this.map.delete(id)) {\n this.version++;\n this.emit();\n }\n }\n\n get(id: string): WidgetRegistration | undefined {\n return this.map.get(id);\n }\n\n getVersion = (): number => this.version;\n\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n private emit(): void {\n this.listeners.forEach((listener) => listener());\n }\n}\n"],"mappings":";;;;;;;;;AA8BA,IAAa,mBAAb,MAA8B;CAC5B,AAAQ,sBAAM,IAAI,KAAiC;CAMnD,AAAQ,yBAAS,IAAI,KAAqB;CAC1C,AAAQ,4BAAY,IAAI,KAAiB;CACzC,AAAQ,UAAU;CAElB,SAAS,KAAyB,OAAqB;EACrD,MAAM,OAAO,KAAK,IAAI,IAAI,IAAI,GAAG;AACjC,OAAK,IAAI,IAAI,IAAI,IAAI,IAAI;AACzB,OAAK,OAAO,IAAI,IAAI,IAAI,MAAM;AAY9B,MALE,CAAC,QACD,KAAK,gBAAgB,IAAI,eACzB,KAAK,gBAAgB,IAAI,eACzB,KAAK,OAAO,IAAI,IAEI;AACpB,QAAK;AACL,QAAK,MAAM;;;CAIf,WAAW,IAAY,OAAqB;AAG1C,MAAI,KAAK,OAAO,IAAI,GAAG,KAAK,MAAO;AAEnC,OAAK,OAAO,OAAO,GAAG;AACtB,MAAI,KAAK,IAAI,OAAO,GAAG,EAAE;AACvB,QAAK;AACL,QAAK,MAAM;;;CAIf,IAAI,IAA4C;AAC9C,SAAO,KAAK,IAAI,IAAI,GAAG;;CAGzB,mBAA2B,KAAK;CAEhC,aAAa,aAAuC;AAClD,OAAK,UAAU,IAAI,SAAS;AAC5B,eAAa;AACX,QAAK,UAAU,OAAO,SAAS;;;CAInC,AAAQ,OAAa;AACnB,OAAK,UAAU,SAAS,aAAa,UAAU,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-7b4aa61 | Cube Dev Team */
|
|
2
|
+
//#region src/components/layout/Board/grid-core/calculate.ts
|
|
3
|
+
/** Calculate the width of a single grid column in pixels. */
|
|
4
|
+
function calcGridColWidth(positionParams) {
|
|
5
|
+
const { margin, containerPadding, containerWidth, cols } = positionParams;
|
|
6
|
+
return (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Calculate the pixel size for a grid unit dimension (width or height).
|
|
10
|
+
*/
|
|
11
|
+
function calcGridItemWHPx(gridUnits, colOrRowSize, marginPx) {
|
|
12
|
+
if (!Number.isFinite(gridUnits)) return gridUnits;
|
|
13
|
+
return Math.round(colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Calculate pixel position for a grid item. Returns left, top, width, height.
|
|
17
|
+
*/
|
|
18
|
+
function calcGridItemPosition(positionParams, x, y, w, h, dragPosition, resizePosition) {
|
|
19
|
+
const { margin, containerPadding, rowHeight } = positionParams;
|
|
20
|
+
const colWidth = calcGridColWidth(positionParams);
|
|
21
|
+
let width;
|
|
22
|
+
let height;
|
|
23
|
+
let top;
|
|
24
|
+
let left;
|
|
25
|
+
if (resizePosition) {
|
|
26
|
+
width = Math.round(resizePosition.width);
|
|
27
|
+
height = Math.round(resizePosition.height);
|
|
28
|
+
} else {
|
|
29
|
+
width = calcGridItemWHPx(w, colWidth, margin[0]);
|
|
30
|
+
height = calcGridItemWHPx(h, rowHeight, margin[1]);
|
|
31
|
+
}
|
|
32
|
+
if (dragPosition) {
|
|
33
|
+
top = Math.round(dragPosition.top);
|
|
34
|
+
left = Math.round(dragPosition.left);
|
|
35
|
+
} else if (resizePosition) {
|
|
36
|
+
top = Math.round(resizePosition.top);
|
|
37
|
+
left = Math.round(resizePosition.left);
|
|
38
|
+
} else {
|
|
39
|
+
top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);
|
|
40
|
+
left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);
|
|
41
|
+
}
|
|
42
|
+
if (!dragPosition && !resizePosition) {
|
|
43
|
+
if (Number.isFinite(w)) {
|
|
44
|
+
const actualMarginRight = Math.round((colWidth + margin[0]) * (x + w) + containerPadding[0]) - left - width;
|
|
45
|
+
if (actualMarginRight !== margin[0]) width += actualMarginRight - margin[0];
|
|
46
|
+
}
|
|
47
|
+
if (Number.isFinite(h)) {
|
|
48
|
+
const actualMarginBottom = Math.round((rowHeight + margin[1]) * (y + h) + containerPadding[1]) - top - height;
|
|
49
|
+
if (actualMarginBottom !== margin[1]) height += actualMarginBottom - margin[1];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
top,
|
|
54
|
+
left,
|
|
55
|
+
width,
|
|
56
|
+
height
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Translate pixel coordinates to grid units without clamping. */
|
|
60
|
+
function calcXYRaw(positionParams, top, left) {
|
|
61
|
+
const { margin, containerPadding, rowHeight } = positionParams;
|
|
62
|
+
const colWidth = calcGridColWidth(positionParams);
|
|
63
|
+
return {
|
|
64
|
+
x: Math.round((left - containerPadding[0]) / (colWidth + margin[0])),
|
|
65
|
+
y: Math.round((top - containerPadding[1]) / (rowHeight + margin[1]))
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Calculate grid units from pixel dimensions (clamped by handle direction). */
|
|
69
|
+
function calcWH(positionParams, width, height, x, y, handle) {
|
|
70
|
+
const { margin, maxRows, cols, rowHeight } = positionParams;
|
|
71
|
+
const colWidth = calcGridColWidth(positionParams);
|
|
72
|
+
const w = Math.round((width + margin[0]) / (colWidth + margin[0]));
|
|
73
|
+
const h = Math.round((height + margin[1]) / (rowHeight + margin[1]));
|
|
74
|
+
let _w = clamp(w, 0, cols - x);
|
|
75
|
+
let _h = clamp(h, 0, maxRows - y);
|
|
76
|
+
if (handle === "sw" || handle === "w" || handle === "nw") _w = clamp(w, 0, cols);
|
|
77
|
+
if (handle === "nw" || handle === "n" || handle === "ne") _h = clamp(h, 0, maxRows);
|
|
78
|
+
return {
|
|
79
|
+
w: _w,
|
|
80
|
+
h: _h
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Clamp a number between bounds. */
|
|
84
|
+
function clamp(num, lowerBound, upperBound) {
|
|
85
|
+
return Math.max(Math.min(num, upperBound), lowerBound);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { calcGridColWidth, calcGridItemPosition, calcWH, calcXYRaw };
|
|
90
|
+
//# sourceMappingURL=calculate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculate.js","names":[],"sources":["../../../../../src/components/layout/Board/grid-core/calculate.ts"],"sourcesContent":["/**\n * Grid calculation utilities.\n *\n * Vendored from react-grid-layout v2 (`src/core/calculate.ts`).\n * See ./NOTICE.md for attribution and license.\n *\n * These functions convert between grid units and pixel positions.\n */\n\nimport type { Position, ResizeHandleAxis } from './types';\n\n/** Parameters needed for position calculations. */\nexport interface PositionParams {\n readonly margin: readonly [number, number];\n readonly containerPadding: readonly [number, number];\n readonly containerWidth: number;\n readonly cols: number;\n readonly rowHeight: number;\n readonly maxRows: number;\n}\n\n// ============================================================================\n// Grid Column/Row Calculations\n// ============================================================================\n\n/** Calculate the width of a single grid column in pixels. */\nexport function calcGridColWidth(positionParams: PositionParams): number {\n const { margin, containerPadding, containerWidth, cols } = positionParams;\n return (\n (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols\n );\n}\n\n/**\n * Calculate the pixel size for a grid unit dimension (width or height).\n */\nexport function calcGridItemWHPx(\n gridUnits: number,\n colOrRowSize: number,\n marginPx: number,\n): number {\n // 0 * Infinity === NaN, which causes problems with resize constraints\n if (!Number.isFinite(gridUnits)) return gridUnits;\n return Math.round(\n colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx,\n );\n}\n\n// ============================================================================\n// Position Calculations\n// ============================================================================\n\n/**\n * Calculate pixel position for a grid item. Returns left, top, width, height.\n */\nexport function calcGridItemPosition(\n positionParams: PositionParams,\n x: number,\n y: number,\n w: number,\n h: number,\n dragPosition?: { top: number; left: number } | null,\n resizePosition?: {\n top: number;\n left: number;\n height: number;\n width: number;\n } | null,\n): Position {\n const { margin, containerPadding, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n let width: number;\n let height: number;\n let top: number;\n let left: number;\n\n // If resizing, use the exact width and height from resize callbacks\n if (resizePosition) {\n width = Math.round(resizePosition.width);\n height = Math.round(resizePosition.height);\n } else {\n width = calcGridItemWHPx(w, colWidth, margin[0]);\n height = calcGridItemWHPx(h, rowHeight, margin[1]);\n }\n\n // If dragging, use the exact left/top from drag callbacks\n if (dragPosition) {\n top = Math.round(dragPosition.top);\n left = Math.round(dragPosition.left);\n } else if (resizePosition) {\n top = Math.round(resizePosition.top);\n left = Math.round(resizePosition.left);\n } else {\n top = Math.round((rowHeight + margin[1]) * y + containerPadding[1]);\n left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);\n }\n\n // When not dragging or resizing, fix margin inconsistencies caused by\n // rounding by comparing where the next sibling would start.\n if (!dragPosition && !resizePosition) {\n if (Number.isFinite(w)) {\n const siblingLeft = Math.round(\n (colWidth + margin[0]) * (x + w) + containerPadding[0],\n );\n const actualMarginRight = siblingLeft - left - width;\n if (actualMarginRight !== margin[0]) {\n width += actualMarginRight - margin[0];\n }\n }\n\n if (Number.isFinite(h)) {\n const siblingTop = Math.round(\n (rowHeight + margin[1]) * (y + h) + containerPadding[1],\n );\n const actualMarginBottom = siblingTop - top - height;\n if (actualMarginBottom !== margin[1]) {\n height += actualMarginBottom - margin[1];\n }\n }\n }\n\n return { top, left, width, height };\n}\n\n/** Translate pixel coordinates to grid units (clamped). */\nexport function calcXY(\n positionParams: PositionParams,\n top: number,\n left: number,\n w: number,\n h: number,\n): { x: number; y: number } {\n const { margin, containerPadding, cols, rowHeight, maxRows } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));\n let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));\n\n x = clamp(x, 0, cols - w);\n y = clamp(y, 0, maxRows - h);\n\n return { x, y };\n}\n\n/** Translate pixel coordinates to grid units without clamping. */\nexport function calcXYRaw(\n positionParams: PositionParams,\n top: number,\n left: number,\n): { x: number; y: number } {\n const { margin, containerPadding, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n const x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));\n const y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));\n\n return { x, y };\n}\n\n/** Calculate grid units from pixel dimensions (clamped by handle direction). */\nexport function calcWH(\n positionParams: PositionParams,\n width: number,\n height: number,\n x: number,\n y: number,\n handle: ResizeHandleAxis,\n): { w: number; h: number } {\n const { margin, maxRows, cols, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n const w = Math.round((width + margin[0]) / (colWidth + margin[0]));\n const h = Math.round((height + margin[1]) / (rowHeight + margin[1]));\n\n let _w = clamp(w, 0, cols - x);\n let _h = clamp(h, 0, maxRows - y);\n\n // West handles can resize to full width\n if (handle === 'sw' || handle === 'w' || handle === 'nw') {\n _w = clamp(w, 0, cols);\n }\n\n // North handles can resize to full height\n if (handle === 'nw' || handle === 'n' || handle === 'ne') {\n _h = clamp(h, 0, maxRows);\n }\n\n return { w: _w, h: _h };\n}\n\n/** Calculate grid units from pixel dimensions without clamping (min 1). */\nexport function calcWHRaw(\n positionParams: PositionParams,\n width: number,\n height: number,\n): { w: number; h: number } {\n const { margin, rowHeight } = positionParams;\n const colWidth = calcGridColWidth(positionParams);\n\n const w = Math.max(\n 1,\n Math.round((width + margin[0]) / (colWidth + margin[0])),\n );\n const h = Math.max(\n 1,\n Math.round((height + margin[1]) / (rowHeight + margin[1])),\n );\n\n return { w, h };\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/** Clamp a number between bounds. */\nexport function clamp(\n num: number,\n lowerBound: number,\n upperBound: number,\n): number {\n return Math.max(Math.min(num, upperBound), lowerBound);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-7b4aa61 | Cube Dev Team */
|
|
2
|
+
//#region src/components/layout/Board/grid-core/collision.ts
|
|
3
|
+
/**
|
|
4
|
+
* Check if two layout items collide (overlap).
|
|
5
|
+
*
|
|
6
|
+
* Two items collide if their bounding boxes overlap and they are not the same
|
|
7
|
+
* item.
|
|
8
|
+
*/
|
|
9
|
+
function collides(l1, l2) {
|
|
10
|
+
if (l1.i === l2.i) return false;
|
|
11
|
+
if (l1.x + l1.w <= l2.x) return false;
|
|
12
|
+
if (l1.x >= l2.x + l2.w) return false;
|
|
13
|
+
if (l1.y + l1.h <= l2.y) return false;
|
|
14
|
+
if (l1.y >= l2.y + l2.h) return false;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Find the first item in the layout that collides with the given item.
|
|
19
|
+
*/
|
|
20
|
+
function getFirstCollision(layout, layoutItem) {
|
|
21
|
+
for (let i = 0; i < layout.length; i++) {
|
|
22
|
+
const item = layout[i];
|
|
23
|
+
if (item !== void 0 && collides(item, layoutItem)) return item;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Find all items in the layout that collide with the given item.
|
|
28
|
+
*/
|
|
29
|
+
function getAllCollisions(layout, layoutItem) {
|
|
30
|
+
return layout.filter((l) => collides(l, layoutItem));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { collides, getAllCollisions, getFirstCollision };
|
|
35
|
+
//# sourceMappingURL=collision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collision.js","names":[],"sources":["../../../../../src/components/layout/Board/grid-core/collision.ts"],"sourcesContent":["/**\n * Collision detection utilities for grid layouts.\n *\n * Vendored from react-grid-layout v2 (`src/core/collision.ts`).\n * See ./NOTICE.md for attribution and license.\n */\n\nimport type { Layout, LayoutItem } from './types';\n\n/**\n * Check if two layout items collide (overlap).\n *\n * Two items collide if their bounding boxes overlap and they are not the same\n * item.\n */\nexport function collides(l1: LayoutItem, l2: LayoutItem): boolean {\n // Same element - can't collide with itself\n if (l1.i === l2.i) return false;\n\n // Check if bounding boxes don't overlap (any gap means no collision)\n if (l1.x + l1.w <= l2.x) return false; // l1 is completely left of l2\n if (l1.x >= l2.x + l2.w) return false; // l1 is completely right of l2\n if (l1.y + l1.h <= l2.y) return false; // l1 is completely above l2\n if (l1.y >= l2.y + l2.h) return false; // l1 is completely below l2\n\n // Bounding boxes overlap\n return true;\n}\n\n/**\n * Find the first item in the layout that collides with the given item.\n */\nexport function getFirstCollision(\n layout: Layout,\n layoutItem: LayoutItem,\n): LayoutItem | undefined {\n for (let i = 0; i < layout.length; i++) {\n const item = layout[i];\n if (item !== undefined && collides(item, layoutItem)) {\n return item;\n }\n }\n return undefined;\n}\n\n/**\n * Find all items in the layout that collide with the given item.\n */\nexport function getAllCollisions(\n layout: Layout,\n layoutItem: LayoutItem,\n): LayoutItem[] {\n return layout.filter((l): l is LayoutItem => collides(l, layoutItem));\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,SAAS,IAAgB,IAAyB;AAEhE,KAAI,GAAG,MAAM,GAAG,EAAG,QAAO;AAG1B,KAAI,GAAG,IAAI,GAAG,KAAK,GAAG,EAAG,QAAO;AAChC,KAAI,GAAG,KAAK,GAAG,IAAI,GAAG,EAAG,QAAO;AAChC,KAAI,GAAG,IAAI,GAAG,KAAK,GAAG,EAAG,QAAO;AAChC,KAAI,GAAG,KAAK,GAAG,IAAI,GAAG,EAAG,QAAO;AAGhC,QAAO;;;;;AAMT,SAAgB,kBACd,QACA,YACwB;AACxB,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,OAAO,OAAO;AACpB,MAAI,SAAS,UAAa,SAAS,MAAM,WAAW,CAClD,QAAO;;;;;;AASb,SAAgB,iBACd,QACA,YACc;AACd,QAAO,OAAO,QAAQ,MAAuB,SAAS,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { CompactType, Compactor } from "./types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/components/layout/Board/grid-core/compactors.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vertical compactor - moves items up to fill gaps. Default compaction mode.
|
|
7
|
+
*/
|
|
8
|
+
declare const verticalCompactor: Compactor;
|
|
9
|
+
/**
|
|
10
|
+
* Horizontal compactor - moves items left to fill gaps.
|
|
11
|
+
*/
|
|
12
|
+
declare const horizontalCompactor: Compactor;
|
|
13
|
+
/**
|
|
14
|
+
* No compaction - items stay where placed (free-form layouts).
|
|
15
|
+
*/
|
|
16
|
+
declare const noCompactor: Compactor;
|
|
17
|
+
/**
|
|
18
|
+
* Get a compactor by type (convenience for the string-based compactType API).
|
|
19
|
+
*/
|
|
20
|
+
declare function getCompactor(compactType: CompactType, allowOverlap?: boolean, preventCollision?: boolean): Compactor;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getCompactor, horizontalCompactor, noCompactor, verticalCompactor };
|
|
23
|
+
//# sourceMappingURL=compactors.d.ts.map
|