@classic-homes/theme-react 0.4.3 → 0.5.1
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 +42 -13
- package/dist/index.d.ts +42 -13
- package/dist/index.js +396 -309
- package/dist/index.mjs +430 -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,
|
|
@@ -1633,17 +1690,18 @@ function StudioCanvasItem({
|
|
|
1633
1690
|
insertLabel,
|
|
1634
1691
|
invalid = false,
|
|
1635
1692
|
insertPlacement = "center",
|
|
1693
|
+
toolbarPlacement = "edge",
|
|
1636
1694
|
className
|
|
1637
1695
|
}) {
|
|
1638
1696
|
const studio = useStudio();
|
|
1639
|
-
const ref =
|
|
1640
|
-
const pickedHere =
|
|
1697
|
+
const ref = React20.useRef(null);
|
|
1698
|
+
const pickedHere = React20.useRef(false);
|
|
1641
1699
|
const inQuickAction = (target) => !!target?.closest?.("[data-studio-quick-action]");
|
|
1642
1700
|
const select = (reveal) => {
|
|
1643
1701
|
if (!selected) onSelect?.();
|
|
1644
1702
|
if (reveal) studio?.revealInspector();
|
|
1645
1703
|
};
|
|
1646
|
-
|
|
1704
|
+
React20.useEffect(() => {
|
|
1647
1705
|
const el = ref.current;
|
|
1648
1706
|
const here = pickedHere.current;
|
|
1649
1707
|
pickedHere.current = false;
|
|
@@ -1692,7 +1750,10 @@ function StudioCanvasItem({
|
|
|
1692
1750
|
"div",
|
|
1693
1751
|
{
|
|
1694
1752
|
"data-studio-quick-action": "",
|
|
1695
|
-
className:
|
|
1753
|
+
className: cn(
|
|
1754
|
+
"absolute right-3 z-10 flex items-center gap-0.5 rounded-md border border-border bg-background p-0.5 shadow-md",
|
|
1755
|
+
toolbarPlacement === "above" ? "bottom-full mb-1" : "-top-4"
|
|
1756
|
+
),
|
|
1696
1757
|
children: toolbar
|
|
1697
1758
|
}
|
|
1698
1759
|
),
|
|
@@ -1721,7 +1782,7 @@ function StudioCanvasItem({
|
|
|
1721
1782
|
}
|
|
1722
1783
|
|
|
1723
1784
|
// src/components/studio/StudioInspector.tsx
|
|
1724
|
-
import * as
|
|
1785
|
+
import * as React21 from "react";
|
|
1725
1786
|
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1726
1787
|
function StudioInspector({
|
|
1727
1788
|
title,
|
|
@@ -1734,9 +1795,10 @@ function StudioInspector({
|
|
|
1734
1795
|
footer,
|
|
1735
1796
|
className
|
|
1736
1797
|
}) {
|
|
1737
|
-
const uid =
|
|
1738
|
-
const [innerTab, setInnerTab] =
|
|
1739
|
-
const
|
|
1798
|
+
const uid = React21.useId();
|
|
1799
|
+
const [innerTab, setInnerTab] = React21.useState(tabs?.[0]?.id ?? "");
|
|
1800
|
+
const requestedTab = tabProp ?? innerTab;
|
|
1801
|
+
const tab = !tabs || tabs.some((t) => t.id === requestedTab) ? requestedTab : tabs[0]?.id ?? "";
|
|
1740
1802
|
const hasTabs = !!tabs && tabs.length > 1;
|
|
1741
1803
|
const choose = (id) => {
|
|
1742
1804
|
if (id === tab) return;
|
|
@@ -1812,8 +1874,8 @@ function StudioInspectorSection({
|
|
|
1812
1874
|
children,
|
|
1813
1875
|
className
|
|
1814
1876
|
}) {
|
|
1815
|
-
const uid =
|
|
1816
|
-
const [open, setOpen] =
|
|
1877
|
+
const uid = React21.useId();
|
|
1878
|
+
const [open, setOpen] = React21.useState(defaultOpen);
|
|
1817
1879
|
const expanded = !collapsible || open;
|
|
1818
1880
|
return /* @__PURE__ */ jsxs13(
|
|
1819
1881
|
"section",
|
|
@@ -1873,7 +1935,7 @@ function StudioPage({
|
|
|
1873
1935
|
|
|
1874
1936
|
// src/components/studio/SaveStatus.tsx
|
|
1875
1937
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
1876
|
-
import { Fragment as
|
|
1938
|
+
import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1877
1939
|
var META = {
|
|
1878
1940
|
saved: { label: "Saved", icon: "check-circle", tone: "text-muted-foreground" },
|
|
1879
1941
|
saving: { label: "Saving\u2026", icon: "loader", tone: "text-muted-foreground" },
|
|
@@ -1890,7 +1952,7 @@ function SaveStatus({ state, detail, onRetry, label, className }) {
|
|
|
1890
1952
|
const text = label ?? meta.label;
|
|
1891
1953
|
const canRetry = !!onRetry && (state === "error" || state === "offline");
|
|
1892
1954
|
const announced = ["error", "offline", "conflict", "invalid"].includes(state);
|
|
1893
|
-
const content = /* @__PURE__ */ jsxs14(
|
|
1955
|
+
const content = /* @__PURE__ */ jsxs14(Fragment4, { children: [
|
|
1894
1956
|
/* @__PURE__ */ jsx22(
|
|
1895
1957
|
StudioIcon,
|
|
1896
1958
|
{
|
|
@@ -1947,9 +2009,9 @@ function SaveStatus({ state, detail, onRetry, label, className }) {
|
|
|
1947
2009
|
}
|
|
1948
2010
|
|
|
1949
2011
|
// src/components/studio/IssuesButton.tsx
|
|
1950
|
-
import * as
|
|
2012
|
+
import * as React22 from "react";
|
|
1951
2013
|
import * as PopoverPrimitive2 from "@radix-ui/react-popover";
|
|
1952
|
-
import { Fragment as
|
|
2014
|
+
import { Fragment as Fragment5, jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1953
2015
|
var plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
1954
2016
|
function IssuesButton({
|
|
1955
2017
|
issues,
|
|
@@ -1960,7 +2022,7 @@ function IssuesButton({
|
|
|
1960
2022
|
showWhenEmpty = false,
|
|
1961
2023
|
className
|
|
1962
2024
|
}) {
|
|
1963
|
-
const [innerOpen, setInnerOpen] =
|
|
2025
|
+
const [innerOpen, setInnerOpen] = React22.useState(false);
|
|
1964
2026
|
const open = openProp ?? innerOpen;
|
|
1965
2027
|
const setOpen = (next) => {
|
|
1966
2028
|
if (openProp === void 0) setInnerOpen(next);
|
|
@@ -1987,7 +2049,7 @@ function IssuesButton({
|
|
|
1987
2049
|
}
|
|
1988
2050
|
) : null;
|
|
1989
2051
|
}
|
|
1990
|
-
const group = (list, heading, error) => list.length > 0 && /* @__PURE__ */ jsxs15(
|
|
2052
|
+
const group = (list, heading, error) => list.length > 0 && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
1991
2053
|
/* @__PURE__ */ jsx23("p", { className: "px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: heading }),
|
|
1992
2054
|
/* @__PURE__ */ jsx23("ul", { className: "pb-1", children: list.map((issue) => /* @__PURE__ */ jsx23("li", { children: /* @__PURE__ */ jsxs15(
|
|
1993
2055
|
"button",
|
|
@@ -2058,7 +2120,7 @@ function IssuesButton({
|
|
|
2058
2120
|
}
|
|
2059
2121
|
|
|
2060
2122
|
// src/components/studio/InsertPalette.tsx
|
|
2061
|
-
import * as
|
|
2123
|
+
import * as React23 from "react";
|
|
2062
2124
|
import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2063
2125
|
function InsertPalette({
|
|
2064
2126
|
open,
|
|
@@ -2070,11 +2132,11 @@ function InsertPalette({
|
|
|
2070
2132
|
searchPlaceholder = "Search",
|
|
2071
2133
|
renderThumbnail
|
|
2072
2134
|
}) {
|
|
2073
|
-
const [query, setQuery] =
|
|
2074
|
-
const picked =
|
|
2075
|
-
const listRef =
|
|
2076
|
-
const searchRef =
|
|
2077
|
-
|
|
2135
|
+
const [query, setQuery] = React23.useState("");
|
|
2136
|
+
const picked = React23.useRef(false);
|
|
2137
|
+
const listRef = React23.useRef(null);
|
|
2138
|
+
const searchRef = React23.useRef(null);
|
|
2139
|
+
React23.useEffect(() => {
|
|
2078
2140
|
if (!open) return;
|
|
2079
2141
|
setQuery("");
|
|
2080
2142
|
picked.current = false;
|
|
@@ -2206,11 +2268,11 @@ function InsertPalette({
|
|
|
2206
2268
|
}
|
|
2207
2269
|
|
|
2208
2270
|
// src/components/DataPanel.tsx
|
|
2209
|
-
import * as
|
|
2271
|
+
import * as React25 from "react";
|
|
2210
2272
|
import * as DropdownMenuPrimitive2 from "@radix-ui/react-dropdown-menu";
|
|
2211
2273
|
|
|
2212
2274
|
// src/hooks/useFocusTrap.ts
|
|
2213
|
-
import { useEffect as
|
|
2275
|
+
import { useEffect as useEffect8, useRef as useRef8, useCallback as useCallback3 } from "react";
|
|
2214
2276
|
var FOCUSABLE_SELECTOR = [
|
|
2215
2277
|
"a[href]",
|
|
2216
2278
|
"area[href]",
|
|
@@ -2232,8 +2294,8 @@ function getFocusableElements(container) {
|
|
|
2232
2294
|
}
|
|
2233
2295
|
function useFocusTrap(options = {}) {
|
|
2234
2296
|
const { active = true, returnFocusTo, initialFocus, preventScroll = false } = options;
|
|
2235
|
-
const containerRef =
|
|
2236
|
-
const previousActiveElementRef =
|
|
2297
|
+
const containerRef = useRef8(null);
|
|
2298
|
+
const previousActiveElementRef = useRef8(null);
|
|
2237
2299
|
const handleKeyDown = useCallback3(
|
|
2238
2300
|
(event) => {
|
|
2239
2301
|
if (!active || event.key !== "Tab") return;
|
|
@@ -2257,12 +2319,13 @@ function useFocusTrap(options = {}) {
|
|
|
2257
2319
|
},
|
|
2258
2320
|
[active, preventScroll]
|
|
2259
2321
|
);
|
|
2260
|
-
|
|
2322
|
+
useEffect8(() => {
|
|
2261
2323
|
if (!active) return;
|
|
2262
2324
|
const container = containerRef.current;
|
|
2263
2325
|
if (!container) return;
|
|
2264
2326
|
previousActiveElementRef.current = document.activeElement;
|
|
2265
2327
|
const focusableElements = getFocusableElements(container);
|
|
2328
|
+
let focusFrame = 0;
|
|
2266
2329
|
if (focusableElements.length > 0) {
|
|
2267
2330
|
let elementToFocus = null;
|
|
2268
2331
|
if (initialFocus) {
|
|
@@ -2271,12 +2334,13 @@ function useFocusTrap(options = {}) {
|
|
|
2271
2334
|
if (!elementToFocus) {
|
|
2272
2335
|
elementToFocus = focusableElements[0];
|
|
2273
2336
|
}
|
|
2274
|
-
requestAnimationFrame(() => {
|
|
2337
|
+
focusFrame = requestAnimationFrame(() => {
|
|
2275
2338
|
elementToFocus?.focus({ preventScroll });
|
|
2276
2339
|
});
|
|
2277
2340
|
}
|
|
2278
2341
|
document.addEventListener("keydown", handleKeyDown);
|
|
2279
2342
|
return () => {
|
|
2343
|
+
cancelAnimationFrame(focusFrame);
|
|
2280
2344
|
document.removeEventListener("keydown", handleKeyDown);
|
|
2281
2345
|
const elementToReturn = returnFocusTo ?? previousActiveElementRef.current;
|
|
2282
2346
|
if (elementToReturn && typeof elementToReturn.focus === "function") {
|
|
@@ -2288,14 +2352,14 @@ function useFocusTrap(options = {}) {
|
|
|
2288
2352
|
}
|
|
2289
2353
|
|
|
2290
2354
|
// src/hooks/useEscapeKey.ts
|
|
2291
|
-
import * as
|
|
2355
|
+
import * as React24 from "react";
|
|
2292
2356
|
function useEscapeKey(callback, options) {
|
|
2293
2357
|
const { enabled = true, preventDefault = true, stopPropagation = false } = options ?? {};
|
|
2294
|
-
const callbackRef =
|
|
2295
|
-
|
|
2358
|
+
const callbackRef = React24.useRef(callback);
|
|
2359
|
+
React24.useEffect(() => {
|
|
2296
2360
|
callbackRef.current = callback;
|
|
2297
2361
|
}, [callback]);
|
|
2298
|
-
|
|
2362
|
+
React24.useEffect(() => {
|
|
2299
2363
|
if (!enabled) return;
|
|
2300
2364
|
const handleKeyDown = (event) => {
|
|
2301
2365
|
if (event.key === "Escape") {
|
|
@@ -2349,68 +2413,76 @@ import {
|
|
|
2349
2413
|
calculateDetachedPositionFromPinned,
|
|
2350
2414
|
getPinnedPullTransform
|
|
2351
2415
|
} from "@classic-homes/data-panel-core";
|
|
2352
|
-
import { Fragment as
|
|
2416
|
+
import { Fragment as Fragment6, jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2353
2417
|
function layoutViewportWidth() {
|
|
2354
2418
|
return document.documentElement.clientWidth;
|
|
2355
2419
|
}
|
|
2420
|
+
var SSR_VIEWPORT_WIDTH = 1024;
|
|
2421
|
+
var SSR_VIEWPORT_HEIGHT = 768;
|
|
2422
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React25.useLayoutEffect : React25.useEffect;
|
|
2356
2423
|
function isSecondaryMouseButton(e) {
|
|
2357
2424
|
return e.pointerType === "mouse" && e.button !== 0;
|
|
2358
2425
|
}
|
|
2359
2426
|
var DropdownTrigger = DropdownMenuPrimitive2.Trigger;
|
|
2360
2427
|
var DropdownContent = DropdownMenuPrimitive2.Content;
|
|
2361
2428
|
var DropdownLabel = DropdownMenuPrimitive2.Label;
|
|
2362
|
-
var
|
|
2429
|
+
var DropdownRadioGroup = DropdownMenuPrimitive2.RadioGroup;
|
|
2430
|
+
var DropdownRadioItem = DropdownMenuPrimitive2.RadioItem;
|
|
2431
|
+
var DropdownItemIndicator = DropdownMenuPrimitive2.ItemIndicator;
|
|
2432
|
+
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
2433
|
var DropdownSeparator = DropdownMenuPrimitive2.Separator;
|
|
2434
|
+
var EMPTY_CONSTRAINTS = {};
|
|
2435
|
+
var EMPTY_CARD_CONFIG = {};
|
|
2436
|
+
var EMPTY_ACTIONS = [];
|
|
2364
2437
|
function useDataPanel(options = {}) {
|
|
2365
2438
|
const {
|
|
2366
2439
|
persistKey,
|
|
2367
2440
|
initialMode = DEFAULT_PANEL_STATE.mode,
|
|
2368
2441
|
initialEdge = DEFAULT_PANEL_STATE.edge,
|
|
2369
2442
|
initialExpanded = DEFAULT_PANEL_STATE.isExpanded,
|
|
2370
|
-
constraints =
|
|
2443
|
+
constraints = EMPTY_CONSTRAINTS
|
|
2371
2444
|
} = options;
|
|
2372
|
-
const resolvedConstraints =
|
|
2373
|
-
|
|
2445
|
+
const resolvedConstraints = React25.useMemo(
|
|
2446
|
+
() => ({ ...DEFAULT_CONSTRAINTS, ...constraints }),
|
|
2447
|
+
[constraints]
|
|
2448
|
+
);
|
|
2449
|
+
const [persistedState] = React25.useState(() => {
|
|
2374
2450
|
if (persistKey && typeof window !== "undefined") {
|
|
2375
2451
|
return loadPanelState(persistKey);
|
|
2376
2452
|
}
|
|
2377
2453
|
return null;
|
|
2378
2454
|
});
|
|
2379
|
-
const [mode, setMode] =
|
|
2380
|
-
const [edge, setEdge] =
|
|
2381
|
-
const [isExpanded, setIsExpanded] =
|
|
2455
|
+
const [mode, setMode] = React25.useState(persistedState?.mode ?? initialMode);
|
|
2456
|
+
const [edge, setEdge] = React25.useState(persistedState?.edge ?? initialEdge);
|
|
2457
|
+
const [isExpanded, setIsExpanded] = React25.useState(
|
|
2382
2458
|
persistedState?.isExpanded ?? initialExpanded
|
|
2383
2459
|
);
|
|
2384
|
-
const [detachedPosition, setDetachedPosition] =
|
|
2460
|
+
const [detachedPosition, setDetachedPosition] = React25.useState(
|
|
2385
2461
|
persistedState?.detachedPosition ?? DEFAULT_PANEL_STATE.detachedPosition
|
|
2386
2462
|
);
|
|
2387
|
-
const [detachedSize, setDetachedSize] =
|
|
2463
|
+
const [detachedSize, setDetachedSize] = React25.useState(
|
|
2388
2464
|
persistedState?.detachedSize ?? DEFAULT_PANEL_STATE.detachedSize
|
|
2389
2465
|
);
|
|
2390
|
-
const [pinnedSize, setPinnedSize] =
|
|
2466
|
+
const [pinnedSize, setPinnedSize] = React25.useState(
|
|
2391
2467
|
persistedState?.pinnedSize ?? DEFAULT_PANEL_STATE.pinnedSize
|
|
2392
2468
|
);
|
|
2393
|
-
const saveTimeoutRef =
|
|
2394
|
-
const debouncedSave =
|
|
2469
|
+
const saveTimeoutRef = React25.useRef(null);
|
|
2470
|
+
const debouncedSave = React25.useCallback(() => {
|
|
2395
2471
|
if (!persistKey) return;
|
|
2396
2472
|
if (saveTimeoutRef.current) {
|
|
2397
2473
|
clearTimeout(saveTimeoutRef.current);
|
|
2398
2474
|
}
|
|
2399
2475
|
saveTimeoutRef.current = setTimeout(() => {
|
|
2400
2476
|
savePanelState(persistKey, {
|
|
2477
|
+
...DEFAULT_PANEL_STATE,
|
|
2478
|
+
...loadPanelState(persistKey),
|
|
2401
2479
|
mode,
|
|
2402
|
-
variant: "full",
|
|
2403
2480
|
edge,
|
|
2404
|
-
isExpanded
|
|
2405
|
-
detachedPosition,
|
|
2406
|
-
detachedSize,
|
|
2407
|
-
pinnedSize,
|
|
2408
|
-
cardSnapIndex: 0,
|
|
2409
|
-
tabOffset: 0
|
|
2481
|
+
isExpanded
|
|
2410
2482
|
});
|
|
2411
2483
|
}, 300);
|
|
2412
|
-
}, [persistKey, mode, edge, isExpanded
|
|
2413
|
-
const handleSetMode =
|
|
2484
|
+
}, [persistKey, mode, edge, isExpanded]);
|
|
2485
|
+
const handleSetMode = React25.useCallback(
|
|
2414
2486
|
(newMode) => {
|
|
2415
2487
|
setMode(newMode);
|
|
2416
2488
|
if (newMode === "detached" && typeof window !== "undefined" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
@@ -2421,7 +2493,7 @@ function useDataPanel(options = {}) {
|
|
|
2421
2493
|
},
|
|
2422
2494
|
[detachedPosition, detachedSize]
|
|
2423
2495
|
);
|
|
2424
|
-
const handleSetDetachedPosition =
|
|
2496
|
+
const handleSetDetachedPosition = React25.useCallback(
|
|
2425
2497
|
(position) => {
|
|
2426
2498
|
if (typeof window === "undefined") {
|
|
2427
2499
|
setDetachedPosition(position);
|
|
@@ -2433,13 +2505,13 @@ function useDataPanel(options = {}) {
|
|
|
2433
2505
|
},
|
|
2434
2506
|
[detachedSize]
|
|
2435
2507
|
);
|
|
2436
|
-
const handleSetDetachedSize =
|
|
2508
|
+
const handleSetDetachedSize = React25.useCallback(
|
|
2437
2509
|
(size) => {
|
|
2438
2510
|
setDetachedSize(constrainSize(size, resolvedConstraints));
|
|
2439
2511
|
},
|
|
2440
2512
|
[resolvedConstraints]
|
|
2441
2513
|
);
|
|
2442
|
-
const handleSetPinnedSize =
|
|
2514
|
+
const handleSetPinnedSize = React25.useCallback(
|
|
2443
2515
|
(size) => {
|
|
2444
2516
|
if (typeof window === "undefined") {
|
|
2445
2517
|
setPinnedSize(size);
|
|
@@ -2453,7 +2525,7 @@ function useDataPanel(options = {}) {
|
|
|
2453
2525
|
},
|
|
2454
2526
|
[edge, resolvedConstraints]
|
|
2455
2527
|
);
|
|
2456
|
-
|
|
2528
|
+
React25.useEffect(() => {
|
|
2457
2529
|
debouncedSave();
|
|
2458
2530
|
}, [debouncedSave]);
|
|
2459
2531
|
return {
|
|
@@ -2547,7 +2619,7 @@ var edgeLabels = {
|
|
|
2547
2619
|
top: "Pin to top",
|
|
2548
2620
|
bottom: "Pin to bottom"
|
|
2549
2621
|
};
|
|
2550
|
-
var DataPanelHeader =
|
|
2622
|
+
var DataPanelHeader = React25.forwardRef(
|
|
2551
2623
|
({
|
|
2552
2624
|
title,
|
|
2553
2625
|
subtitle,
|
|
@@ -2578,7 +2650,7 @@ var DataPanelHeader = React24.forwardRef(
|
|
|
2578
2650
|
),
|
|
2579
2651
|
"data-panel-header": true,
|
|
2580
2652
|
children: [
|
|
2581
|
-
/* @__PURE__ */ jsx25("div", { className: "flex flex-col min-w-0 flex-1", children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(
|
|
2653
|
+
/* @__PURE__ */ jsx25("div", { className: "flex flex-col min-w-0 flex-1", children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
2582
2654
|
title && /* @__PURE__ */ jsx25("h3", { id: titleId, className: "text-sm font-semibold leading-none truncate", children: title }),
|
|
2583
2655
|
subtitle && /* @__PURE__ */ jsx25("p", { className: "text-xs text-muted-foreground mt-1 truncate", children: subtitle })
|
|
2584
2656
|
] }) }),
|
|
@@ -2630,30 +2702,28 @@ var DataPanelHeader = React24.forwardRef(
|
|
|
2630
2702
|
align: "end",
|
|
2631
2703
|
children: [
|
|
2632
2704
|
/* @__PURE__ */ jsx25(DropdownLabel, { className: "px-2 py-1.5 text-sm font-semibold", children: "Panel Position" }),
|
|
2633
|
-
|
|
2634
|
-
|
|
2705
|
+
/* @__PURE__ */ jsxs17(
|
|
2706
|
+
DropdownRadioGroup,
|
|
2635
2707
|
{
|
|
2636
|
-
|
|
2637
|
-
|
|
2708
|
+
value: mode === "detached" ? "detached" : edge,
|
|
2709
|
+
onValueChange: (value) => {
|
|
2710
|
+
if (value === "detached") {
|
|
2711
|
+
onModeChange?.("detached");
|
|
2712
|
+
return;
|
|
2713
|
+
}
|
|
2638
2714
|
onModeChange?.("pinned");
|
|
2639
|
-
onEdgeChange?.(
|
|
2715
|
+
onEdgeChange?.(value);
|
|
2640
2716
|
},
|
|
2641
2717
|
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" })
|
|
2718
|
+
["left", "right", "top", "bottom"].map((e) => /* @__PURE__ */ jsxs17(DropdownRadioItem, { value: e, className: menuRadioItemClass, children: [
|
|
2719
|
+
edgeLabels[e],
|
|
2720
|
+
/* @__PURE__ */ jsx25(DropdownItemIndicator, { className: "ml-auto text-xs", children: "\u2713" })
|
|
2721
|
+
] }, e)),
|
|
2722
|
+
/* @__PURE__ */ jsx25(DropdownSeparator, { className: "-mx-1 my-1 h-px bg-muted" }),
|
|
2723
|
+
/* @__PURE__ */ jsxs17(DropdownRadioItem, { value: "detached", className: menuRadioItemClass, children: [
|
|
2724
|
+
"Detach",
|
|
2725
|
+
/* @__PURE__ */ jsx25(DropdownItemIndicator, { className: "ml-auto text-xs", children: "\u2713" })
|
|
2726
|
+
] })
|
|
2657
2727
|
]
|
|
2658
2728
|
}
|
|
2659
2729
|
)
|
|
@@ -2724,7 +2794,7 @@ function DataPanelCardHeader({
|
|
|
2724
2794
|
tabIndex: 0,
|
|
2725
2795
|
"aria-expanded": isExpanded,
|
|
2726
2796
|
onKeyDown: onToggleKeyDown,
|
|
2727
|
-
children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(
|
|
2797
|
+
children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
2728
2798
|
subtitle && /* @__PURE__ */ jsx25("p", { className: "text-sm text-muted-foreground truncate", children: subtitle }),
|
|
2729
2799
|
title && /* @__PURE__ */ jsx25("h3", { id: titleId, className: "text-lg font-semibold truncate", children: title })
|
|
2730
2800
|
] })
|
|
@@ -2771,7 +2841,7 @@ function DataPanelCardHeader({
|
|
|
2771
2841
|
}
|
|
2772
2842
|
);
|
|
2773
2843
|
}
|
|
2774
|
-
var DataPanelContent =
|
|
2844
|
+
var DataPanelContent = React25.forwardRef(
|
|
2775
2845
|
({ children, className, "aria-label": ariaLabel = "Panel content" }, ref) => {
|
|
2776
2846
|
return /* @__PURE__ */ jsx25(
|
|
2777
2847
|
"div",
|
|
@@ -2786,7 +2856,7 @@ var DataPanelContent = React24.forwardRef(
|
|
|
2786
2856
|
}
|
|
2787
2857
|
);
|
|
2788
2858
|
DataPanelContent.displayName = "DataPanelContent";
|
|
2789
|
-
var DataPanelFooter =
|
|
2859
|
+
var DataPanelFooter = React25.forwardRef(
|
|
2790
2860
|
({ actions = [], footerContent, footerActions, className }, ref) => {
|
|
2791
2861
|
if (!footerContent && actions.length === 0 && !footerActions) {
|
|
2792
2862
|
return null;
|
|
@@ -2803,7 +2873,7 @@ var DataPanelFooter = React24.forwardRef(
|
|
|
2803
2873
|
"flex items-center justify-end gap-2 border-t border-border bg-muted/30 px-4 py-3",
|
|
2804
2874
|
className
|
|
2805
2875
|
),
|
|
2806
|
-
children: footerContent ? footerContent : /* @__PURE__ */ jsxs17(
|
|
2876
|
+
children: footerContent ? footerContent : /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
2807
2877
|
footerActions,
|
|
2808
2878
|
actions.map((action, index) => /* @__PURE__ */ jsx25(
|
|
2809
2879
|
Button,
|
|
@@ -2822,7 +2892,7 @@ var DataPanelFooter = React24.forwardRef(
|
|
|
2822
2892
|
}
|
|
2823
2893
|
);
|
|
2824
2894
|
DataPanelFooter.displayName = "DataPanelFooter";
|
|
2825
|
-
var DataPanelTab =
|
|
2895
|
+
var DataPanelTab = React25.forwardRef(
|
|
2826
2896
|
({
|
|
2827
2897
|
title = "Panel",
|
|
2828
2898
|
subtitle,
|
|
@@ -2848,17 +2918,18 @@ var DataPanelTab = React24.forwardRef(
|
|
|
2848
2918
|
bottom: "left-1/2 rounded-t-lg border-b-0"
|
|
2849
2919
|
}[edge];
|
|
2850
2920
|
const insetStyle = { [edge]: tabInset };
|
|
2851
|
-
const innerRef =
|
|
2852
|
-
const dragRef =
|
|
2921
|
+
const innerRef = React25.useRef(null);
|
|
2922
|
+
const dragRef = React25.useRef({
|
|
2853
2923
|
startX: 0,
|
|
2854
2924
|
startY: 0,
|
|
2855
2925
|
startOffset: 0,
|
|
2856
2926
|
moved: false,
|
|
2857
2927
|
pointerId: -1
|
|
2858
2928
|
});
|
|
2859
|
-
const [dragOffset, setDragOffset] =
|
|
2929
|
+
const [dragOffset, setDragOffset] = React25.useState(null);
|
|
2860
2930
|
const effectiveOffset = dragOffset ?? offset;
|
|
2861
2931
|
const draggable = !!onOffsetChange;
|
|
2932
|
+
const pointerHandledRef = React25.useRef(false);
|
|
2862
2933
|
const tabTransform = getTabTransform(edge, tabWidth, effectiveOffset);
|
|
2863
2934
|
const tabBounds = getTabBounds(edge, tabWidth);
|
|
2864
2935
|
const setRefs = (node) => {
|
|
@@ -2902,6 +2973,10 @@ var DataPanelTab = React24.forwardRef(
|
|
|
2902
2973
|
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
2903
2974
|
}
|
|
2904
2975
|
d.pointerId = -1;
|
|
2976
|
+
pointerHandledRef.current = true;
|
|
2977
|
+
setTimeout(() => {
|
|
2978
|
+
pointerHandledRef.current = false;
|
|
2979
|
+
}, 0);
|
|
2905
2980
|
if (d.moved) {
|
|
2906
2981
|
onOffsetChange?.(dragOffset ?? offset);
|
|
2907
2982
|
} else {
|
|
@@ -2925,7 +3000,7 @@ var DataPanelTab = React24.forwardRef(
|
|
|
2925
3000
|
onClick?.();
|
|
2926
3001
|
}
|
|
2927
3002
|
};
|
|
2928
|
-
|
|
3003
|
+
React25.useEffect(() => {
|
|
2929
3004
|
if (!onOffsetChange || dragOffset !== null) return;
|
|
2930
3005
|
const reclamp = () => {
|
|
2931
3006
|
const clamped = constrainTabOffset(
|
|
@@ -2973,7 +3048,13 @@ var DataPanelTab = React24.forwardRef(
|
|
|
2973
3048
|
type: "button",
|
|
2974
3049
|
"aria-label": `Expand ${title} panel`,
|
|
2975
3050
|
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:
|
|
3051
|
+
onClick: () => {
|
|
3052
|
+
if (pointerHandledRef.current) {
|
|
3053
|
+
pointerHandledRef.current = false;
|
|
3054
|
+
return;
|
|
3055
|
+
}
|
|
3056
|
+
onClick?.();
|
|
3057
|
+
},
|
|
2977
3058
|
onKeyDown: handleExpandKeyDown,
|
|
2978
3059
|
children: [
|
|
2979
3060
|
/* @__PURE__ */ jsx25("span", { className: "truncate text-sm font-semibold", children: title }),
|
|
@@ -3014,7 +3095,7 @@ function ResizeHandles({
|
|
|
3014
3095
|
onPinnedSizeChange,
|
|
3015
3096
|
constraints
|
|
3016
3097
|
}) {
|
|
3017
|
-
const handleDetachedKeyDown =
|
|
3098
|
+
const handleDetachedKeyDown = React25.useCallback(
|
|
3018
3099
|
(e, handle) => {
|
|
3019
3100
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
3020
3101
|
let width = detachedSize.width;
|
|
@@ -3077,7 +3158,7 @@ function ResizeHandles({
|
|
|
3077
3158
|
},
|
|
3078
3159
|
[detachedPosition, detachedSize, constraints, onDetachedResize]
|
|
3079
3160
|
);
|
|
3080
|
-
const handlePinnedKeyDown =
|
|
3161
|
+
const handlePinnedKeyDown = React25.useCallback(
|
|
3081
3162
|
(e) => {
|
|
3082
3163
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
3083
3164
|
let newSize = pinnedSize;
|
|
@@ -3137,7 +3218,7 @@ function ResizeHandles({
|
|
|
3137
3218
|
"bottom-left",
|
|
3138
3219
|
"bottom-right"
|
|
3139
3220
|
];
|
|
3140
|
-
return /* @__PURE__ */ jsx25(
|
|
3221
|
+
return /* @__PURE__ */ jsx25(Fragment6, { children: handles.map((handle) => {
|
|
3141
3222
|
const isCorner = handle.includes("-");
|
|
3142
3223
|
const isHorizontal2 = handle === "top" || handle === "bottom";
|
|
3143
3224
|
const isVertical = handle === "left" || handle === "right";
|
|
@@ -3194,14 +3275,14 @@ function ResizeHandles({
|
|
|
3194
3275
|
}
|
|
3195
3276
|
);
|
|
3196
3277
|
}
|
|
3197
|
-
var DataPanel =
|
|
3278
|
+
var DataPanel = React25.forwardRef(
|
|
3198
3279
|
({
|
|
3199
3280
|
open: controlledOpen,
|
|
3200
3281
|
onOpenChange,
|
|
3201
3282
|
mode: controlledMode,
|
|
3202
3283
|
onModeChange,
|
|
3203
3284
|
variant: controlledVariant,
|
|
3204
|
-
cardConfig =
|
|
3285
|
+
cardConfig = EMPTY_CARD_CONFIG,
|
|
3205
3286
|
edge: controlledEdge,
|
|
3206
3287
|
onEdgeChange,
|
|
3207
3288
|
expanded: controlledExpanded,
|
|
@@ -3209,8 +3290,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3209
3290
|
title,
|
|
3210
3291
|
subtitle,
|
|
3211
3292
|
children,
|
|
3212
|
-
actions =
|
|
3213
|
-
constraints =
|
|
3293
|
+
actions = EMPTY_ACTIONS,
|
|
3294
|
+
constraints = EMPTY_CONSTRAINTS,
|
|
3214
3295
|
tabWidth = DEFAULT_TAB_WIDTH,
|
|
3215
3296
|
tabInset = 0,
|
|
3216
3297
|
disableClose = false,
|
|
@@ -3226,39 +3307,35 @@ var DataPanel = React24.forwardRef(
|
|
|
3226
3307
|
footerActions,
|
|
3227
3308
|
className
|
|
3228
3309
|
}, ref) => {
|
|
3229
|
-
const resolvedConstraints =
|
|
3310
|
+
const resolvedConstraints = React25.useMemo(
|
|
3230
3311
|
() => ({ ...DEFAULT_CONSTRAINTS, ...constraints }),
|
|
3231
3312
|
[constraints]
|
|
3232
3313
|
);
|
|
3233
|
-
const resolvedCardConfig =
|
|
3314
|
+
const resolvedCardConfig = React25.useMemo(
|
|
3234
3315
|
() => ({ ...DEFAULT_CARD_CONFIG, ...cardConfig }),
|
|
3235
3316
|
[cardConfig]
|
|
3236
3317
|
);
|
|
3237
|
-
const panelId =
|
|
3318
|
+
const panelId = React25.useId();
|
|
3238
3319
|
const titleId = `${panelId}-title`;
|
|
3239
|
-
const [internalOpen, setInternalOpen] =
|
|
3240
|
-
const [internalMode, setInternalMode] =
|
|
3241
|
-
const [internalVariant, setInternalVariant] =
|
|
3320
|
+
const [internalOpen, setInternalOpen] = React25.useState(true);
|
|
3321
|
+
const [internalMode, setInternalMode] = React25.useState(DEFAULT_PANEL_STATE.mode);
|
|
3322
|
+
const [internalVariant, setInternalVariant] = React25.useState(
|
|
3242
3323
|
DEFAULT_PANEL_STATE.variant
|
|
3243
3324
|
);
|
|
3244
|
-
const [internalEdge, setInternalEdge] =
|
|
3245
|
-
const [internalExpanded, setInternalExpanded] =
|
|
3325
|
+
const [internalEdge, setInternalEdge] = React25.useState(DEFAULT_PANEL_STATE.edge);
|
|
3326
|
+
const [internalExpanded, setInternalExpanded] = React25.useState(
|
|
3246
3327
|
DEFAULT_PANEL_STATE.isExpanded
|
|
3247
3328
|
);
|
|
3248
|
-
const [detachedPosition, setDetachedPosition] =
|
|
3329
|
+
const [detachedPosition, setDetachedPosition] = React25.useState(
|
|
3249
3330
|
DEFAULT_PANEL_STATE.detachedPosition
|
|
3250
3331
|
);
|
|
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
|
-
);
|
|
3332
|
+
const [detachedSize, setDetachedSize] = React25.useState(DEFAULT_PANEL_STATE.detachedSize);
|
|
3333
|
+
const [pinnedSize, setPinnedSize] = React25.useState(DEFAULT_PANEL_STATE.pinnedSize);
|
|
3334
|
+
const [tabOffset, setTabOffset] = React25.useState(DEFAULT_PANEL_STATE.tabOffset);
|
|
3335
|
+
const [viewportWidth, setViewportWidth] = React25.useState(SSR_VIEWPORT_WIDTH);
|
|
3336
|
+
const [viewportHeight, setViewportHeight] = React25.useState(SSR_VIEWPORT_HEIGHT);
|
|
3260
3337
|
const isMobile = viewportWidth < 640;
|
|
3261
|
-
const cardDefaultLeftOffset =
|
|
3338
|
+
const cardDefaultLeftOffset = React25.useCallback(
|
|
3262
3339
|
(width) => {
|
|
3263
3340
|
const margin = resolvedCardConfig.horizontalMargin;
|
|
3264
3341
|
if (resolvedCardConfig.align === "left") return margin;
|
|
@@ -3269,45 +3346,45 @@ var DataPanel = React24.forwardRef(
|
|
|
3269
3346
|
},
|
|
3270
3347
|
[viewportWidth, resolvedCardConfig.align, resolvedCardConfig.horizontalMargin]
|
|
3271
3348
|
);
|
|
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 =
|
|
3349
|
+
const [cardHorizontalPosition, setCardHorizontalPosition] = React25.useState(0);
|
|
3350
|
+
const [cardExpandedHeight, setCardExpandedHeight] = React25.useState(0);
|
|
3351
|
+
const [cardWidth, setCardWidth] = React25.useState(null);
|
|
3352
|
+
const [cardDragCurrentHeight, setCardDragCurrentHeight] = React25.useState(CARD_HEADER_HEIGHT);
|
|
3353
|
+
const [isCardVerticalDragging, setIsCardVerticalDragging] = React25.useState(false);
|
|
3354
|
+
const [isCardHorizontalDragging, setIsCardHorizontalDragging] = React25.useState(false);
|
|
3355
|
+
const [isCardHeightTransitioning, setIsCardHeightTransitioning] = React25.useState(false);
|
|
3356
|
+
const [isCardWidthResizing, setIsCardWidthResizing] = React25.useState(false);
|
|
3357
|
+
const [isCardTopResizing, setIsCardTopResizing] = React25.useState(false);
|
|
3358
|
+
const [isDragging, setIsDragging] = React25.useState(false);
|
|
3359
|
+
const [isResizing, setIsResizing] = React25.useState(false);
|
|
3360
|
+
const [snapPreview, setSnapPreview] = React25.useState(null);
|
|
3361
|
+
const [isPinnedDragging, setIsPinnedDragging] = React25.useState(false);
|
|
3362
|
+
const [pullOffset, setPullOffset] = React25.useState(0);
|
|
3363
|
+
const dragStateRef = React25.useRef({
|
|
3287
3364
|
startPosition: { x: 0, y: 0 },
|
|
3288
3365
|
startPanelPosition: { x: 0, y: 0 }
|
|
3289
3366
|
});
|
|
3290
|
-
const pinnedDragStateRef =
|
|
3367
|
+
const pinnedDragStateRef = React25.useRef({
|
|
3291
3368
|
startPosition: { x: 0, y: 0 },
|
|
3292
3369
|
hasDetached: false
|
|
3293
3370
|
});
|
|
3294
|
-
const resizeStateRef =
|
|
3371
|
+
const resizeStateRef = React25.useRef({
|
|
3295
3372
|
handle: null,
|
|
3296
3373
|
startPosition: { x: 0, y: 0 },
|
|
3297
3374
|
startSize: { width: 0, height: 0 },
|
|
3298
3375
|
startPanelPosition: { x: 0, y: 0 }
|
|
3299
3376
|
});
|
|
3300
|
-
const cardDragStateRef =
|
|
3377
|
+
const cardDragStateRef = React25.useRef({
|
|
3301
3378
|
startY: 0,
|
|
3302
3379
|
startX: 0,
|
|
3303
3380
|
startTime: 0,
|
|
3304
3381
|
startExpanded: false,
|
|
3305
3382
|
startHorizontalPosition: 0
|
|
3306
3383
|
});
|
|
3307
|
-
const cardCurrentHeightRef =
|
|
3308
|
-
const cardTopResizeStartRef =
|
|
3309
|
-
const cardHeightUserSetRef =
|
|
3310
|
-
const cardWidthResizeStateRef =
|
|
3384
|
+
const cardCurrentHeightRef = React25.useRef(CARD_HEADER_HEIGHT);
|
|
3385
|
+
const cardTopResizeStartRef = React25.useRef({ startY: 0, startHeight: 0 });
|
|
3386
|
+
const cardHeightUserSetRef = React25.useRef(false);
|
|
3387
|
+
const cardWidthResizeStateRef = React25.useRef({
|
|
3311
3388
|
handle: null,
|
|
3312
3389
|
startX: 0,
|
|
3313
3390
|
startWidth: 0,
|
|
@@ -3322,9 +3399,9 @@ var DataPanel = React24.forwardRef(
|
|
|
3322
3399
|
const resizeRight = !disableResize && (variant === "full" && (mode === "detached" || edge === "left") || variant === "card" && isExpanded && !isMobile);
|
|
3323
3400
|
const resizeBottom = !disableResize && variant === "full" && (mode === "detached" || edge === "top");
|
|
3324
3401
|
const hasFooter = !!(footerContent || actions.length > 0 || footerActions);
|
|
3325
|
-
const saveTimeoutRef =
|
|
3326
|
-
const isMountedRef =
|
|
3327
|
-
|
|
3402
|
+
const saveTimeoutRef = React25.useRef(null);
|
|
3403
|
+
const isMountedRef = React25.useRef(true);
|
|
3404
|
+
React25.useEffect(() => {
|
|
3328
3405
|
isMountedRef.current = true;
|
|
3329
3406
|
return () => {
|
|
3330
3407
|
isMountedRef.current = false;
|
|
@@ -3335,7 +3412,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3335
3412
|
}
|
|
3336
3413
|
};
|
|
3337
3414
|
}, []);
|
|
3338
|
-
const debouncedSave =
|
|
3415
|
+
const debouncedSave = React25.useCallback(() => {
|
|
3339
3416
|
if (!persistKey) return;
|
|
3340
3417
|
if (saveTimeoutRef.current) {
|
|
3341
3418
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -3364,12 +3441,12 @@ var DataPanel = React24.forwardRef(
|
|
|
3364
3441
|
pinnedSize,
|
|
3365
3442
|
tabOffset
|
|
3366
3443
|
]);
|
|
3367
|
-
|
|
3444
|
+
React25.useEffect(() => {
|
|
3368
3445
|
debouncedSave();
|
|
3369
3446
|
}, [debouncedSave]);
|
|
3370
|
-
const hasLoadedRef =
|
|
3371
|
-
const hasPersistedPositionRef =
|
|
3372
|
-
|
|
3447
|
+
const hasLoadedRef = React25.useRef(false);
|
|
3448
|
+
const hasPersistedPositionRef = React25.useRef(false);
|
|
3449
|
+
React25.useEffect(() => {
|
|
3373
3450
|
if (!persistKey || hasLoadedRef.current) return;
|
|
3374
3451
|
hasLoadedRef.current = true;
|
|
3375
3452
|
const persisted = loadPanelState(persistKey);
|
|
@@ -3398,7 +3475,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3398
3475
|
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
3399
3476
|
}
|
|
3400
3477
|
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
3401
|
-
|
|
3478
|
+
React25.useEffect(() => {
|
|
3402
3479
|
if (mode === "detached" && !hasPersistedPositionRef.current && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
3403
3480
|
setDetachedPosition(
|
|
3404
3481
|
getInitialDetachedPosition(detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
@@ -3421,8 +3498,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3421
3498
|
},
|
|
3422
3499
|
{ enabled: isDialog, preventDefault: false }
|
|
3423
3500
|
);
|
|
3424
|
-
const panelElRef =
|
|
3425
|
-
const tabRef =
|
|
3501
|
+
const panelElRef = React25.useRef(null);
|
|
3502
|
+
const tabRef = React25.useRef(null);
|
|
3426
3503
|
const setPanelRef = (node) => {
|
|
3427
3504
|
panelElRef.current = node;
|
|
3428
3505
|
focusTrapRef.current = node;
|
|
@@ -3432,7 +3509,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3432
3509
|
ref.current = node;
|
|
3433
3510
|
}
|
|
3434
3511
|
};
|
|
3435
|
-
const handleModeChange =
|
|
3512
|
+
const handleModeChange = React25.useCallback(
|
|
3436
3513
|
(newMode) => {
|
|
3437
3514
|
if (controlledMode === void 0) {
|
|
3438
3515
|
setInternalMode(newMode);
|
|
@@ -3441,7 +3518,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3441
3518
|
},
|
|
3442
3519
|
[controlledMode, onModeChange]
|
|
3443
3520
|
);
|
|
3444
|
-
const handleEdgeChange =
|
|
3521
|
+
const handleEdgeChange = React25.useCallback(
|
|
3445
3522
|
(newEdge) => {
|
|
3446
3523
|
if (controlledEdge === void 0) {
|
|
3447
3524
|
setInternalEdge(newEdge);
|
|
@@ -3450,8 +3527,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3450
3527
|
},
|
|
3451
3528
|
[controlledEdge, onEdgeChange]
|
|
3452
3529
|
);
|
|
3453
|
-
const restoreFocusRef =
|
|
3454
|
-
const handleExpandedChange =
|
|
3530
|
+
const restoreFocusRef = React25.useRef(false);
|
|
3531
|
+
const handleExpandedChange = React25.useCallback(
|
|
3455
3532
|
(newExpanded) => {
|
|
3456
3533
|
const active = typeof document !== "undefined" ? document.activeElement : null;
|
|
3457
3534
|
restoreFocusRef.current = newExpanded !== isExpanded && !!active && active !== document.body;
|
|
@@ -3462,7 +3539,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3462
3539
|
},
|
|
3463
3540
|
[controlledExpanded, onExpandedChange, isExpanded]
|
|
3464
3541
|
);
|
|
3465
|
-
|
|
3542
|
+
React25.useEffect(() => {
|
|
3466
3543
|
if (!restoreFocusRef.current) return;
|
|
3467
3544
|
restoreFocusRef.current = false;
|
|
3468
3545
|
const active = document.activeElement;
|
|
@@ -3495,7 +3572,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3495
3572
|
document.body.style.userSelect = "none";
|
|
3496
3573
|
}
|
|
3497
3574
|
};
|
|
3498
|
-
const handleDragMove =
|
|
3575
|
+
const handleDragMove = React25.useCallback(
|
|
3499
3576
|
(e) => {
|
|
3500
3577
|
if (!isDragging) return;
|
|
3501
3578
|
const currentPos = getPointerPosition(e);
|
|
@@ -3522,7 +3599,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3522
3599
|
},
|
|
3523
3600
|
[isDragging, detachedSize, snapThreshold]
|
|
3524
3601
|
);
|
|
3525
|
-
const handleDragEnd =
|
|
3602
|
+
const handleDragEnd = React25.useCallback(() => {
|
|
3526
3603
|
if (!isDragging) return;
|
|
3527
3604
|
setIsDragging(false);
|
|
3528
3605
|
document.body.style.cursor = "";
|
|
@@ -3533,7 +3610,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3533
3610
|
setSnapPreview(null);
|
|
3534
3611
|
}
|
|
3535
3612
|
}, [isDragging, snapPreview, handleModeChange, handleEdgeChange]);
|
|
3536
|
-
const handlePinnedDragMove =
|
|
3613
|
+
const handlePinnedDragMove = React25.useCallback(
|
|
3537
3614
|
(e) => {
|
|
3538
3615
|
if (!isPinnedDragging) return;
|
|
3539
3616
|
const currentPos = getPointerPosition(e);
|
|
@@ -3569,7 +3646,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3569
3646
|
},
|
|
3570
3647
|
[isPinnedDragging, edge, detachThreshold, pinnedSize, detachedSize, handleModeChange]
|
|
3571
3648
|
);
|
|
3572
|
-
const handlePinnedDragEnd =
|
|
3649
|
+
const handlePinnedDragEnd = React25.useCallback(() => {
|
|
3573
3650
|
if (!isPinnedDragging) return;
|
|
3574
3651
|
setIsPinnedDragging(false);
|
|
3575
3652
|
setPullOffset(0);
|
|
@@ -3591,7 +3668,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3591
3668
|
document.body.style.cursor = getResizeCursor(handle);
|
|
3592
3669
|
document.body.style.userSelect = "none";
|
|
3593
3670
|
};
|
|
3594
|
-
const handleResizeMove =
|
|
3671
|
+
const handleResizeMove = React25.useCallback(
|
|
3595
3672
|
(e) => {
|
|
3596
3673
|
if (!isResizing || !resizeStateRef.current.handle) return;
|
|
3597
3674
|
const currentPos = getPointerPosition(e);
|
|
@@ -3632,7 +3709,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3632
3709
|
},
|
|
3633
3710
|
[isResizing, mode, edge, resolvedConstraints]
|
|
3634
3711
|
);
|
|
3635
|
-
const handleResizeEnd =
|
|
3712
|
+
const handleResizeEnd = React25.useCallback(() => {
|
|
3636
3713
|
if (!isResizing) return;
|
|
3637
3714
|
setIsResizing(false);
|
|
3638
3715
|
resizeStateRef.current.handle = null;
|
|
@@ -3664,7 +3741,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3664
3741
|
}
|
|
3665
3742
|
document.body.style.userSelect = "none";
|
|
3666
3743
|
};
|
|
3667
|
-
const handleCardPointerMove =
|
|
3744
|
+
const handleCardPointerMove = React25.useCallback(
|
|
3668
3745
|
(e) => {
|
|
3669
3746
|
const currentPos = getPointerPosition(e);
|
|
3670
3747
|
if (isCardVerticalDragging) {
|
|
@@ -3704,7 +3781,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3704
3781
|
resolvedCardConfig.maxWidth
|
|
3705
3782
|
]
|
|
3706
3783
|
);
|
|
3707
|
-
const handleCardPointerUp =
|
|
3784
|
+
const handleCardPointerUp = React25.useCallback(
|
|
3708
3785
|
(e) => {
|
|
3709
3786
|
const endTime = Date.now();
|
|
3710
3787
|
const currentPos = getPointerPosition(e);
|
|
@@ -3762,7 +3839,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3762
3839
|
document.body.style.cursor = "ns-resize";
|
|
3763
3840
|
document.body.style.userSelect = "none";
|
|
3764
3841
|
};
|
|
3765
|
-
const handleCardResizeMove =
|
|
3842
|
+
const handleCardResizeMove = React25.useCallback(
|
|
3766
3843
|
(e) => {
|
|
3767
3844
|
if (!isCardTopResizing) return;
|
|
3768
3845
|
const currentPos = getPointerPosition(e);
|
|
@@ -3776,7 +3853,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3776
3853
|
},
|
|
3777
3854
|
[isCardTopResizing, viewportHeight]
|
|
3778
3855
|
);
|
|
3779
|
-
const handleCardResizeEnd =
|
|
3856
|
+
const handleCardResizeEnd = React25.useCallback(() => {
|
|
3780
3857
|
if (!isCardTopResizing) return;
|
|
3781
3858
|
setIsCardTopResizing(false);
|
|
3782
3859
|
document.body.style.cursor = "";
|
|
@@ -3805,7 +3882,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3805
3882
|
document.body.style.cursor = "ew-resize";
|
|
3806
3883
|
document.body.style.userSelect = "none";
|
|
3807
3884
|
};
|
|
3808
|
-
const handleCardWidthResizeMove =
|
|
3885
|
+
const handleCardWidthResizeMove = React25.useCallback(
|
|
3809
3886
|
(e) => {
|
|
3810
3887
|
const st = cardWidthResizeStateRef.current;
|
|
3811
3888
|
if (!isCardWidthResizing || !st.handle) return;
|
|
@@ -3847,7 +3924,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3847
3924
|
resolvedCardConfig.maxWidth
|
|
3848
3925
|
]
|
|
3849
3926
|
);
|
|
3850
|
-
const handleCardWidthResizeEnd =
|
|
3927
|
+
const handleCardWidthResizeEnd = React25.useCallback(() => {
|
|
3851
3928
|
if (!isCardWidthResizing) return;
|
|
3852
3929
|
setIsCardWidthResizing(false);
|
|
3853
3930
|
cardWidthResizeStateRef.current.handle = null;
|
|
@@ -3898,7 +3975,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3898
3975
|
if (kind === "width-left") setCardHorizontalPosition((p) => p - appliedDelta);
|
|
3899
3976
|
debouncedSave();
|
|
3900
3977
|
};
|
|
3901
|
-
|
|
3978
|
+
React25.useEffect(() => {
|
|
3902
3979
|
if (isDragging) {
|
|
3903
3980
|
window.addEventListener("pointermove", handleDragMove);
|
|
3904
3981
|
window.addEventListener("pointerup", handleDragEnd);
|
|
@@ -3910,7 +3987,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3910
3987
|
};
|
|
3911
3988
|
}
|
|
3912
3989
|
}, [isDragging, handleDragMove, handleDragEnd]);
|
|
3913
|
-
|
|
3990
|
+
React25.useEffect(() => {
|
|
3914
3991
|
if (isPinnedDragging) {
|
|
3915
3992
|
window.addEventListener("pointermove", handlePinnedDragMove);
|
|
3916
3993
|
window.addEventListener("pointerup", handlePinnedDragEnd);
|
|
@@ -3922,7 +3999,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3922
3999
|
};
|
|
3923
4000
|
}
|
|
3924
4001
|
}, [isPinnedDragging, handlePinnedDragMove, handlePinnedDragEnd]);
|
|
3925
|
-
|
|
4002
|
+
React25.useEffect(() => {
|
|
3926
4003
|
if (isResizing) {
|
|
3927
4004
|
window.addEventListener("pointermove", handleResizeMove);
|
|
3928
4005
|
window.addEventListener("pointerup", handleResizeEnd);
|
|
@@ -3934,7 +4011,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3934
4011
|
};
|
|
3935
4012
|
}
|
|
3936
4013
|
}, [isResizing, handleResizeMove, handleResizeEnd]);
|
|
3937
|
-
|
|
4014
|
+
React25.useEffect(() => {
|
|
3938
4015
|
if (isCardVerticalDragging || isCardHorizontalDragging) {
|
|
3939
4016
|
window.addEventListener("pointermove", handleCardPointerMove);
|
|
3940
4017
|
window.addEventListener("pointerup", handleCardPointerUp);
|
|
@@ -3951,7 +4028,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3951
4028
|
handleCardPointerMove,
|
|
3952
4029
|
handleCardPointerUp
|
|
3953
4030
|
]);
|
|
3954
|
-
|
|
4031
|
+
React25.useEffect(() => {
|
|
3955
4032
|
if (isCardTopResizing) {
|
|
3956
4033
|
window.addEventListener("pointermove", handleCardResizeMove);
|
|
3957
4034
|
window.addEventListener("pointerup", handleCardResizeEnd);
|
|
@@ -3963,7 +4040,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3963
4040
|
};
|
|
3964
4041
|
}
|
|
3965
4042
|
}, [isCardTopResizing, handleCardResizeMove, handleCardResizeEnd]);
|
|
3966
|
-
|
|
4043
|
+
React25.useEffect(() => {
|
|
3967
4044
|
if (isCardWidthResizing) {
|
|
3968
4045
|
window.addEventListener("pointermove", handleCardWidthResizeMove);
|
|
3969
4046
|
window.addEventListener("pointerup", handleCardWidthResizeEnd);
|
|
@@ -3975,10 +4052,10 @@ var DataPanel = React24.forwardRef(
|
|
|
3975
4052
|
};
|
|
3976
4053
|
}
|
|
3977
4054
|
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
3978
|
-
const resizeStateLatestRef =
|
|
4055
|
+
const resizeStateLatestRef = React25.useRef({ mode, detachedSize });
|
|
3979
4056
|
resizeStateLatestRef.current = { mode, detachedSize };
|
|
3980
4057
|
const expandedRatio = resolvedCardConfig.expandedRatio;
|
|
3981
|
-
|
|
4058
|
+
useIsomorphicLayoutEffect(() => {
|
|
3982
4059
|
const onResize = () => {
|
|
3983
4060
|
const vh = window.innerHeight;
|
|
3984
4061
|
setViewportWidth(layoutViewportWidth());
|
|
@@ -4000,19 +4077,19 @@ var DataPanel = React24.forwardRef(
|
|
|
4000
4077
|
window.addEventListener("resize", onWindowResize);
|
|
4001
4078
|
return () => window.removeEventListener("resize", onWindowResize);
|
|
4002
4079
|
}, [expandedRatio]);
|
|
4003
|
-
|
|
4080
|
+
React25.useEffect(() => {
|
|
4004
4081
|
if (isMobile && variant === "card") {
|
|
4005
4082
|
setCardHorizontalPosition(0);
|
|
4006
4083
|
setCardWidth(null);
|
|
4007
4084
|
}
|
|
4008
4085
|
}, [isMobile, variant]);
|
|
4009
|
-
|
|
4086
|
+
React25.useEffect(() => {
|
|
4010
4087
|
if (isCardHeightTransitioning) {
|
|
4011
4088
|
const t = setTimeout(() => setIsCardHeightTransitioning(false), 350);
|
|
4012
4089
|
return () => clearTimeout(t);
|
|
4013
4090
|
}
|
|
4014
4091
|
}, [isCardHeightTransitioning]);
|
|
4015
|
-
const panelStyles =
|
|
4092
|
+
const panelStyles = React25.useMemo(() => {
|
|
4016
4093
|
if (variant === "card") {
|
|
4017
4094
|
const defaultCardWidth = Math.min(
|
|
4018
4095
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
@@ -4092,7 +4169,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4092
4169
|
}
|
|
4093
4170
|
);
|
|
4094
4171
|
}
|
|
4095
|
-
return /* @__PURE__ */ jsxs17(
|
|
4172
|
+
return /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
4096
4173
|
snapPreview && /* @__PURE__ */ jsx25(
|
|
4097
4174
|
"div",
|
|
4098
4175
|
{
|
|
@@ -4132,7 +4209,6 @@ var DataPanel = React24.forwardRef(
|
|
|
4132
4209
|
"aria-modal": isDialog ? "true" : void 0,
|
|
4133
4210
|
"aria-labelledby": title ? titleId : void 0,
|
|
4134
4211
|
"aria-label": !title ? "Side panel" : void 0,
|
|
4135
|
-
"aria-expanded": variant === "card" ? isExpanded : void 0,
|
|
4136
4212
|
onPointerDown: variant === "full" ? handleDragStart : void 0,
|
|
4137
4213
|
children: [
|
|
4138
4214
|
variant === "card" ? /* @__PURE__ */ jsx25(
|
|
@@ -4171,7 +4247,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4171
4247
|
draggable: !disableDrag && (mode === "detached" || mode === "pinned" && detachThreshold > 0)
|
|
4172
4248
|
}
|
|
4173
4249
|
),
|
|
4174
|
-
showContent && /* @__PURE__ */ jsxs17(
|
|
4250
|
+
showContent && /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
4175
4251
|
/* @__PURE__ */ jsx25(
|
|
4176
4252
|
DataPanelContent,
|
|
4177
4253
|
{
|
|
@@ -4219,7 +4295,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4219
4295
|
constraints: resolvedConstraints
|
|
4220
4296
|
}
|
|
4221
4297
|
),
|
|
4222
|
-
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ jsxs17(
|
|
4298
|
+
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
4223
4299
|
/* @__PURE__ */ jsx25(
|
|
4224
4300
|
"div",
|
|
4225
4301
|
{
|
|
@@ -4278,7 +4354,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4278
4354
|
DataPanel.displayName = "DataPanel";
|
|
4279
4355
|
|
|
4280
4356
|
// src/components/Skeleton.tsx
|
|
4281
|
-
import * as
|
|
4357
|
+
import * as React26 from "react";
|
|
4282
4358
|
import { cva as cva6 } from "class-variance-authority";
|
|
4283
4359
|
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
4284
4360
|
var skeletonVariants = cva6("rounded-md bg-muted", {
|
|
@@ -4296,7 +4372,7 @@ var skeletonVariants = cva6("rounded-md bg-muted", {
|
|
|
4296
4372
|
variant: "default"
|
|
4297
4373
|
}
|
|
4298
4374
|
});
|
|
4299
|
-
var Skeleton =
|
|
4375
|
+
var Skeleton = React26.forwardRef(
|
|
4300
4376
|
({ className, variant, animation = "pulse", ...props }, ref) => {
|
|
4301
4377
|
const animationClass = animation === "pulse" ? "animate-pulse" : animation === "shimmer" ? "animate-shimmer" : "";
|
|
4302
4378
|
return /* @__PURE__ */ jsx26(
|
|
@@ -4312,7 +4388,7 @@ var Skeleton = React25.forwardRef(
|
|
|
4312
4388
|
Skeleton.displayName = "Skeleton";
|
|
4313
4389
|
|
|
4314
4390
|
// src/components/Spinner.tsx
|
|
4315
|
-
import * as
|
|
4391
|
+
import * as React27 from "react";
|
|
4316
4392
|
import { cva as cva7 } from "class-variance-authority";
|
|
4317
4393
|
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4318
4394
|
var spinnerVariants = cva7("animate-spin text-current", {
|
|
@@ -4328,7 +4404,7 @@ var spinnerVariants = cva7("animate-spin text-current", {
|
|
|
4328
4404
|
size: "md"
|
|
4329
4405
|
}
|
|
4330
4406
|
});
|
|
4331
|
-
var Spinner =
|
|
4407
|
+
var Spinner = React27.forwardRef(
|
|
4332
4408
|
({ className, size, label = "Loading...", ...props }, ref) => {
|
|
4333
4409
|
return /* @__PURE__ */ jsxs18(
|
|
4334
4410
|
"svg",
|
|
@@ -4370,7 +4446,7 @@ var Spinner = React26.forwardRef(
|
|
|
4370
4446
|
Spinner.displayName = "Spinner";
|
|
4371
4447
|
|
|
4372
4448
|
// src/components/LoadingLogo.tsx
|
|
4373
|
-
import * as
|
|
4449
|
+
import * as React28 from "react";
|
|
4374
4450
|
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4375
4451
|
var logoPaths = [
|
|
4376
4452
|
"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",
|
|
@@ -4393,7 +4469,7 @@ var colors = {
|
|
|
4393
4469
|
stroke: "#ffffff"
|
|
4394
4470
|
}
|
|
4395
4471
|
};
|
|
4396
|
-
var LoadingLogo =
|
|
4472
|
+
var LoadingLogo = React28.forwardRef(
|
|
4397
4473
|
({ width = 40, height = 40, loading = false, variant = "dark", className, ...props }, ref) => {
|
|
4398
4474
|
const currentColors = colors[variant];
|
|
4399
4475
|
const fillColor = loading ? currentColors.fillLoading : currentColors.fill;
|
|
@@ -4442,7 +4518,7 @@ var LoadingLogo = React27.forwardRef(
|
|
|
4442
4518
|
LoadingLogo.displayName = "LoadingLogo";
|
|
4443
4519
|
|
|
4444
4520
|
// src/components/ProgressBar.tsx
|
|
4445
|
-
import * as
|
|
4521
|
+
import * as React29 from "react";
|
|
4446
4522
|
import { cva as cva8 } from "class-variance-authority";
|
|
4447
4523
|
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4448
4524
|
var progressBarVariants = cva8("w-full overflow-hidden rounded-full bg-muted", {
|
|
@@ -4470,7 +4546,7 @@ var progressFillVariants = cva8("h-full rounded-full transition-all duration-300
|
|
|
4470
4546
|
variant: "default"
|
|
4471
4547
|
}
|
|
4472
4548
|
});
|
|
4473
|
-
var ProgressBar =
|
|
4549
|
+
var ProgressBar = React29.forwardRef(
|
|
4474
4550
|
({ className, size, variant, value, max = 100, label = "Progress", showValue = false, ...props }, ref) => {
|
|
4475
4551
|
const isIndeterminate = value === void 0;
|
|
4476
4552
|
const clampedValue = isIndeterminate ? 0 : Math.min(Math.max(0, value), max);
|
|
@@ -4509,11 +4585,11 @@ var ProgressBar = React28.forwardRef(
|
|
|
4509
4585
|
ProgressBar.displayName = "ProgressBar";
|
|
4510
4586
|
|
|
4511
4587
|
// src/components/LoadingOverlay.tsx
|
|
4512
|
-
import * as
|
|
4513
|
-
import { Fragment as
|
|
4588
|
+
import * as React30 from "react";
|
|
4589
|
+
import { Fragment as Fragment7, jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4514
4590
|
var spinnerSizeMap = { sm: "sm", md: "md", lg: "lg", xl: "xl" };
|
|
4515
4591
|
var logoSizeMap = { sm: 32, md: 40, lg: 56, xl: 80 };
|
|
4516
|
-
var LoadingOverlay =
|
|
4592
|
+
var LoadingOverlay = React30.forwardRef(
|
|
4517
4593
|
({
|
|
4518
4594
|
loading = true,
|
|
4519
4595
|
variant = "spinner",
|
|
@@ -4528,8 +4604,8 @@ var LoadingOverlay = React29.forwardRef(
|
|
|
4528
4604
|
children,
|
|
4529
4605
|
...props
|
|
4530
4606
|
}, ref) => {
|
|
4531
|
-
const [visible, setVisible] =
|
|
4532
|
-
|
|
4607
|
+
const [visible, setVisible] = React30.useState(delay === 0 && loading);
|
|
4608
|
+
React30.useEffect(() => {
|
|
4533
4609
|
if (!loading) {
|
|
4534
4610
|
setVisible(false);
|
|
4535
4611
|
return;
|
|
@@ -4541,10 +4617,16 @@ var LoadingOverlay = React29.forwardRef(
|
|
|
4541
4617
|
const timer = setTimeout(() => setVisible(true), delay);
|
|
4542
4618
|
return () => clearTimeout(timer);
|
|
4543
4619
|
}, [loading, delay]);
|
|
4620
|
+
if (!visible && mode === "inline") {
|
|
4621
|
+
return null;
|
|
4622
|
+
}
|
|
4544
4623
|
if (!visible) {
|
|
4545
|
-
return
|
|
4624
|
+
return /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
4625
|
+
children,
|
|
4626
|
+
null
|
|
4627
|
+
] });
|
|
4546
4628
|
}
|
|
4547
|
-
const indicator = /* @__PURE__ */ jsxs21(
|
|
4629
|
+
const indicator = /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
4548
4630
|
variant === "spinner" && /* @__PURE__ */ jsx30(Spinner, { size: spinnerSizeMap[size] }),
|
|
4549
4631
|
variant === "logo" && /* @__PURE__ */ jsx30(LoadingLogo, { loading: true, width: logoSizeMap[size], height: logoSizeMap[size] }),
|
|
4550
4632
|
variant === "progress" && /* @__PURE__ */ jsx30(ProgressBar, { value: progress, className: "w-48 max-w-full" }),
|
|
@@ -4572,7 +4654,7 @@ var LoadingOverlay = React29.forwardRef(
|
|
|
4572
4654
|
}
|
|
4573
4655
|
const bgClass = opaque ? "bg-background" : mode === "fullscreen" ? "bg-background/80" : "bg-background/60";
|
|
4574
4656
|
const positionClass = mode === "fullscreen" ? "fixed inset-0 z-50" : "absolute inset-0 z-10";
|
|
4575
|
-
return /* @__PURE__ */ jsxs21(
|
|
4657
|
+
return /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
4576
4658
|
children,
|
|
4577
4659
|
/* @__PURE__ */ jsx30(
|
|
4578
4660
|
"div",
|
|
@@ -4597,9 +4679,9 @@ var LoadingOverlay = React29.forwardRef(
|
|
|
4597
4679
|
LoadingOverlay.displayName = "LoadingOverlay";
|
|
4598
4680
|
|
|
4599
4681
|
// src/components/LoadingPage.tsx
|
|
4600
|
-
import * as
|
|
4682
|
+
import * as React31 from "react";
|
|
4601
4683
|
import { jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4602
|
-
var LoadingPage =
|
|
4684
|
+
var LoadingPage = React31.forwardRef(
|
|
4603
4685
|
({
|
|
4604
4686
|
loading = true,
|
|
4605
4687
|
message,
|
|
@@ -4610,8 +4692,8 @@ var LoadingPage = React30.forwardRef(
|
|
|
4610
4692
|
className,
|
|
4611
4693
|
...props
|
|
4612
4694
|
}, ref) => {
|
|
4613
|
-
const [visible, setVisible] =
|
|
4614
|
-
|
|
4695
|
+
const [visible, setVisible] = React31.useState(delay === 0 && loading);
|
|
4696
|
+
React31.useEffect(() => {
|
|
4615
4697
|
if (!loading) {
|
|
4616
4698
|
setVisible(false);
|
|
4617
4699
|
return;
|
|
@@ -4651,9 +4733,9 @@ var LoadingPage = React30.forwardRef(
|
|
|
4651
4733
|
LoadingPage.displayName = "LoadingPage";
|
|
4652
4734
|
|
|
4653
4735
|
// src/components/LoadingSection.tsx
|
|
4654
|
-
import * as
|
|
4736
|
+
import * as React32 from "react";
|
|
4655
4737
|
import { jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4656
|
-
var LoadingSection =
|
|
4738
|
+
var LoadingSection = React32.forwardRef(
|
|
4657
4739
|
({
|
|
4658
4740
|
loading = false,
|
|
4659
4741
|
variant = "spinner",
|
|
@@ -4695,9 +4777,9 @@ var LoadingSection = React31.forwardRef(
|
|
|
4695
4777
|
LoadingSection.displayName = "LoadingSection";
|
|
4696
4778
|
|
|
4697
4779
|
// src/components/LiveRegion.tsx
|
|
4698
|
-
import * as
|
|
4780
|
+
import * as React33 from "react";
|
|
4699
4781
|
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
4700
|
-
var LiveRegion =
|
|
4782
|
+
var LiveRegion = React33.forwardRef(
|
|
4701
4783
|
({ message, politeness = "polite", atomic = true, visuallyHidden = true, className, children }, ref) => {
|
|
4702
4784
|
return /* @__PURE__ */ jsx33(
|
|
4703
4785
|
"div",
|
|
@@ -4718,9 +4800,9 @@ var LiveRegion = React32.forwardRef(
|
|
|
4718
4800
|
LiveRegion.displayName = "LiveRegion";
|
|
4719
4801
|
|
|
4720
4802
|
// src/components/SkipLink.tsx
|
|
4721
|
-
import * as
|
|
4803
|
+
import * as React34 from "react";
|
|
4722
4804
|
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
4723
|
-
var SkipLink =
|
|
4805
|
+
var SkipLink = React34.forwardRef(
|
|
4724
4806
|
({ targetId, className, children = "Skip to main content", onClick, ...props }, ref) => {
|
|
4725
4807
|
const handleClick = (e) => {
|
|
4726
4808
|
e.preventDefault();
|
|
@@ -4754,11 +4836,11 @@ var SkipLink = React33.forwardRef(
|
|
|
4754
4836
|
SkipLink.displayName = "SkipLink";
|
|
4755
4837
|
|
|
4756
4838
|
// src/hooks/useFocusRef.ts
|
|
4757
|
-
import { useRef as
|
|
4839
|
+
import { useRef as useRef11, useEffect as useEffect13 } from "react";
|
|
4758
4840
|
function useFocusRef(options = {}) {
|
|
4759
4841
|
const { focusOnMount = false, preventScroll = false, delay = 0 } = options;
|
|
4760
|
-
const ref =
|
|
4761
|
-
|
|
4842
|
+
const ref = useRef11(null);
|
|
4843
|
+
useEffect13(() => {
|
|
4762
4844
|
if (!focusOnMount) return;
|
|
4763
4845
|
const focus = () => {
|
|
4764
4846
|
if (ref.current && typeof ref.current.focus === "function") {
|
|
@@ -4777,10 +4859,10 @@ function useFocusRef(options = {}) {
|
|
|
4777
4859
|
}
|
|
4778
4860
|
|
|
4779
4861
|
// src/hooks/useReducedMotion.ts
|
|
4780
|
-
import { useState as useState13, useEffect as
|
|
4862
|
+
import { useState as useState13, useEffect as useEffect14 } from "react";
|
|
4781
4863
|
function useReducedMotion() {
|
|
4782
4864
|
const [reducedMotion, setReducedMotion] = useState13(false);
|
|
4783
|
-
|
|
4865
|
+
useEffect14(() => {
|
|
4784
4866
|
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
4785
4867
|
setReducedMotion(mediaQuery.matches);
|
|
4786
4868
|
const handleChange = (event) => {
|
|
@@ -4795,8 +4877,8 @@ function useReducedMotion() {
|
|
|
4795
4877
|
}
|
|
4796
4878
|
|
|
4797
4879
|
// src/hooks/useArrowNavigation.ts
|
|
4798
|
-
import { useCallback as useCallback5, useRef as
|
|
4799
|
-
var DEFAULT_SELECTOR = '[role="menuitem"], [role="option"], [role="tab"], button, a, [tabindex]:not([tabindex="-1"])';
|
|
4880
|
+
import { useCallback as useCallback5, useRef as useRef12, useState as useState14 } from "react";
|
|
4881
|
+
var DEFAULT_SELECTOR = '[data-arrow-nav-item], [role="menuitem"], [role="option"], [role="tab"], button, a, [tabindex]:not([tabindex="-1"])';
|
|
4800
4882
|
function useArrowNavigation(options = {}) {
|
|
4801
4883
|
const {
|
|
4802
4884
|
orientation = "vertical",
|
|
@@ -4804,8 +4886,8 @@ function useArrowNavigation(options = {}) {
|
|
|
4804
4886
|
itemSelector = DEFAULT_SELECTOR,
|
|
4805
4887
|
onFocusChange
|
|
4806
4888
|
} = options;
|
|
4807
|
-
const containerRef =
|
|
4808
|
-
const focusedIndexRef =
|
|
4889
|
+
const containerRef = useRef12(null);
|
|
4890
|
+
const focusedIndexRef = useRef12(-1);
|
|
4809
4891
|
const [focusedIndex, setFocusedIndexState] = useState14(-1);
|
|
4810
4892
|
const setFocusedIndex = useCallback5((index) => {
|
|
4811
4893
|
focusedIndexRef.current = index;
|
|
@@ -4902,6 +4984,7 @@ function useArrowNavigation(options = {}) {
|
|
|
4902
4984
|
const tabStopIndex = focusedIndex === -1 ? 0 : focusedIndex;
|
|
4903
4985
|
const getItemProps = useCallback5(
|
|
4904
4986
|
(index) => ({
|
|
4987
|
+
"data-arrow-nav-item": true,
|
|
4905
4988
|
tabIndex: index === tabStopIndex ? 0 : -1,
|
|
4906
4989
|
onFocus: () => {
|
|
4907
4990
|
setFocusedIndex(index);
|
|
@@ -4918,13 +5001,13 @@ function useArrowNavigation(options = {}) {
|
|
|
4918
5001
|
}
|
|
4919
5002
|
|
|
4920
5003
|
// src/hooks/useRovingTabindex.ts
|
|
4921
|
-
import { useState as useState15, useCallback as useCallback6, useRef as
|
|
5004
|
+
import { useState as useState15, useCallback as useCallback6, useRef as useRef13 } from "react";
|
|
4922
5005
|
var DEFAULT_SELECTOR2 = "[data-roving-tabindex-item]";
|
|
4923
5006
|
function useRovingTabindex(options = {}) {
|
|
4924
5007
|
const { loop = true, itemSelector = DEFAULT_SELECTOR2, initialIndex = 0, onIndexChange } = options;
|
|
4925
5008
|
const [activeIndex, setActiveIndex] = useState15(initialIndex);
|
|
4926
|
-
const containerRef =
|
|
4927
|
-
const itemsRef =
|
|
5009
|
+
const containerRef = useRef13(null);
|
|
5010
|
+
const itemsRef = useRef13(/* @__PURE__ */ new Map());
|
|
4928
5011
|
const getItems = useCallback6(() => {
|
|
4929
5012
|
if (!containerRef.current) {
|
|
4930
5013
|
return Array.from(itemsRef.current.values());
|
|
@@ -4990,7 +5073,7 @@ function useRovingTabindex(options = {}) {
|
|
|
4990
5073
|
onKeyDown: handleKeyDown
|
|
4991
5074
|
};
|
|
4992
5075
|
const getItemProps = useCallback6(
|
|
4993
|
-
(index) => ({
|
|
5076
|
+
(index, handlers = {}) => ({
|
|
4994
5077
|
"data-roving-tabindex-item": true,
|
|
4995
5078
|
tabIndex: index === activeIndex ? 0 : -1,
|
|
4996
5079
|
ref: (node) => {
|
|
@@ -5000,11 +5083,13 @@ function useRovingTabindex(options = {}) {
|
|
|
5000
5083
|
itemsRef.current.delete(index);
|
|
5001
5084
|
}
|
|
5002
5085
|
},
|
|
5003
|
-
onClick: () => {
|
|
5086
|
+
onClick: (event) => {
|
|
5087
|
+
handlers.onClick?.(event);
|
|
5004
5088
|
setActiveIndex(index);
|
|
5005
5089
|
onIndexChange?.(index);
|
|
5006
5090
|
},
|
|
5007
|
-
onFocus: () => {
|
|
5091
|
+
onFocus: (event) => {
|
|
5092
|
+
handlers.onFocus?.(event);
|
|
5008
5093
|
if (activeIndex !== index) {
|
|
5009
5094
|
setActiveIndex(index);
|
|
5010
5095
|
onIndexChange?.(index);
|
|
@@ -5026,21 +5111,21 @@ function useRovingTabindex(options = {}) {
|
|
|
5026
5111
|
}
|
|
5027
5112
|
|
|
5028
5113
|
// src/hooks/useClickOutside.ts
|
|
5029
|
-
import * as
|
|
5114
|
+
import * as React35 from "react";
|
|
5030
5115
|
function useClickOutside(ref, callback, options) {
|
|
5031
5116
|
const {
|
|
5032
5117
|
enabled = true,
|
|
5033
5118
|
events = ["mousedown", "touchstart"],
|
|
5034
5119
|
ignoreElements = []
|
|
5035
5120
|
} = options ?? {};
|
|
5036
|
-
const callbackRef =
|
|
5037
|
-
const ignoreElementsRef =
|
|
5038
|
-
|
|
5121
|
+
const callbackRef = React35.useRef(callback);
|
|
5122
|
+
const ignoreElementsRef = React35.useRef(ignoreElements);
|
|
5123
|
+
React35.useEffect(() => {
|
|
5039
5124
|
callbackRef.current = callback;
|
|
5040
5125
|
ignoreElementsRef.current = ignoreElements;
|
|
5041
5126
|
}, [callback, ignoreElements]);
|
|
5042
5127
|
const eventsKey = events.join(",");
|
|
5043
|
-
|
|
5128
|
+
React35.useEffect(() => {
|
|
5044
5129
|
if (!enabled) return;
|
|
5045
5130
|
const handleEvent = (event) => {
|
|
5046
5131
|
const target = event.target;
|
|
@@ -5123,6 +5208,7 @@ export {
|
|
|
5123
5208
|
badgeVariants,
|
|
5124
5209
|
buttonVariants,
|
|
5125
5210
|
cn,
|
|
5211
|
+
labelVariants,
|
|
5126
5212
|
pageHeaderActionsVariants,
|
|
5127
5213
|
pageHeaderContainerVariants,
|
|
5128
5214
|
pageHeaderSubtitleVariants,
|