@accelint/design-toolkit 9.13.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/catalog-info.yaml +1 -1
- package/dist/components/accordion/context.d.ts +2 -2
- package/dist/components/accordion/group.d.ts +2 -2
- package/dist/components/accordion/header.d.ts +2 -2
- package/dist/components/accordion/index.d.ts +2 -2
- package/dist/components/accordion/panel.d.ts +2 -2
- package/dist/components/accordion/trigger.d.ts +2 -2
- package/dist/components/action-bar/index.d.ts +2 -2
- package/dist/components/audio/index.d.ts +2 -2
- package/dist/components/avatar/context.d.ts +4 -4
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/badge/context.d.ts +4 -4
- package/dist/components/badge/index.d.ts +2 -2
- package/dist/components/breadcrumbs/index.d.ts +2 -2
- package/dist/components/breadcrumbs/item.d.ts +2 -2
- package/dist/components/button/context.d.ts +8 -8
- package/dist/components/button/index.d.ts +2 -2
- package/dist/components/button/link.d.ts +2 -2
- package/dist/components/button/toggle.d.ts +2 -2
- package/dist/components/carousel/context.d.ts +4 -4
- package/dist/components/carousel/gallery.d.ts +2 -2
- package/dist/components/carousel/index.d.ts +2 -2
- package/dist/components/carousel/navigation.d.ts +3 -3
- package/dist/components/carousel/position.d.ts +2 -2
- package/dist/components/carousel/select.d.ts +2 -2
- package/dist/components/carousel/viewer.d.ts +2 -2
- package/dist/components/checkbox/context.d.ts +3 -3
- package/dist/components/checkbox/group.d.ts +2 -2
- package/dist/components/checkbox/index.d.ts +2 -2
- package/dist/components/chip/context.d.ts +4 -4
- package/dist/components/chip/deletable.d.ts +2 -2
- package/dist/components/chip/index.d.ts +2 -2
- package/dist/components/chip/list.d.ts +4 -4
- package/dist/components/chip/selectable.d.ts +2 -2
- package/dist/components/classification-badge/context.d.ts +4 -4
- package/dist/components/classification-badge/index.d.ts +2 -2
- package/dist/components/classification-banner/context.d.ts +4 -4
- package/dist/components/classification-banner/index.d.ts +2 -2
- package/dist/components/clock/index.d.ts +2 -2
- package/dist/components/color-picker/index.d.ts +2 -2
- package/dist/components/combobox-field/context.d.ts +4 -4
- package/dist/components/combobox-field/index.d.ts +2 -2
- package/dist/components/coordinate-field/context.d.ts +6 -6
- package/dist/components/coordinate-field/index.d.ts +2 -2
- package/dist/components/coordinate-field/segment.d.ts +2 -2
- package/dist/components/date-field/index.d.ts +2 -2
- package/dist/components/deferred-collection/index.d.ts +2 -2
- package/dist/components/details-list/context.d.ts +4 -4
- package/dist/components/details-list/index.d.ts +2 -2
- package/dist/components/details-list/label.d.ts +2 -2
- package/dist/components/details-list/value.d.ts +2 -2
- package/dist/components/dialog/content.d.ts +2 -2
- package/dist/components/dialog/context.d.ts +2 -2
- package/dist/components/dialog/footer.d.ts +2 -2
- package/dist/components/dialog/index.d.ts +2 -2
- package/dist/components/dialog/title.d.ts +2 -2
- package/dist/components/divider/context.d.ts +4 -4
- package/dist/components/divider/index.d.ts +2 -2
- package/dist/components/drawer/back.d.ts +2 -2
- package/dist/components/drawer/close.d.ts +2 -2
- package/dist/components/drawer/content.d.ts +2 -2
- package/dist/components/drawer/context.d.ts +2 -2
- package/dist/components/drawer/footer.d.ts +2 -2
- package/dist/components/drawer/header-title.d.ts +2 -2
- package/dist/components/drawer/index.d.ts +2 -2
- package/dist/components/drawer/layout-main.d.ts +2 -2
- package/dist/components/drawer/layout.d.ts +2 -2
- package/dist/components/drawer/menu-item.d.ts +2 -2
- package/dist/components/drawer/menu.d.ts +2 -2
- package/dist/components/drawer/panel.d.ts +2 -2
- package/dist/components/drawer/trigger.d.ts +2 -2
- package/dist/components/drawer/view.d.ts +2 -2
- package/dist/components/flashcard/index.d.ts +9 -9
- package/dist/components/floating-card/constants.d.ts +26 -0
- package/dist/components/floating-card/constants.js +40 -0
- package/dist/components/floating-card/constants.js.map +1 -0
- package/dist/components/floating-card/context.d.ts +38 -6
- package/dist/components/floating-card/context.js +24 -3
- package/dist/components/floating-card/context.js.map +1 -1
- package/dist/components/floating-card/hooks/use-card-layout.d.ts +36 -0
- package/dist/components/floating-card/hooks/use-card-layout.js +106 -0
- package/dist/components/floating-card/hooks/use-card-layout.js.map +1 -0
- package/dist/components/floating-card/hooks/use-drag.d.ts +62 -0
- package/dist/components/floating-card/hooks/use-drag.js +100 -0
- package/dist/components/floating-card/hooks/use-drag.js.map +1 -0
- package/dist/components/floating-card/hooks/use-mouse-interaction.d.ts +58 -0
- package/dist/components/floating-card/hooks/use-mouse-interaction.js +91 -0
- package/dist/components/floating-card/hooks/use-mouse-interaction.js.map +1 -0
- package/dist/components/floating-card/hooks/use-resize.d.ts +56 -0
- package/dist/components/floating-card/hooks/use-resize.js +98 -0
- package/dist/components/floating-card/hooks/use-resize.js.map +1 -0
- package/dist/components/floating-card/index.d.ts +6 -2
- package/dist/components/floating-card/index.js +24 -32
- package/dist/components/floating-card/index.js.map +1 -1
- package/dist/components/floating-card/panel.d.ts +69 -0
- package/dist/components/floating-card/panel.js +111 -0
- package/dist/components/floating-card/panel.js.map +1 -0
- package/dist/components/floating-card/provider.d.ts +10 -6
- package/dist/components/floating-card/provider.js +159 -153
- package/dist/components/floating-card/provider.js.map +1 -1
- package/dist/components/floating-card/styles.module.css +93 -39
- package/dist/components/floating-card/types.d.ts +51 -10
- package/dist/components/floating-card/utils.d.ts +8 -85
- package/dist/components/floating-card/utils.js +12 -38
- package/dist/components/floating-card/utils.js.map +1 -1
- package/dist/components/gantt/components/base-elements/point.d.ts +2 -2
- package/dist/components/gantt/components/base-elements/range.d.ts +2 -2
- package/dist/components/gantt/components/containers/external/gantt-content-container/index.d.ts +2 -2
- package/dist/components/gantt/components/containers/external/gantt-panel-container/index.d.ts +2 -2
- package/dist/components/gantt/components/containers/internal/index.d.ts +2 -2
- package/dist/components/gantt/components/containers/internal/layout-container/index.d.ts +2 -2
- package/dist/components/gantt/components/containers/internal/virtualized-content-height-container/index.d.ts +2 -2
- package/dist/components/gantt/components/content-row/block.d.ts +2 -2
- package/dist/components/gantt/components/content-row/bracket.d.ts +3 -3
- package/dist/components/gantt/components/content-row/icon-marker.d.ts +2 -2
- package/dist/components/gantt/components/content-row/index.d.ts +2 -2
- package/dist/components/gantt/components/content-row/marker.d.ts +2 -2
- package/dist/components/gantt/components/content-row/spacer.d.ts +2 -2
- package/dist/components/gantt/components/current-time/index.d.ts +2 -2
- package/dist/components/gantt/components/header/index.d.ts +3 -3
- package/dist/components/gantt/components/panel-row/index.d.ts +2 -2
- package/dist/components/gantt/components/rows-virtualizer/index.d.ts +3 -3
- package/dist/components/gantt/components/timeline/index.d.ts +2 -2
- package/dist/components/gantt/components/timeline-chunk/index.d.ts +3 -3
- package/dist/components/gantt/context/index.d.ts +4 -4
- package/dist/components/gantt/context/store/index.d.ts +4 -4
- package/dist/components/gantt/context/temporal-data/index.d.ts +4 -4
- package/dist/components/gantt/hooks/use-layout-subscription/index.js +8 -8
- package/dist/components/gantt/hooks/use-layout-subscription/index.js.map +1 -1
- package/dist/components/hero/context.d.ts +2 -2
- package/dist/components/hero/index.d.ts +2 -2
- package/dist/components/hero/subtitle.d.ts +3 -3
- package/dist/components/hero/title.d.ts +2 -2
- package/dist/components/hotkey/context.d.ts +4 -4
- package/dist/components/hotkey/index.d.ts +2 -2
- package/dist/components/hotkey/set.d.ts +2 -2
- package/dist/components/icon/context.d.ts +4 -4
- package/dist/components/icon/index.d.ts +2 -2
- package/dist/components/input/context.d.ts +2 -2
- package/dist/components/input/index.d.ts +2 -2
- package/dist/components/kanban/card-body.d.ts +2 -2
- package/dist/components/kanban/card-header-actions.d.ts +2 -2
- package/dist/components/kanban/card-header-title.d.ts +2 -2
- package/dist/components/kanban/card-header.d.ts +2 -2
- package/dist/components/kanban/card.d.ts +2 -2
- package/dist/components/kanban/column-actions.d.ts +2 -2
- package/dist/components/kanban/column-container.d.ts +2 -2
- package/dist/components/kanban/column-content.d.ts +2 -2
- package/dist/components/kanban/column-header-actions.d.ts +2 -2
- package/dist/components/kanban/column-header-drag-handle.d.ts +2 -2
- package/dist/components/kanban/column-header-title.d.ts +2 -2
- package/dist/components/kanban/column-header.d.ts +2 -2
- package/dist/components/kanban/column.d.ts +2 -2
- package/dist/components/kanban/context.d.ts +2 -2
- package/dist/components/kanban/header-actions.d.ts +2 -2
- package/dist/components/kanban/header-search.d.ts +2 -2
- package/dist/components/kanban/header-title.d.ts +2 -2
- package/dist/components/kanban/header.d.ts +2 -2
- package/dist/components/kanban/kanban.d.ts +4 -4
- package/dist/components/label/context.d.ts +4 -4
- package/dist/components/label/index.d.ts +2 -2
- package/dist/components/lines/index.d.ts +2 -2
- package/dist/components/link/context.d.ts +2 -2
- package/dist/components/link/index.d.ts +2 -2
- package/dist/components/list/context.d.ts +2 -2
- package/dist/components/list/index.d.ts +2 -2
- package/dist/components/list/item-content.d.ts +2 -2
- package/dist/components/list/item-description.d.ts +2 -2
- package/dist/components/list/item-title.d.ts +2 -2
- package/dist/components/list/item.d.ts +2 -2
- package/dist/components/media-controls/context.d.ts +4 -4
- package/dist/components/media-controls/fullscreen-button.d.ts +2 -2
- package/dist/components/media-controls/index.d.ts +2 -2
- package/dist/components/media-controls/mute-button.d.ts +2 -2
- package/dist/components/media-controls/play-button.d.ts +2 -2
- package/dist/components/media-controls/playback-rate.d.ts +2 -2
- package/dist/components/media-controls/seek-button.d.ts +2 -2
- package/dist/components/media-controls/time-display.d.ts +2 -2
- package/dist/components/media-controls/time-range.d.ts +2 -2
- package/dist/components/media-controls/volume-slider.d.ts +2 -2
- package/dist/components/menu/context.d.ts +2 -2
- package/dist/components/menu/index.d.ts +2 -2
- package/dist/components/menu/item-description.d.ts +2 -2
- package/dist/components/menu/item-label.d.ts +2 -2
- package/dist/components/menu/item.d.ts +2 -2
- package/dist/components/menu/section.d.ts +2 -2
- package/dist/components/menu/separator.d.ts +2 -2
- package/dist/components/menu/submenu.d.ts +2 -2
- package/dist/components/notice/index.d.ts +2 -2
- package/dist/components/notice/list.d.ts +2 -2
- package/dist/components/notice/notice-icon.d.ts +2 -2
- package/dist/components/options/context.d.ts +2 -2
- package/dist/components/options/index.d.ts +2 -2
- package/dist/components/options/item-content.d.ts +2 -2
- package/dist/components/options/item-description.d.ts +2 -2
- package/dist/components/options/item-label.d.ts +2 -2
- package/dist/components/options/item.d.ts +2 -2
- package/dist/components/options/section.d.ts +2 -2
- package/dist/components/pagination/context.d.ts +2 -2
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/pagination/next.d.ts +2 -2
- package/dist/components/pagination/pages.d.ts +2 -2
- package/dist/components/pagination/prev.d.ts +2 -2
- package/dist/components/popover/content.d.ts +2 -2
- package/dist/components/popover/footer.d.ts +2 -2
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/title.d.ts +2 -2
- package/dist/components/popover/trigger.d.ts +2 -2
- package/dist/components/query-builder/action-element.d.ts +2 -2
- package/dist/components/query-builder/actions.d.ts +4 -4
- package/dist/components/query-builder/combinator-selector.d.ts +2 -2
- package/dist/components/query-builder/index.d.ts +2 -2
- package/dist/components/query-builder/rule-group.d.ts +4 -4
- package/dist/components/query-builder/rule.d.ts +2 -2
- package/dist/components/query-builder/value-editor.d.ts +2 -2
- package/dist/components/query-builder/value-selector.d.ts +2 -2
- package/dist/components/radio/context.d.ts +3 -3
- package/dist/components/radio/group.d.ts +2 -2
- package/dist/components/radio/index.d.ts +2 -2
- package/dist/components/search-field/context.d.ts +4 -4
- package/dist/components/search-field/index.d.ts +2 -2
- package/dist/components/select-field/context.d.ts +4 -4
- package/dist/components/select-field/index.d.ts +2 -2
- package/dist/components/sidenav/avatar.d.ts +2 -2
- package/dist/components/sidenav/content.d.ts +2 -2
- package/dist/components/sidenav/context.d.ts +2 -2
- package/dist/components/sidenav/footer.d.ts +2 -2
- package/dist/components/sidenav/header.d.ts +2 -2
- package/dist/components/sidenav/index.d.ts +2 -2
- package/dist/components/sidenav/item.d.ts +2 -2
- package/dist/components/sidenav/link.d.ts +2 -2
- package/dist/components/sidenav/menu-item.d.ts +2 -2
- package/dist/components/sidenav/menu.d.ts +2 -2
- package/dist/components/sidenav/trigger.d.ts +2 -2
- package/dist/components/skeleton/index.d.ts +2 -2
- package/dist/components/slider/index.d.ts +2 -2
- package/dist/components/status-indicator/index.d.ts +2 -2
- package/dist/components/switch/context.d.ts +4 -4
- package/dist/components/switch/index.d.ts +2 -2
- package/dist/components/table/body.d.ts +4 -3
- package/dist/components/table/body.js.map +1 -1
- package/dist/components/table/cell.d.ts +4 -3
- package/dist/components/table/cell.js.map +1 -1
- package/dist/components/table/context.d.ts +2 -2
- package/dist/components/table/features.d.ts +80 -0
- package/dist/components/table/features.js +61 -0
- package/dist/components/table/features.js.map +1 -0
- package/dist/components/table/header-cell.d.ts +4 -3
- package/dist/components/table/header-cell.js.map +1 -1
- package/dist/components/table/header.d.ts +4 -3
- package/dist/components/table/header.js.map +1 -1
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/index.js +40 -49
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/table/row-ordering-feature.d.ts +88 -0
- package/dist/components/table/row-ordering-feature.js +115 -0
- package/dist/components/table/row-ordering-feature.js.map +1 -0
- package/dist/components/table/row.d.ts +4 -3
- package/dist/components/table/row.js.map +1 -1
- package/dist/components/table/types.d.ts +15 -13
- package/dist/components/tabs/context.d.ts +3 -3
- package/dist/components/tabs/index.d.ts +2 -2
- package/dist/components/tabs/list.d.ts +2 -2
- package/dist/components/tabs/panel.d.ts +2 -2
- package/dist/components/tabs/tab.d.ts +2 -2
- package/dist/components/text-area-field/context.d.ts +4 -4
- package/dist/components/text-area-field/index.d.ts +2 -2
- package/dist/components/text-field/context.d.ts +4 -4
- package/dist/components/text-field/index.d.ts +2 -2
- package/dist/components/time-field/index.d.ts +2 -2
- package/dist/components/tooltip/context.d.ts +2 -2
- package/dist/components/tooltip/index.d.ts +2 -2
- package/dist/components/tooltip/trigger.d.ts +2 -2
- package/dist/components/tree/context.d.ts +3 -3
- package/dist/components/tree/index.d.ts +2 -2
- package/dist/components/tree/item-actions.d.ts +2 -2
- package/dist/components/tree/item-content.d.ts +2 -2
- package/dist/components/tree/item-description.d.ts +2 -2
- package/dist/components/tree/item-label.d.ts +2 -2
- package/dist/components/tree/item-prefix-icon.d.ts +2 -2
- package/dist/components/tree/item.d.ts +2 -2
- package/dist/components/tree/lines.d.ts +2 -2
- package/dist/components/video/index.d.ts +2 -2
- package/dist/components/view-stack/context.d.ts +2 -2
- package/dist/components/view-stack/index.d.ts +2 -2
- package/dist/components/view-stack/trigger.d.ts +2 -2
- package/dist/components/view-stack/view.d.ts +2 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/providers/portal.d.ts +2 -2
- package/dist/providers/theme-provider.d.ts +2 -2
- package/package.json +20 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","names":["CloseIcon","components: Record<string, FunctionComponent<IDockviewPanelProps>>"],"sources":["../../../src/components/floating-card/provider.tsx"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { clsx } from '@accelint/design-foundation/lib/utils';\nimport CloseIcon from '@accelint/icons/cancel';\nimport PinIcon from '@accelint/icons/pin';\nimport {\n type DockviewApi,\n DockviewReact,\n type DockviewReadyEvent,\n type IDockviewPanelProps,\n} from 'dockview-react';\nimport {\n type FunctionComponent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { Button } from '../button';\nimport { Divider } from '../divider';\nimport { Icon } from '../icon';\nimport { FloatingCardContext, useFloatingCard } from './context';\nimport styles from './styles.module.css';\nimport { createHeaderAdapter, type FloatingCardHeaderProps } from './utils';\nimport type { UniqueId } from '@accelint/core/utility/uuid';\nimport type {\n FloatingCardContextValue,\n FloatingCardProviderProps,\n} from './types';\n\n/**\n * Internal component that registers a DOM ref for a card container.\n *\n * Used by the floating card engine to mount portal targets. Also manages\n * the data-pinned attribute on the resize container to control drag handle visibility.\n *\n * @param props - Dockview panel props containing the card ID.\n */\nfunction FloatingCardContainer(props: Readonly<IDockviewPanelProps>) {\n const { addRef, isPinned, subscribeToPinState } = useFloatingCard();\n const cardId = props.api.id as UniqueId;\n\n const pinned = useSyncExternalStore(\n subscribeToPinState,\n () => isPinned(cardId),\n () => false,\n );\n\n const cardRef = useRef<HTMLDivElement | null>(null);\n\n const refCallback = useCallback(\n (ref: HTMLDivElement | null) => {\n cardRef.current = ref;\n addRef(cardId, ref);\n },\n [addRef, cardId],\n );\n\n // Toggle a data-pinned attribute on the ancestor .dv-resize-container\n // so CSS can disable pointer-events on the drag handle.\n useEffect(() => {\n const el = cardRef.current;\n const container = el?.closest<HTMLElement>('.dv-resize-container');\n\n if (!container) {\n return;\n }\n\n if (pinned) {\n container.dataset.pinned = '';\n } else {\n delete container.dataset.pinned;\n }\n }, [pinned]);\n\n return <div className={styles.cardContent} ref={refCallback} />;\n}\n\n/**\n * Default left header showing an optional custom icon and the card's title.\n */\nfunction DefaultLeftHeader({\n title,\n icon,\n id,\n}: Readonly<FloatingCardHeaderProps>) {\n return (\n <div className={styles.headerSide}>\n {icon ? <Icon size='small'>{icon}</Icon> : null}\n {title && title !== id ? (\n <div className={styles.headerTitleContainer}>\n <div className={styles.headerTitle}>{title}</div>\n </div>\n ) : null}\n </div>\n );\n}\n\n/** Stable no-op subscribe for useSyncExternalStore when no pin subscription is available. */\nconst noopSubscribe = () => () => undefined;\n\n/**\n * Default right header showing optional action buttons and an always-present close button.\n *\n * @remarks Handles rendering of 'divider' and 'pin' action types specially.\n */\nfunction DefaultRightHeader({\n closeGroup,\n headerActions,\n id,\n togglePinCard,\n isPinned,\n subscribeToPinState,\n}: Readonly<FloatingCardHeaderProps>) {\n const pinned = useSyncExternalStore(\n subscribeToPinState ?? noopSubscribe,\n () => (id && isPinned ? isPinned(id as UniqueId) : false),\n () => false,\n );\n\n return (\n <div className={styles.headerSide}>\n {headerActions?.map((action, index) => {\n if (action === 'divider') {\n return (\n // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here because the order of actions is unlikely to change.\n <Divider key={`${id}-divider-${index}`} orientation='vertical' />\n );\n }\n if (action === 'pin') {\n return (\n <Button\n className={styles.pinButton}\n // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here because the order of actions is unlikely to change.\n key={`${id}-pin-${index}`}\n variant='icon'\n size='small'\n color={pinned ? 'accent' : undefined}\n aria-label='Pin'\n aria-pressed={pinned}\n onClick={() => {\n if (id && togglePinCard) {\n togglePinCard(id as UniqueId);\n }\n }}\n >\n <Icon>\n <PinIcon />\n </Icon>\n </Button>\n );\n }\n return (\n <Button\n key={`${id}-${\n // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here because the order of actions is unlikely to change.\n index\n }`}\n variant='icon'\n size='small'\n onClick={action.onClick}\n >\n <Icon>{action.icon}</Icon>\n </Button>\n );\n })}\n <Button variant='icon' size='small' onClick={closeGroup}>\n <Icon>\n <CloseIcon />\n </Icon>\n </Button>\n </div>\n );\n}\n\nconst components: Record<string, FunctionComponent<IDockviewPanelProps>> = {\n default: FloatingCardContainer,\n};\n\n/**\n * Provides a context and layout area for floating cards within the application.\n *\n * Wraps children with floating card context and renders a Dockview instance to manage\n * docking, dragging, and layout of floating cards.\n *\n * @param props - The props for the FloatingCardProvider component.\n * @param props.children - Child components rendered inside the floating card provider.\n * @param props.icon - Optional icon rendered in all card headers (static or factory).\n * @param props.headerActions - Optional action buttons for card headers (static or factory).\n * @param props.className - Additional CSS class names for styling.\n * @returns The FloatingCardProvider component that manages floating card layout and context.\n *\n * @remarks\n * - Manages registration and cleanup of floating card DOM references\n * - Exposes closeCard, togglePinCard, and isPinned via context\n * - Automatically cleans up refs when cards are removed via any path (drag close, group close, API close)\n * - Cards are bounded within the viewport\n *\n * @example\n * ```tsx\n * <FloatingCardProvider\n * icon={<AppLogo />}\n * headerActions={[\n * { icon: <SettingsIcon />, onClick: openSettings },\n * 'divider',\n * 'pin'\n * ]}\n * >\n * <FloatingCard id=\"panel-1\" title=\"My Panel\">\n * <div>Panel content</div>\n * </FloatingCard>\n * </FloatingCardProvider>\n * ```\n */\nexport function FloatingCardProvider({\n children,\n icon,\n headerActions,\n initialPinned,\n className,\n}: FloatingCardProviderProps) {\n const [api, setApi] = useState<DockviewApi | null>(null);\n const [cards, setCards] = useState<Record<UniqueId, HTMLDivElement>>({});\n const pinnedCardsRef = useRef<Set<UniqueId>>(new Set(initialPinned));\n const pinListenersRef = useRef<Set<() => void>>(new Set());\n\n const closeCard = useCallback(\n (id: UniqueId) => {\n api?.getPanel(id)?.api.close();\n },\n [api],\n );\n\n const togglePinCard = useCallback((id: UniqueId) => {\n const next = new Set(pinnedCardsRef.current);\n if (next.has(id)) {\n next.delete(id);\n } else {\n next.add(id);\n }\n pinnedCardsRef.current = next;\n for (const listener of pinListenersRef.current) {\n listener();\n }\n }, []);\n\n const isPinned = useCallback(\n (id: UniqueId) => pinnedCardsRef.current.has(id),\n [],\n );\n\n const subscribeToPinState = useCallback((callback: () => void) => {\n pinListenersRef.current.add(callback);\n return () => {\n pinListenersRef.current.delete(callback);\n };\n }, []);\n\n const removeRef = useCallback((view: UniqueId) => {\n setCards((prev) => {\n const newCards = { ...prev };\n delete newCards[view];\n return newCards;\n });\n if (pinnedCardsRef.current.has(view)) {\n const next = new Set(pinnedCardsRef.current);\n next.delete(view);\n pinnedCardsRef.current = next;\n for (const listener of pinListenersRef.current) {\n listener();\n }\n }\n }, []);\n\n const addRef = useCallback((id: UniqueId, ref: HTMLDivElement | null) => {\n if (ref) {\n setCards((prev) => {\n if (prev[id]) {\n return prev;\n }\n return { ...prev, [id]: ref };\n });\n }\n }, []);\n\n // Clean up stale refs when cards are removed via any path\n // (drag close, group close, API close, etc.)\n useEffect(() => {\n if (!api) {\n return;\n }\n\n const disposable = api.onDidRemovePanel((event) => {\n removeRef(event.id as UniqueId);\n });\n\n return () => {\n disposable.dispose();\n };\n }, [api, removeRef]);\n\n const contextValue = useMemo<FloatingCardContextValue>(\n () => ({\n cards,\n addRef,\n removeRef,\n closeCard,\n togglePinCard,\n isPinned,\n subscribeToPinState,\n api,\n }),\n [\n cards,\n closeCard,\n removeRef,\n api,\n addRef,\n togglePinCard,\n isPinned,\n subscribeToPinState,\n ],\n );\n\n const leftAdapter = useMemo(\n () =>\n createHeaderAdapter(DefaultLeftHeader, {\n icon,\n }),\n [icon],\n );\n\n const rightAdapter = useMemo(\n () =>\n createHeaderAdapter(DefaultRightHeader, {\n headerActions,\n togglePinCard,\n isPinned,\n subscribeToPinState,\n }),\n [headerActions, togglePinCard, isPinned, subscribeToPinState],\n );\n\n const theme = useMemo(\n () => ({\n name: 'accelint',\n className: styles.floatingCardProvider ?? '',\n }),\n [],\n );\n\n const onReady = useCallback((event: DockviewReadyEvent) => {\n setApi(event.api);\n }, []);\n\n return (\n <FloatingCardContext.Provider value={contextValue}>\n <div className={clsx(styles.providerRoot, className)}>\n <DockviewReact\n locked\n floatingGroupBounds={'boundedWithinViewport'}\n components={components}\n prefixHeaderActionsComponent={leftAdapter}\n rightHeaderActionsComponent={rightAdapter}\n onReady={onReady}\n theme={theme}\n />\n {children}\n </div>\n </FloatingCardContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,sBAAsB,OAAsC;CACnE,MAAM,EAAE,QAAQ,UAAU,wBAAwB,iBAAiB;CACnE,MAAM,SAAS,MAAM,IAAI;CAEzB,MAAM,SAAS,qBACb,2BACM,SAAS,OAAO,QAChB,MACP;CAED,MAAM,UAAU,OAA8B,KAAK;CAEnD,MAAM,cAAc,aACjB,QA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AK,MAAM,YAAY,gBAAgB,QACrC,WAAU;;IAGb,EAAE,CAAC;CAEN,MAAM,SAAS,aAAa,IAAc,QAA+B;AACvE,MAAI,IACF,WAAU,SAAS;AACjB,OAAI,KAAK,IACP,QAAO;AAET,UAAO;IAAE,GAAG;KAAO,KAAK;IAAK;IAC7B;IAEH,EAAE,CAAC;AAIN,iBAAgB;AACd,MAAI,CAAC,IACH;EAGF,MAAM,aAAa,IAAI,kBAAkB,UAAU;AACjD,aAAU,MAAM,GAAe;IAC/B;AAEF,eAAa;AACX,cAAW,SAAS;;IAErB,CAAC,KAAK,UAAU,CAAC;CAEpB,MAAM,eAAe,eACZ;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,GACD;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;CAED,MAAM,cAAc,cAEhB,oBAAoB,mBAAmB,EACrC,MACD,CAAC,EACJ,CAAC,KAAK,CACP;CAED,MAAM,eAAe,cAEjB,oBAAoB,oBAAoB;EACtC;EACA;EACA;EACA;EACD,CAAC,EACJ;EAAC;EAAe;EAAe;EAAU;EAAoB,CAC9D;CAED,MAAM,QAAQ,eACL;EACL,MAAM;EACN,WAAW,OAAO,wBAAwB;EAC3C,GACD,EAAE,CACH;CAED,MAAM,UAAU,aAAa,UAA8B;AACzD,SAAO,MAAM,IAAI;IAChB,EAAE,CAAC;AAEN,QACE,oBAAC,oBAAoB;EAAS,OAAO;YACnC,qBAAC;GAAI,WAAW,KAAK,OAAO,cAAc,UAAU;cAClD,oBAAC;IACC;IACA,qBAAqB;IACT;IACZ,8BAA8B;IAC9B,6BAA6B;IACpB;IACF;KACP,EACD;IACG;GACuB"}
|
|
1
|
+
{"version":3,"file":"provider.js","names":["CloseIcon"],"sources":["../../../src/components/floating-card/provider.tsx"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { clsx } from '@accelint/design-foundation/lib/utils';\nimport CloseIcon from '@accelint/icons/cancel';\nimport PinIcon from '@accelint/icons/pin';\nimport {\n useCallback,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { Button } from '../button';\nimport { Divider } from '../divider';\nimport { Icon } from '../icon';\nimport { FloatingCardContext, FloatingCardRegistryContext } from './context';\nimport type { FloatingCardRegistryValue } from './context';\nimport { useCardLayout } from './hooks/use-card-layout';\nimport { FloatingCardPanel } from './panel';\nimport styles from './styles.module.css';\nimport { resolveMaybeFactory } from './utils';\nimport type { UniqueId } from '@accelint/core/utility/uuid';\nimport type {\n Bounds,\n Dimensions,\n FloatingCardContextValue,\n FloatingCardHeaderAction,\n FloatingCardLayout,\n FloatingCardProviderProps,\n Position,\n} from './types';\n\n/** Header shown at the start of a card: optional icon plus the title. */\nfunction CardHeaderStart({\n icon,\n title,\n}: Readonly<{ icon: React.ReactNode; title: string | undefined }>) {\n return (\n <div className={styles.headerSide}>\n {icon ? <Icon size='small'>{icon}</Icon> : null}\n {title ? (\n <div className={styles.headerTitleContainer}>\n <div className={styles.headerTitle}>{title}</div>\n </div>\n ) : null}\n </div>\n );\n}\n\n/** Action buttons for a card, ending in the always-present close button. */\nfunction CardHeaderActions({\n actions,\n id,\n isPinned,\n onClose,\n onTogglePin,\n}: Readonly<{\n actions: FloatingCardHeaderAction[] | undefined;\n id: UniqueId;\n isPinned: boolean;\n onClose: () => void;\n onTogglePin: () => void;\n}>) {\n return (\n <>\n {actions?.map((action, index) => {\n if (action === 'divider') {\n return (\n // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here because the order of actions is unlikely to change.\n <Divider key={`${id}-divider-${index}`} orientation='vertical' />\n );\n }\n\n if (action === 'pin') {\n return (\n <Button\n aria-label='Pin'\n aria-pressed={isPinned}\n color={isPinned ? 'accent' : undefined}\n // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here because the order of actions is unlikely to change.\n key={`${id}-pin-${index}`}\n onPress={onTogglePin}\n size='small'\n variant='icon'\n >\n <Icon>\n <PinIcon />\n </Icon>\n </Button>\n );\n }\n\n return (\n <Button\n aria-label={action.label}\n // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here because the order of actions is unlikely to change.\n key={`${id}-action-${index}`}\n onPress={action.onClick}\n size='small'\n variant='icon'\n >\n <Icon>{action.icon}</Icon>\n </Button>\n );\n })}\n <Button aria-label='Close' onPress={onClose} size='small' variant='icon'>\n <Icon>\n <CloseIcon />\n </Icon>\n </Button>\n </>\n );\n}\n\n/**\n * Provides a context and layout area for floating cards within the application.\n *\n * Wraps children with floating card context and renders each registered card as\n * a draggable, resizable panel bounded by the provider's own box.\n *\n * @param props - The props for the FloatingCardProvider component.\n * @param props.children - Child components rendered inside the floating card provider.\n * @param props.icon - Optional icon rendered in all card headers (static or factory).\n * @param props.headerActions - Optional action buttons for card headers (static or factory).\n * @param props.initialPinned - Card IDs that start pinned.\n * @param props.bounds - Region cards are confined to. Defaults to `'provider'`.\n * @param props.className - Additional CSS class names for styling.\n * @returns The FloatingCardProvider component that manages floating card layout and context.\n *\n * @remarks\n * - Manages registration and cleanup of floating card DOM references\n * - Exposes closeCard, togglePinCard, and isPinned via context\n * - Cards are bounded within the provider element by default; `bounds='viewport'`\n * lets them move anywhere on screen\n * - Cards are dragged by their header; pinning a card freezes drag and resize\n *\n * @example\n * ```tsx\n * <FloatingCardProvider\n * icon={<AppLogo />}\n * headerActions={[\n * { icon: <SettingsIcon />, onClick: openSettings },\n * 'divider',\n * 'pin'\n * ]}\n * >\n * <FloatingCard id=\"panel-1\" title=\"My Panel\">\n * <div>Panel content</div>\n * </FloatingCard>\n * </FloatingCardProvider>\n * ```\n */\nexport function FloatingCardProvider({\n children,\n icon,\n headerActions,\n initialPinned,\n bounds = 'provider',\n className,\n}: FloatingCardProviderProps) {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const [cards, setCards] = useState<Record<UniqueId, HTMLDivElement>>({});\n\n const pinnedRef = useRef<Set<UniqueId>>(new Set(initialPinned));\n const pinListenersRef = useRef<Set<() => void>>(new Set());\n\n const {\n layouts,\n registerCard,\n unregisterCard,\n moveCard,\n resizeCard,\n bringToFront,\n } = useCardLayout();\n\n const notifyPinChange = useCallback(() => {\n for (const listener of pinListenersRef.current) {\n listener();\n }\n }, []);\n\n const isPinned = useCallback((id: UniqueId) => pinnedRef.current.has(id), []);\n\n const subscribeToPinState = useCallback((callback: () => void) => {\n pinListenersRef.current.add(callback);\n\n return () => {\n pinListenersRef.current.delete(callback);\n };\n }, []);\n\n const togglePinCard = useCallback(\n (id: UniqueId) => {\n const next = new Set(pinnedRef.current);\n\n if (next.has(id)) {\n next.delete(id);\n } else {\n next.add(id);\n }\n\n pinnedRef.current = next;\n notifyPinChange();\n },\n [notifyPinChange],\n );\n\n const removeRef = useCallback(\n (id: UniqueId) => {\n setCards((current) => {\n if (!current[id]) {\n return current;\n }\n\n const next = { ...current };\n delete next[id];\n\n return next;\n });\n\n if (pinnedRef.current.has(id)) {\n const next = new Set(pinnedRef.current);\n next.delete(id);\n pinnedRef.current = next;\n notifyPinChange();\n }\n },\n [notifyPinChange],\n );\n\n const addRef = useCallback((id: UniqueId, ref: HTMLDivElement | null) => {\n if (!ref) {\n return;\n }\n\n setCards((current) =>\n current[id] === ref ? current : { ...current, [id]: ref },\n );\n }, []);\n\n const closeCard = useCallback(\n (id: UniqueId) => {\n unregisterCard(id);\n removeRef(id);\n },\n [removeRef, unregisterCard],\n );\n\n const getBounds = useCallback((): Bounds => {\n const element = rootRef.current;\n\n if (!element) {\n return { top: 0, left: 0, right: 0, bottom: 0 };\n }\n\n const rect = element.getBoundingClientRect();\n\n if (bounds === 'viewport') {\n // Cards are positioned relative to the provider, so the viewport box is\n // expressed in that coordinate space by subtracting the provider offset.\n return {\n top: -rect.top,\n left: -rect.left,\n right: window.innerWidth - rect.left,\n bottom: window.innerHeight - rect.top,\n };\n }\n\n return { top: 0, left: 0, right: rect.width, bottom: rect.height };\n }, [bounds]);\n\n const contextValue = useMemo<FloatingCardContextValue>(\n () => ({\n cards,\n closeCard,\n togglePinCard,\n isPinned,\n subscribeToPinState,\n }),\n [cards, closeCard, togglePinCard, isPinned, subscribeToPinState],\n );\n\n const registryValue = useMemo<FloatingCardRegistryValue>(\n () => ({ openCard: registerCard, addRef }),\n [registerCard, addRef],\n );\n\n return (\n <FloatingCardContext.Provider value={contextValue}>\n <FloatingCardRegistryContext.Provider value={registryValue}>\n <div className={clsx(styles.providerRoot, className)} ref={rootRef}>\n {Object.entries(layouts).map(([id, layout]) => (\n <CardPanel\n actions={resolveMaybeFactory(headerActions, id)}\n getBounds={getBounds}\n icon={resolveMaybeFactory(icon, id)}\n id={id as UniqueId}\n isPinned={isPinned}\n key={id}\n layout={layout}\n onAddRef={addRef}\n onClose={closeCard}\n onFocus={bringToFront}\n onMove={moveCard}\n onResize={resizeCard}\n onTogglePin={togglePinCard}\n subscribeToPinState={subscribeToPinState}\n />\n ))}\n {children}\n </div>\n </FloatingCardRegistryContext.Provider>\n </FloatingCardContext.Provider>\n );\n}\n\ntype CardPanelProps = {\n actions: FloatingCardHeaderAction[] | undefined;\n getBounds: () => Bounds;\n icon: React.ReactNode;\n id: UniqueId;\n isPinned: (id: UniqueId) => boolean;\n layout: FloatingCardLayout;\n onAddRef: (id: UniqueId, ref: HTMLDivElement | null) => void;\n onClose: (id: UniqueId) => void;\n onFocus: (id: UniqueId) => void;\n onMove: (id: UniqueId, position: Position) => void;\n onResize: (id: UniqueId, dimensions: Dimensions, position: Position) => void;\n onTogglePin: (id: UniqueId) => void;\n subscribeToPinState: (callback: () => void) => () => void;\n};\n\n/**\n * Binds one card's identity to the provider's callbacks so {@link FloatingCardPanel}\n * can stay a plain presentational component.\n *\n * @remarks\n * Pin state lives in a mutable store rather than React state, so it is read\n * through `useSyncExternalStore` -- only the cards whose pin state changed\n * re-render.\n */\nfunction CardPanel({\n actions,\n getBounds,\n icon,\n id,\n isPinned,\n layout,\n onAddRef,\n onClose,\n onFocus,\n onMove,\n onResize,\n onTogglePin,\n subscribeToPinState,\n}: CardPanelProps) {\n const { title } = layout;\n\n const pinned = useSyncExternalStore(\n subscribeToPinState,\n () => isPinned(id),\n () => false,\n );\n\n const contentRef = useCallback(\n (element: HTMLDivElement | null) => {\n onAddRef(id, element);\n },\n [id, onAddRef],\n );\n\n return (\n <FloatingCardPanel\n actions={\n <CardHeaderActions\n actions={actions}\n id={id}\n isPinned={pinned}\n onClose={() => onClose(id)}\n onTogglePin={() => onTogglePin(id)}\n />\n }\n contentRef={contentRef}\n getBounds={getBounds}\n header={<CardHeaderStart icon={icon} title={title} />}\n id={id}\n isPinned={pinned}\n // Ids are typically uuids, which read as noise to a screen reader, so an\n // untitled card gets a generic name instead.\n label={title ?? 'Floating card'}\n layout={layout}\n onFocus={() => onFocus(id)}\n onMove={(position) => onMove(id, position)}\n onResize={(dimensions, position) => onResize(id, dimensions, position)}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAS,gBAAgB,EACvB,MACA,SACiE;AACjE,QACE,qBAAC;EAAI,WAAW,OAAO;aACpB,OAAO,oBAAC;GAAK,MAAK;aAAS;IAAY,GAAG,MAC1C,QACC,oBAAC;GAAI,WAAW,OAAO;aACrB,oBAAC;IAAI,WAAW,OAAO;cAAc;KAAY;IAC7C,GACJ;GACA;;;AAKV,SAAS,kBAAkB,EACzB,SACA,IACA,UACA,SACA,eAOE;AACF,QACE,8CACG,SAAS,KAAK,QAAQ,UAAU;AAC/B,MAAI,WAAW,UACb,QAEE,oBAAC,WAAuC,aAAY,cAAtC,GAAG,GAAG,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c;EAAQ,GACzC,CAAC,cAAc,OAAO,CACvB;AAED,QACE,oBAAC,oBAAoB;EAAS,OAAO;YACnC,oBAAC,4BAA4B;GAAS,OAAO;aAC3C,qBAAC;IAAI,WAAW,KAAK,OAAO,cAAc,UAAU;IAAE,KAAK;eACxD,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,IAAI,YACjC,oBAAC;KACC,SAAS,oBAAoB,eAAe,GAAG;KACpC;KACX,MAAM,oBAAoB,MAAM,GAAG;KAC/B;KACM;KAEF;KACR,UAAU;KACV,SAAS;KACT,SAAS;KACT,QAAQ;KACR,UAAU;KACV,aAAa;KACQ;OARhB,GASL,CACF,EACD;KACG;IAC+B;GACV;;;;;;;;;;;AA6BnC,SAAS,UAAU,EACjB,SACA,WACA,MACA,IACA,UACA,QACA,UACA,SACA,SACA,QACA,UACA,aACA,uBACiB;CACjB,MAAM,EAAE,UAAU;CAElB,MAAM,SAAS,qBACb,2BACM,SAAS,GAAG,QACZ,MACP;CAED,MAAM,aAAa,aAChB,YAAmC;AAClC,WAAS,IAAI,QAAQ;IAEvB,CAAC,IAAI,SAAS,CACf;AAED,QACE,oBAAC;EACC,SACE,oBAAC;GACU;GACL;GACJ,UAAU;GACV,eAAe,QAAQ,GAAG;GAC1B,mBAAmB,YAAY,GAAG;IAClC;EAEQ;EACD;EACX,QAAQ,oBAAC;GAAsB;GAAa;IAAS;EACjD;EACJ,UAAU;EAGV,OAAO,SAAS;EACR;EACR,eAAe,QAAQ,GAAG;EAC1B,SAAS,aAAa,OAAO,IAAI,SAAS;EAC1C,WAAW,YAAY,aAAa,SAAS,IAAI,YAAY,SAAS;GACtE"}
|
|
@@ -13,21 +13,36 @@
|
|
|
13
13
|
@reference '@accelint/design-foundation/styles';
|
|
14
14
|
|
|
15
15
|
@layer components.l3 {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
/* The provider covers its container but stays transparent to pointer events,
|
|
17
|
+
so only the cards themselves are interactive and the application content
|
|
18
|
+
beneath keeps working normally. */
|
|
20
19
|
.providerRoot {
|
|
21
20
|
@apply pointer-events-none absolute inset-0;
|
|
22
21
|
}
|
|
23
22
|
|
|
23
|
+
.panel {
|
|
24
|
+
@apply bg-surface-default rounded-large shadow-elevation-overlay-bold pointer-events-auto absolute flex flex-col overflow-hidden;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.header {
|
|
28
|
+
@apply p-xs gap-xs text-header-m @container/floating-card-header flex h-32 shrink-0 cursor-grab items-center;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* A pinned card cannot be moved, so its header stops advertising a drag. */
|
|
32
|
+
.panel[data-pinned] .header {
|
|
33
|
+
@apply cursor-default;
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
.headerSide {
|
|
25
37
|
@apply gap-xs flex h-full items-center;
|
|
26
38
|
}
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
.headerActions {
|
|
41
|
+
@apply gap-xs ml-auto flex h-full items-center;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Zero width + pointer-events-none lets the title visually overflow the flex
|
|
45
|
+
row without consuming space or swallowing the header's drag gesture. */
|
|
31
46
|
.headerTitleContainer {
|
|
32
47
|
@apply text-header-m pl-xs pointer-events-none h-full w-0;
|
|
33
48
|
}
|
|
@@ -42,37 +57,76 @@
|
|
|
42
57
|
@apply h-full truncate leading-24 @min-[1rem]/floating-card-header:w-[calc(100cqw-10rem)];
|
|
43
58
|
}
|
|
44
59
|
|
|
45
|
-
.
|
|
46
|
-
@apply
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
.content {
|
|
61
|
+
@apply min-h-0 flex-1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Resize handles are invisible hit areas laid over the card's edges and
|
|
65
|
+
corners. Corners sit above edges so the diagonal cursors win where the two
|
|
66
|
+
overlap. */
|
|
67
|
+
.resize-n,
|
|
68
|
+
.resize-s,
|
|
69
|
+
.resize-e,
|
|
70
|
+
.resize-w,
|
|
71
|
+
.resize-ne,
|
|
72
|
+
.resize-nw,
|
|
73
|
+
.resize-se,
|
|
74
|
+
.resize-sw {
|
|
75
|
+
@apply absolute;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.resize-n,
|
|
79
|
+
.resize-s {
|
|
80
|
+
@apply h-xxs inset-x-0;
|
|
81
|
+
cursor: ns-resize;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.resize-e,
|
|
85
|
+
.resize-w {
|
|
86
|
+
@apply w-xxs inset-y-0;
|
|
87
|
+
cursor: ew-resize;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.resize-n {
|
|
91
|
+
@apply top-0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.resize-s {
|
|
95
|
+
@apply bottom-0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.resize-e {
|
|
99
|
+
@apply right-0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.resize-w {
|
|
103
|
+
@apply left-0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.resize-ne,
|
|
107
|
+
.resize-nw,
|
|
108
|
+
.resize-se,
|
|
109
|
+
.resize-sw {
|
|
110
|
+
@apply size-s z-1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.resize-ne {
|
|
114
|
+
@apply top-0 right-0;
|
|
115
|
+
cursor: nesw-resize;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.resize-nw {
|
|
119
|
+
@apply top-0 left-0;
|
|
120
|
+
cursor: nwse-resize;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.resize-se {
|
|
124
|
+
@apply right-0 bottom-0;
|
|
125
|
+
cursor: nwse-resize;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.resize-sw {
|
|
129
|
+
@apply bottom-0 left-0;
|
|
130
|
+
cursor: nesw-resize;
|
|
77
131
|
}
|
|
78
132
|
}
|
|
@@ -12,10 +12,35 @@
|
|
|
12
12
|
|
|
13
13
|
import { MaybeFactory } from "./utils.js";
|
|
14
14
|
import { PropsWithChildren, ReactNode } from "react";
|
|
15
|
-
import { DockviewApi } from "dockview-react";
|
|
16
15
|
import { UniqueId } from "@accelint/core/utility/uuid";
|
|
17
16
|
|
|
18
17
|
//#region src/components/floating-card/types.d.ts
|
|
18
|
+
/** A point in the provider's coordinate space. */
|
|
19
|
+
type Position = {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
};
|
|
23
|
+
/** A card's rendered size. */
|
|
24
|
+
type Dimensions = {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
/** The box a card is kept inside while dragging and resizing. */
|
|
29
|
+
type Bounds = {
|
|
30
|
+
top: number;
|
|
31
|
+
left: number;
|
|
32
|
+
right: number;
|
|
33
|
+
bottom: number;
|
|
34
|
+
};
|
|
35
|
+
/** Edge or corner a resize gesture pulls from. */
|
|
36
|
+
type ResizeHandle = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw';
|
|
37
|
+
/** Geometry, title, and stacking for one card, tracked by the provider. */
|
|
38
|
+
type FloatingCardLayout = {
|
|
39
|
+
title: string | undefined;
|
|
40
|
+
position: Position;
|
|
41
|
+
dimensions: Dimensions;
|
|
42
|
+
zIndex: number;
|
|
43
|
+
};
|
|
19
44
|
/**
|
|
20
45
|
* Context value providing floating card management functionality.
|
|
21
46
|
*
|
|
@@ -25,20 +50,19 @@ import { UniqueId } from "@accelint/core/utility/uuid";
|
|
|
25
50
|
type FloatingCardContextValue = {
|
|
26
51
|
/** Registry mapping card IDs to their rendered DOM containers */
|
|
27
52
|
cards: Record<UniqueId, HTMLDivElement>;
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Programmatically closes a floating card by ID.
|
|
55
|
+
*
|
|
56
|
+
* @remarks Closing clears the card's pin state, so a pinned card that closes
|
|
57
|
+
* reopens unpinned.
|
|
58
|
+
*/
|
|
33
59
|
closeCard: (id: UniqueId) => void;
|
|
34
|
-
/** Toggles pin state for a floating card, disabling drag when pinned */
|
|
60
|
+
/** Toggles pin state for a floating card, disabling drag and resize when pinned */
|
|
35
61
|
togglePinCard: (id: UniqueId) => void;
|
|
36
62
|
/** Checks if a floating card is currently pinned */
|
|
37
63
|
isPinned: (id: UniqueId) => boolean;
|
|
38
64
|
/** Subscribes to pin state changes; returns an unsubscribe function */
|
|
39
65
|
subscribeToPinState: (callback: () => void) => () => void;
|
|
40
|
-
/** Dockview API instance, null until FloatingCardProvider's onReady fires */
|
|
41
|
-
api: DockviewApi | null;
|
|
42
66
|
};
|
|
43
67
|
/**
|
|
44
68
|
* Props for the FloatingCard component.
|
|
@@ -109,6 +133,13 @@ type FloatingCardProps = Readonly<{
|
|
|
109
133
|
type FloatingCardHeaderAction = {
|
|
110
134
|
/** Icon to display in the action button */
|
|
111
135
|
icon: ReactNode;
|
|
136
|
+
/**
|
|
137
|
+
* Accessible name for the button.
|
|
138
|
+
*
|
|
139
|
+
* @remarks The button renders an icon with no visible text, so without a
|
|
140
|
+
* label screen readers announce it only as "button".
|
|
141
|
+
*/
|
|
142
|
+
label?: string;
|
|
112
143
|
/** Handler called when the action button is clicked */
|
|
113
144
|
onClick: () => void;
|
|
114
145
|
} | 'divider' | 'pin';
|
|
@@ -146,6 +177,16 @@ type FloatingCardProviderProps = Readonly<PropsWithChildren<{
|
|
|
146
177
|
* per-floating card actions.
|
|
147
178
|
*/
|
|
148
179
|
headerActions?: MaybeFactory<FloatingCardHeaderAction[]>;
|
|
180
|
+
/**
|
|
181
|
+
* Region that cards are kept inside while being dragged and resized.
|
|
182
|
+
*
|
|
183
|
+
* `'provider'` confines cards to the provider element, so a provider that
|
|
184
|
+
* occupies part of the page keeps its cards within that region.
|
|
185
|
+
* `'viewport'` lets cards move anywhere on screen.
|
|
186
|
+
*
|
|
187
|
+
* @defaultValue 'provider'
|
|
188
|
+
*/
|
|
189
|
+
bounds?: 'provider' | 'viewport';
|
|
149
190
|
/**
|
|
150
191
|
* Optional set of card IDs that should be pinned when the provider first mounts.
|
|
151
192
|
*
|
|
@@ -157,5 +198,5 @@ type FloatingCardProviderProps = Readonly<PropsWithChildren<{
|
|
|
157
198
|
className?: string;
|
|
158
199
|
}>>;
|
|
159
200
|
//#endregion
|
|
160
|
-
export { FloatingCardContextValue, FloatingCardHeaderAction, FloatingCardProps, FloatingCardProviderProps };
|
|
201
|
+
export { Bounds, Dimensions, FloatingCardContextValue, FloatingCardHeaderAction, FloatingCardLayout, FloatingCardProps, FloatingCardProviderProps, Position, ResizeHandle };
|
|
161
202
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { FloatingCardHeaderAction } from "./types.js";
|
|
14
|
-
import { FunctionComponent, ReactNode } from "react";
|
|
15
|
-
import { IDockviewHeaderActionsProps } from "dockview-react";
|
|
16
|
-
import { UniqueId } from "@accelint/core/utility/uuid";
|
|
17
|
-
|
|
18
1
|
//#region src/components/floating-card/utils.d.ts
|
|
19
2
|
/**
|
|
20
3
|
* A value that can be static or dynamically computed per floating card.
|
|
@@ -26,79 +9,19 @@ import { UniqueId } from "@accelint/core/utility/uuid";
|
|
|
26
9
|
*/
|
|
27
10
|
type MaybeFactory<T> = T | ((cardId: string) => T);
|
|
28
11
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* Used internally by the floating card system to provide header components
|
|
32
|
-
* with the necessary props and callbacks for rendering customizable headers.
|
|
12
|
+
* Reads a value that callers may supply either directly or as a per-card factory.
|
|
33
13
|
*
|
|
34
|
-
* @
|
|
35
|
-
*
|
|
36
|
-
*
|
|
14
|
+
* @template T - Type of the resolved value.
|
|
15
|
+
* @param value - The static value or factory.
|
|
16
|
+
* @param cardId - Card the value is being resolved for.
|
|
17
|
+
* @returns The value for this card.
|
|
37
18
|
*
|
|
38
19
|
* @example
|
|
39
20
|
* ```tsx
|
|
40
|
-
*
|
|
41
|
-
* return (props: DockviewHeaderProps) => {
|
|
42
|
-
* const icon = typeof options.icon === 'function'
|
|
43
|
-
* ? options.icon(props.id)
|
|
44
|
-
* : options.icon;
|
|
45
|
-
* const actions = typeof options.headerActions === 'function'
|
|
46
|
-
* ? options.headerActions(props.id)
|
|
47
|
-
* : options.headerActions;
|
|
48
|
-
*
|
|
49
|
-
* return (
|
|
50
|
-
* <CustomHeader
|
|
51
|
-
* icon={icon}
|
|
52
|
-
* actions={actions}
|
|
53
|
-
* isPinned={options.isPinned?.(props.id)}
|
|
54
|
-
* onTogglePin={() => options.togglePinCard?.(props.id)}
|
|
55
|
-
* />
|
|
56
|
-
* );
|
|
57
|
-
* };
|
|
58
|
-
* }
|
|
21
|
+
* const icon = resolveMaybeFactory(props.icon, cardId);
|
|
59
22
|
* ```
|
|
60
23
|
*/
|
|
61
|
-
|
|
62
|
-
icon?: MaybeFactory<ReactNode>;
|
|
63
|
-
headerActions?: MaybeFactory<FloatingCardHeaderProps['headerActions']>;
|
|
64
|
-
togglePinCard?: (id: UniqueId) => void;
|
|
65
|
-
isPinned?: (id: UniqueId) => boolean;
|
|
66
|
-
subscribeToPinState?: (callback: () => void) => () => void;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Props passed to floating card header components.
|
|
70
|
-
*
|
|
71
|
-
* @remarks Internal type used by header adapters to map Dockview props to custom header components.
|
|
72
|
-
*/
|
|
73
|
-
type FloatingCardHeaderProps = {
|
|
74
|
-
/** ID of the active floating card panel */
|
|
75
|
-
id?: string;
|
|
76
|
-
/** Title text displayed in the header */
|
|
77
|
-
title?: string;
|
|
78
|
-
/** Optional icon displayed at the start of the header */
|
|
79
|
-
icon?: ReactNode;
|
|
80
|
-
/** Callback to close the entire card group */
|
|
81
|
-
closeGroup: () => void;
|
|
82
|
-
/** Toggles pin state for the specified card */
|
|
83
|
-
togglePinCard?: (id: UniqueId) => void;
|
|
84
|
-
/** Checks if the specified card is pinned */
|
|
85
|
-
isPinned?: (id: UniqueId) => boolean;
|
|
86
|
-
/** Subscribes to pin state changes; returns an unsubscribe function */
|
|
87
|
-
subscribeToPinState?: (callback: () => void) => () => void;
|
|
88
|
-
/** Custom action buttons to render in the header */
|
|
89
|
-
headerActions?: FloatingCardHeaderAction[];
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Creates an adapter component to map Dockview's header action props to custom header component props.
|
|
93
|
-
*
|
|
94
|
-
* Handles title change subscriptions and resolves MaybeFactory options (icon, headerActions)
|
|
95
|
-
* either as static values or by invoking factory functions with the active card ID.
|
|
96
|
-
*
|
|
97
|
-
* @param Component - The header component to wrap.
|
|
98
|
-
* @param options - Configuration options including icon and headerActions (static or factory).
|
|
99
|
-
* @returns Adapter component compatible with Dockview's header API.
|
|
100
|
-
*/
|
|
101
|
-
declare function createHeaderAdapter(Component: FunctionComponent<FloatingCardHeaderProps>, options: HeaderAdapterOptions): FunctionComponent<IDockviewHeaderActionsProps>;
|
|
24
|
+
declare function resolveMaybeFactory<T>(value: MaybeFactory<T> | undefined, cardId: string): T | undefined;
|
|
102
25
|
//#endregion
|
|
103
|
-
export {
|
|
26
|
+
export { MaybeFactory, resolveMaybeFactory };
|
|
104
27
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -11,50 +11,24 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
import { useEffect, useState } from "react";
|
|
15
|
-
import { jsx } from "react/jsx-runtime";
|
|
16
|
-
|
|
17
14
|
//#region src/components/floating-card/utils.tsx
|
|
18
15
|
/**
|
|
19
|
-
*
|
|
16
|
+
* Reads a value that callers may supply either directly or as a per-card factory.
|
|
20
17
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
18
|
+
* @template T - Type of the resolved value.
|
|
19
|
+
* @param value - The static value or factory.
|
|
20
|
+
* @param cardId - Card the value is being resolved for.
|
|
21
|
+
* @returns The value for this card.
|
|
23
22
|
*
|
|
24
|
-
* @
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const icon = resolveMaybeFactory(props.icon, cardId);
|
|
26
|
+
* ```
|
|
27
27
|
*/
|
|
28
|
-
function
|
|
29
|
-
function
|
|
30
|
-
const panelId = props.panels[0]?.id ?? "";
|
|
31
|
-
const [title, setTitle] = useState(props.activePanel?.title);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const panel = props.activePanel;
|
|
34
|
-
if (!panel) return;
|
|
35
|
-
setTitle(panel.title);
|
|
36
|
-
const disposable = panel.api.onDidTitleChange(() => {
|
|
37
|
-
setTitle(panel.title);
|
|
38
|
-
});
|
|
39
|
-
return () => {
|
|
40
|
-
disposable.dispose();
|
|
41
|
-
};
|
|
42
|
-
}, [props.activePanel]);
|
|
43
|
-
return /* @__PURE__ */ jsx(Component, {
|
|
44
|
-
icon: props.activePanel ? typeof options?.icon === "function" ? options.icon(panelId) : options?.icon : void 0,
|
|
45
|
-
headerActions: typeof options?.headerActions === "function" ? options.headerActions(panelId) : options?.headerActions,
|
|
46
|
-
title,
|
|
47
|
-
id: props.activePanel?.id,
|
|
48
|
-
closeGroup: () => props.api.close(),
|
|
49
|
-
togglePinCard: options.togglePinCard,
|
|
50
|
-
isPinned: options.isPinned,
|
|
51
|
-
subscribeToPinState: options.subscribeToPinState
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
HeaderAdapter.displayName = `HeaderAdapter(${Component.displayName ?? Component.name ?? "Anonymous"})`;
|
|
55
|
-
return HeaderAdapter;
|
|
28
|
+
function resolveMaybeFactory(value, cardId) {
|
|
29
|
+
return typeof value === "function" ? value(cardId) : value;
|
|
56
30
|
}
|
|
57
31
|
|
|
58
32
|
//#endregion
|
|
59
|
-
export {
|
|
33
|
+
export { resolveMaybeFactory };
|
|
60
34
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/floating-card/utils.tsx"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/floating-card/utils.tsx"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * A value that can be static or dynamically computed per floating card.\n *\n * Enables per-card customization of props by passing a factory function\n * that receives the card ID and returns the appropriate value.\n *\n * @template T - The type of the static value or factory return type.\n */\nexport type MaybeFactory<T> = T | ((cardId: string) => T);\n\n/**\n * Reads a value that callers may supply either directly or as a per-card factory.\n *\n * @template T - Type of the resolved value.\n * @param value - The static value or factory.\n * @param cardId - Card the value is being resolved for.\n * @returns The value for this card.\n *\n * @example\n * ```tsx\n * const icon = resolveMaybeFactory(props.icon, cardId);\n * ```\n */\nexport function resolveMaybeFactory<T>(\n value: MaybeFactory<T> | undefined,\n cardId: string,\n): T | undefined {\n return typeof value === 'function'\n ? (value as (cardId: string) => T)(cardId)\n : value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,oBACd,OACA,QACe;AACf,QAAO,OAAO,UAAU,aACnB,MAAgC,OAAO,GACxC"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { GanttRowElementColorProp } from "../../types.js";
|
|
14
14
|
import { HTMLAttributes, PropsWithChildren } from "react";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime215 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/gantt/components/base-elements/point.d.ts
|
|
18
18
|
/** Props for point-based Gantt elements (markers, brackets). */
|
|
@@ -22,7 +22,7 @@ type PointProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
22
22
|
/** Visual color variant. @default 'accent' */
|
|
23
23
|
color?: GanttRowElementColorProp;
|
|
24
24
|
};
|
|
25
|
-
declare function Point(props: PropsWithChildren<PointProps>):
|
|
25
|
+
declare function Point(props: PropsWithChildren<PointProps>): react_jsx_runtime215.JSX.Element | null;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { Point, PointProps };
|
|
28
28
|
//# sourceMappingURL=point.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { GanttRowElementColorProp } from "../../types.js";
|
|
14
14
|
import { HTMLAttributes, PropsWithChildren } from "react";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime217 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/gantt/components/base-elements/range.d.ts
|
|
18
18
|
/** Props for range-based Gantt elements (blocks, spacers). */
|
|
@@ -24,7 +24,7 @@ type RangeProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
24
24
|
/** Visual color variant. @default 'accent' */
|
|
25
25
|
color?: GanttRowElementColorProp;
|
|
26
26
|
};
|
|
27
|
-
declare function Range(props: PropsWithChildren<RangeProps>):
|
|
27
|
+
declare function Range(props: PropsWithChildren<RangeProps>): react_jsx_runtime217.JSX.Element | null;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { Range, RangeProps };
|
|
30
30
|
//# sourceMappingURL=range.d.ts.map
|
package/dist/components/gantt/components/containers/external/gantt-content-container/index.d.ts
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { PropsWithChildren } from "react";
|
|
14
|
-
import * as
|
|
14
|
+
import * as react_jsx_runtime237 from "react/jsx-runtime";
|
|
15
15
|
|
|
16
16
|
//#region src/components/gantt/components/containers/external/gantt-content-container/index.d.ts
|
|
17
17
|
/** Scrollable content area of the Gantt chart containing the timeline header and virtualized content rows. */
|
|
18
18
|
declare function GanttContentContainer({
|
|
19
19
|
children
|
|
20
|
-
}: PropsWithChildren):
|
|
20
|
+
}: PropsWithChildren): react_jsx_runtime237.JSX.Element;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { GanttContentContainer };
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/components/gantt/components/containers/external/gantt-panel-container/index.d.ts
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { PropsWithChildren } from "react";
|
|
14
|
-
import * as
|
|
14
|
+
import * as react_jsx_runtime239 from "react/jsx-runtime";
|
|
15
15
|
|
|
16
16
|
//#region src/components/gantt/components/containers/external/gantt-panel-container/index.d.ts
|
|
17
17
|
/** Fixed-width side panel of the Gantt chart for row labels, paired alongside `GanttContentContainer`. */
|
|
18
18
|
declare function GanttPanelContainer({
|
|
19
19
|
children
|
|
20
|
-
}: PropsWithChildren):
|
|
20
|
+
}: PropsWithChildren): react_jsx_runtime239.JSX.Element;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { GanttPanelContainer };
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { PropsWithChildren } from "react";
|
|
14
|
-
import * as
|
|
14
|
+
import * as react_jsx_runtime235 from "react/jsx-runtime";
|
|
15
15
|
|
|
16
16
|
//#region src/components/gantt/components/containers/internal/index.d.ts
|
|
17
17
|
declare function RootContainer({
|
|
18
18
|
children
|
|
19
|
-
}: PropsWithChildren):
|
|
19
|
+
}: PropsWithChildren): react_jsx_runtime235.JSX.Element;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { RootContainer };
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { PropsWithChildren } from "react";
|
|
14
|
-
import * as
|
|
14
|
+
import * as react_jsx_runtime238 from "react/jsx-runtime";
|
|
15
15
|
|
|
16
16
|
//#region src/components/gantt/components/containers/internal/layout-container/index.d.ts
|
|
17
17
|
declare function LayoutContainer({
|
|
18
18
|
children
|
|
19
|
-
}: PropsWithChildren):
|
|
19
|
+
}: PropsWithChildren): react_jsx_runtime238.JSX.Element;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { LayoutContainer };
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|