@wow-two-beta/ui 0.0.14 → 0.0.16
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/actions/index.d.ts +1 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +3 -3
- package/dist/actions/speedDial/SpeedDial.d.ts +38 -0
- package/dist/actions/speedDial/SpeedDial.d.ts.map +1 -0
- package/dist/actions/speedDial/index.d.ts +3 -0
- package/dist/actions/speedDial/index.d.ts.map +1 -0
- package/dist/{chunk-FS6DTWWH.js → chunk-2VAZKEQD.js} +6 -231
- package/dist/chunk-2VAZKEQD.js.map +1 -0
- package/dist/{chunk-RIW2V3N4.js → chunk-3IN5ULKY.js} +213 -5
- package/dist/chunk-3IN5ULKY.js.map +1 -0
- package/dist/{chunk-UGHPZ3I7.js → chunk-4ESR253U.js} +331 -5
- package/dist/chunk-4ESR253U.js.map +1 -0
- package/dist/chunk-ASIHQQDQ.js +27 -0
- package/dist/chunk-ASIHQQDQ.js.map +1 -0
- package/dist/chunk-FFQENBTW.js +31 -0
- package/dist/chunk-FFQENBTW.js.map +1 -0
- package/dist/{chunk-BQTO7XY6.js → chunk-ILYL6ROC.js} +548 -33
- package/dist/chunk-ILYL6ROC.js.map +1 -0
- package/dist/{chunk-YMSAS7M7.js → chunk-NC2CBGX2.js} +24 -4
- package/dist/chunk-NC2CBGX2.js.map +1 -0
- package/dist/{chunk-ULAOIBCP.js → chunk-NRAJPSEK.js} +164 -7
- package/dist/chunk-NRAJPSEK.js.map +1 -0
- package/dist/chunk-SM2TOB4U.js +641 -0
- package/dist/chunk-SM2TOB4U.js.map +1 -0
- package/dist/{chunk-ASXB42MH.js → chunk-W7LQZKTH.js} +246 -42
- package/dist/chunk-W7LQZKTH.js.map +1 -0
- package/dist/chunk-XHGWBSIR.js +222 -0
- package/dist/chunk-XHGWBSIR.js.map +1 -0
- package/dist/chunk-ZCA365IX.js +44 -0
- package/dist/chunk-ZCA365IX.js.map +1 -0
- package/dist/display/carousel/Carousel.d.ts +47 -0
- package/dist/display/carousel/Carousel.d.ts.map +1 -0
- package/dist/display/carousel/index.d.ts +3 -0
- package/dist/display/carousel/index.d.ts.map +1 -0
- package/dist/display/index.d.ts +1 -0
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.js +4 -3
- package/dist/feedback/index.d.ts +2 -0
- package/dist/feedback/index.d.ts.map +1 -1
- package/dist/feedback/index.js +4 -1
- package/dist/feedback/loadingOverlay/LoadingOverlay.d.ts +19 -0
- package/dist/feedback/loadingOverlay/LoadingOverlay.d.ts.map +1 -0
- package/dist/feedback/loadingOverlay/index.d.ts +2 -0
- package/dist/feedback/loadingOverlay/index.d.ts.map +1 -0
- package/dist/feedback/toaster/Toaster.d.ts +49 -0
- package/dist/feedback/toaster/Toaster.d.ts.map +1 -0
- package/dist/feedback/toaster/index.d.ts +2 -0
- package/dist/feedback/toaster/index.d.ts.map +1 -0
- package/dist/forms/editable/Editable.d.ts +37 -0
- package/dist/forms/editable/Editable.d.ts.map +1 -0
- package/dist/forms/editable/index.d.ts +3 -0
- package/dist/forms/editable/index.d.ts.map +1 -0
- package/dist/forms/fileUpload/FileUpload.d.ts +25 -0
- package/dist/forms/fileUpload/FileUpload.d.ts.map +1 -0
- package/dist/forms/fileUpload/index.d.ts +2 -0
- package/dist/forms/fileUpload/index.d.ts.map +1 -0
- package/dist/forms/index.d.ts +3 -0
- package/dist/forms/index.d.ts.map +1 -1
- package/dist/forms/index.js +8 -4
- package/dist/forms/tagsInput/TagsInput.d.ts +26 -0
- package/dist/forms/tagsInput/TagsInput.d.ts.map +1 -0
- package/dist/forms/tagsInput/index.d.ts +2 -0
- package/dist/forms/tagsInput/index.d.ts.map +1 -0
- package/dist/index.js +13 -9
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +3 -1
- package/dist/layout/resizablePanels/ResizablePanels.d.ts +27 -0
- package/dist/layout/resizablePanels/ResizablePanels.d.ts.map +1 -0
- package/dist/layout/resizablePanels/index.d.ts +3 -0
- package/dist/layout/resizablePanels/index.d.ts.map +1 -0
- package/dist/nav/commandPalette/CommandPalette.d.ts +48 -0
- package/dist/nav/commandPalette/CommandPalette.d.ts.map +1 -0
- package/dist/nav/commandPalette/index.d.ts +3 -0
- package/dist/nav/commandPalette/index.d.ts.map +1 -0
- package/dist/nav/index.d.ts +1 -0
- package/dist/nav/index.d.ts.map +1 -1
- package/dist/nav/index.js +6 -3
- package/dist/overlays/index.js +5 -3
- package/dist/primitives/announce/Announce.d.ts +13 -0
- package/dist/primitives/announce/Announce.d.ts.map +1 -0
- package/dist/primitives/announce/index.d.ts +2 -0
- package/dist/primitives/announce/index.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-ASXB42MH.js.map +0 -1
- package/dist/chunk-BQTO7XY6.js.map +0 -1
- package/dist/chunk-FS6DTWWH.js.map +0 -1
- package/dist/chunk-NKGNOOXJ.js +0 -330
- package/dist/chunk-NKGNOOXJ.js.map +0 -1
- package/dist/chunk-RIW2V3N4.js.map +0 -1
- package/dist/chunk-UGHPZ3I7.js.map +0 -1
- package/dist/chunk-ULAOIBCP.js.map +0 -1
- package/dist/chunk-YMSAS7M7.js.map +0 -1
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
import { useControlled } from './chunk-4P2TFUVW.js';
|
|
2
|
+
import { tv } from './chunk-BMBIZLO4.js';
|
|
3
|
+
import { cn } from './chunk-KZ4VFY2T.js';
|
|
4
|
+
import { forwardRef, createContext, useRef, useEffect, useCallback, useMemo, Children, isValidElement, useState, useContext } from 'react';
|
|
5
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var Box = forwardRef(
|
|
8
|
+
({ as: Component = "div", className, ...props }, ref) => /* @__PURE__ */ jsx(Component, { ref, className: cn(className), ...props })
|
|
9
|
+
);
|
|
10
|
+
Box.displayName = "Box";
|
|
11
|
+
|
|
12
|
+
// src/layout/stack/Stack.variants.ts
|
|
13
|
+
var stackVariants = tv({
|
|
14
|
+
base: "flex",
|
|
15
|
+
variants: {
|
|
16
|
+
direction: {
|
|
17
|
+
row: "flex-row",
|
|
18
|
+
column: "flex-col",
|
|
19
|
+
"row-reverse": "flex-row-reverse",
|
|
20
|
+
"column-reverse": "flex-col-reverse"
|
|
21
|
+
},
|
|
22
|
+
align: {
|
|
23
|
+
start: "items-start",
|
|
24
|
+
center: "items-center",
|
|
25
|
+
end: "items-end",
|
|
26
|
+
stretch: "items-stretch",
|
|
27
|
+
baseline: "items-baseline"
|
|
28
|
+
},
|
|
29
|
+
justify: {
|
|
30
|
+
start: "justify-start",
|
|
31
|
+
center: "justify-center",
|
|
32
|
+
end: "justify-end",
|
|
33
|
+
between: "justify-between",
|
|
34
|
+
around: "justify-around",
|
|
35
|
+
evenly: "justify-evenly"
|
|
36
|
+
},
|
|
37
|
+
gap: {
|
|
38
|
+
"0": "gap-0",
|
|
39
|
+
"1": "gap-1",
|
|
40
|
+
"2": "gap-2",
|
|
41
|
+
"3": "gap-3",
|
|
42
|
+
"4": "gap-4",
|
|
43
|
+
"5": "gap-5",
|
|
44
|
+
"6": "gap-6",
|
|
45
|
+
"8": "gap-8",
|
|
46
|
+
"10": "gap-10",
|
|
47
|
+
"12": "gap-12"
|
|
48
|
+
},
|
|
49
|
+
wrap: {
|
|
50
|
+
wrap: "flex-wrap",
|
|
51
|
+
nowrap: "flex-nowrap",
|
|
52
|
+
"wrap-reverse": "flex-wrap-reverse"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
defaultVariants: {
|
|
56
|
+
direction: "column",
|
|
57
|
+
gap: "4"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var Stack = forwardRef(
|
|
61
|
+
({ as: Component = "div", className, direction, align, justify, gap, wrap, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
62
|
+
Component,
|
|
63
|
+
{
|
|
64
|
+
ref,
|
|
65
|
+
className: cn(stackVariants({ direction, align, justify, gap, wrap }), className),
|
|
66
|
+
...props
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
Stack.displayName = "Stack";
|
|
71
|
+
var HStack = forwardRef((props, ref) => /* @__PURE__ */ jsx(Stack, { ref, direction: "row", ...props }));
|
|
72
|
+
HStack.displayName = "HStack";
|
|
73
|
+
var VStack = forwardRef((props, ref) => /* @__PURE__ */ jsx(Stack, { ref, direction: "column", ...props }));
|
|
74
|
+
VStack.displayName = "VStack";
|
|
75
|
+
|
|
76
|
+
// src/layout/grid/Grid.variants.ts
|
|
77
|
+
var gridVariants = tv({
|
|
78
|
+
base: "grid",
|
|
79
|
+
variants: {
|
|
80
|
+
columns: {
|
|
81
|
+
"1": "grid-cols-1",
|
|
82
|
+
"2": "grid-cols-2",
|
|
83
|
+
"3": "grid-cols-3",
|
|
84
|
+
"4": "grid-cols-4",
|
|
85
|
+
"5": "grid-cols-5",
|
|
86
|
+
"6": "grid-cols-6",
|
|
87
|
+
"8": "grid-cols-8",
|
|
88
|
+
"12": "grid-cols-12"
|
|
89
|
+
},
|
|
90
|
+
gap: {
|
|
91
|
+
"0": "gap-0",
|
|
92
|
+
"1": "gap-1",
|
|
93
|
+
"2": "gap-2",
|
|
94
|
+
"3": "gap-3",
|
|
95
|
+
"4": "gap-4",
|
|
96
|
+
"5": "gap-5",
|
|
97
|
+
"6": "gap-6",
|
|
98
|
+
"8": "gap-8",
|
|
99
|
+
"10": "gap-10",
|
|
100
|
+
"12": "gap-12"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
defaultVariants: {
|
|
104
|
+
columns: "2",
|
|
105
|
+
gap: "4"
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
var Grid = forwardRef(
|
|
109
|
+
({ as: Component = "div", className, columns, gap, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
110
|
+
Component,
|
|
111
|
+
{
|
|
112
|
+
ref,
|
|
113
|
+
className: cn(gridVariants({ columns, gap }), className),
|
|
114
|
+
...props
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
Grid.displayName = "Grid";
|
|
119
|
+
|
|
120
|
+
// src/layout/container/Container.variants.ts
|
|
121
|
+
var containerVariants = tv({
|
|
122
|
+
base: "mx-auto w-full px-4",
|
|
123
|
+
variants: {
|
|
124
|
+
size: {
|
|
125
|
+
sm: "max-w-screen-sm",
|
|
126
|
+
md: "max-w-screen-md",
|
|
127
|
+
lg: "max-w-screen-lg",
|
|
128
|
+
xl: "max-w-screen-xl",
|
|
129
|
+
"2xl": "max-w-screen-2xl",
|
|
130
|
+
full: "max-w-full"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
defaultVariants: {
|
|
134
|
+
size: "lg"
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
var Container = forwardRef(
|
|
138
|
+
({ as: Component = "div", className, size, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
139
|
+
Component,
|
|
140
|
+
{
|
|
141
|
+
ref,
|
|
142
|
+
className: cn(containerVariants({ size }), className),
|
|
143
|
+
...props
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
Container.displayName = "Container";
|
|
148
|
+
var Flex = forwardRef(
|
|
149
|
+
({ as: Component = "div", className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
150
|
+
Component,
|
|
151
|
+
{
|
|
152
|
+
ref,
|
|
153
|
+
className: cn("flex", className),
|
|
154
|
+
...props
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
);
|
|
158
|
+
Flex.displayName = "Flex";
|
|
159
|
+
var AspectRatio = forwardRef(
|
|
160
|
+
({ ratio = 1, className, style, children, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
161
|
+
"div",
|
|
162
|
+
{
|
|
163
|
+
ref,
|
|
164
|
+
className: cn("relative w-full", className),
|
|
165
|
+
style: { aspectRatio: `${ratio}`, ...style },
|
|
166
|
+
...props,
|
|
167
|
+
children
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
AspectRatio.displayName = "AspectRatio";
|
|
172
|
+
var Spacer = forwardRef(
|
|
173
|
+
({ size, axis = "horizontal", className, style, ...props }, ref) => {
|
|
174
|
+
const fixed = size !== void 0 ? axis === "horizontal" ? { width: typeof size === "number" ? `${size}px` : size, flexShrink: 0 } : { height: typeof size === "number" ? `${size}px` : size, flexShrink: 0 } : void 0;
|
|
175
|
+
return /* @__PURE__ */ jsx(
|
|
176
|
+
"div",
|
|
177
|
+
{
|
|
178
|
+
ref,
|
|
179
|
+
"aria-hidden": "true",
|
|
180
|
+
className: cn(size === void 0 && "flex-1", className),
|
|
181
|
+
style: { ...fixed, ...style },
|
|
182
|
+
...props
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
Spacer.displayName = "Spacer";
|
|
188
|
+
var Center = forwardRef(
|
|
189
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
ref,
|
|
193
|
+
className: cn("flex items-center justify-center", className),
|
|
194
|
+
...props
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
);
|
|
198
|
+
Center.displayName = "Center";
|
|
199
|
+
var ScrollArea = forwardRef(
|
|
200
|
+
({ axis = "vertical", className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
ref,
|
|
204
|
+
className: cn(
|
|
205
|
+
"relative",
|
|
206
|
+
axis === "vertical" && "overflow-y-auto overflow-x-hidden",
|
|
207
|
+
axis === "horizontal" && "overflow-x-auto overflow-y-hidden",
|
|
208
|
+
axis === "both" && "overflow-auto",
|
|
209
|
+
className
|
|
210
|
+
),
|
|
211
|
+
...props
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
);
|
|
215
|
+
ScrollArea.displayName = "ScrollArea";
|
|
216
|
+
var GAP = {
|
|
217
|
+
"0": "gap-0",
|
|
218
|
+
"1": "gap-1",
|
|
219
|
+
"2": "gap-2",
|
|
220
|
+
"3": "gap-3",
|
|
221
|
+
"4": "gap-4",
|
|
222
|
+
"6": "gap-6",
|
|
223
|
+
"8": "gap-8"
|
|
224
|
+
};
|
|
225
|
+
var ALIGN = {
|
|
226
|
+
start: "items-start",
|
|
227
|
+
center: "items-center",
|
|
228
|
+
end: "items-end",
|
|
229
|
+
baseline: "items-baseline"
|
|
230
|
+
};
|
|
231
|
+
var Inline = forwardRef(
|
|
232
|
+
({ gap = "2", align = "center", className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
233
|
+
"div",
|
|
234
|
+
{
|
|
235
|
+
ref,
|
|
236
|
+
className: cn("flex flex-wrap", GAP[gap], ALIGN[align], className),
|
|
237
|
+
...props
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
);
|
|
241
|
+
Inline.displayName = "Inline";
|
|
242
|
+
var GAP2 = {
|
|
243
|
+
"2": "gap-2",
|
|
244
|
+
"3": "gap-3",
|
|
245
|
+
"4": "gap-4",
|
|
246
|
+
"6": "gap-6",
|
|
247
|
+
"8": "gap-8"
|
|
248
|
+
};
|
|
249
|
+
var JUSTIFY = {
|
|
250
|
+
start: "justify-start",
|
|
251
|
+
center: "justify-center",
|
|
252
|
+
end: "justify-end"
|
|
253
|
+
};
|
|
254
|
+
var Cluster = forwardRef(
|
|
255
|
+
({ gap = "4", justify = "center", className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
256
|
+
"div",
|
|
257
|
+
{
|
|
258
|
+
ref,
|
|
259
|
+
className: cn("flex flex-wrap items-center", GAP2[gap], JUSTIFY[justify], className),
|
|
260
|
+
...props
|
|
261
|
+
}
|
|
262
|
+
)
|
|
263
|
+
);
|
|
264
|
+
Cluster.displayName = "Cluster";
|
|
265
|
+
var PADDING = {
|
|
266
|
+
"0": "",
|
|
267
|
+
"2": "p-2",
|
|
268
|
+
"3": "p-3",
|
|
269
|
+
"4": "p-4",
|
|
270
|
+
"6": "p-6",
|
|
271
|
+
"8": "p-8"
|
|
272
|
+
};
|
|
273
|
+
var RADIUS = {
|
|
274
|
+
none: "",
|
|
275
|
+
sm: "rounded-sm",
|
|
276
|
+
md: "rounded-md",
|
|
277
|
+
lg: "rounded-lg"
|
|
278
|
+
};
|
|
279
|
+
var SURFACE = {
|
|
280
|
+
card: "bg-card text-card-foreground",
|
|
281
|
+
muted: "bg-muted text-foreground",
|
|
282
|
+
transparent: ""
|
|
283
|
+
};
|
|
284
|
+
var Frame = forwardRef(
|
|
285
|
+
({ padding = "4", radius = "md", surface = "card", bordered = true, className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
286
|
+
"div",
|
|
287
|
+
{
|
|
288
|
+
ref,
|
|
289
|
+
className: cn(
|
|
290
|
+
SURFACE[surface],
|
|
291
|
+
PADDING[padding],
|
|
292
|
+
RADIUS[radius],
|
|
293
|
+
bordered && "border border-border",
|
|
294
|
+
className
|
|
295
|
+
),
|
|
296
|
+
...props
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
);
|
|
300
|
+
Frame.displayName = "Frame";
|
|
301
|
+
var GAP3 = {
|
|
302
|
+
"0": "gap-0",
|
|
303
|
+
"4": "gap-4",
|
|
304
|
+
"6": "gap-6",
|
|
305
|
+
"8": "gap-8",
|
|
306
|
+
"10": "gap-10"
|
|
307
|
+
};
|
|
308
|
+
var TwoColumn = forwardRef(
|
|
309
|
+
({ aside, children, asideWidth = "w-64", asideSide = "left", gap = "6", className, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
310
|
+
"div",
|
|
311
|
+
{
|
|
312
|
+
ref,
|
|
313
|
+
className: cn(
|
|
314
|
+
"flex w-full",
|
|
315
|
+
asideSide === "right" && "flex-row-reverse",
|
|
316
|
+
GAP3[gap],
|
|
317
|
+
className
|
|
318
|
+
),
|
|
319
|
+
...props,
|
|
320
|
+
children: [
|
|
321
|
+
/* @__PURE__ */ jsx("aside", { className: cn("shrink-0", asideWidth), children: aside }),
|
|
322
|
+
/* @__PURE__ */ jsx("main", { className: "min-w-0 flex-1", children })
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
);
|
|
327
|
+
TwoColumn.displayName = "TwoColumn";
|
|
328
|
+
var ResizableContext = createContext(null);
|
|
329
|
+
function useResizableContext() {
|
|
330
|
+
const ctx = useContext(ResizableContext);
|
|
331
|
+
if (!ctx) throw new Error("ResizablePanels.* must be used inside <ResizablePanels>");
|
|
332
|
+
return ctx;
|
|
333
|
+
}
|
|
334
|
+
function countPanels(children) {
|
|
335
|
+
let n = 0;
|
|
336
|
+
Children.forEach(children, (child) => {
|
|
337
|
+
if (isValidElement(child) && child.type.displayName === "ResizablePanel") {
|
|
338
|
+
n += 1;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
return n;
|
|
342
|
+
}
|
|
343
|
+
var ResizablePanels = forwardRef(
|
|
344
|
+
function ResizablePanels2({ orientation = "horizontal", defaultSizes, sizes: sizesProp, onSizesChange, className, children, ...rest }, forwardedRef) {
|
|
345
|
+
const panels = useRef([]);
|
|
346
|
+
const containerRef = useRef(null);
|
|
347
|
+
const panelCount = countPanels(children);
|
|
348
|
+
const initialSizes = defaultSizes && defaultSizes.length === panelCount ? defaultSizes : Array(panelCount).fill(100 / Math.max(panelCount, 1));
|
|
349
|
+
const [sizes, setSizes] = useControlled({
|
|
350
|
+
controlled: sizesProp,
|
|
351
|
+
default: initialSizes,
|
|
352
|
+
onChange: onSizesChange
|
|
353
|
+
});
|
|
354
|
+
useEffect(() => {
|
|
355
|
+
if (sizes.length === panelCount) return;
|
|
356
|
+
setSizes(Array(panelCount).fill(100 / Math.max(panelCount, 1)));
|
|
357
|
+
}, [panelCount]);
|
|
358
|
+
const applyDelta = useCallback(
|
|
359
|
+
(separatorIndex, deltaPct) => {
|
|
360
|
+
const a = separatorIndex;
|
|
361
|
+
const b = separatorIndex + 1;
|
|
362
|
+
const aInfo = panels.current[a];
|
|
363
|
+
const bInfo = panels.current[b];
|
|
364
|
+
if (!aInfo || !bInfo) return;
|
|
365
|
+
const next = sizes.slice();
|
|
366
|
+
let nextA = next[a] + deltaPct;
|
|
367
|
+
let nextB = next[b] - deltaPct;
|
|
368
|
+
if (nextA < aInfo.minSize) {
|
|
369
|
+
const adj = aInfo.minSize - nextA;
|
|
370
|
+
nextA += adj;
|
|
371
|
+
nextB -= adj;
|
|
372
|
+
}
|
|
373
|
+
if (nextB < bInfo.minSize) {
|
|
374
|
+
const adj = bInfo.minSize - nextB;
|
|
375
|
+
nextB += adj;
|
|
376
|
+
nextA -= adj;
|
|
377
|
+
}
|
|
378
|
+
if (nextA > aInfo.maxSize) {
|
|
379
|
+
const adj = nextA - aInfo.maxSize;
|
|
380
|
+
nextA -= adj;
|
|
381
|
+
nextB += adj;
|
|
382
|
+
}
|
|
383
|
+
if (nextB > bInfo.maxSize) {
|
|
384
|
+
const adj = nextB - bInfo.maxSize;
|
|
385
|
+
nextB -= adj;
|
|
386
|
+
nextA += adj;
|
|
387
|
+
}
|
|
388
|
+
next[a] = nextA;
|
|
389
|
+
next[b] = nextB;
|
|
390
|
+
setSizes(next);
|
|
391
|
+
},
|
|
392
|
+
[sizes, setSizes]
|
|
393
|
+
);
|
|
394
|
+
const beginDrag = useCallback(
|
|
395
|
+
(separatorIndex, event) => {
|
|
396
|
+
const container = containerRef.current;
|
|
397
|
+
if (!container) return;
|
|
398
|
+
const startX = event.clientX;
|
|
399
|
+
const startY = event.clientY;
|
|
400
|
+
const rect = container.getBoundingClientRect();
|
|
401
|
+
const total = orientation === "horizontal" ? rect.width : rect.height;
|
|
402
|
+
if (total === 0) return;
|
|
403
|
+
const startSizes = sizes.slice();
|
|
404
|
+
const onMove = (e) => {
|
|
405
|
+
const deltaPx = orientation === "horizontal" ? e.clientX - startX : e.clientY - startY;
|
|
406
|
+
const deltaPct = deltaPx / total * 100;
|
|
407
|
+
const a = separatorIndex;
|
|
408
|
+
const b = separatorIndex + 1;
|
|
409
|
+
const aInfo = panels.current[a];
|
|
410
|
+
const bInfo = panels.current[b];
|
|
411
|
+
if (!aInfo || !bInfo) return;
|
|
412
|
+
let nextA = startSizes[a] + deltaPct;
|
|
413
|
+
let nextB = startSizes[b] - deltaPct;
|
|
414
|
+
nextA = Math.max(aInfo.minSize, Math.min(aInfo.maxSize, nextA));
|
|
415
|
+
nextB = Math.max(bInfo.minSize, Math.min(bInfo.maxSize, nextB));
|
|
416
|
+
const sum = nextA + nextB;
|
|
417
|
+
const startSum = startSizes[a] + startSizes[b];
|
|
418
|
+
if (sum !== startSum) {
|
|
419
|
+
const diff = startSum - sum;
|
|
420
|
+
if (nextA + diff <= aInfo.maxSize && nextA + diff >= aInfo.minSize) {
|
|
421
|
+
nextA = nextA + diff;
|
|
422
|
+
} else {
|
|
423
|
+
nextB = nextB + diff;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
const next = startSizes.slice();
|
|
427
|
+
next[a] = nextA;
|
|
428
|
+
next[b] = nextB;
|
|
429
|
+
setSizes(next);
|
|
430
|
+
};
|
|
431
|
+
const onUp = () => {
|
|
432
|
+
window.removeEventListener("mousemove", onMove);
|
|
433
|
+
window.removeEventListener("mouseup", onUp);
|
|
434
|
+
document.body.style.cursor = "";
|
|
435
|
+
document.body.style.userSelect = "";
|
|
436
|
+
};
|
|
437
|
+
document.body.style.cursor = orientation === "horizontal" ? "col-resize" : "row-resize";
|
|
438
|
+
document.body.style.userSelect = "none";
|
|
439
|
+
window.addEventListener("mousemove", onMove);
|
|
440
|
+
window.addEventListener("mouseup", onUp);
|
|
441
|
+
},
|
|
442
|
+
[orientation, sizes, setSizes]
|
|
443
|
+
);
|
|
444
|
+
const resetPair = useCallback(
|
|
445
|
+
(separatorIndex) => {
|
|
446
|
+
const a = separatorIndex;
|
|
447
|
+
const b = separatorIndex + 1;
|
|
448
|
+
const aInfo = panels.current[a];
|
|
449
|
+
const bInfo = panels.current[b];
|
|
450
|
+
if (!aInfo || !bInfo) return;
|
|
451
|
+
const next = sizes.slice();
|
|
452
|
+
const total = next[a] + next[b];
|
|
453
|
+
next[a] = total * aInfo.defaultSize / (aInfo.defaultSize + bInfo.defaultSize);
|
|
454
|
+
next[b] = total - next[a];
|
|
455
|
+
setSizes(next);
|
|
456
|
+
},
|
|
457
|
+
[sizes, setSizes]
|
|
458
|
+
);
|
|
459
|
+
const ctx = useMemo(
|
|
460
|
+
() => ({
|
|
461
|
+
orientation,
|
|
462
|
+
sizes,
|
|
463
|
+
panels,
|
|
464
|
+
containerRef,
|
|
465
|
+
beginDrag,
|
|
466
|
+
nudge: applyDelta,
|
|
467
|
+
resetPair
|
|
468
|
+
}),
|
|
469
|
+
[orientation, sizes, beginDrag, applyDelta, resetPair]
|
|
470
|
+
);
|
|
471
|
+
let panelIdx = 0;
|
|
472
|
+
let sepIdx = 0;
|
|
473
|
+
const elements = Children.map(children, (child) => {
|
|
474
|
+
if (!isValidElement(child)) return child;
|
|
475
|
+
const displayName = child.type.displayName;
|
|
476
|
+
if (displayName === "ResizablePanel") {
|
|
477
|
+
const node = /* @__PURE__ */ jsx(
|
|
478
|
+
ResizablePanelInner,
|
|
479
|
+
{
|
|
480
|
+
index: panelIdx,
|
|
481
|
+
...child.props
|
|
482
|
+
},
|
|
483
|
+
`p-${panelIdx}`
|
|
484
|
+
);
|
|
485
|
+
panelIdx += 1;
|
|
486
|
+
return node;
|
|
487
|
+
}
|
|
488
|
+
if (displayName === "ResizableSeparator") {
|
|
489
|
+
const node = /* @__PURE__ */ jsx(
|
|
490
|
+
ResizableSeparatorInner,
|
|
491
|
+
{
|
|
492
|
+
index: sepIdx,
|
|
493
|
+
...child.props
|
|
494
|
+
},
|
|
495
|
+
`s-${sepIdx}`
|
|
496
|
+
);
|
|
497
|
+
sepIdx += 1;
|
|
498
|
+
return node;
|
|
499
|
+
}
|
|
500
|
+
return child;
|
|
501
|
+
});
|
|
502
|
+
return /* @__PURE__ */ jsx(ResizableContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
503
|
+
"div",
|
|
504
|
+
{
|
|
505
|
+
ref: (el) => {
|
|
506
|
+
containerRef.current = el;
|
|
507
|
+
if (typeof forwardedRef === "function") forwardedRef(el);
|
|
508
|
+
else if (forwardedRef) forwardedRef.current = el;
|
|
509
|
+
},
|
|
510
|
+
"data-orientation": orientation,
|
|
511
|
+
className: cn(
|
|
512
|
+
"flex h-full w-full",
|
|
513
|
+
orientation === "horizontal" ? "flex-row" : "flex-col",
|
|
514
|
+
className
|
|
515
|
+
),
|
|
516
|
+
...rest,
|
|
517
|
+
children: elements
|
|
518
|
+
}
|
|
519
|
+
) });
|
|
520
|
+
}
|
|
521
|
+
);
|
|
522
|
+
function ResizablePanelInner({
|
|
523
|
+
index,
|
|
524
|
+
defaultSize = 100,
|
|
525
|
+
minSize = 0,
|
|
526
|
+
maxSize = 100,
|
|
527
|
+
className,
|
|
528
|
+
children,
|
|
529
|
+
...rest
|
|
530
|
+
}) {
|
|
531
|
+
const ctx = useResizableContext();
|
|
532
|
+
if (!ctx.panels.current[index]) {
|
|
533
|
+
ctx.panels.current[index] = { index, defaultSize, minSize, maxSize };
|
|
534
|
+
} else {
|
|
535
|
+
ctx.panels.current[index] = { index, defaultSize, minSize, maxSize };
|
|
536
|
+
}
|
|
537
|
+
const size = ctx.sizes[index] ?? defaultSize;
|
|
538
|
+
return /* @__PURE__ */ jsx(
|
|
539
|
+
"div",
|
|
540
|
+
{
|
|
541
|
+
"data-panel-index": index,
|
|
542
|
+
className: cn("overflow-auto", className),
|
|
543
|
+
style: ctx.orientation === "horizontal" ? { width: `${size}%`, height: "100%" } : { height: `${size}%`, width: "100%" },
|
|
544
|
+
...rest,
|
|
545
|
+
children
|
|
546
|
+
}
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
var ResizablePanel = forwardRef(
|
|
550
|
+
function ResizablePanel2() {
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
);
|
|
554
|
+
ResizablePanel.displayName = "ResizablePanel";
|
|
555
|
+
function ResizableSeparatorInner({
|
|
556
|
+
index,
|
|
557
|
+
disabled,
|
|
558
|
+
className,
|
|
559
|
+
onKeyDown,
|
|
560
|
+
onDoubleClick,
|
|
561
|
+
...rest
|
|
562
|
+
}) {
|
|
563
|
+
const ctx = useResizableContext();
|
|
564
|
+
const [dragging, setDragging] = useState(false);
|
|
565
|
+
const handleMouseDown = (e) => {
|
|
566
|
+
if (disabled) return;
|
|
567
|
+
if (e.button !== 0) return;
|
|
568
|
+
e.preventDefault();
|
|
569
|
+
setDragging(true);
|
|
570
|
+
ctx.beginDrag(index, e);
|
|
571
|
+
const onUp = () => {
|
|
572
|
+
setDragging(false);
|
|
573
|
+
window.removeEventListener("mouseup", onUp);
|
|
574
|
+
};
|
|
575
|
+
window.addEventListener("mouseup", onUp);
|
|
576
|
+
};
|
|
577
|
+
const handleKeyDown = (e) => {
|
|
578
|
+
onKeyDown?.(e);
|
|
579
|
+
if (e.defaultPrevented || disabled) return;
|
|
580
|
+
const step = e.shiftKey ? 10 : 1;
|
|
581
|
+
if (ctx.orientation === "horizontal") {
|
|
582
|
+
if (e.key === "ArrowLeft") {
|
|
583
|
+
e.preventDefault();
|
|
584
|
+
ctx.nudge(index, -step);
|
|
585
|
+
} else if (e.key === "ArrowRight") {
|
|
586
|
+
e.preventDefault();
|
|
587
|
+
ctx.nudge(index, step);
|
|
588
|
+
}
|
|
589
|
+
} else {
|
|
590
|
+
if (e.key === "ArrowUp") {
|
|
591
|
+
e.preventDefault();
|
|
592
|
+
ctx.nudge(index, -step);
|
|
593
|
+
} else if (e.key === "ArrowDown") {
|
|
594
|
+
e.preventDefault();
|
|
595
|
+
ctx.nudge(index, step);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
const ariaValueNow = ctx.sizes[index + 1] ?? 50;
|
|
600
|
+
const nextPanel = ctx.panels.current[index + 1];
|
|
601
|
+
return /* @__PURE__ */ jsx(
|
|
602
|
+
"div",
|
|
603
|
+
{
|
|
604
|
+
role: "separator",
|
|
605
|
+
"aria-orientation": ctx.orientation === "horizontal" ? "vertical" : "horizontal",
|
|
606
|
+
"aria-valuenow": Math.round(ariaValueNow),
|
|
607
|
+
"aria-valuemin": nextPanel?.minSize ?? 0,
|
|
608
|
+
"aria-valuemax": nextPanel?.maxSize ?? 100,
|
|
609
|
+
"aria-disabled": disabled || void 0,
|
|
610
|
+
tabIndex: disabled ? -1 : 0,
|
|
611
|
+
"data-dragging": dragging || void 0,
|
|
612
|
+
onMouseDown: handleMouseDown,
|
|
613
|
+
onKeyDown: handleKeyDown,
|
|
614
|
+
onDoubleClick: (e) => {
|
|
615
|
+
onDoubleClick?.(e);
|
|
616
|
+
if (e.defaultPrevented || disabled) return;
|
|
617
|
+
ctx.resetPair(index);
|
|
618
|
+
},
|
|
619
|
+
className: cn(
|
|
620
|
+
"flex shrink-0 items-center justify-center bg-border transition-colors",
|
|
621
|
+
ctx.orientation === "horizontal" ? "w-1 cursor-col-resize hover:bg-border-strong data-[dragging]:bg-primary" : "h-1 cursor-row-resize hover:bg-border-strong data-[dragging]:bg-primary",
|
|
622
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
623
|
+
disabled && "cursor-default opacity-50 hover:bg-border",
|
|
624
|
+
className
|
|
625
|
+
),
|
|
626
|
+
...rest
|
|
627
|
+
}
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
var ResizableSeparator = forwardRef(
|
|
631
|
+
function ResizableSeparator2() {
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
);
|
|
635
|
+
ResizableSeparator.displayName = "ResizableSeparator";
|
|
636
|
+
ResizablePanels.Panel = ResizablePanel;
|
|
637
|
+
ResizablePanels.Separator = ResizableSeparator;
|
|
638
|
+
|
|
639
|
+
export { AspectRatio, Box, Center, Cluster, Container, Flex, Frame, Grid, HStack, Inline, ResizablePanel, ResizablePanels, ResizableSeparator, ScrollArea, Spacer, Stack, TwoColumn, VStack, containerVariants, gridVariants, stackVariants };
|
|
640
|
+
//# sourceMappingURL=chunk-SM2TOB4U.js.map
|
|
641
|
+
//# sourceMappingURL=chunk-SM2TOB4U.js.map
|