@humain/ui 2.2.1 → 2.2.3

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.
Files changed (67) hide show
  1. package/dist/components/templates/AppShell/AppShell.d.ts +4 -2
  2. package/dist/components/templates/AppShell/index.d.ts +1 -1
  3. package/dist/components/templates/AppSidebar/AppSidebar.constants.d.ts +4 -0
  4. package/dist/components/templates/AppSidebar/AppSidebar.d.ts +1 -0
  5. package/dist/index.js +19 -18
  6. package/dist/index217.js +6 -24
  7. package/dist/index217.js.map +1 -1
  8. package/dist/index218.js +20 -23
  9. package/dist/index218.js.map +1 -1
  10. package/dist/index219.js +20 -95
  11. package/dist/index219.js.map +1 -1
  12. package/dist/index220.js +92 -88
  13. package/dist/index220.js.map +1 -1
  14. package/dist/index221.js +97 -29
  15. package/dist/index221.js.map +1 -1
  16. package/dist/index222.js +24 -470
  17. package/dist/index222.js.map +1 -1
  18. package/dist/index223.js +450 -196
  19. package/dist/index223.js.map +1 -1
  20. package/dist/index224.js +199 -754
  21. package/dist/index224.js.map +1 -1
  22. package/dist/index225.js +777 -61
  23. package/dist/index225.js.map +1 -1
  24. package/dist/index226.js +58 -181
  25. package/dist/index226.js.map +1 -1
  26. package/dist/index227.js +175 -259
  27. package/dist/index227.js.map +1 -1
  28. package/dist/index228.js +246 -172
  29. package/dist/index228.js.map +1 -1
  30. package/dist/index229.js +195 -32
  31. package/dist/index229.js.map +1 -1
  32. package/dist/index230.js +12 -40
  33. package/dist/index230.js.map +1 -1
  34. package/dist/index231.js +23 -26
  35. package/dist/index231.js.map +1 -1
  36. package/dist/index232.js +45 -22
  37. package/dist/index232.js.map +1 -1
  38. package/dist/index233.js +27 -48
  39. package/dist/index233.js.map +1 -1
  40. package/dist/index234.js +52 -26
  41. package/dist/index234.js.map +1 -1
  42. package/dist/index235.js +40 -225
  43. package/dist/index235.js.map +1 -1
  44. package/dist/index236.js +217 -39
  45. package/dist/index236.js.map +1 -1
  46. package/dist/index237.js +50 -0
  47. package/dist/index237.js.map +1 -0
  48. package/dist/styles.css +1 -1
  49. package/dist/wc/{sidebar.js → AppSidebar.constants.js} +80 -78
  50. package/dist/wc/AppSidebar.constants.js.map +1 -0
  51. package/dist/wc/hf-app-shell.js +346 -343
  52. package/dist/wc/hf-app-shell.js.map +1 -1
  53. package/dist/wc/hf-app-sidebar.js +65 -62
  54. package/dist/wc/hf-app-sidebar.js.map +1 -1
  55. package/dist/wc-react/{sidebar.js → AppSidebar.constants.js} +89 -87
  56. package/dist/wc-react/AppSidebar.constants.js.map +1 -0
  57. package/dist/wc-react/hf-app-shell.js +383 -380
  58. package/dist/wc-react/hf-app-shell.js.map +1 -1
  59. package/dist/wc-react/hf-app-sidebar.js +69 -66
  60. package/dist/wc-react/hf-app-sidebar.js.map +1 -1
  61. package/package.json +1 -1
  62. package/skills/humain-ui/SKILL.md +1 -1
  63. package/skills/humain-ui-wc/SKILL.md +1 -1
  64. package/skills/humain-ui-wc.skill +0 -0
  65. package/skills/humain-ui.skill +0 -0
  66. package/dist/wc/sidebar.js.map +0 -1
  67. package/dist/wc-react/sidebar.js.map +0 -1
package/dist/index223.js CHANGED
@@ -1,229 +1,483 @@
1
1
  "use client";
2
2
  import { cn } from "./index2.js";
3
- import { Button } from "./index5.js";
4
- import { DropdownMenu } from "./index192.js";
5
- import { usePanelExpansion } from "./index217.js";
6
- import { AppShellContent } from "./index218.js";
7
- import { EllipsisVertical, Maximize2, Minimize2 } from "lucide-react";
3
+ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "./index45.js";
4
+ import { AppShell as AppShell$1 } from "./index213.js";
5
+ import { Sheet as SheetNamespace, SheetContent } from "./index214.js";
6
+ import { useIsMobile } from "./index215.js";
7
+ import { SidebarContext } from "./index216.js";
8
+ import { APP_SIDEBAR_COLLAPSED_WIDTH, APP_SIDEBAR_EXPANDED_WIDTH } from "./index217.js";
9
+ import { AppShellProvider, PanelIndexContext, PanelLayoutContext } from "./index218.js";
10
+ import { AppShellContent } from "./index219.js";
11
+ import { AppShellMobileTabBar } from "./index220.js";
12
+ import { AppShellPanel } from "./index221.js";
13
+ import { getExpandedPanelFromLayout, layoutMapToTuple, normalizePanelSizes, toResizableMinSize, toResizablePercentageSize } from "./index222.js";
8
14
  import * as React$1 from "react";
9
15
  import { jsx, jsxs } from "react/jsx-runtime";
