@adea-ai/ui 0.107.0 → 0.108.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/components/layout/contextual-sidebar/contextual-sidebar.d.ts +55 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts.map +1 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js +199 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -0
- package/dist/components/layout/contextual-sidebar/index.d.ts +3 -0
- package/dist/components/layout/contextual-sidebar/index.d.ts.map +1 -0
- package/dist/components/layout/contextual-sidebar/index.js +3 -0
- package/dist/components/layout/pixel-resize-handle/index.d.ts +2 -0
- package/dist/components/layout/pixel-resize-handle/index.d.ts.map +1 -0
- package/dist/components/layout/pixel-resize-handle/index.js +2 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts +29 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts.map +1 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js +183 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js.map +1 -0
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts +3 -19
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.js +8 -76
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.js.map +1 -1
- package/dist/components/ui/resizable/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable/resizable.js +2 -2
- package/dist/components/ui/resizable/resizable.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lint/index.d.ts.map +1 -1
- package/dist/lint.js +154 -20
- package/dist/lint.js.map +1 -1
- package/dist/r/contextual-sidebar.json +25 -0
- package/dist/r/pixel-resize-handle.json +23 -0
- package/dist/r/registry.json +49 -1
- package/dist/r/sidebar-nav.json +1 -1
- package/dist/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +180 -0
- package/dist/r/src/components/layout/contextual-sidebar/index.ts +6 -0
- package/dist/r/src/components/layout/pixel-resize-handle/index.ts +1 -0
- package/dist/r/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +177 -0
- package/dist/r/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +7 -55
- package/dist/r/src/components/ui/resizable/resizable.tsx +4 -2
- package/package.json +3 -1
- package/registry.json +49 -1
- package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +180 -0
- package/src/components/layout/contextual-sidebar/index.ts +6 -0
- package/src/components/layout/pixel-resize-handle/index.ts +1 -0
- package/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +177 -0
- package/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +7 -55
- package/src/components/ui/resizable/resizable.tsx +4 -2
- package/src/index.ts +1 -0
- package/src/lint/index.ts +234 -22
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Accessor, JSX } from 'solid-js';
|
|
2
|
+
export type ContextualSidebarRenderContext = {
|
|
3
|
+
/** Whether the slot is being rendered inside the modal mobile sheet. */
|
|
4
|
+
mobile: boolean;
|
|
5
|
+
/** Mount nested popovers and menus inside the mobile dialog's accessibility tree. */
|
|
6
|
+
portalMount(): HTMLElement | undefined;
|
|
7
|
+
};
|
|
8
|
+
export type ContextualSidebarProps = {
|
|
9
|
+
/** Stable host id prefix; generated when omitted. */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Landmark name shared by the desktop and mobile navigation. */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Visible navigation title and mobile dialog title. */
|
|
14
|
+
title: string;
|
|
15
|
+
/** Host-controlled expanded state for the desktop panel and mobile dialog. */
|
|
16
|
+
open: boolean;
|
|
17
|
+
onOpenChange(open: boolean): void;
|
|
18
|
+
/** Current host-owned pixel width, reflected by the resize handle. */
|
|
19
|
+
width: number;
|
|
20
|
+
minimum: number;
|
|
21
|
+
maximum: number;
|
|
22
|
+
step?: number;
|
|
23
|
+
/** Pass the host's initial viewport seed to distinguish stale desktop state. */
|
|
24
|
+
wideViewportAtLoad?: boolean;
|
|
25
|
+
resizeLabel?: string;
|
|
26
|
+
/** Stable external opener used when the modal mobile sheet closes. */
|
|
27
|
+
restoreFocusRef?: Accessor<HTMLElement | undefined>;
|
|
28
|
+
/** Called with the nav node so a host can project width onto its layout root. */
|
|
29
|
+
onSidebarElement?: (element: HTMLElement | undefined, mobile: boolean) => void;
|
|
30
|
+
/** Host-owned layout classes applied to both nav instances. */
|
|
31
|
+
sidebarClass?: string;
|
|
32
|
+
/** Host-owned responsive constraints for the modal sheet. */
|
|
33
|
+
sheetClass?: string;
|
|
34
|
+
headerClass?: string;
|
|
35
|
+
contentClass?: string;
|
|
36
|
+
footerClass?: string;
|
|
37
|
+
headingAs?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
38
|
+
/** Optional action/content slot alongside the shared heading. */
|
|
39
|
+
header?(context: ContextualSidebarRenderContext): JSX.Element;
|
|
40
|
+
/** View-specific navigation rows, projects, rooms, files, or sessions. */
|
|
41
|
+
content(context: ContextualSidebarRenderContext): JSX.Element;
|
|
42
|
+
/** Optional view-specific footer, such as an archive affordance. */
|
|
43
|
+
footer?(context: ContextualSidebarRenderContext): JSX.Element;
|
|
44
|
+
onWidthChange(width: number): void;
|
|
45
|
+
onWidthCommit?(width: number): void;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* ContextualSidebar.
|
|
49
|
+
*
|
|
50
|
+
* Shared navigation geometry and interaction policy for an application's
|
|
51
|
+
* contextual sidebar. The host keeps ownership of the actual grid width,
|
|
52
|
+
* persisted preference, open state, and view-specific navigation content.
|
|
53
|
+
*/
|
|
54
|
+
export declare function ContextualSidebar(props: ContextualSidebarProps): JSX.Element;
|
|
55
|
+
//# sourceMappingURL=contextual-sidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextual-sidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/contextual-sidebar/contextual-sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAa7C,MAAM,MAAM,8BAA8B,GAAG;IAC3C,wEAAwE;IACxE,MAAM,EAAE,OAAO,CAAA;IACf,qFAAqF;IACrF,WAAW,IAAI,WAAW,GAAG,SAAS,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,qDAAqD;IACrD,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAA;IACb,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAA;IACb,8EAA8E;IAC9E,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;IACjC,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gFAAgF;IAChF,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,sEAAsE;IACtE,eAAe,CAAC,EAAE,QAAQ,CAAC,WAAW,GAAG,SAAS,CAAC,CAAA;IACnD,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IAC9E,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IACnD,iEAAiE;IACjE,MAAM,CAAC,CAAC,OAAO,EAAE,8BAA8B,GAAG,GAAG,CAAC,OAAO,CAAA;IAC7D,0EAA0E;IAC1E,OAAO,CAAC,OAAO,EAAE,8BAA8B,GAAG,GAAG,CAAC,OAAO,CAAA;IAC7D,oEAAoE;IACpE,MAAM,CAAC,CAAC,OAAO,EAAE,8BAA8B,GAAG,GAAG,CAAC,OAAO,CAAA;IAC7D,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAgH9D"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { cn } from "../../../lib/utils.js";
|
|
2
|
+
import { Sheet, SheetContent, SheetTitle } from "../../ui/sheet/sheet.js";
|
|
3
|
+
import { SidebarNav, SidebarNavContent, SidebarNavFooter, SidebarNavHeader, SidebarNavTitle } from "../sidebar-nav/sidebar-nav.js";
|
|
4
|
+
import { PixelResizeHandle } from "../pixel-resize-handle/pixel-resize-handle.js";
|
|
5
|
+
import { createComponent, memo } from "solid-js/web";
|
|
6
|
+
import { Show, createSignal, createUniqueId, onCleanup, onMount } from "solid-js";
|
|
7
|
+
//#region src/components/layout/contextual-sidebar/contextual-sidebar.tsx
|
|
8
|
+
/**
|
|
9
|
+
* ContextualSidebar.
|
|
10
|
+
*
|
|
11
|
+
* Shared navigation geometry and interaction policy for an application's
|
|
12
|
+
* contextual sidebar. The host keeps ownership of the actual grid width,
|
|
13
|
+
* persisted preference, open state, and view-specific navigation content.
|
|
14
|
+
*/
|
|
15
|
+
function ContextualSidebar(props) {
|
|
16
|
+
const [isNarrowViewport, setIsNarrowViewport] = createSignal(false);
|
|
17
|
+
const [mobileMount, setMobileMount] = createSignal();
|
|
18
|
+
const id = props.id ?? `contextual-sidebar-${createUniqueId()}`;
|
|
19
|
+
const resizeLabel = () => props.resizeLabel ?? `Resize ${props.label}`;
|
|
20
|
+
const portalMount = () => {
|
|
21
|
+
const mount = mobileMount();
|
|
22
|
+
return mount?.connected && mount.element.isConnected ? mount.element : void 0;
|
|
23
|
+
};
|
|
24
|
+
onMount(() => {
|
|
25
|
+
const media = window.matchMedia("(max-width: 48rem)");
|
|
26
|
+
const updateViewport = () => {
|
|
27
|
+
const wasNarrow = isNarrowViewport();
|
|
28
|
+
if (media.matches && !wasNarrow) props.onOpenChange(false);
|
|
29
|
+
setIsNarrowViewport(media.matches);
|
|
30
|
+
};
|
|
31
|
+
if (media.matches && props.wideViewportAtLoad && props.open) props.onOpenChange(false);
|
|
32
|
+
setIsNarrowViewport(media.matches);
|
|
33
|
+
media.addEventListener("change", updateViewport);
|
|
34
|
+
onCleanup(() => media.removeEventListener("change", updateViewport));
|
|
35
|
+
});
|
|
36
|
+
const renderSidebar = (mobile) => {
|
|
37
|
+
let element;
|
|
38
|
+
const context = {
|
|
39
|
+
mobile,
|
|
40
|
+
portalMount: () => mobile ? portalMount() : void 0
|
|
41
|
+
};
|
|
42
|
+
const navigationId = `${id}-${mobile ? "mobile" : "desktop"}`;
|
|
43
|
+
onCleanup(() => {
|
|
44
|
+
if (mobile && mobileMount()?.element === element) setMobileMount(void 0);
|
|
45
|
+
element = void 0;
|
|
46
|
+
props.onSidebarElement?.(void 0, mobile);
|
|
47
|
+
});
|
|
48
|
+
return createComponent(SidebarNav, {
|
|
49
|
+
as: "aside",
|
|
50
|
+
id: navigationId,
|
|
51
|
+
get ["aria-label"]() {
|
|
52
|
+
return props.label;
|
|
53
|
+
},
|
|
54
|
+
get ["aria-hidden"]() {
|
|
55
|
+
return !mobile && !props.open ? "true" : void 0;
|
|
56
|
+
},
|
|
57
|
+
get inert() {
|
|
58
|
+
return !mobile && !props.open;
|
|
59
|
+
},
|
|
60
|
+
"data-contextual-sidebar": mobile ? "mobile" : "desktop",
|
|
61
|
+
get ["data-open"]() {
|
|
62
|
+
return mobile ? void 0 : String(props.open);
|
|
63
|
+
},
|
|
64
|
+
ref: (node) => {
|
|
65
|
+
element = node;
|
|
66
|
+
if (mobile) {
|
|
67
|
+
setMobileMount({
|
|
68
|
+
element: node,
|
|
69
|
+
connected: node.isConnected
|
|
70
|
+
});
|
|
71
|
+
queueMicrotask(() => {
|
|
72
|
+
if (node.isConnected && mobileMount()?.element === node) setMobileMount({
|
|
73
|
+
element: node,
|
|
74
|
+
connected: true
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
props.onSidebarElement?.(node, mobile);
|
|
79
|
+
},
|
|
80
|
+
get ["class"]() {
|
|
81
|
+
return cn("relative h-full w-full max-w-full", props.sidebarClass);
|
|
82
|
+
},
|
|
83
|
+
get children() {
|
|
84
|
+
return [createComponent(Show, {
|
|
85
|
+
get when() {
|
|
86
|
+
return !mobile && props.open;
|
|
87
|
+
},
|
|
88
|
+
get children() {
|
|
89
|
+
return createComponent(PixelResizeHandle, {
|
|
90
|
+
side: "left",
|
|
91
|
+
get value() {
|
|
92
|
+
return props.width;
|
|
93
|
+
},
|
|
94
|
+
get minimum() {
|
|
95
|
+
return props.minimum;
|
|
96
|
+
},
|
|
97
|
+
get maximum() {
|
|
98
|
+
return props.maximum;
|
|
99
|
+
},
|
|
100
|
+
get step() {
|
|
101
|
+
return props.step;
|
|
102
|
+
},
|
|
103
|
+
get label() {
|
|
104
|
+
return resizeLabel();
|
|
105
|
+
},
|
|
106
|
+
controls: navigationId,
|
|
107
|
+
get onChange() {
|
|
108
|
+
return props.onWidthChange;
|
|
109
|
+
},
|
|
110
|
+
get onCommit() {
|
|
111
|
+
return props.onWidthCommit;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}), createComponent(Show, {
|
|
116
|
+
get when() {
|
|
117
|
+
return !mobile || mobileMount()?.connected;
|
|
118
|
+
},
|
|
119
|
+
get children() {
|
|
120
|
+
return [
|
|
121
|
+
createComponent(SidebarNavHeader, {
|
|
122
|
+
get ["class"]() {
|
|
123
|
+
return cn(mobile && "pe-12", props.headerClass);
|
|
124
|
+
},
|
|
125
|
+
get children() {
|
|
126
|
+
return [createComponent(SidebarNavTitle, {
|
|
127
|
+
get as() {
|
|
128
|
+
return props.headingAs ?? "h2";
|
|
129
|
+
},
|
|
130
|
+
get children() {
|
|
131
|
+
return props.title;
|
|
132
|
+
}
|
|
133
|
+
}), memo(() => props.header?.(context))];
|
|
134
|
+
}
|
|
135
|
+
}),
|
|
136
|
+
createComponent(SidebarNavContent, {
|
|
137
|
+
get ["class"]() {
|
|
138
|
+
return props.contentClass;
|
|
139
|
+
},
|
|
140
|
+
get children() {
|
|
141
|
+
return props.content(context);
|
|
142
|
+
}
|
|
143
|
+
}),
|
|
144
|
+
memo(() => memo(() => !!props.footer)() ? createComponent(SidebarNavFooter, {
|
|
145
|
+
get ["class"]() {
|
|
146
|
+
return props.footerClass;
|
|
147
|
+
},
|
|
148
|
+
get children() {
|
|
149
|
+
return props.footer(context);
|
|
150
|
+
}
|
|
151
|
+
}) : null)
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
})];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
return createComponent(Sheet, {
|
|
159
|
+
get open() {
|
|
160
|
+
return memo(() => !!isNarrowViewport())() && props.open;
|
|
161
|
+
},
|
|
162
|
+
onOpenChange: (open) => props.onOpenChange(open),
|
|
163
|
+
get children() {
|
|
164
|
+
return [createComponent(Show, {
|
|
165
|
+
get when() {
|
|
166
|
+
return !isNarrowViewport();
|
|
167
|
+
},
|
|
168
|
+
children: (_wide) => renderSidebar(false)
|
|
169
|
+
}), createComponent(Show, {
|
|
170
|
+
get when() {
|
|
171
|
+
return isNarrowViewport();
|
|
172
|
+
},
|
|
173
|
+
get children() {
|
|
174
|
+
return createComponent(SheetContent, {
|
|
175
|
+
side: "start",
|
|
176
|
+
get ["class"]() {
|
|
177
|
+
return cn("gap-0 p-0", props.sheetClass);
|
|
178
|
+
},
|
|
179
|
+
get restoreFocusRef() {
|
|
180
|
+
return props.restoreFocusRef;
|
|
181
|
+
},
|
|
182
|
+
get children() {
|
|
183
|
+
return [createComponent(SheetTitle, {
|
|
184
|
+
"class": "sr-only",
|
|
185
|
+
get children() {
|
|
186
|
+
return [memo(() => props.title), " navigation"];
|
|
187
|
+
}
|
|
188
|
+
}), memo(() => renderSidebar(true))];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
})];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
export { ContextualSidebar };
|
|
198
|
+
|
|
199
|
+
//# sourceMappingURL=contextual-sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextual-sidebar.js","names":["Accessor","JSX","Show","createSignal","createUniqueId","onCleanup","onMount","cn","Sheet","SheetContent","SheetTitle","SidebarNav","SidebarNavContent","SidebarNavFooter","SidebarNavHeader","SidebarNavTitle","PixelResizeHandle","ContextualSidebarRenderContext","mobile","portalMount","HTMLElement","ContextualSidebarProps","id","label","title","open","onOpenChange","width","minimum","maximum","step","wideViewportAtLoad","resizeLabel","restoreFocusRef","onSidebarElement","element","sidebarClass","sheetClass","headerClass","contentClass","footerClass","headingAs","header","context","Element","content","footer","onWidthChange","onWidthCommit","ContextualSidebar","props","isNarrowViewport","setIsNarrowViewport","mobileMount","setMobileMount","connected","mount","isConnected","undefined","media","window","matchMedia","updateViewport","wasNarrow","matches","addEventListener","removeEventListener","renderSidebar","navigationId","_$createComponent","as","aria-label","aria-hidden","inert","data-open","String","ref","node","queueMicrotask","class","children","when","side","value","controls","onChange","onCommit","_$memo","_wide","_$createComponent","_$memo"],"sources":["../../../../src/components/layout/contextual-sidebar/contextual-sidebar.tsx"],"sourcesContent":["import type { Accessor, JSX } from 'solid-js'\nimport { Show, createSignal, createUniqueId, onCleanup, onMount } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { Sheet, SheetContent, SheetTitle } from '../../ui/sheet'\nimport {\n SidebarNav,\n SidebarNavContent,\n SidebarNavFooter,\n SidebarNavHeader,\n SidebarNavTitle,\n} from '../sidebar-nav/sidebar-nav'\nimport { PixelResizeHandle } from '../pixel-resize-handle/pixel-resize-handle'\n\nexport type ContextualSidebarRenderContext = {\n /** Whether the slot is being rendered inside the modal mobile sheet. */\n mobile: boolean\n /** Mount nested popovers and menus inside the mobile dialog's accessibility tree. */\n portalMount(): HTMLElement | undefined\n}\n\nexport type ContextualSidebarProps = {\n /** Stable host id prefix; generated when omitted. */\n id?: string\n /** Landmark name shared by the desktop and mobile navigation. */\n label: string\n /** Visible navigation title and mobile dialog title. */\n title: string\n /** Host-controlled expanded state for the desktop panel and mobile dialog. */\n open: boolean\n onOpenChange(open: boolean): void\n /** Current host-owned pixel width, reflected by the resize handle. */\n width: number\n minimum: number\n maximum: number\n step?: number\n /** Pass the host's initial viewport seed to distinguish stale desktop state. */\n wideViewportAtLoad?: boolean\n resizeLabel?: string\n /** Stable external opener used when the modal mobile sheet closes. */\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n /** Called with the nav node so a host can project width onto its layout root. */\n onSidebarElement?: (element: HTMLElement | undefined, mobile: boolean) => void\n /** Host-owned layout classes applied to both nav instances. */\n sidebarClass?: string\n /** Host-owned responsive constraints for the modal sheet. */\n sheetClass?: string\n headerClass?: string\n contentClass?: string\n footerClass?: string\n headingAs?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'\n /** Optional action/content slot alongside the shared heading. */\n header?(context: ContextualSidebarRenderContext): JSX.Element\n /** View-specific navigation rows, projects, rooms, files, or sessions. */\n content(context: ContextualSidebarRenderContext): JSX.Element\n /** Optional view-specific footer, such as an archive affordance. */\n footer?(context: ContextualSidebarRenderContext): JSX.Element\n onWidthChange(width: number): void\n onWidthCommit?(width: number): void\n}\n\n/**\n * ContextualSidebar.\n *\n * Shared navigation geometry and interaction policy for an application's\n * contextual sidebar. The host keeps ownership of the actual grid width,\n * persisted preference, open state, and view-specific navigation content.\n */\nexport function ContextualSidebar(props: ContextualSidebarProps) {\n const [isNarrowViewport, setIsNarrowViewport] = createSignal(false)\n const [mobileMount, setMobileMount] = createSignal<\n { element: HTMLElement; connected: boolean } | undefined\n >()\n const id = props.id ?? `contextual-sidebar-${createUniqueId()}`\n const resizeLabel = () => props.resizeLabel ?? `Resize ${props.label}`\n const portalMount = () => {\n const mount = mobileMount()\n return mount?.connected && mount.element.isConnected ? mount.element : undefined\n }\n\n onMount(() => {\n const media = window.matchMedia('(max-width: 48rem)')\n const updateViewport = () => {\n const wasNarrow = isNarrowViewport()\n // Close before mounting a modal. A desktop-expanded host state is not\n // mobile intent, and opening the Sheet for one frame can steal focus.\n if (media.matches && !wasNarrow) props.onOpenChange(false)\n setIsNarrowViewport(media.matches)\n }\n\n // A route can mount after a wide-loaded host crosses into mobile. Clear\n // that stale seed, but preserve a sidebar intentionally opened at a\n // narrow boot viewport.\n if (media.matches && props.wideViewportAtLoad && props.open) props.onOpenChange(false)\n setIsNarrowViewport(media.matches)\n media.addEventListener('change', updateViewport)\n onCleanup(() => media.removeEventListener('change', updateViewport))\n })\n\n const renderSidebar = (mobile: boolean) => {\n let element: HTMLElement | undefined\n const context: ContextualSidebarRenderContext = {\n mobile,\n portalMount: () => (mobile ? portalMount() : undefined),\n }\n const navigationId = `${id}-${mobile ? 'mobile' : 'desktop'}`\n\n onCleanup(() => {\n if (mobile && mobileMount()?.element === element) setMobileMount(undefined)\n element = undefined\n props.onSidebarElement?.(undefined, mobile)\n })\n\n return (\n <SidebarNav\n as=\"aside\"\n id={navigationId}\n aria-label={props.label}\n aria-hidden={!mobile && !props.open ? 'true' : undefined}\n inert={!mobile && !props.open}\n data-contextual-sidebar={mobile ? 'mobile' : 'desktop'}\n data-open={mobile ? undefined : String(props.open)}\n ref={(node) => {\n element = node\n if (mobile) {\n setMobileMount({ element: node, connected: node.isConnected })\n queueMicrotask(() => {\n if (node.isConnected && mobileMount()?.element === node)\n setMobileMount({ element: node, connected: true })\n })\n }\n props.onSidebarElement?.(node, mobile)\n }}\n class={cn('relative h-full w-full max-w-full', props.sidebarClass)}\n >\n <Show when={!mobile && props.open}>\n <PixelResizeHandle\n side=\"left\"\n value={props.width}\n minimum={props.minimum}\n maximum={props.maximum}\n step={props.step}\n label={resizeLabel()}\n controls={navigationId}\n onChange={props.onWidthChange}\n onCommit={props.onWidthCommit}\n />\n </Show>\n <Show when={!mobile || mobileMount()?.connected}>\n <SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>\n <SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>\n {props.footer ? (\n <SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>\n ) : null}\n </Show>\n </SidebarNav>\n )\n }\n\n return (\n <Sheet\n open={isNarrowViewport() && props.open}\n onOpenChange={(open) => props.onOpenChange(open)}\n >\n <Show when={!isNarrowViewport()}>{(_wide) => renderSidebar(false)}</Show>\n <Show when={isNarrowViewport()}>\n <SheetContent\n side=\"start\"\n class={cn('gap-0 p-0', props.sheetClass)}\n restoreFocusRef={props.restoreFocusRef}\n >\n <SheetTitle class=\"sr-only\">{props.title} navigation</SheetTitle>\n {renderSidebar(true)}\n </SheetContent>\n </Show>\n </Sheet>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAmEA,SAAgBiD,kBAAkBC,OAA+B;CAC/D,MAAM,CAACC,kBAAkBC,uBAAuBjD,aAAa,KAAK;CAClE,MAAM,CAACkD,aAAaC,kBAAkBnD,aAEpC;CACF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E,MAAI;MAAA,KAAA,WAAA;OAAA,OACG3E,GAAG,aAAa2C,MAAMb,UAAU;MAAC;MAAA,IACxCJ,kBAAe;OAAA,OAAEiB,MAAMjB;MAAe;MAAA,IAAA+C,WAAA;OAAA,OAAA,CAAAX,gBAErC3D,YAAU;QAAA,SAAA;QAAA,IAAAsE,WAAA;SAAA,OAAA,CAAAO,WAAkBrC,MAAM1B,KAAK,GAAA,aAAA;QAAA;OAAA,CAAA,GAAA+D,WACvCpB,cAAc,IAAI,CAAC,CAAA;MAAA;KAAA,CAAA;IAAA;GAAA,CAAA,CAAA;EAAA;CAAA,CAAA;AAK9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/contextual-sidebar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,GACpC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/pixel-resize-handle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type PixelResizeHandleProps = {
|
|
2
|
+
/** Which physical edge of the ruler the resizable surface is attached to. */
|
|
3
|
+
side: 'left' | 'right';
|
|
4
|
+
/** Current width in CSS pixels. */
|
|
5
|
+
value: number;
|
|
6
|
+
minimum: number;
|
|
7
|
+
maximum: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
label?: string;
|
|
10
|
+
controls?: string;
|
|
11
|
+
class?: string;
|
|
12
|
+
onChange(value: number): void;
|
|
13
|
+
onCommit?(value: number): void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* PixelResizeHandle.
|
|
17
|
+
*
|
|
18
|
+
* A keyboard- and pointer-operable edge ruler for a host-owned pane. Keep the
|
|
19
|
+
* pane's actual width and any persistence in its layout owner; this component
|
|
20
|
+
* reports a bounded pixel value and places the shared resizable grip at the
|
|
21
|
+
* matching left or right edge.
|
|
22
|
+
*
|
|
23
|
+
* Corvu 0.2.5 supplies geometry, keyboard resizing, ARIA and the shared grip,
|
|
24
|
+
* but its global drag handler does not end on pointer cancellation. Prevent
|
|
25
|
+
* that handler through its public start hook and use local pointer capture
|
|
26
|
+
* for bounded pixel gestures, including cancellation and lost capture.
|
|
27
|
+
*/
|
|
28
|
+
export declare function PixelResizeHandle(props: PixelResizeHandleProps): import("solid-js").JSX.Element;
|
|
29
|
+
//# sourceMappingURL=pixel-resize-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixel-resize-handle.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG;IACnC,6EAA6E;IAC7E,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,kCAgJ9D"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { cn } from "../../../lib/utils.js";
|
|
2
|
+
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "../../ui/resizable/resizable.js";
|
|
3
|
+
import { createComponent, memo } from "solid-js/web";
|
|
4
|
+
import { createSignal, onCleanup } from "solid-js";
|
|
5
|
+
//#region src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx
|
|
6
|
+
/**
|
|
7
|
+
* PixelResizeHandle.
|
|
8
|
+
*
|
|
9
|
+
* A keyboard- and pointer-operable edge ruler for a host-owned pane. Keep the
|
|
10
|
+
* pane's actual width and any persistence in its layout owner; this component
|
|
11
|
+
* reports a bounded pixel value and places the shared resizable grip at the
|
|
12
|
+
* matching left or right edge.
|
|
13
|
+
*
|
|
14
|
+
* Corvu 0.2.5 supplies geometry, keyboard resizing, ARIA and the shared grip,
|
|
15
|
+
* but its global drag handler does not end on pointer cancellation. Prevent
|
|
16
|
+
* that handler through its public start hook and use local pointer capture
|
|
17
|
+
* for bounded pixel gestures, including cancellation and lost capture.
|
|
18
|
+
*/
|
|
19
|
+
function PixelResizeHandle(props) {
|
|
20
|
+
const maximum = () => Math.max(1, props.maximum);
|
|
21
|
+
const minimum = () => Math.min(maximum(), Math.max(0, props.minimum));
|
|
22
|
+
const value = () => Math.min(maximum(), Math.max(minimum(), Math.round(props.value)));
|
|
23
|
+
const ratio = () => value() / maximum();
|
|
24
|
+
const isRight = () => props.side === "right";
|
|
25
|
+
const rulerSizes = () => isRight() ? [1 - ratio(), ratio()] : [ratio(), 1 - ratio()];
|
|
26
|
+
const commit = () => props.onCommit?.(value());
|
|
27
|
+
let interacting = false;
|
|
28
|
+
const [drag, setDrag] = createSignal();
|
|
29
|
+
const endPointer = (shouldCommit) => {
|
|
30
|
+
const current = drag();
|
|
31
|
+
if (!current) return;
|
|
32
|
+
setDrag(void 0);
|
|
33
|
+
if (current.handle.hasPointerCapture(current.pointerId)) current.handle.releasePointerCapture(current.pointerId);
|
|
34
|
+
if (shouldCommit) commit();
|
|
35
|
+
};
|
|
36
|
+
const endKeyboard = () => {
|
|
37
|
+
const wasInteracting = interacting;
|
|
38
|
+
interacting = false;
|
|
39
|
+
if (wasInteracting) commit();
|
|
40
|
+
};
|
|
41
|
+
onCleanup(() => {
|
|
42
|
+
endKeyboard();
|
|
43
|
+
endPointer(false);
|
|
44
|
+
});
|
|
45
|
+
return createComponent(ResizablePanelGroup, {
|
|
46
|
+
orientation: "horizontal",
|
|
47
|
+
dir: "ltr",
|
|
48
|
+
get sizes() {
|
|
49
|
+
return rulerSizes();
|
|
50
|
+
},
|
|
51
|
+
get keyboardDelta() {
|
|
52
|
+
return `${props.step ?? 16}px`;
|
|
53
|
+
},
|
|
54
|
+
get style() {
|
|
55
|
+
return { width: `${maximum()}px` };
|
|
56
|
+
},
|
|
57
|
+
get ["class"]() {
|
|
58
|
+
return cn("pointer-events-none absolute inset-y-0 flex", {
|
|
59
|
+
"left-0": props.side === "left",
|
|
60
|
+
"right-0": props.side === "right"
|
|
61
|
+
}, props.class);
|
|
62
|
+
},
|
|
63
|
+
onSizesChange: (sizes) => {
|
|
64
|
+
if (!interacting || sizes.length !== 2) return;
|
|
65
|
+
const next = Math.round((sizes[isRight() ? 1 : 0] ?? ratio()) * maximum());
|
|
66
|
+
const bounded = Math.min(maximum(), Math.max(minimum(), next));
|
|
67
|
+
if (bounded !== value()) props.onChange(bounded);
|
|
68
|
+
},
|
|
69
|
+
get children() {
|
|
70
|
+
return [
|
|
71
|
+
createComponent(ResizablePanel, {
|
|
72
|
+
get minSize() {
|
|
73
|
+
return memo(() => !!isRight())() ? 0 : minimum() / maximum();
|
|
74
|
+
},
|
|
75
|
+
maxSize: 1,
|
|
76
|
+
"aria-hidden": "true"
|
|
77
|
+
}),
|
|
78
|
+
createComponent(ResizableHandle, {
|
|
79
|
+
withHandle: true,
|
|
80
|
+
get label() {
|
|
81
|
+
return props.label ?? `Resize ${props.side} pane`;
|
|
82
|
+
},
|
|
83
|
+
get ["aria-controls"]() {
|
|
84
|
+
return props.controls;
|
|
85
|
+
},
|
|
86
|
+
get ["aria-valuemin"]() {
|
|
87
|
+
return minimum();
|
|
88
|
+
},
|
|
89
|
+
get ["aria-valuemax"]() {
|
|
90
|
+
return maximum();
|
|
91
|
+
},
|
|
92
|
+
get ["aria-valuenow"]() {
|
|
93
|
+
return value();
|
|
94
|
+
},
|
|
95
|
+
get ["aria-valuetext"]() {
|
|
96
|
+
return `${value()} pixels`;
|
|
97
|
+
},
|
|
98
|
+
get ["data-dragging"]() {
|
|
99
|
+
return drag() ? "" : void 0;
|
|
100
|
+
},
|
|
101
|
+
onHandleDragStart: (event) => {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
if (event.button !== 0 || !event.isPrimary) return;
|
|
104
|
+
const handle = event.currentTarget;
|
|
105
|
+
if (!(handle instanceof HTMLElement)) return;
|
|
106
|
+
endPointer(false);
|
|
107
|
+
interacting = false;
|
|
108
|
+
handle.focus();
|
|
109
|
+
handle.setPointerCapture(event.pointerId);
|
|
110
|
+
setDrag({
|
|
111
|
+
pointerId: event.pointerId,
|
|
112
|
+
startX: event.clientX,
|
|
113
|
+
startValue: value(),
|
|
114
|
+
handle
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
onPointerMove: (event) => {
|
|
118
|
+
const current = drag();
|
|
119
|
+
if (!current || event.pointerId !== current.pointerId) return;
|
|
120
|
+
if (!current.handle.hasPointerCapture(current.pointerId)) {
|
|
121
|
+
endPointer(false);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const delta = (event.clientX - current.startX) * (isRight() ? -1 : 1);
|
|
125
|
+
const next = Math.min(maximum(), Math.max(minimum(), Math.round(current.startValue + delta)));
|
|
126
|
+
if (next !== value()) props.onChange(next);
|
|
127
|
+
},
|
|
128
|
+
onPointerUp: (event) => {
|
|
129
|
+
if (event.pointerId === drag()?.pointerId) endPointer(true);
|
|
130
|
+
},
|
|
131
|
+
onPointerCancel: (event) => {
|
|
132
|
+
if (event.pointerId === drag()?.pointerId) endPointer(false);
|
|
133
|
+
},
|
|
134
|
+
onLostPointerCapture: (event) => {
|
|
135
|
+
if (event.pointerId === drag()?.pointerId) endPointer(false);
|
|
136
|
+
},
|
|
137
|
+
onBlur: () => {
|
|
138
|
+
endKeyboard();
|
|
139
|
+
endPointer(false);
|
|
140
|
+
},
|
|
141
|
+
onKeyDown: (event) => {
|
|
142
|
+
const current = drag();
|
|
143
|
+
if (current && !current.handle.hasPointerCapture(current.pointerId)) endPointer(false);
|
|
144
|
+
if (drag()) {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if ([
|
|
149
|
+
"ArrowLeft",
|
|
150
|
+
"ArrowRight",
|
|
151
|
+
"Home",
|
|
152
|
+
"End"
|
|
153
|
+
].includes(event.key)) interacting = true;
|
|
154
|
+
if (event.key === "Home" || event.key === "End") {
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
props.onChange(event.key === "Home" ? minimum() : maximum());
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
onKeyUp: (event) => {
|
|
160
|
+
if ([
|
|
161
|
+
"ArrowLeft",
|
|
162
|
+
"ArrowRight",
|
|
163
|
+
"Home",
|
|
164
|
+
"End"
|
|
165
|
+
].includes(event.key)) endKeyboard();
|
|
166
|
+
},
|
|
167
|
+
"class": "pointer-events-auto"
|
|
168
|
+
}),
|
|
169
|
+
createComponent(ResizablePanel, {
|
|
170
|
+
get minSize() {
|
|
171
|
+
return memo(() => !!isRight())() ? minimum() / maximum() : 0;
|
|
172
|
+
},
|
|
173
|
+
maxSize: 1,
|
|
174
|
+
"aria-hidden": "true"
|
|
175
|
+
})
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { PixelResizeHandle };
|
|
182
|
+
|
|
183
|
+
//# sourceMappingURL=pixel-resize-handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixel-resize-handle.js","names":["ResizableHandle","ResizablePanel","ResizablePanelGroup","createSignal","onCleanup","cn","PixelResizeHandleProps","side","value","minimum","maximum","step","label","controls","class","onChange","onCommit","PixelResizeHandle","props","Math","max","min","round","ratio","isRight","rulerSizes","commit","interacting","drag","setDrag","pointerId","startX","startValue","handle","HTMLElement","endPointer","shouldCommit","current","undefined","hasPointerCapture","releasePointerCapture","endKeyboard","wasInteracting","_$createComponent","orientation","dir","sizes","keyboardDelta","style","width","onSizesChange","length","next","bounded","children","minSize","_$memo","maxSize","withHandle","aria-controls","aria-valuemin","aria-valuemax","aria-valuenow","aria-valuetext","data-dragging","onHandleDragStart","event","preventDefault","button","isPrimary","currentTarget","focus","setPointerCapture","clientX","onPointerMove","PointerEvent","delta","onPointerUp","onPointerCancel","onLostPointerCapture","onBlur","onKeyDown","includes","key","onKeyUp","_$createComponent","_$memo"],"sources":["../../../../src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx"],"sourcesContent":["import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '../../ui/resizable'\nimport { createSignal, onCleanup } from 'solid-js'\nimport { cn } from '#lib/utils'\n\nexport type PixelResizeHandleProps = {\n /** Which physical edge of the ruler the resizable surface is attached to. */\n side: 'left' | 'right'\n /** Current width in CSS pixels. */\n value: number\n minimum: number\n maximum: number\n step?: number\n label?: string\n controls?: string\n class?: string\n onChange(value: number): void\n onCommit?(value: number): void\n}\n\n/**\n * PixelResizeHandle.\n *\n * A keyboard- and pointer-operable edge ruler for a host-owned pane. Keep the\n * pane's actual width and any persistence in its layout owner; this component\n * reports a bounded pixel value and places the shared resizable grip at the\n * matching left or right edge.\n *\n * Corvu 0.2.5 supplies geometry, keyboard resizing, ARIA and the shared grip,\n * but its global drag handler does not end on pointer cancellation. Prevent\n * that handler through its public start hook and use local pointer capture\n * for bounded pixel gestures, including cancellation and lost capture.\n */\nexport function PixelResizeHandle(props: PixelResizeHandleProps) {\n const maximum = () => Math.max(1, props.maximum)\n const minimum = () => Math.min(maximum(), Math.max(0, props.minimum))\n const value = () => Math.min(maximum(), Math.max(minimum(), Math.round(props.value)))\n const ratio = () => value() / maximum()\n const isRight = () => props.side === 'right'\n const rulerSizes = () => (isRight() ? [1 - ratio(), ratio()] : [ratio(), 1 - ratio()])\n const commit = () => props.onCommit?.(value())\n let interacting = false\n const [drag, setDrag] = createSignal<{\n pointerId: number\n startX: number\n startValue: number\n handle: HTMLElement\n }>()\n const endPointer = (shouldCommit: boolean) => {\n const current = drag()\n if (!current) return\n setDrag(undefined)\n if (current.handle.hasPointerCapture(current.pointerId))\n current.handle.releasePointerCapture(current.pointerId)\n if (shouldCommit) commit()\n }\n const endKeyboard = () => {\n const wasInteracting = interacting\n interacting = false\n if (wasInteracting) commit()\n }\n onCleanup(() => {\n endKeyboard()\n endPointer(false)\n })\n\n return (\n <ResizablePanelGroup\n orientation=\"horizontal\"\n dir=\"ltr\"\n sizes={rulerSizes()}\n keyboardDelta={`${props.step ?? 16}px`}\n style={{ width: `${maximum()}px` }}\n class={cn(\n 'pointer-events-none absolute inset-y-0 flex',\n {\n 'left-0': props.side === 'left',\n 'right-0': props.side === 'right',\n },\n props.class\n )}\n onSizesChange={(sizes) => {\n // Panel registration and teardown also emit sizes. Only user resizing\n // may update the host preference; collapsing must preserve its width.\n if (!interacting || sizes.length !== 2) return\n const next = Math.round((sizes[isRight() ? 1 : 0] ?? ratio()) * maximum())\n const bounded = Math.min(maximum(), Math.max(minimum(), next))\n if (bounded !== value()) props.onChange(bounded)\n }}\n >\n <ResizablePanel\n minSize={isRight() ? 0 : minimum() / maximum()}\n maxSize={1}\n aria-hidden=\"true\"\n />\n <ResizableHandle\n withHandle\n label={props.label ?? `Resize ${props.side} pane`}\n aria-controls={props.controls}\n aria-valuemin={minimum()}\n aria-valuemax={maximum()}\n aria-valuenow={value()}\n aria-valuetext={`${value()} pixels`}\n data-dragging={drag() ? '' : undefined}\n onHandleDragStart={(event) => {\n // Corvu checks defaultPrevented before starting its global handler.\n event.preventDefault()\n if (event.button !== 0 || !event.isPrimary) return\n const handle = event.currentTarget\n if (!(handle instanceof HTMLElement)) return\n endPointer(false)\n interacting = false\n handle.focus()\n handle.setPointerCapture(event.pointerId)\n setDrag({\n pointerId: event.pointerId,\n startX: event.clientX,\n startValue: value(),\n handle,\n })\n }}\n onPointerMove={(event: PointerEvent) => {\n const current = drag()\n if (!current || event.pointerId !== current.pointerId) return\n if (!current.handle.hasPointerCapture(current.pointerId)) {\n endPointer(false)\n return\n }\n const delta = (event.clientX - current.startX) * (isRight() ? -1 : 1)\n const next = Math.min(\n maximum(),\n Math.max(minimum(), Math.round(current.startValue + delta))\n )\n if (next !== value()) props.onChange(next)\n }}\n onPointerUp={(event: PointerEvent) => {\n if (event.pointerId === drag()?.pointerId) endPointer(true)\n }}\n onPointerCancel={(event: PointerEvent) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onLostPointerCapture={(event: PointerEvent) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onBlur={() => {\n endKeyboard()\n endPointer(false)\n }}\n onKeyDown={(event) => {\n const current = drag()\n if (current && !current.handle.hasPointerCapture(current.pointerId)) endPointer(false)\n if (drag()) {\n event.preventDefault()\n return\n }\n if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) interacting = true\n // Corvu operates on physical panel order. Home/End here describe\n // the controlled pane width, including a pane after the separator.\n if (event.key === 'Home' || event.key === 'End') {\n event.preventDefault()\n props.onChange(event.key === 'Home' ? minimum() : maximum())\n }\n }}\n onKeyUp={(event) => {\n if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) {\n endKeyboard()\n }\n }}\n class=\"pointer-events-auto\"\n />\n <ResizablePanel\n minSize={isRight() ? minimum() / maximum() : 0}\n maxSize={1}\n aria-hidden=\"true\"\n />\n </ResizablePanelGroup>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgCA,SAA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;MAAK,CAAC,CAACe,SAAShB,MAAMiB,GAAG,GAAGxD,cAAc;MAGlF,IAAIuC,MAAMiB,QAAQ,UAAUjB,MAAMiB,QAAQ,OAAO;OAC/CjB,MAAMC,eAAe;OACrBjD,MAAMH,SAASmD,MAAMiB,QAAQ,SAAS1E,QAAQ,IAAIC,QAAQ,CAAC;MAC7D;KACF;KACA0E,UAAUlB,UAAU;MAClB,IAAI;OAAC;OAAa;OAAc;OAAQ;MAAK,CAAC,CAACgB,SAAShB,MAAMiB,GAAG,GAC/D1C,YAAY;KAEhB;KAAC,SAAA;IAAA,CAAA;IAAAE,gBAGF1C,gBAAc;KAAA,IACbsD,UAAO;MAAA,OAAEC,WAAA,CAAA,CAAAhC,QAAQ,CAAC,CAAA,CAAA,IAAGf,QAAQ,IAAIC,QAAQ,IAAI;KAAC;KAC9C+C,SAAS;KAAC,eAAA;IAAA,CAAA;GAAA;EAAA;CAAA,CAAA;AAKlB"}
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
maximum: number;
|
|
5
|
-
step?: number;
|
|
6
|
-
label?: string;
|
|
7
|
-
controls?: string;
|
|
8
|
-
class?: string;
|
|
9
|
-
onChange(value: number): void;
|
|
10
|
-
onCommit?(value: number): void;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Resize a contextual sidebar without making its host recreate a separator
|
|
14
|
-
* widget. Corvu owns pointer capture, cancellation, constraints, keyboard
|
|
15
|
-
* movement and cleanup. Its two invisible panels provide a bounded pixel
|
|
16
|
-
* ruler; the host retains the real pane layout and preference persistence.
|
|
17
|
-
* Place this inside the positioned sidebar. The ruler can extend over the
|
|
18
|
-
* adjacent content, but only its handle participates in pointer hit testing.
|
|
19
|
-
*/
|
|
1
|
+
import { type PixelResizeHandleProps } from '../pixel-resize-handle/pixel-resize-handle';
|
|
2
|
+
export type SidebarNavResizeHandleProps = Omit<PixelResizeHandleProps, 'side'>;
|
|
3
|
+
/** Keep the established left-sidebar API as a thin adapter over the shared edge ruler. */
|
|
20
4
|
export declare function SidebarNavResizeHandle(props: SidebarNavResizeHandleProps): import("solid-js").JSX.Element;
|
|
21
5
|
//# sourceMappingURL=sidebar-nav-resize-handle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-nav-resize-handle.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sidebar-nav-resize-handle.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,4CAA4C,CAAA;AAEnD,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAA;AAE9E,0FAA0F;AAC1F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,kCAExE"}
|