react-panel-layout 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{FloatingPanelFrame-SOrLGjZd.js → FloatingPanelFrame-DDT6aING.js} +7 -8
- package/dist/FloatingPanelFrame-DDT6aING.js.map +1 -0
- package/dist/FloatingPanelFrame-DrYwgI9f.cjs +2 -0
- package/dist/FloatingPanelFrame-DrYwgI9f.cjs.map +1 -0
- package/dist/GridLayout-DC7fCmcI.cjs +2 -0
- package/dist/GridLayout-DC7fCmcI.cjs.map +1 -0
- package/dist/GridLayout-tpSM0iM-.js +1460 -0
- package/dist/GridLayout-tpSM0iM-.js.map +1 -0
- package/dist/components/grid/GridLayout.d.ts +5 -0
- package/dist/components/window/FloatingWindow.d.ts +15 -0
- package/dist/config/panelRouter.d.ts +2 -2
- package/dist/config.cjs +1 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/floating.cjs +1 -1
- package/dist/floating.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +892 -822
- package/dist/index.js.map +1 -1
- package/dist/modules/grid/GridLayoutContext.d.ts +5 -0
- package/dist/modules/grid/resizeHandles.d.ts +14 -0
- package/dist/modules/grid/trackUtils.d.ts +29 -0
- package/dist/modules/grid/useGridTracks.d.ts +6 -15
- package/dist/modules/grid/useLayerInteractions.d.ts +2 -1
- package/dist/modules/window/useFloatingState.d.ts +9 -0
- package/dist/types.d.ts +79 -4
- package/dist/utils/css.d.ts +19 -0
- package/package.json +1 -1
- package/dist/FloatingPanelFrame-SOrLGjZd.js.map +0 -1
- package/dist/FloatingPanelFrame-XtBcHANI.cjs +0 -2
- package/dist/FloatingPanelFrame-XtBcHANI.cjs.map +0 -1
- package/dist/GridLayout-CLvW8jID.js +0 -1352
- package/dist/GridLayout-CLvW8jID.js.map +0 -1
- package/dist/GridLayout-qufTyOQM.cjs +0 -2
- package/dist/GridLayout-qufTyOQM.cjs.map +0 -1
package/dist/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","sources":["../src/config/panelRouter.tsx","../src/config/PanelContentDeclaration.tsx"],"sourcesContent":["/**\n * @file Router-like builder for GridLayout\n *\n * Provides a React Router–style configuration API to declare panel layers.\n * Converts route objects to the existing GridLayout props without magic.\n */\nimport * as React from \"react\";\nimport type {\n DrawerBehavior,\n FloatingWindowConfig,\n LayerDefinition,\n LayerPositionMode,\n PanelLayoutConfig,\n PanelLayoutProps,\n PivotBehavior,\n WindowPosition,\n} from \"../types\";\nimport { GridLayout } from \"../components/grid/GridLayout\";\n\nexport type PanelRoute = {\n /** Unique id for the layer. Required. */\n id: string;\n /** React node to render for this layer. Required. */\n element: React.ReactNode;\n /** Visibility flag. Defaults to visible. */\n visible?: boolean;\n\n /**\n * Grid placement key. When using `positionMode: 'grid'` (default), this must be provided.\n * Using `area` mirrors React Router's route path intent but for grid cells.\n */\n area?: string;\n\n /** Explicit positioning mode; defaults to 'grid' unless floating/drawer implies otherwise. */\n positionMode?: LayerPositionMode;\n /** Offsets when using non-grid modes. */\n position?: WindowPosition;\n /** Optional stacking order. */\n zIndex?: number;\n /** Optional dimensions; required for resizable/draggable floating layers. */\n width?: number | string;\n height?: number | string;\n /** Pointer events control. */\n pointerEvents?: boolean | \"auto\" | \"none\";\n /** Optional style overrides. */\n style?: React.CSSProperties;\n /** Optional backdrop style (drawer). */\n backdropStyle?: React.CSSProperties;\n\n /** Drawer behavior for mobile-friendly panels. */\n drawer?: DrawerBehavior;\n /** Floating window configuration. */\n floating?: FloatingWindowConfig;\n /** Pivot behavior for content switching. */\n pivot?: PivotBehavior;\n\n /**\n * Optional child declarations; purely a grouping convenience.\n * Children are flattened; no implicit inheritance.\n */\n children?: PanelRoute[];\n};\n\nconst toLayer = (route: PanelRoute): LayerDefinition => {\n const inferredMode: LayerPositionMode = resolveRoutePositionMode(route);\n\n if (inferredMode === \"grid\") {\n if (!route.area) {\n throw new Error(`PanelRoute ${route.id} must specify 'area' for grid placement.`);\n }\n }\n\n return {\n id: route.id,\n component: route.element,\n visible: route.visible,\n gridArea: route.area,\n positionMode: inferredMode,\n position: route.position,\n zIndex: route.zIndex,\n width: route.width,\n height: route.height,\n pointerEvents: route.pointerEvents,\n style: route.style,\n drawer: route.drawer,\n floating: route.floating,\n pivot: route.pivot,\n backdropStyle: route.backdropStyle,\n } satisfies LayerDefinition;\n};\n\nconst resolveRoutePositionMode = (route: PanelRoute): LayerPositionMode => {\n if (route.positionMode) {\n return route.positionMode;\n }\n if (route.floating) {\n // Embedded => absolute, Popup => relative (handled by renderer); keep explicitness here.\n return \"absolute\";\n }\n if (route.drawer) {\n return \"grid\";\n }\n return \"grid\";\n};\n\nconst flattenRoutes = (routes: PanelRoute[]): PanelRoute[] => {\n const result: PanelRoute[] = [];\n const walk = (node: PanelRoute): void => {\n result.push(node);\n if (node.children) {\n node.children.forEach((child) => walk(child));\n }\n };\n routes.forEach((r) => walk(r));\n return result;\n};\n\nconst validateUniqueIds = (routes: PanelRoute[]): void => {\n const seen = new Set<string>();\n routes.forEach((r) => {\n if (seen.has(r.id)) {\n throw new Error(`Duplicate PanelRoute id detected: ${r.id}`);\n }\n seen.add(r.id);\n });\n};\n\nexport const buildLayersFromRoutes = (routes: PanelRoute[]): LayerDefinition[] => {\n const flat = flattenRoutes(routes);\n validateUniqueIds(flat);\n return flat.map((r) => toLayer(r));\n};\n\nexport const createPanelLayoutFromRoutes = (input: {\n config: PanelLayoutConfig;\n routes: PanelRoute[];\n style?: React.CSSProperties;\n}): PanelLayoutProps => {\n const layers = buildLayersFromRoutes(input.routes);\n return {\n config: input.config,\n layers,\n };\n};\n\nexport type PanelLayoutRouterProps = {\n config: PanelLayoutConfig;\n routes: PanelRoute[];\n style?: React.CSSProperties;\n};\n\nexport const PanelLayoutRouter: React.FC<PanelLayoutRouterProps> = ({ config, routes, style }) => {\n const layers = React.useMemo(() => buildLayersFromRoutes(routes), [routes]);\n return <GridLayout config={config} layers={layers} style={style} />;\n};\n","/**\n * @file PanelContentDeclaration (JSX DSL for content configuration ONLY)\n *\n * IMPORTANT: This file declares a JSX DSL to configure panel \"content\" and layout\n * tracks. It does NOT implement grid rendering, resizing, dragging, or drawers.\n * Those behaviors live in the existing layout/rendering modules. Keep this file\n * limited to declaration and conversion into GridLayout props.\n *\n * Usage (content declaration):\n * <PanelLayout>\n * <Config>\n * <Rows>...</Rows>\n * <Columns>...</Columns>\n * <Areas matrix={...}/>\n * </Config>\n * <Panel type=\"grid\" id=\"main\" area=\"main\">...</Panel>\n * <Panel type=\"floating\" id=\"preview\" position={{ left: 0, top: 0 }} width={300} height={200} />\n * <Panel type=\"drawer\" id=\"nav\" drawer={{ defaultOpen: true }} position={{ left: 0 }} />\n * </PanelLayout>\n */\nimport * as React from \"react\";\nimport { GridLayout } from \"../components/grid/GridLayout\";\nimport type { DrawerBehavior, GridTrack, PanelLayoutConfig, WindowPosition } from \"../types\";\nimport type { PanelRoute } from \"./panelRouter\";\nimport { buildLayersFromRoutes } from \"./panelRouter\";\n\nexport type PanelRootProps = {\n config?: PanelLayoutConfig;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n// Unified child declaration: <Panel type=\"grid\" .../> or <Panel type=\"floating\" .../>...\ntype PanelCommonProps = {\n id: string;\n visible?: boolean;\n zIndex?: number;\n width?: number | string;\n height?: number | string;\n pointerEvents?: boolean | \"auto\" | \"none\";\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nexport type PanelProps =\n | (PanelCommonProps & { type: \"grid\"; area: string })\n | (PanelCommonProps & {\n type: \"floating\";\n position: WindowPosition;\n width: number | string;\n height: number | string;\n draggable?: boolean;\n resizable?: boolean;\n })\n | (PanelCommonProps & {\n type: \"drawer\";\n drawer: DrawerBehavior;\n position?: WindowPosition;\n backdropStyle?: React.CSSProperties;\n })\n | (Omit<PanelCommonProps, \"children\"> & {\n type: \"pivot\";\n area: string;\n /** Currently active item ID (controlled mode) */\n activeId?: string;\n /** Default active item ID (uncontrolled mode) */\n defaultActiveId?: string;\n /** Callback when active item changes */\n onActiveChange?: (id: string) => void;\n children?: React.ReactNode;\n });\n\nexport const Panel: React.FC<PanelProps> = () => null;\n\n/**\n * PivotItem declaration for use inside <Panel type=\"pivot\">\n */\nexport type PivotItemDeclProps = {\n id: string;\n label?: string;\n disabled?: boolean;\n children?: React.ReactNode;\n};\n\nexport const PivotItem: React.FC<PivotItemDeclProps> = () => null;\n\nconst isElementOf = <P,>(element: unknown, component: React.FC<P>): element is React.ReactElement<P> => {\n if (!React.isValidElement<P>(element)) {\n return false;\n }\n return element.type === component;\n};\n\nexport const buildRoutesFromChildren = (children: React.ReactNode): PanelRoute[] => {\n const routes: PanelRoute[] = [];\n\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n // Unified <Panel type=\"...\" />\n if (isElementOf(node, Panel)) {\n const props = node.props as PanelProps;\n if (!props.id) {\n throw new Error(\"<Panel> requires an 'id' prop.\");\n }\n if (props.type === \"grid\") {\n if (!props.area) {\n throw new Error(`<Panel id=\"${props.id}\"> requires an explicit 'area' prop when type=\"grid\".`);\n }\n routes.push({\n id: props.id,\n area: props.area,\n element: props.children ?? null,\n visible: props.visible,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n });\n return;\n }\n if (props.type === \"floating\") {\n if (!props.position) {\n throw new Error(`<Panel id=\"${props.id}\"> requires a 'position' prop when type=\"floating\".`);\n }\n if (props.width === undefined || props.height === undefined) {\n throw new Error(`<Panel id=\"${props.id}\"> requires 'width' and 'height' when type=\"floating\".`);\n }\n routes.push({\n id: props.id,\n element: props.children ?? null,\n visible: props.visible ?? true,\n positionMode: \"absolute\",\n position: props.position,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n floating: { mode: \"embedded\", draggable: props.draggable, resizable: props.resizable },\n });\n return;\n }\n if (props.type === \"drawer\") {\n routes.push({\n id: props.id,\n element: props.children ?? null,\n visible: props.visible ?? true,\n positionMode: \"relative\",\n position: props.position,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n drawer: props.drawer,\n backdropStyle: props.backdropStyle,\n });\n return;\n }\n if (props.type === \"pivot\") {\n if (!props.area) {\n throw new Error(`<Panel id=\"${props.id}\"> requires an explicit 'area' prop when type=\"pivot\".`);\n }\n const pivotItems = collectPivotItems(props.children);\n if (pivotItems.length === 0) {\n throw new Error(`<Panel id=\"${props.id}\"> requires at least one <PivotItem> child when type=\"pivot\".`);\n }\n routes.push({\n id: props.id,\n area: props.area,\n element: null,\n visible: props.visible,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n pivot: {\n items: pivotItems,\n activeId: props.activeId,\n defaultActiveId: props.defaultActiveId,\n onActiveChange: props.onActiveChange,\n },\n });\n return;\n }\n // unknown type -> error for explicitness\n throw new Error(\"<Panel> has unsupported type.\");\n }\n\n if (React.isValidElement(node)) {\n if (node.type === React.Fragment) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n return;\n }\n // Unknown element: ignore quietly to allow comments/wrappers.\n return;\n }\n // Primitive nodes (string/number) are ignored.\n };\n\n visit(children);\n return routes;\n};\n\n// Root container renamed to PanelLayout to avoid name collision with child <Panel/>\nexport const PanelLayout: React.FC<PanelRootProps> = ({ config, style, children }) => {\n const routes = React.useMemo(() => buildRoutesFromChildren(children), [children]);\n const layers = React.useMemo(() => buildLayersFromRoutes(routes), [routes]);\n const derivedConfig = React.useMemo(() => {\n if (config) {\n return config;\n }\n const built = buildConfigFromChildren(children);\n if (!built) {\n throw new Error(\"Panel requires either 'config' prop or a JSX config (<Config><Rows/><Columns/><Areas/></Config>). \");\n }\n return built;\n }, [children, config]);\n return <GridLayout config={derivedConfig} layers={layers} style={style} />;\n};\n\n// =============================\n// JSX Config Declarations\n// =============================\n\nexport type ConfigProps = {\n gap?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nexport const Config: React.FC<ConfigProps> = () => {\n return null;\n};\n\nexport const Rows: React.FC<{ children?: React.ReactNode }> = () => {\n return null;\n};\n\nexport const Columns: React.FC<{ children?: React.ReactNode }> = () => {\n return null;\n};\n\nexport type RowProps = GridTrack;\nexport const Row: React.FC<RowProps> = () => {\n return null;\n};\n\nexport type ColumnProps = GridTrack;\nexport const Col: React.FC<ColumnProps> = () => {\n return null;\n};\n\nexport type AreasProps = {\n matrix: string[][];\n};\nexport const Areas: React.FC<AreasProps> = () => {\n return null;\n};\n\ntype CollectedConfig = {\n gap?: string;\n style?: React.CSSProperties;\n rows?: GridTrack[];\n columns?: GridTrack[];\n areas?: string[][];\n};\n\nconst collectTracks = <P extends GridTrack>(children: React.ReactNode, marker: React.FC<P>): GridTrack[] => {\n const result: GridTrack[] = [];\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n if (isElementOf(node, marker)) {\n const props = node.props as P;\n if (!props.size) {\n throw new Error(\"Row/Col requires 'size' property.\");\n }\n result.push({\n size: props.size,\n resizable: props.resizable,\n minSize: props.minSize,\n maxSize: props.maxSize,\n });\n return;\n }\n if (React.isValidElement(node)) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n }\n };\n visit(children);\n return result;\n};\n\nconst collectConfigBlock = (children: React.ReactNode): CollectedConfig | null => {\n const node = findFirst(children, Config);\n if (!node) {\n return null;\n }\n const props = node.props as ConfigProps;\n const rows = collectTracks(node.props.children, Row);\n const columns = collectTracks(node.props.children, Col);\n const areasNode = findFirst(node.props.children, Areas);\n const areas = areasNode ? (areasNode.props as AreasProps).matrix : undefined;\n return {\n gap: props.gap,\n style: props.style,\n rows,\n columns,\n areas,\n };\n};\n\nconst findFirst = <P,>(children: React.ReactNode, marker: React.FC<P>): React.ReactElement<P> | null => {\n const visit = (node: React.ReactNode): React.ReactElement<P> | null => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return null;\n }\n if (Array.isArray(node)) {\n for (const item of node) {\n const found = visit(item);\n if (found) {\n return found;\n }\n }\n return null;\n }\n if (isElementOf(node, marker)) {\n return node as React.ReactElement<P>;\n }\n if (React.isValidElement(node)) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n return visit(el.props.children);\n }\n return null;\n };\n return visit(children);\n};\n\ntype CollectedPivotItem = {\n id: string;\n label?: string;\n content: React.ReactNode;\n disabled?: boolean;\n};\n\nconst collectPivotItems = (children: React.ReactNode): CollectedPivotItem[] => {\n const items: CollectedPivotItem[] = [];\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n if (isElementOf(node, PivotItem)) {\n const props = node.props as PivotItemDeclProps;\n if (!props.id) {\n throw new Error(\"<PivotItem> requires an 'id' prop.\");\n }\n items.push({\n id: props.id,\n label: props.label,\n content: props.children ?? null,\n disabled: props.disabled,\n });\n return;\n }\n if (React.isValidElement(node)) {\n if (node.type === React.Fragment) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n }\n }\n };\n visit(children);\n return items;\n};\n\nexport const buildConfigFromChildren = (children: React.ReactNode): PanelLayoutConfig | null => {\n const collected = collectConfigBlock(children);\n if (!collected) {\n return null;\n }\n if (!collected.rows || collected.rows.length === 0) {\n throw new Error(\"Config must include at least one <Row size=...> inside <Config>.\");\n }\n if (!collected.columns || collected.columns.length === 0) {\n throw new Error(\"Config must include at least one <Col size=...> inside <Config>.\");\n }\n if (!collected.areas || collected.areas.length === 0) {\n throw new Error(\"Config must include <Areas matrix={...}> inside <Config>.\");\n }\n\n const rowCount = collected.areas.length;\n const colCount = collected.areas[0]?.length ?? 0;\n if (rowCount !== collected.rows.length) {\n throw new Error(`Areas row count (${rowCount}) must match Rows count (${collected.rows.length}).`);\n }\n if (colCount !== collected.columns.length) {\n throw new Error(`Areas column count (${colCount}) must match Columns count (${collected.columns.length}).`);\n }\n\n return {\n areas: collected.areas,\n rows: collected.rows,\n columns: collected.columns,\n gap: collected.gap,\n style: collected.style,\n } satisfies PanelLayoutConfig;\n};\n"],"names":["toLayer","route","inferredMode","resolveRoutePositionMode","flattenRoutes","routes","result","walk","node","child","r","validateUniqueIds","seen","buildLayersFromRoutes","flat","Panel","PivotItem","isElementOf","element","component","React","buildRoutesFromChildren","children","visit","props","pivotItems","collectPivotItems","PanelLayout","config","style","layers","derivedConfig","built","buildConfigFromChildren","jsx","GridLayout","Config","Rows","Columns","Row","Col","Areas","collectTracks","marker","collectConfigBlock","findFirst","rows","columns","areasNode","areas","item","found","items","collected","rowCount","colCount"],"mappings":"ycA+DMA,EAAWC,GAAuC,CACtD,MAAMC,EAAkCC,EAAyBF,CAAK,EAEtE,GAAIC,IAAiB,QACf,CAACD,EAAM,KACT,MAAM,IAAI,MAAM,cAAcA,EAAM,EAAE,0CAA0C,EAIpF,MAAO,CACL,GAAIA,EAAM,GACV,UAAWA,EAAM,QACjB,QAASA,EAAM,QACf,SAAUA,EAAM,KAChB,aAAcC,EACd,SAAUD,EAAM,SAChB,OAAQA,EAAM,OACd,MAAOA,EAAM,MACb,OAAQA,EAAM,OACd,cAAeA,EAAM,cACrB,MAAOA,EAAM,MACb,OAAQA,EAAM,OACd,SAAUA,EAAM,SAChB,MAAOA,EAAM,MACb,cAAeA,EAAM,aAAA,CAEzB,EAEME,EAA4BF,GAC5BA,EAAM,aACDA,EAAM,aAEXA,EAAM,SAED,YAELA,EAAM,OACD,QAKLG,EAAiBC,GAAuC,CAC5D,MAAM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AChB,QAASA,EAAU,QACnB,IAAKA,EAAU,IACf,MAAOA,EAAU,KAAA,CAErB"}
|
|
1
|
+
{"version":3,"file":"config.cjs","sources":["../src/config/panelRouter.tsx","../src/config/PanelContentDeclaration.tsx"],"sourcesContent":["/**\n * @file Router-like builder for GridLayout\n *\n * Provides a React Router–style configuration API to declare panel layers.\n * Converts route objects to the existing GridLayout props without magic.\n */\nimport * as React from \"react\";\nimport type {\n DrawerBehavior,\n FloatingBehavior,\n LayerDefinition,\n LayerPositionMode,\n PanelLayoutConfig,\n PanelLayoutProps,\n PivotBehavior,\n WindowPosition,\n} from \"../types\";\nimport { GridLayout } from \"../components/grid/GridLayout\";\n\nexport type PanelRoute = {\n /** Unique id for the layer. Required. */\n id: string;\n /** React node to render for this layer. Required. */\n element: React.ReactNode;\n /** Visibility flag. Defaults to visible. */\n visible?: boolean;\n\n /**\n * Grid placement key. When using `positionMode: 'grid'` (default), this must be provided.\n * Using `area` mirrors React Router's route path intent but for grid cells.\n */\n area?: string;\n\n /** Explicit positioning mode; defaults to 'grid' unless floating/drawer implies otherwise. */\n positionMode?: LayerPositionMode;\n /** Offsets when using non-grid modes. */\n position?: WindowPosition;\n /** Optional stacking order. */\n zIndex?: number;\n /** Optional dimensions; required for resizable/draggable floating layers. */\n width?: number | string;\n height?: number | string;\n /** Pointer events control. */\n pointerEvents?: boolean | \"auto\" | \"none\";\n /** Optional style overrides. */\n style?: React.CSSProperties;\n /** Optional backdrop style (drawer). */\n backdropStyle?: React.CSSProperties;\n\n /** Drawer behavior for mobile-friendly panels. */\n drawer?: DrawerBehavior;\n /** Floating window configuration. */\n floating?: FloatingBehavior;\n /** Pivot behavior for content switching. */\n pivot?: PivotBehavior;\n\n /**\n * Optional child declarations; purely a grouping convenience.\n * Children are flattened; no implicit inheritance.\n */\n children?: PanelRoute[];\n};\n\nconst toLayer = (route: PanelRoute): LayerDefinition => {\n const inferredMode: LayerPositionMode = resolveRoutePositionMode(route);\n\n if (inferredMode === \"grid\") {\n if (!route.area) {\n throw new Error(`PanelRoute ${route.id} must specify 'area' for grid placement.`);\n }\n }\n\n return {\n id: route.id,\n component: route.element,\n visible: route.visible,\n gridArea: route.area,\n positionMode: inferredMode,\n position: route.position,\n zIndex: route.zIndex,\n width: route.width,\n height: route.height,\n pointerEvents: route.pointerEvents,\n style: route.style,\n drawer: route.drawer,\n floating: route.floating,\n pivot: route.pivot,\n backdropStyle: route.backdropStyle,\n } satisfies LayerDefinition;\n};\n\nconst resolveRoutePositionMode = (route: PanelRoute): LayerPositionMode => {\n if (route.positionMode) {\n return route.positionMode;\n }\n if (route.floating) {\n // Embedded => absolute, Popup => relative (handled by renderer); keep explicitness here.\n return \"absolute\";\n }\n if (route.drawer) {\n return \"grid\";\n }\n return \"grid\";\n};\n\nconst flattenRoutes = (routes: PanelRoute[]): PanelRoute[] => {\n const result: PanelRoute[] = [];\n const walk = (node: PanelRoute): void => {\n result.push(node);\n if (node.children) {\n node.children.forEach((child) => walk(child));\n }\n };\n routes.forEach((r) => walk(r));\n return result;\n};\n\nconst validateUniqueIds = (routes: PanelRoute[]): void => {\n const seen = new Set<string>();\n routes.forEach((r) => {\n if (seen.has(r.id)) {\n throw new Error(`Duplicate PanelRoute id detected: ${r.id}`);\n }\n seen.add(r.id);\n });\n};\n\nexport const buildLayersFromRoutes = (routes: PanelRoute[]): LayerDefinition[] => {\n const flat = flattenRoutes(routes);\n validateUniqueIds(flat);\n return flat.map((r) => toLayer(r));\n};\n\nexport const createPanelLayoutFromRoutes = (input: {\n config: PanelLayoutConfig;\n routes: PanelRoute[];\n style?: React.CSSProperties;\n}): PanelLayoutProps => {\n const layers = buildLayersFromRoutes(input.routes);\n return {\n config: input.config,\n layers,\n };\n};\n\nexport type PanelLayoutRouterProps = {\n config: PanelLayoutConfig;\n routes: PanelRoute[];\n style?: React.CSSProperties;\n};\n\nexport const PanelLayoutRouter: React.FC<PanelLayoutRouterProps> = ({ config, routes, style }) => {\n const layers = React.useMemo(() => buildLayersFromRoutes(routes), [routes]);\n return <GridLayout config={config} layers={layers} style={style} />;\n};\n","/**\n * @file PanelContentDeclaration (JSX DSL for content configuration ONLY)\n *\n * IMPORTANT: This file declares a JSX DSL to configure panel \"content\" and layout\n * tracks. It does NOT implement grid rendering, resizing, dragging, or drawers.\n * Those behaviors live in the existing layout/rendering modules. Keep this file\n * limited to declaration and conversion into GridLayout props.\n *\n * Usage (content declaration):\n * <PanelLayout>\n * <Config>\n * <Rows>...</Rows>\n * <Columns>...</Columns>\n * <Areas matrix={...}/>\n * </Config>\n * <Panel type=\"grid\" id=\"main\" area=\"main\">...</Panel>\n * <Panel type=\"floating\" id=\"preview\" position={{ left: 0, top: 0 }} width={300} height={200} />\n * <Panel type=\"drawer\" id=\"nav\" drawer={{ defaultOpen: true }} position={{ left: 0 }} />\n * </PanelLayout>\n */\nimport * as React from \"react\";\nimport { GridLayout } from \"../components/grid/GridLayout\";\nimport type { DrawerBehavior, GridTrack, PanelLayoutConfig, WindowPosition } from \"../types\";\nimport type { PanelRoute } from \"./panelRouter\";\nimport { buildLayersFromRoutes } from \"./panelRouter\";\n\nexport type PanelRootProps = {\n config?: PanelLayoutConfig;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n// Unified child declaration: <Panel type=\"grid\" .../> or <Panel type=\"floating\" .../>...\ntype PanelCommonProps = {\n id: string;\n visible?: boolean;\n zIndex?: number;\n width?: number | string;\n height?: number | string;\n pointerEvents?: boolean | \"auto\" | \"none\";\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nexport type PanelProps =\n | (PanelCommonProps & { type: \"grid\"; area: string })\n | (PanelCommonProps & {\n type: \"floating\";\n position: WindowPosition;\n width: number | string;\n height: number | string;\n draggable?: boolean;\n resizable?: boolean;\n })\n | (PanelCommonProps & {\n type: \"drawer\";\n drawer: DrawerBehavior;\n position?: WindowPosition;\n backdropStyle?: React.CSSProperties;\n })\n | (Omit<PanelCommonProps, \"children\"> & {\n type: \"pivot\";\n area: string;\n /** Currently active item ID (controlled mode) */\n activeId?: string;\n /** Default active item ID (uncontrolled mode) */\n defaultActiveId?: string;\n /** Callback when active item changes */\n onActiveChange?: (id: string) => void;\n children?: React.ReactNode;\n });\n\nexport const Panel: React.FC<PanelProps> = () => null;\n\n/**\n * PivotItem declaration for use inside <Panel type=\"pivot\">\n */\nexport type PivotItemDeclProps = {\n id: string;\n label?: string;\n disabled?: boolean;\n children?: React.ReactNode;\n};\n\nexport const PivotItem: React.FC<PivotItemDeclProps> = () => null;\n\nconst isElementOf = <P,>(element: unknown, component: React.FC<P>): element is React.ReactElement<P> => {\n if (!React.isValidElement<P>(element)) {\n return false;\n }\n return element.type === component;\n};\n\nexport const buildRoutesFromChildren = (children: React.ReactNode): PanelRoute[] => {\n const routes: PanelRoute[] = [];\n\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n // Unified <Panel type=\"...\" />\n if (isElementOf(node, Panel)) {\n const props = node.props as PanelProps;\n if (!props.id) {\n throw new Error(\"<Panel> requires an 'id' prop.\");\n }\n if (props.type === \"grid\") {\n if (!props.area) {\n throw new Error(`<Panel id=\"${props.id}\"> requires an explicit 'area' prop when type=\"grid\".`);\n }\n routes.push({\n id: props.id,\n area: props.area,\n element: props.children ?? null,\n visible: props.visible,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n });\n return;\n }\n if (props.type === \"floating\") {\n if (!props.position) {\n throw new Error(`<Panel id=\"${props.id}\"> requires a 'position' prop when type=\"floating\".`);\n }\n if (props.width === undefined || props.height === undefined) {\n throw new Error(`<Panel id=\"${props.id}\"> requires 'width' and 'height' when type=\"floating\".`);\n }\n routes.push({\n id: props.id,\n element: props.children ?? null,\n visible: props.visible ?? true,\n positionMode: \"absolute\",\n position: props.position,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n floating: { mode: \"embedded\", draggable: props.draggable, resizable: props.resizable },\n });\n return;\n }\n if (props.type === \"drawer\") {\n routes.push({\n id: props.id,\n element: props.children ?? null,\n visible: props.visible ?? true,\n positionMode: \"relative\",\n position: props.position,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n drawer: props.drawer,\n backdropStyle: props.backdropStyle,\n });\n return;\n }\n if (props.type === \"pivot\") {\n if (!props.area) {\n throw new Error(`<Panel id=\"${props.id}\"> requires an explicit 'area' prop when type=\"pivot\".`);\n }\n const pivotItems = collectPivotItems(props.children);\n if (pivotItems.length === 0) {\n throw new Error(`<Panel id=\"${props.id}\"> requires at least one <PivotItem> child when type=\"pivot\".`);\n }\n routes.push({\n id: props.id,\n area: props.area,\n element: null,\n visible: props.visible,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n pivot: {\n items: pivotItems,\n activeId: props.activeId,\n defaultActiveId: props.defaultActiveId,\n onActiveChange: props.onActiveChange,\n },\n });\n return;\n }\n // unknown type -> error for explicitness\n throw new Error(\"<Panel> has unsupported type.\");\n }\n\n if (React.isValidElement(node)) {\n if (node.type === React.Fragment) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n return;\n }\n // Unknown element: ignore quietly to allow comments/wrappers.\n return;\n }\n // Primitive nodes (string/number) are ignored.\n };\n\n visit(children);\n return routes;\n};\n\n// Root container renamed to PanelLayout to avoid name collision with child <Panel/>\nexport const PanelLayout: React.FC<PanelRootProps> = ({ config, style, children }) => {\n const routes = React.useMemo(() => buildRoutesFromChildren(children), [children]);\n const layers = React.useMemo(() => buildLayersFromRoutes(routes), [routes]);\n const derivedConfig = React.useMemo(() => {\n if (config) {\n return config;\n }\n const built = buildConfigFromChildren(children);\n if (!built) {\n throw new Error(\"Panel requires either 'config' prop or a JSX config (<Config><Rows/><Columns/><Areas/></Config>). \");\n }\n return built;\n }, [children, config]);\n return <GridLayout config={derivedConfig} layers={layers} style={style} />;\n};\n\n// =============================\n// JSX Config Declarations\n// =============================\n\nexport type ConfigProps = {\n gap?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nexport const Config: React.FC<ConfigProps> = () => {\n return null;\n};\n\nexport const Rows: React.FC<{ children?: React.ReactNode }> = () => {\n return null;\n};\n\nexport const Columns: React.FC<{ children?: React.ReactNode }> = () => {\n return null;\n};\n\nexport type RowProps = GridTrack;\nexport const Row: React.FC<RowProps> = () => {\n return null;\n};\n\nexport type ColumnProps = GridTrack;\nexport const Col: React.FC<ColumnProps> = () => {\n return null;\n};\n\nexport type AreasProps = {\n matrix: string[][];\n};\nexport const Areas: React.FC<AreasProps> = () => {\n return null;\n};\n\ntype CollectedConfig = {\n gap?: string;\n style?: React.CSSProperties;\n rows?: GridTrack[];\n columns?: GridTrack[];\n areas?: string[][];\n};\n\nconst collectTracks = <P extends GridTrack>(children: React.ReactNode, marker: React.FC<P>): GridTrack[] => {\n const result: GridTrack[] = [];\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n if (isElementOf(node, marker)) {\n const props = node.props as P;\n if (!props.size) {\n throw new Error(\"Row/Col requires 'size' property.\");\n }\n result.push({\n size: props.size,\n resizable: props.resizable,\n minSize: props.minSize,\n maxSize: props.maxSize,\n });\n return;\n }\n if (React.isValidElement(node)) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n }\n };\n visit(children);\n return result;\n};\n\nconst collectConfigBlock = (children: React.ReactNode): CollectedConfig | null => {\n const node = findFirst(children, Config);\n if (!node) {\n return null;\n }\n const props = node.props as ConfigProps;\n const rows = collectTracks(node.props.children, Row);\n const columns = collectTracks(node.props.children, Col);\n const areasNode = findFirst(node.props.children, Areas);\n const areas = areasNode ? (areasNode.props as AreasProps).matrix : undefined;\n return {\n gap: props.gap,\n style: props.style,\n rows,\n columns,\n areas,\n };\n};\n\nconst findFirst = <P,>(children: React.ReactNode, marker: React.FC<P>): React.ReactElement<P> | null => {\n const visit = (node: React.ReactNode): React.ReactElement<P> | null => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return null;\n }\n if (Array.isArray(node)) {\n for (const item of node) {\n const found = visit(item);\n if (found) {\n return found;\n }\n }\n return null;\n }\n if (isElementOf(node, marker)) {\n return node as React.ReactElement<P>;\n }\n if (React.isValidElement(node)) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n return visit(el.props.children);\n }\n return null;\n };\n return visit(children);\n};\n\ntype CollectedPivotItem = {\n id: string;\n label?: string;\n content: React.ReactNode;\n disabled?: boolean;\n};\n\nconst collectPivotItems = (children: React.ReactNode): CollectedPivotItem[] => {\n const items: CollectedPivotItem[] = [];\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n if (isElementOf(node, PivotItem)) {\n const props = node.props as PivotItemDeclProps;\n if (!props.id) {\n throw new Error(\"<PivotItem> requires an 'id' prop.\");\n }\n items.push({\n id: props.id,\n label: props.label,\n content: props.children ?? null,\n disabled: props.disabled,\n });\n return;\n }\n if (React.isValidElement(node)) {\n if (node.type === React.Fragment) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n }\n }\n };\n visit(children);\n return items;\n};\n\nexport const buildConfigFromChildren = (children: React.ReactNode): PanelLayoutConfig | null => {\n const collected = collectConfigBlock(children);\n if (!collected) {\n return null;\n }\n if (!collected.rows || collected.rows.length === 0) {\n throw new Error(\"Config must include at least one <Row size=...> inside <Config>.\");\n }\n if (!collected.columns || collected.columns.length === 0) {\n throw new Error(\"Config must include at least one <Col size=...> inside <Config>.\");\n }\n if (!collected.areas || collected.areas.length === 0) {\n throw new Error(\"Config must include <Areas matrix={...}> inside <Config>.\");\n }\n\n const rowCount = collected.areas.length;\n const colCount = collected.areas[0]?.length ?? 0;\n if (rowCount !== collected.rows.length) {\n throw new Error(`Areas row count (${rowCount}) must match Rows count (${collected.rows.length}).`);\n }\n if (colCount !== collected.columns.length) {\n throw new Error(`Areas column count (${colCount}) must match Columns count (${collected.columns.length}).`);\n }\n\n return {\n areas: collected.areas,\n rows: collected.rows,\n columns: collected.columns,\n gap: collected.gap,\n style: collected.style,\n } satisfies PanelLayoutConfig;\n};\n"],"names":["toLayer","route","inferredMode","resolveRoutePositionMode","flattenRoutes","routes","result","walk","node","child","r","validateUniqueIds","seen","buildLayersFromRoutes","flat","Panel","PivotItem","isElementOf","element","component","React","buildRoutesFromChildren","children","visit","props","pivotItems","collectPivotItems","PanelLayout","config","style","layers","derivedConfig","built","buildConfigFromChildren","jsx","GridLayout","Config","Rows","Columns","Row","Col","Areas","collectTracks","marker","collectConfigBlock","findFirst","rows","columns","areasNode","areas","item","found","items","collected","rowCount","colCount"],"mappings":"ycA+DMA,EAAWC,GAAuC,CACtD,MAAMC,EAAkCC,EAAyBF,CAAK,EAEtE,GAAIC,IAAiB,QACf,CAACD,EAAM,KACT,MAAM,IAAI,MAAM,cAAcA,EAAM,EAAE,0CAA0C,EAIpF,MAAO,CACL,GAAIA,EAAM,GACV,UAAWA,EAAM,QACjB,QAASA,EAAM,QACf,SAAUA,EAAM,KAChB,aAAcC,EACd,SAAUD,EAAM,SAChB,OAAQA,EAAM,OACd,MAAOA,EAAM,MACb,OAAQA,EAAM,OACd,cAAeA,EAAM,cACrB,MAAOA,EAAM,MACb,OAAQA,EAAM,OACd,SAAUA,EAAM,SAChB,MAAOA,EAAM,MACb,cAAeA,EAAM,aAAA,CAEzB,EAEME,EAA4BF,GAC5BA,EAAM,aACDA,EAAM,aAEXA,EAAM,SAED,YAELA,EAAM,OACD,QAKLG,EAAiBC,GAAuC,CAC5D,MAAMC,EAAuB,CAAA,EACvBC,EAAQC,GAA2B,CACvCF,EAAO,KAAK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AAA,CAErB"}
|
package/dist/config.js
CHANGED
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../src/config/panelRouter.tsx","../src/config/PanelContentDeclaration.tsx"],"sourcesContent":["/**\n * @file Router-like builder for GridLayout\n *\n * Provides a React Router–style configuration API to declare panel layers.\n * Converts route objects to the existing GridLayout props without magic.\n */\nimport * as React from \"react\";\nimport type {\n DrawerBehavior,\n FloatingWindowConfig,\n LayerDefinition,\n LayerPositionMode,\n PanelLayoutConfig,\n PanelLayoutProps,\n PivotBehavior,\n WindowPosition,\n} from \"../types\";\nimport { GridLayout } from \"../components/grid/GridLayout\";\n\nexport type PanelRoute = {\n /** Unique id for the layer. Required. */\n id: string;\n /** React node to render for this layer. Required. */\n element: React.ReactNode;\n /** Visibility flag. Defaults to visible. */\n visible?: boolean;\n\n /**\n * Grid placement key. When using `positionMode: 'grid'` (default), this must be provided.\n * Using `area` mirrors React Router's route path intent but for grid cells.\n */\n area?: string;\n\n /** Explicit positioning mode; defaults to 'grid' unless floating/drawer implies otherwise. */\n positionMode?: LayerPositionMode;\n /** Offsets when using non-grid modes. */\n position?: WindowPosition;\n /** Optional stacking order. */\n zIndex?: number;\n /** Optional dimensions; required for resizable/draggable floating layers. */\n width?: number | string;\n height?: number | string;\n /** Pointer events control. */\n pointerEvents?: boolean | \"auto\" | \"none\";\n /** Optional style overrides. */\n style?: React.CSSProperties;\n /** Optional backdrop style (drawer). */\n backdropStyle?: React.CSSProperties;\n\n /** Drawer behavior for mobile-friendly panels. */\n drawer?: DrawerBehavior;\n /** Floating window configuration. */\n floating?: FloatingWindowConfig;\n /** Pivot behavior for content switching. */\n pivot?: PivotBehavior;\n\n /**\n * Optional child declarations; purely a grouping convenience.\n * Children are flattened; no implicit inheritance.\n */\n children?: PanelRoute[];\n};\n\nconst toLayer = (route: PanelRoute): LayerDefinition => {\n const inferredMode: LayerPositionMode = resolveRoutePositionMode(route);\n\n if (inferredMode === \"grid\") {\n if (!route.area) {\n throw new Error(`PanelRoute ${route.id} must specify 'area' for grid placement.`);\n }\n }\n\n return {\n id: route.id,\n component: route.element,\n visible: route.visible,\n gridArea: route.area,\n positionMode: inferredMode,\n position: route.position,\n zIndex: route.zIndex,\n width: route.width,\n height: route.height,\n pointerEvents: route.pointerEvents,\n style: route.style,\n drawer: route.drawer,\n floating: route.floating,\n pivot: route.pivot,\n backdropStyle: route.backdropStyle,\n } satisfies LayerDefinition;\n};\n\nconst resolveRoutePositionMode = (route: PanelRoute): LayerPositionMode => {\n if (route.positionMode) {\n return route.positionMode;\n }\n if (route.floating) {\n // Embedded => absolute, Popup => relative (handled by renderer); keep explicitness here.\n return \"absolute\";\n }\n if (route.drawer) {\n return \"grid\";\n }\n return \"grid\";\n};\n\nconst flattenRoutes = (routes: PanelRoute[]): PanelRoute[] => {\n const result: PanelRoute[] = [];\n const walk = (node: PanelRoute): void => {\n result.push(node);\n if (node.children) {\n node.children.forEach((child) => walk(child));\n }\n };\n routes.forEach((r) => walk(r));\n return result;\n};\n\nconst validateUniqueIds = (routes: PanelRoute[]): void => {\n const seen = new Set<string>();\n routes.forEach((r) => {\n if (seen.has(r.id)) {\n throw new Error(`Duplicate PanelRoute id detected: ${r.id}`);\n }\n seen.add(r.id);\n });\n};\n\nexport const buildLayersFromRoutes = (routes: PanelRoute[]): LayerDefinition[] => {\n const flat = flattenRoutes(routes);\n validateUniqueIds(flat);\n return flat.map((r) => toLayer(r));\n};\n\nexport const createPanelLayoutFromRoutes = (input: {\n config: PanelLayoutConfig;\n routes: PanelRoute[];\n style?: React.CSSProperties;\n}): PanelLayoutProps => {\n const layers = buildLayersFromRoutes(input.routes);\n return {\n config: input.config,\n layers,\n };\n};\n\nexport type PanelLayoutRouterProps = {\n config: PanelLayoutConfig;\n routes: PanelRoute[];\n style?: React.CSSProperties;\n};\n\nexport const PanelLayoutRouter: React.FC<PanelLayoutRouterProps> = ({ config, routes, style }) => {\n const layers = React.useMemo(() => buildLayersFromRoutes(routes), [routes]);\n return <GridLayout config={config} layers={layers} style={style} />;\n};\n","/**\n * @file PanelContentDeclaration (JSX DSL for content configuration ONLY)\n *\n * IMPORTANT: This file declares a JSX DSL to configure panel \"content\" and layout\n * tracks. It does NOT implement grid rendering, resizing, dragging, or drawers.\n * Those behaviors live in the existing layout/rendering modules. Keep this file\n * limited to declaration and conversion into GridLayout props.\n *\n * Usage (content declaration):\n * <PanelLayout>\n * <Config>\n * <Rows>...</Rows>\n * <Columns>...</Columns>\n * <Areas matrix={...}/>\n * </Config>\n * <Panel type=\"grid\" id=\"main\" area=\"main\">...</Panel>\n * <Panel type=\"floating\" id=\"preview\" position={{ left: 0, top: 0 }} width={300} height={200} />\n * <Panel type=\"drawer\" id=\"nav\" drawer={{ defaultOpen: true }} position={{ left: 0 }} />\n * </PanelLayout>\n */\nimport * as React from \"react\";\nimport { GridLayout } from \"../components/grid/GridLayout\";\nimport type { DrawerBehavior, GridTrack, PanelLayoutConfig, WindowPosition } from \"../types\";\nimport type { PanelRoute } from \"./panelRouter\";\nimport { buildLayersFromRoutes } from \"./panelRouter\";\n\nexport type PanelRootProps = {\n config?: PanelLayoutConfig;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n// Unified child declaration: <Panel type=\"grid\" .../> or <Panel type=\"floating\" .../>...\ntype PanelCommonProps = {\n id: string;\n visible?: boolean;\n zIndex?: number;\n width?: number | string;\n height?: number | string;\n pointerEvents?: boolean | \"auto\" | \"none\";\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nexport type PanelProps =\n | (PanelCommonProps & { type: \"grid\"; area: string })\n | (PanelCommonProps & {\n type: \"floating\";\n position: WindowPosition;\n width: number | string;\n height: number | string;\n draggable?: boolean;\n resizable?: boolean;\n })\n | (PanelCommonProps & {\n type: \"drawer\";\n drawer: DrawerBehavior;\n position?: WindowPosition;\n backdropStyle?: React.CSSProperties;\n })\n | (Omit<PanelCommonProps, \"children\"> & {\n type: \"pivot\";\n area: string;\n /** Currently active item ID (controlled mode) */\n activeId?: string;\n /** Default active item ID (uncontrolled mode) */\n defaultActiveId?: string;\n /** Callback when active item changes */\n onActiveChange?: (id: string) => void;\n children?: React.ReactNode;\n });\n\nexport const Panel: React.FC<PanelProps> = () => null;\n\n/**\n * PivotItem declaration for use inside <Panel type=\"pivot\">\n */\nexport type PivotItemDeclProps = {\n id: string;\n label?: string;\n disabled?: boolean;\n children?: React.ReactNode;\n};\n\nexport const PivotItem: React.FC<PivotItemDeclProps> = () => null;\n\nconst isElementOf = <P,>(element: unknown, component: React.FC<P>): element is React.ReactElement<P> => {\n if (!React.isValidElement<P>(element)) {\n return false;\n }\n return element.type === component;\n};\n\nexport const buildRoutesFromChildren = (children: React.ReactNode): PanelRoute[] => {\n const routes: PanelRoute[] = [];\n\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n // Unified <Panel type=\"...\" />\n if (isElementOf(node, Panel)) {\n const props = node.props as PanelProps;\n if (!props.id) {\n throw new Error(\"<Panel> requires an 'id' prop.\");\n }\n if (props.type === \"grid\") {\n if (!props.area) {\n throw new Error(`<Panel id=\"${props.id}\"> requires an explicit 'area' prop when type=\"grid\".`);\n }\n routes.push({\n id: props.id,\n area: props.area,\n element: props.children ?? null,\n visible: props.visible,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n });\n return;\n }\n if (props.type === \"floating\") {\n if (!props.position) {\n throw new Error(`<Panel id=\"${props.id}\"> requires a 'position' prop when type=\"floating\".`);\n }\n if (props.width === undefined || props.height === undefined) {\n throw new Error(`<Panel id=\"${props.id}\"> requires 'width' and 'height' when type=\"floating\".`);\n }\n routes.push({\n id: props.id,\n element: props.children ?? null,\n visible: props.visible ?? true,\n positionMode: \"absolute\",\n position: props.position,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n floating: { mode: \"embedded\", draggable: props.draggable, resizable: props.resizable },\n });\n return;\n }\n if (props.type === \"drawer\") {\n routes.push({\n id: props.id,\n element: props.children ?? null,\n visible: props.visible ?? true,\n positionMode: \"relative\",\n position: props.position,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n drawer: props.drawer,\n backdropStyle: props.backdropStyle,\n });\n return;\n }\n if (props.type === \"pivot\") {\n if (!props.area) {\n throw new Error(`<Panel id=\"${props.id}\"> requires an explicit 'area' prop when type=\"pivot\".`);\n }\n const pivotItems = collectPivotItems(props.children);\n if (pivotItems.length === 0) {\n throw new Error(`<Panel id=\"${props.id}\"> requires at least one <PivotItem> child when type=\"pivot\".`);\n }\n routes.push({\n id: props.id,\n area: props.area,\n element: null,\n visible: props.visible,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n pivot: {\n items: pivotItems,\n activeId: props.activeId,\n defaultActiveId: props.defaultActiveId,\n onActiveChange: props.onActiveChange,\n },\n });\n return;\n }\n // unknown type -> error for explicitness\n throw new Error(\"<Panel> has unsupported type.\");\n }\n\n if (React.isValidElement(node)) {\n if (node.type === React.Fragment) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n return;\n }\n // Unknown element: ignore quietly to allow comments/wrappers.\n return;\n }\n // Primitive nodes (string/number) are ignored.\n };\n\n visit(children);\n return routes;\n};\n\n// Root container renamed to PanelLayout to avoid name collision with child <Panel/>\nexport const PanelLayout: React.FC<PanelRootProps> = ({ config, style, children }) => {\n const routes = React.useMemo(() => buildRoutesFromChildren(children), [children]);\n const layers = React.useMemo(() => buildLayersFromRoutes(routes), [routes]);\n const derivedConfig = React.useMemo(() => {\n if (config) {\n return config;\n }\n const built = buildConfigFromChildren(children);\n if (!built) {\n throw new Error(\"Panel requires either 'config' prop or a JSX config (<Config><Rows/><Columns/><Areas/></Config>). \");\n }\n return built;\n }, [children, config]);\n return <GridLayout config={derivedConfig} layers={layers} style={style} />;\n};\n\n// =============================\n// JSX Config Declarations\n// =============================\n\nexport type ConfigProps = {\n gap?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nexport const Config: React.FC<ConfigProps> = () => {\n return null;\n};\n\nexport const Rows: React.FC<{ children?: React.ReactNode }> = () => {\n return null;\n};\n\nexport const Columns: React.FC<{ children?: React.ReactNode }> = () => {\n return null;\n};\n\nexport type RowProps = GridTrack;\nexport const Row: React.FC<RowProps> = () => {\n return null;\n};\n\nexport type ColumnProps = GridTrack;\nexport const Col: React.FC<ColumnProps> = () => {\n return null;\n};\n\nexport type AreasProps = {\n matrix: string[][];\n};\nexport const Areas: React.FC<AreasProps> = () => {\n return null;\n};\n\ntype CollectedConfig = {\n gap?: string;\n style?: React.CSSProperties;\n rows?: GridTrack[];\n columns?: GridTrack[];\n areas?: string[][];\n};\n\nconst collectTracks = <P extends GridTrack>(children: React.ReactNode, marker: React.FC<P>): GridTrack[] => {\n const result: GridTrack[] = [];\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n if (isElementOf(node, marker)) {\n const props = node.props as P;\n if (!props.size) {\n throw new Error(\"Row/Col requires 'size' property.\");\n }\n result.push({\n size: props.size,\n resizable: props.resizable,\n minSize: props.minSize,\n maxSize: props.maxSize,\n });\n return;\n }\n if (React.isValidElement(node)) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n }\n };\n visit(children);\n return result;\n};\n\nconst collectConfigBlock = (children: React.ReactNode): CollectedConfig | null => {\n const node = findFirst(children, Config);\n if (!node) {\n return null;\n }\n const props = node.props as ConfigProps;\n const rows = collectTracks(node.props.children, Row);\n const columns = collectTracks(node.props.children, Col);\n const areasNode = findFirst(node.props.children, Areas);\n const areas = areasNode ? (areasNode.props as AreasProps).matrix : undefined;\n return {\n gap: props.gap,\n style: props.style,\n rows,\n columns,\n areas,\n };\n};\n\nconst findFirst = <P,>(children: React.ReactNode, marker: React.FC<P>): React.ReactElement<P> | null => {\n const visit = (node: React.ReactNode): React.ReactElement<P> | null => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return null;\n }\n if (Array.isArray(node)) {\n for (const item of node) {\n const found = visit(item);\n if (found) {\n return found;\n }\n }\n return null;\n }\n if (isElementOf(node, marker)) {\n return node as React.ReactElement<P>;\n }\n if (React.isValidElement(node)) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n return visit(el.props.children);\n }\n return null;\n };\n return visit(children);\n};\n\ntype CollectedPivotItem = {\n id: string;\n label?: string;\n content: React.ReactNode;\n disabled?: boolean;\n};\n\nconst collectPivotItems = (children: React.ReactNode): CollectedPivotItem[] => {\n const items: CollectedPivotItem[] = [];\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n if (isElementOf(node, PivotItem)) {\n const props = node.props as PivotItemDeclProps;\n if (!props.id) {\n throw new Error(\"<PivotItem> requires an 'id' prop.\");\n }\n items.push({\n id: props.id,\n label: props.label,\n content: props.children ?? null,\n disabled: props.disabled,\n });\n return;\n }\n if (React.isValidElement(node)) {\n if (node.type === React.Fragment) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n }\n }\n };\n visit(children);\n return items;\n};\n\nexport const buildConfigFromChildren = (children: React.ReactNode): PanelLayoutConfig | null => {\n const collected = collectConfigBlock(children);\n if (!collected) {\n return null;\n }\n if (!collected.rows || collected.rows.length === 0) {\n throw new Error(\"Config must include at least one <Row size=...> inside <Config>.\");\n }\n if (!collected.columns || collected.columns.length === 0) {\n throw new Error(\"Config must include at least one <Col size=...> inside <Config>.\");\n }\n if (!collected.areas || collected.areas.length === 0) {\n throw new Error(\"Config must include <Areas matrix={...}> inside <Config>.\");\n }\n\n const rowCount = collected.areas.length;\n const colCount = collected.areas[0]?.length ?? 0;\n if (rowCount !== collected.rows.length) {\n throw new Error(`Areas row count (${rowCount}) must match Rows count (${collected.rows.length}).`);\n }\n if (colCount !== collected.columns.length) {\n throw new Error(`Areas column count (${colCount}) must match Columns count (${collected.columns.length}).`);\n }\n\n return {\n areas: collected.areas,\n rows: collected.rows,\n columns: collected.columns,\n gap: collected.gap,\n style: collected.style,\n } satisfies PanelLayoutConfig;\n};\n"],"names":["toLayer","route","inferredMode","resolveRoutePositionMode","flattenRoutes","routes","result","walk","node","child","r","validateUniqueIds","seen","buildLayersFromRoutes","flat","Panel","PivotItem","isElementOf","element","component","React","buildRoutesFromChildren","children","visit","props","pivotItems","collectPivotItems","PanelLayout","config","style","layers","derivedConfig","built","buildConfigFromChildren","jsx","GridLayout","Config","Rows","Columns","Row","Col","Areas","collectTracks","marker","collectConfigBlock","findFirst","rows","columns","areasNode","areas","item","found","items","collected","rowCount","colCount"],"mappings":";;;AA+DA,MAAMA,IAAU,CAACC,MAAuC;AACtD,QAAMC,IAAkCC,EAAyBF,CAAK;AAEtE,MAAIC,MAAiB,UACf,CAACD,EAAM;AACT,UAAM,IAAI,MAAM,cAAcA,EAAM,EAAE,0CAA0C;AAIpF,SAAO;AAAA,IACL,IAAIA,EAAM;AAAA,IACV,WAAWA,EAAM;AAAA,IACjB,SAASA,EAAM;AAAA,IACf,UAAUA,EAAM;AAAA,IAChB,cAAcC;AAAA,IACd,UAAUD,EAAM;AAAA,IAChB,QAAQA,EAAM;AAAA,IACd,OAAOA,EAAM;AAAA,IACb,QAAQA,EAAM;AAAA,IACd,eAAeA,EAAM;AAAA,IACrB,OAAOA,EAAM;AAAA,IACb,QAAQA,EAAM;AAAA,IACd,UAAUA,EAAM;AAAA,IAChB,OAAOA,EAAM;AAAA,IACb,eAAeA,EAAM;AAAA,EAAA;AAEzB,GAEME,IAA2B,CAACF,MAC5BA,EAAM,eACDA,EAAM,eAEX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AAeZ,CAAI,KACvBA,EAAK,SAASY,EAAM,YAEtBG,EADWf,EACF,MAAM,QAAQ;AAAA;AAAA,EAG7B;AACA,SAAAe,EAAMD,CAAQ,GACP8B;AACT,GAEanB,IAA0B,CAACX,MAAwD;AAC9F,QAAM+B,IAAYT,EAAmBtB,CAAQ;AAC7C,MAAI,CAAC+B;AACH,WAAO;AAET,MAAI,CAACA,EAAU,QAAQA,EAAU,KAAK,WAAW;AAC/C,UAAM,IAAI,MAAM,kEAAkE;AAEpF,MAAI,CAACA,EAAU,WAAWA,EAAU,QAAQ,WAAW;AACrD,UAAM,IAAI,MAAM,kEAAkE;AAEpF,MAAI,CAACA,EAAU,SAASA,EAAU,MAAM,WAAW;AACjD,UAAM,IAAI,MAAM,2DAA2D;AAG7E,QAAMC,IAAWD,EAAU,MAAM,QAC3BE,IAAWF,EAAU,MAAM,CAAC,GAAG,UAAU;AAC/C,MAAIC,MAAaD,EAAU,KAAK;AAC9B,UAAM,IAAI,MAAM,oBAAoBC,CAAQ,4BAA4BD,EAAU,KAAK,MAAM,IAAI;AAEnG,MAAIE,MAAaF,EAAU,QAAQ;AACjC,UAAM,IAAI,MAAM,uBAAuBE,CAAQ,+BAA+BF,EAAU,QAAQ,MAAM,IAAI;AAG5G,SAAO;AAAA,IACL,OAAOA,EAAU;AAAA,IACjB,MAAMA,EAAU;AAAA,IAChB,SAASA,EAAU;AAAA,IACnB,KAAKA,EAAU;AAAA,IACf,OAAOA,EAAU;AAAA,EAAA;AAErB;"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../src/config/panelRouter.tsx","../src/config/PanelContentDeclaration.tsx"],"sourcesContent":["/**\n * @file Router-like builder for GridLayout\n *\n * Provides a React Router–style configuration API to declare panel layers.\n * Converts route objects to the existing GridLayout props without magic.\n */\nimport * as React from \"react\";\nimport type {\n DrawerBehavior,\n FloatingBehavior,\n LayerDefinition,\n LayerPositionMode,\n PanelLayoutConfig,\n PanelLayoutProps,\n PivotBehavior,\n WindowPosition,\n} from \"../types\";\nimport { GridLayout } from \"../components/grid/GridLayout\";\n\nexport type PanelRoute = {\n /** Unique id for the layer. Required. */\n id: string;\n /** React node to render for this layer. Required. */\n element: React.ReactNode;\n /** Visibility flag. Defaults to visible. */\n visible?: boolean;\n\n /**\n * Grid placement key. When using `positionMode: 'grid'` (default), this must be provided.\n * Using `area` mirrors React Router's route path intent but for grid cells.\n */\n area?: string;\n\n /** Explicit positioning mode; defaults to 'grid' unless floating/drawer implies otherwise. */\n positionMode?: LayerPositionMode;\n /** Offsets when using non-grid modes. */\n position?: WindowPosition;\n /** Optional stacking order. */\n zIndex?: number;\n /** Optional dimensions; required for resizable/draggable floating layers. */\n width?: number | string;\n height?: number | string;\n /** Pointer events control. */\n pointerEvents?: boolean | \"auto\" | \"none\";\n /** Optional style overrides. */\n style?: React.CSSProperties;\n /** Optional backdrop style (drawer). */\n backdropStyle?: React.CSSProperties;\n\n /** Drawer behavior for mobile-friendly panels. */\n drawer?: DrawerBehavior;\n /** Floating window configuration. */\n floating?: FloatingBehavior;\n /** Pivot behavior for content switching. */\n pivot?: PivotBehavior;\n\n /**\n * Optional child declarations; purely a grouping convenience.\n * Children are flattened; no implicit inheritance.\n */\n children?: PanelRoute[];\n};\n\nconst toLayer = (route: PanelRoute): LayerDefinition => {\n const inferredMode: LayerPositionMode = resolveRoutePositionMode(route);\n\n if (inferredMode === \"grid\") {\n if (!route.area) {\n throw new Error(`PanelRoute ${route.id} must specify 'area' for grid placement.`);\n }\n }\n\n return {\n id: route.id,\n component: route.element,\n visible: route.visible,\n gridArea: route.area,\n positionMode: inferredMode,\n position: route.position,\n zIndex: route.zIndex,\n width: route.width,\n height: route.height,\n pointerEvents: route.pointerEvents,\n style: route.style,\n drawer: route.drawer,\n floating: route.floating,\n pivot: route.pivot,\n backdropStyle: route.backdropStyle,\n } satisfies LayerDefinition;\n};\n\nconst resolveRoutePositionMode = (route: PanelRoute): LayerPositionMode => {\n if (route.positionMode) {\n return route.positionMode;\n }\n if (route.floating) {\n // Embedded => absolute, Popup => relative (handled by renderer); keep explicitness here.\n return \"absolute\";\n }\n if (route.drawer) {\n return \"grid\";\n }\n return \"grid\";\n};\n\nconst flattenRoutes = (routes: PanelRoute[]): PanelRoute[] => {\n const result: PanelRoute[] = [];\n const walk = (node: PanelRoute): void => {\n result.push(node);\n if (node.children) {\n node.children.forEach((child) => walk(child));\n }\n };\n routes.forEach((r) => walk(r));\n return result;\n};\n\nconst validateUniqueIds = (routes: PanelRoute[]): void => {\n const seen = new Set<string>();\n routes.forEach((r) => {\n if (seen.has(r.id)) {\n throw new Error(`Duplicate PanelRoute id detected: ${r.id}`);\n }\n seen.add(r.id);\n });\n};\n\nexport const buildLayersFromRoutes = (routes: PanelRoute[]): LayerDefinition[] => {\n const flat = flattenRoutes(routes);\n validateUniqueIds(flat);\n return flat.map((r) => toLayer(r));\n};\n\nexport const createPanelLayoutFromRoutes = (input: {\n config: PanelLayoutConfig;\n routes: PanelRoute[];\n style?: React.CSSProperties;\n}): PanelLayoutProps => {\n const layers = buildLayersFromRoutes(input.routes);\n return {\n config: input.config,\n layers,\n };\n};\n\nexport type PanelLayoutRouterProps = {\n config: PanelLayoutConfig;\n routes: PanelRoute[];\n style?: React.CSSProperties;\n};\n\nexport const PanelLayoutRouter: React.FC<PanelLayoutRouterProps> = ({ config, routes, style }) => {\n const layers = React.useMemo(() => buildLayersFromRoutes(routes), [routes]);\n return <GridLayout config={config} layers={layers} style={style} />;\n};\n","/**\n * @file PanelContentDeclaration (JSX DSL for content configuration ONLY)\n *\n * IMPORTANT: This file declares a JSX DSL to configure panel \"content\" and layout\n * tracks. It does NOT implement grid rendering, resizing, dragging, or drawers.\n * Those behaviors live in the existing layout/rendering modules. Keep this file\n * limited to declaration and conversion into GridLayout props.\n *\n * Usage (content declaration):\n * <PanelLayout>\n * <Config>\n * <Rows>...</Rows>\n * <Columns>...</Columns>\n * <Areas matrix={...}/>\n * </Config>\n * <Panel type=\"grid\" id=\"main\" area=\"main\">...</Panel>\n * <Panel type=\"floating\" id=\"preview\" position={{ left: 0, top: 0 }} width={300} height={200} />\n * <Panel type=\"drawer\" id=\"nav\" drawer={{ defaultOpen: true }} position={{ left: 0 }} />\n * </PanelLayout>\n */\nimport * as React from \"react\";\nimport { GridLayout } from \"../components/grid/GridLayout\";\nimport type { DrawerBehavior, GridTrack, PanelLayoutConfig, WindowPosition } from \"../types\";\nimport type { PanelRoute } from \"./panelRouter\";\nimport { buildLayersFromRoutes } from \"./panelRouter\";\n\nexport type PanelRootProps = {\n config?: PanelLayoutConfig;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n// Unified child declaration: <Panel type=\"grid\" .../> or <Panel type=\"floating\" .../>...\ntype PanelCommonProps = {\n id: string;\n visible?: boolean;\n zIndex?: number;\n width?: number | string;\n height?: number | string;\n pointerEvents?: boolean | \"auto\" | \"none\";\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nexport type PanelProps =\n | (PanelCommonProps & { type: \"grid\"; area: string })\n | (PanelCommonProps & {\n type: \"floating\";\n position: WindowPosition;\n width: number | string;\n height: number | string;\n draggable?: boolean;\n resizable?: boolean;\n })\n | (PanelCommonProps & {\n type: \"drawer\";\n drawer: DrawerBehavior;\n position?: WindowPosition;\n backdropStyle?: React.CSSProperties;\n })\n | (Omit<PanelCommonProps, \"children\"> & {\n type: \"pivot\";\n area: string;\n /** Currently active item ID (controlled mode) */\n activeId?: string;\n /** Default active item ID (uncontrolled mode) */\n defaultActiveId?: string;\n /** Callback when active item changes */\n onActiveChange?: (id: string) => void;\n children?: React.ReactNode;\n });\n\nexport const Panel: React.FC<PanelProps> = () => null;\n\n/**\n * PivotItem declaration for use inside <Panel type=\"pivot\">\n */\nexport type PivotItemDeclProps = {\n id: string;\n label?: string;\n disabled?: boolean;\n children?: React.ReactNode;\n};\n\nexport const PivotItem: React.FC<PivotItemDeclProps> = () => null;\n\nconst isElementOf = <P,>(element: unknown, component: React.FC<P>): element is React.ReactElement<P> => {\n if (!React.isValidElement<P>(element)) {\n return false;\n }\n return element.type === component;\n};\n\nexport const buildRoutesFromChildren = (children: React.ReactNode): PanelRoute[] => {\n const routes: PanelRoute[] = [];\n\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n // Unified <Panel type=\"...\" />\n if (isElementOf(node, Panel)) {\n const props = node.props as PanelProps;\n if (!props.id) {\n throw new Error(\"<Panel> requires an 'id' prop.\");\n }\n if (props.type === \"grid\") {\n if (!props.area) {\n throw new Error(`<Panel id=\"${props.id}\"> requires an explicit 'area' prop when type=\"grid\".`);\n }\n routes.push({\n id: props.id,\n area: props.area,\n element: props.children ?? null,\n visible: props.visible,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n });\n return;\n }\n if (props.type === \"floating\") {\n if (!props.position) {\n throw new Error(`<Panel id=\"${props.id}\"> requires a 'position' prop when type=\"floating\".`);\n }\n if (props.width === undefined || props.height === undefined) {\n throw new Error(`<Panel id=\"${props.id}\"> requires 'width' and 'height' when type=\"floating\".`);\n }\n routes.push({\n id: props.id,\n element: props.children ?? null,\n visible: props.visible ?? true,\n positionMode: \"absolute\",\n position: props.position,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n floating: { mode: \"embedded\", draggable: props.draggable, resizable: props.resizable },\n });\n return;\n }\n if (props.type === \"drawer\") {\n routes.push({\n id: props.id,\n element: props.children ?? null,\n visible: props.visible ?? true,\n positionMode: \"relative\",\n position: props.position,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n drawer: props.drawer,\n backdropStyle: props.backdropStyle,\n });\n return;\n }\n if (props.type === \"pivot\") {\n if (!props.area) {\n throw new Error(`<Panel id=\"${props.id}\"> requires an explicit 'area' prop when type=\"pivot\".`);\n }\n const pivotItems = collectPivotItems(props.children);\n if (pivotItems.length === 0) {\n throw new Error(`<Panel id=\"${props.id}\"> requires at least one <PivotItem> child when type=\"pivot\".`);\n }\n routes.push({\n id: props.id,\n area: props.area,\n element: null,\n visible: props.visible,\n zIndex: props.zIndex,\n width: props.width,\n height: props.height,\n pointerEvents: props.pointerEvents,\n style: props.style,\n pivot: {\n items: pivotItems,\n activeId: props.activeId,\n defaultActiveId: props.defaultActiveId,\n onActiveChange: props.onActiveChange,\n },\n });\n return;\n }\n // unknown type -> error for explicitness\n throw new Error(\"<Panel> has unsupported type.\");\n }\n\n if (React.isValidElement(node)) {\n if (node.type === React.Fragment) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n return;\n }\n // Unknown element: ignore quietly to allow comments/wrappers.\n return;\n }\n // Primitive nodes (string/number) are ignored.\n };\n\n visit(children);\n return routes;\n};\n\n// Root container renamed to PanelLayout to avoid name collision with child <Panel/>\nexport const PanelLayout: React.FC<PanelRootProps> = ({ config, style, children }) => {\n const routes = React.useMemo(() => buildRoutesFromChildren(children), [children]);\n const layers = React.useMemo(() => buildLayersFromRoutes(routes), [routes]);\n const derivedConfig = React.useMemo(() => {\n if (config) {\n return config;\n }\n const built = buildConfigFromChildren(children);\n if (!built) {\n throw new Error(\"Panel requires either 'config' prop or a JSX config (<Config><Rows/><Columns/><Areas/></Config>). \");\n }\n return built;\n }, [children, config]);\n return <GridLayout config={derivedConfig} layers={layers} style={style} />;\n};\n\n// =============================\n// JSX Config Declarations\n// =============================\n\nexport type ConfigProps = {\n gap?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nexport const Config: React.FC<ConfigProps> = () => {\n return null;\n};\n\nexport const Rows: React.FC<{ children?: React.ReactNode }> = () => {\n return null;\n};\n\nexport const Columns: React.FC<{ children?: React.ReactNode }> = () => {\n return null;\n};\n\nexport type RowProps = GridTrack;\nexport const Row: React.FC<RowProps> = () => {\n return null;\n};\n\nexport type ColumnProps = GridTrack;\nexport const Col: React.FC<ColumnProps> = () => {\n return null;\n};\n\nexport type AreasProps = {\n matrix: string[][];\n};\nexport const Areas: React.FC<AreasProps> = () => {\n return null;\n};\n\ntype CollectedConfig = {\n gap?: string;\n style?: React.CSSProperties;\n rows?: GridTrack[];\n columns?: GridTrack[];\n areas?: string[][];\n};\n\nconst collectTracks = <P extends GridTrack>(children: React.ReactNode, marker: React.FC<P>): GridTrack[] => {\n const result: GridTrack[] = [];\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n if (isElementOf(node, marker)) {\n const props = node.props as P;\n if (!props.size) {\n throw new Error(\"Row/Col requires 'size' property.\");\n }\n result.push({\n size: props.size,\n resizable: props.resizable,\n minSize: props.minSize,\n maxSize: props.maxSize,\n });\n return;\n }\n if (React.isValidElement(node)) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n }\n };\n visit(children);\n return result;\n};\n\nconst collectConfigBlock = (children: React.ReactNode): CollectedConfig | null => {\n const node = findFirst(children, Config);\n if (!node) {\n return null;\n }\n const props = node.props as ConfigProps;\n const rows = collectTracks(node.props.children, Row);\n const columns = collectTracks(node.props.children, Col);\n const areasNode = findFirst(node.props.children, Areas);\n const areas = areasNode ? (areasNode.props as AreasProps).matrix : undefined;\n return {\n gap: props.gap,\n style: props.style,\n rows,\n columns,\n areas,\n };\n};\n\nconst findFirst = <P,>(children: React.ReactNode, marker: React.FC<P>): React.ReactElement<P> | null => {\n const visit = (node: React.ReactNode): React.ReactElement<P> | null => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return null;\n }\n if (Array.isArray(node)) {\n for (const item of node) {\n const found = visit(item);\n if (found) {\n return found;\n }\n }\n return null;\n }\n if (isElementOf(node, marker)) {\n return node as React.ReactElement<P>;\n }\n if (React.isValidElement(node)) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n return visit(el.props.children);\n }\n return null;\n };\n return visit(children);\n};\n\ntype CollectedPivotItem = {\n id: string;\n label?: string;\n content: React.ReactNode;\n disabled?: boolean;\n};\n\nconst collectPivotItems = (children: React.ReactNode): CollectedPivotItem[] => {\n const items: CollectedPivotItem[] = [];\n const visit = (node: React.ReactNode): void => {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return;\n }\n if (Array.isArray(node)) {\n node.forEach(visit);\n return;\n }\n if (isElementOf(node, PivotItem)) {\n const props = node.props as PivotItemDeclProps;\n if (!props.id) {\n throw new Error(\"<PivotItem> requires an 'id' prop.\");\n }\n items.push({\n id: props.id,\n label: props.label,\n content: props.children ?? null,\n disabled: props.disabled,\n });\n return;\n }\n if (React.isValidElement(node)) {\n if (node.type === React.Fragment) {\n const el = node as React.ReactElement<{ children?: React.ReactNode }>;\n visit(el.props.children);\n }\n }\n };\n visit(children);\n return items;\n};\n\nexport const buildConfigFromChildren = (children: React.ReactNode): PanelLayoutConfig | null => {\n const collected = collectConfigBlock(children);\n if (!collected) {\n return null;\n }\n if (!collected.rows || collected.rows.length === 0) {\n throw new Error(\"Config must include at least one <Row size=...> inside <Config>.\");\n }\n if (!collected.columns || collected.columns.length === 0) {\n throw new Error(\"Config must include at least one <Col size=...> inside <Config>.\");\n }\n if (!collected.areas || collected.areas.length === 0) {\n throw new Error(\"Config must include <Areas matrix={...}> inside <Config>.\");\n }\n\n const rowCount = collected.areas.length;\n const colCount = collected.areas[0]?.length ?? 0;\n if (rowCount !== collected.rows.length) {\n throw new Error(`Areas row count (${rowCount}) must match Rows count (${collected.rows.length}).`);\n }\n if (colCount !== collected.columns.length) {\n throw new Error(`Areas column count (${colCount}) must match Columns count (${collected.columns.length}).`);\n }\n\n return {\n areas: collected.areas,\n rows: collected.rows,\n columns: collected.columns,\n gap: collected.gap,\n style: collected.style,\n } satisfies PanelLayoutConfig;\n};\n"],"names":["toLayer","route","inferredMode","resolveRoutePositionMode","flattenRoutes","routes","result","walk","node","child","r","validateUniqueIds","seen","buildLayersFromRoutes","flat","Panel","PivotItem","isElementOf","element","component","React","buildRoutesFromChildren","children","visit","props","pivotItems","collectPivotItems","PanelLayout","config","style","layers","derivedConfig","built","buildConfigFromChildren","jsx","GridLayout","Config","Rows","Columns","Row","Col","Areas","collectTracks","marker","collectConfigBlock","findFirst","rows","columns","areasNode","areas","item","found","items","collected","rowCount","colCount"],"mappings":";;;AA+DA,MAAMA,IAAU,CAACC,MAAuC;AACtD,QAAMC,IAAkCC,EAAyBF,CAAK;AAEtE,MAAIC,MAAiB,UACf,CAACD,EAAM;AACT,UAAM,IAAI,MAAM,cAAcA,EAAM,EAAE,0CAA0C;AAIpF,SAAO;AAAA,IACL,IAAIA,EAAM;AAAA,IACV,WAAWA,EAAM;AAAA,IACjB,SAASA,EAAM;AAAA,IACf,UAAUA,EAAM;AAAA,IAChB,cAAcC;AAAA,IACd,UAAUD,EAAM;AAAA,IAChB,QAAQA,EAAM;AAAA,IACd,OAAOA,EAAM;AAAA,IACb,QAAQA,EAAM;AAAA,IACd,eAAeA,EAAM;AAAA,IACrB,OAAOA,EAAM;AAAA,IACb,QAAQA,EAAM;AAAA,IACd,UAAUA,EAAM;AAAA,IAChB,OAAOA,EAAM;AAAA,IACb,eAAeA,EAAM;AAAA,EAAA;AAEzB,GAEME,IAA2B,CAACF,MAC5BA,EAAM,eACDA,EAAM,eAEXA,EAAM,WAED,cAELA,EAAM,QACD,SAKLG,IAAgB,CAACC,MAAuC;AAC5D,QAAMC,IAAuB,CAAA,GACvBC,IAAO,CAACC,MAA2B;AACvC,IAAAF,EAAO,KAAKE,CAAI,GACZA,EAAK,YACPA,EAAK,SAAS,QAAQ,CAACC,MAAUF,EAAKE,CAAK,CAAC;AAAA,EAEhD;AACA,SAAAJ,EAAO,QAAQ,CAACK,MAAMH,EAAKG,CAAC,CAAC,GACtBJ;AACT,GAEMK,IAAoB,CAACN,MAA+B;AACxD,QAAMO,wBAAW,IAAA;AACjB,EAAAP,EAAO,QAA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AI,MAAM,kEAAkE;AAEpF,MAAI,CAACA,EAAU,SAASA,EAAU,MAAM,WAAW;AACjD,UAAM,IAAI,MAAM,2DAA2D;AAG7E,QAAMC,IAAWD,EAAU,MAAM,QAC3BE,IAAWF,EAAU,MAAM,CAAC,GAAG,UAAU;AAC/C,MAAIC,MAAaD,EAAU,KAAK;AAC9B,UAAM,IAAI,MAAM,oBAAoBC,CAAQ,4BAA4BD,EAAU,KAAK,MAAM,IAAI;AAEnG,MAAIE,MAAaF,EAAU,QAAQ;AACjC,UAAM,IAAI,MAAM,uBAAuBE,CAAQ,+BAA+BF,EAAU,QAAQ,MAAM,IAAI;AAG5G,SAAO;AAAA,IACL,OAAOA,EAAU;AAAA,IACjB,MAAMA,EAAU;AAAA,IAChB,SAASA,EAAU;AAAA,IACnB,KAAKA,EAAU;AAAA,IACf,OAAOA,EAAU;AAAA,EAAA;AAErB;"}
|
package/dist/floating.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./FloatingPanelFrame-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./FloatingPanelFrame-DrYwgI9f.cjs");exports.FloatingPanelContent=a.FloatingPanelContent;exports.FloatingPanelControls=a.FloatingPanelControls;exports.FloatingPanelFrame=a.FloatingPanelFrame;exports.FloatingPanelHeader=a.FloatingPanelHeader;exports.FloatingPanelMeta=a.FloatingPanelMeta;exports.FloatingPanelTitle=a.FloatingPanelTitle;
|
|
2
2
|
//# sourceMappingURL=floating.cjs.map
|
package/dist/floating.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("./GridLayout-qufTyOQM.cjs"),b=require("react/jsx-runtime"),Et=require("react"),P=require("./styles-DcG3aIFx.cjs"),tt=require("./usePivot-C8q0pMgW.cjs"),Rt=require("react-dom");function Ct(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const l=Ct(Et),Pt=t=>{const e=t==="drag"?P.COLOR_RESIZE_HANDLE_ACTIVE:t==="hover"?P.COLOR_RESIZE_HANDLE_HOVER:P.COLOR_RESIZE_HANDLE_IDLE;return{width:P.HORIZONTAL_DIVIDER_WIDTH,cursor:"col-resize",position:"relative",userSelect:"none",backgroundColor:e}},Dt=({onResize:t,component:e,element:r})=>{const{ref:n,isDragging:o,onPointerDown:s}=G.useResizeDrag({axis:"x",onResize:t}),[c,i]=l.useState(!1),a={ref:n,style:Pt(o?"drag":c?"hover":"idle"),role:"separator","aria-orientation":"vertical","data-dragging":o?"true":void 0,onPointerDown:s,onPointerEnter:()=>i(!0),onPointerLeave:()=>i(!1)};return r?l.cloneElement(r,a):e?b.jsx(e,{...a}):b.jsx("div",{...a})},jt=()=>{const{layerId:t}=G.useLayerInstance(),{getLayerHandleProps:e}=G.useGridLayoutContext();return l.useMemo(()=>e(t),[e,t])},ct=l.createContext(null),At=()=>{const t=l.useContext(ct);if(!t)throw new Error("useKeybindings must be used within KeybindingsProvider");return t},_t=t=>{const e=[];t.metaKey&&e.push("Mod"),t.ctrlKey&&e.push("Ctrl"),t.altKey&&e.push("Alt"),t.shiftKey&&e.push("Shift");const r=t.key.length===1?t.key.toUpperCase():t.key;return e.push(r),e.join("-")},kt=({children:t,configure:e})=>{const r=l.useRef({}),n=l.useCallback((c,i)=>{r.current={...r.current,[c]:i}},[]),o=l.useCallback(c=>{const i={...r.current};delete i[c],r.current=i},[]);l.useEffect(()=>{const c=i=>{const a=_t(i),u=r.current[a];u&&u(i)};return window.addEventListener("keydown",c),()=>{window.removeEventListener("keydown",c)}},[]);const s=l.useMemo(()=>({register:n,unregister:o}),[n,o]);return l.useEffect(()=>{e&&e(s)},[s,e]),b.jsx(ct.Provider,{value:s,children:t})},Mt=(t,e)=>{t.register("Mod-\\",r=>{r.preventDefault(),e.splitFocused("vertical")}),t.register("Mod-Shift-\\",r=>{r.preventDefault(),e.splitFocused("horizontal")});for(const r of[1,2,3,4,5,6,7,8,9])t.register(`Mod-${String(r)}`,n=>{n.preventDefault(),e.focusGroupIndex(r)});t.register("Alt-ArrowRight",r=>{r.preventDefault(),e.focusNextGroup()}),t.register("Alt-ArrowLeft",r=>{r.preventDefault(),e.focusPrevGroup()})},Ot=t=>t.type==="group",at=(t,e={x:0,y:0,w:100,h:100})=>{const r=new Map,n=(o,s)=>{if(Ot(o)){r.set(o.groupId,s);return}if(o.direction==="vertical"){const a=s.w*o.ratio,u=s.w-a;n(o.a,{x:s.x,y:s.y,w:a,h:s.h}),n(o.b,{x:s.x+a,y:s.y,w:u,h:s.h});return}const c=s.h*o.ratio,i=s.h-c;n(o.a,{x:s.x,y:s.y,w:s.w,h:c}),n(o.b,{x:s.x,y:s.y+c,w:s.w,h:i})};return n(t,e),r},Nt=(t,e)=>{const r=at(t.tree),n={areas:[["root"]],rows:[{size:"1fr"}],columns:[{size:"1fr"}],gap:"0px",style:{position:"relative"}},o=Array.from(r.entries()).map(([s,c])=>{const i={position:"absolute",left:`${c.x}%`,top:`${c.y}%`,width:`${c.w}%`,height:`${c.h}%`,overflow:"hidden",display:"flex",flexDirection:"column"};return{id:s,positionMode:"absolute",style:i,component:e(s)}});return{config:n,layers:o}},Lt=(t,e,r)=>{const n=at(t.tree),o=Array.from(new Set(Array.from(n.values()).flatMap(m=>[m.x,m.x+m.w]))).sort((m,x)=>m-x),s=Array.from(new Set(Array.from(n.values()).flatMap(m=>[m.y,m.y+m.h]))).sort((m,x)=>m-x),c=o.slice(1).map((m,x)=>`${m-o[x]}fr`),i=s.slice(1).map((m,x)=>`${m-s[x]}fr`),a=c.map(m=>({size:m,resizable:r})),u=i.map(m=>({size:m,resizable:r})),d=(m,x,I,y)=>{for(const[g,v]of n.entries())if(m>=v.x&&x<=v.x+v.w&&I>=v.y&&y<=v.y+v.h)return g;return"."},f=[];for(let m=0;m<s.length-1;m+=1){const x=[];for(let I=0;I<o.length-1;I+=1)x.push(d(o[I],o[I+1],s[m],s[m+1]));f.push(x)}const h={areas:f,rows:u,columns:a,gap:"0px"},w=Array.from(n.keys()).map(m=>({id:m,gridArea:m,component:e(m)}));return{config:h,layers:w}},ut=l.createContext(null),Bt=()=>{const t=l.useContext(ut);if(!t)throw new Error("usePanelRenderContext must be used within PanelRenderProvider");return t},Ht=({value:t,children:e})=>b.jsx(ut.Provider,{value:t,children:e}),lt=l.createContext(null),dt=()=>{const t=l.useContext(lt);if(!t)throw new Error("useDomRegistry must be used within DomRegistryProvider");return t},$t=({children:t})=>{const e=l.useRef(new Map),r=l.useCallback(a=>{const u=e.current.get(a);if(u)return u;const d={group:null,tabbar:null,content:null};return e.current.set(a,d),d},[]),n=l.useCallback((a,u)=>{const d=r(a);if(d.group=u,u===null){const f=e.current.get(a);(f?f.tabbar===null&&f.content===null:!1)&&e.current.delete(a)}},[r]),o=l.useCallback((a,u)=>{const d=r(a);if(d.tabbar=u,u===null){const f=e.current.get(a);(f?f.group===null&&f.content===null:!1)&&e.current.delete(a)}},[r]),s=l.useCallback((a,u)=>{const d=r(a);if(d.content=u,u===null){const f=e.current.get(a);(f?f.group===null&&f.tabbar===null:!1)&&e.current.delete(a)}},[r]),c=l.useCallback(()=>e.current,[]),i=l.useMemo(()=>({setGroupEl:n,setTabbarEl:o,setContentEl:s,getAll:c}),[n,o,s,c]);return b.jsx(lt.Provider,{value:i,children:t})},zt={display:"flex",flexDirection:"column",width:"100%",height:"100%"},Xt={flex:"1 1 auto",minWidth:0,minHeight:0,position:"relative",overflow:"hidden"};function Ft(t,e,r,n){return t?l.cloneElement(t,r,n):e?b.jsx(e,{...r,children:n}):b.jsx("div",{...r,children:n})}function Yt(t,e,r,n){return t?l.cloneElement(t,r,n):e?b.jsx(e,{...r,children:n}):b.jsx("div",{...r,children:n})}const qt=({group:t,tabbar:e,content:r,onContentPointerDown:n,groupRef:o,contentRef:s,component:c,element:i,contentComponent:a,contentElement:u})=>{const d={ref:o,style:zt,"data-group-id":t.id},h=Ft(u,a,{ref:s,style:Xt,"data-dnd-zone":"content",onPointerDown:n},r),w=b.jsxs(b.Fragment,{children:[e,h]});return Yt(i,c,d,w)},pt=l.memo(qt,(t,e)=>t.group.id!==e.group.id||t.group.activeTabId!==e.group.activeTabId||t.group.tabs.length!==e.group.tabs.length?!1:t.group.tabs===e.group.tabs);pt.displayName="PanelGroupView";const q=(t,e,r)=>{const n=t.left,o=t.top,s=t.width,c=t.height,i=e-n,a=r-o,u=s/3,d=c/3;return i>u&&i<s-u&&a>d&&a<c-d?"center":i<a&&i<s-i&&a<c-a?"left":s-i<a&&s-i<i&&a<c-a?"right":a<i&&a<c-a&&i<s-i?"top":"bottom"};function _(t,e){if(!e){const n=(()=>({type:t}));return Object.defineProperty(n,"type",{value:t,writable:!1,enumerable:!0}),n}const r=((...n)=>{const o=e(...n);return typeof o>"u"?{type:t}:{type:t,payload:o}});return Object.defineProperty(r,"type",{value:t,writable:!1,enumerable:!0}),r}const Vt=(t,e)=>{const r={};return Object.keys(t).forEach(n=>{const o=t[n];r[n]=((...s)=>{const c=o(...s);return e(c),c})}),r},ft=(t,e)=>{const r={};return Object.keys(e).forEach(n=>{const o=e[n];if(!o)return;const s=t[n];if(!s)throw new Error(`Missing action creator for key "${String(n)}"`);r[s.type]=o}),r},bt={phase:{kind:"idle"},suggest:null,pointer:null,tabbarHover:null,draggingTabElement:null},A={startContent:_("START_CONTENT",t=>t),startTab:_("START_TAB",t=>t),setSuggest:_("SET_SUGGEST",t=>t),setPointer:_("SET_POINTER",t=>t),setTabbarHover:_("SET_TABBAR_HOVER",t=>t),reset:_("RESET")},Kt=ft(A,{startContent:(t,e)=>({phase:{kind:"content",startX:e.payload.x,startY:e.payload.y,fromGroupId:e.payload.groupId,tabId:e.payload.tabId,cache:e.payload.cache},suggest:null,pointer:null,tabbarHover:null,draggingTabElement:null}),startTab:(t,e)=>({phase:{kind:"tab",startX:e.payload.x,startY:e.payload.y,fromGroupId:e.payload.groupId,tabId:e.payload.tabId,cache:e.payload.cache},suggest:null,pointer:null,tabbarHover:null,draggingTabElement:e.payload.element}),setSuggest:(t,e)=>({...t,suggest:e.payload}),setPointer:(t,e)=>({...t,pointer:e.payload}),setTabbarHover:(t,e)=>({...t,tabbarHover:e.payload}),reset:()=>bt}),Ut=(t,e)=>{const r=Kt[e.type];return r?r(t,e,void 0):t},gt=l.createContext(null),U=()=>{const t=l.useContext(gt);if(!t)throw new Error("usePanelInteractions must be used within InteractionsProvider");return t},Wt=({containerRef:t,dragThresholdPx:e,onCommitContentDrop:r,onCommitTabDrop:n,isContentZoneAllowed:o,children:s})=>{const[c,i]=l.useReducer(Ut,bt),a=dt(),u=l.useCallback(()=>{const I=Array.from(a.getAll().entries()),y=I.map(([p,T])=>({gid:p,el:T.content??T.group})).filter(p=>!!p.el).map(p=>({...p,rect:p.el.getBoundingClientRect()})),g=I.map(([p,T])=>({gid:p,el:T.tabbar})).filter(p=>!!p.el).map(p=>({...p,rect:p.el.getBoundingClientRect()})),v=I.map(([p,T])=>({gid:p,el:T.content??T.group})).filter(p=>!!p.el).map(p=>({...p,rect:p.el.getBoundingClientRect()}));return{groups:y,tabbars:g,contents:v}},[a]),d=G.useEffectEvent(I=>{if(!t.current)return;const g=I.clientX,v=I.clientY,p=c.phase;if(p.kind==="idle")return;const T=Math.abs(g-p.startX),R=Math.abs(v-p.startY);if(T<e&&R<e){c.phase.kind==="content"&&i(A.setSuggest(null)),i(A.setPointer(null)),i(A.setTabbarHover(null));return}if(i(A.setPointer({x:g,y:v})),p.kind==="content"){const E=p.cache.groups.find(({rect:S})=>g>=S.left&&g<=S.right&&v>=S.top&&v<=S.bottom);if(!E){i(A.setSuggest(null));return}const D=q(E.rect,g,v);if(o&&!o({targetGroupId:E.gid,zone:D})){i(A.setSuggest(null));return}i(A.setSuggest({rect:E.rect,zone:D}));return}if(p.kind==="tab"){const E=p.cache.tabbars.find(({rect:C})=>g>=C.left&&g<=C.right&&v>=C.top&&v<=C.bottom);if(E){const k=Array.from(E.el.querySelectorAll("[role='tab']")).map(H=>H.getBoundingClientRect()),j=k.map(H=>H.left+H.width/2),O=j.findIndex(H=>g<H),N=O===-1?j.length:O,Gt=k.length===0?E.rect.left+8:N===0?k[0].left:N===k.length?k[k.length-1].right:(k[N-1].right+k[N].left)/2;i(A.setTabbarHover({groupId:E.gid,index:N,rect:E.rect,insertX:Gt}))}else i(A.setTabbarHover(null));const D=p.cache.contents.find(({rect:C})=>g>=C.left&&g<=C.right&&v>=C.top&&v<=C.bottom);if(!D){i(A.setSuggest(null));return}const S=q(D.rect,g,v);if(o&&!o({targetGroupId:D.gid,zone:S})){i(A.setSuggest(null));return}i(A.setSuggest({rect:D.rect,zone:S}))}}),f=G.useEffectEvent(I=>{const y=t.current,g=c;if(i(A.reset()),!y)return;const v=I.clientX,p=I.clientY;if(g.phase.kind==="idle")return;const T=Math.abs(v-g.phase.startX),R=Math.abs(p-g.phase.startY);if(!(T<e&&R<e)){if(g.phase.kind==="content"){const E=g.phase.cache.groups.find(({rect:C})=>v>=C.left&&v<=C.right&&p>=C.top&&p<=C.bottom);if(!E)return;const D=E.gid??null;if(!D)return;const S=q(E.rect,v,p);if(o&&!o({targetGroupId:D,zone:S}))return;r({fromGroupId:g.phase.fromGroupId,tabId:g.phase.tabId,targetGroupId:D,zone:S});return}if(g.phase.kind==="tab"){const E=g.phase.cache.tabbars.find(({rect:S})=>v>=S.left&&v<=S.right&&p>=S.top&&p<=S.bottom);if(E){const S=E.gid;if(!S)return;const k=Array.from(E.el.querySelectorAll("[role='tab']")).map(N=>{const Z=N.getBoundingClientRect();return Z.left+Z.width/2}),j=k.findIndex(N=>v<N),O=j===-1?k.length:j;n({fromGroupId:g.phase.fromGroupId,tabId:g.phase.tabId,targetGroupId:S,targetIndex:O});return}const D=g.phase.cache.contents.find(({rect:S})=>v>=S.left&&v<=S.right&&p>=S.top&&p<=S.bottom);if(D){const S=D.gid??null;if(!S)return;const C=q(D.rect,v,p);if(o&&!o({targetGroupId:S,zone:C}))return;r({fromGroupId:g.phase.fromGroupId,tabId:g.phase.tabId,targetGroupId:S,zone:C})}}}}),h=G.useEffectEvent(()=>{i(A.reset())});l.useEffect(()=>{if(c.phase.kind!=="idle")return window.addEventListener("pointermove",d),window.addEventListener("pointerup",f,{once:!0}),window.addEventListener("pointercancel",h,{once:!0}),()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h)}},[c.phase.kind]);const w=l.useCallback((I,y,g)=>{if(g.button!==0)return;g.currentTarget.setPointerCapture(g.pointerId);const v=u();i(A.startContent({x:g.clientX,y:g.clientY,groupId:I,tabId:y,cache:v}))},[u]),m=l.useCallback((I,y,g)=>{if(g.button!==0)return;const v=g.currentTarget;v&&v.setPointerCapture(g.pointerId);const p=u();i(A.startTab({x:g.clientX,y:g.clientY,groupId:y,tabId:I,cache:p,element:v}))},[u]),x=l.useMemo(()=>({suggest:c.suggest,isTabDragging:c.phase.kind==="tab",draggingTabId:c.phase.kind==="tab"?c.phase.tabId:null,dragPointer:c.pointer,tabbarHover:c.tabbarHover,draggingTabElement:c.draggingTabElement,onStartContentDrag:w,onStartTabDrag:m}),[c.suggest,c.pointer,c.tabbarHover,c.phase,c.draggingTabElement,w,m]);return b.jsx(gt.Provider,{value:x,children:s})},rt={display:"inline-flex",alignItems:"center",userSelect:"none"},Zt=({groupId:t,tab:e,active:r,dragging:n,onClickTab:o,onStartDrag:s,onCloseTab:c,tabComponent:i,tabElement:a,onDoubleClick:u})=>{const d=l.useEffectEvent(()=>{o(e.id)}),f=l.useEffectEvent(x=>{s&&x.button===0&&s(e.id,t,x)}),h=()=>{const x=!!c;return b.jsx(l.Activity,{mode:x?"visible":"hidden",children:b.jsx("button",{type:"button","aria-label":`Close tab ${e.title}`,onClick:I=>{c&&(I.stopPropagation(),c(t,e.id))},style:{marginLeft:6},tabIndex:x?void 0:-1,disabled:!x,"aria-hidden":x?void 0:!0,children:"×"})})},w={role:"tab","aria-selected":r,tabIndex:r?0:-1,style:rt,onClick:d,onPointerDown:f,onDoubleClick:u,"data-tab-id":e.id,"data-active":r?"true":"false","data-dragging":n?"true":"false",children:b.jsxs(b.Fragment,{children:[b.jsx("span",{children:e.title}),h()]})},m={type:"button",role:"tab","aria-selected":r,tabIndex:r?0:-1,style:rt,onClick:()=>{o(e.id)},onPointerDown:x=>{s&&x.button===0&&s(e.id,t,x)},onDoubleClick:u,children:b.jsx("span",{children:e.title})};return a?a(m):i?b.jsx(i,{...m}):b.jsx("div",{...w})},Jt={display:"flex",alignItems:"center"},Qt={flex:"1 1 auto",alignSelf:"stretch"},te=({group:t,onClickTab:e,onStartDrag:r,rootRef:n,component:o,element:s,tabComponent:c,tabElement:i,onAddTab:a,onCloseTab:u,doubleClickToAdd:d})=>{const{isTabDragging:f,draggingTabId:h}=U(),w=l.useRef(null),m=l.useCallback(p=>{if(w.current=p,!!n){if(typeof n=="function"){n(p);return}try{n.current=p}catch{}}},[n]),x=l.useEffectEvent(p=>{const T=w.current??p.currentTarget;if(!T)return;const R=Array.from(T.querySelectorAll('[role="tab"]'));if(R.length===0)return;const E=j=>{const O=Math.max(0,Math.min(j,R.length-1)),N=R[O];N&&N.focus()},D=document.activeElement,S=D?R.indexOf(D):R.findIndex(j=>j.getAttribute("data-tab-id")===t.activeTabId);if(p.key==="ArrowRight"){p.preventDefault();const j=S>=0?S+1:0;E(j>=R.length?0:j);return}if(p.key==="ArrowLeft"){p.preventDefault();const j=S>=0?S-1:R.length-1;E(j<0?R.length-1:j);return}if(p.key==="Home"){p.preventDefault(),E(0);return}if(p.key==="End"){p.preventDefault(),E(R.length-1);return}if(p.key==="Enter"||p.key===" "){p.preventDefault();const O=(S>=0?R[S]:null)?.getAttribute("data-tab-id")??null;O&&e(O);return}if(p.key==="Delete"||p.key==="Backspace"){if(u){p.preventDefault();const O=(S>=0?R[S]:null)?.getAttribute("data-tab-id")??null;O&&u(t.id,O)}return}const C=(p.ctrlKey?1:0)+(p.metaKey?1:0)>0,k=typeof p.key=="string"?p.key.toLowerCase():"";if(C&&k==="t"){a&&(p.preventDefault(),a(t.id));return}});l.useEffect(()=>{const p=w.current;if(!p)return;const T=p.querySelector(`[role="tab"][data-tab-id="${t.activeTabId}"]`);if(T===document.activeElement)return;!p.contains(document.activeElement)&&T&&T.focus()},[t.activeTabId]);const I={style:Jt,role:"tablist","data-tabbar":"true","data-group-id":t.id,"data-dragging":f?"true":"false",onKeyDown:x},y=G.useElementComponentWrapper({element:s,component:o}),g=()=>a?b.jsx("button",{type:"button","aria-label":"Add tab",onClick:()=>{a(t.id)},children:"+"}):null,v=l.useCallback(()=>{d&&a&&a(t.id)},[d,a,t.id]);return b.jsxs(y,{...I,ref:m,onDoubleClick:v,children:[t.tabs.map((p,T)=>b.jsx(Zt,{groupId:t.id,tab:p,active:t.activeTabId===p.id,dragging:h===p.id,onClickTab:e,onStartDrag:r,onCloseTab:u,tabComponent:c,tabElement:i,onDoubleClick:R=>R.stopPropagation()},`${t.id}:${p.id}:${T}`)),b.jsx("span",{style:Qt}),g()]})},ee=({id:t,TabBarComponent:e,PanelGroupComponent:r})=>{const{getGroup:n,getGroupContent:o,onClickTab:s,onAddTab:c,onCloseTab:i,onStartTabDrag:a,doubleClickToAdd:u,registerContentContainer:d}=Bt(),{setGroupEl:f,setTabbarEl:h,setContentEl:w}=dt(),m=l.useCallback(T=>{f(t,T)},[t,f]),x=l.useCallback(T=>{w(t,T),d(t,T)},[t,w,d]),I=l.useCallback(T=>{h(t,T)},[t,h]),y=n(t);if(!y)return null;const g=o(t),v=e??te,p=r??(T=>b.jsx(pt,{...T}));return b.jsx(p,{group:y,tabbar:b.jsx(v,{rootRef:I,group:y,onClickTab:T=>s(t,T),onAddTab:c,onCloseTab:i,onStartDrag:(T,R,E)=>a(T,R,E),doubleClickToAdd:u}),content:g,groupRef:m,contentRef:x})},re=(t,e)=>{const r=new Array(16);for(let n=0;n<4;n++)for(let o=0;o<4;o++)r[n*4+o]=t[0+o]*e[n*4+0]+t[4+o]*e[n*4+1]+t[8+o]*e[n*4+2]+t[12+o]*e[n*4+3];return r},V=t=>{if(t.length!==16)throw new Error("Matrix must have exactly 16 values");const e=Object.freeze([...t]),r=n=>{const o=re(e,n);return V(o)};return Object.freeze({translate:(n=0,o=0,s=0)=>r([1,0,0,0,0,1,0,0,0,0,1,0,n,o,s,1]),translate3d:(n,o,s)=>r([1,0,0,0,0,1,0,0,0,0,1,0,n,o,s,1]),translateX:n=>r([1,0,0,0,0,1,0,0,0,0,1,0,n,0,0,1]),translateY:n=>r([1,0,0,0,0,1,0,0,0,0,1,0,0,n,0,1]),translateZ:n=>r([1,0,0,0,0,1,0,0,0,0,1,0,0,0,n,1]),scale:(n=1,o=1,s=1)=>r([n,0,0,0,0,o,0,0,0,0,s,0,0,0,0,1]),scale3d:(n,o,s)=>r([n,0,0,0,0,o,0,0,0,0,s,0,0,0,0,1]),scaleX:n=>r([n,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),scaleY:n=>r([1,0,0,0,0,n,0,0,0,0,1,0,0,0,0,1]),scaleZ:n=>r([1,0,0,0,0,1,0,0,0,0,n,0,0,0,0,1]),rotateX:n=>{const o=Math.cos(n),s=Math.sin(n);return r([1,0,0,0,0,o,s,0,0,-s,o,0,0,0,0,1])},rotateY:n=>{const o=Math.cos(n),s=Math.sin(n);return r([o,0,-s,0,0,1,0,0,s,0,o,0,0,0,0,1])},rotateZ:n=>{const o=Math.cos(n),s=Math.sin(n);return r([o,s,0,0,-s,o,0,0,0,0,1,0,0,0,0,1])},rotate:(n,o,s,c)=>{const i=Math.sqrt(o*o+s*s+c*c);if(i===0)return V(e);o/=i,s/=i,c/=i;const a=Math.cos(n),u=Math.sin(n),d=1-a;return r([d*o*o+a,d*o*s+u*c,d*o*c-u*s,0,d*o*s-u*c,d*s*s+a,d*s*c+u*o,0,d*o*c+u*s,d*s*c-u*o,d*c*c+a,0,0,0,0,1])},rotate3d:(n,o,s,c)=>{const i=Math.sqrt(n*n+o*o+s*s);if(i===0)return V(e);n/=i,o/=i,s/=i;const a=Math.cos(c),u=Math.sin(c),d=1-a;return r([d*n*n+a,d*n*o+u*s,d*n*s-u*o,0,d*n*o-u*s,d*o*o+a,d*o*s+u*n,0,d*n*s+u*o,d*o*s-u*n,d*s*s+a,0,0,0,0,1])},skew:(n=0,o=0)=>{const s=Math.tan(n),c=Math.tan(o);return r([1,c,0,0,s,1,0,0,0,0,1,0,0,0,0,1])},skewX:n=>{const o=Math.tan(n);return r([1,0,0,0,o,1,0,0,0,0,1,0,0,0,0,1])},skewY:n=>{const o=Math.tan(n);return r([1,o,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},perspective:n=>{if(n===0)throw new Error("Perspective distance cannot be zero");return r([1,0,0,0,0,1,0,0,0,0,1,-1/n,0,0,0,1])},toCSS:()=>`matrix3d(${e.join(", ")})`,toArray:()=>e,toString:()=>[`[${e[0]}, ${e[4]}, ${e[8]}, ${e[12]}]`,`[${e[1]}, ${e[5]}, ${e[9]}, ${e[13]}]`,`[${e[2]}, ${e[6]}, ${e[10]}, ${e[14]}]`,`[${e[3]}, ${e[7]}, ${e[11]}, ${e[15]}]`].join(`
|
|
2
|
-
`)})},ne=()=>V([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),oe={position:"fixed",inset:0,pointerEvents:"none",zIndex:P.DROP_SUGGEST_Z_INDEX},se={position:"absolute",border:`${P.DROP_SUGGEST_BORDER_WIDTH} dashed ${P.DROP_SUGGEST_BORDER_COLOR}`,background:P.DROP_SUGGEST_BG_COLOR,borderRadius:P.DROP_SUGGEST_BORDER_RADIUS,transformOrigin:"top left"},L=(t,e)=>e<=0?0:G.clampNumber(t/e,0),ie=(t,e,r)=>{const{width:n,height:o}=t,s=r/2,c=n>0?n:1,i=o>0?o:1,a={translateX:r,translateY:r,scaleX:L(G.clampNumber(n-r*2,0),c),scaleY:L(G.clampNumber(o-r*2,0),i)},u={translateX:r,translateY:r,scaleX:L(G.clampNumber(n/2-r*1.5,0),c),scaleY:L(G.clampNumber(o-r*2,0),i)},d={translateX:n/2+s,translateY:r,scaleX:L(G.clampNumber(n/2-r*1.5,0),c),scaleY:L(G.clampNumber(o-r*2,0),i)},f={translateX:r,translateY:r,scaleX:L(G.clampNumber(n-r*2,0),c),scaleY:L(G.clampNumber(o/2-r*1.5,0),i)},h={translateX:r,translateY:o/2+s,scaleX:L(G.clampNumber(n-r*2,0),c),scaleY:L(G.clampNumber(o/2-r*1.5,0),i)},w={center:a,left:u,right:d,top:f,bottom:h},{translateX:m,translateY:x,scaleX:I,scaleY:y}=w[e];return ne().translate(m,x,0).scale(I,y,1).toCSS()},ce=(t,e)=>{const r=P.DROP_SUGGEST_PADDING_PX;return{...se,left:t.left,top:t.top,width:t.width,height:t.height,transform:ie(t,e,r)}},ae=({suggest:t})=>{if(!t)return null;const{rect:e,zone:r}=t,n=ce(e,r);return b.jsx("div",{style:oe,children:b.jsx("div",{style:n})})},ue=typeof window<"u"&&typeof document<"u",le=t=>{const[e,r]=l.useState(null),[n,o]=l.useState(null);return tt.useIsomorphicLayoutEffect(()=>{if(!ue||!t){r(null),o(null);return}const s=t.getBoundingClientRect();r({width:s.width,height:s.height}),o(t.outerHTML)},[t]),{html:n,size:e}},de={position:"fixed",inset:0,pointerEvents:"none",zIndex:P.TAB_DRAG_OVERLAY_Z_INDEX},pe={position:"absolute",width:P.TAB_DRAG_INSERT_GUIDE_WIDTH,borderRadius:P.TAB_DRAG_INSERT_GUIDE_BORDER_RADIUS,background:P.TAB_DRAG_INSERT_GUIDE_COLOR,boxShadow:P.TAB_DRAG_INSERT_GUIDE_SHADOW},fe=()=>{const{isTabDragging:t,draggingTabId:e,dragPointer:r,tabbarHover:n,draggingTabElement:o}=U(),{html:s,size:c}=le(o),i=r!==null&&e!==null,a=l.useMemo(()=>{if(!(!i||!r))return{position:"absolute",left:r.x,top:r.y,transform:`translate(${P.TAB_DRAG_PREVIEW_OFFSET_X}, ${P.TAB_DRAG_PREVIEW_OFFSET_Y})`,pointerEvents:"none"}},[i,r]),u=l.useMemo(()=>{if(!(!a||!o))return c?{...a,width:c.width,height:c.height}:a},[a,o,c]),d=l.useMemo(()=>{if(n)return{...pe,left:n.insertX,top:n.rect.top+4,height:Math.max(0,n.rect.height-8)}},[n]);return t?b.jsxs("div",{style:de,children:[b.jsx(l.Activity,{mode:u?"visible":"hidden",children:b.jsx("div",{style:u,children:b.jsx("div",{style:{width:"100%",height:"100%",pointerEvents:"none"},dangerouslySetInnerHTML:{__html:s??""}})})}),b.jsx(l.Activity,{mode:d?"visible":"hidden",children:b.jsx("div",{style:d})})]}):null},M=t=>t.type==="group",F=(t,e=[])=>{if(M(t))return[...e,t.groupId];const r=F(t.a,e);return F(t.b,r)},W=(t,e)=>e.reduce((r,n)=>M(r)?r:r[n],t),Y=(t,e,r)=>{if(e.length===0)return r;const[n,...o]=e;return M(t)?t:n==="a"?{...t,a:Y(t.a,o,r)}:{...t,b:Y(t.b,o,r)}},K=(t,e,r=[])=>{if(M(t))return t.groupId===e?{splitPath:null,side:null}:null;if(M(t.a)&&t.a.groupId===e)return{splitPath:r,side:"a"};if(M(t.b)&&t.b.groupId===e)return{splitPath:r,side:"b"};const n=K(t.a,e,[...r,"a"]);return n||K(t.b,e,[...r,"b"])},ht=(t,e,r,n)=>{const o=n(),s=K(t,e),c={type:"split",direction:r,ratio:.5,a:{type:"group",groupId:e},b:{type:"group",groupId:o}};if(!s||s.splitPath===null)return{tree:c,newGroupId:o};const i=s.splitPath,a=W(t,i);if(M(a))return{tree:c,newGroupId:o};const u=s.side==="a"?{...a,a:c}:{...a,b:c};return{tree:Y(t,i,u),newGroupId:o}},be=(t,e)=>{const r=K(t,e);if(!r||r.splitPath===null)return{tree:t,survivorGroupId:e};const n=r.splitPath,o=W(t,n);if(M(o))return{tree:t,survivorGroupId:e};const s=r.side==="a"?o.b:o.a,c=Y(t,n,s),i=M(s)?s.groupId:F(s)[0]??null;return{tree:c,survivorGroupId:i}},ge=(t,e,r)=>{const n=W(t,e);if(M(n))return t;const o={...n,ratio:G.clampNumber(r,.05,.95)};return Y(t,e,o)},J=t=>{if(Object.keys(t.groups).filter(o=>t.groups[o].tabIds.length===0).length===0)return t;const n=(o,s)=>{const c=o.groups[s];if(!c||c.tabs.length>0||Object.keys(o.groups).length<=1)return o;const{tree:a,survivorGroupId:u}=be(o.tree,s),{[s]:d,...f}=o.groups,h=F(a),w=o.focusedGroupId===s?u??h[0]??null:o.focusedGroupId;return{...o,tree:a,groups:f,groupOrder:h,focusedGroupId:w}};return t.groupOrder.reduce((o,s)=>n(o,s),t)},he=t=>({id:t,tabIds:[],tabs:[],activeTabId:null}),nt=(t,e,r,n)=>{const o={...t.groups},s=o[e];if(!s)throw new Error(`Group ${e} does not exist.`);const c={...t.panels,[r.id]:r},i=[...s.tabIds,r.id],a=n?r.id:s.activeTabId??r.id,u=i.map(f=>c[f]),d={...s,tabIds:i,tabs:u,activeTabId:a};return o[e]=d,{...t,panels:c,groups:o}},me=(t,e,r)=>{const n={...t.groups},o=n[e];if(!o)throw new Error(`Group ${e} does not exist.`);const s=o.tabIds.filter(a=>a!==r),c=s.map(a=>t.panels[a]),i=o.activeTabId===r?s[0]??null:o.activeTabId;return n[e]={...o,tabIds:s,tabs:c,activeTabId:i},{...t,groups:n}},ot=(t,e,r,n,o)=>{const s=t.groups[e],c=t.groups[r];if(!s||!c)throw new Error("moveTab: source or target group is missing.");const i={...t.groups},a=s.tabIds.filter(f=>f!==n),u=[...c.tabIds.filter(f=>f!==n),n],d=s.activeTabId===n?a[0]??null:s.activeTabId;return i[e]={...s,tabIds:a,tabs:a.map(f=>t.panels[f]),activeTabId:d},i[r]={...c,tabIds:u,tabs:u.map(f=>t.panels[f]),activeTabId:n},{...t,groups:i}},mt=(t,e,r)=>{const n=t.groups[e];if(!n)throw new Error(`setActiveTab: group ${e} not found.`);if(!n.tabIds.some(s=>s===r))throw new Error(`setActiveTab: tab ${r} not found in group ${e}.`);const o={...t.groups,[e]:{...n,activeTabId:r}};return{...t,groups:o,focusedGroupId:e}},st=(t,e,r,n,o)=>{const s=t.groups[e];if(!s)throw new Error(`addTabToGroupAtIndex: group ${e} not found.`);const c={...t.panels,[r.id]:r},i=s.tabIds.slice(),a=Math.max(0,Math.min(n,i.length));i.splice(a,0,r.id);const u=i.map(h=>c[h]),d=o?r.id:s.activeTabId??r.id,f={...t.groups,[e]:{...s,tabIds:i,tabs:u,activeTabId:d}};return{...t,panels:c,groups:f}},B=(t,e)=>{if(!t.groups[e])throw new Error(`setFocusedGroup: group ${e} not found.`);return{...t,focusedGroupId:e}},ve=(t,e)=>{const r=e-1,n=t.groupOrder[r];return n?B(t,n):t},Ie=t=>{const e=t.groupOrder,r=t.focusedGroupId;if(!r){const s=e[0];return s?B(t,s):t}const n=e.indexOf(r),o=e[(n+1)%e.length];return B(t,o)},we=t=>{const e=t.groupOrder,r=t.focusedGroupId;if(!r){const s=e[e.length-1];return s?B(t,s):t}const n=e.indexOf(r),o=e[(n-1+e.length)%e.length];return B(t,o)},vt=(t,e,r,n)=>{const{tree:o,newGroupId:s}=ht(t.tree,e,r,n),c={...t.groups,[s]:he(s)},i=F(o);return{...t,tree:o,groups:c,groupOrder:i,focusedGroupId:s}},xe=t=>{const r={type:"group",groupId:"g_1"},n=Object.fromEntries(t.map(i=>[i.id,i])),s={g_1:{id:"g_1",tabIds:t.map(i=>i.id),tabs:t,activeTabId:t[0]?.id??null}};return{tree:r,panels:n,groups:s,groupOrder:["g_1"],focusedGroupId:"g_1"}},ye=l.createContext(null),Te=({value:t,children:e})=>b.jsx(ye.Provider,{value:t,children:e}),It=l.createContext(null),Se=()=>{const t=l.useContext(It);if(!t)throw new Error("useTree must be used within TreeProvider");return t},Ge=({value:t,children:e})=>b.jsx(It.Provider,{value:t,children:e}),Ee=l.createContext(null),Re=({value:t,children:e})=>b.jsx(Ee.Provider,{value:t,children:e}),z=t=>{const e=G.toFiniteNumberOr(t,Number.POSITIVE_INFINITY);return G.clampNumber(e,1)},Ce=t=>typeof t=="object"&&t!==null,Pe=t=>Ce(t)?"rows"in t?!0:"cols"in t:!1,wt=t=>{if(!t)return{rows:Number.POSITIVE_INFINITY,cols:Number.POSITIVE_INFINITY};if(typeof t=="number"){const r=z(t);return{rows:r,cols:r}}if(Pe(t))return{rows:z(t.rows),cols:z(t.cols)};const e=t;return{rows:z(e.maxHorizontal),cols:z(e.maxVertical)}},Q=t=>{if(M(t))return{horizontal:1,vertical:1};const e=Q(t.a),r=Q(t.b);return t.direction==="horizontal"?{horizontal:e.horizontal+r.horizontal,vertical:Math.max(e.vertical,r.vertical)}:{horizontal:Math.max(e.horizontal,r.horizontal),vertical:e.vertical+r.vertical}},De=(t,e,r)=>{const{tree:n}=ht(t,e,r,()=>"__preview__");return n},et=(t,e,r,n)=>{if(!Number.isFinite(n.rows)&&!Number.isFinite(n.cols))return!0;const o=De(t,e,r),s=Q(o);return!(s.horizontal>n.rows||s.vertical>n.cols)},xt={splitFocused:_("panelState/splitFocused",t=>({direction:t})),focusGroupIndex:_("panelState/focusGroupIndex",t=>({index1Based:t})),focusNextGroup:_("panelState/focusNextGroup"),focusPrevGroup:_("panelState/focusPrevGroup"),setActiveTab:_("panelState/setActiveTab",(t,e)=>({groupId:t,tabId:e})),addTab:_("panelState/addTab",t=>t),addNewTab:_("panelState/addNewTab",t=>t),removeTab:_("panelState/removeTab",(t,e)=>({groupId:t,tabId:e})),contentDrop:_("panelState/contentDrop",t=>t),tabDrop:_("panelState/tabDrop",t=>t),adjustSplitRatio:_("panelState/adjustSplitRatio",t=>t)},je=(t,e,r)=>{const n=t.groups[e.fromGroupId],o=t.groups[e.targetGroupId];if(!n||!o||!n.tabs.find(f=>f.id===e.tabId))return t;if(e.zone==="center"&&e.fromGroupId===e.targetGroupId)return mt(t,e.fromGroupId,e.tabId);if(e.zone==="center"){const f=ot(t,e.fromGroupId,e.targetGroupId,e.tabId);return B(f,e.targetGroupId)}const c=e.zone==="left"||e.zone==="right"?"vertical":"horizontal";if(!et(t.tree,e.targetGroupId,c,r.splitLimits))return t;const i=r.createGroupId(),a=vt(t,e.targetGroupId,c,()=>i),u=e.zone==="left"||e.zone==="top"?e.targetGroupId:i,d=ot(a,e.fromGroupId,u,e.tabId);return B(d,u)},Ae=(t,e)=>{const r=t.groups[e.fromGroupId],n=t.groups[e.targetGroupId];if(!r||!n||!t.panels[e.tabId])return t;if(e.fromGroupId===e.targetGroupId){const h=r.tabIds.filter(y=>y!==e.tabId),w=Math.max(0,Math.min(e.targetIndex,h.length)),m=h.slice(0,w).concat([e.tabId],h.slice(w)),x=m.map(y=>t.panels[y]).filter(Boolean),I={...t.groups,[e.fromGroupId]:{...r,tabIds:m,tabs:x}};return{...t,groups:I}}const s={...t.groups},c=r.tabIds.filter(h=>h!==e.tabId),i=c.map(h=>t.panels[h]);s[e.fromGroupId]={...r,tabIds:c,tabs:i,activeTabId:r.activeTabId===e.tabId?i[0]?.id??null:r.activeTabId};const a=n.tabIds.filter(h=>h!==e.tabId),u=Math.max(0,Math.min(e.targetIndex,a.length)),d=a.slice(0,u).concat([e.tabId],a.slice(u)),f=d.map(h=>t.panels[h]).filter(Boolean);return s[e.targetGroupId]={...n,tabIds:d,tabs:f,activeTabId:e.tabId},{...t,groups:s,focusedGroupId:e.targetGroupId}},_e=ft(xt,{splitFocused:(t,e,r)=>{const n=t.focusedGroupId??t.groupOrder[0]??null;return!n||!et(t.tree,n,e.payload.direction,r.splitLimits)?t:vt(t,n,e.payload.direction,r.createGroupId)},focusGroupIndex:(t,e)=>ve(t,e.payload.index1Based),focusNextGroup:t=>Ie(t),focusPrevGroup:t=>we(t),setActiveTab:(t,e)=>mt(t,e.payload.groupId,e.payload.tabId),addTab:(t,e)=>{const{groupId:r,tab:n,index:o,makeActive:s}=e.payload;return typeof o=="number"?st(t,r,n,o,s??!0):nt(t,r,n,s??!0)},addNewTab:(t,e,r)=>{if(!r.createPanelId)throw new Error("addNewTab requires PanelSystemProvider.createPanelId");const o={id:r.createPanelId(),title:e.payload.title,render:()=>e.payload.title},{groupId:s,index:c,makeActive:i}=e.payload;return typeof c=="number"?st(t,s,o,c,i??!0):nt(t,s,o,i??!0)},removeTab:(t,e)=>me(t,e.payload.groupId,e.payload.tabId),contentDrop:(t,e,r)=>je(t,e.payload,r),tabDrop:(t,e)=>Ae(t,e.payload),adjustSplitRatio:(t,e)=>{const r=W(t.tree,e.payload.path);if(M(r))return t;const n=ge(t.tree,e.payload.path,r.ratio+e.payload.deltaRatio);return{...t,tree:n}}}),it=(t,e,r)=>{const n=_e[e.type];if(!n)return t;const o=n(t,e,r);return J(o)},yt=l.createContext(null),$=()=>{const t=l.useContext(yt);if(!t)throw new Error("usePanelSystem must be used within PanelSystemProvider");return t},ke=({initialState:t,createGroupId:e,createPanelId:r,state:n,onStateChange:o,splitLimits:s,children:c})=>{const i=l.useMemo(()=>J(t),[t]),a=l.useMemo(()=>wt(s),[s]),u=l.useRef({createGroupId:e,splitLimits:a,createPanelId:r});u.current.createGroupId=e,u.current.splitLimits=a,u.current.createPanelId=r;const[d,f]=l.useReducer((T,R)=>it(T,R,u.current),i),h=l.useMemo(()=>n?J(n):d,[n,d]),w=l.useRef(h);w.current=h;const m=n!==void 0,x=l.useCallback(T=>{if(m){const R=it(w.current,T,u.current);o?.(R);return}f(T)},[m,o,f]),I=l.useMemo(()=>Vt(xt,x),[x]),y=l.useMemo(()=>({setActiveTab:I.setActiveTab,tabDrop:I.tabDrop}),[I]),g=l.useMemo(()=>({adjustSplitRatio:I.adjustSplitRatio}),[I]),v=l.useMemo(()=>({focusGroupIndex:I.focusGroupIndex,focusNextGroup:I.focusNextGroup,focusPrevGroup:I.focusPrevGroup}),[I]),p=l.useMemo(()=>({state:h,dispatch:x,actions:I}),[h,x,I]);return b.jsx(yt.Provider,{value:p,children:b.jsx(Te,{value:y,children:b.jsx(Ge,{value:g,children:b.jsx(Re,{value:v,children:c})})})})},Me=()=>{const{actions:t}=$();return l.useMemo(()=>({splitFocused:e=>{t.splitFocused(e)},focusGroupIndex:e=>{t.focusGroupIndex(e)},focusNextGroup:()=>{t.focusNextGroup()},focusPrevGroup:()=>{t.focusPrevGroup()},closeFocusedGroup:()=>{}}),[t])},Oe=()=>{const{actions:t}=$(),e=l.useCallback(({fromGroupId:n,tabId:o,targetGroupId:s,zone:c})=>{t.contentDrop({fromGroupId:n,tabId:o,targetGroupId:s,zone:c})},[t]),r=l.useCallback(({fromGroupId:n,tabId:o,targetGroupId:s,targetIndex:c})=>{t.tabDrop({fromGroupId:n,tabId:o,targetGroupId:s,targetIndex:c})},[t]);return{onCommitContentDrop:e,onCommitTabDrop:r}},Ne=()=>{const t=At(),e=Me();return l.useEffect(()=>{Mt(t,e)},[t,e]),null},Tt=l.createContext(null),Le=()=>{const t=l.useContext(Tt);if(!t)throw new Error("useContentRegistry must be used within ContentRegistryProvider");return t},Be=t=>{const e=document.createElement("div");return e.setAttribute("data-panel-wrapper",t),e.style.display="contents",e},He=(t,e,r)=>{const[n]=l.useState(()=>Be(t));return tt.useIsomorphicLayoutEffect(()=>(n.style.display=r?"contents":"none",e&&n.parentElement!==e&&e.appendChild(n),()=>{n.parentElement?.removeChild(n)}),[n,e,r]),n},St=l.memo(({panelId:t,content:e,placement:r,containerElement:n})=>{const o=r?.isActive??!1,s=He(t,n,o);return Rt.createPortal(b.jsx(l.Activity,{mode:o?"visible":"hidden",children:e}),s)});St.displayName="PanelContentHost";const $e=({children:t,panels:e,placements:r})=>{const[n,o]=l.useState(new Map),s=l.useRef(new Map),c=l.useCallback((d,f)=>{o(h=>{const w=new Map(h);return f?w.set(d,f):w.delete(d),w})},[]),i=l.useMemo(()=>({registerContentContainer:c}),[c]),a=l.useCallback((d,f)=>{const h=s.current.get(d);if(h)return h;const w=f.render(f.id);return s.current.set(d,w),w},[]),u=Object.keys(e);return b.jsxs(Tt.Provider,{value:i,children:[t,u.map(d=>{const f=e[d];if(!f)return null;const h=r[d]??null,w=h?n.get(h.groupId)??null:null,m=a(d,f);return b.jsx(St,{panelId:d,content:m,placement:h,containerElement:w},d)})]})},ze=({children:t,emptyContentComponent:e,doubleClickToAdd:r})=>{const n=U(),{state:o,actions:s}=$(),{registerContentContainer:c}=Le(),i=l.useCallback(()=>l.createElement("div",{style:{color:"#888",fontSize:12,padding:12}},"No tabs"),[]),a=e??i,u=l.useCallback(y=>{const g=o.groups[y];if(!g)return null;const v=g.tabIds.map(p=>o.panels[p]).filter(Boolean);return{...g,tabs:v}},[o.groups,o.panels]),d=l.useCallback(y=>{const g=o.groups[y];return!g||g.tabIds.length===0?b.jsx(a,{}):null},[o.groups,a]),f=l.useCallback((y,g)=>{s.setActiveTab(y,g)},[s]),h=l.useCallback(y=>{s.addNewTab({groupId:y,title:"New Tab",makeActive:!0})},[s]),w=l.useCallback((y,g)=>{s.removeTab(y,g)},[s]),m=l.useCallback((y,g,v)=>{s.setActiveTab(g,y),n.onStartTabDrag(y,g,v)},[s,n]),x=l.useCallback((y,g)=>{const v=o.groups[y];!v||!v.activeTabId||n.onStartContentDrag(y,v.activeTabId,g)},[o.groups,n]),I=l.useMemo(()=>({getGroup:u,getGroupContent:d,onClickTab:f,onAddTab:h,onCloseTab:w,onStartTabDrag:m,onStartContentDrag:x,doubleClickToAdd:r,registerContentContainer:c}),[u,d,f,h,w,m,x,r,c]);return b.jsx(Ht,{value:I,children:t})},Xe=({children:t,emptyContentComponent:e,doubleClickToAdd:r})=>{const{state:n}=$(),o=l.useMemo(()=>{const s={};for(const[c,i]of Object.entries(n.groups))for(const a of i.tabIds)s[a]={groupId:c,isActive:a===i.activeTabId};return s},[n.groups]);return b.jsx($e,{panels:n.panels,placements:o,children:b.jsx(ze,{emptyContentComponent:e,doubleClickToAdd:r,children:t})})},X=(t,e,r,n)=>{if(M(t))return n;const o=t.direction,s=o==="vertical"?r.x+r.w*t.ratio:r.y+r.h*t.ratio;if(n.push({path:e,direction:o,parentRect:r,linePos:s}),o==="vertical"){const a=r.w*t.ratio,u=r.w-a;return X(t.a,[...e,"a"],{x:r.x,y:r.y,w:a,h:r.h},n),X(t.b,[...e,"b"],{x:r.x+a,y:r.y,w:u,h:r.h},n),n}const c=r.h*t.ratio,i=r.h-c;return X(t.a,[...e,"a"],{x:r.x,y:r.y,w:r.w,h:c},n),X(t.b,[...e,"b"],{x:r.x,y:r.y+c,w:r.w,h:i},n),n},Fe=({containerRef:t})=>{const{state:e}=$(),{adjustSplitRatio:r}=Se(),n=l.useMemo(()=>X(e.tree,[],{x:0,y:0,w:100,h:100},[]),[e.tree]),[o,s]=l.useState(null);if(tt.useIsomorphicLayoutEffect(()=>{const i=t.current;if(!i)return;const a=()=>{const w=i.getBoundingClientRect();s({left:w.left,top:w.top,width:w.width,height:w.height})};a();function u(){try{const w=window.ResizeObserver;return typeof w=="function"?w:null}catch{return null}}const d=u(),f=d?new d(()=>a()):null;f&&f.observe(i);const h=()=>a();return window.addEventListener("scroll",h,!0),()=>{window.removeEventListener("scroll",h,!0),f&&f.disconnect()}},[t,e.tree]),!o)return null;const c=(i,a)=>{const u={left:o.left+o.width*i.parentRect.x/100,top:o.top+o.height*i.parentRect.y/100,width:o.width*i.parentRect.w/100,height:o.height*i.parentRect.h/100},d=P.SPLIT_HANDLE_THICKNESS;if(i.direction==="vertical"){const m=u.left+u.width*(i.linePos-i.parentRect.x)/i.parentRect.w,x={position:"fixed",left:`calc(${Math.round(m)}px - ${d} / 2)`,top:Math.round(u.top),width:d,height:Math.round(u.height),cursor:"col-resize",pointerEvents:"auto"},I=y=>{const g=o.width*i.parentRect.w/100,v=g===0?0:y/g;r({path:i.path,deltaRatio:v})};return b.jsx("div",{style:x,children:b.jsx(G.ResizeHandle,{direction:"vertical",onResize:I})},`split-${a}`)}const f=u.top+u.height*(i.linePos-i.parentRect.y)/i.parentRect.h,h={position:"fixed",left:Math.round(u.left),top:`calc(${Math.round(f)}px - ${d} / 2)`,width:Math.round(u.width),height:d,cursor:"row-resize",pointerEvents:"auto"},w=m=>{const x=o.height*i.parentRect.h/100,I=x===0?0:m/x;r({path:i.path,deltaRatio:I})};return b.jsx("div",{style:h,children:b.jsx(G.ResizeHandle,{direction:"horizontal",onResize:w})},`split-${a}`)};return b.jsx("div",{style:{position:"fixed",inset:0,pointerEvents:"none"},children:n.map((i,a)=>c(i,a))})},Ye={position:"relative",display:"flex",width:"100%",height:"100%"},qe=({state:t,layoutMode:e,gridTracksInteractive:r,view:n,tabBarComponent:o,panelGroupComponent:s})=>{const c=a=>{if(n){const u=n;return b.jsx(u,{groupId:a})}return b.jsx(ee,{id:a,TabBarComponent:o,PanelGroupComponent:s})};if(e==="grid"){const a=Lt(t,c,!!r);return b.jsx(G.GridLayout,{config:a.config,layers:a.layers})}const i=Nt(t,c);return b.jsx(G.GridLayout,{config:i.config,layers:i.layers})},Ve=({containerRef:t,layoutMode:e,gridTracksInteractive:r,dragThresholdPx:n,view:o,style:s,className:c,tabBarComponent:i,panelGroupComponent:a,splitLimits:u,emptyContentComponent:d,doubleClickToAdd:f})=>{const{state:h}=$(),{onCommitContentDrop:w,onCommitTabDrop:m}=Oe(),x=l.useMemo(()=>({...Ye,...s}),[s]),I=l.useCallback(({targetGroupId:y,zone:g})=>{if(g==="center")return!0;const v=g==="left"||g==="right"?"vertical":"horizontal";return et(h.tree,y,v,u)},[h.tree,u]);return b.jsx($t,{children:b.jsxs(Wt,{containerRef:t,dragThresholdPx:n,onCommitContentDrop:w,onCommitTabDrop:m,isContentZoneAllowed:I,children:[b.jsx(Xe,{emptyContentComponent:d,doubleClickToAdd:f,children:b.jsx("div",{ref:t,className:c,style:x,children:b.jsx(qe,{state:h,layoutMode:e,gridTracksInteractive:r,view:o,tabBarComponent:i,panelGroupComponent:a})})}),b.jsx(Fe,{containerRef:t}),b.jsx(Ke,{})]})})},Ke=()=>{const t=U();return b.jsxs(b.Fragment,{children:[b.jsx(ae,{suggest:t.suggest}),b.jsx(fe,{})]})},Ue=({initialState:t,createGroupId:e,createPanelId:r,layoutMode:n,gridTracksInteractive:o,dragThresholdPx:s,view:c,emptyContentComponent:i,state:a,onStateChange:u,className:d,style:f,tabBarComponent:h,panelGroupComponent:w,splitLimits:m,doubleClickToAdd:x})=>{if(!t)throw new Error("PanelSystem requires initialState.");if(!e)throw new Error("PanelSystem requires explicit createGroupId function.");if(!n)throw new Error("PanelSystem requires explicit layoutMode ('absolute' | 'grid').");if(n==="grid"&&o===void 0)throw new Error("PanelSystem(layoutMode='grid') requires explicit 'gridTracksInteractive' flag.");if(s===void 0)throw new Error("PanelSystem requires explicit 'dragThresholdPx' value.");const I=l.useRef(null),y=l.useMemo(()=>wt(m),[m]);return b.jsx(ke,{initialState:t,createGroupId:e,createPanelId:r,state:a,onStateChange:u,splitLimits:m,children:b.jsxs(kt,{children:[b.jsx(Ne,{}),b.jsx(Ve,{containerRef:I,layoutMode:n,gridTracksInteractive:o,dragThresholdPx:s,view:c,style:f,className:d,tabBarComponent:h,panelGroupComponent:w,splitLimits:y,emptyContentComponent:i,doubleClickToAdd:x})]})})};exports.Drawer=G.Drawer;exports.DrawerLayers=G.DrawerLayers;exports.GridLayout=G.GridLayout;exports.ResizeHandle=G.ResizeHandle;exports.runTransition=G.runTransition;exports.useTransitionState=G.useTransitionState;exports.CSS_VAR_PREFIX=P.CSS_VAR_PREFIX;exports.HorizontalDivider=Dt;exports.PanelSystem=Ue;exports.buildInitialState=xe;exports.useLayerDragHandle=jt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("./GridLayout-DC7fCmcI.cjs"),b=require("react/jsx-runtime"),Rt=require("react"),P=require("./styles-DcG3aIFx.cjs"),tt=require("./usePivot-C8q0pMgW.cjs"),Pt=require("react-dom");function Dt(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const l=Dt(Rt),jt=t=>{const e=t==="drag"?P.COLOR_RESIZE_HANDLE_ACTIVE:t==="hover"?P.COLOR_RESIZE_HANDLE_HOVER:P.COLOR_RESIZE_HANDLE_IDLE;return{width:P.HORIZONTAL_DIVIDER_WIDTH,cursor:"col-resize",position:"relative",userSelect:"none",backgroundColor:e}},At=({onResize:t,component:e,element:n})=>{const{ref:r,isDragging:o,onPointerDown:s}=G.useResizeDrag({axis:"x",onResize:t}),[a,i]=l.useState(!1),c={ref:r,style:jt(o?"drag":a?"hover":"idle"),role:"separator","aria-orientation":"vertical","data-dragging":o?"true":void 0,onPointerDown:s,onPointerEnter:()=>i(!0),onPointerLeave:()=>i(!1)};return n?l.cloneElement(n,c):e?b.jsx(e,{...c}):b.jsx("div",{...c})},kt=()=>{const{layerId:t}=G.useLayerInstance(),{getLayerHandleProps:e}=G.useGridLayoutContext();return l.useMemo(()=>e(t),[e,t])},nt={left:0,top:0},rt={width:400,height:300},_t=t=>{const[e,n]=l.useState(()=>{const u={};return t.forEach(p=>{if(p.floating){const g=p.floating;u[p.id]={position:g.defaultPosition??nt,size:g.defaultSize??rt}}}),u}),r=l.useMemo(()=>{const u=new Map;return t.forEach(p=>u.set(p.id,p)),u},[t]),o=l.useCallback(u=>{const p=r.get(u);return p?.floating?.position!==void 0?p.floating.position:e[u]?.position??nt},[r,e]),s=l.useCallback(u=>{const p=r.get(u);return p?.floating?.size!==void 0?p.floating.size:e[u]?.size??rt},[r,e]),a=l.useCallback(u=>r.get(u)?.floating?.zIndex,[r]),i=l.useCallback((u,p)=>{const g=r.get(u);g?.floating&&(g.floating.position===void 0&&n(v=>{const m=v[u];return m?{...v,[u]:{...m,position:p}}:v}),g.floating.onMove?.(p))},[r]),c=l.useCallback((u,p)=>{const g=r.get(u);g?.floating&&(g.floating.size===void 0&&n(v=>{const m=v[u];return m?{...v,[u]:{...m,size:p}}:v}),g.floating.onResize?.(p))},[r]),d=l.useCallback(u=>{r.get(u)?.floating?.onClose?.()},[r]);return{getPosition:o,getSize:s,getZIndex:a,updatePosition:i,updateSize:c,close:d}},ut=l.createContext(null),Mt=()=>{const t=l.useContext(ut);if(!t)throw new Error("useKeybindings must be used within KeybindingsProvider");return t},Ot=t=>{const e=[];t.metaKey&&e.push("Mod"),t.ctrlKey&&e.push("Ctrl"),t.altKey&&e.push("Alt"),t.shiftKey&&e.push("Shift");const n=t.key.length===1?t.key.toUpperCase():t.key;return e.push(n),e.join("-")},Nt=({children:t,configure:e})=>{const n=l.useRef({}),r=l.useCallback((a,i)=>{n.current={...n.current,[a]:i}},[]),o=l.useCallback(a=>{const i={...n.current};delete i[a],n.current=i},[]);l.useEffect(()=>{const a=i=>{const c=Ot(i),d=n.current[c];d&&d(i)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[]);const s=l.useMemo(()=>({register:r,unregister:o}),[r,o]);return l.useEffect(()=>{e&&e(s)},[s,e]),b.jsx(ut.Provider,{value:s,children:t})},Lt=(t,e)=>{t.register("Mod-\\",n=>{n.preventDefault(),e.splitFocused("vertical")}),t.register("Mod-Shift-\\",n=>{n.preventDefault(),e.splitFocused("horizontal")});for(const n of[1,2,3,4,5,6,7,8,9])t.register(`Mod-${String(n)}`,r=>{r.preventDefault(),e.focusGroupIndex(n)});t.register("Alt-ArrowRight",n=>{n.preventDefault(),e.focusNextGroup()}),t.register("Alt-ArrowLeft",n=>{n.preventDefault(),e.focusPrevGroup()})},Bt=t=>t.type==="group",lt=(t,e={x:0,y:0,w:100,h:100})=>{const n=new Map,r=(o,s)=>{if(Bt(o)){n.set(o.groupId,s);return}if(o.direction==="vertical"){const c=s.w*o.ratio,d=s.w-c;r(o.a,{x:s.x,y:s.y,w:c,h:s.h}),r(o.b,{x:s.x+c,y:s.y,w:d,h:s.h});return}const a=s.h*o.ratio,i=s.h-a;r(o.a,{x:s.x,y:s.y,w:s.w,h:a}),r(o.b,{x:s.x,y:s.y+a,w:s.w,h:i})};return r(t,e),n},Ht=(t,e)=>{const n=lt(t.tree),r={areas:[["root"]],rows:[{size:"1fr"}],columns:[{size:"1fr"}],gap:"0px",style:{position:"relative"}},o=Array.from(n.entries()).map(([s,a])=>{const i={position:"absolute",left:`${a.x}%`,top:`${a.y}%`,width:`${a.w}%`,height:`${a.h}%`,overflow:"hidden",display:"flex",flexDirection:"column"};return{id:s,positionMode:"absolute",style:i,component:e(s)}});return{config:r,layers:o}},zt=(t,e,n)=>{const r=lt(t.tree),o=Array.from(new Set(Array.from(r.values()).flatMap(m=>[m.x,m.x+m.w]))).sort((m,x)=>m-x),s=Array.from(new Set(Array.from(r.values()).flatMap(m=>[m.y,m.y+m.h]))).sort((m,x)=>m-x),a=o.slice(1).map((m,x)=>`${m-o[x]}fr`),i=s.slice(1).map((m,x)=>`${m-s[x]}fr`),c=a.map(m=>({size:m,resizable:n})),d=i.map(m=>({size:m,resizable:n})),u=(m,x,I,y)=>{for(const[h,w]of r.entries())if(m>=w.x&&x<=w.x+w.w&&I>=w.y&&y<=w.y+w.h)return h;return"."},p=[];for(let m=0;m<s.length-1;m+=1){const x=[];for(let I=0;I<o.length-1;I+=1)x.push(u(o[I],o[I+1],s[m],s[m+1]));p.push(x)}const g={areas:p,rows:d,columns:c,gap:"0px"},v=Array.from(r.keys()).map(m=>({id:m,gridArea:m,component:e(m)}));return{config:g,layers:v}},dt=l.createContext(null),$t=()=>{const t=l.useContext(dt);if(!t)throw new Error("usePanelRenderContext must be used within PanelRenderProvider");return t},Ft=({value:t,children:e})=>b.jsx(dt.Provider,{value:t,children:e}),pt=l.createContext(null),ft=()=>{const t=l.useContext(pt);if(!t)throw new Error("useDomRegistry must be used within DomRegistryProvider");return t},Xt=({children:t})=>{const e=l.useRef(new Map),n=l.useCallback(c=>{const d=e.current.get(c);if(d)return d;const u={group:null,tabbar:null,content:null};return e.current.set(c,u),u},[]),r=l.useCallback((c,d)=>{const u=n(c);if(u.group=d,d===null){const p=e.current.get(c);(p?p.tabbar===null&&p.content===null:!1)&&e.current.delete(c)}},[n]),o=l.useCallback((c,d)=>{const u=n(c);if(u.tabbar=d,d===null){const p=e.current.get(c);(p?p.group===null&&p.content===null:!1)&&e.current.delete(c)}},[n]),s=l.useCallback((c,d)=>{const u=n(c);if(u.content=d,d===null){const p=e.current.get(c);(p?p.group===null&&p.tabbar===null:!1)&&e.current.delete(c)}},[n]),a=l.useCallback(()=>e.current,[]),i=l.useMemo(()=>({setGroupEl:r,setTabbarEl:o,setContentEl:s,getAll:a}),[r,o,s,a]);return b.jsx(pt.Provider,{value:i,children:t})},Yt={display:"flex",flexDirection:"column",width:"100%",height:"100%"},qt={flex:"1 1 auto",minWidth:0,minHeight:0,position:"relative",overflow:"hidden"};function Ut(t,e,n,r){return t?l.cloneElement(t,n,r):e?b.jsx(e,{...n,children:r}):b.jsx("div",{...n,children:r})}function Vt(t,e,n,r){return t?l.cloneElement(t,n,r):e?b.jsx(e,{...n,children:r}):b.jsx("div",{...n,children:r})}const Kt=({group:t,tabbar:e,content:n,onContentPointerDown:r,groupRef:o,contentRef:s,component:a,element:i,contentComponent:c,contentElement:d})=>{const u={ref:o,style:Yt,"data-group-id":t.id},g=Ut(d,c,{ref:s,style:qt,"data-dnd-zone":"content",onPointerDown:r},n),v=b.jsxs(b.Fragment,{children:[e,g]});return Vt(i,a,u,v)},gt=l.memo(Kt,(t,e)=>t.group.id!==e.group.id||t.group.activeTabId!==e.group.activeTabId||t.group.tabs.length!==e.group.tabs.length?!1:t.group.tabs===e.group.tabs);gt.displayName="PanelGroupView";const q=(t,e,n)=>{const r=t.left,o=t.top,s=t.width,a=t.height,i=e-r,c=n-o,d=s/3,u=a/3;return i>d&&i<s-d&&c>u&&c<a-u?"center":i<c&&i<s-i&&c<a-c?"left":s-i<c&&s-i<i&&c<a-c?"right":c<i&&c<a-c&&i<s-i?"top":"bottom"};function k(t,e){if(!e){const r=(()=>({type:t}));return Object.defineProperty(r,"type",{value:t,writable:!1,enumerable:!0}),r}const n=((...r)=>{const o=e(...r);return typeof o>"u"?{type:t}:{type:t,payload:o}});return Object.defineProperty(n,"type",{value:t,writable:!1,enumerable:!0}),n}const Wt=(t,e)=>{const n={};return Object.keys(t).forEach(r=>{const o=t[r];n[r]=((...s)=>{const a=o(...s);return e(a),a})}),n},bt=(t,e)=>{const n={};return Object.keys(e).forEach(r=>{const o=e[r];if(!o)return;const s=t[r];if(!s)throw new Error(`Missing action creator for key "${String(r)}"`);n[s.type]=o}),n},ht={phase:{kind:"idle"},suggest:null,pointer:null,tabbarHover:null,draggingTabElement:null},A={startContent:k("START_CONTENT",t=>t),startTab:k("START_TAB",t=>t),setSuggest:k("SET_SUGGEST",t=>t),setPointer:k("SET_POINTER",t=>t),setTabbarHover:k("SET_TABBAR_HOVER",t=>t),reset:k("RESET")},Zt=bt(A,{startContent:(t,e)=>({phase:{kind:"content",startX:e.payload.x,startY:e.payload.y,fromGroupId:e.payload.groupId,tabId:e.payload.tabId,cache:e.payload.cache},suggest:null,pointer:null,tabbarHover:null,draggingTabElement:null}),startTab:(t,e)=>({phase:{kind:"tab",startX:e.payload.x,startY:e.payload.y,fromGroupId:e.payload.groupId,tabId:e.payload.tabId,cache:e.payload.cache},suggest:null,pointer:null,tabbarHover:null,draggingTabElement:e.payload.element}),setSuggest:(t,e)=>({...t,suggest:e.payload}),setPointer:(t,e)=>({...t,pointer:e.payload}),setTabbarHover:(t,e)=>({...t,tabbarHover:e.payload}),reset:()=>ht}),Jt=(t,e)=>{const n=Zt[e.type];return n?n(t,e,void 0):t},mt=l.createContext(null),K=()=>{const t=l.useContext(mt);if(!t)throw new Error("usePanelInteractions must be used within InteractionsProvider");return t},Qt=({containerRef:t,dragThresholdPx:e,onCommitContentDrop:n,onCommitTabDrop:r,isContentZoneAllowed:o,children:s})=>{const[a,i]=l.useReducer(Jt,ht),c=ft(),d=l.useCallback(()=>{const I=Array.from(c.getAll().entries()),y=I.map(([f,S])=>({gid:f,el:S.content??S.group})).filter(f=>!!f.el).map(f=>({...f,rect:f.el.getBoundingClientRect()})),h=I.map(([f,S])=>({gid:f,el:S.tabbar})).filter(f=>!!f.el).map(f=>({...f,rect:f.el.getBoundingClientRect()})),w=I.map(([f,S])=>({gid:f,el:S.content??S.group})).filter(f=>!!f.el).map(f=>({...f,rect:f.el.getBoundingClientRect()}));return{groups:y,tabbars:h,contents:w}},[c]),u=G.useEffectEvent(I=>{if(!t.current)return;const h=I.clientX,w=I.clientY,f=a.phase;if(f.kind==="idle")return;const S=Math.abs(h-f.startX),C=Math.abs(w-f.startY);if(S<e&&C<e){a.phase.kind==="content"&&i(A.setSuggest(null)),i(A.setPointer(null)),i(A.setTabbarHover(null));return}if(i(A.setPointer({x:h,y:w})),f.kind==="content"){const E=f.cache.groups.find(({rect:T})=>h>=T.left&&h<=T.right&&w>=T.top&&w<=T.bottom);if(!E){i(A.setSuggest(null));return}const D=q(E.rect,h,w);if(o&&!o({targetGroupId:E.gid,zone:D})){i(A.setSuggest(null));return}i(A.setSuggest({rect:E.rect,zone:D}));return}if(f.kind==="tab"){const E=f.cache.tabbars.find(({rect:R})=>h>=R.left&&h<=R.right&&w>=R.top&&w<=R.bottom);if(E){const _=Array.from(E.el.querySelectorAll("[role='tab']")).map(H=>H.getBoundingClientRect()),j=_.map(H=>H.left+H.width/2),O=j.findIndex(H=>h<H),N=O===-1?j.length:O,Ct=_.length===0?E.rect.left+8:N===0?_[0].left:N===_.length?_[_.length-1].right:(_[N-1].right+_[N].left)/2;i(A.setTabbarHover({groupId:E.gid,index:N,rect:E.rect,insertX:Ct}))}else i(A.setTabbarHover(null));const D=f.cache.contents.find(({rect:R})=>h>=R.left&&h<=R.right&&w>=R.top&&w<=R.bottom);if(!D){i(A.setSuggest(null));return}const T=q(D.rect,h,w);if(o&&!o({targetGroupId:D.gid,zone:T})){i(A.setSuggest(null));return}i(A.setSuggest({rect:D.rect,zone:T}))}}),p=G.useEffectEvent(I=>{const y=t.current,h=a;if(i(A.reset()),!y)return;const w=I.clientX,f=I.clientY;if(h.phase.kind==="idle")return;const S=Math.abs(w-h.phase.startX),C=Math.abs(f-h.phase.startY);if(!(S<e&&C<e)){if(h.phase.kind==="content"){const E=h.phase.cache.groups.find(({rect:R})=>w>=R.left&&w<=R.right&&f>=R.top&&f<=R.bottom);if(!E)return;const D=E.gid??null;if(!D)return;const T=q(E.rect,w,f);if(o&&!o({targetGroupId:D,zone:T}))return;n({fromGroupId:h.phase.fromGroupId,tabId:h.phase.tabId,targetGroupId:D,zone:T});return}if(h.phase.kind==="tab"){const E=h.phase.cache.tabbars.find(({rect:T})=>w>=T.left&&w<=T.right&&f>=T.top&&f<=T.bottom);if(E){const T=E.gid;if(!T)return;const _=Array.from(E.el.querySelectorAll("[role='tab']")).map(N=>{const Z=N.getBoundingClientRect();return Z.left+Z.width/2}),j=_.findIndex(N=>w<N),O=j===-1?_.length:j;r({fromGroupId:h.phase.fromGroupId,tabId:h.phase.tabId,targetGroupId:T,targetIndex:O});return}const D=h.phase.cache.contents.find(({rect:T})=>w>=T.left&&w<=T.right&&f>=T.top&&f<=T.bottom);if(D){const T=D.gid??null;if(!T)return;const R=q(D.rect,w,f);if(o&&!o({targetGroupId:T,zone:R}))return;n({fromGroupId:h.phase.fromGroupId,tabId:h.phase.tabId,targetGroupId:T,zone:R})}}}}),g=G.useEffectEvent(()=>{i(A.reset())});l.useEffect(()=>{if(a.phase.kind!=="idle")return window.addEventListener("pointermove",u),window.addEventListener("pointerup",p,{once:!0}),window.addEventListener("pointercancel",g,{once:!0}),()=>{window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",g)}},[a.phase.kind]);const v=l.useCallback((I,y,h)=>{if(h.button!==0)return;h.currentTarget.setPointerCapture(h.pointerId);const w=d();i(A.startContent({x:h.clientX,y:h.clientY,groupId:I,tabId:y,cache:w}))},[d]),m=l.useCallback((I,y,h)=>{if(h.button!==0)return;const w=h.currentTarget;w&&w.setPointerCapture(h.pointerId);const f=d();i(A.startTab({x:h.clientX,y:h.clientY,groupId:y,tabId:I,cache:f,element:w}))},[d]),x=l.useMemo(()=>({suggest:a.suggest,isTabDragging:a.phase.kind==="tab",draggingTabId:a.phase.kind==="tab"?a.phase.tabId:null,dragPointer:a.pointer,tabbarHover:a.tabbarHover,draggingTabElement:a.draggingTabElement,onStartContentDrag:v,onStartTabDrag:m}),[a.suggest,a.pointer,a.tabbarHover,a.phase,a.draggingTabElement,v,m]);return b.jsx(mt.Provider,{value:x,children:s})},ot={display:"inline-flex",alignItems:"center",userSelect:"none"},te=({groupId:t,tab:e,active:n,dragging:r,onClickTab:o,onStartDrag:s,onCloseTab:a,tabComponent:i,tabElement:c,onDoubleClick:d})=>{const u=l.useEffectEvent(()=>{o(e.id)}),p=l.useEffectEvent(x=>{s&&x.button===0&&s(e.id,t,x)}),g=()=>{const x=!!a;return b.jsx(l.Activity,{mode:x?"visible":"hidden",children:b.jsx("button",{type:"button","aria-label":`Close tab ${e.title}`,onClick:I=>{a&&(I.stopPropagation(),a(t,e.id))},style:{marginLeft:6},tabIndex:x?void 0:-1,disabled:!x,"aria-hidden":x?void 0:!0,children:"×"})})},v={role:"tab","aria-selected":n,tabIndex:n?0:-1,style:ot,onClick:u,onPointerDown:p,onDoubleClick:d,"data-tab-id":e.id,"data-active":n?"true":"false","data-dragging":r?"true":"false",children:b.jsxs(b.Fragment,{children:[b.jsx("span",{children:e.title}),g()]})},m={type:"button",role:"tab","aria-selected":n,tabIndex:n?0:-1,style:ot,onClick:()=>{o(e.id)},onPointerDown:x=>{s&&x.button===0&&s(e.id,t,x)},onDoubleClick:d,children:b.jsx("span",{children:e.title})};return c?c(m):i?b.jsx(i,{...m}):b.jsx("div",{...v})},ee={display:"flex",alignItems:"center"},ne={flex:"1 1 auto",alignSelf:"stretch"},re=({group:t,onClickTab:e,onStartDrag:n,rootRef:r,component:o,element:s,tabComponent:a,tabElement:i,onAddTab:c,onCloseTab:d,doubleClickToAdd:u})=>{const{isTabDragging:p,draggingTabId:g}=K(),v=l.useRef(null),m=l.useCallback(f=>{if(v.current=f,!!r){if(typeof r=="function"){r(f);return}try{r.current=f}catch{}}},[r]),x=l.useEffectEvent(f=>{const S=v.current??f.currentTarget;if(!S)return;const C=Array.from(S.querySelectorAll('[role="tab"]'));if(C.length===0)return;const E=j=>{const O=Math.max(0,Math.min(j,C.length-1)),N=C[O];N&&N.focus()},D=document.activeElement,T=D?C.indexOf(D):C.findIndex(j=>j.getAttribute("data-tab-id")===t.activeTabId);if(f.key==="ArrowRight"){f.preventDefault();const j=T>=0?T+1:0;E(j>=C.length?0:j);return}if(f.key==="ArrowLeft"){f.preventDefault();const j=T>=0?T-1:C.length-1;E(j<0?C.length-1:j);return}if(f.key==="Home"){f.preventDefault(),E(0);return}if(f.key==="End"){f.preventDefault(),E(C.length-1);return}if(f.key==="Enter"||f.key===" "){f.preventDefault();const O=(T>=0?C[T]:null)?.getAttribute("data-tab-id")??null;O&&e(O);return}if(f.key==="Delete"||f.key==="Backspace"){if(d){f.preventDefault();const O=(T>=0?C[T]:null)?.getAttribute("data-tab-id")??null;O&&d(t.id,O)}return}const R=(f.ctrlKey?1:0)+(f.metaKey?1:0)>0,_=typeof f.key=="string"?f.key.toLowerCase():"";if(R&&_==="t"){c&&(f.preventDefault(),c(t.id));return}});l.useEffect(()=>{const f=v.current;if(!f)return;const S=f.querySelector(`[role="tab"][data-tab-id="${t.activeTabId}"]`);if(S===document.activeElement)return;!f.contains(document.activeElement)&&S&&S.focus()},[t.activeTabId]);const I={style:ee,role:"tablist","data-tabbar":"true","data-group-id":t.id,"data-dragging":p?"true":"false",onKeyDown:x},y=G.useElementComponentWrapper({element:s,component:o}),h=()=>c?b.jsx("button",{type:"button","aria-label":"Add tab",onClick:()=>{c(t.id)},children:"+"}):null,w=l.useCallback(()=>{u&&c&&c(t.id)},[u,c,t.id]);return b.jsxs(y,{...I,ref:m,onDoubleClick:w,children:[t.tabs.map((f,S)=>b.jsx(te,{groupId:t.id,tab:f,active:t.activeTabId===f.id,dragging:g===f.id,onClickTab:e,onStartDrag:n,onCloseTab:d,tabComponent:a,tabElement:i,onDoubleClick:C=>C.stopPropagation()},`${t.id}:${f.id}:${S}`)),b.jsx("span",{style:ne}),h()]})},oe=({id:t,TabBarComponent:e,PanelGroupComponent:n})=>{const{getGroup:r,getGroupContent:o,onClickTab:s,onAddTab:a,onCloseTab:i,onStartTabDrag:c,doubleClickToAdd:d,registerContentContainer:u}=$t(),{setGroupEl:p,setTabbarEl:g,setContentEl:v}=ft(),m=l.useCallback(S=>{p(t,S)},[t,p]),x=l.useCallback(S=>{v(t,S),u(t,S)},[t,v,u]),I=l.useCallback(S=>{g(t,S)},[t,g]),y=r(t);if(!y)return null;const h=o(t),w=e??re,f=n??(S=>b.jsx(gt,{...S}));return b.jsx(f,{group:y,tabbar:b.jsx(w,{rootRef:I,group:y,onClickTab:S=>s(t,S),onAddTab:a,onCloseTab:i,onStartDrag:(S,C,E)=>c(S,C,E),doubleClickToAdd:d}),content:h,groupRef:m,contentRef:x})},se=(t,e)=>{const n=new Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++)n[r*4+o]=t[0+o]*e[r*4+0]+t[4+o]*e[r*4+1]+t[8+o]*e[r*4+2]+t[12+o]*e[r*4+3];return n},U=t=>{if(t.length!==16)throw new Error("Matrix must have exactly 16 values");const e=Object.freeze([...t]),n=r=>{const o=se(e,r);return U(o)};return Object.freeze({translate:(r=0,o=0,s=0)=>n([1,0,0,0,0,1,0,0,0,0,1,0,r,o,s,1]),translate3d:(r,o,s)=>n([1,0,0,0,0,1,0,0,0,0,1,0,r,o,s,1]),translateX:r=>n([1,0,0,0,0,1,0,0,0,0,1,0,r,0,0,1]),translateY:r=>n([1,0,0,0,0,1,0,0,0,0,1,0,0,r,0,1]),translateZ:r=>n([1,0,0,0,0,1,0,0,0,0,1,0,0,0,r,1]),scale:(r=1,o=1,s=1)=>n([r,0,0,0,0,o,0,0,0,0,s,0,0,0,0,1]),scale3d:(r,o,s)=>n([r,0,0,0,0,o,0,0,0,0,s,0,0,0,0,1]),scaleX:r=>n([r,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),scaleY:r=>n([1,0,0,0,0,r,0,0,0,0,1,0,0,0,0,1]),scaleZ:r=>n([1,0,0,0,0,1,0,0,0,0,r,0,0,0,0,1]),rotateX:r=>{const o=Math.cos(r),s=Math.sin(r);return n([1,0,0,0,0,o,s,0,0,-s,o,0,0,0,0,1])},rotateY:r=>{const o=Math.cos(r),s=Math.sin(r);return n([o,0,-s,0,0,1,0,0,s,0,o,0,0,0,0,1])},rotateZ:r=>{const o=Math.cos(r),s=Math.sin(r);return n([o,s,0,0,-s,o,0,0,0,0,1,0,0,0,0,1])},rotate:(r,o,s,a)=>{const i=Math.sqrt(o*o+s*s+a*a);if(i===0)return U(e);o/=i,s/=i,a/=i;const c=Math.cos(r),d=Math.sin(r),u=1-c;return n([u*o*o+c,u*o*s+d*a,u*o*a-d*s,0,u*o*s-d*a,u*s*s+c,u*s*a+d*o,0,u*o*a+d*s,u*s*a-d*o,u*a*a+c,0,0,0,0,1])},rotate3d:(r,o,s,a)=>{const i=Math.sqrt(r*r+o*o+s*s);if(i===0)return U(e);r/=i,o/=i,s/=i;const c=Math.cos(a),d=Math.sin(a),u=1-c;return n([u*r*r+c,u*r*o+d*s,u*r*s-d*o,0,u*r*o-d*s,u*o*o+c,u*o*s+d*r,0,u*r*s+d*o,u*o*s-d*r,u*s*s+c,0,0,0,0,1])},skew:(r=0,o=0)=>{const s=Math.tan(r),a=Math.tan(o);return n([1,a,0,0,s,1,0,0,0,0,1,0,0,0,0,1])},skewX:r=>{const o=Math.tan(r);return n([1,0,0,0,o,1,0,0,0,0,1,0,0,0,0,1])},skewY:r=>{const o=Math.tan(r);return n([1,o,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},perspective:r=>{if(r===0)throw new Error("Perspective distance cannot be zero");return n([1,0,0,0,0,1,0,0,0,0,1,-1/r,0,0,0,1])},toCSS:()=>`matrix3d(${e.join(", ")})`,toArray:()=>e,toString:()=>[`[${e[0]}, ${e[4]}, ${e[8]}, ${e[12]}]`,`[${e[1]}, ${e[5]}, ${e[9]}, ${e[13]}]`,`[${e[2]}, ${e[6]}, ${e[10]}, ${e[14]}]`,`[${e[3]}, ${e[7]}, ${e[11]}, ${e[15]}]`].join(`
|
|
2
|
+
`)})},ie=()=>U([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ae={position:"fixed",inset:0,pointerEvents:"none",zIndex:P.DROP_SUGGEST_Z_INDEX},ce={position:"absolute",border:`${P.DROP_SUGGEST_BORDER_WIDTH} dashed ${P.DROP_SUGGEST_BORDER_COLOR}`,background:P.DROP_SUGGEST_BG_COLOR,borderRadius:P.DROP_SUGGEST_BORDER_RADIUS,transformOrigin:"top left"},L=(t,e)=>e<=0?0:G.clampNumber(t/e,0),ue=(t,e,n)=>{const{width:r,height:o}=t,s=n/2,a=r>0?r:1,i=o>0?o:1,c={translateX:n,translateY:n,scaleX:L(G.clampNumber(r-n*2,0),a),scaleY:L(G.clampNumber(o-n*2,0),i)},d={translateX:n,translateY:n,scaleX:L(G.clampNumber(r/2-n*1.5,0),a),scaleY:L(G.clampNumber(o-n*2,0),i)},u={translateX:r/2+s,translateY:n,scaleX:L(G.clampNumber(r/2-n*1.5,0),a),scaleY:L(G.clampNumber(o-n*2,0),i)},p={translateX:n,translateY:n,scaleX:L(G.clampNumber(r-n*2,0),a),scaleY:L(G.clampNumber(o/2-n*1.5,0),i)},g={translateX:n,translateY:o/2+s,scaleX:L(G.clampNumber(r-n*2,0),a),scaleY:L(G.clampNumber(o/2-n*1.5,0),i)},v={center:c,left:d,right:u,top:p,bottom:g},{translateX:m,translateY:x,scaleX:I,scaleY:y}=v[e];return ie().translate(m,x,0).scale(I,y,1).toCSS()},le=(t,e)=>{const n=P.DROP_SUGGEST_PADDING_PX;return{...ce,left:t.left,top:t.top,width:t.width,height:t.height,transform:ue(t,e,n)}},de=({suggest:t})=>{if(!t)return null;const{rect:e,zone:n}=t,r=le(e,n);return b.jsx("div",{style:ae,children:b.jsx("div",{style:r})})},pe=typeof window<"u"&&typeof document<"u",fe=t=>{const[e,n]=l.useState(null),[r,o]=l.useState(null);return tt.useIsomorphicLayoutEffect(()=>{if(!pe||!t){n(null),o(null);return}const s=t.getBoundingClientRect();n({width:s.width,height:s.height}),o(t.outerHTML)},[t]),{html:r,size:e}},ge={position:"fixed",inset:0,pointerEvents:"none",zIndex:P.TAB_DRAG_OVERLAY_Z_INDEX},be={position:"absolute",width:P.TAB_DRAG_INSERT_GUIDE_WIDTH,borderRadius:P.TAB_DRAG_INSERT_GUIDE_BORDER_RADIUS,background:P.TAB_DRAG_INSERT_GUIDE_COLOR,boxShadow:P.TAB_DRAG_INSERT_GUIDE_SHADOW},he=()=>{const{isTabDragging:t,draggingTabId:e,dragPointer:n,tabbarHover:r,draggingTabElement:o}=K(),{html:s,size:a}=fe(o),i=n!==null&&e!==null,c=l.useMemo(()=>{if(!(!i||!n))return{position:"absolute",left:n.x,top:n.y,transform:`translate(${P.TAB_DRAG_PREVIEW_OFFSET_X}, ${P.TAB_DRAG_PREVIEW_OFFSET_Y})`,pointerEvents:"none"}},[i,n]),d=l.useMemo(()=>{if(!(!c||!o))return a?{...c,width:a.width,height:a.height}:c},[c,o,a]),u=l.useMemo(()=>{if(r)return{...be,left:r.insertX,top:r.rect.top+4,height:Math.max(0,r.rect.height-8)}},[r]);return t?b.jsxs("div",{style:ge,children:[b.jsx(l.Activity,{mode:d?"visible":"hidden",children:b.jsx("div",{style:d,children:b.jsx("div",{style:{width:"100%",height:"100%",pointerEvents:"none"},dangerouslySetInnerHTML:{__html:s??""}})})}),b.jsx(l.Activity,{mode:u?"visible":"hidden",children:b.jsx("div",{style:u})})]}):null},M=t=>t.type==="group",X=(t,e=[])=>{if(M(t))return[...e,t.groupId];const n=X(t.a,e);return X(t.b,n)},W=(t,e)=>e.reduce((n,r)=>M(n)?n:n[r],t),Y=(t,e,n)=>{if(e.length===0)return n;const[r,...o]=e;return M(t)?t:r==="a"?{...t,a:Y(t.a,o,n)}:{...t,b:Y(t.b,o,n)}},V=(t,e,n=[])=>{if(M(t))return t.groupId===e?{splitPath:null,side:null}:null;if(M(t.a)&&t.a.groupId===e)return{splitPath:n,side:"a"};if(M(t.b)&&t.b.groupId===e)return{splitPath:n,side:"b"};const r=V(t.a,e,[...n,"a"]);return r||V(t.b,e,[...n,"b"])},vt=(t,e,n,r)=>{const o=r(),s=V(t,e),a={type:"split",direction:n,ratio:.5,a:{type:"group",groupId:e},b:{type:"group",groupId:o}};if(!s||s.splitPath===null)return{tree:a,newGroupId:o};const i=s.splitPath,c=W(t,i);if(M(c))return{tree:a,newGroupId:o};const d=s.side==="a"?{...c,a}:{...c,b:a};return{tree:Y(t,i,d),newGroupId:o}},me=(t,e)=>{const n=V(t,e);if(!n||n.splitPath===null)return{tree:t,survivorGroupId:e};const r=n.splitPath,o=W(t,r);if(M(o))return{tree:t,survivorGroupId:e};const s=n.side==="a"?o.b:o.a,a=Y(t,r,s),i=M(s)?s.groupId:X(s)[0]??null;return{tree:a,survivorGroupId:i}},ve=(t,e,n)=>{const r=W(t,e);if(M(r))return t;const o={...r,ratio:G.clampNumber(n,.05,.95)};return Y(t,e,o)},J=t=>{if(Object.keys(t.groups).filter(o=>t.groups[o].tabIds.length===0).length===0)return t;const r=(o,s)=>{const a=o.groups[s];if(!a||a.tabs.length>0||Object.keys(o.groups).length<=1)return o;const{tree:c,survivorGroupId:d}=me(o.tree,s),{[s]:u,...p}=o.groups,g=X(c),v=o.focusedGroupId===s?d??g[0]??null:o.focusedGroupId;return{...o,tree:c,groups:p,groupOrder:g,focusedGroupId:v}};return t.groupOrder.reduce((o,s)=>r(o,s),t)},we=t=>({id:t,tabIds:[],tabs:[],activeTabId:null}),st=(t,e,n,r)=>{const o={...t.groups},s=o[e];if(!s)throw new Error(`Group ${e} does not exist.`);const a={...t.panels,[n.id]:n},i=[...s.tabIds,n.id],c=r?n.id:s.activeTabId??n.id,d=i.map(p=>a[p]),u={...s,tabIds:i,tabs:d,activeTabId:c};return o[e]=u,{...t,panels:a,groups:o}},Ie=(t,e,n)=>{const r={...t.groups},o=r[e];if(!o)throw new Error(`Group ${e} does not exist.`);const s=o.tabIds.filter(c=>c!==n),a=s.map(c=>t.panels[c]),i=o.activeTabId===n?s[0]??null:o.activeTabId;return r[e]={...o,tabIds:s,tabs:a,activeTabId:i},{...t,groups:r}},it=(t,e,n,r,o)=>{const s=t.groups[e],a=t.groups[n];if(!s||!a)throw new Error("moveTab: source or target group is missing.");const i={...t.groups},c=s.tabIds.filter(p=>p!==r),d=[...a.tabIds.filter(p=>p!==r),r],u=s.activeTabId===r?c[0]??null:s.activeTabId;return i[e]={...s,tabIds:c,tabs:c.map(p=>t.panels[p]),activeTabId:u},i[n]={...a,tabIds:d,tabs:d.map(p=>t.panels[p]),activeTabId:r},{...t,groups:i}},wt=(t,e,n)=>{const r=t.groups[e];if(!r)throw new Error(`setActiveTab: group ${e} not found.`);if(!r.tabIds.some(s=>s===n))throw new Error(`setActiveTab: tab ${n} not found in group ${e}.`);const o={...t.groups,[e]:{...r,activeTabId:n}};return{...t,groups:o,focusedGroupId:e}},at=(t,e,n,r,o)=>{const s=t.groups[e];if(!s)throw new Error(`addTabToGroupAtIndex: group ${e} not found.`);const a={...t.panels,[n.id]:n},i=s.tabIds.slice(),c=Math.max(0,Math.min(r,i.length));i.splice(c,0,n.id);const d=i.map(g=>a[g]),u=o?n.id:s.activeTabId??n.id,p={...t.groups,[e]:{...s,tabIds:i,tabs:d,activeTabId:u}};return{...t,panels:a,groups:p}},B=(t,e)=>{if(!t.groups[e])throw new Error(`setFocusedGroup: group ${e} not found.`);return{...t,focusedGroupId:e}},xe=(t,e)=>{const n=e-1,r=t.groupOrder[n];return r?B(t,r):t},ye=t=>{const e=t.groupOrder,n=t.focusedGroupId;if(!n){const s=e[0];return s?B(t,s):t}const r=e.indexOf(n),o=e[(r+1)%e.length];return B(t,o)},Se=t=>{const e=t.groupOrder,n=t.focusedGroupId;if(!n){const s=e[e.length-1];return s?B(t,s):t}const r=e.indexOf(n),o=e[(r-1+e.length)%e.length];return B(t,o)},It=(t,e,n,r)=>{const{tree:o,newGroupId:s}=vt(t.tree,e,n,r),a={...t.groups,[s]:we(s)},i=X(o);return{...t,tree:o,groups:a,groupOrder:i,focusedGroupId:s}},Te=t=>{const n={type:"group",groupId:"g_1"},r=Object.fromEntries(t.map(i=>[i.id,i])),s={g_1:{id:"g_1",tabIds:t.map(i=>i.id),tabs:t,activeTabId:t[0]?.id??null}};return{tree:n,panels:r,groups:s,groupOrder:["g_1"],focusedGroupId:"g_1"}},Ge=l.createContext(null),Ee=({value:t,children:e})=>b.jsx(Ge.Provider,{value:t,children:e}),xt=l.createContext(null),Ce=()=>{const t=l.useContext(xt);if(!t)throw new Error("useTree must be used within TreeProvider");return t},Re=({value:t,children:e})=>b.jsx(xt.Provider,{value:t,children:e}),Pe=l.createContext(null),De=({value:t,children:e})=>b.jsx(Pe.Provider,{value:t,children:e}),$=t=>{const e=G.toFiniteNumberOr(t,Number.POSITIVE_INFINITY);return G.clampNumber(e,1)},je=t=>typeof t=="object"&&t!==null,Ae=t=>je(t)?"rows"in t?!0:"cols"in t:!1,yt=t=>{if(!t)return{rows:Number.POSITIVE_INFINITY,cols:Number.POSITIVE_INFINITY};if(typeof t=="number"){const n=$(t);return{rows:n,cols:n}}if(Ae(t))return{rows:$(t.rows),cols:$(t.cols)};const e=t;return{rows:$(e.maxHorizontal),cols:$(e.maxVertical)}},Q=t=>{if(M(t))return{horizontal:1,vertical:1};const e=Q(t.a),n=Q(t.b);return t.direction==="horizontal"?{horizontal:e.horizontal+n.horizontal,vertical:Math.max(e.vertical,n.vertical)}:{horizontal:Math.max(e.horizontal,n.horizontal),vertical:e.vertical+n.vertical}},ke=(t,e,n)=>{const{tree:r}=vt(t,e,n,()=>"__preview__");return r},et=(t,e,n,r)=>{if(!Number.isFinite(r.rows)&&!Number.isFinite(r.cols))return!0;const o=ke(t,e,n),s=Q(o);return!(s.horizontal>r.rows||s.vertical>r.cols)},St={splitFocused:k("panelState/splitFocused",t=>({direction:t})),focusGroupIndex:k("panelState/focusGroupIndex",t=>({index1Based:t})),focusNextGroup:k("panelState/focusNextGroup"),focusPrevGroup:k("panelState/focusPrevGroup"),setActiveTab:k("panelState/setActiveTab",(t,e)=>({groupId:t,tabId:e})),addTab:k("panelState/addTab",t=>t),addNewTab:k("panelState/addNewTab",t=>t),removeTab:k("panelState/removeTab",(t,e)=>({groupId:t,tabId:e})),contentDrop:k("panelState/contentDrop",t=>t),tabDrop:k("panelState/tabDrop",t=>t),adjustSplitRatio:k("panelState/adjustSplitRatio",t=>t)},_e=(t,e,n)=>{const r=t.groups[e.fromGroupId],o=t.groups[e.targetGroupId];if(!r||!o||!r.tabs.find(p=>p.id===e.tabId))return t;if(e.zone==="center"&&e.fromGroupId===e.targetGroupId)return wt(t,e.fromGroupId,e.tabId);if(e.zone==="center"){const p=it(t,e.fromGroupId,e.targetGroupId,e.tabId);return B(p,e.targetGroupId)}const a=e.zone==="left"||e.zone==="right"?"vertical":"horizontal";if(!et(t.tree,e.targetGroupId,a,n.splitLimits))return t;const i=n.createGroupId(),c=It(t,e.targetGroupId,a,()=>i),d=e.zone==="left"||e.zone==="top"?e.targetGroupId:i,u=it(c,e.fromGroupId,d,e.tabId);return B(u,d)},Me=(t,e)=>{const n=t.groups[e.fromGroupId],r=t.groups[e.targetGroupId];if(!n||!r||!t.panels[e.tabId])return t;if(e.fromGroupId===e.targetGroupId){const g=n.tabIds.filter(y=>y!==e.tabId),v=Math.max(0,Math.min(e.targetIndex,g.length)),m=g.slice(0,v).concat([e.tabId],g.slice(v)),x=m.map(y=>t.panels[y]).filter(Boolean),I={...t.groups,[e.fromGroupId]:{...n,tabIds:m,tabs:x}};return{...t,groups:I}}const s={...t.groups},a=n.tabIds.filter(g=>g!==e.tabId),i=a.map(g=>t.panels[g]);s[e.fromGroupId]={...n,tabIds:a,tabs:i,activeTabId:n.activeTabId===e.tabId?i[0]?.id??null:n.activeTabId};const c=r.tabIds.filter(g=>g!==e.tabId),d=Math.max(0,Math.min(e.targetIndex,c.length)),u=c.slice(0,d).concat([e.tabId],c.slice(d)),p=u.map(g=>t.panels[g]).filter(Boolean);return s[e.targetGroupId]={...r,tabIds:u,tabs:p,activeTabId:e.tabId},{...t,groups:s,focusedGroupId:e.targetGroupId}},Oe=bt(St,{splitFocused:(t,e,n)=>{const r=t.focusedGroupId??t.groupOrder[0]??null;return!r||!et(t.tree,r,e.payload.direction,n.splitLimits)?t:It(t,r,e.payload.direction,n.createGroupId)},focusGroupIndex:(t,e)=>xe(t,e.payload.index1Based),focusNextGroup:t=>ye(t),focusPrevGroup:t=>Se(t),setActiveTab:(t,e)=>wt(t,e.payload.groupId,e.payload.tabId),addTab:(t,e)=>{const{groupId:n,tab:r,index:o,makeActive:s}=e.payload;return typeof o=="number"?at(t,n,r,o,s??!0):st(t,n,r,s??!0)},addNewTab:(t,e,n)=>{if(!n.createPanelId)throw new Error("addNewTab requires PanelSystemProvider.createPanelId");const o={id:n.createPanelId(),title:e.payload.title,render:()=>e.payload.title},{groupId:s,index:a,makeActive:i}=e.payload;return typeof a=="number"?at(t,s,o,a,i??!0):st(t,s,o,i??!0)},removeTab:(t,e)=>Ie(t,e.payload.groupId,e.payload.tabId),contentDrop:(t,e,n)=>_e(t,e.payload,n),tabDrop:(t,e)=>Me(t,e.payload),adjustSplitRatio:(t,e)=>{const n=W(t.tree,e.payload.path);if(M(n))return t;const r=ve(t.tree,e.payload.path,n.ratio+e.payload.deltaRatio);return{...t,tree:r}}}),ct=(t,e,n)=>{const r=Oe[e.type];if(!r)return t;const o=r(t,e,n);return J(o)},Tt=l.createContext(null),z=()=>{const t=l.useContext(Tt);if(!t)throw new Error("usePanelSystem must be used within PanelSystemProvider");return t},Ne=({initialState:t,createGroupId:e,createPanelId:n,state:r,onStateChange:o,splitLimits:s,children:a})=>{const i=l.useMemo(()=>J(t),[t]),c=l.useMemo(()=>yt(s),[s]),d=l.useRef({createGroupId:e,splitLimits:c,createPanelId:n});d.current.createGroupId=e,d.current.splitLimits=c,d.current.createPanelId=n;const[u,p]=l.useReducer((S,C)=>ct(S,C,d.current),i),g=l.useMemo(()=>r?J(r):u,[r,u]),v=l.useRef(g);v.current=g;const m=r!==void 0,x=l.useCallback(S=>{if(m){const C=ct(v.current,S,d.current);o?.(C);return}p(S)},[m,o,p]),I=l.useMemo(()=>Wt(St,x),[x]),y=l.useMemo(()=>({setActiveTab:I.setActiveTab,tabDrop:I.tabDrop}),[I]),h=l.useMemo(()=>({adjustSplitRatio:I.adjustSplitRatio}),[I]),w=l.useMemo(()=>({focusGroupIndex:I.focusGroupIndex,focusNextGroup:I.focusNextGroup,focusPrevGroup:I.focusPrevGroup}),[I]),f=l.useMemo(()=>({state:g,dispatch:x,actions:I}),[g,x,I]);return b.jsx(Tt.Provider,{value:f,children:b.jsx(Ee,{value:y,children:b.jsx(Re,{value:h,children:b.jsx(De,{value:w,children:a})})})})},Le=()=>{const{actions:t}=z();return l.useMemo(()=>({splitFocused:e=>{t.splitFocused(e)},focusGroupIndex:e=>{t.focusGroupIndex(e)},focusNextGroup:()=>{t.focusNextGroup()},focusPrevGroup:()=>{t.focusPrevGroup()},closeFocusedGroup:()=>{}}),[t])},Be=()=>{const{actions:t}=z(),e=l.useCallback(({fromGroupId:r,tabId:o,targetGroupId:s,zone:a})=>{t.contentDrop({fromGroupId:r,tabId:o,targetGroupId:s,zone:a})},[t]),n=l.useCallback(({fromGroupId:r,tabId:o,targetGroupId:s,targetIndex:a})=>{t.tabDrop({fromGroupId:r,tabId:o,targetGroupId:s,targetIndex:a})},[t]);return{onCommitContentDrop:e,onCommitTabDrop:n}},He=()=>{const t=Mt(),e=Le();return l.useEffect(()=>{Lt(t,e)},[t,e]),null},Gt=l.createContext(null),ze=()=>{const t=l.useContext(Gt);if(!t)throw new Error("useContentRegistry must be used within ContentRegistryProvider");return t},$e=t=>{const e=document.createElement("div");return e.setAttribute("data-panel-wrapper",t),e.style.display="contents",e},Fe=(t,e,n)=>{const[r]=l.useState(()=>$e(t));return tt.useIsomorphicLayoutEffect(()=>(r.style.display=n?"contents":"none",e&&r.parentElement!==e&&e.appendChild(r),()=>{r.parentElement?.removeChild(r)}),[r,e,n]),r},Et=l.memo(({panelId:t,content:e,placement:n,containerElement:r})=>{const o=n?.isActive??!1,s=Fe(t,r,o);return Pt.createPortal(b.jsx(l.Activity,{mode:o?"visible":"hidden",children:e}),s)});Et.displayName="PanelContentHost";const Xe=({children:t,panels:e,placements:n})=>{const[r,o]=l.useState(new Map),s=l.useRef(new Map),a=l.useCallback((u,p)=>{o(g=>{const v=new Map(g);return p?v.set(u,p):v.delete(u),v})},[]),i=l.useMemo(()=>({registerContentContainer:a}),[a]),c=l.useCallback((u,p)=>{const g=s.current.get(u);if(g)return g;const v=p.render(p.id);return s.current.set(u,v),v},[]),d=Object.keys(e);return b.jsxs(Gt.Provider,{value:i,children:[t,d.map(u=>{const p=e[u];if(!p)return null;const g=n[u]??null,v=g?r.get(g.groupId)??null:null,m=c(u,p);return b.jsx(Et,{panelId:u,content:m,placement:g,containerElement:v},u)})]})},Ye=({children:t,emptyContentComponent:e,doubleClickToAdd:n})=>{const r=K(),{state:o,actions:s}=z(),{registerContentContainer:a}=ze(),i=l.useCallback(()=>l.createElement("div",{style:{color:"#888",fontSize:12,padding:12}},"No tabs"),[]),c=e??i,d=l.useCallback(y=>{const h=o.groups[y];if(!h)return null;const w=h.tabIds.map(f=>o.panels[f]).filter(Boolean);return{...h,tabs:w}},[o.groups,o.panels]),u=l.useCallback(y=>{const h=o.groups[y];return!h||h.tabIds.length===0?b.jsx(c,{}):null},[o.groups,c]),p=l.useCallback((y,h)=>{s.setActiveTab(y,h)},[s]),g=l.useCallback(y=>{s.addNewTab({groupId:y,title:"New Tab",makeActive:!0})},[s]),v=l.useCallback((y,h)=>{s.removeTab(y,h)},[s]),m=l.useCallback((y,h,w)=>{s.setActiveTab(h,y),r.onStartTabDrag(y,h,w)},[s,r]),x=l.useCallback((y,h)=>{const w=o.groups[y];!w||!w.activeTabId||r.onStartContentDrag(y,w.activeTabId,h)},[o.groups,r]),I=l.useMemo(()=>({getGroup:d,getGroupContent:u,onClickTab:p,onAddTab:g,onCloseTab:v,onStartTabDrag:m,onStartContentDrag:x,doubleClickToAdd:n,registerContentContainer:a}),[d,u,p,g,v,m,x,n,a]);return b.jsx(Ft,{value:I,children:t})},qe=({children:t,emptyContentComponent:e,doubleClickToAdd:n})=>{const{state:r}=z(),o=l.useMemo(()=>{const s={};for(const[a,i]of Object.entries(r.groups))for(const c of i.tabIds)s[c]={groupId:a,isActive:c===i.activeTabId};return s},[r.groups]);return b.jsx(Xe,{panels:r.panels,placements:o,children:b.jsx(Ye,{emptyContentComponent:e,doubleClickToAdd:n,children:t})})},F=(t,e,n,r)=>{if(M(t))return r;const o=t.direction,s=o==="vertical"?n.x+n.w*t.ratio:n.y+n.h*t.ratio;if(r.push({path:e,direction:o,parentRect:n,linePos:s}),o==="vertical"){const c=n.w*t.ratio,d=n.w-c;return F(t.a,[...e,"a"],{x:n.x,y:n.y,w:c,h:n.h},r),F(t.b,[...e,"b"],{x:n.x+c,y:n.y,w:d,h:n.h},r),r}const a=n.h*t.ratio,i=n.h-a;return F(t.a,[...e,"a"],{x:n.x,y:n.y,w:n.w,h:a},r),F(t.b,[...e,"b"],{x:n.x,y:n.y+a,w:n.w,h:i},r),r},Ue=({containerRef:t})=>{const{state:e}=z(),{adjustSplitRatio:n}=Ce(),r=l.useMemo(()=>F(e.tree,[],{x:0,y:0,w:100,h:100},[]),[e.tree]),[o,s]=l.useState(null);if(tt.useIsomorphicLayoutEffect(()=>{const i=t.current;if(!i)return;const c=()=>{const v=i.getBoundingClientRect();s({left:v.left,top:v.top,width:v.width,height:v.height})};c();function d(){try{const v=window.ResizeObserver;return typeof v=="function"?v:null}catch{return null}}const u=d(),p=u?new u(()=>c()):null;p&&p.observe(i);const g=()=>c();return window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("scroll",g,!0),p&&p.disconnect()}},[t,e.tree]),!o)return null;const a=(i,c)=>{const d={left:o.left+o.width*i.parentRect.x/100,top:o.top+o.height*i.parentRect.y/100,width:o.width*i.parentRect.w/100,height:o.height*i.parentRect.h/100},u=P.SPLIT_HANDLE_THICKNESS;if(i.direction==="vertical"){const m=d.left+d.width*(i.linePos-i.parentRect.x)/i.parentRect.w,x={position:"fixed",left:`calc(${Math.round(m)}px - ${u} / 2)`,top:Math.round(d.top),width:u,height:Math.round(d.height),cursor:"col-resize",pointerEvents:"auto"},I=y=>{const h=o.width*i.parentRect.w/100,w=h===0?0:y/h;n({path:i.path,deltaRatio:w})};return b.jsx("div",{style:x,children:b.jsx(G.ResizeHandle,{direction:"vertical",onResize:I})},`split-${c}`)}const p=d.top+d.height*(i.linePos-i.parentRect.y)/i.parentRect.h,g={position:"fixed",left:Math.round(d.left),top:`calc(${Math.round(p)}px - ${u} / 2)`,width:Math.round(d.width),height:u,cursor:"row-resize",pointerEvents:"auto"},v=m=>{const x=o.height*i.parentRect.h/100,I=x===0?0:m/x;n({path:i.path,deltaRatio:I})};return b.jsx("div",{style:g,children:b.jsx(G.ResizeHandle,{direction:"horizontal",onResize:v})},`split-${c}`)};return b.jsx("div",{style:{position:"fixed",inset:0,pointerEvents:"none"},children:r.map((i,c)=>a(i,c))})},Ve={position:"relative",display:"flex",width:"100%",height:"100%"},Ke=({state:t,layoutMode:e,gridTracksInteractive:n,view:r,tabBarComponent:o,panelGroupComponent:s})=>{const a=c=>{if(r){const d=r;return b.jsx(d,{groupId:c})}return b.jsx(oe,{id:c,TabBarComponent:o,PanelGroupComponent:s})};if(e==="grid"){const c=zt(t,a,!!n);return b.jsx(G.GridLayout,{config:c.config,layers:c.layers})}const i=Ht(t,a);return b.jsx(G.GridLayout,{config:i.config,layers:i.layers})},We=({containerRef:t,layoutMode:e,gridTracksInteractive:n,dragThresholdPx:r,view:o,style:s,className:a,tabBarComponent:i,panelGroupComponent:c,splitLimits:d,emptyContentComponent:u,doubleClickToAdd:p})=>{const{state:g}=z(),{onCommitContentDrop:v,onCommitTabDrop:m}=Be(),x=l.useMemo(()=>({...Ve,...s}),[s]),I=l.useCallback(({targetGroupId:y,zone:h})=>{if(h==="center")return!0;const w=h==="left"||h==="right"?"vertical":"horizontal";return et(g.tree,y,w,d)},[g.tree,d]);return b.jsx(Xt,{children:b.jsxs(Qt,{containerRef:t,dragThresholdPx:r,onCommitContentDrop:v,onCommitTabDrop:m,isContentZoneAllowed:I,children:[b.jsx(qe,{emptyContentComponent:u,doubleClickToAdd:p,children:b.jsx("div",{ref:t,className:a,style:x,children:b.jsx(Ke,{state:g,layoutMode:e,gridTracksInteractive:n,view:o,tabBarComponent:i,panelGroupComponent:c})})}),b.jsx(Ue,{containerRef:t}),b.jsx(Ze,{})]})})},Ze=()=>{const t=K();return b.jsxs(b.Fragment,{children:[b.jsx(de,{suggest:t.suggest}),b.jsx(he,{})]})},Je=({initialState:t,createGroupId:e,createPanelId:n,layoutMode:r,gridTracksInteractive:o,dragThresholdPx:s,view:a,emptyContentComponent:i,state:c,onStateChange:d,className:u,style:p,tabBarComponent:g,panelGroupComponent:v,splitLimits:m,doubleClickToAdd:x})=>{if(!t)throw new Error("PanelSystem requires initialState.");if(!e)throw new Error("PanelSystem requires explicit createGroupId function.");if(!r)throw new Error("PanelSystem requires explicit layoutMode ('absolute' | 'grid').");if(r==="grid"&&o===void 0)throw new Error("PanelSystem(layoutMode='grid') requires explicit 'gridTracksInteractive' flag.");if(s===void 0)throw new Error("PanelSystem requires explicit 'dragThresholdPx' value.");const I=l.useRef(null),y=l.useMemo(()=>yt(m),[m]);return b.jsx(Ne,{initialState:t,createGroupId:e,createPanelId:n,state:c,onStateChange:d,splitLimits:m,children:b.jsxs(Nt,{children:[b.jsx(He,{}),b.jsx(We,{containerRef:I,layoutMode:r,gridTracksInteractive:o,dragThresholdPx:s,view:a,style:p,className:u,tabBarComponent:g,panelGroupComponent:v,splitLimits:y,emptyContentComponent:i,doubleClickToAdd:x})]})})};exports.Drawer=G.Drawer;exports.DrawerLayers=G.DrawerLayers;exports.FloatingWindow=G.FloatingWindow;exports.GridLayout=G.GridLayout;exports.ResizeHandle=G.ResizeHandle;exports.runTransition=G.runTransition;exports.useTransitionState=G.useTransitionState;exports.CSS_VAR_PREFIX=P.CSS_VAR_PREFIX;exports.HorizontalDivider=At;exports.PanelSystem=Je;exports.buildInitialState=Te;exports.useFloatingState=_t;exports.useLayerDragHandle=kt;
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|