10
- //#region src/components/templates/AppShellCard/AppShellCard.tsx
11
- var HEADER_TYPE = "AppShellCard.Header";
12
- var TOOLBAR_TYPE = "AppShellCard.Toolbar";
13
- var ACTIONS_TYPE = "AppShellCard.Actions";
14
- var MENU_TYPE = "AppShellCard.Menu";
15
- var TITLE_TYPE = "AppShellCard.Title";
16
- function getAppShellCardType(child) {
17
- if (!child.type || typeof child.type === "string") return;
18
- return child.type.__appShellCardType;
16
+ //#region src/components/templates/AppShell/AppShell.tsx
17
+ var DEFAULT_APP_SHELL_BACKGROUND = "var(--app-background)";
18
+ function isAppShellPanelComponent(type) {
19
+ return typeof type === "function" && type.__appShellType === "AppShell.Panel";
19
20
  }
20
- function assignAppShellCardType(component, type) {
21
- component.__appShellCardType = type;
22
- return component;
21
+ function isAppShellPanelElement(child) {
22
+ return React$1.isValidElement(child) && isAppShellPanelComponent(child.type);
23
23
  }
24
- function getNodeText(node) {
25
- if (typeof node === "string" || typeof node === "number") return String(node);
26
- if (Array.isArray(node)) return node.map(getNodeText).join("");
27
- if (React$1.isValidElement(node)) return getNodeText(node.props.children);
28
- return "";
24
+ function getAppShellPanelIdentity(panel, ariaBaseId, index) {
25
+ return panel.key ?? panel.props.label ?? `${ariaBaseId}-panel-${index}`;
29
26
  }
30
- function getTitleText(node) {
31
- let titleText = "";
32
- React$1.Children.forEach(node, (child) => {
33
- if (titleText || !React$1.isValidElement(child)) return;
34
- if (getAppShellCardType(child) === TITLE_TYPE) {
35
- titleText = getNodeText(child.props.children).trim();
36
- return;
37
- }
38
- titleText = getTitleText(child.props.children);
27
+ function AppShellPanelWithLayout({ panel, visible, index, overrides = {}, isMobile, activePanel, hasExpanded, hasTabBar, ariaBaseId, rootExpansionActive, firstExpandedIndex, onExpandedPanelChange }) {
28
+ if (isMobile && index !== activePanel) return null;
29
+ const layoutInfo = {
30
+ visible: isMobile ? true : visible,
31
+ collapseMode: hasExpanded ? "animated" : "removed",
32
+ isMobile,
33
+ tabId: hasTabBar ? `${ariaBaseId}-tab-${index}` : void 0,
34
+ panelId: hasTabBar ? `${ariaBaseId}-tabpanel-${index}` : void 0,
35
+ expanded: rootExpansionActive ? hasExpanded && index === firstExpandedIndex : void 0,
36
+ onExpandedChange: rootExpansionActive ? (nextExpanded) => onExpandedPanelChange(nextExpanded ? index : null) : void 0,
37
+ ...overrides
38
+ };
39
+ return /* @__PURE__ */ jsx(PanelIndexContext.Provider, {
40
+ value: index,
41
+ children: /* @__PURE__ */ jsx(PanelLayoutContext.Provider, {
42
+ value: layoutInfo,
43
+ children: panel
44
+ })
39
45
  });
40
- return titleText;
41
46
  }
42
- var appShellCardBodyPaddingClasses = {
43
- none: "",
44
- md: "p-4 sm:p-6"
45
- };
46
- var appShellCardElevationClasses = {
47
- none: "shadow-none",
48
- "2xs": "shadow-2xs",
49
- xs: "shadow-xs",
50
- sm: "shadow-sm",
51
- md: "shadow-md",
52
- lg: "shadow-lg",
53
- xl: "shadow-xl",
54
- "2xl": "shadow-2xl"
55
- };
56
- var appShellCardToolbarClassName = "flex shrink-0 items-center gap-4 overflow-hidden border-b border-border px-4 py-3 sm:gap-6 sm:p-6";
57
- var AppShellCardRoot = React$1.forwardRef(function AppShellCardRoot({ className, bodyPadding = "md", elevation = "md", bodyClassName, bodyAriaLabel, inset = false, children, ...props }, ref) {
58
- const expansion = usePanelExpansion();
59
- const menuId = React$1.useId();
60
- const bodyRef = React$1.useRef(null);
47
+ function AppShellRoot({ background = DEFAULT_APP_SHELL_BACKGROUND, height = "100dvh", padding = 16, mobilePadding, gap = 12, connected = false, skipToId, activePanel: activePanelProp, onActivePanelChange, defaultActivePanel = 0, expandedPanel: expandedPanelProp, defaultExpandedPanel, onExpandedPanelChange, resizablePanels, defaultPanelSizes, panelSizes, onPanelSizesChange, expandThreshold = 85, className, children, ...props }) {
48
+ const isMobile = useIsMobile();
49
+ const ariaBaseId = React$1.useId();
50
+ const [internalActivePanel, setInternalActivePanel] = React$1.useState(defaultActivePanel);
51
+ const [internalExpandedPanel, setInternalExpandedPanel] = React$1.useState(defaultExpandedPanel ?? null);
52
+ const [internalPanelSizes, setInternalPanelSizes] = React$1.useState(() => normalizePanelSizes(defaultPanelSizes));
53
+ const [isResizingPanels, setIsResizingPanels] = React$1.useState(false);
54
+ const [isRestoringResizablePanels, setIsRestoringResizablePanels] = React$1.useState(false);
55
+ const [internalMobileSidebarOpen, setInternalMobileSidebarOpen] = React$1.useState(false);
56
+ const resizableGroupRef = React$1.useRef(null);
57
+ const rootRef = React$1.useRef(null);
58
+ const allowResizeReleaseExpansionRef = React$1.useRef(false);
59
+ const suppressControlledLayoutChangeRef = React$1.useRef(false);
60
+ const previousResizableExpandedRef = React$1.useRef(false);
61
+ const activePanel = activePanelProp ?? internalActivePanel;
62
+ const handleActivePanelChange = React$1.useCallback((index) => {
63
+ if (activePanelProp === void 0) setInternalActivePanel((prev) => prev === index ? prev : index);
64
+ onActivePanelChange?.(index);
65
+ }, [activePanelProp, onActivePanelChange]);
66
+ const rootExpansionRequested = expandedPanelProp !== void 0 || defaultExpandedPanel !== void 0 || onExpandedPanelChange !== void 0;
67
+ const resolvedExpandedPanel = expandedPanelProp !== void 0 ? expandedPanelProp : internalExpandedPanel;
68
+ const handleExpandedPanelChange = React$1.useCallback((panelIndex) => {
69
+ if (expandedPanelProp === void 0) setInternalExpandedPanel(panelIndex);
70
+ onExpandedPanelChange?.(panelIndex);
71
+ }, [expandedPanelProp, onExpandedPanelChange]);
72
+ const { panels, panelInfos, sidebarChild, otherChildren } = React$1.useMemo(() => {
73
+ const p = [];
74
+ const infos = [];
75
+ let sidebar = null;
76
+ const other = [];
77
+ React$1.Children.forEach(children, (child) => {
78
+ if (isAppShellPanelElement(child)) {
79
+ infos.push({
80
+ key: child.key ?? child.props.label,
81
+ label: child.props.label
82
+ });
83
+ p.push(child);
84
+ return;
85
+ }
86
+ if (!React$1.isValidElement(child)) return;
87
+ if (child.type === AppShellSidebar) sidebar = child;
88
+ else other.push(child);
89
+ });
90
+ return {
91
+ panels: p,
92
+ panelInfos: infos,
93
+ sidebarChild: sidebar,
94
+ otherChildren: other
95
+ };
96
+ }, [children]);
97
+ const shouldUseResizablePanels = resizablePanels ?? true;
98
+ const firstPanelExpandedIndex = panels.findIndex((p) => p.props.expanded);
99
+ const hasPanelExpansionProps = panels.some((panel) => panel.props.expanded !== void 0 || panel.props.onExpandedChange !== void 0);
100
+ const canUseResizablePanelPair = shouldUseResizablePanels && !connected && !isMobile && panels.length === 2 && (resizablePanels !== void 0 || !hasPanelExpansionProps);
101
+ const rootExpansionActive = rootExpansionRequested || canUseResizablePanelPair;
102
+ const validRootExpandedPanel = typeof resolvedExpandedPanel === "number" && Number.isInteger(resolvedExpandedPanel) && resolvedExpandedPanel >= 0 && resolvedExpandedPanel < panels.length ? resolvedExpandedPanel : null;
103
+ let firstExpandedIndex = firstPanelExpandedIndex;
104
+ if (rootExpansionActive) firstExpandedIndex = validRootExpandedPanel;
105
+ const hasExpanded = firstExpandedIndex !== -1 && firstExpandedIndex !== null;
106
+ const visibleCount = hasExpanded ? 1 : Math.min(panels.length, 2);
107
+ const canRenderResizablePanels = canUseResizablePanelPair;
108
+ const resolvedPanelSizes = React$1.useMemo(() => normalizePanelSizes(panelSizes ?? internalPanelSizes), [panelSizes, internalPanelSizes]);
109
+ const resizablePanelSizes = React$1.useMemo(() => {
110
+ if (hasExpanded && firstExpandedIndex === 0) return [100, 0];
111
+ if (hasExpanded && firstExpandedIndex === 1) return [0, 100];
112
+ return resolvedPanelSizes;
113
+ }, [
114
+ firstExpandedIndex,
115
+ hasExpanded,
116
+ resolvedPanelSizes
117
+ ]);
118
+ const shouldBypassResizableMinSize = hasExpanded || isRestoringResizablePanels || !hasExpanded && previousResizableExpandedRef.current;
119
+ if (process.env.NODE_ENV !== "production") {
120
+ const expandedPanelPropCount = panels.filter((p) => p.props.expanded).length;
121
+ if (rootExpansionActive && expandedPanelPropCount > 0) console.warn("AppShell.Root: root-owned expansion props should not be mixed with AppShell.Panel expanded. Root expansion will be used.");
122
+ if (!rootExpansionActive && expandedPanelPropCount > 1) console.warn("AppShell.Root: multiple panels have expanded={true}. Only the first expanded panel will be shown.");
123
+ if (rootExpansionActive && resolvedExpandedPanel !== null && resolvedExpandedPanel !== void 0 && validRootExpandedPanel === null) console.warn(`AppShell.Root: expandedPanel index ${resolvedExpandedPanel} is out of range. No panel will be expanded.`);
124
+ if (resizablePanels === true && connected) console.warn("AppShell.Root: resizablePanels is not supported with connected. Rendering non-resizable panels.");
125
+ if (resizablePanels === true && !connected && panels.length !== 2) console.warn(`AppShell.Root: resizablePanels requires exactly 2 Panel children, got ${panels.length}. Rendering non-resizable panels.`);
126
+ if (panels.length > 2 && !hasExpanded) console.warn(`AppShell.Root: max 2 Panel children allowed, got ${panels.length}. Only the first 2 will be visible.`);
127
+ }
128
+ const handleLayoutChange = React$1.useCallback((layout) => {
129
+ if (hasExpanded || suppressControlledLayoutChangeRef.current) return;
130
+ if (panelSizes === void 0) setInternalPanelSizes(layoutMapToTuple(layout));
131
+ }, [hasExpanded, panelSizes]);
132
+ const handleLayoutChanged = React$1.useCallback((layout) => {
133
+ if (hasExpanded || !allowResizeReleaseExpansionRef.current || suppressControlledLayoutChangeRef.current) return;
134
+ const nextSizes = layoutMapToTuple(layout);
135
+ if (panelSizes === void 0) setInternalPanelSizes(nextSizes);
136
+ onPanelSizesChange?.(nextSizes);
137
+ const expandedIndex = getExpandedPanelFromLayout(layout, expandThreshold);
138
+ if (expandedIndex !== null) handleExpandedPanelChange(expandedIndex);
139
+ }, [
140
+ expandThreshold,
141
+ handleExpandedPanelChange,
142
+ hasExpanded,
143
+ onPanelSizesChange,
144
+ panelSizes
145
+ ]);
61
146
  React$1.useEffect(() => {
62
- const el = bodyRef.current;
63
- if (!el) return;
64
- const update = () => {
65
- const hasOverflow = el.scrollHeight > el.clientHeight;
66
- const top = hasOverflow && el.scrollTop > 0 ? "1" : "0";
67
- const bottom = hasOverflow && el.scrollTop + el.clientHeight < el.scrollHeight - 1 ? "1" : "0";
68
- if (el.style.getPropertyValue("--scroll-t") !== top) el.style.setProperty("--scroll-t", top);
69
- if (el.style.getPropertyValue("--scroll-b") !== bottom) el.style.setProperty("--scroll-b", bottom);
147
+ if (!canRenderResizablePanels) {
148
+ suppressControlledLayoutChangeRef.current = false;
149
+ previousResizableExpandedRef.current = false;
150
+ return;
151
+ }
152
+ const ownerWindow = rootRef.current?.ownerDocument.defaultView;
153
+ if (!ownerWindow) return;
154
+ const wasExpanded = previousResizableExpandedRef.current;
155
+ previousResizableExpandedRef.current = hasExpanded;
156
+ if (!(hasExpanded || wasExpanded || panelSizes !== void 0)) {
157
+ suppressControlledLayoutChangeRef.current = false;
158
+ return;
159
+ }
160
+ let restoreFrame;
161
+ const [first, second] = resizablePanelSizes;
162
+ if (wasExpanded && !hasExpanded) restoreFrame = ownerWindow.requestAnimationFrame(() => {
163
+ setIsRestoringResizablePanels(true);
164
+ });
165
+ suppressControlledLayoutChangeRef.current = true;
166
+ const nextLayout = {
167
+ panel0: first,
168
+ panel1: second
70
169
  };
71
- el.addEventListener("scroll", update, { passive: true });
72
- const OwnerResizeObserver = el.ownerDocument.defaultView?.ResizeObserver;
73
- const observer = OwnerResizeObserver ? new OwnerResizeObserver(update) : null;
74
- observer?.observe(el);
75
- update();
170
+ resizableGroupRef.current?.setLayout(nextLayout);
171
+ const frame = ownerWindow.requestAnimationFrame(() => {
172
+ resizableGroupRef.current?.setLayout(nextLayout);
173
+ });
174
+ const timeout = ownerWindow.setTimeout(() => {
175
+ suppressControlledLayoutChangeRef.current = false;
176
+ }, 350);
76
177
  return () => {
77
- el.removeEventListener("scroll", update);
78
- observer?.disconnect();
178
+ if (restoreFrame !== void 0) ownerWindow.cancelAnimationFrame(restoreFrame);
179
+ ownerWindow.cancelAnimationFrame(frame);
180
+ ownerWindow.clearTimeout(timeout);
181
+ suppressControlledLayoutChangeRef.current = false;
79
182
  };
80
- }, []);
81
- let toolbarSlot = null;
82
- let headerSlot = null;
83
- let actionsSlot = null;
84
- let menuSlot = null;
85
- const toolbarChildren = [];
86
- const bodyChildren = [];
87
- for (const child of React$1.Children.toArray(children)) {
88
- if (!React$1.isValidElement(child)) {
89
- bodyChildren.push(child);
90
- continue;
91
- }
92
- const type = getAppShellCardType(child);
93
- if (type === HEADER_TYPE) headerSlot = child;
94
- else if (type === TOOLBAR_TYPE) toolbarSlot = child;
95
- else if (type === ACTIONS_TYPE) actionsSlot = child;
96
- else if (type === MENU_TYPE) menuSlot = child;
97
- else bodyChildren.push(child);
98
- }
99
- if (toolbarSlot) for (const child of React$1.Children.toArray(toolbarSlot.props.children)) {
100
- if (!React$1.isValidElement(child)) {
101
- toolbarChildren.push(child);
102
- continue;
183
+ }, [
184
+ canRenderResizablePanels,
185
+ hasExpanded,
186
+ panelSizes,
187
+ resizablePanelSizes
188
+ ]);
189
+ React$1.useEffect(() => {
190
+ if (!isRestoringResizablePanels) return;
191
+ const ownerWindow = rootRef.current?.ownerDocument.defaultView;
192
+ if (!ownerWindow) return;
193
+ const timeout = ownerWindow.setTimeout(() => {
194
+ setIsRestoringResizablePanels(false);
195
+ }, 350);
196
+ return () => ownerWindow.clearTimeout(timeout);
197
+ }, [isRestoringResizablePanels]);
198
+ React$1.useEffect(() => {
199
+ if (!canRenderResizablePanels) {
200
+ allowResizeReleaseExpansionRef.current = false;
201
+ suppressControlledLayoutChangeRef.current = false;
202
+ return;
103
203
  }
104
- const type = getAppShellCardType(child);
105
- if (type === HEADER_TYPE) headerSlot = child;
106
- else if (type === ACTIONS_TYPE) actionsSlot = child;
107
- else if (type === MENU_TYPE) menuSlot = child;
108
- else toolbarChildren.push(child);
109
- }
110
- const hasToolbar = toolbarSlot || headerSlot || actionsSlot || menuSlot || toolbarChildren.length > 0 || expansion?.onExpandedChange;
111
- const titleText = headerSlot ? getTitleText(headerSlot) : "";
112
- const resolvedBodyAriaLabel = bodyAriaLabel ?? (titleText ? `${titleText} content` : "Card content");
113
- const { children: _toolbarSlotChildren, className: toolbarClassName, ...toolbarProps } = toolbarSlot?.props ?? {};
114
- return /* @__PURE__ */ jsxs(AppShellContent, {
115
- ref,
116
- "data-slot": "app-shell-card",
117
- className: cn(appShellCardElevationClasses[elevation], "transition-[margin] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]", inset && !expansion?.expanded ? "mx-5 my-10" : "m-0", className),
118
- ...props,
119
- children: [hasToolbar && /* @__PURE__ */ jsxs("div", {
120
- role: "toolbar",
121
- "aria-label": "Card actions",
122
- ...toolbarProps,
123
- "data-slot": "app-shell-card-toolbar",
124
- className: cn(appShellCardToolbarClassName, toolbarClassName),
125
- children: [
126
- headerSlot,
127
- toolbarChildren,
128
- actionsSlot,
129
- menuSlot && /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenu.Trigger, { render: /* @__PURE__ */ jsx(Button, {
130
- appearance: "ghost",
131
- size: "icon",
132
- "aria-label": "More options",
133
- children: /* @__PURE__ */ jsx(EllipsisVertical, { className: "size-5" })
134
- }) }), /* @__PURE__ */ jsx(DropdownMenu.Popup, {
135
- id: `${menuId}-popup`,
136
- align: "end",
137
- sideOffset: 4,
138
- children: menuSlot.props.children
139
- })] }),
140
- expansion?.onExpandedChange && /* @__PURE__ */ jsx(Button, {
141
- appearance: "ghost",
142
- size: "icon",
143
- onClick: () => expansion.onExpandedChange?.(!expansion.expanded),
144
- "aria-label": expansion.expanded ? "Minimize panel" : "Maximize panel",
145
- children: /* @__PURE__ */ jsx("span", {
146
- className: "delight-fade-in inline-flex",
147
- children: expansion.expanded ? /* @__PURE__ */ jsx(Minimize2, { className: "size-5" }) : /* @__PURE__ */ jsx(Maximize2, { className: "size-5" })
148
- }, String(expansion.expanded))
204
+ const ownerWindow = rootRef.current?.ownerDocument.defaultView;
205
+ if (!ownerWindow) return;
206
+ const frame = ownerWindow.requestAnimationFrame(() => {
207
+ allowResizeReleaseExpansionRef.current = true;
208
+ });
209
+ return () => {
210
+ ownerWindow.cancelAnimationFrame(frame);
211
+ allowResizeReleaseExpansionRef.current = false;
212
+ };
213
+ }, [canRenderResizablePanels]);
214
+ React$1.useEffect(() => {
215
+ if (!isResizingPanels) return;
216
+ const ownerWindow = rootRef.current?.ownerDocument.defaultView;
217
+ if (!ownerWindow) return;
218
+ const stopResizing = () => setIsResizingPanels(false);
219
+ ownerWindow.addEventListener("pointerup", stopResizing);
220
+ ownerWindow.addEventListener("pointercancel", stopResizing);
221
+ return () => {
222
+ ownerWindow.removeEventListener("pointerup", stopResizing);
223
+ ownerWindow.removeEventListener("pointercancel", stopResizing);
224
+ };
225
+ }, [isResizingPanels]);
226
+ const handleResizablePointerDownCapture = React$1.useCallback((event) => {
227
+ const target = event.target;
228
+ if (!(target instanceof Element)) return;
229
+ if (target.closest("[data-slot=\"resizable-handle\"]")) setIsResizingPanels(true);
230
+ }, []);
231
+ const visiblePanels = React$1.useMemo(() => hasExpanded ? panels.map((panel, i) => ({
232
+ panel,
233
+ visible: i === firstExpandedIndex,
234
+ index: i
235
+ })) : panels.map((panel, i) => ({
236
+ panel,
237
+ visible: i < 2,
238
+ index: i
239
+ })), [
240
+ panels,
241
+ hasExpanded,
242
+ firstExpandedIndex
243
+ ]);
244
+ const hasTabBar = isMobile && panels.length > 1;
245
+ const getPanelPosition = React$1.useCallback((index) => {
246
+ if (visibleCount === 1) return "only";
247
+ if (hasExpanded) return index === firstExpandedIndex ? "only" : "last";
248
+ return index === 0 ? "first" : "last";
249
+ }, [
250
+ visibleCount,
251
+ hasExpanded,
252
+ firstExpandedIndex
253
+ ]);
254
+ const contextValue = React$1.useMemo(() => ({
255
+ connected,
256
+ panelCount: visibleCount,
257
+ getPanelPosition
258
+ }), [
259
+ connected,
260
+ visibleCount,
261
+ getPanelPosition
262
+ ]);
263
+ const sidebarContext = React$1.useContext(SidebarContext);
264
+ const mobileSidebarOpen = sidebarContext?.openMobile ?? internalMobileSidebarOpen;
265
+ const setMobileSidebarOpen = sidebarContext?.setOpenMobile ?? setInternalMobileSidebarOpen;
266
+ const handleSidebarOpen = React$1.useCallback(() => {
267
+ setMobileSidebarOpen(true);
268
+ }, [setMobileSidebarOpen]);
269
+ const handleSheetOpenChange = React$1.useCallback((open) => {
270
+ setMobileSidebarOpen(open);
271
+ }, [setMobileSidebarOpen]);
272
+ const skipLink = skipToId ? /* @__PURE__ */ jsx("a", {
273
+ href: `#${skipToId}`,
274
+ className: "sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-50 focus:rounded-md focus:bg-background focus:px-4 focus:py-2 focus:text-sm focus:font-medium focus:text-foreground focus:shadow-sm focus:ring-2 focus:ring-ring",
275
+ children: "Skip to content"
276
+ }) : null;
277
+ const renderedPanels = React$1.useMemo(() => visiblePanels.map(({ panel, visible, index }) => /* @__PURE__ */ jsx(AppShellPanelWithLayout, {
278
+ panel,
279
+ visible,
280
+ index,
281
+ isMobile,
282
+ activePanel,
283
+ hasExpanded,
284
+ hasTabBar,
285
+ ariaBaseId,
286
+ rootExpansionActive,
287
+ firstExpandedIndex,
288
+ onExpandedPanelChange: handleExpandedPanelChange
289
+ }, getAppShellPanelIdentity(panel, ariaBaseId, index))), [
290
+ visiblePanels,
291
+ ariaBaseId,
292
+ isMobile,
293
+ activePanel,
294
+ hasExpanded,
295
+ hasTabBar,
296
+ rootExpansionActive,
297
+ firstExpandedIndex,
298
+ handleExpandedPanelChange
299
+ ]);
300
+ const renderedResizablePanels = canRenderResizablePanels ? /* @__PURE__ */ jsxs(ResizablePanelGroup, {
301
+ orientation: "horizontal",
302
+ disabled: hasExpanded,
303
+ groupRef: resizableGroupRef,
304
+ onLayoutChange: handleLayoutChange,
305
+ onLayoutChanged: handleLayoutChanged,
306
+ onPointerDownCapture: handleResizablePointerDownCapture,
307
+ className: cn("min-h-0 min-w-0 flex-1", !isResizingPanels && "[&>[data-slot=resizable-panel]]:transition-[flex-grow] [&>[data-slot=resizable-panel]]:duration-300 [&>[data-slot=resizable-panel]]:ease-[cubic-bezier(0.16,1,0.3,1)] motion-reduce:[&>[data-slot=resizable-panel]]:transition-none"),
308
+ children: [
309
+ /* @__PURE__ */ jsx(ResizablePanel, {
310
+ id: "panel0",
311
+ defaultSize: toResizablePercentageSize(resizablePanelSizes[0]),
312
+ minSize: shouldBypassResizableMinSize ? 0 : toResizableMinSize(panels[0].props.minWidth),
313
+ children: /* @__PURE__ */ jsx(AppShellPanelWithLayout, {
314
+ panel: panels[0],
315
+ visible: !hasExpanded || firstExpandedIndex === 0,
316
+ index: 0,
317
+ overrides: { sizeManagedByRoot: true },
318
+ isMobile,
319
+ activePanel,
320
+ hasExpanded,
321
+ hasTabBar,
322
+ ariaBaseId,
323
+ rootExpansionActive,
324
+ firstExpandedIndex,
325
+ onExpandedPanelChange: handleExpandedPanelChange
149
326
  })
327
+ }),
328
+ /* @__PURE__ */ jsx(ResizableHandle, {
329
+ disabled: hasExpanded,
330
+ className: cn("z-10 min-w-2 shrink-0 cursor-col-resize w-[var(--app-shell-gap,0px)] bg-transparent after:w-2 hover:bg-transparent", "transition-[width,min-width,opacity,background-color] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] motion-reduce:transition-none", hasExpanded && "min-w-0 w-0 opacity-0 after:w-0 pointer-events-none")
331
+ }),
332
+ /* @__PURE__ */ jsx(ResizablePanel, {
333
+ id: "panel1",
334
+ defaultSize: toResizablePercentageSize(resizablePanelSizes[1]),
335
+ minSize: shouldBypassResizableMinSize ? 0 : toResizableMinSize(panels[1].props.minWidth),
336
+ children: /* @__PURE__ */ jsx(AppShellPanelWithLayout, {
337
+ panel: panels[1],
338
+ visible: !hasExpanded || firstExpandedIndex === 1,
339
+ index: 1,
340
+ overrides: { sizeManagedByRoot: true },
341
+ isMobile,
342
+ activePanel,
343
+ hasExpanded,
344
+ hasTabBar,
345
+ ariaBaseId,
346
+ rootExpansionActive,
347
+ firstExpandedIndex,
348
+ onExpandedPanelChange: handleExpandedPanelChange
349
+ })
350
+ })
351
+ ]
352
+ }) : null;
353
+ const activeLabel = hasTabBar && panelInfos[activePanel] ? panelInfos[activePanel].label || `Panel ${activePanel + 1}` : null;
354
+ if (isMobile) return /* @__PURE__ */ jsx(AppShellProvider, {
355
+ value: contextValue,
356
+ children: /* @__PURE__ */ jsxs(AppShell$1, {
357
+ ref: rootRef,
358
+ background,
359
+ height,
360
+ padding,
361
+ mobilePadding,
362
+ gap: 0,
363
+ connected,
364
+ className,
365
+ ...props,
366
+ children: [
367
+ skipLink,
368
+ sidebarChild && /* @__PURE__ */ jsx(SheetNamespace, {
369
+ open: mobileSidebarOpen,
370
+ onOpenChange: handleSheetOpenChange,
371
+ children: /* @__PURE__ */ jsx(SheetContent, {
372
+ side: "left",
373
+ showCloseButton: false,
374
+ className: "w-[280px] p-0",
375
+ "aria-label": "Sidebar navigation",
376
+ children: sidebarChild
377
+ })
378
+ }),
379
+ /* @__PURE__ */ jsxs("div", {
380
+ className: "flex h-full min-w-0 flex-1 flex-col overflow-clip",
381
+ children: [/* @__PURE__ */ jsx(AppShellMobileTabBar, {
382
+ panels: panelInfos,
383
+ activeIndex: activePanel,
384
+ onActiveChange: handleActivePanelChange,
385
+ onSidebarOpen: sidebarChild ? handleSidebarOpen : void 0,
386
+ baseId: ariaBaseId
387
+ }), /* @__PURE__ */ jsx("div", {
388
+ className: "flex min-h-0 flex-1",
389
+ children: renderedPanels
390
+ })]
391
+ }),
392
+ activeLabel && /* @__PURE__ */ jsxs("div", {
393
+ className: "sr-only",
394
+ role: "status",
395
+ "aria-live": "polite",
396
+ children: [activeLabel, " panel active"]
397
+ }),
398
+ otherChildren
150
399
  ]
151
- }), /* @__PURE__ */ jsx("section", {
152
- ref: bodyRef,
153
- "data-slot": "app-shell-card-body",
154
- "aria-label": resolvedBodyAriaLabel || "Card content",
155
- tabIndex: 0,
156
- className: cn("delight-scroll-shadow flex-1 min-h-0 overflow-auto focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring rounded-b-[inherit]", appShellCardBodyPaddingClasses[bodyPadding], bodyClassName),
157
- children: bodyChildren
158
- })]
400
+ })
159
401
  });
160
- });
161
- AppShellCardRoot.displayName = "AppShellCard";
162
- function AppShellCardToolbar({ className, children, ...props }) {
163
- return /* @__PURE__ */ jsx("div", {
164
- "data-slot": "app-shell-card-toolbar",
165
- role: "toolbar",
166
- "aria-label": "Card actions",
167
- className: cn(appShellCardToolbarClassName, className),
168
- ...props,
169
- children
402
+ return /* @__PURE__ */ jsx(AppShellProvider, {
403
+ value: contextValue,
404
+ children: /* @__PURE__ */ jsxs(AppShell$1, {
405
+ ref: rootRef,
406
+ background,
407
+ height,
408
+ padding,
409
+ mobilePadding,
410
+ gap: connected || hasExpanded ? 0 : gap,
411
+ connected,
412
+ className,
413
+ ...props,
414
+ children: [
415
+ skipLink,
416
+ sidebarChild,
417
+ renderedResizablePanels ?? renderedPanels,
418
+ otherChildren
419
+ ]
420
+ })
170
421
  });
171
422
  }
172
- AppShellCardToolbar.displayName = "AppShellCard.Toolbar";
173
- assignAppShellCardType(AppShellCardToolbar, TOOLBAR_TYPE);
174
- function AppShellCardHeader({ className, children, ...props }) {
423
+ AppShellRoot.displayName = "AppShell";
424
+ /**
425
+ * Layout slot for the sidebar region. Renders a div — the actual aside
426
+ * landmark is provided by AppSidebar/Sidebar primitive inside it.
427
+ *
428
+ * **Auto-detection (default):** When no `width` prop is provided, the sidebar
429
+ * observes the child SidebarProvider's `data-state` attribute via CSS `:has()`
430
+ * and transitions between `collapsedWidth` and `expandedWidth` automatically.
431
+ *
432
+ * **Manual mode:** Pass an explicit `width` to control sizing yourself.
433
+ */
434
+ function AppShellSidebar({ width, expandedWidth = APP_SIDEBAR_EXPANDED_WIDTH, collapsedWidth = APP_SIDEBAR_COLLAPSED_WIDTH, className, style, children, ...props }) {
435
+ const autoMode = width === void 0;
175
436
  return /* @__PURE__ */ jsx("div", {
176
- "data-slot": "app-shell-card-header",
177
- className: cn("flex min-w-0 flex-1 flex-col justify-center", className),
437
+ "data-slot": "app-shell-sidebar",
438
+ style: {
439
+ ...autoMode ? {
440
+ "--app-shell-sidebar-collapsed": collapsedWidth,
441
+ "--app-shell-sidebar-expanded": expandedWidth
442
+ } : {
443
+ "--app-shell-sidebar-width": width,
444
+ minWidth: APP_SIDEBAR_COLLAPSED_WIDTH
445
+ },
446
+ ...style
447
+ },
448
+ className: cn("flex h-full shrink-0 flex-col overflow-clip", "transition-[width] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]", "motion-reduce:transition-none", autoMode ? ["w-[var(--app-shell-sidebar-collapsed)]", "[&:has([data-state=expanded])]:w-[var(--app-shell-sidebar-expanded)]"] : "w-[var(--app-shell-sidebar-width)]", className),
178
449
  ...props,
179
450
  children
180
451
  });
181
452
  }
182
- AppShellCardHeader.displayName = "AppShellCard.Header";
183
- assignAppShellCardType(AppShellCardHeader, HEADER_TYPE);
184
- function AppShellCardTitle({ className, children, ...props }) {
185
- return /* @__PURE__ */ jsx("h3", {
186
- "data-slot": "app-shell-card-title",
187
- className: cn("text-lg font-semibold leading-7 text-foreground", className),
188
- ...props,
189
- children
190
- });
191
- }
192
- AppShellCardTitle.displayName = "AppShellCard.Title";
193
- assignAppShellCardType(AppShellCardTitle, TITLE_TYPE);
194
- function AppShellCardSubtitle({ className, children, ...props }) {
195
- return /* @__PURE__ */ jsx("p", {
196
- "data-slot": "app-shell-card-subtitle",
197
- className: cn("text-sm leading-5 text-secondary-foreground", className),
198
- ...props,
199
- children
200
- });
201
- }
202
- AppShellCardSubtitle.displayName = "AppShellCard.Subtitle";
203
- function AppShellCardActions({ className, children, ...props }) {
453
+ AppShellSidebar.displayName = "AppShell.Sidebar";
454
+ function AppShellHeader({ className, children, ...props }) {
204
455
  return /* @__PURE__ */ jsx("div", {
205
- "data-slot": "app-shell-card-actions",
206
- className: cn("flex shrink-0 items-center gap-2", className),
456
+ "data-slot": "app-shell-header",
457
+ className: cn("shrink-0", className),
207
458
  ...props,
208
459
  children
209
460
  });
210
461
  }
211
- AppShellCardActions.displayName = "AppShellCard.Actions";
212
- assignAppShellCardType(AppShellCardActions, ACTIONS_TYPE);
213
- function AppShellCardMenu({ children }) {
214
- return children;
215
- }
216
- AppShellCardMenu.displayName = "AppShellCard.Menu";
217
- assignAppShellCardType(AppShellCardMenu, MENU_TYPE);
218
- var AppShellCard = Object.assign(AppShellCardRoot, {
219
- Toolbar: AppShellCardToolbar,
220
- Header: AppShellCardHeader,
221
- Title: AppShellCardTitle,
222
- Subtitle: AppShellCardSubtitle,
223
- Actions: AppShellCardActions,
224
- Menu: AppShellCardMenu
462
+ AppShellHeader.displayName = "AppShell.Header";
463
+ var appShellBackgrounds = {
464
+ transparent: "transparent",
465
+ appBg: DEFAULT_APP_SHELL_BACKGROUND,
466
+ neutral: "var(--muted)",
467
+ brandSubtle: "linear-gradient(135deg, var(--air-50) 0%, var(--air-100) 100%)",
468
+ brand: "linear-gradient(135deg, var(--air-400) 0%, var(--primary) 100%)",
469
+ brandDeep: "linear-gradient(135deg, var(--primary) 0%, var(--air-900) 100%)",
470
+ desertMidnight: "linear-gradient(135deg, var(--slate-500) 0%, var(--slate-700) 100%)",
471
+ aqua: "linear-gradient(135deg, var(--air-400) 0%, var(--air-600) 100%)"
472
+ };
473
+ var AppShell = Object.assign(AppShellRoot, {
474
+ Root: AppShellRoot,
475
+ Sidebar: AppShellSidebar,
476
+ Header: AppShellHeader,
477
+ Panel: AppShellPanel,
478
+ Content: AppShellContent
225
479
  });
226
480
  //#endregion
227
- export { AppShellCard, AppShellCardActions, AppShellCardHeader, AppShellCardMenu, AppShellCardRoot, AppShellCardSubtitle, AppShellCardTitle, AppShellCardToolbar };
481
+ export { APP_SIDEBAR_COLLAPSED_WIDTH, APP_SIDEBAR_EXPANDED_WIDTH, AppShell, AppShellContent, AppShellHeader, AppShellPanel, AppShellRoot, AppShellSidebar, appShellBackgrounds };
228
482
 
229
483
  //# sourceMappingURL=index223.js.map