@classic-homes/theme-react 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +0 -7
- package/dist/index.d.mts +39 -12
- package/dist/index.d.ts +39 -12
- package/dist/index.js +401 -309
- package/dist/index.mjs +435 -344
- package/package.json +9 -5
package/dist/index.mjs
CHANGED
|
@@ -98,9 +98,25 @@ var CardFooter = React2.forwardRef(
|
|
|
98
98
|
CardFooter.displayName = "CardFooter";
|
|
99
99
|
|
|
100
100
|
// src/components/Input.tsx
|
|
101
|
+
import * as React4 from "react";
|
|
102
|
+
|
|
103
|
+
// src/lib/useDevWarning.ts
|
|
101
104
|
import * as React3 from "react";
|
|
105
|
+
var warnedOnce = /* @__PURE__ */ new Set();
|
|
106
|
+
function useDevWarning(condition, message, once = false) {
|
|
107
|
+
React3.useEffect(() => {
|
|
108
|
+
if (process.env.NODE_ENV === "production" || !condition) return;
|
|
109
|
+
if (once) {
|
|
110
|
+
if (warnedOnce.has(message)) return;
|
|
111
|
+
warnedOnce.add(message);
|
|
112
|
+
}
|
|
113
|
+
console.warn(message);
|
|
114
|
+
}, [condition, message, once]);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/components/Input.tsx
|
|
102
118
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
103
|
-
var Input =
|
|
119
|
+
var Input = React4.forwardRef(
|
|
104
120
|
({
|
|
105
121
|
className,
|
|
106
122
|
type,
|
|
@@ -109,13 +125,10 @@ var Input = React3.forwardRef(
|
|
|
109
125
|
"aria-describedby": ariaDescribedBy,
|
|
110
126
|
...props
|
|
111
127
|
}, ref) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
128
|
+
useDevWarning(
|
|
129
|
+
!props["aria-label"] && !props["aria-labelledby"] && !props.id,
|
|
130
|
+
"Input: Missing accessible label. Provide aria-label, aria-labelledby, or associate with a Label using id/htmlFor for WCAG compliance."
|
|
131
|
+
);
|
|
119
132
|
return /* @__PURE__ */ jsx3(
|
|
120
133
|
"input",
|
|
121
134
|
{
|
|
@@ -138,24 +151,24 @@ var Input = React3.forwardRef(
|
|
|
138
151
|
Input.displayName = "Input";
|
|
139
152
|
|
|
140
153
|
// src/components/PasswordInput.tsx
|
|
141
|
-
import * as
|
|
154
|
+
import * as React6 from "react";
|
|
142
155
|
|
|
143
156
|
// src/hooks/useAnnounce.ts
|
|
144
|
-
import * as
|
|
157
|
+
import * as React5 from "react";
|
|
145
158
|
function useAnnounce(defaultOptions) {
|
|
146
|
-
const [message, setMessage] =
|
|
147
|
-
const [politeness, setPoliteness] =
|
|
159
|
+
const [message, setMessage] = React5.useState("");
|
|
160
|
+
const [politeness, setPoliteness] = React5.useState(
|
|
148
161
|
defaultOptions?.politeness ?? "polite"
|
|
149
162
|
);
|
|
150
|
-
const clearTimeoutRef =
|
|
151
|
-
const clear =
|
|
163
|
+
const clearTimeoutRef = React5.useRef(null);
|
|
164
|
+
const clear = React5.useCallback(() => {
|
|
152
165
|
setMessage("");
|
|
153
166
|
if (clearTimeoutRef.current) {
|
|
154
167
|
clearTimeout(clearTimeoutRef.current);
|
|
155
168
|
clearTimeoutRef.current = null;
|
|
156
169
|
}
|
|
157
170
|
}, []);
|
|
158
|
-
const announce =
|
|
171
|
+
const announce = React5.useCallback(
|
|
159
172
|
(newMessage, options) => {
|
|
160
173
|
if (clearTimeoutRef.current) {
|
|
161
174
|
clearTimeout(clearTimeoutRef.current);
|
|
@@ -173,7 +186,7 @@ function useAnnounce(defaultOptions) {
|
|
|
173
186
|
},
|
|
174
187
|
[defaultOptions?.clearDelay, defaultOptions?.politeness]
|
|
175
188
|
);
|
|
176
|
-
|
|
189
|
+
React5.useEffect(() => {
|
|
177
190
|
return () => {
|
|
178
191
|
if (clearTimeoutRef.current) {
|
|
179
192
|
clearTimeout(clearTimeoutRef.current);
|
|
@@ -225,7 +238,7 @@ var EyeOffIcon = () => /* @__PURE__ */ jsx4(
|
|
|
225
238
|
children: /* @__PURE__ */ jsx4("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24M1 1l22 22" })
|
|
226
239
|
}
|
|
227
240
|
);
|
|
228
|
-
var PasswordInput =
|
|
241
|
+
var PasswordInput = React6.forwardRef(
|
|
229
242
|
({
|
|
230
243
|
className,
|
|
231
244
|
disabled,
|
|
@@ -238,15 +251,12 @@ var PasswordInput = React5.forwardRef(
|
|
|
238
251
|
"aria-labelledby": ariaLabelledBy,
|
|
239
252
|
...props
|
|
240
253
|
}, ref) => {
|
|
241
|
-
const [showPassword, setShowPassword] =
|
|
254
|
+
const [showPassword, setShowPassword] = React6.useState(false);
|
|
242
255
|
const { announce, message, politeness } = useAnnounce();
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
256
|
+
useDevWarning(
|
|
257
|
+
!ariaLabel && !ariaLabelledBy && !id,
|
|
258
|
+
"PasswordInput: Missing accessible label. Provide aria-label, aria-labelledby, or an id to associate with a Label element for WCAG compliance."
|
|
259
|
+
);
|
|
250
260
|
const toggleVisibility = () => {
|
|
251
261
|
setShowPassword((prev) => {
|
|
252
262
|
const newState = !prev;
|
|
@@ -290,20 +300,20 @@ var PasswordInput = React5.forwardRef(
|
|
|
290
300
|
PasswordInput.displayName = "PasswordInput";
|
|
291
301
|
|
|
292
302
|
// src/components/Label.tsx
|
|
293
|
-
import * as
|
|
303
|
+
import * as React7 from "react";
|
|
294
304
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
295
305
|
import { cva as cva2 } from "class-variance-authority";
|
|
296
306
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
297
307
|
var labelVariants = cva2(
|
|
298
308
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
299
309
|
);
|
|
300
|
-
var Label =
|
|
310
|
+
var Label = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
301
311
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
302
312
|
|
|
303
313
|
// src/components/Badge.tsx
|
|
304
|
-
import * as
|
|
314
|
+
import * as React8 from "react";
|
|
305
315
|
import { cva as cva3 } from "class-variance-authority";
|
|
306
|
-
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
316
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
307
317
|
var badgeVariants = cva3(
|
|
308
318
|
"inline-flex items-center justify-center rounded-md border font-medium w-fit whitespace-nowrap shrink-0 gap-1",
|
|
309
319
|
{
|
|
@@ -349,7 +359,7 @@ var badgeVariants = cva3(
|
|
|
349
359
|
}
|
|
350
360
|
}
|
|
351
361
|
);
|
|
352
|
-
var Badge =
|
|
362
|
+
var Badge = React8.forwardRef(
|
|
353
363
|
({ className, variant, size, live, clickable, label, children, onClick, ...props }, ref) => {
|
|
354
364
|
if (process.env.NODE_ENV !== "production") {
|
|
355
365
|
if (live && !label) {
|
|
@@ -360,41 +370,34 @@ var Badge = React7.forwardRef(
|
|
|
360
370
|
}
|
|
361
371
|
const isInteractive = clickable || !!onClick;
|
|
362
372
|
const classes = cn(badgeVariants({ variant, size, clickable: isInteractive }), className);
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
"
|
|
367
|
-
|
|
368
|
-
...props
|
|
369
|
-
};
|
|
373
|
+
const liveProps = live ? { role: "status", "aria-live": "polite", "aria-atomic": "true" } : {};
|
|
374
|
+
const content = /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
375
|
+
children,
|
|
376
|
+
label && /* @__PURE__ */ jsx6("span", { className: "sr-only", children: label })
|
|
377
|
+
] });
|
|
370
378
|
if (isInteractive) {
|
|
371
|
-
return /* @__PURE__ */
|
|
379
|
+
return /* @__PURE__ */ jsx6(
|
|
372
380
|
"button",
|
|
373
381
|
{
|
|
374
382
|
ref,
|
|
375
383
|
type: "button",
|
|
376
384
|
onClick,
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
label && /* @__PURE__ */ jsx6("span", { className: "sr-only", children: label })
|
|
381
|
-
]
|
|
385
|
+
className: classes,
|
|
386
|
+
...props,
|
|
387
|
+
children: live ? /* @__PURE__ */ jsx6("span", { ...liveProps, children: content }) : content
|
|
382
388
|
}
|
|
383
389
|
);
|
|
384
390
|
}
|
|
385
|
-
return /* @__PURE__ */
|
|
386
|
-
children,
|
|
387
|
-
label && /* @__PURE__ */ jsx6("span", { className: "sr-only", children: label })
|
|
388
|
-
] });
|
|
391
|
+
return /* @__PURE__ */ jsx6("span", { ref, ...liveProps, className: classes, ...props, children: content });
|
|
389
392
|
}
|
|
390
393
|
);
|
|
391
394
|
Badge.displayName = "Badge";
|
|
392
395
|
|
|
393
396
|
// src/components/Separator.tsx
|
|
394
|
-
import * as
|
|
397
|
+
import * as React9 from "react";
|
|
395
398
|
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
396
399
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
397
|
-
var Separator =
|
|
400
|
+
var Separator = React9.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => {
|
|
398
401
|
if (process.env.NODE_ENV !== "production") {
|
|
399
402
|
if (!decorative && !props["aria-label"]) {
|
|
400
403
|
console.warn(
|
|
@@ -420,12 +423,12 @@ var Separator = React8.forwardRef(({ className, orientation = "horizontal", deco
|
|
|
420
423
|
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
421
424
|
|
|
422
425
|
// src/components/Switch.tsx
|
|
423
|
-
import * as
|
|
426
|
+
import * as React10 from "react";
|
|
424
427
|
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
425
428
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
426
429
|
var SwitchRoot = SwitchPrimitives.Root;
|
|
427
430
|
var SwitchThumb = SwitchPrimitives.Thumb;
|
|
428
|
-
var Switch =
|
|
431
|
+
var Switch = React10.forwardRef(
|
|
429
432
|
({
|
|
430
433
|
className,
|
|
431
434
|
size = "default",
|
|
@@ -434,13 +437,10 @@ var Switch = React9.forwardRef(
|
|
|
434
437
|
"aria-describedby": ariaDescribedBy,
|
|
435
438
|
...props
|
|
436
439
|
}, ref) => {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
440
|
+
useDevWarning(
|
|
441
|
+
!ariaLabel && !ariaLabelledBy && !props.id,
|
|
442
|
+
"Switch: Missing accessible label. Provide aria-label, aria-labelledby, or associate with a Label using id/htmlFor for WCAG compliance."
|
|
443
|
+
);
|
|
444
444
|
return /* @__PURE__ */ jsx8(
|
|
445
445
|
SwitchRoot,
|
|
446
446
|
{
|
|
@@ -472,10 +472,10 @@ var Switch = React9.forwardRef(
|
|
|
472
472
|
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
473
473
|
|
|
474
474
|
// src/components/Avatar.tsx
|
|
475
|
-
import * as
|
|
475
|
+
import * as React11 from "react";
|
|
476
476
|
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
477
477
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
478
|
-
var Avatar =
|
|
478
|
+
var Avatar = React11.forwardRef(
|
|
479
479
|
({ className, name, "aria-label": ariaLabel, ...props }, ref) => {
|
|
480
480
|
if (process.env.NODE_ENV !== "production") {
|
|
481
481
|
if (!ariaLabel && !name) {
|
|
@@ -489,6 +489,7 @@ var Avatar = React10.forwardRef(
|
|
|
489
489
|
AvatarPrimitive.Root,
|
|
490
490
|
{
|
|
491
491
|
ref,
|
|
492
|
+
role: computedAriaLabel ? "img" : void 0,
|
|
492
493
|
"aria-label": computedAriaLabel,
|
|
493
494
|
className: cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className),
|
|
494
495
|
...props
|
|
@@ -497,7 +498,7 @@ var Avatar = React10.forwardRef(
|
|
|
497
498
|
}
|
|
498
499
|
);
|
|
499
500
|
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
500
|
-
var AvatarImage =
|
|
501
|
+
var AvatarImage = React11.forwardRef(({ className, alt, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
501
502
|
AvatarPrimitive.Image,
|
|
502
503
|
{
|
|
503
504
|
ref,
|
|
@@ -507,7 +508,7 @@ var AvatarImage = React10.forwardRef(({ className, alt, ...props }, ref) => /* @
|
|
|
507
508
|
}
|
|
508
509
|
));
|
|
509
510
|
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
510
|
-
var AvatarFallback =
|
|
511
|
+
var AvatarFallback = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
511
512
|
AvatarPrimitive.Fallback,
|
|
512
513
|
{
|
|
513
514
|
ref,
|
|
@@ -521,7 +522,7 @@ var AvatarFallback = React10.forwardRef(({ className, ...props }, ref) => /* @__
|
|
|
521
522
|
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
522
523
|
|
|
523
524
|
// src/components/Dialog.tsx
|
|
524
|
-
import * as
|
|
525
|
+
import * as React12 from "react";
|
|
525
526
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
526
527
|
import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
527
528
|
var PrimitiveOverlay = DialogPrimitive.Overlay;
|
|
@@ -540,7 +541,7 @@ var dialogSizeClasses = {
|
|
|
540
541
|
"2xl": "max-w-[min(theme(maxWidth.3xl),calc(100vw-2rem))]",
|
|
541
542
|
full: "max-w-[calc(100vw-2rem)]"
|
|
542
543
|
};
|
|
543
|
-
var DialogOverlay =
|
|
544
|
+
var DialogOverlay = React12.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx10(
|
|
544
545
|
PrimitiveOverlay,
|
|
545
546
|
{
|
|
546
547
|
ref,
|
|
@@ -552,19 +553,50 @@ var DialogOverlay = React11.forwardRef(({ className, ...props }, ref) => /* @__P
|
|
|
552
553
|
}
|
|
553
554
|
));
|
|
554
555
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
555
|
-
var DialogContent =
|
|
556
|
+
var DialogContent = React12.forwardRef(({ className, children, size = "md", showClose = false, ...props }, ref) => /* @__PURE__ */ jsxs3(DialogPortal, { children: [
|
|
556
557
|
/* @__PURE__ */ jsx10(DialogOverlay, {}),
|
|
557
|
-
/* @__PURE__ */
|
|
558
|
+
/* @__PURE__ */ jsxs3(
|
|
558
559
|
PrimitiveContent,
|
|
559
560
|
{
|
|
560
561
|
ref,
|
|
561
562
|
className: cn(
|
|
562
|
-
|
|
563
|
+
// max-h + overflow: a dialog taller than the viewport scrolls inside
|
|
564
|
+
// itself instead of running off-screen.
|
|
565
|
+
"fixed left-[50%] top-[50%] z-50 grid max-h-[calc(100dvh-2rem)] w-full translate-x-[-50%] translate-y-[-50%] gap-4 overflow-y-auto overscroll-contain border border-border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
563
566
|
dialogSizeClasses[size],
|
|
564
567
|
className
|
|
565
568
|
),
|
|
566
569
|
...props,
|
|
567
|
-
children
|
|
570
|
+
children: [
|
|
571
|
+
children,
|
|
572
|
+
showClose && /* @__PURE__ */ jsx10(
|
|
573
|
+
DialogPrimitive.Close,
|
|
574
|
+
{
|
|
575
|
+
className: "absolute right-3 top-3 flex h-9 w-9 items-center justify-center rounded-md bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none",
|
|
576
|
+
"aria-label": "Close dialog",
|
|
577
|
+
children: /* @__PURE__ */ jsxs3(
|
|
578
|
+
"svg",
|
|
579
|
+
{
|
|
580
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
581
|
+
width: "20",
|
|
582
|
+
height: "20",
|
|
583
|
+
viewBox: "0 0 24 24",
|
|
584
|
+
fill: "none",
|
|
585
|
+
stroke: "currentColor",
|
|
586
|
+
strokeWidth: "2",
|
|
587
|
+
strokeLinecap: "round",
|
|
588
|
+
strokeLinejoin: "round",
|
|
589
|
+
className: "h-5 w-5",
|
|
590
|
+
"aria-hidden": "true",
|
|
591
|
+
children: [
|
|
592
|
+
/* @__PURE__ */ jsx10("path", { d: "M18 6 6 18" }),
|
|
593
|
+
/* @__PURE__ */ jsx10("path", { d: "m6 6 12 12" })
|
|
594
|
+
]
|
|
595
|
+
}
|
|
596
|
+
)
|
|
597
|
+
}
|
|
598
|
+
)
|
|
599
|
+
]
|
|
568
600
|
}
|
|
569
601
|
)
|
|
570
602
|
] }));
|
|
@@ -579,7 +611,7 @@ var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsx10(
|
|
|
579
611
|
}
|
|
580
612
|
);
|
|
581
613
|
DialogFooter.displayName = "DialogFooter";
|
|
582
|
-
var DialogTitle =
|
|
614
|
+
var DialogTitle = React12.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx10(
|
|
583
615
|
PrimitiveTitle,
|
|
584
616
|
{
|
|
585
617
|
ref,
|
|
@@ -588,7 +620,7 @@ var DialogTitle = React11.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
588
620
|
}
|
|
589
621
|
));
|
|
590
622
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
591
|
-
var DialogDescription =
|
|
623
|
+
var DialogDescription = React12.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx10(
|
|
592
624
|
PrimitiveDescription,
|
|
593
625
|
{
|
|
594
626
|
ref,
|
|
@@ -599,7 +631,7 @@ var DialogDescription = React11.forwardRef(({ className, ...props }, ref) => /*
|
|
|
599
631
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
600
632
|
|
|
601
633
|
// src/components/PageHeader.tsx
|
|
602
|
-
import * as
|
|
634
|
+
import * as React13 from "react";
|
|
603
635
|
import { cva as cva4 } from "class-variance-authority";
|
|
604
636
|
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
605
637
|
var pageHeaderContainerVariants = cva4("", {
|
|
@@ -662,15 +694,13 @@ var pageHeaderActionsVariants = cva4("flex gap-4", {
|
|
|
662
694
|
variant: "default"
|
|
663
695
|
}
|
|
664
696
|
});
|
|
665
|
-
var PageHeader =
|
|
697
|
+
var PageHeader = React13.forwardRef(
|
|
666
698
|
({ className, variant, title, subtitle, actions, as: Heading = "h1", ...props }, ref) => {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
}
|
|
699
|
+
useDevWarning(
|
|
700
|
+
Heading === "h1",
|
|
701
|
+
'PageHeader: Using as="h1" (the default). Ensure there is only one h1 per page for proper document structure. Consider as="h2" for secondary headers.',
|
|
702
|
+
true
|
|
703
|
+
);
|
|
674
704
|
return /* @__PURE__ */ jsxs4(
|
|
675
705
|
"header",
|
|
676
706
|
{
|
|
@@ -766,7 +796,7 @@ function StudioIcon({
|
|
|
766
796
|
}
|
|
767
797
|
|
|
768
798
|
// src/components/Sheet.tsx
|
|
769
|
-
import { Fragment, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
799
|
+
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
770
800
|
var sheetVariants = cva5(
|
|
771
801
|
"fixed z-50 flex flex-col border-border bg-background shadow-lg outline-none duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
772
802
|
{
|
|
@@ -813,7 +843,7 @@ function Sheet({
|
|
|
813
843
|
/* @__PURE__ */ jsx13("div", { className: "h-1.5 w-10 rounded-full bg-muted", "aria-hidden": "true" }),
|
|
814
844
|
hideTitle && /* @__PURE__ */ jsx13("div", { className: "absolute right-2 top-1", children: close })
|
|
815
845
|
] }),
|
|
816
|
-
hideTitle ? /* @__PURE__ */ jsxs5(
|
|
846
|
+
hideTitle ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
817
847
|
/* @__PURE__ */ jsx13(DialogPrimitive2.Title, { className: "sr-only", children: title }),
|
|
818
848
|
description && /* @__PURE__ */ jsx13(DialogPrimitive2.Description, { className: "sr-only", children: description }),
|
|
819
849
|
side !== "bottom" && /* @__PURE__ */ jsx13("div", { className: "absolute right-2 top-2 z-10", children: close })
|
|
@@ -836,8 +866,9 @@ function Sheet({
|
|
|
836
866
|
}
|
|
837
867
|
|
|
838
868
|
// src/components/SortableList.tsx
|
|
839
|
-
import * as
|
|
840
|
-
import { Fragment as
|
|
869
|
+
import * as React14 from "react";
|
|
870
|
+
import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
871
|
+
var HANDLE_STYLE = { touchAction: "none" };
|
|
841
872
|
function SortableList({
|
|
842
873
|
items,
|
|
843
874
|
getKey,
|
|
@@ -849,19 +880,19 @@ function SortableList({
|
|
|
849
880
|
className,
|
|
850
881
|
itemClassName
|
|
851
882
|
}) {
|
|
852
|
-
const instructionsId = `${
|
|
853
|
-
const listRef =
|
|
854
|
-
const [announcement, setAnnouncement] =
|
|
855
|
-
const [drag, setDrag] =
|
|
883
|
+
const instructionsId = `${React14.useId()}-sortable-help`;
|
|
884
|
+
const listRef = React14.useRef(null);
|
|
885
|
+
const [announcement, setAnnouncement] = React14.useState("");
|
|
886
|
+
const [drag, setDrag] = React14.useState(
|
|
856
887
|
null
|
|
857
888
|
);
|
|
858
|
-
const rects =
|
|
859
|
-
const startY =
|
|
860
|
-
const [grabbed, setGrabbed] =
|
|
861
|
-
const grabbedFrom =
|
|
862
|
-
const moving =
|
|
863
|
-
const pendingFocus =
|
|
864
|
-
|
|
889
|
+
const rects = React14.useRef([]);
|
|
890
|
+
const startY = React14.useRef(0);
|
|
891
|
+
const [grabbed, setGrabbed] = React14.useState(null);
|
|
892
|
+
const grabbedFrom = React14.useRef(0);
|
|
893
|
+
const moving = React14.useRef(false);
|
|
894
|
+
const pendingFocus = React14.useRef(null);
|
|
895
|
+
React14.useLayoutEffect(() => {
|
|
865
896
|
if (pendingFocus.current === null) return;
|
|
866
897
|
const handles = listRef.current?.querySelectorAll(
|
|
867
898
|
":scope > li [data-sortable-handle]"
|
|
@@ -908,6 +939,7 @@ function SortableList({
|
|
|
908
939
|
"aria-describedby": instructionsId,
|
|
909
940
|
"aria-pressed": grabbed === index,
|
|
910
941
|
"data-sortable-handle": String(key),
|
|
942
|
+
style: HANDLE_STYLE,
|
|
911
943
|
onPointerDown(event) {
|
|
912
944
|
if (disabled || event.button !== 0 || !listRef.current) return;
|
|
913
945
|
event.preventDefault();
|
|
@@ -967,7 +999,7 @@ function SortableList({
|
|
|
967
999
|
if (!moving.current && grabbed === index) setGrabbed(null);
|
|
968
1000
|
}
|
|
969
1001
|
});
|
|
970
|
-
return /* @__PURE__ */ jsxs6(
|
|
1002
|
+
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
971
1003
|
/* @__PURE__ */ jsx14("ul", { ref: listRef, "aria-label": label, className: cn("relative", className), children: items.map((item, index) => {
|
|
972
1004
|
const key = getKey(item, index);
|
|
973
1005
|
const dragging = drag?.from === index || grabbed === index;
|
|
@@ -999,20 +1031,20 @@ function SortableList({
|
|
|
999
1031
|
}
|
|
1000
1032
|
|
|
1001
1033
|
// src/components/studio/Studio.tsx
|
|
1002
|
-
import * as
|
|
1034
|
+
import * as React16 from "react";
|
|
1003
1035
|
|
|
1004
1036
|
// src/components/studio/context.ts
|
|
1005
|
-
import * as
|
|
1006
|
-
var StudioContext =
|
|
1037
|
+
import * as React15 from "react";
|
|
1038
|
+
var StudioContext = React15.createContext(void 0);
|
|
1007
1039
|
function useStudio() {
|
|
1008
|
-
return
|
|
1040
|
+
return React15.useContext(StudioContext);
|
|
1009
1041
|
}
|
|
1010
1042
|
|
|
1011
1043
|
// src/components/studio/Studio.tsx
|
|
1012
1044
|
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1013
1045
|
function useLayout() {
|
|
1014
|
-
const [layout, setLayout] =
|
|
1015
|
-
|
|
1046
|
+
const [layout, setLayout] = React16.useState("wide");
|
|
1047
|
+
React16.useEffect(() => {
|
|
1016
1048
|
const wide = window.matchMedia("(min-width: 1280px)");
|
|
1017
1049
|
const medium = window.matchMedia("(min-width: 768px)");
|
|
1018
1050
|
const update = () => setLayout(wide.matches ? "wide" : medium.matches ? "medium" : "compact");
|
|
@@ -1027,9 +1059,9 @@ function useLayout() {
|
|
|
1027
1059
|
return layout;
|
|
1028
1060
|
}
|
|
1029
1061
|
function useControllable(value, onChange) {
|
|
1030
|
-
const [inner, setInner] =
|
|
1062
|
+
const [inner, setInner] = React16.useState(false);
|
|
1031
1063
|
const current = value ?? inner;
|
|
1032
|
-
const set =
|
|
1064
|
+
const set = React16.useCallback(
|
|
1033
1065
|
(next) => {
|
|
1034
1066
|
if (value === void 0) setInner(next);
|
|
1035
1067
|
onChange?.(next);
|
|
@@ -1061,11 +1093,11 @@ function Studio({
|
|
|
1061
1093
|
);
|
|
1062
1094
|
const railInSheet = !!rail && layout !== "wide";
|
|
1063
1095
|
const inspectorInSheet = !!inspector && layout === "compact";
|
|
1064
|
-
|
|
1096
|
+
React16.useEffect(() => {
|
|
1065
1097
|
if (layout === "wide" && railOpen) setRailOpen(false);
|
|
1066
1098
|
if (layout !== "compact" && inspectorOpen) setInspectorOpen(false);
|
|
1067
1099
|
}, [layout, railOpen, inspectorOpen, setRailOpen, setInspectorOpen]);
|
|
1068
|
-
const context =
|
|
1100
|
+
const context = React16.useMemo(
|
|
1069
1101
|
() => ({
|
|
1070
1102
|
layout,
|
|
1071
1103
|
railInSheet,
|
|
@@ -1159,7 +1191,7 @@ function Studio({
|
|
|
1159
1191
|
}
|
|
1160
1192
|
|
|
1161
1193
|
// src/components/studio/StudioBar.tsx
|
|
1162
|
-
import * as
|
|
1194
|
+
import * as React17 from "react";
|
|
1163
1195
|
|
|
1164
1196
|
// src/components/studio/menu.tsx
|
|
1165
1197
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
@@ -1209,7 +1241,7 @@ function ModeSwitch({
|
|
|
1209
1241
|
value,
|
|
1210
1242
|
onChange
|
|
1211
1243
|
}) {
|
|
1212
|
-
const refs =
|
|
1244
|
+
const refs = React17.useRef([]);
|
|
1213
1245
|
const keyDown = (event, index) => {
|
|
1214
1246
|
const step = event.key === "ArrowRight" || event.key === "ArrowDown" ? 1 : event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0;
|
|
1215
1247
|
if (!step) return;
|
|
@@ -1272,9 +1304,9 @@ function StudioBar({
|
|
|
1272
1304
|
menuLabel = "More actions",
|
|
1273
1305
|
className
|
|
1274
1306
|
}) {
|
|
1275
|
-
const [draft, setDraft] =
|
|
1276
|
-
const atFocus =
|
|
1277
|
-
|
|
1307
|
+
const [draft, setDraft] = React17.useState(title);
|
|
1308
|
+
const atFocus = React17.useRef(title);
|
|
1309
|
+
React17.useEffect(() => setDraft(title), [title]);
|
|
1278
1310
|
const commit = () => {
|
|
1279
1311
|
const next = draft.trim();
|
|
1280
1312
|
if (!next) {
|
|
@@ -1364,7 +1396,7 @@ function StudioBar({
|
|
|
1364
1396
|
}
|
|
1365
1397
|
|
|
1366
1398
|
// src/components/studio/StudioOutline.tsx
|
|
1367
|
-
import * as
|
|
1399
|
+
import * as React18 from "react";
|
|
1368
1400
|
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1369
1401
|
function StudioOutline({
|
|
1370
1402
|
items,
|
|
@@ -1382,12 +1414,12 @@ function StudioOutline({
|
|
|
1382
1414
|
className
|
|
1383
1415
|
}) {
|
|
1384
1416
|
const studio = useStudio();
|
|
1385
|
-
const listHost =
|
|
1417
|
+
const listHost = React18.useRef(null);
|
|
1386
1418
|
const focusIndex = Math.max(
|
|
1387
1419
|
0,
|
|
1388
1420
|
items.findIndex((i) => i.id === selected)
|
|
1389
1421
|
);
|
|
1390
|
-
|
|
1422
|
+
React18.useEffect(() => {
|
|
1391
1423
|
if (!selected) return;
|
|
1392
1424
|
listHost.current?.querySelector(`[data-outline-id="${CSS.escape(selected)}"]`)?.scrollIntoView?.({ block: "nearest" });
|
|
1393
1425
|
}, [selected]);
|
|
@@ -1544,8 +1576,9 @@ function StudioOutline({
|
|
|
1544
1576
|
}
|
|
1545
1577
|
|
|
1546
1578
|
// src/components/studio/StudioCanvas.tsx
|
|
1547
|
-
import * as
|
|
1579
|
+
import * as React19 from "react";
|
|
1548
1580
|
import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1581
|
+
var DEVICES = ["desktop", "phone"];
|
|
1549
1582
|
function StudioCanvas({
|
|
1550
1583
|
children,
|
|
1551
1584
|
deviceToggle = false,
|
|
@@ -1559,13 +1592,31 @@ function StudioCanvas({
|
|
|
1559
1592
|
className
|
|
1560
1593
|
}) {
|
|
1561
1594
|
const studio = useStudio();
|
|
1562
|
-
const [innerDevice, setInnerDevice] =
|
|
1595
|
+
const [innerDevice, setInnerDevice] = React19.useState("desktop");
|
|
1563
1596
|
const device = deviceProp ?? innerDevice;
|
|
1564
1597
|
const setDevice = (d) => {
|
|
1565
1598
|
if (deviceProp === void 0) setInnerDevice(d);
|
|
1566
1599
|
onDeviceChange?.(d);
|
|
1567
1600
|
};
|
|
1568
1601
|
const showDevices = deviceToggle && studio?.layout !== "compact";
|
|
1602
|
+
const deviceRefs = React19.useRef([]);
|
|
1603
|
+
const deviceKeyDown = (event, index) => {
|
|
1604
|
+
const step = event.key === "ArrowRight" || event.key === "ArrowDown" ? 1 : event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0;
|
|
1605
|
+
if (!step) return;
|
|
1606
|
+
event.preventDefault();
|
|
1607
|
+
const next = (index + step + DEVICES.length) % DEVICES.length;
|
|
1608
|
+
setDevice(DEVICES[next]);
|
|
1609
|
+
deviceRefs.current[next]?.focus();
|
|
1610
|
+
};
|
|
1611
|
+
const handleKeyDown = (e) => {
|
|
1612
|
+
if (e.key !== "Escape" || e.defaultPrevented || !onBackgroundClick) return;
|
|
1613
|
+
const target = e.target;
|
|
1614
|
+
if (target.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName)) {
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
e.preventDefault();
|
|
1618
|
+
onBackgroundClick();
|
|
1619
|
+
};
|
|
1569
1620
|
const width = device === "phone" && showDevices ? "390px" : maxWidth;
|
|
1570
1621
|
return /* @__PURE__ */ jsxs11("section", { "aria-label": label, className: cn("flex h-full flex-col", className), children: [
|
|
1571
1622
|
(showDevices || toolbar) && /* @__PURE__ */ jsxs11("div", { className: "flex shrink-0 items-center justify-end gap-2 px-3 pt-3", children: [
|
|
@@ -1576,13 +1627,18 @@ function StudioCanvas({
|
|
|
1576
1627
|
role: "radiogroup",
|
|
1577
1628
|
"aria-label": "Preview size",
|
|
1578
1629
|
className: "inline-flex h-9 items-center gap-1 rounded-lg bg-muted p-1 text-muted-foreground",
|
|
1579
|
-
children:
|
|
1630
|
+
children: DEVICES.map((d, i) => /* @__PURE__ */ jsxs11(
|
|
1580
1631
|
"button",
|
|
1581
1632
|
{
|
|
1633
|
+
ref: (el) => {
|
|
1634
|
+
deviceRefs.current[i] = el;
|
|
1635
|
+
},
|
|
1582
1636
|
type: "button",
|
|
1583
1637
|
role: "radio",
|
|
1584
1638
|
"aria-checked": device === d,
|
|
1639
|
+
tabIndex: device === d ? 0 : -1,
|
|
1585
1640
|
onClick: () => setDevice(d),
|
|
1641
|
+
onKeyDown: (e) => deviceKeyDown(e, i),
|
|
1586
1642
|
className: cn(
|
|
1587
1643
|
"inline-flex h-7 items-center gap-1.5 rounded-md px-2.5 text-sm font-medium hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1588
1644
|
device === d && "bg-background text-foreground shadow-sm"
|
|
@@ -1604,6 +1660,7 @@ function StudioCanvas({
|
|
|
1604
1660
|
onClick: (e) => {
|
|
1605
1661
|
if (e.target === e.currentTarget) onBackgroundClick?.();
|
|
1606
1662
|
},
|
|
1663
|
+
onKeyDown: handleKeyDown,
|
|
1607
1664
|
children: /* @__PURE__ */ jsx19(
|
|
1608
1665
|
"div",
|
|
1609
1666
|
{
|
|
@@ -1621,7 +1678,7 @@ function StudioCanvas({
|
|
|
1621
1678
|
}
|
|
1622
1679
|
|
|
1623
1680
|
// src/components/studio/StudioCanvasItem.tsx
|
|
1624
|
-
import * as
|
|
1681
|
+
import * as React20 from "react";
|
|
1625
1682
|
import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1626
1683
|
function StudioCanvasItem({
|
|
1627
1684
|
children,
|
|
@@ -1636,14 +1693,14 @@ function StudioCanvasItem({
|
|
|
1636
1693
|
className
|
|
1637
1694
|
}) {
|
|
1638
1695
|
const studio = useStudio();
|
|
1639
|
-
const ref =
|
|
1640
|
-
const pickedHere =
|
|
1696
|
+
const ref = React20.useRef(null);
|
|
1697
|
+
const pickedHere = React20.useRef(false);
|
|
1641
1698
|
const inQuickAction = (target) => !!target?.closest?.("[data-studio-quick-action]");
|
|
1642
1699
|
const select = (reveal) => {
|
|
1643
1700
|
if (!selected) onSelect?.();
|
|
1644
1701
|
if (reveal) studio?.revealInspector();
|
|
1645
1702
|
};
|
|
1646
|
-
|
|
1703
|
+
React20.useEffect(() => {
|
|
1647
1704
|
const el = ref.current;
|
|
1648
1705
|
const here = pickedHere.current;
|
|
1649
1706
|
pickedHere.current = false;
|
|
@@ -1721,7 +1778,7 @@ function StudioCanvasItem({
|
|
|
1721
1778
|
}
|
|
1722
1779
|
|
|
1723
1780
|
// src/components/studio/StudioInspector.tsx
|
|
1724
|
-
import * as
|
|
1781
|
+
import * as React21 from "react";
|
|
1725
1782
|
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1726
1783
|
function StudioInspector({
|
|
1727
1784
|
title,
|
|
@@ -1734,9 +1791,10 @@ function StudioInspector({
|
|
|
1734
1791
|
footer,
|
|
1735
1792
|
className
|
|
1736
1793
|
}) {
|
|
1737
|
-
const uid =
|
|
1738
|
-
const [innerTab, setInnerTab] =
|
|
1739
|
-
const
|
|
1794
|
+
const uid = React21.useId();
|
|
1795
|
+
const [innerTab, setInnerTab] = React21.useState(tabs?.[0]?.id ?? "");
|
|
1796
|
+
const requestedTab = tabProp ?? innerTab;
|
|
1797
|
+
const tab = !tabs || tabs.some((t) => t.id === requestedTab) ? requestedTab : tabs[0]?.id ?? "";
|
|
1740
1798
|
const hasTabs = !!tabs && tabs.length > 1;
|
|
1741
1799
|
const choose = (id) => {
|
|
1742
1800
|
if (id === tab) return;
|
|
@@ -1812,8 +1870,8 @@ function StudioInspectorSection({
|
|
|
1812
1870
|
children,
|
|
1813
1871
|
className
|
|
1814
1872
|
}) {
|
|
1815
|
-
const uid =
|
|
1816
|
-
const [open, setOpen] =
|
|
1873
|
+
const uid = React21.useId();
|
|
1874
|
+
const [open, setOpen] = React21.useState(defaultOpen);
|
|
1817
1875
|
const expanded = !collapsible || open;
|
|
1818
1876
|
return /* @__PURE__ */ jsxs13(
|
|
1819
1877
|
"section",
|
|
@@ -1873,7 +1931,7 @@ function StudioPage({
|
|
|
1873
1931
|
|
|
1874
1932
|
// src/components/studio/SaveStatus.tsx
|
|
1875
1933
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
1876
|
-
import { Fragment as
|
|
1934
|
+
import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1877
1935
|
var META = {
|
|
1878
1936
|
saved: { label: "Saved", icon: "check-circle", tone: "text-muted-foreground" },
|
|
1879
1937
|
saving: { label: "Saving\u2026", icon: "loader", tone: "text-muted-foreground" },
|
|
@@ -1890,7 +1948,7 @@ function SaveStatus({ state, detail, onRetry, label, className }) {
|
|
|
1890
1948
|
const text = label ?? meta.label;
|
|
1891
1949
|
const canRetry = !!onRetry && (state === "error" || state === "offline");
|
|
1892
1950
|
const announced = ["error", "offline", "conflict", "invalid"].includes(state);
|
|
1893
|
-
const content = /* @__PURE__ */ jsxs14(
|
|
1951
|
+
const content = /* @__PURE__ */ jsxs14(Fragment4, { children: [
|
|
1894
1952
|
/* @__PURE__ */ jsx22(
|
|
1895
1953
|
StudioIcon,
|
|
1896
1954
|
{
|
|
@@ -1947,9 +2005,9 @@ function SaveStatus({ state, detail, onRetry, label, className }) {
|
|
|
1947
2005
|
}
|
|
1948
2006
|
|
|
1949
2007
|
// src/components/studio/IssuesButton.tsx
|
|
1950
|
-
import * as
|
|
2008
|
+
import * as React22 from "react";
|
|
1951
2009
|
import * as PopoverPrimitive2 from "@radix-ui/react-popover";
|
|
1952
|
-
import { Fragment as
|
|
2010
|
+
import { Fragment as Fragment5, jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1953
2011
|
var plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
1954
2012
|
function IssuesButton({
|
|
1955
2013
|
issues,
|
|
@@ -1960,7 +2018,7 @@ function IssuesButton({
|
|
|
1960
2018
|
showWhenEmpty = false,
|
|
1961
2019
|
className
|
|
1962
2020
|
}) {
|
|
1963
|
-
const [innerOpen, setInnerOpen] =
|
|
2021
|
+
const [innerOpen, setInnerOpen] = React22.useState(false);
|
|
1964
2022
|
const open = openProp ?? innerOpen;
|
|
1965
2023
|
const setOpen = (next) => {
|
|
1966
2024
|
if (openProp === void 0) setInnerOpen(next);
|
|
@@ -1987,7 +2045,7 @@ function IssuesButton({
|
|
|
1987
2045
|
}
|
|
1988
2046
|
) : null;
|
|
1989
2047
|
}
|
|
1990
|
-
const group = (list, heading, error) => list.length > 0 && /* @__PURE__ */ jsxs15(
|
|
2048
|
+
const group = (list, heading, error) => list.length > 0 && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
1991
2049
|
/* @__PURE__ */ jsx23("p", { className: "px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: heading }),
|
|
1992
2050
|
/* @__PURE__ */ jsx23("ul", { className: "pb-1", children: list.map((issue) => /* @__PURE__ */ jsx23("li", { children: /* @__PURE__ */ jsxs15(
|
|
1993
2051
|
"button",
|
|
@@ -2058,7 +2116,7 @@ function IssuesButton({
|
|
|
2058
2116
|
}
|
|
2059
2117
|
|
|
2060
2118
|
// src/components/studio/InsertPalette.tsx
|
|
2061
|
-
import * as
|
|
2119
|
+
import * as React23 from "react";
|
|
2062
2120
|
import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2063
2121
|
function InsertPalette({
|
|
2064
2122
|
open,
|
|
@@ -2070,11 +2128,11 @@ function InsertPalette({
|
|
|
2070
2128
|
searchPlaceholder = "Search",
|
|
2071
2129
|
renderThumbnail
|
|
2072
2130
|
}) {
|
|
2073
|
-
const [query, setQuery] =
|
|
2074
|
-
const picked =
|
|
2075
|
-
const listRef =
|
|
2076
|
-
const searchRef =
|
|
2077
|
-
|
|
2131
|
+
const [query, setQuery] = React23.useState("");
|
|
2132
|
+
const picked = React23.useRef(false);
|
|
2133
|
+
const listRef = React23.useRef(null);
|
|
2134
|
+
const searchRef = React23.useRef(null);
|
|
2135
|
+
React23.useEffect(() => {
|
|
2078
2136
|
if (!open) return;
|
|
2079
2137
|
setQuery("");
|
|
2080
2138
|
picked.current = false;
|
|
@@ -2206,11 +2264,11 @@ function InsertPalette({
|
|
|
2206
2264
|
}
|
|
2207
2265
|
|
|
2208
2266
|
// src/components/DataPanel.tsx
|
|
2209
|
-
import * as
|
|
2267
|
+
import * as React25 from "react";
|
|
2210
2268
|
import * as DropdownMenuPrimitive2 from "@radix-ui/react-dropdown-menu";
|
|
2211
2269
|
|
|
2212
2270
|
// src/hooks/useFocusTrap.ts
|
|
2213
|
-
import { useEffect as
|
|
2271
|
+
import { useEffect as useEffect8, useRef as useRef8, useCallback as useCallback3 } from "react";
|
|
2214
2272
|
var FOCUSABLE_SELECTOR = [
|
|
2215
2273
|
"a[href]",
|
|
2216
2274
|
"area[href]",
|
|
@@ -2232,8 +2290,8 @@ function getFocusableElements(container) {
|
|
|
2232
2290
|
}
|
|
2233
2291
|
function useFocusTrap(options = {}) {
|
|
2234
2292
|
const { active = true, returnFocusTo, initialFocus, preventScroll = false } = options;
|
|
2235
|
-
const containerRef =
|
|
2236
|
-
const previousActiveElementRef =
|
|
2293
|
+
const containerRef = useRef8(null);
|
|
2294
|
+
const previousActiveElementRef = useRef8(null);
|
|
2237
2295
|
const handleKeyDown = useCallback3(
|
|
2238
2296
|
(event) => {
|
|
2239
2297
|
if (!active || event.key !== "Tab") return;
|
|
@@ -2257,12 +2315,13 @@ function useFocusTrap(options = {}) {
|
|
|
2257
2315
|
},
|
|
2258
2316
|
[active, preventScroll]
|
|
2259
2317
|
);
|
|
2260
|
-
|
|
2318
|
+
useEffect8(() => {
|
|
2261
2319
|
if (!active) return;
|
|
2262
2320
|
const container = containerRef.current;
|
|
2263
2321
|
if (!container) return;
|
|
2264
2322
|
previousActiveElementRef.current = document.activeElement;
|
|
2265
2323
|
const focusableElements = getFocusableElements(container);
|
|
2324
|
+
let focusFrame = 0;
|
|
2266
2325
|
if (focusableElements.length > 0) {
|
|
2267
2326
|
let elementToFocus = null;
|
|
2268
2327
|
if (initialFocus) {
|
|
@@ -2271,12 +2330,13 @@ function useFocusTrap(options = {}) {
|
|
|
2271
2330
|
if (!elementToFocus) {
|
|
2272
2331
|
elementToFocus = focusableElements[0];
|
|
2273
2332
|
}
|
|
2274
|
-
requestAnimationFrame(() => {
|
|
2333
|
+
focusFrame = requestAnimationFrame(() => {
|
|
2275
2334
|
elementToFocus?.focus({ preventScroll });
|
|
2276
2335
|
});
|
|
2277
2336
|
}
|
|
2278
2337
|
document.addEventListener("keydown", handleKeyDown);
|
|
2279
2338
|
return () => {
|
|
2339
|
+
cancelAnimationFrame(focusFrame);
|
|
2280
2340
|
document.removeEventListener("keydown", handleKeyDown);
|
|
2281
2341
|
const elementToReturn = returnFocusTo ?? previousActiveElementRef.current;
|
|
2282
2342
|
if (elementToReturn && typeof elementToReturn.focus === "function") {
|
|
@@ -2288,14 +2348,14 @@ function useFocusTrap(options = {}) {
|
|
|
2288
2348
|
}
|
|
2289
2349
|
|
|
2290
2350
|
// src/hooks/useEscapeKey.ts
|
|
2291
|
-
import * as
|
|
2351
|
+
import * as React24 from "react";
|
|
2292
2352
|
function useEscapeKey(callback, options) {
|
|
2293
2353
|
const { enabled = true, preventDefault = true, stopPropagation = false } = options ?? {};
|
|
2294
|
-
const callbackRef =
|
|
2295
|
-
|
|
2354
|
+
const callbackRef = React24.useRef(callback);
|
|
2355
|
+
React24.useEffect(() => {
|
|
2296
2356
|
callbackRef.current = callback;
|
|
2297
2357
|
}, [callback]);
|
|
2298
|
-
|
|
2358
|
+
React24.useEffect(() => {
|
|
2299
2359
|
if (!enabled) return;
|
|
2300
2360
|
const handleKeyDown = (event) => {
|
|
2301
2361
|
if (event.key === "Escape") {
|
|
@@ -2349,68 +2409,76 @@ import {
|
|
|
2349
2409
|
calculateDetachedPositionFromPinned,
|
|
2350
2410
|
getPinnedPullTransform
|
|
2351
2411
|
} from "@classic-homes/data-panel-core";
|
|
2352
|
-
import { Fragment as
|
|
2412
|
+
import { Fragment as Fragment6, jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2353
2413
|
function layoutViewportWidth() {
|
|
2354
2414
|
return document.documentElement.clientWidth;
|
|
2355
2415
|
}
|
|
2416
|
+
var SSR_VIEWPORT_WIDTH = 1024;
|
|
2417
|
+
var SSR_VIEWPORT_HEIGHT = 768;
|
|
2418
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React25.useLayoutEffect : React25.useEffect;
|
|
2356
2419
|
function isSecondaryMouseButton(e) {
|
|
2357
2420
|
return e.pointerType === "mouse" && e.button !== 0;
|
|
2358
2421
|
}
|
|
2359
2422
|
var DropdownTrigger = DropdownMenuPrimitive2.Trigger;
|
|
2360
2423
|
var DropdownContent = DropdownMenuPrimitive2.Content;
|
|
2361
2424
|
var DropdownLabel = DropdownMenuPrimitive2.Label;
|
|
2362
|
-
var
|
|
2425
|
+
var DropdownRadioGroup = DropdownMenuPrimitive2.RadioGroup;
|
|
2426
|
+
var DropdownRadioItem = DropdownMenuPrimitive2.RadioItem;
|
|
2427
|
+
var DropdownItemIndicator = DropdownMenuPrimitive2.ItemIndicator;
|
|
2428
|
+
var menuRadioItemClass = "relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none bg-popover focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50";
|
|
2363
2429
|
var DropdownSeparator = DropdownMenuPrimitive2.Separator;
|
|
2430
|
+
var EMPTY_CONSTRAINTS = {};
|
|
2431
|
+
var EMPTY_CARD_CONFIG = {};
|
|
2432
|
+
var EMPTY_ACTIONS = [];
|
|
2364
2433
|
function useDataPanel(options = {}) {
|
|
2365
2434
|
const {
|
|
2366
2435
|
persistKey,
|
|
2367
2436
|
initialMode = DEFAULT_PANEL_STATE.mode,
|
|
2368
2437
|
initialEdge = DEFAULT_PANEL_STATE.edge,
|
|
2369
2438
|
initialExpanded = DEFAULT_PANEL_STATE.isExpanded,
|
|
2370
|
-
constraints =
|
|
2439
|
+
constraints = EMPTY_CONSTRAINTS
|
|
2371
2440
|
} = options;
|
|
2372
|
-
const resolvedConstraints =
|
|
2373
|
-
|
|
2441
|
+
const resolvedConstraints = React25.useMemo(
|
|
2442
|
+
() => ({ ...DEFAULT_CONSTRAINTS, ...constraints }),
|
|
2443
|
+
[constraints]
|
|
2444
|
+
);
|
|
2445
|
+
const [persistedState] = React25.useState(() => {
|
|
2374
2446
|
if (persistKey && typeof window !== "undefined") {
|
|
2375
2447
|
return loadPanelState(persistKey);
|
|
2376
2448
|
}
|
|
2377
2449
|
return null;
|
|
2378
2450
|
});
|
|
2379
|
-
const [mode, setMode] =
|
|
2380
|
-
const [edge, setEdge] =
|
|
2381
|
-
const [isExpanded, setIsExpanded] =
|
|
2451
|
+
const [mode, setMode] = React25.useState(persistedState?.mode ?? initialMode);
|
|
2452
|
+
const [edge, setEdge] = React25.useState(persistedState?.edge ?? initialEdge);
|
|
2453
|
+
const [isExpanded, setIsExpanded] = React25.useState(
|
|
2382
2454
|
persistedState?.isExpanded ?? initialExpanded
|
|
2383
2455
|
);
|
|
2384
|
-
const [detachedPosition, setDetachedPosition] =
|
|
2456
|
+
const [detachedPosition, setDetachedPosition] = React25.useState(
|
|
2385
2457
|
persistedState?.detachedPosition ?? DEFAULT_PANEL_STATE.detachedPosition
|
|
2386
2458
|
);
|
|
2387
|
-
const [detachedSize, setDetachedSize] =
|
|
2459
|
+
const [detachedSize, setDetachedSize] = React25.useState(
|
|
2388
2460
|
persistedState?.detachedSize ?? DEFAULT_PANEL_STATE.detachedSize
|
|
2389
2461
|
);
|
|
2390
|
-
const [pinnedSize, setPinnedSize] =
|
|
2462
|
+
const [pinnedSize, setPinnedSize] = React25.useState(
|
|
2391
2463
|
persistedState?.pinnedSize ?? DEFAULT_PANEL_STATE.pinnedSize
|
|
2392
2464
|
);
|
|
2393
|
-
const saveTimeoutRef =
|
|
2394
|
-
const debouncedSave =
|
|
2465
|
+
const saveTimeoutRef = React25.useRef(null);
|
|
2466
|
+
const debouncedSave = React25.useCallback(() => {
|
|
2395
2467
|
if (!persistKey) return;
|
|
2396
2468
|
if (saveTimeoutRef.current) {
|
|
2397
2469
|
clearTimeout(saveTimeoutRef.current);
|
|
2398
2470
|
}
|
|
2399
2471
|
saveTimeoutRef.current = setTimeout(() => {
|
|
2400
2472
|
savePanelState(persistKey, {
|
|
2473
|
+
...DEFAULT_PANEL_STATE,
|
|
2474
|
+
...loadPanelState(persistKey),
|
|
2401
2475
|
mode,
|
|
2402
|
-
variant: "full",
|
|
2403
2476
|
edge,
|
|
2404
|
-
isExpanded
|
|
2405
|
-
detachedPosition,
|
|
2406
|
-
detachedSize,
|
|
2407
|
-
pinnedSize,
|
|
2408
|
-
cardSnapIndex: 0,
|
|
2409
|
-
tabOffset: 0
|
|
2477
|
+
isExpanded
|
|
2410
2478
|
});
|
|
2411
2479
|
}, 300);
|
|
2412
|
-
}, [persistKey, mode, edge, isExpanded
|
|
2413
|
-
const handleSetMode =
|
|
2480
|
+
}, [persistKey, mode, edge, isExpanded]);
|
|
2481
|
+
const handleSetMode = React25.useCallback(
|
|
2414
2482
|
(newMode) => {
|
|
2415
2483
|
setMode(newMode);
|
|
2416
2484
|
if (newMode === "detached" && typeof window !== "undefined" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
@@ -2421,7 +2489,7 @@ function useDataPanel(options = {}) {
|
|
|
2421
2489
|
},
|
|
2422
2490
|
[detachedPosition, detachedSize]
|
|
2423
2491
|
);
|
|
2424
|
-
const handleSetDetachedPosition =
|
|
2492
|
+
const handleSetDetachedPosition = React25.useCallback(
|
|
2425
2493
|
(position) => {
|
|
2426
2494
|
if (typeof window === "undefined") {
|
|
2427
2495
|
setDetachedPosition(position);
|
|
@@ -2433,13 +2501,13 @@ function useDataPanel(options = {}) {
|
|
|
2433
2501
|
},
|
|
2434
2502
|
[detachedSize]
|
|
2435
2503
|
);
|
|
2436
|
-
const handleSetDetachedSize =
|
|
2504
|
+
const handleSetDetachedSize = React25.useCallback(
|
|
2437
2505
|
(size) => {
|
|
2438
2506
|
setDetachedSize(constrainSize(size, resolvedConstraints));
|
|
2439
2507
|
},
|
|
2440
2508
|
[resolvedConstraints]
|
|
2441
2509
|
);
|
|
2442
|
-
const handleSetPinnedSize =
|
|
2510
|
+
const handleSetPinnedSize = React25.useCallback(
|
|
2443
2511
|
(size) => {
|
|
2444
2512
|
if (typeof window === "undefined") {
|
|
2445
2513
|
setPinnedSize(size);
|
|
@@ -2453,7 +2521,7 @@ function useDataPanel(options = {}) {
|
|
|
2453
2521
|
},
|
|
2454
2522
|
[edge, resolvedConstraints]
|
|
2455
2523
|
);
|
|
2456
|
-
|
|
2524
|
+
React25.useEffect(() => {
|
|
2457
2525
|
debouncedSave();
|
|
2458
2526
|
}, [debouncedSave]);
|
|
2459
2527
|
return {
|
|
@@ -2547,7 +2615,7 @@ var edgeLabels = {
|
|
|
2547
2615
|
top: "Pin to top",
|
|
2548
2616
|
bottom: "Pin to bottom"
|
|
2549
2617
|
};
|
|
2550
|
-
var DataPanelHeader =
|
|
2618
|
+
var DataPanelHeader = React25.forwardRef(
|
|
2551
2619
|
({
|
|
2552
2620
|
title,
|
|
2553
2621
|
subtitle,
|
|
@@ -2578,7 +2646,7 @@ var DataPanelHeader = React24.forwardRef(
|
|
|
2578
2646
|
),
|
|
2579
2647
|
"data-panel-header": true,
|
|
2580
2648
|
children: [
|
|
2581
|
-
/* @__PURE__ */ jsx25("div", { className: "flex flex-col min-w-0 flex-1", children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(
|
|
2649
|
+
/* @__PURE__ */ jsx25("div", { className: "flex flex-col min-w-0 flex-1", children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
2582
2650
|
title && /* @__PURE__ */ jsx25("h3", { id: titleId, className: "text-sm font-semibold leading-none truncate", children: title }),
|
|
2583
2651
|
subtitle && /* @__PURE__ */ jsx25("p", { className: "text-xs text-muted-foreground mt-1 truncate", children: subtitle })
|
|
2584
2652
|
] }) }),
|
|
@@ -2630,30 +2698,28 @@ var DataPanelHeader = React24.forwardRef(
|
|
|
2630
2698
|
align: "end",
|
|
2631
2699
|
children: [
|
|
2632
2700
|
/* @__PURE__ */ jsx25(DropdownLabel, { className: "px-2 py-1.5 text-sm font-semibold", children: "Panel Position" }),
|
|
2633
|
-
|
|
2634
|
-
|
|
2701
|
+
/* @__PURE__ */ jsxs17(
|
|
2702
|
+
DropdownRadioGroup,
|
|
2635
2703
|
{
|
|
2636
|
-
|
|
2637
|
-
|
|
2704
|
+
value: mode === "detached" ? "detached" : edge,
|
|
2705
|
+
onValueChange: (value) => {
|
|
2706
|
+
if (value === "detached") {
|
|
2707
|
+
onModeChange?.("detached");
|
|
2708
|
+
return;
|
|
2709
|
+
}
|
|
2638
2710
|
onModeChange?.("pinned");
|
|
2639
|
-
onEdgeChange?.(
|
|
2711
|
+
onEdgeChange?.(value);
|
|
2640
2712
|
},
|
|
2641
2713
|
children: [
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
{
|
|
2652
|
-
className: "relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none bg-popover focus:bg-accent focus:text-accent-foreground",
|
|
2653
|
-
onSelect: () => onModeChange?.("detached"),
|
|
2654
|
-
children: [
|
|
2655
|
-
"Detach",
|
|
2656
|
-
mode === "detached" && /* @__PURE__ */ jsx25("span", { className: "ml-auto text-xs", children: "\u2713" })
|
|
2714
|
+
["left", "right", "top", "bottom"].map((e) => /* @__PURE__ */ jsxs17(DropdownRadioItem, { value: e, className: menuRadioItemClass, children: [
|
|
2715
|
+
edgeLabels[e],
|
|
2716
|
+
/* @__PURE__ */ jsx25(DropdownItemIndicator, { className: "ml-auto text-xs", children: "\u2713" })
|
|
2717
|
+
] }, e)),
|
|
2718
|
+
/* @__PURE__ */ jsx25(DropdownSeparator, { className: "-mx-1 my-1 h-px bg-muted" }),
|
|
2719
|
+
/* @__PURE__ */ jsxs17(DropdownRadioItem, { value: "detached", className: menuRadioItemClass, children: [
|
|
2720
|
+
"Detach",
|
|
2721
|
+
/* @__PURE__ */ jsx25(DropdownItemIndicator, { className: "ml-auto text-xs", children: "\u2713" })
|
|
2722
|
+
] })
|
|
2657
2723
|
]
|
|
2658
2724
|
}
|
|
2659
2725
|
)
|
|
@@ -2724,7 +2790,7 @@ function DataPanelCardHeader({
|
|
|
2724
2790
|
tabIndex: 0,
|
|
2725
2791
|
"aria-expanded": isExpanded,
|
|
2726
2792
|
onKeyDown: onToggleKeyDown,
|
|
2727
|
-
children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(
|
|
2793
|
+
children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
2728
2794
|
subtitle && /* @__PURE__ */ jsx25("p", { className: "text-sm text-muted-foreground truncate", children: subtitle }),
|
|
2729
2795
|
title && /* @__PURE__ */ jsx25("h3", { id: titleId, className: "text-lg font-semibold truncate", children: title })
|
|
2730
2796
|
] })
|
|
@@ -2771,7 +2837,7 @@ function DataPanelCardHeader({
|
|
|
2771
2837
|
}
|
|
2772
2838
|
);
|
|
2773
2839
|
}
|
|
2774
|
-
var DataPanelContent =
|
|
2840
|
+
var DataPanelContent = React25.forwardRef(
|
|
2775
2841
|
({ children, className, "aria-label": ariaLabel = "Panel content" }, ref) => {
|
|
2776
2842
|
return /* @__PURE__ */ jsx25(
|
|
2777
2843
|
"div",
|
|
@@ -2786,7 +2852,7 @@ var DataPanelContent = React24.forwardRef(
|
|
|
2786
2852
|
}
|
|
2787
2853
|
);
|
|
2788
2854
|
DataPanelContent.displayName = "DataPanelContent";
|
|
2789
|
-
var DataPanelFooter =
|
|
2855
|
+
var DataPanelFooter = React25.forwardRef(
|
|
2790
2856
|
({ actions = [], footerContent, footerActions, className }, ref) => {
|
|
2791
2857
|
if (!footerContent && actions.length === 0 && !footerActions) {
|
|
2792
2858
|
return null;
|
|
@@ -2803,7 +2869,7 @@ var DataPanelFooter = React24.forwardRef(
|
|
|
2803
2869
|
"flex items-center justify-end gap-2 border-t border-border bg-muted/30 px-4 py-3",
|
|
2804
2870
|
className
|
|
2805
2871
|
),
|
|
2806
|
-
children: footerContent ? footerContent : /* @__PURE__ */ jsxs17(
|
|
2872
|
+
children: footerContent ? footerContent : /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
2807
2873
|
footerActions,
|
|
2808
2874
|
actions.map((action, index) => /* @__PURE__ */ jsx25(
|
|
2809
2875
|
Button,
|
|
@@ -2822,7 +2888,7 @@ var DataPanelFooter = React24.forwardRef(
|
|
|
2822
2888
|
}
|
|
2823
2889
|
);
|
|
2824
2890
|
DataPanelFooter.displayName = "DataPanelFooter";
|
|
2825
|
-
var DataPanelTab =
|
|
2891
|
+
var DataPanelTab = React25.forwardRef(
|
|
2826
2892
|
({
|
|
2827
2893
|
title = "Panel",
|
|
2828
2894
|
subtitle,
|
|
@@ -2848,17 +2914,18 @@ var DataPanelTab = React24.forwardRef(
|
|
|
2848
2914
|
bottom: "left-1/2 rounded-t-lg border-b-0"
|
|
2849
2915
|
}[edge];
|
|
2850
2916
|
const insetStyle = { [edge]: tabInset };
|
|
2851
|
-
const innerRef =
|
|
2852
|
-
const dragRef =
|
|
2917
|
+
const innerRef = React25.useRef(null);
|
|
2918
|
+
const dragRef = React25.useRef({
|
|
2853
2919
|
startX: 0,
|
|
2854
2920
|
startY: 0,
|
|
2855
2921
|
startOffset: 0,
|
|
2856
2922
|
moved: false,
|
|
2857
2923
|
pointerId: -1
|
|
2858
2924
|
});
|
|
2859
|
-
const [dragOffset, setDragOffset] =
|
|
2925
|
+
const [dragOffset, setDragOffset] = React25.useState(null);
|
|
2860
2926
|
const effectiveOffset = dragOffset ?? offset;
|
|
2861
2927
|
const draggable = !!onOffsetChange;
|
|
2928
|
+
const pointerHandledRef = React25.useRef(false);
|
|
2862
2929
|
const tabTransform = getTabTransform(edge, tabWidth, effectiveOffset);
|
|
2863
2930
|
const tabBounds = getTabBounds(edge, tabWidth);
|
|
2864
2931
|
const setRefs = (node) => {
|
|
@@ -2902,6 +2969,10 @@ var DataPanelTab = React24.forwardRef(
|
|
|
2902
2969
|
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
2903
2970
|
}
|
|
2904
2971
|
d.pointerId = -1;
|
|
2972
|
+
pointerHandledRef.current = true;
|
|
2973
|
+
setTimeout(() => {
|
|
2974
|
+
pointerHandledRef.current = false;
|
|
2975
|
+
}, 0);
|
|
2905
2976
|
if (d.moved) {
|
|
2906
2977
|
onOffsetChange?.(dragOffset ?? offset);
|
|
2907
2978
|
} else {
|
|
@@ -2925,7 +2996,7 @@ var DataPanelTab = React24.forwardRef(
|
|
|
2925
2996
|
onClick?.();
|
|
2926
2997
|
}
|
|
2927
2998
|
};
|
|
2928
|
-
|
|
2999
|
+
React25.useEffect(() => {
|
|
2929
3000
|
if (!onOffsetChange || dragOffset !== null) return;
|
|
2930
3001
|
const reclamp = () => {
|
|
2931
3002
|
const clamped = constrainTabOffset(
|
|
@@ -2973,7 +3044,13 @@ var DataPanelTab = React24.forwardRef(
|
|
|
2973
3044
|
type: "button",
|
|
2974
3045
|
"aria-label": `Expand ${title} panel`,
|
|
2975
3046
|
className: "flex min-w-0 flex-1 flex-col text-left leading-tight hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
2976
|
-
onClick:
|
|
3047
|
+
onClick: () => {
|
|
3048
|
+
if (pointerHandledRef.current) {
|
|
3049
|
+
pointerHandledRef.current = false;
|
|
3050
|
+
return;
|
|
3051
|
+
}
|
|
3052
|
+
onClick?.();
|
|
3053
|
+
},
|
|
2977
3054
|
onKeyDown: handleExpandKeyDown,
|
|
2978
3055
|
children: [
|
|
2979
3056
|
/* @__PURE__ */ jsx25("span", { className: "truncate text-sm font-semibold", children: title }),
|
|
@@ -3014,7 +3091,7 @@ function ResizeHandles({
|
|
|
3014
3091
|
onPinnedSizeChange,
|
|
3015
3092
|
constraints
|
|
3016
3093
|
}) {
|
|
3017
|
-
const handleDetachedKeyDown =
|
|
3094
|
+
const handleDetachedKeyDown = React25.useCallback(
|
|
3018
3095
|
(e, handle) => {
|
|
3019
3096
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
3020
3097
|
let width = detachedSize.width;
|
|
@@ -3077,7 +3154,7 @@ function ResizeHandles({
|
|
|
3077
3154
|
},
|
|
3078
3155
|
[detachedPosition, detachedSize, constraints, onDetachedResize]
|
|
3079
3156
|
);
|
|
3080
|
-
const handlePinnedKeyDown =
|
|
3157
|
+
const handlePinnedKeyDown = React25.useCallback(
|
|
3081
3158
|
(e) => {
|
|
3082
3159
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
3083
3160
|
let newSize = pinnedSize;
|
|
@@ -3137,7 +3214,7 @@ function ResizeHandles({
|
|
|
3137
3214
|
"bottom-left",
|
|
3138
3215
|
"bottom-right"
|
|
3139
3216
|
];
|
|
3140
|
-
return /* @__PURE__ */ jsx25(
|
|
3217
|
+
return /* @__PURE__ */ jsx25(Fragment6, { children: handles.map((handle) => {
|
|
3141
3218
|
const isCorner = handle.includes("-");
|
|
3142
3219
|
const isHorizontal2 = handle === "top" || handle === "bottom";
|
|
3143
3220
|
const isVertical = handle === "left" || handle === "right";
|
|
@@ -3194,14 +3271,14 @@ function ResizeHandles({
|
|
|
3194
3271
|
}
|
|
3195
3272
|
);
|
|
3196
3273
|
}
|
|
3197
|
-
var DataPanel =
|
|
3274
|
+
var DataPanel = React25.forwardRef(
|
|
3198
3275
|
({
|
|
3199
3276
|
open: controlledOpen,
|
|
3200
3277
|
onOpenChange,
|
|
3201
3278
|
mode: controlledMode,
|
|
3202
3279
|
onModeChange,
|
|
3203
3280
|
variant: controlledVariant,
|
|
3204
|
-
cardConfig =
|
|
3281
|
+
cardConfig = EMPTY_CARD_CONFIG,
|
|
3205
3282
|
edge: controlledEdge,
|
|
3206
3283
|
onEdgeChange,
|
|
3207
3284
|
expanded: controlledExpanded,
|
|
@@ -3209,8 +3286,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3209
3286
|
title,
|
|
3210
3287
|
subtitle,
|
|
3211
3288
|
children,
|
|
3212
|
-
actions =
|
|
3213
|
-
constraints =
|
|
3289
|
+
actions = EMPTY_ACTIONS,
|
|
3290
|
+
constraints = EMPTY_CONSTRAINTS,
|
|
3214
3291
|
tabWidth = DEFAULT_TAB_WIDTH,
|
|
3215
3292
|
tabInset = 0,
|
|
3216
3293
|
disableClose = false,
|
|
@@ -3226,39 +3303,35 @@ var DataPanel = React24.forwardRef(
|
|
|
3226
3303
|
footerActions,
|
|
3227
3304
|
className
|
|
3228
3305
|
}, ref) => {
|
|
3229
|
-
const resolvedConstraints =
|
|
3306
|
+
const resolvedConstraints = React25.useMemo(
|
|
3230
3307
|
() => ({ ...DEFAULT_CONSTRAINTS, ...constraints }),
|
|
3231
3308
|
[constraints]
|
|
3232
3309
|
);
|
|
3233
|
-
const resolvedCardConfig =
|
|
3310
|
+
const resolvedCardConfig = React25.useMemo(
|
|
3234
3311
|
() => ({ ...DEFAULT_CARD_CONFIG, ...cardConfig }),
|
|
3235
3312
|
[cardConfig]
|
|
3236
3313
|
);
|
|
3237
|
-
const panelId =
|
|
3314
|
+
const panelId = React25.useId();
|
|
3238
3315
|
const titleId = `${panelId}-title`;
|
|
3239
|
-
const [internalOpen, setInternalOpen] =
|
|
3240
|
-
const [internalMode, setInternalMode] =
|
|
3241
|
-
const [internalVariant, setInternalVariant] =
|
|
3316
|
+
const [internalOpen, setInternalOpen] = React25.useState(true);
|
|
3317
|
+
const [internalMode, setInternalMode] = React25.useState(DEFAULT_PANEL_STATE.mode);
|
|
3318
|
+
const [internalVariant, setInternalVariant] = React25.useState(
|
|
3242
3319
|
DEFAULT_PANEL_STATE.variant
|
|
3243
3320
|
);
|
|
3244
|
-
const [internalEdge, setInternalEdge] =
|
|
3245
|
-
const [internalExpanded, setInternalExpanded] =
|
|
3321
|
+
const [internalEdge, setInternalEdge] = React25.useState(DEFAULT_PANEL_STATE.edge);
|
|
3322
|
+
const [internalExpanded, setInternalExpanded] = React25.useState(
|
|
3246
3323
|
DEFAULT_PANEL_STATE.isExpanded
|
|
3247
3324
|
);
|
|
3248
|
-
const [detachedPosition, setDetachedPosition] =
|
|
3325
|
+
const [detachedPosition, setDetachedPosition] = React25.useState(
|
|
3249
3326
|
DEFAULT_PANEL_STATE.detachedPosition
|
|
3250
3327
|
);
|
|
3251
|
-
const [detachedSize, setDetachedSize] =
|
|
3252
|
-
const [pinnedSize, setPinnedSize] =
|
|
3253
|
-
const [tabOffset, setTabOffset] =
|
|
3254
|
-
const [viewportWidth, setViewportWidth] =
|
|
3255
|
-
|
|
3256
|
-
);
|
|
3257
|
-
const [viewportHeight, setViewportHeight] = React24.useState(
|
|
3258
|
-
typeof window !== "undefined" ? window.innerHeight : 768
|
|
3259
|
-
);
|
|
3328
|
+
const [detachedSize, setDetachedSize] = React25.useState(DEFAULT_PANEL_STATE.detachedSize);
|
|
3329
|
+
const [pinnedSize, setPinnedSize] = React25.useState(DEFAULT_PANEL_STATE.pinnedSize);
|
|
3330
|
+
const [tabOffset, setTabOffset] = React25.useState(DEFAULT_PANEL_STATE.tabOffset);
|
|
3331
|
+
const [viewportWidth, setViewportWidth] = React25.useState(SSR_VIEWPORT_WIDTH);
|
|
3332
|
+
const [viewportHeight, setViewportHeight] = React25.useState(SSR_VIEWPORT_HEIGHT);
|
|
3260
3333
|
const isMobile = viewportWidth < 640;
|
|
3261
|
-
const cardDefaultLeftOffset =
|
|
3334
|
+
const cardDefaultLeftOffset = React25.useCallback(
|
|
3262
3335
|
(width) => {
|
|
3263
3336
|
const margin = resolvedCardConfig.horizontalMargin;
|
|
3264
3337
|
if (resolvedCardConfig.align === "left") return margin;
|
|
@@ -3269,45 +3342,45 @@ var DataPanel = React24.forwardRef(
|
|
|
3269
3342
|
},
|
|
3270
3343
|
[viewportWidth, resolvedCardConfig.align, resolvedCardConfig.horizontalMargin]
|
|
3271
3344
|
);
|
|
3272
|
-
const [cardHorizontalPosition, setCardHorizontalPosition] =
|
|
3273
|
-
const [cardExpandedHeight, setCardExpandedHeight] =
|
|
3274
|
-
const [cardWidth, setCardWidth] =
|
|
3275
|
-
const [cardDragCurrentHeight, setCardDragCurrentHeight] =
|
|
3276
|
-
const [isCardVerticalDragging, setIsCardVerticalDragging] =
|
|
3277
|
-
const [isCardHorizontalDragging, setIsCardHorizontalDragging] =
|
|
3278
|
-
const [isCardHeightTransitioning, setIsCardHeightTransitioning] =
|
|
3279
|
-
const [isCardWidthResizing, setIsCardWidthResizing] =
|
|
3280
|
-
const [isCardTopResizing, setIsCardTopResizing] =
|
|
3281
|
-
const [isDragging, setIsDragging] =
|
|
3282
|
-
const [isResizing, setIsResizing] =
|
|
3283
|
-
const [snapPreview, setSnapPreview] =
|
|
3284
|
-
const [isPinnedDragging, setIsPinnedDragging] =
|
|
3285
|
-
const [pullOffset, setPullOffset] =
|
|
3286
|
-
const dragStateRef =
|
|
3345
|
+
const [cardHorizontalPosition, setCardHorizontalPosition] = React25.useState(0);
|
|
3346
|
+
const [cardExpandedHeight, setCardExpandedHeight] = React25.useState(0);
|
|
3347
|
+
const [cardWidth, setCardWidth] = React25.useState(null);
|
|
3348
|
+
const [cardDragCurrentHeight, setCardDragCurrentHeight] = React25.useState(CARD_HEADER_HEIGHT);
|
|
3349
|
+
const [isCardVerticalDragging, setIsCardVerticalDragging] = React25.useState(false);
|
|
3350
|
+
const [isCardHorizontalDragging, setIsCardHorizontalDragging] = React25.useState(false);
|
|
3351
|
+
const [isCardHeightTransitioning, setIsCardHeightTransitioning] = React25.useState(false);
|
|
3352
|
+
const [isCardWidthResizing, setIsCardWidthResizing] = React25.useState(false);
|
|
3353
|
+
const [isCardTopResizing, setIsCardTopResizing] = React25.useState(false);
|
|
3354
|
+
const [isDragging, setIsDragging] = React25.useState(false);
|
|
3355
|
+
const [isResizing, setIsResizing] = React25.useState(false);
|
|
3356
|
+
const [snapPreview, setSnapPreview] = React25.useState(null);
|
|
3357
|
+
const [isPinnedDragging, setIsPinnedDragging] = React25.useState(false);
|
|
3358
|
+
const [pullOffset, setPullOffset] = React25.useState(0);
|
|
3359
|
+
const dragStateRef = React25.useRef({
|
|
3287
3360
|
startPosition: { x: 0, y: 0 },
|
|
3288
3361
|
startPanelPosition: { x: 0, y: 0 }
|
|
3289
3362
|
});
|
|
3290
|
-
const pinnedDragStateRef =
|
|
3363
|
+
const pinnedDragStateRef = React25.useRef({
|
|
3291
3364
|
startPosition: { x: 0, y: 0 },
|
|
3292
3365
|
hasDetached: false
|
|
3293
3366
|
});
|
|
3294
|
-
const resizeStateRef =
|
|
3367
|
+
const resizeStateRef = React25.useRef({
|
|
3295
3368
|
handle: null,
|
|
3296
3369
|
startPosition: { x: 0, y: 0 },
|
|
3297
3370
|
startSize: { width: 0, height: 0 },
|
|
3298
3371
|
startPanelPosition: { x: 0, y: 0 }
|
|
3299
3372
|
});
|
|
3300
|
-
const cardDragStateRef =
|
|
3373
|
+
const cardDragStateRef = React25.useRef({
|
|
3301
3374
|
startY: 0,
|
|
3302
3375
|
startX: 0,
|
|
3303
3376
|
startTime: 0,
|
|
3304
3377
|
startExpanded: false,
|
|
3305
3378
|
startHorizontalPosition: 0
|
|
3306
3379
|
});
|
|
3307
|
-
const cardCurrentHeightRef =
|
|
3308
|
-
const cardTopResizeStartRef =
|
|
3309
|
-
const cardHeightUserSetRef =
|
|
3310
|
-
const cardWidthResizeStateRef =
|
|
3380
|
+
const cardCurrentHeightRef = React25.useRef(CARD_HEADER_HEIGHT);
|
|
3381
|
+
const cardTopResizeStartRef = React25.useRef({ startY: 0, startHeight: 0 });
|
|
3382
|
+
const cardHeightUserSetRef = React25.useRef(false);
|
|
3383
|
+
const cardWidthResizeStateRef = React25.useRef({
|
|
3311
3384
|
handle: null,
|
|
3312
3385
|
startX: 0,
|
|
3313
3386
|
startWidth: 0,
|
|
@@ -3319,9 +3392,12 @@ var DataPanel = React24.forwardRef(
|
|
|
3319
3392
|
const edge = controlledEdge ?? internalEdge;
|
|
3320
3393
|
const isExpanded = controlledExpanded ?? internalExpanded;
|
|
3321
3394
|
const showContent = variant !== "card" || isExpanded || isCardVerticalDragging;
|
|
3322
|
-
const
|
|
3323
|
-
const
|
|
3324
|
-
|
|
3395
|
+
const resizeRight = !disableResize && (variant === "full" && (mode === "detached" || edge === "left") || variant === "card" && isExpanded && !isMobile);
|
|
3396
|
+
const resizeBottom = !disableResize && variant === "full" && (mode === "detached" || edge === "top");
|
|
3397
|
+
const hasFooter = !!(footerContent || actions.length > 0 || footerActions);
|
|
3398
|
+
const saveTimeoutRef = React25.useRef(null);
|
|
3399
|
+
const isMountedRef = React25.useRef(true);
|
|
3400
|
+
React25.useEffect(() => {
|
|
3325
3401
|
isMountedRef.current = true;
|
|
3326
3402
|
return () => {
|
|
3327
3403
|
isMountedRef.current = false;
|
|
@@ -3332,7 +3408,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3332
3408
|
}
|
|
3333
3409
|
};
|
|
3334
3410
|
}, []);
|
|
3335
|
-
const debouncedSave =
|
|
3411
|
+
const debouncedSave = React25.useCallback(() => {
|
|
3336
3412
|
if (!persistKey) return;
|
|
3337
3413
|
if (saveTimeoutRef.current) {
|
|
3338
3414
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -3361,12 +3437,12 @@ var DataPanel = React24.forwardRef(
|
|
|
3361
3437
|
pinnedSize,
|
|
3362
3438
|
tabOffset
|
|
3363
3439
|
]);
|
|
3364
|
-
|
|
3440
|
+
React25.useEffect(() => {
|
|
3365
3441
|
debouncedSave();
|
|
3366
3442
|
}, [debouncedSave]);
|
|
3367
|
-
const hasLoadedRef =
|
|
3368
|
-
const hasPersistedPositionRef =
|
|
3369
|
-
|
|
3443
|
+
const hasLoadedRef = React25.useRef(false);
|
|
3444
|
+
const hasPersistedPositionRef = React25.useRef(false);
|
|
3445
|
+
React25.useEffect(() => {
|
|
3370
3446
|
if (!persistKey || hasLoadedRef.current) return;
|
|
3371
3447
|
hasLoadedRef.current = true;
|
|
3372
3448
|
const persisted = loadPanelState(persistKey);
|
|
@@ -3395,7 +3471,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3395
3471
|
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
3396
3472
|
}
|
|
3397
3473
|
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
3398
|
-
|
|
3474
|
+
React25.useEffect(() => {
|
|
3399
3475
|
if (mode === "detached" && !hasPersistedPositionRef.current && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
3400
3476
|
setDetachedPosition(
|
|
3401
3477
|
getInitialDetachedPosition(detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
@@ -3418,8 +3494,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3418
3494
|
},
|
|
3419
3495
|
{ enabled: isDialog, preventDefault: false }
|
|
3420
3496
|
);
|
|
3421
|
-
const panelElRef =
|
|
3422
|
-
const tabRef =
|
|
3497
|
+
const panelElRef = React25.useRef(null);
|
|
3498
|
+
const tabRef = React25.useRef(null);
|
|
3423
3499
|
const setPanelRef = (node) => {
|
|
3424
3500
|
panelElRef.current = node;
|
|
3425
3501
|
focusTrapRef.current = node;
|
|
@@ -3429,7 +3505,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3429
3505
|
ref.current = node;
|
|
3430
3506
|
}
|
|
3431
3507
|
};
|
|
3432
|
-
const handleModeChange =
|
|
3508
|
+
const handleModeChange = React25.useCallback(
|
|
3433
3509
|
(newMode) => {
|
|
3434
3510
|
if (controlledMode === void 0) {
|
|
3435
3511
|
setInternalMode(newMode);
|
|
@@ -3438,7 +3514,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3438
3514
|
},
|
|
3439
3515
|
[controlledMode, onModeChange]
|
|
3440
3516
|
);
|
|
3441
|
-
const handleEdgeChange =
|
|
3517
|
+
const handleEdgeChange = React25.useCallback(
|
|
3442
3518
|
(newEdge) => {
|
|
3443
3519
|
if (controlledEdge === void 0) {
|
|
3444
3520
|
setInternalEdge(newEdge);
|
|
@@ -3447,8 +3523,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3447
3523
|
},
|
|
3448
3524
|
[controlledEdge, onEdgeChange]
|
|
3449
3525
|
);
|
|
3450
|
-
const restoreFocusRef =
|
|
3451
|
-
const handleExpandedChange =
|
|
3526
|
+
const restoreFocusRef = React25.useRef(false);
|
|
3527
|
+
const handleExpandedChange = React25.useCallback(
|
|
3452
3528
|
(newExpanded) => {
|
|
3453
3529
|
const active = typeof document !== "undefined" ? document.activeElement : null;
|
|
3454
3530
|
restoreFocusRef.current = newExpanded !== isExpanded && !!active && active !== document.body;
|
|
@@ -3459,7 +3535,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3459
3535
|
},
|
|
3460
3536
|
[controlledExpanded, onExpandedChange, isExpanded]
|
|
3461
3537
|
);
|
|
3462
|
-
|
|
3538
|
+
React25.useEffect(() => {
|
|
3463
3539
|
if (!restoreFocusRef.current) return;
|
|
3464
3540
|
restoreFocusRef.current = false;
|
|
3465
3541
|
const active = document.activeElement;
|
|
@@ -3492,7 +3568,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3492
3568
|
document.body.style.userSelect = "none";
|
|
3493
3569
|
}
|
|
3494
3570
|
};
|
|
3495
|
-
const handleDragMove =
|
|
3571
|
+
const handleDragMove = React25.useCallback(
|
|
3496
3572
|
(e) => {
|
|
3497
3573
|
if (!isDragging) return;
|
|
3498
3574
|
const currentPos = getPointerPosition(e);
|
|
@@ -3519,7 +3595,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3519
3595
|
},
|
|
3520
3596
|
[isDragging, detachedSize, snapThreshold]
|
|
3521
3597
|
);
|
|
3522
|
-
const handleDragEnd =
|
|
3598
|
+
const handleDragEnd = React25.useCallback(() => {
|
|
3523
3599
|
if (!isDragging) return;
|
|
3524
3600
|
setIsDragging(false);
|
|
3525
3601
|
document.body.style.cursor = "";
|
|
@@ -3530,7 +3606,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3530
3606
|
setSnapPreview(null);
|
|
3531
3607
|
}
|
|
3532
3608
|
}, [isDragging, snapPreview, handleModeChange, handleEdgeChange]);
|
|
3533
|
-
const handlePinnedDragMove =
|
|
3609
|
+
const handlePinnedDragMove = React25.useCallback(
|
|
3534
3610
|
(e) => {
|
|
3535
3611
|
if (!isPinnedDragging) return;
|
|
3536
3612
|
const currentPos = getPointerPosition(e);
|
|
@@ -3566,7 +3642,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3566
3642
|
},
|
|
3567
3643
|
[isPinnedDragging, edge, detachThreshold, pinnedSize, detachedSize, handleModeChange]
|
|
3568
3644
|
);
|
|
3569
|
-
const handlePinnedDragEnd =
|
|
3645
|
+
const handlePinnedDragEnd = React25.useCallback(() => {
|
|
3570
3646
|
if (!isPinnedDragging) return;
|
|
3571
3647
|
setIsPinnedDragging(false);
|
|
3572
3648
|
setPullOffset(0);
|
|
@@ -3588,7 +3664,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3588
3664
|
document.body.style.cursor = getResizeCursor(handle);
|
|
3589
3665
|
document.body.style.userSelect = "none";
|
|
3590
3666
|
};
|
|
3591
|
-
const handleResizeMove =
|
|
3667
|
+
const handleResizeMove = React25.useCallback(
|
|
3592
3668
|
(e) => {
|
|
3593
3669
|
if (!isResizing || !resizeStateRef.current.handle) return;
|
|
3594
3670
|
const currentPos = getPointerPosition(e);
|
|
@@ -3629,7 +3705,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3629
3705
|
},
|
|
3630
3706
|
[isResizing, mode, edge, resolvedConstraints]
|
|
3631
3707
|
);
|
|
3632
|
-
const handleResizeEnd =
|
|
3708
|
+
const handleResizeEnd = React25.useCallback(() => {
|
|
3633
3709
|
if (!isResizing) return;
|
|
3634
3710
|
setIsResizing(false);
|
|
3635
3711
|
resizeStateRef.current.handle = null;
|
|
@@ -3661,7 +3737,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3661
3737
|
}
|
|
3662
3738
|
document.body.style.userSelect = "none";
|
|
3663
3739
|
};
|
|
3664
|
-
const handleCardPointerMove =
|
|
3740
|
+
const handleCardPointerMove = React25.useCallback(
|
|
3665
3741
|
(e) => {
|
|
3666
3742
|
const currentPos = getPointerPosition(e);
|
|
3667
3743
|
if (isCardVerticalDragging) {
|
|
@@ -3701,7 +3777,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3701
3777
|
resolvedCardConfig.maxWidth
|
|
3702
3778
|
]
|
|
3703
3779
|
);
|
|
3704
|
-
const handleCardPointerUp =
|
|
3780
|
+
const handleCardPointerUp = React25.useCallback(
|
|
3705
3781
|
(e) => {
|
|
3706
3782
|
const endTime = Date.now();
|
|
3707
3783
|
const currentPos = getPointerPosition(e);
|
|
@@ -3759,7 +3835,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3759
3835
|
document.body.style.cursor = "ns-resize";
|
|
3760
3836
|
document.body.style.userSelect = "none";
|
|
3761
3837
|
};
|
|
3762
|
-
const handleCardResizeMove =
|
|
3838
|
+
const handleCardResizeMove = React25.useCallback(
|
|
3763
3839
|
(e) => {
|
|
3764
3840
|
if (!isCardTopResizing) return;
|
|
3765
3841
|
const currentPos = getPointerPosition(e);
|
|
@@ -3773,7 +3849,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3773
3849
|
},
|
|
3774
3850
|
[isCardTopResizing, viewportHeight]
|
|
3775
3851
|
);
|
|
3776
|
-
const handleCardResizeEnd =
|
|
3852
|
+
const handleCardResizeEnd = React25.useCallback(() => {
|
|
3777
3853
|
if (!isCardTopResizing) return;
|
|
3778
3854
|
setIsCardTopResizing(false);
|
|
3779
3855
|
document.body.style.cursor = "";
|
|
@@ -3802,7 +3878,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3802
3878
|
document.body.style.cursor = "ew-resize";
|
|
3803
3879
|
document.body.style.userSelect = "none";
|
|
3804
3880
|
};
|
|
3805
|
-
const handleCardWidthResizeMove =
|
|
3881
|
+
const handleCardWidthResizeMove = React25.useCallback(
|
|
3806
3882
|
(e) => {
|
|
3807
3883
|
const st = cardWidthResizeStateRef.current;
|
|
3808
3884
|
if (!isCardWidthResizing || !st.handle) return;
|
|
@@ -3844,7 +3920,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3844
3920
|
resolvedCardConfig.maxWidth
|
|
3845
3921
|
]
|
|
3846
3922
|
);
|
|
3847
|
-
const handleCardWidthResizeEnd =
|
|
3923
|
+
const handleCardWidthResizeEnd = React25.useCallback(() => {
|
|
3848
3924
|
if (!isCardWidthResizing) return;
|
|
3849
3925
|
setIsCardWidthResizing(false);
|
|
3850
3926
|
cardWidthResizeStateRef.current.handle = null;
|
|
@@ -3895,7 +3971,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3895
3971
|
if (kind === "width-left") setCardHorizontalPosition((p) => p - appliedDelta);
|
|
3896
3972
|
debouncedSave();
|
|
3897
3973
|
};
|
|
3898
|
-
|
|
3974
|
+
React25.useEffect(() => {
|
|
3899
3975
|
if (isDragging) {
|
|
3900
3976
|
window.addEventListener("pointermove", handleDragMove);
|
|
3901
3977
|
window.addEventListener("pointerup", handleDragEnd);
|
|
@@ -3907,7 +3983,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3907
3983
|
};
|
|
3908
3984
|
}
|
|
3909
3985
|
}, [isDragging, handleDragMove, handleDragEnd]);
|
|
3910
|
-
|
|
3986
|
+
React25.useEffect(() => {
|
|
3911
3987
|
if (isPinnedDragging) {
|
|
3912
3988
|
window.addEventListener("pointermove", handlePinnedDragMove);
|
|
3913
3989
|
window.addEventListener("pointerup", handlePinnedDragEnd);
|
|
@@ -3919,7 +3995,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3919
3995
|
};
|
|
3920
3996
|
}
|
|
3921
3997
|
}, [isPinnedDragging, handlePinnedDragMove, handlePinnedDragEnd]);
|
|
3922
|
-
|
|
3998
|
+
React25.useEffect(() => {
|
|
3923
3999
|
if (isResizing) {
|
|
3924
4000
|
window.addEventListener("pointermove", handleResizeMove);
|
|
3925
4001
|
window.addEventListener("pointerup", handleResizeEnd);
|
|
@@ -3931,7 +4007,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3931
4007
|
};
|
|
3932
4008
|
}
|
|
3933
4009
|
}, [isResizing, handleResizeMove, handleResizeEnd]);
|
|
3934
|
-
|
|
4010
|
+
React25.useEffect(() => {
|
|
3935
4011
|
if (isCardVerticalDragging || isCardHorizontalDragging) {
|
|
3936
4012
|
window.addEventListener("pointermove", handleCardPointerMove);
|
|
3937
4013
|
window.addEventListener("pointerup", handleCardPointerUp);
|
|
@@ -3948,7 +4024,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3948
4024
|
handleCardPointerMove,
|
|
3949
4025
|
handleCardPointerUp
|
|
3950
4026
|
]);
|
|
3951
|
-
|
|
4027
|
+
React25.useEffect(() => {
|
|
3952
4028
|
if (isCardTopResizing) {
|
|
3953
4029
|
window.addEventListener("pointermove", handleCardResizeMove);
|
|
3954
4030
|
window.addEventListener("pointerup", handleCardResizeEnd);
|
|
@@ -3960,7 +4036,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3960
4036
|
};
|
|
3961
4037
|
}
|
|
3962
4038
|
}, [isCardTopResizing, handleCardResizeMove, handleCardResizeEnd]);
|
|
3963
|
-
|
|
4039
|
+
React25.useEffect(() => {
|
|
3964
4040
|
if (isCardWidthResizing) {
|
|
3965
4041
|
window.addEventListener("pointermove", handleCardWidthResizeMove);
|
|
3966
4042
|
window.addEventListener("pointerup", handleCardWidthResizeEnd);
|
|
@@ -3972,10 +4048,10 @@ var DataPanel = React24.forwardRef(
|
|
|
3972
4048
|
};
|
|
3973
4049
|
}
|
|
3974
4050
|
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
3975
|
-
const resizeStateLatestRef =
|
|
4051
|
+
const resizeStateLatestRef = React25.useRef({ mode, detachedSize });
|
|
3976
4052
|
resizeStateLatestRef.current = { mode, detachedSize };
|
|
3977
4053
|
const expandedRatio = resolvedCardConfig.expandedRatio;
|
|
3978
|
-
|
|
4054
|
+
useIsomorphicLayoutEffect(() => {
|
|
3979
4055
|
const onResize = () => {
|
|
3980
4056
|
const vh = window.innerHeight;
|
|
3981
4057
|
setViewportWidth(layoutViewportWidth());
|
|
@@ -3997,19 +4073,19 @@ var DataPanel = React24.forwardRef(
|
|
|
3997
4073
|
window.addEventListener("resize", onWindowResize);
|
|
3998
4074
|
return () => window.removeEventListener("resize", onWindowResize);
|
|
3999
4075
|
}, [expandedRatio]);
|
|
4000
|
-
|
|
4076
|
+
React25.useEffect(() => {
|
|
4001
4077
|
if (isMobile && variant === "card") {
|
|
4002
4078
|
setCardHorizontalPosition(0);
|
|
4003
4079
|
setCardWidth(null);
|
|
4004
4080
|
}
|
|
4005
4081
|
}, [isMobile, variant]);
|
|
4006
|
-
|
|
4082
|
+
React25.useEffect(() => {
|
|
4007
4083
|
if (isCardHeightTransitioning) {
|
|
4008
4084
|
const t = setTimeout(() => setIsCardHeightTransitioning(false), 350);
|
|
4009
4085
|
return () => clearTimeout(t);
|
|
4010
4086
|
}
|
|
4011
4087
|
}, [isCardHeightTransitioning]);
|
|
4012
|
-
const panelStyles =
|
|
4088
|
+
const panelStyles = React25.useMemo(() => {
|
|
4013
4089
|
if (variant === "card") {
|
|
4014
4090
|
const defaultCardWidth = Math.min(
|
|
4015
4091
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
@@ -4089,7 +4165,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4089
4165
|
}
|
|
4090
4166
|
);
|
|
4091
4167
|
}
|
|
4092
|
-
return /* @__PURE__ */ jsxs17(
|
|
4168
|
+
return /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
4093
4169
|
snapPreview && /* @__PURE__ */ jsx25(
|
|
4094
4170
|
"div",
|
|
4095
4171
|
{
|
|
@@ -4129,7 +4205,6 @@ var DataPanel = React24.forwardRef(
|
|
|
4129
4205
|
"aria-modal": isDialog ? "true" : void 0,
|
|
4130
4206
|
"aria-labelledby": title ? titleId : void 0,
|
|
4131
4207
|
"aria-label": !title ? "Side panel" : void 0,
|
|
4132
|
-
"aria-expanded": variant === "card" ? isExpanded : void 0,
|
|
4133
4208
|
onPointerDown: variant === "full" ? handleDragStart : void 0,
|
|
4134
4209
|
children: [
|
|
4135
4210
|
variant === "card" ? /* @__PURE__ */ jsx25(
|
|
@@ -4168,8 +4243,14 @@ var DataPanel = React24.forwardRef(
|
|
|
4168
4243
|
draggable: !disableDrag && (mode === "detached" || mode === "pinned" && detachThreshold > 0)
|
|
4169
4244
|
}
|
|
4170
4245
|
),
|
|
4171
|
-
showContent && /* @__PURE__ */ jsxs17(
|
|
4172
|
-
/* @__PURE__ */ jsx25(
|
|
4246
|
+
showContent && /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
4247
|
+
/* @__PURE__ */ jsx25(
|
|
4248
|
+
DataPanelContent,
|
|
4249
|
+
{
|
|
4250
|
+
className: cn(resizeRight && "mr-2.5", resizeBottom && !hasFooter && "mb-2.5"),
|
|
4251
|
+
children
|
|
4252
|
+
}
|
|
4253
|
+
),
|
|
4173
4254
|
/* @__PURE__ */ jsx25(
|
|
4174
4255
|
DataPanelFooter,
|
|
4175
4256
|
{
|
|
@@ -4210,7 +4291,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4210
4291
|
constraints: resolvedConstraints
|
|
4211
4292
|
}
|
|
4212
4293
|
),
|
|
4213
|
-
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ jsxs17(
|
|
4294
|
+
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
4214
4295
|
/* @__PURE__ */ jsx25(
|
|
4215
4296
|
"div",
|
|
4216
4297
|
{
|
|
@@ -4269,7 +4350,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4269
4350
|
DataPanel.displayName = "DataPanel";
|
|
4270
4351
|
|
|
4271
4352
|
// src/components/Skeleton.tsx
|
|
4272
|
-
import * as
|
|
4353
|
+
import * as React26 from "react";
|
|
4273
4354
|
import { cva as cva6 } from "class-variance-authority";
|
|
4274
4355
|
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
4275
4356
|
var skeletonVariants = cva6("rounded-md bg-muted", {
|
|
@@ -4287,7 +4368,7 @@ var skeletonVariants = cva6("rounded-md bg-muted", {
|
|
|
4287
4368
|
variant: "default"
|
|
4288
4369
|
}
|
|
4289
4370
|
});
|
|
4290
|
-
var Skeleton =
|
|
4371
|
+
var Skeleton = React26.forwardRef(
|
|
4291
4372
|
({ className, variant, animation = "pulse", ...props }, ref) => {
|
|
4292
4373
|
const animationClass = animation === "pulse" ? "animate-pulse" : animation === "shimmer" ? "animate-shimmer" : "";
|
|
4293
4374
|
return /* @__PURE__ */ jsx26(
|
|
@@ -4303,7 +4384,7 @@ var Skeleton = React25.forwardRef(
|
|
|
4303
4384
|
Skeleton.displayName = "Skeleton";
|
|
4304
4385
|
|
|
4305
4386
|
// src/components/Spinner.tsx
|
|
4306
|
-
import * as
|
|
4387
|
+
import * as React27 from "react";
|
|
4307
4388
|
import { cva as cva7 } from "class-variance-authority";
|
|
4308
4389
|
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4309
4390
|
var spinnerVariants = cva7("animate-spin text-current", {
|
|
@@ -4319,7 +4400,7 @@ var spinnerVariants = cva7("animate-spin text-current", {
|
|
|
4319
4400
|
size: "md"
|
|
4320
4401
|
}
|
|
4321
4402
|
});
|
|
4322
|
-
var Spinner =
|
|
4403
|
+
var Spinner = React27.forwardRef(
|
|
4323
4404
|
({ className, size, label = "Loading...", ...props }, ref) => {
|
|
4324
4405
|
return /* @__PURE__ */ jsxs18(
|
|
4325
4406
|
"svg",
|
|
@@ -4361,7 +4442,7 @@ var Spinner = React26.forwardRef(
|
|
|
4361
4442
|
Spinner.displayName = "Spinner";
|
|
4362
4443
|
|
|
4363
4444
|
// src/components/LoadingLogo.tsx
|
|
4364
|
-
import * as
|
|
4445
|
+
import * as React28 from "react";
|
|
4365
4446
|
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4366
4447
|
var logoPaths = [
|
|
4367
4448
|
"M9.902 16.6c.3.7 1.7.8 1-.6-.6-1.4-2.3-5.1-6.1-6.3-1.7-.5-3.7.4-4.3 1.6-.4.7-1.1 2.9.5 4.3.8.7 1.9 1.2 3.6 1 .4-.1.9-.5.6-.8-.5-.4-1.9-1.7-1.1-2.7.7-.8 1.4-.6 2-.3.4.2 2.1 1 3.7 3.6l.1.2z",
|
|
@@ -4384,7 +4465,7 @@ var colors = {
|
|
|
4384
4465
|
stroke: "#ffffff"
|
|
4385
4466
|
}
|
|
4386
4467
|
};
|
|
4387
|
-
var LoadingLogo =
|
|
4468
|
+
var LoadingLogo = React28.forwardRef(
|
|
4388
4469
|
({ width = 40, height = 40, loading = false, variant = "dark", className, ...props }, ref) => {
|
|
4389
4470
|
const currentColors = colors[variant];
|
|
4390
4471
|
const fillColor = loading ? currentColors.fillLoading : currentColors.fill;
|
|
@@ -4433,7 +4514,7 @@ var LoadingLogo = React27.forwardRef(
|
|
|
4433
4514
|
LoadingLogo.displayName = "LoadingLogo";
|
|
4434
4515
|
|
|
4435
4516
|
// src/components/ProgressBar.tsx
|
|
4436
|
-
import * as
|
|
4517
|
+
import * as React29 from "react";
|
|
4437
4518
|
import { cva as cva8 } from "class-variance-authority";
|
|
4438
4519
|
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4439
4520
|
var progressBarVariants = cva8("w-full overflow-hidden rounded-full bg-muted", {
|
|
@@ -4461,7 +4542,7 @@ var progressFillVariants = cva8("h-full rounded-full transition-all duration-300
|
|
|
4461
4542
|
variant: "default"
|
|
4462
4543
|
}
|
|
4463
4544
|
});
|
|
4464
|
-
var ProgressBar =
|
|
4545
|
+
var ProgressBar = React29.forwardRef(
|
|
4465
4546
|
({ className, size, variant, value, max = 100, label = "Progress", showValue = false, ...props }, ref) => {
|
|
4466
4547
|
const isIndeterminate = value === void 0;
|
|
4467
4548
|
const clampedValue = isIndeterminate ? 0 : Math.min(Math.max(0, value), max);
|
|
@@ -4500,11 +4581,11 @@ var ProgressBar = React28.forwardRef(
|
|
|
4500
4581
|
ProgressBar.displayName = "ProgressBar";
|
|
4501
4582
|
|
|
4502
4583
|
// src/components/LoadingOverlay.tsx
|
|
4503
|
-
import * as
|
|
4504
|
-
import { Fragment as
|
|
4584
|
+
import * as React30 from "react";
|
|
4585
|
+
import { Fragment as Fragment7, jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4505
4586
|
var spinnerSizeMap = { sm: "sm", md: "md", lg: "lg", xl: "xl" };
|
|
4506
4587
|
var logoSizeMap = { sm: 32, md: 40, lg: 56, xl: 80 };
|
|
4507
|
-
var LoadingOverlay =
|
|
4588
|
+
var LoadingOverlay = React30.forwardRef(
|
|
4508
4589
|
({
|
|
4509
4590
|
loading = true,
|
|
4510
4591
|
variant = "spinner",
|
|
@@ -4519,8 +4600,8 @@ var LoadingOverlay = React29.forwardRef(
|
|
|
4519
4600
|
children,
|
|
4520
4601
|
...props
|
|
4521
4602
|
}, ref) => {
|
|
4522
|
-
const [visible, setVisible] =
|
|
4523
|
-
|
|
4603
|
+
const [visible, setVisible] = React30.useState(delay === 0 && loading);
|
|
4604
|
+
React30.useEffect(() => {
|
|
4524
4605
|
if (!loading) {
|
|
4525
4606
|
setVisible(false);
|
|
4526
4607
|
return;
|
|
@@ -4532,10 +4613,16 @@ var LoadingOverlay = React29.forwardRef(
|
|
|
4532
4613
|
const timer = setTimeout(() => setVisible(true), delay);
|
|
4533
4614
|
return () => clearTimeout(timer);
|
|
4534
4615
|
}, [loading, delay]);
|
|
4616
|
+
if (!visible && mode === "inline") {
|
|
4617
|
+
return null;
|
|
4618
|
+
}
|
|
4535
4619
|
if (!visible) {
|
|
4536
|
-
return
|
|
4620
|
+
return /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
4621
|
+
children,
|
|
4622
|
+
null
|
|
4623
|
+
] });
|
|
4537
4624
|
}
|
|
4538
|
-
const indicator = /* @__PURE__ */ jsxs21(
|
|
4625
|
+
const indicator = /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
4539
4626
|
variant === "spinner" && /* @__PURE__ */ jsx30(Spinner, { size: spinnerSizeMap[size] }),
|
|
4540
4627
|
variant === "logo" && /* @__PURE__ */ jsx30(LoadingLogo, { loading: true, width: logoSizeMap[size], height: logoSizeMap[size] }),
|
|
4541
4628
|
variant === "progress" && /* @__PURE__ */ jsx30(ProgressBar, { value: progress, className: "w-48 max-w-full" }),
|
|
@@ -4563,7 +4650,7 @@ var LoadingOverlay = React29.forwardRef(
|
|
|
4563
4650
|
}
|
|
4564
4651
|
const bgClass = opaque ? "bg-background" : mode === "fullscreen" ? "bg-background/80" : "bg-background/60";
|
|
4565
4652
|
const positionClass = mode === "fullscreen" ? "fixed inset-0 z-50" : "absolute inset-0 z-10";
|
|
4566
|
-
return /* @__PURE__ */ jsxs21(
|
|
4653
|
+
return /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
4567
4654
|
children,
|
|
4568
4655
|
/* @__PURE__ */ jsx30(
|
|
4569
4656
|
"div",
|
|
@@ -4588,9 +4675,9 @@ var LoadingOverlay = React29.forwardRef(
|
|
|
4588
4675
|
LoadingOverlay.displayName = "LoadingOverlay";
|
|
4589
4676
|
|
|
4590
4677
|
// src/components/LoadingPage.tsx
|
|
4591
|
-
import * as
|
|
4678
|
+
import * as React31 from "react";
|
|
4592
4679
|
import { jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4593
|
-
var LoadingPage =
|
|
4680
|
+
var LoadingPage = React31.forwardRef(
|
|
4594
4681
|
({
|
|
4595
4682
|
loading = true,
|
|
4596
4683
|
message,
|
|
@@ -4601,8 +4688,8 @@ var LoadingPage = React30.forwardRef(
|
|
|
4601
4688
|
className,
|
|
4602
4689
|
...props
|
|
4603
4690
|
}, ref) => {
|
|
4604
|
-
const [visible, setVisible] =
|
|
4605
|
-
|
|
4691
|
+
const [visible, setVisible] = React31.useState(delay === 0 && loading);
|
|
4692
|
+
React31.useEffect(() => {
|
|
4606
4693
|
if (!loading) {
|
|
4607
4694
|
setVisible(false);
|
|
4608
4695
|
return;
|
|
@@ -4642,9 +4729,9 @@ var LoadingPage = React30.forwardRef(
|
|
|
4642
4729
|
LoadingPage.displayName = "LoadingPage";
|
|
4643
4730
|
|
|
4644
4731
|
// src/components/LoadingSection.tsx
|
|
4645
|
-
import * as
|
|
4732
|
+
import * as React32 from "react";
|
|
4646
4733
|
import { jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4647
|
-
var LoadingSection =
|
|
4734
|
+
var LoadingSection = React32.forwardRef(
|
|
4648
4735
|
({
|
|
4649
4736
|
loading = false,
|
|
4650
4737
|
variant = "spinner",
|
|
@@ -4686,9 +4773,9 @@ var LoadingSection = React31.forwardRef(
|
|
|
4686
4773
|
LoadingSection.displayName = "LoadingSection";
|
|
4687
4774
|
|
|
4688
4775
|
// src/components/LiveRegion.tsx
|
|
4689
|
-
import * as
|
|
4776
|
+
import * as React33 from "react";
|
|
4690
4777
|
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
4691
|
-
var LiveRegion =
|
|
4778
|
+
var LiveRegion = React33.forwardRef(
|
|
4692
4779
|
({ message, politeness = "polite", atomic = true, visuallyHidden = true, className, children }, ref) => {
|
|
4693
4780
|
return /* @__PURE__ */ jsx33(
|
|
4694
4781
|
"div",
|
|
@@ -4709,9 +4796,9 @@ var LiveRegion = React32.forwardRef(
|
|
|
4709
4796
|
LiveRegion.displayName = "LiveRegion";
|
|
4710
4797
|
|
|
4711
4798
|
// src/components/SkipLink.tsx
|
|
4712
|
-
import * as
|
|
4799
|
+
import * as React34 from "react";
|
|
4713
4800
|
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
4714
|
-
var SkipLink =
|
|
4801
|
+
var SkipLink = React34.forwardRef(
|
|
4715
4802
|
({ targetId, className, children = "Skip to main content", onClick, ...props }, ref) => {
|
|
4716
4803
|
const handleClick = (e) => {
|
|
4717
4804
|
e.preventDefault();
|
|
@@ -4745,11 +4832,11 @@ var SkipLink = React33.forwardRef(
|
|
|
4745
4832
|
SkipLink.displayName = "SkipLink";
|
|
4746
4833
|
|
|
4747
4834
|
// src/hooks/useFocusRef.ts
|
|
4748
|
-
import { useRef as
|
|
4835
|
+
import { useRef as useRef11, useEffect as useEffect13 } from "react";
|
|
4749
4836
|
function useFocusRef(options = {}) {
|
|
4750
4837
|
const { focusOnMount = false, preventScroll = false, delay = 0 } = options;
|
|
4751
|
-
const ref =
|
|
4752
|
-
|
|
4838
|
+
const ref = useRef11(null);
|
|
4839
|
+
useEffect13(() => {
|
|
4753
4840
|
if (!focusOnMount) return;
|
|
4754
4841
|
const focus = () => {
|
|
4755
4842
|
if (ref.current && typeof ref.current.focus === "function") {
|
|
@@ -4768,10 +4855,10 @@ function useFocusRef(options = {}) {
|
|
|
4768
4855
|
}
|
|
4769
4856
|
|
|
4770
4857
|
// src/hooks/useReducedMotion.ts
|
|
4771
|
-
import { useState as useState13, useEffect as
|
|
4858
|
+
import { useState as useState13, useEffect as useEffect14 } from "react";
|
|
4772
4859
|
function useReducedMotion() {
|
|
4773
4860
|
const [reducedMotion, setReducedMotion] = useState13(false);
|
|
4774
|
-
|
|
4861
|
+
useEffect14(() => {
|
|
4775
4862
|
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
4776
4863
|
setReducedMotion(mediaQuery.matches);
|
|
4777
4864
|
const handleChange = (event) => {
|
|
@@ -4786,8 +4873,8 @@ function useReducedMotion() {
|
|
|
4786
4873
|
}
|
|
4787
4874
|
|
|
4788
4875
|
// src/hooks/useArrowNavigation.ts
|
|
4789
|
-
import { useCallback as useCallback5, useRef as
|
|
4790
|
-
var DEFAULT_SELECTOR = '[role="menuitem"], [role="option"], [role="tab"], button, a, [tabindex]:not([tabindex="-1"])';
|
|
4876
|
+
import { useCallback as useCallback5, useRef as useRef12, useState as useState14 } from "react";
|
|
4877
|
+
var DEFAULT_SELECTOR = '[data-arrow-nav-item], [role="menuitem"], [role="option"], [role="tab"], button, a, [tabindex]:not([tabindex="-1"])';
|
|
4791
4878
|
function useArrowNavigation(options = {}) {
|
|
4792
4879
|
const {
|
|
4793
4880
|
orientation = "vertical",
|
|
@@ -4795,8 +4882,8 @@ function useArrowNavigation(options = {}) {
|
|
|
4795
4882
|
itemSelector = DEFAULT_SELECTOR,
|
|
4796
4883
|
onFocusChange
|
|
4797
4884
|
} = options;
|
|
4798
|
-
const containerRef =
|
|
4799
|
-
const focusedIndexRef =
|
|
4885
|
+
const containerRef = useRef12(null);
|
|
4886
|
+
const focusedIndexRef = useRef12(-1);
|
|
4800
4887
|
const [focusedIndex, setFocusedIndexState] = useState14(-1);
|
|
4801
4888
|
const setFocusedIndex = useCallback5((index) => {
|
|
4802
4889
|
focusedIndexRef.current = index;
|
|
@@ -4893,6 +4980,7 @@ function useArrowNavigation(options = {}) {
|
|
|
4893
4980
|
const tabStopIndex = focusedIndex === -1 ? 0 : focusedIndex;
|
|
4894
4981
|
const getItemProps = useCallback5(
|
|
4895
4982
|
(index) => ({
|
|
4983
|
+
"data-arrow-nav-item": true,
|
|
4896
4984
|
tabIndex: index === tabStopIndex ? 0 : -1,
|
|
4897
4985
|
onFocus: () => {
|
|
4898
4986
|
setFocusedIndex(index);
|
|
@@ -4909,13 +4997,13 @@ function useArrowNavigation(options = {}) {
|
|
|
4909
4997
|
}
|
|
4910
4998
|
|
|
4911
4999
|
// src/hooks/useRovingTabindex.ts
|
|
4912
|
-
import { useState as useState15, useCallback as useCallback6, useRef as
|
|
5000
|
+
import { useState as useState15, useCallback as useCallback6, useRef as useRef13 } from "react";
|
|
4913
5001
|
var DEFAULT_SELECTOR2 = "[data-roving-tabindex-item]";
|
|
4914
5002
|
function useRovingTabindex(options = {}) {
|
|
4915
5003
|
const { loop = true, itemSelector = DEFAULT_SELECTOR2, initialIndex = 0, onIndexChange } = options;
|
|
4916
5004
|
const [activeIndex, setActiveIndex] = useState15(initialIndex);
|
|
4917
|
-
const containerRef =
|
|
4918
|
-
const itemsRef =
|
|
5005
|
+
const containerRef = useRef13(null);
|
|
5006
|
+
const itemsRef = useRef13(/* @__PURE__ */ new Map());
|
|
4919
5007
|
const getItems = useCallback6(() => {
|
|
4920
5008
|
if (!containerRef.current) {
|
|
4921
5009
|
return Array.from(itemsRef.current.values());
|
|
@@ -4981,7 +5069,7 @@ function useRovingTabindex(options = {}) {
|
|
|
4981
5069
|
onKeyDown: handleKeyDown
|
|
4982
5070
|
};
|
|
4983
5071
|
const getItemProps = useCallback6(
|
|
4984
|
-
(index) => ({
|
|
5072
|
+
(index, handlers = {}) => ({
|
|
4985
5073
|
"data-roving-tabindex-item": true,
|
|
4986
5074
|
tabIndex: index === activeIndex ? 0 : -1,
|
|
4987
5075
|
ref: (node) => {
|
|
@@ -4991,11 +5079,13 @@ function useRovingTabindex(options = {}) {
|
|
|
4991
5079
|
itemsRef.current.delete(index);
|
|
4992
5080
|
}
|
|
4993
5081
|
},
|
|
4994
|
-
onClick: () => {
|
|
5082
|
+
onClick: (event) => {
|
|
5083
|
+
handlers.onClick?.(event);
|
|
4995
5084
|
setActiveIndex(index);
|
|
4996
5085
|
onIndexChange?.(index);
|
|
4997
5086
|
},
|
|
4998
|
-
onFocus: () => {
|
|
5087
|
+
onFocus: (event) => {
|
|
5088
|
+
handlers.onFocus?.(event);
|
|
4999
5089
|
if (activeIndex !== index) {
|
|
5000
5090
|
setActiveIndex(index);
|
|
5001
5091
|
onIndexChange?.(index);
|
|
@@ -5017,21 +5107,21 @@ function useRovingTabindex(options = {}) {
|
|
|
5017
5107
|
}
|
|
5018
5108
|
|
|
5019
5109
|
// src/hooks/useClickOutside.ts
|
|
5020
|
-
import * as
|
|
5110
|
+
import * as React35 from "react";
|
|
5021
5111
|
function useClickOutside(ref, callback, options) {
|
|
5022
5112
|
const {
|
|
5023
5113
|
enabled = true,
|
|
5024
5114
|
events = ["mousedown", "touchstart"],
|
|
5025
5115
|
ignoreElements = []
|
|
5026
5116
|
} = options ?? {};
|
|
5027
|
-
const callbackRef =
|
|
5028
|
-
const ignoreElementsRef =
|
|
5029
|
-
|
|
5117
|
+
const callbackRef = React35.useRef(callback);
|
|
5118
|
+
const ignoreElementsRef = React35.useRef(ignoreElements);
|
|
5119
|
+
React35.useEffect(() => {
|
|
5030
5120
|
callbackRef.current = callback;
|
|
5031
5121
|
ignoreElementsRef.current = ignoreElements;
|
|
5032
5122
|
}, [callback, ignoreElements]);
|
|
5033
5123
|
const eventsKey = events.join(",");
|
|
5034
|
-
|
|
5124
|
+
React35.useEffect(() => {
|
|
5035
5125
|
if (!enabled) return;
|
|
5036
5126
|
const handleEvent = (event) => {
|
|
5037
5127
|
const target = event.target;
|
|
@@ -5114,6 +5204,7 @@ export {
|
|
|
5114
5204
|
badgeVariants,
|
|
5115
5205
|
buttonVariants,
|
|
5116
5206
|
cn,
|
|
5207
|
+
labelVariants,
|
|
5117
5208
|
pageHeaderActionsVariants,
|
|
5118
5209
|
pageHeaderContainerVariants,
|
|
5119
5210
|
pageHeaderSubtitleVariants,
|