@classic-homes/theme-react 0.4.1 → 0.4.2
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.d.mts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +177 -82
- package/dist/index.mjs +177 -83
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ export { CardConfig, DataPanelAction, DataPanelState, PanelConstraints, PanelEdg
|
|
|
10
10
|
import { ClassValue } from 'clsx';
|
|
11
11
|
|
|
12
12
|
declare const buttonVariants: (props?: ({
|
|
13
|
-
variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" |
|
|
13
|
+
variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
|
|
14
14
|
size?: "default" | "sm" | "md" | "lg" | "icon" | null | undefined;
|
|
15
15
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
16
16
|
/** Base button props without size */
|
|
@@ -89,8 +89,9 @@ declare const Label: React$1.ForwardRefExoticComponent<Omit<LabelPrimitive.Label
|
|
|
89
89
|
declare const badgeVariants: (props?: ({
|
|
90
90
|
variant?: "default" | "secondary" | "destructive" | "outline" | "success" | "warning" | "info" | null | undefined;
|
|
91
91
|
size?: "default" | "sm" | "dot" | null | undefined;
|
|
92
|
+
clickable?: boolean | null | undefined;
|
|
92
93
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
93
|
-
interface BadgeProps extends React$1.HTMLAttributes<HTMLElement>, VariantProps<typeof badgeVariants> {
|
|
94
|
+
interface BadgeProps extends React$1.HTMLAttributes<HTMLElement>, Omit<VariantProps<typeof badgeVariants>, 'clickable'> {
|
|
94
95
|
/** When true, adds role="status" and aria-live="polite" for dynamic content announcements */
|
|
95
96
|
live?: boolean;
|
|
96
97
|
/** When true, renders the badge as an interactive button */
|
|
@@ -163,11 +164,11 @@ declare const DialogTrigger: React$1.ForwardRefExoticComponent<DialogPrimitive.D
|
|
|
163
164
|
declare const DialogPortal: React$1.FC<DialogPrimitive.DialogPortalProps>;
|
|
164
165
|
declare const DialogClose: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
165
166
|
declare const dialogSizeClasses: {
|
|
166
|
-
readonly sm: "max-w-sm";
|
|
167
|
-
readonly md: "max-w-lg";
|
|
168
|
-
readonly lg: "max-w-xl";
|
|
169
|
-
readonly xl: "max-w-2xl";
|
|
170
|
-
readonly '2xl': "max-w-3xl";
|
|
167
|
+
readonly sm: "max-w-[min(theme(maxWidth.sm),calc(100vw-2rem))]";
|
|
168
|
+
readonly md: "max-w-[min(theme(maxWidth.lg),calc(100vw-2rem))]";
|
|
169
|
+
readonly lg: "max-w-[min(theme(maxWidth.xl),calc(100vw-2rem))]";
|
|
170
|
+
readonly xl: "max-w-[min(theme(maxWidth.2xl),calc(100vw-2rem))]";
|
|
171
|
+
readonly '2xl': "max-w-[min(theme(maxWidth.3xl),calc(100vw-2rem))]";
|
|
171
172
|
readonly full: "max-w-[calc(100vw-2rem)]";
|
|
172
173
|
};
|
|
173
174
|
type DialogSize = keyof typeof dialogSizeClasses;
|
|
@@ -815,7 +816,7 @@ declare const DataPanelTab: React$1.ForwardRefExoticComponent<DataPanelTabProps
|
|
|
815
816
|
declare const DataPanel: React$1.ForwardRefExoticComponent<DataPanelProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
816
817
|
|
|
817
818
|
declare const skeletonVariants: (props?: ({
|
|
818
|
-
variant?: "
|
|
819
|
+
variant?: "text" | "default" | "title" | "button" | "card" | "avatar" | null | undefined;
|
|
819
820
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
820
821
|
interface SkeletonProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof skeletonVariants> {
|
|
821
822
|
/** Animation style for the skeleton */
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { CardConfig, DataPanelAction, DataPanelState, PanelConstraints, PanelEdg
|
|
|
10
10
|
import { ClassValue } from 'clsx';
|
|
11
11
|
|
|
12
12
|
declare const buttonVariants: (props?: ({
|
|
13
|
-
variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" |
|
|
13
|
+
variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
|
|
14
14
|
size?: "default" | "sm" | "md" | "lg" | "icon" | null | undefined;
|
|
15
15
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
16
16
|
/** Base button props without size */
|
|
@@ -89,8 +89,9 @@ declare const Label: React$1.ForwardRefExoticComponent<Omit<LabelPrimitive.Label
|
|
|
89
89
|
declare const badgeVariants: (props?: ({
|
|
90
90
|
variant?: "default" | "secondary" | "destructive" | "outline" | "success" | "warning" | "info" | null | undefined;
|
|
91
91
|
size?: "default" | "sm" | "dot" | null | undefined;
|
|
92
|
+
clickable?: boolean | null | undefined;
|
|
92
93
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
93
|
-
interface BadgeProps extends React$1.HTMLAttributes<HTMLElement>, VariantProps<typeof badgeVariants> {
|
|
94
|
+
interface BadgeProps extends React$1.HTMLAttributes<HTMLElement>, Omit<VariantProps<typeof badgeVariants>, 'clickable'> {
|
|
94
95
|
/** When true, adds role="status" and aria-live="polite" for dynamic content announcements */
|
|
95
96
|
live?: boolean;
|
|
96
97
|
/** When true, renders the badge as an interactive button */
|
|
@@ -163,11 +164,11 @@ declare const DialogTrigger: React$1.ForwardRefExoticComponent<DialogPrimitive.D
|
|
|
163
164
|
declare const DialogPortal: React$1.FC<DialogPrimitive.DialogPortalProps>;
|
|
164
165
|
declare const DialogClose: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
165
166
|
declare const dialogSizeClasses: {
|
|
166
|
-
readonly sm: "max-w-sm";
|
|
167
|
-
readonly md: "max-w-lg";
|
|
168
|
-
readonly lg: "max-w-xl";
|
|
169
|
-
readonly xl: "max-w-2xl";
|
|
170
|
-
readonly '2xl': "max-w-3xl";
|
|
167
|
+
readonly sm: "max-w-[min(theme(maxWidth.sm),calc(100vw-2rem))]";
|
|
168
|
+
readonly md: "max-w-[min(theme(maxWidth.lg),calc(100vw-2rem))]";
|
|
169
|
+
readonly lg: "max-w-[min(theme(maxWidth.xl),calc(100vw-2rem))]";
|
|
170
|
+
readonly xl: "max-w-[min(theme(maxWidth.2xl),calc(100vw-2rem))]";
|
|
171
|
+
readonly '2xl': "max-w-[min(theme(maxWidth.3xl),calc(100vw-2rem))]";
|
|
171
172
|
readonly full: "max-w-[calc(100vw-2rem)]";
|
|
172
173
|
};
|
|
173
174
|
type DialogSize = keyof typeof dialogSizeClasses;
|
|
@@ -815,7 +816,7 @@ declare const DataPanelTab: React$1.ForwardRefExoticComponent<DataPanelTabProps
|
|
|
815
816
|
declare const DataPanel: React$1.ForwardRefExoticComponent<DataPanelProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
816
817
|
|
|
817
818
|
declare const skeletonVariants: (props?: ({
|
|
818
|
-
variant?: "
|
|
819
|
+
variant?: "text" | "default" | "title" | "button" | "card" | "avatar" | null | undefined;
|
|
819
820
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
820
821
|
interface SkeletonProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof skeletonVariants> {
|
|
821
822
|
/** Animation style for the skeleton */
|
package/dist/index.js
CHANGED
|
@@ -115,8 +115,15 @@ var import_class_variance_authority = require("class-variance-authority");
|
|
|
115
115
|
// src/lib/utils.ts
|
|
116
116
|
var import_clsx = require("clsx");
|
|
117
117
|
var import_tailwind_merge = require("tailwind-merge");
|
|
118
|
+
var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
|
|
119
|
+
extend: {
|
|
120
|
+
classGroups: {
|
|
121
|
+
"font-size": [{ text: ["h1", "h2", "h3", "h4", "h5", "h6"] }]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
118
125
|
function cn(...inputs) {
|
|
119
|
-
return
|
|
126
|
+
return twMerge((0, import_clsx.clsx)(inputs));
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
// src/components/Button.tsx
|
|
@@ -227,7 +234,7 @@ var Input = React3.forwardRef(
|
|
|
227
234
|
"aria-describedby": ariaDescribedBy,
|
|
228
235
|
required,
|
|
229
236
|
className: cn(
|
|
230
|
-
"flex h-10 w-full rounded-md border border-input bg-background text-foreground px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
237
|
+
"flex h-10 w-full rounded-md border border-input bg-background text-foreground px-3 py-2 text-sm max-sm:text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
231
238
|
ariaInvalid === true || ariaInvalid === "true" ? "border-destructive focus-visible:ring-destructive" : "",
|
|
232
239
|
className
|
|
233
240
|
),
|
|
@@ -262,18 +269,18 @@ function useAnnounce(defaultOptions) {
|
|
|
262
269
|
if (clearTimeoutRef.current) {
|
|
263
270
|
clearTimeout(clearTimeoutRef.current);
|
|
264
271
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
clearTimeoutRef.current = setTimeout(() => {
|
|
272
|
+
setPoliteness(options?.politeness ?? defaultOptions?.politeness ?? "polite");
|
|
273
|
+
setMessage("");
|
|
274
|
+
clearTimeoutRef.current = setTimeout(() => {
|
|
275
|
+
setMessage(newMessage);
|
|
276
|
+
const delay = options?.clearDelay ?? defaultOptions?.clearDelay ?? 1e3;
|
|
277
|
+
clearTimeoutRef.current = delay > 0 ? setTimeout(() => {
|
|
272
278
|
setMessage("");
|
|
273
|
-
|
|
274
|
-
|
|
279
|
+
clearTimeoutRef.current = null;
|
|
280
|
+
}, delay) : null;
|
|
281
|
+
}, 0);
|
|
275
282
|
},
|
|
276
|
-
[defaultOptions?.clearDelay]
|
|
283
|
+
[defaultOptions?.clearDelay, defaultOptions?.politeness]
|
|
277
284
|
);
|
|
278
285
|
React4.useEffect(() => {
|
|
279
286
|
return () => {
|
|
@@ -365,7 +372,7 @@ var PasswordInput = React5.forwardRef(
|
|
|
365
372
|
"aria-label": ariaLabel,
|
|
366
373
|
"aria-labelledby": ariaLabelledBy,
|
|
367
374
|
className: cn(
|
|
368
|
-
"flex h-10 w-full rounded-md border border-input bg-background text-foreground px-3 py-2 pr-10 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
375
|
+
"flex h-10 w-full rounded-md border border-input bg-background text-foreground px-3 py-2 pr-10 text-sm max-sm:text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
369
376
|
className
|
|
370
377
|
),
|
|
371
378
|
disabled,
|
|
@@ -411,23 +418,43 @@ var badgeVariants = (0, import_class_variance_authority3.cva)(
|
|
|
411
418
|
{
|
|
412
419
|
variants: {
|
|
413
420
|
variant: {
|
|
414
|
-
default: "border-transparent bg-primary text-primary-foreground
|
|
415
|
-
secondary: "border-transparent bg-secondary text-secondary-foreground
|
|
416
|
-
destructive: "border-transparent bg-destructive text-destructive-foreground
|
|
417
|
-
outline: "text-foreground
|
|
418
|
-
success: "border-transparent bg-success text-success-foreground
|
|
419
|
-
warning: "border-transparent bg-warning text-warning-foreground
|
|
420
|
-
info: "border-transparent bg-info text-info-foreground
|
|
421
|
+
default: "border-transparent bg-primary text-primary-foreground",
|
|
422
|
+
secondary: "border-transparent bg-secondary text-secondary-foreground",
|
|
423
|
+
destructive: "border-transparent bg-destructive text-destructive-foreground",
|
|
424
|
+
outline: "text-foreground",
|
|
425
|
+
success: "border-transparent bg-success text-success-foreground",
|
|
426
|
+
warning: "border-transparent bg-warning text-warning-foreground",
|
|
427
|
+
info: "border-transparent bg-info text-info-foreground"
|
|
421
428
|
},
|
|
422
429
|
size: {
|
|
423
430
|
default: "px-2 py-0.5 text-xs",
|
|
424
431
|
sm: "px-1.5 py-0.5 text-xs",
|
|
425
432
|
dot: "h-5 w-5 p-0 text-xs"
|
|
433
|
+
},
|
|
434
|
+
// Hover feedback only on interactive badges: a static badge that darkens
|
|
435
|
+
// under the pointer reads as clickable when it is not (matches Svelte)
|
|
436
|
+
clickable: {
|
|
437
|
+
true: "cursor-pointer focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
438
|
+
false: ""
|
|
426
439
|
}
|
|
427
440
|
},
|
|
441
|
+
compoundVariants: [
|
|
442
|
+
{ variant: "default", clickable: true, class: "hover:bg-primary-hover" },
|
|
443
|
+
{ variant: "secondary", clickable: true, class: "hover:bg-secondary-hover" },
|
|
444
|
+
{ variant: "destructive", clickable: true, class: "hover:bg-destructive-hover" },
|
|
445
|
+
{
|
|
446
|
+
variant: "outline",
|
|
447
|
+
clickable: true,
|
|
448
|
+
class: "hover:bg-accent-hover hover:text-accent-foreground"
|
|
449
|
+
},
|
|
450
|
+
{ variant: "success", clickable: true, class: "hover:bg-success/80" },
|
|
451
|
+
{ variant: "warning", clickable: true, class: "hover:bg-warning/80" },
|
|
452
|
+
{ variant: "info", clickable: true, class: "hover:bg-info/80" }
|
|
453
|
+
],
|
|
428
454
|
defaultVariants: {
|
|
429
455
|
variant: "default",
|
|
430
|
-
size: "default"
|
|
456
|
+
size: "default",
|
|
457
|
+
clickable: false
|
|
431
458
|
}
|
|
432
459
|
}
|
|
433
460
|
);
|
|
@@ -441,11 +468,7 @@ var Badge = React7.forwardRef(
|
|
|
441
468
|
}
|
|
442
469
|
}
|
|
443
470
|
const isInteractive = clickable || !!onClick;
|
|
444
|
-
const classes = cn(
|
|
445
|
-
badgeVariants({ variant, size }),
|
|
446
|
-
isInteractive && "cursor-pointer focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
447
|
-
className
|
|
448
|
-
);
|
|
471
|
+
const classes = cn(badgeVariants({ variant, size, clickable: isInteractive }), className);
|
|
449
472
|
const sharedProps = {
|
|
450
473
|
role: live ? "status" : void 0,
|
|
451
474
|
"aria-live": live ? "polite" : void 0,
|
|
@@ -619,11 +642,11 @@ var DialogTrigger = DialogPrimitive.Trigger;
|
|
|
619
642
|
var DialogPortal = DialogPrimitive.Portal;
|
|
620
643
|
var DialogClose = DialogPrimitive.Close;
|
|
621
644
|
var dialogSizeClasses = {
|
|
622
|
-
sm: "max-w-sm",
|
|
623
|
-
md: "max-w-lg",
|
|
624
|
-
lg: "max-w-xl",
|
|
625
|
-
xl: "max-w-2xl",
|
|
626
|
-
"2xl": "max-w-3xl",
|
|
645
|
+
sm: "max-w-[min(theme(maxWidth.sm),calc(100vw-2rem))]",
|
|
646
|
+
md: "max-w-[min(theme(maxWidth.lg),calc(100vw-2rem))]",
|
|
647
|
+
lg: "max-w-[min(theme(maxWidth.xl),calc(100vw-2rem))]",
|
|
648
|
+
xl: "max-w-[min(theme(maxWidth.2xl),calc(100vw-2rem))]",
|
|
649
|
+
"2xl": "max-w-[min(theme(maxWidth.3xl),calc(100vw-2rem))]",
|
|
627
650
|
full: "max-w-[calc(100vw-2rem)]"
|
|
628
651
|
};
|
|
629
652
|
var DialogOverlay = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
@@ -1763,12 +1786,11 @@ function StudioCanvasItem({
|
|
|
1763
1786
|
select(false);
|
|
1764
1787
|
},
|
|
1765
1788
|
children: [
|
|
1766
|
-
|
|
1789
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1767
1790
|
"button",
|
|
1768
1791
|
{
|
|
1769
1792
|
type: "button",
|
|
1770
1793
|
className: "sr-only left-2 top-2 z-10 rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground focus:not-sr-only focus:absolute",
|
|
1771
|
-
onClick: () => select(true),
|
|
1772
1794
|
children: [
|
|
1773
1795
|
"Edit ",
|
|
1774
1796
|
label
|
|
@@ -2182,7 +2204,9 @@ function InsertPalette({
|
|
|
2182
2204
|
onOpenChange(false);
|
|
2183
2205
|
onSelect(item.id);
|
|
2184
2206
|
};
|
|
2185
|
-
const entries = () => Array.from(
|
|
2207
|
+
const entries = () => Array.from(
|
|
2208
|
+
listRef.current?.querySelectorAll("[data-palette-item]:not(:disabled)") ?? []
|
|
2209
|
+
);
|
|
2186
2210
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2187
2211
|
DialogContent,
|
|
2188
2212
|
{
|
|
@@ -2406,6 +2430,9 @@ var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
|
2406
2430
|
function layoutViewportWidth() {
|
|
2407
2431
|
return document.documentElement.clientWidth;
|
|
2408
2432
|
}
|
|
2433
|
+
function isSecondaryMouseButton(e) {
|
|
2434
|
+
return e.pointerType === "mouse" && e.button !== 0;
|
|
2435
|
+
}
|
|
2409
2436
|
var DropdownTrigger = DropdownMenuPrimitive2.Trigger;
|
|
2410
2437
|
var DropdownContent = DropdownMenuPrimitive2.Content;
|
|
2411
2438
|
var DropdownLabel = DropdownMenuPrimitive2.Label;
|
|
@@ -2622,7 +2649,8 @@ var DataPanelHeader = React24.forwardRef(
|
|
|
2622
2649
|
ref,
|
|
2623
2650
|
className: cn(
|
|
2624
2651
|
"flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 py-3",
|
|
2625
|
-
|
|
2652
|
+
// touch-none: a touch drag moves the panel instead of panning the page
|
|
2653
|
+
draggable && "cursor-grab active:cursor-grabbing touch-none",
|
|
2626
2654
|
className
|
|
2627
2655
|
),
|
|
2628
2656
|
"data-panel-header": true,
|
|
@@ -2648,6 +2676,7 @@ var DataPanelHeader = React24.forwardRef(
|
|
|
2648
2676
|
},
|
|
2649
2677
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
2650
2678
|
"aria-expanded": isExpanded,
|
|
2679
|
+
"data-panel-collapse": true,
|
|
2651
2680
|
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2652
2681
|
"span",
|
|
2653
2682
|
{
|
|
@@ -2740,11 +2769,16 @@ function DataPanelCardHeader({
|
|
|
2740
2769
|
onToggleExpand,
|
|
2741
2770
|
onClose
|
|
2742
2771
|
}) {
|
|
2772
|
+
const onToggleKeyDown = (e) => {
|
|
2773
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
2774
|
+
e.preventDefault();
|
|
2775
|
+
onToggleExpand();
|
|
2776
|
+
};
|
|
2743
2777
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
2744
2778
|
"div",
|
|
2745
2779
|
{
|
|
2746
2780
|
"data-panel-header": true,
|
|
2747
|
-
className: "relative flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 pt-5 pb-3 cursor-pointer",
|
|
2781
|
+
className: "relative flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 pt-5 pb-3 cursor-pointer touch-none",
|
|
2748
2782
|
onPointerDown: onHeaderPointerDown,
|
|
2749
2783
|
children: [
|
|
2750
2784
|
showDragHandle && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
@@ -2756,7 +2790,7 @@ function DataPanelCardHeader({
|
|
|
2756
2790
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
2757
2791
|
"aria-expanded": isExpanded,
|
|
2758
2792
|
onPointerDown: onHeaderPointerDown,
|
|
2759
|
-
onKeyDown:
|
|
2793
|
+
onKeyDown: onToggleKeyDown
|
|
2760
2794
|
}
|
|
2761
2795
|
),
|
|
2762
2796
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
@@ -2765,7 +2799,8 @@ function DataPanelCardHeader({
|
|
|
2765
2799
|
className: "flex-1 min-w-0",
|
|
2766
2800
|
role: "button",
|
|
2767
2801
|
tabIndex: 0,
|
|
2768
|
-
|
|
2802
|
+
"aria-expanded": isExpanded,
|
|
2803
|
+
onKeyDown: onToggleKeyDown,
|
|
2769
2804
|
children: headerContent ? headerContent : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
2770
2805
|
subtitle && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-sm text-muted-foreground truncate", children: subtitle }),
|
|
2771
2806
|
title && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h3", { id: titleId, className: "text-lg font-semibold truncate", children: title })
|
|
@@ -3196,7 +3231,7 @@ function ResizeHandles({
|
|
|
3196
3231
|
),
|
|
3197
3232
|
role: "slider",
|
|
3198
3233
|
tabIndex: 0,
|
|
3199
|
-
"aria-orientation":
|
|
3234
|
+
"aria-orientation": isHorizontal2 ? "vertical" : "horizontal",
|
|
3200
3235
|
"aria-label": `Resize panel from ${handle.replace("-", "")} ${isCorner ? "corner" : "edge"}`,
|
|
3201
3236
|
"aria-valuenow": getAriaValueNow(handle),
|
|
3202
3237
|
"aria-valuemin": min2,
|
|
@@ -3300,6 +3335,17 @@ var DataPanel = React24.forwardRef(
|
|
|
3300
3335
|
typeof window !== "undefined" ? window.innerHeight : 768
|
|
3301
3336
|
);
|
|
3302
3337
|
const isMobile = viewportWidth < 640;
|
|
3338
|
+
const cardDefaultLeftOffset = React24.useCallback(
|
|
3339
|
+
(width) => {
|
|
3340
|
+
const margin = resolvedCardConfig.horizontalMargin;
|
|
3341
|
+
if (resolvedCardConfig.align === "left") return margin;
|
|
3342
|
+
if (resolvedCardConfig.align === "right") {
|
|
3343
|
+
return Math.max(margin, viewportWidth - width - margin);
|
|
3344
|
+
}
|
|
3345
|
+
return Math.max(margin, (viewportWidth - width) / 2);
|
|
3346
|
+
},
|
|
3347
|
+
[viewportWidth, resolvedCardConfig.align, resolvedCardConfig.horizontalMargin]
|
|
3348
|
+
);
|
|
3303
3349
|
const [cardHorizontalPosition, setCardHorizontalPosition] = React24.useState(0);
|
|
3304
3350
|
const [cardExpandedHeight, setCardExpandedHeight] = React24.useState(0);
|
|
3305
3351
|
const [cardWidth, setCardWidth] = React24.useState(null);
|
|
@@ -3337,6 +3383,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3337
3383
|
});
|
|
3338
3384
|
const cardCurrentHeightRef = React24.useRef(import_data_panel_core.CARD_HEADER_HEIGHT);
|
|
3339
3385
|
const cardTopResizeStartRef = React24.useRef({ startY: 0, startHeight: 0 });
|
|
3386
|
+
const cardHeightUserSetRef = React24.useRef(false);
|
|
3340
3387
|
const cardWidthResizeStateRef = React24.useRef({
|
|
3341
3388
|
handle: null,
|
|
3342
3389
|
startX: 0,
|
|
@@ -3395,6 +3442,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3395
3442
|
debouncedSave();
|
|
3396
3443
|
}, [debouncedSave]);
|
|
3397
3444
|
const hasLoadedRef = React24.useRef(false);
|
|
3445
|
+
const hasPersistedPositionRef = React24.useRef(false);
|
|
3398
3446
|
React24.useEffect(() => {
|
|
3399
3447
|
if (!persistKey || hasLoadedRef.current) return;
|
|
3400
3448
|
hasLoadedRef.current = true;
|
|
@@ -3406,14 +3454,26 @@ var DataPanel = React24.forwardRef(
|
|
|
3406
3454
|
if (controlledEdge === void 0 && persisted.edge) setInternalEdge(persisted.edge);
|
|
3407
3455
|
if (controlledExpanded === void 0 && persisted.isExpanded !== void 0)
|
|
3408
3456
|
setInternalExpanded(persisted.isExpanded);
|
|
3409
|
-
if (persisted.detachedPosition)
|
|
3457
|
+
if (persisted.detachedPosition) {
|
|
3458
|
+
const size = persisted.detachedSize ?? import_data_panel_core.DEFAULT_PANEL_STATE.detachedSize;
|
|
3459
|
+
const { x: defaultX, y: defaultY } = import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition;
|
|
3460
|
+
hasPersistedPositionRef.current = persisted.detachedPosition.x !== defaultX || persisted.detachedPosition.y !== defaultY;
|
|
3461
|
+
setDetachedPosition(
|
|
3462
|
+
(0, import_data_panel_core.constrainPosition)(
|
|
3463
|
+
persisted.detachedPosition,
|
|
3464
|
+
size,
|
|
3465
|
+
layoutViewportWidth(),
|
|
3466
|
+
window.innerHeight
|
|
3467
|
+
)
|
|
3468
|
+
);
|
|
3469
|
+
}
|
|
3410
3470
|
if (persisted.detachedSize) setDetachedSize(persisted.detachedSize);
|
|
3411
3471
|
if (persisted.pinnedSize) setPinnedSize(persisted.pinnedSize);
|
|
3412
3472
|
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
3413
3473
|
}
|
|
3414
3474
|
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
3415
3475
|
React24.useEffect(() => {
|
|
3416
|
-
if (mode === "detached" && detachedPosition.x === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
3476
|
+
if (mode === "detached" && !hasPersistedPositionRef.current && detachedPosition.x === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
3417
3477
|
setDetachedPosition(
|
|
3418
3478
|
(0, import_data_panel_core.getInitialDetachedPosition)(detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
3419
3479
|
);
|
|
@@ -3428,12 +3488,17 @@ var DataPanel = React24.forwardRef(
|
|
|
3428
3488
|
const isDialog = open && (mode === "detached" || variant === "card" && isExpanded && isMobile);
|
|
3429
3489
|
const focusTrapRef = useFocusTrap({ active: isDialog });
|
|
3430
3490
|
useEscapeKey(
|
|
3431
|
-
() => {
|
|
3491
|
+
(event) => {
|
|
3492
|
+
if (event.defaultPrevented) return;
|
|
3493
|
+
event.preventDefault();
|
|
3432
3494
|
if (!disableClose) handleOpenChange(false);
|
|
3433
3495
|
},
|
|
3434
|
-
{ enabled: isDialog }
|
|
3496
|
+
{ enabled: isDialog, preventDefault: false }
|
|
3435
3497
|
);
|
|
3498
|
+
const panelElRef = React24.useRef(null);
|
|
3499
|
+
const tabRef = React24.useRef(null);
|
|
3436
3500
|
const setPanelRef = (node) => {
|
|
3501
|
+
panelElRef.current = node;
|
|
3437
3502
|
focusTrapRef.current = node;
|
|
3438
3503
|
if (typeof ref === "function") {
|
|
3439
3504
|
ref(node);
|
|
@@ -3459,18 +3524,29 @@ var DataPanel = React24.forwardRef(
|
|
|
3459
3524
|
},
|
|
3460
3525
|
[controlledEdge, onEdgeChange]
|
|
3461
3526
|
);
|
|
3527
|
+
const restoreFocusRef = React24.useRef(false);
|
|
3462
3528
|
const handleExpandedChange = React24.useCallback(
|
|
3463
3529
|
(newExpanded) => {
|
|
3530
|
+
const active = typeof document !== "undefined" ? document.activeElement : null;
|
|
3531
|
+
restoreFocusRef.current = newExpanded !== isExpanded && !!active && active !== document.body;
|
|
3464
3532
|
if (controlledExpanded === void 0) {
|
|
3465
3533
|
setInternalExpanded(newExpanded);
|
|
3466
3534
|
}
|
|
3467
3535
|
onExpandedChange?.(newExpanded);
|
|
3468
3536
|
},
|
|
3469
|
-
[controlledExpanded, onExpandedChange]
|
|
3537
|
+
[controlledExpanded, onExpandedChange, isExpanded]
|
|
3470
3538
|
);
|
|
3539
|
+
React24.useEffect(() => {
|
|
3540
|
+
if (!restoreFocusRef.current) return;
|
|
3541
|
+
restoreFocusRef.current = false;
|
|
3542
|
+
const active = document.activeElement;
|
|
3543
|
+
if (active && active !== document.body) return;
|
|
3544
|
+
const target = tabRef.current ? tabRef.current.querySelector("button") : panelElRef.current?.querySelector("[data-panel-collapse]");
|
|
3545
|
+
(target ?? panelElRef.current)?.focus();
|
|
3546
|
+
}, [isExpanded, mode]);
|
|
3471
3547
|
const handleToggleExpand = () => handleExpandedChange(!isExpanded);
|
|
3472
3548
|
const handleDragStart = (e) => {
|
|
3473
|
-
if (disableDrag) return;
|
|
3549
|
+
if (disableDrag || isSecondaryMouseButton(e)) return;
|
|
3474
3550
|
const target = e.target;
|
|
3475
3551
|
if (!target.closest("[data-panel-header]")) return;
|
|
3476
3552
|
const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
|
|
@@ -3575,7 +3651,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3575
3651
|
document.body.style.userSelect = "";
|
|
3576
3652
|
}, [isPinnedDragging]);
|
|
3577
3653
|
const handleResizeStart = (e, handle) => {
|
|
3578
|
-
if (disableResize) return;
|
|
3654
|
+
if (disableResize || isSecondaryMouseButton(e)) return;
|
|
3579
3655
|
e.preventDefault();
|
|
3580
3656
|
e.stopPropagation();
|
|
3581
3657
|
setIsResizing(true);
|
|
@@ -3638,7 +3714,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3638
3714
|
document.body.style.userSelect = "";
|
|
3639
3715
|
}, [isResizing]);
|
|
3640
3716
|
const handleCardHeaderPointerDown = (e) => {
|
|
3641
|
-
if (variant !== "card") return;
|
|
3717
|
+
if (variant !== "card" || isSecondaryMouseButton(e)) return;
|
|
3642
3718
|
const target = e.target;
|
|
3643
3719
|
const isDragHandle = target.closest("[data-card-drag-handle]");
|
|
3644
3720
|
if (!isDragHandle && target.closest("button")) return;
|
|
@@ -3677,14 +3753,12 @@ var DataPanel = React24.forwardRef(
|
|
|
3677
3753
|
}
|
|
3678
3754
|
if (isCardHorizontalDragging && !isMobile) {
|
|
3679
3755
|
const deltaX = currentPos.x - cardDragStateRef.current.startX;
|
|
3680
|
-
const
|
|
3756
|
+
const defaultWidth = Math.min(
|
|
3681
3757
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
3682
3758
|
resolvedCardConfig.maxWidth
|
|
3683
3759
|
);
|
|
3684
|
-
const
|
|
3685
|
-
|
|
3686
|
-
(viewportWidth - cw) / 2
|
|
3687
|
-
);
|
|
3760
|
+
const cw = cardWidth ?? defaultWidth;
|
|
3761
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultWidth);
|
|
3688
3762
|
const minOffset = -(defaultLeftOffset - resolvedCardConfig.horizontalMargin);
|
|
3689
3763
|
const maxOffset = viewportWidth - cw - defaultLeftOffset - resolvedCardConfig.horizontalMargin;
|
|
3690
3764
|
const nextPos = cardDragStateRef.current.startHorizontalPosition + deltaX;
|
|
@@ -3698,6 +3772,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3698
3772
|
viewportWidth,
|
|
3699
3773
|
viewportHeight,
|
|
3700
3774
|
cardExpandedHeight,
|
|
3775
|
+
cardWidth,
|
|
3776
|
+
cardDefaultLeftOffset,
|
|
3701
3777
|
resolvedCardConfig.horizontalMargin,
|
|
3702
3778
|
resolvedCardConfig.maxWidth
|
|
3703
3779
|
]
|
|
@@ -3751,6 +3827,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3751
3827
|
);
|
|
3752
3828
|
const handleCardResizeStart = (e) => {
|
|
3753
3829
|
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
3830
|
+
if (isSecondaryMouseButton(e)) return;
|
|
3754
3831
|
e.preventDefault();
|
|
3755
3832
|
e.stopPropagation();
|
|
3756
3833
|
setIsCardTopResizing(true);
|
|
@@ -3768,6 +3845,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3768
3845
|
import_data_panel_core.CARD_HEADER_HEIGHT * 2,
|
|
3769
3846
|
Math.min(viewportHeight * 0.95, cardTopResizeStartRef.current.startHeight + deltaY)
|
|
3770
3847
|
);
|
|
3848
|
+
cardHeightUserSetRef.current = true;
|
|
3771
3849
|
setCardExpandedHeight(newHeight);
|
|
3772
3850
|
},
|
|
3773
3851
|
[isCardTopResizing, viewportHeight]
|
|
@@ -3781,6 +3859,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3781
3859
|
}, [isCardTopResizing, debouncedSave]);
|
|
3782
3860
|
const handleCardWidthResizeStart = (e, handle) => {
|
|
3783
3861
|
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
3862
|
+
if (isSecondaryMouseButton(e)) return;
|
|
3784
3863
|
e.preventDefault();
|
|
3785
3864
|
e.stopPropagation();
|
|
3786
3865
|
const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
|
|
@@ -3789,10 +3868,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3789
3868
|
resolvedCardConfig.maxWidth
|
|
3790
3869
|
);
|
|
3791
3870
|
const currentWidth = cardWidth ?? defaultCardWidth;
|
|
3792
|
-
const defaultLeftOffset =
|
|
3793
|
-
resolvedCardConfig.horizontalMargin,
|
|
3794
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
3795
|
-
);
|
|
3871
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
3796
3872
|
cardWidthResizeStateRef.current = {
|
|
3797
3873
|
handle,
|
|
3798
3874
|
startX: pos.x,
|
|
@@ -3820,25 +3896,27 @@ var DataPanel = React24.forwardRef(
|
|
|
3820
3896
|
);
|
|
3821
3897
|
setCardWidth(newWidth);
|
|
3822
3898
|
} else {
|
|
3823
|
-
const
|
|
3824
|
-
const newWidth =
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
)
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3899
|
+
const right = st.startLeft + st.startWidth;
|
|
3900
|
+
const newWidth = Math.max(
|
|
3901
|
+
import_data_panel_core.CARD_MIN_WIDTH,
|
|
3902
|
+
Math.min(
|
|
3903
|
+
resolvedCardConfig.maxWidth,
|
|
3904
|
+
right - resolvedCardConfig.horizontalMargin,
|
|
3905
|
+
st.startWidth - deltaX
|
|
3906
|
+
)
|
|
3907
|
+
);
|
|
3908
|
+
const defaultCardWidth = Math.min(
|
|
3909
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
3910
|
+
resolvedCardConfig.maxWidth
|
|
3911
|
+
);
|
|
3912
|
+
setCardWidth(newWidth);
|
|
3913
|
+
setCardHorizontalPosition(right - newWidth - cardDefaultLeftOffset(defaultCardWidth));
|
|
3837
3914
|
}
|
|
3838
3915
|
},
|
|
3839
3916
|
[
|
|
3840
3917
|
isCardWidthResizing,
|
|
3841
3918
|
viewportWidth,
|
|
3919
|
+
cardDefaultLeftOffset,
|
|
3842
3920
|
resolvedCardConfig.horizontalMargin,
|
|
3843
3921
|
resolvedCardConfig.maxWidth
|
|
3844
3922
|
]
|
|
@@ -3867,6 +3945,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3867
3945
|
else if (e.key === "ArrowDown") delta = -step;
|
|
3868
3946
|
else return;
|
|
3869
3947
|
e.preventDefault();
|
|
3948
|
+
cardHeightUserSetRef.current = true;
|
|
3870
3949
|
setCardExpandedHeight((h) => Math.max(cardHeightMin, Math.min(cardHeightMax, h + delta)));
|
|
3871
3950
|
debouncedSave();
|
|
3872
3951
|
return;
|
|
@@ -3881,9 +3960,11 @@ var DataPanel = React24.forwardRef(
|
|
|
3881
3960
|
}
|
|
3882
3961
|
if (widthDelta === 0) return;
|
|
3883
3962
|
e.preventDefault();
|
|
3963
|
+
const margin = resolvedCardConfig.horizontalMargin;
|
|
3964
|
+
const currentLeft = cardDefaultLeftOffset(cardDefaultWidth) + cardHorizontalPosition;
|
|
3884
3965
|
const maxWidth = Math.min(
|
|
3885
3966
|
resolvedCardConfig.maxWidth,
|
|
3886
|
-
viewportWidth -
|
|
3967
|
+
kind === "width-left" ? currentLeft + cardCurrentWidth - margin : viewportWidth - margin - currentLeft
|
|
3887
3968
|
);
|
|
3888
3969
|
const nextWidth = Math.max(import_data_panel_core.CARD_MIN_WIDTH, Math.min(maxWidth, cardCurrentWidth + widthDelta));
|
|
3889
3970
|
const appliedDelta = nextWidth - cardCurrentWidth;
|
|
@@ -3968,16 +4049,31 @@ var DataPanel = React24.forwardRef(
|
|
|
3968
4049
|
};
|
|
3969
4050
|
}
|
|
3970
4051
|
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
4052
|
+
const resizeStateLatestRef = React24.useRef({ mode, detachedSize });
|
|
4053
|
+
resizeStateLatestRef.current = { mode, detachedSize };
|
|
4054
|
+
const expandedRatio = resolvedCardConfig.expandedRatio;
|
|
3971
4055
|
React24.useEffect(() => {
|
|
3972
4056
|
const onResize = () => {
|
|
4057
|
+
const vh = window.innerHeight;
|
|
3973
4058
|
setViewportWidth(layoutViewportWidth());
|
|
3974
|
-
setViewportHeight(
|
|
3975
|
-
setCardExpandedHeight(
|
|
4059
|
+
setViewportHeight(vh);
|
|
4060
|
+
setCardExpandedHeight(
|
|
4061
|
+
(h) => cardHeightUserSetRef.current ? Math.max(import_data_panel_core.CARD_HEADER_HEIGHT * 2, Math.min(vh * 0.95, h)) : vh * expandedRatio
|
|
4062
|
+
);
|
|
4063
|
+
};
|
|
4064
|
+
const onWindowResize = () => {
|
|
4065
|
+
onResize();
|
|
4066
|
+
const { mode: currentMode, detachedSize: size } = resizeStateLatestRef.current;
|
|
4067
|
+
if (currentMode === "detached") {
|
|
4068
|
+
setDetachedPosition(
|
|
4069
|
+
(p) => (0, import_data_panel_core.constrainPosition)(p, size, layoutViewportWidth(), window.innerHeight)
|
|
4070
|
+
);
|
|
4071
|
+
}
|
|
3976
4072
|
};
|
|
3977
4073
|
onResize();
|
|
3978
|
-
window.addEventListener("resize",
|
|
3979
|
-
return () => window.removeEventListener("resize",
|
|
3980
|
-
}, []);
|
|
4074
|
+
window.addEventListener("resize", onWindowResize);
|
|
4075
|
+
return () => window.removeEventListener("resize", onWindowResize);
|
|
4076
|
+
}, [expandedRatio]);
|
|
3981
4077
|
React24.useEffect(() => {
|
|
3982
4078
|
if (isMobile && variant === "card") {
|
|
3983
4079
|
setCardHorizontalPosition(0);
|
|
@@ -3997,10 +4093,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3997
4093
|
resolvedCardConfig.maxWidth
|
|
3998
4094
|
);
|
|
3999
4095
|
const actualCardWidth = cardWidth ?? defaultCardWidth;
|
|
4000
|
-
const defaultLeftOffset =
|
|
4001
|
-
resolvedCardConfig.horizontalMargin,
|
|
4002
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
4003
|
-
);
|
|
4096
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
4004
4097
|
const height = isCardVerticalDragging || isCardHeightTransitioning ? cardDragCurrentHeight : isExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
|
|
4005
4098
|
return {
|
|
4006
4099
|
bottom: 0,
|
|
@@ -4037,6 +4130,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4037
4130
|
isCardVerticalDragging,
|
|
4038
4131
|
isCardHeightTransitioning,
|
|
4039
4132
|
isExpanded,
|
|
4133
|
+
cardDefaultLeftOffset,
|
|
4040
4134
|
resolvedCardConfig.horizontalMargin,
|
|
4041
4135
|
resolvedCardConfig.maxWidth,
|
|
4042
4136
|
resolvedCardConfig.borderRadius
|
|
@@ -4058,6 +4152,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4058
4152
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4059
4153
|
DataPanelTab,
|
|
4060
4154
|
{
|
|
4155
|
+
ref: tabRef,
|
|
4061
4156
|
title,
|
|
4062
4157
|
subtitle,
|
|
4063
4158
|
edge,
|
|
@@ -4694,7 +4789,7 @@ LiveRegion.displayName = "LiveRegion";
|
|
|
4694
4789
|
var React33 = __toESM(require("react"));
|
|
4695
4790
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4696
4791
|
var SkipLink = React33.forwardRef(
|
|
4697
|
-
({ targetId, className, children = "Skip to main content", ...props }, ref) => {
|
|
4792
|
+
({ targetId, className, children = "Skip to main content", onClick, ...props }, ref) => {
|
|
4698
4793
|
const handleClick = (e) => {
|
|
4699
4794
|
e.preventDefault();
|
|
4700
4795
|
const target = document.getElementById(targetId);
|
|
@@ -4709,7 +4804,7 @@ var SkipLink = React33.forwardRef(
|
|
|
4709
4804
|
`SkipLink: Target element with id="${targetId}" not found. Ensure the target element exists and has the correct id attribute.`
|
|
4710
4805
|
);
|
|
4711
4806
|
}
|
|
4712
|
-
|
|
4807
|
+
onClick?.(e);
|
|
4713
4808
|
};
|
|
4714
4809
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4715
4810
|
"a",
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,14 @@ import { cva } from "class-variance-authority";
|
|
|
5
5
|
|
|
6
6
|
// src/lib/utils.ts
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
|
-
import {
|
|
8
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
9
|
+
var twMerge = extendTailwindMerge({
|
|
10
|
+
extend: {
|
|
11
|
+
classGroups: {
|
|
12
|
+
"font-size": [{ text: ["h1", "h2", "h3", "h4", "h5", "h6"] }]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
9
16
|
function cn(...inputs) {
|
|
10
17
|
return twMerge(clsx(inputs));
|
|
11
18
|
}
|
|
@@ -118,7 +125,7 @@ var Input = React3.forwardRef(
|
|
|
118
125
|
"aria-describedby": ariaDescribedBy,
|
|
119
126
|
required,
|
|
120
127
|
className: cn(
|
|
121
|
-
"flex h-10 w-full rounded-md border border-input bg-background text-foreground px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
128
|
+
"flex h-10 w-full rounded-md border border-input bg-background text-foreground px-3 py-2 text-sm max-sm:text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
122
129
|
ariaInvalid === true || ariaInvalid === "true" ? "border-destructive focus-visible:ring-destructive" : "",
|
|
123
130
|
className
|
|
124
131
|
),
|
|
@@ -153,18 +160,18 @@ function useAnnounce(defaultOptions) {
|
|
|
153
160
|
if (clearTimeoutRef.current) {
|
|
154
161
|
clearTimeout(clearTimeoutRef.current);
|
|
155
162
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
clearTimeoutRef.current = setTimeout(() => {
|
|
163
|
+
setPoliteness(options?.politeness ?? defaultOptions?.politeness ?? "polite");
|
|
164
|
+
setMessage("");
|
|
165
|
+
clearTimeoutRef.current = setTimeout(() => {
|
|
166
|
+
setMessage(newMessage);
|
|
167
|
+
const delay = options?.clearDelay ?? defaultOptions?.clearDelay ?? 1e3;
|
|
168
|
+
clearTimeoutRef.current = delay > 0 ? setTimeout(() => {
|
|
163
169
|
setMessage("");
|
|
164
|
-
|
|
165
|
-
|
|
170
|
+
clearTimeoutRef.current = null;
|
|
171
|
+
}, delay) : null;
|
|
172
|
+
}, 0);
|
|
166
173
|
},
|
|
167
|
-
[defaultOptions?.clearDelay]
|
|
174
|
+
[defaultOptions?.clearDelay, defaultOptions?.politeness]
|
|
168
175
|
);
|
|
169
176
|
React4.useEffect(() => {
|
|
170
177
|
return () => {
|
|
@@ -256,7 +263,7 @@ var PasswordInput = React5.forwardRef(
|
|
|
256
263
|
"aria-label": ariaLabel,
|
|
257
264
|
"aria-labelledby": ariaLabelledBy,
|
|
258
265
|
className: cn(
|
|
259
|
-
"flex h-10 w-full rounded-md border border-input bg-background text-foreground px-3 py-2 pr-10 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
266
|
+
"flex h-10 w-full rounded-md border border-input bg-background text-foreground px-3 py-2 pr-10 text-sm max-sm:text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
260
267
|
className
|
|
261
268
|
),
|
|
262
269
|
disabled,
|
|
@@ -302,23 +309,43 @@ var badgeVariants = cva3(
|
|
|
302
309
|
{
|
|
303
310
|
variants: {
|
|
304
311
|
variant: {
|
|
305
|
-
default: "border-transparent bg-primary text-primary-foreground
|
|
306
|
-
secondary: "border-transparent bg-secondary text-secondary-foreground
|
|
307
|
-
destructive: "border-transparent bg-destructive text-destructive-foreground
|
|
308
|
-
outline: "text-foreground
|
|
309
|
-
success: "border-transparent bg-success text-success-foreground
|
|
310
|
-
warning: "border-transparent bg-warning text-warning-foreground
|
|
311
|
-
info: "border-transparent bg-info text-info-foreground
|
|
312
|
+
default: "border-transparent bg-primary text-primary-foreground",
|
|
313
|
+
secondary: "border-transparent bg-secondary text-secondary-foreground",
|
|
314
|
+
destructive: "border-transparent bg-destructive text-destructive-foreground",
|
|
315
|
+
outline: "text-foreground",
|
|
316
|
+
success: "border-transparent bg-success text-success-foreground",
|
|
317
|
+
warning: "border-transparent bg-warning text-warning-foreground",
|
|
318
|
+
info: "border-transparent bg-info text-info-foreground"
|
|
312
319
|
},
|
|
313
320
|
size: {
|
|
314
321
|
default: "px-2 py-0.5 text-xs",
|
|
315
322
|
sm: "px-1.5 py-0.5 text-xs",
|
|
316
323
|
dot: "h-5 w-5 p-0 text-xs"
|
|
324
|
+
},
|
|
325
|
+
// Hover feedback only on interactive badges: a static badge that darkens
|
|
326
|
+
// under the pointer reads as clickable when it is not (matches Svelte)
|
|
327
|
+
clickable: {
|
|
328
|
+
true: "cursor-pointer focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
329
|
+
false: ""
|
|
317
330
|
}
|
|
318
331
|
},
|
|
332
|
+
compoundVariants: [
|
|
333
|
+
{ variant: "default", clickable: true, class: "hover:bg-primary-hover" },
|
|
334
|
+
{ variant: "secondary", clickable: true, class: "hover:bg-secondary-hover" },
|
|
335
|
+
{ variant: "destructive", clickable: true, class: "hover:bg-destructive-hover" },
|
|
336
|
+
{
|
|
337
|
+
variant: "outline",
|
|
338
|
+
clickable: true,
|
|
339
|
+
class: "hover:bg-accent-hover hover:text-accent-foreground"
|
|
340
|
+
},
|
|
341
|
+
{ variant: "success", clickable: true, class: "hover:bg-success/80" },
|
|
342
|
+
{ variant: "warning", clickable: true, class: "hover:bg-warning/80" },
|
|
343
|
+
{ variant: "info", clickable: true, class: "hover:bg-info/80" }
|
|
344
|
+
],
|
|
319
345
|
defaultVariants: {
|
|
320
346
|
variant: "default",
|
|
321
|
-
size: "default"
|
|
347
|
+
size: "default",
|
|
348
|
+
clickable: false
|
|
322
349
|
}
|
|
323
350
|
}
|
|
324
351
|
);
|
|
@@ -332,11 +359,7 @@ var Badge = React7.forwardRef(
|
|
|
332
359
|
}
|
|
333
360
|
}
|
|
334
361
|
const isInteractive = clickable || !!onClick;
|
|
335
|
-
const classes = cn(
|
|
336
|
-
badgeVariants({ variant, size }),
|
|
337
|
-
isInteractive && "cursor-pointer focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
338
|
-
className
|
|
339
|
-
);
|
|
362
|
+
const classes = cn(badgeVariants({ variant, size, clickable: isInteractive }), className);
|
|
340
363
|
const sharedProps = {
|
|
341
364
|
role: live ? "status" : void 0,
|
|
342
365
|
"aria-live": live ? "polite" : void 0,
|
|
@@ -510,11 +533,11 @@ var DialogTrigger = DialogPrimitive.Trigger;
|
|
|
510
533
|
var DialogPortal = DialogPrimitive.Portal;
|
|
511
534
|
var DialogClose = DialogPrimitive.Close;
|
|
512
535
|
var dialogSizeClasses = {
|
|
513
|
-
sm: "max-w-sm",
|
|
514
|
-
md: "max-w-lg",
|
|
515
|
-
lg: "max-w-xl",
|
|
516
|
-
xl: "max-w-2xl",
|
|
517
|
-
"2xl": "max-w-3xl",
|
|
536
|
+
sm: "max-w-[min(theme(maxWidth.sm),calc(100vw-2rem))]",
|
|
537
|
+
md: "max-w-[min(theme(maxWidth.lg),calc(100vw-2rem))]",
|
|
538
|
+
lg: "max-w-[min(theme(maxWidth.xl),calc(100vw-2rem))]",
|
|
539
|
+
xl: "max-w-[min(theme(maxWidth.2xl),calc(100vw-2rem))]",
|
|
540
|
+
"2xl": "max-w-[min(theme(maxWidth.3xl),calc(100vw-2rem))]",
|
|
518
541
|
full: "max-w-[calc(100vw-2rem)]"
|
|
519
542
|
};
|
|
520
543
|
var DialogOverlay = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx10(
|
|
@@ -1654,12 +1677,11 @@ function StudioCanvasItem({
|
|
|
1654
1677
|
select(false);
|
|
1655
1678
|
},
|
|
1656
1679
|
children: [
|
|
1657
|
-
|
|
1680
|
+
/* @__PURE__ */ jsxs12(
|
|
1658
1681
|
"button",
|
|
1659
1682
|
{
|
|
1660
1683
|
type: "button",
|
|
1661
1684
|
className: "sr-only left-2 top-2 z-10 rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground focus:not-sr-only focus:absolute",
|
|
1662
|
-
onClick: () => select(true),
|
|
1663
1685
|
children: [
|
|
1664
1686
|
"Edit ",
|
|
1665
1687
|
label
|
|
@@ -2073,7 +2095,9 @@ function InsertPalette({
|
|
|
2073
2095
|
onOpenChange(false);
|
|
2074
2096
|
onSelect(item.id);
|
|
2075
2097
|
};
|
|
2076
|
-
const entries = () => Array.from(
|
|
2098
|
+
const entries = () => Array.from(
|
|
2099
|
+
listRef.current?.querySelectorAll("[data-palette-item]:not(:disabled)") ?? []
|
|
2100
|
+
);
|
|
2077
2101
|
return /* @__PURE__ */ jsx24(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs16(
|
|
2078
2102
|
DialogContent,
|
|
2079
2103
|
{
|
|
@@ -2297,7 +2321,6 @@ import {
|
|
|
2297
2321
|
DEFAULT_CONSTRAINTS,
|
|
2298
2322
|
DEFAULT_CARD_CONFIG,
|
|
2299
2323
|
CARD_HEADER_HEIGHT,
|
|
2300
|
-
CARD_EXPANDED_RATIO,
|
|
2301
2324
|
CARD_MIN_WIDTH,
|
|
2302
2325
|
loadPanelState,
|
|
2303
2326
|
savePanelState,
|
|
@@ -2330,6 +2353,9 @@ import { Fragment as Fragment5, jsx as jsx25, jsxs as jsxs17 } from "react/jsx-r
|
|
|
2330
2353
|
function layoutViewportWidth() {
|
|
2331
2354
|
return document.documentElement.clientWidth;
|
|
2332
2355
|
}
|
|
2356
|
+
function isSecondaryMouseButton(e) {
|
|
2357
|
+
return e.pointerType === "mouse" && e.button !== 0;
|
|
2358
|
+
}
|
|
2333
2359
|
var DropdownTrigger = DropdownMenuPrimitive2.Trigger;
|
|
2334
2360
|
var DropdownContent = DropdownMenuPrimitive2.Content;
|
|
2335
2361
|
var DropdownLabel = DropdownMenuPrimitive2.Label;
|
|
@@ -2546,7 +2572,8 @@ var DataPanelHeader = React24.forwardRef(
|
|
|
2546
2572
|
ref,
|
|
2547
2573
|
className: cn(
|
|
2548
2574
|
"flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 py-3",
|
|
2549
|
-
|
|
2575
|
+
// touch-none: a touch drag moves the panel instead of panning the page
|
|
2576
|
+
draggable && "cursor-grab active:cursor-grabbing touch-none",
|
|
2550
2577
|
className
|
|
2551
2578
|
),
|
|
2552
2579
|
"data-panel-header": true,
|
|
@@ -2572,6 +2599,7 @@ var DataPanelHeader = React24.forwardRef(
|
|
|
2572
2599
|
},
|
|
2573
2600
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
2574
2601
|
"aria-expanded": isExpanded,
|
|
2602
|
+
"data-panel-collapse": true,
|
|
2575
2603
|
children: /* @__PURE__ */ jsx25(
|
|
2576
2604
|
"span",
|
|
2577
2605
|
{
|
|
@@ -2664,11 +2692,16 @@ function DataPanelCardHeader({
|
|
|
2664
2692
|
onToggleExpand,
|
|
2665
2693
|
onClose
|
|
2666
2694
|
}) {
|
|
2695
|
+
const onToggleKeyDown = (e) => {
|
|
2696
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
2697
|
+
e.preventDefault();
|
|
2698
|
+
onToggleExpand();
|
|
2699
|
+
};
|
|
2667
2700
|
return /* @__PURE__ */ jsxs17(
|
|
2668
2701
|
"div",
|
|
2669
2702
|
{
|
|
2670
2703
|
"data-panel-header": true,
|
|
2671
|
-
className: "relative flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 pt-5 pb-3 cursor-pointer",
|
|
2704
|
+
className: "relative flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 pt-5 pb-3 cursor-pointer touch-none",
|
|
2672
2705
|
onPointerDown: onHeaderPointerDown,
|
|
2673
2706
|
children: [
|
|
2674
2707
|
showDragHandle && /* @__PURE__ */ jsx25(
|
|
@@ -2680,7 +2713,7 @@ function DataPanelCardHeader({
|
|
|
2680
2713
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
2681
2714
|
"aria-expanded": isExpanded,
|
|
2682
2715
|
onPointerDown: onHeaderPointerDown,
|
|
2683
|
-
onKeyDown:
|
|
2716
|
+
onKeyDown: onToggleKeyDown
|
|
2684
2717
|
}
|
|
2685
2718
|
),
|
|
2686
2719
|
/* @__PURE__ */ jsx25(
|
|
@@ -2689,7 +2722,8 @@ function DataPanelCardHeader({
|
|
|
2689
2722
|
className: "flex-1 min-w-0",
|
|
2690
2723
|
role: "button",
|
|
2691
2724
|
tabIndex: 0,
|
|
2692
|
-
|
|
2725
|
+
"aria-expanded": isExpanded,
|
|
2726
|
+
onKeyDown: onToggleKeyDown,
|
|
2693
2727
|
children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
2694
2728
|
subtitle && /* @__PURE__ */ jsx25("p", { className: "text-sm text-muted-foreground truncate", children: subtitle }),
|
|
2695
2729
|
title && /* @__PURE__ */ jsx25("h3", { id: titleId, className: "text-lg font-semibold truncate", children: title })
|
|
@@ -3120,7 +3154,7 @@ function ResizeHandles({
|
|
|
3120
3154
|
),
|
|
3121
3155
|
role: "slider",
|
|
3122
3156
|
tabIndex: 0,
|
|
3123
|
-
"aria-orientation":
|
|
3157
|
+
"aria-orientation": isHorizontal2 ? "vertical" : "horizontal",
|
|
3124
3158
|
"aria-label": `Resize panel from ${handle.replace("-", "")} ${isCorner ? "corner" : "edge"}`,
|
|
3125
3159
|
"aria-valuenow": getAriaValueNow(handle),
|
|
3126
3160
|
"aria-valuemin": min2,
|
|
@@ -3224,6 +3258,17 @@ var DataPanel = React24.forwardRef(
|
|
|
3224
3258
|
typeof window !== "undefined" ? window.innerHeight : 768
|
|
3225
3259
|
);
|
|
3226
3260
|
const isMobile = viewportWidth < 640;
|
|
3261
|
+
const cardDefaultLeftOffset = React24.useCallback(
|
|
3262
|
+
(width) => {
|
|
3263
|
+
const margin = resolvedCardConfig.horizontalMargin;
|
|
3264
|
+
if (resolvedCardConfig.align === "left") return margin;
|
|
3265
|
+
if (resolvedCardConfig.align === "right") {
|
|
3266
|
+
return Math.max(margin, viewportWidth - width - margin);
|
|
3267
|
+
}
|
|
3268
|
+
return Math.max(margin, (viewportWidth - width) / 2);
|
|
3269
|
+
},
|
|
3270
|
+
[viewportWidth, resolvedCardConfig.align, resolvedCardConfig.horizontalMargin]
|
|
3271
|
+
);
|
|
3227
3272
|
const [cardHorizontalPosition, setCardHorizontalPosition] = React24.useState(0);
|
|
3228
3273
|
const [cardExpandedHeight, setCardExpandedHeight] = React24.useState(0);
|
|
3229
3274
|
const [cardWidth, setCardWidth] = React24.useState(null);
|
|
@@ -3261,6 +3306,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3261
3306
|
});
|
|
3262
3307
|
const cardCurrentHeightRef = React24.useRef(CARD_HEADER_HEIGHT);
|
|
3263
3308
|
const cardTopResizeStartRef = React24.useRef({ startY: 0, startHeight: 0 });
|
|
3309
|
+
const cardHeightUserSetRef = React24.useRef(false);
|
|
3264
3310
|
const cardWidthResizeStateRef = React24.useRef({
|
|
3265
3311
|
handle: null,
|
|
3266
3312
|
startX: 0,
|
|
@@ -3319,6 +3365,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3319
3365
|
debouncedSave();
|
|
3320
3366
|
}, [debouncedSave]);
|
|
3321
3367
|
const hasLoadedRef = React24.useRef(false);
|
|
3368
|
+
const hasPersistedPositionRef = React24.useRef(false);
|
|
3322
3369
|
React24.useEffect(() => {
|
|
3323
3370
|
if (!persistKey || hasLoadedRef.current) return;
|
|
3324
3371
|
hasLoadedRef.current = true;
|
|
@@ -3330,14 +3377,26 @@ var DataPanel = React24.forwardRef(
|
|
|
3330
3377
|
if (controlledEdge === void 0 && persisted.edge) setInternalEdge(persisted.edge);
|
|
3331
3378
|
if (controlledExpanded === void 0 && persisted.isExpanded !== void 0)
|
|
3332
3379
|
setInternalExpanded(persisted.isExpanded);
|
|
3333
|
-
if (persisted.detachedPosition)
|
|
3380
|
+
if (persisted.detachedPosition) {
|
|
3381
|
+
const size = persisted.detachedSize ?? DEFAULT_PANEL_STATE.detachedSize;
|
|
3382
|
+
const { x: defaultX, y: defaultY } = DEFAULT_PANEL_STATE.detachedPosition;
|
|
3383
|
+
hasPersistedPositionRef.current = persisted.detachedPosition.x !== defaultX || persisted.detachedPosition.y !== defaultY;
|
|
3384
|
+
setDetachedPosition(
|
|
3385
|
+
constrainPosition(
|
|
3386
|
+
persisted.detachedPosition,
|
|
3387
|
+
size,
|
|
3388
|
+
layoutViewportWidth(),
|
|
3389
|
+
window.innerHeight
|
|
3390
|
+
)
|
|
3391
|
+
);
|
|
3392
|
+
}
|
|
3334
3393
|
if (persisted.detachedSize) setDetachedSize(persisted.detachedSize);
|
|
3335
3394
|
if (persisted.pinnedSize) setPinnedSize(persisted.pinnedSize);
|
|
3336
3395
|
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
3337
3396
|
}
|
|
3338
3397
|
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
3339
3398
|
React24.useEffect(() => {
|
|
3340
|
-
if (mode === "detached" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
3399
|
+
if (mode === "detached" && !hasPersistedPositionRef.current && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
3341
3400
|
setDetachedPosition(
|
|
3342
3401
|
getInitialDetachedPosition(detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
3343
3402
|
);
|
|
@@ -3352,12 +3411,17 @@ var DataPanel = React24.forwardRef(
|
|
|
3352
3411
|
const isDialog = open && (mode === "detached" || variant === "card" && isExpanded && isMobile);
|
|
3353
3412
|
const focusTrapRef = useFocusTrap({ active: isDialog });
|
|
3354
3413
|
useEscapeKey(
|
|
3355
|
-
() => {
|
|
3414
|
+
(event) => {
|
|
3415
|
+
if (event.defaultPrevented) return;
|
|
3416
|
+
event.preventDefault();
|
|
3356
3417
|
if (!disableClose) handleOpenChange(false);
|
|
3357
3418
|
},
|
|
3358
|
-
{ enabled: isDialog }
|
|
3419
|
+
{ enabled: isDialog, preventDefault: false }
|
|
3359
3420
|
);
|
|
3421
|
+
const panelElRef = React24.useRef(null);
|
|
3422
|
+
const tabRef = React24.useRef(null);
|
|
3360
3423
|
const setPanelRef = (node) => {
|
|
3424
|
+
panelElRef.current = node;
|
|
3361
3425
|
focusTrapRef.current = node;
|
|
3362
3426
|
if (typeof ref === "function") {
|
|
3363
3427
|
ref(node);
|
|
@@ -3383,18 +3447,29 @@ var DataPanel = React24.forwardRef(
|
|
|
3383
3447
|
},
|
|
3384
3448
|
[controlledEdge, onEdgeChange]
|
|
3385
3449
|
);
|
|
3450
|
+
const restoreFocusRef = React24.useRef(false);
|
|
3386
3451
|
const handleExpandedChange = React24.useCallback(
|
|
3387
3452
|
(newExpanded) => {
|
|
3453
|
+
const active = typeof document !== "undefined" ? document.activeElement : null;
|
|
3454
|
+
restoreFocusRef.current = newExpanded !== isExpanded && !!active && active !== document.body;
|
|
3388
3455
|
if (controlledExpanded === void 0) {
|
|
3389
3456
|
setInternalExpanded(newExpanded);
|
|
3390
3457
|
}
|
|
3391
3458
|
onExpandedChange?.(newExpanded);
|
|
3392
3459
|
},
|
|
3393
|
-
[controlledExpanded, onExpandedChange]
|
|
3460
|
+
[controlledExpanded, onExpandedChange, isExpanded]
|
|
3394
3461
|
);
|
|
3462
|
+
React24.useEffect(() => {
|
|
3463
|
+
if (!restoreFocusRef.current) return;
|
|
3464
|
+
restoreFocusRef.current = false;
|
|
3465
|
+
const active = document.activeElement;
|
|
3466
|
+
if (active && active !== document.body) return;
|
|
3467
|
+
const target = tabRef.current ? tabRef.current.querySelector("button") : panelElRef.current?.querySelector("[data-panel-collapse]");
|
|
3468
|
+
(target ?? panelElRef.current)?.focus();
|
|
3469
|
+
}, [isExpanded, mode]);
|
|
3395
3470
|
const handleToggleExpand = () => handleExpandedChange(!isExpanded);
|
|
3396
3471
|
const handleDragStart = (e) => {
|
|
3397
|
-
if (disableDrag) return;
|
|
3472
|
+
if (disableDrag || isSecondaryMouseButton(e)) return;
|
|
3398
3473
|
const target = e.target;
|
|
3399
3474
|
if (!target.closest("[data-panel-header]")) return;
|
|
3400
3475
|
const pos = getPointerPosition(e.nativeEvent);
|
|
@@ -3499,7 +3574,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3499
3574
|
document.body.style.userSelect = "";
|
|
3500
3575
|
}, [isPinnedDragging]);
|
|
3501
3576
|
const handleResizeStart = (e, handle) => {
|
|
3502
|
-
if (disableResize) return;
|
|
3577
|
+
if (disableResize || isSecondaryMouseButton(e)) return;
|
|
3503
3578
|
e.preventDefault();
|
|
3504
3579
|
e.stopPropagation();
|
|
3505
3580
|
setIsResizing(true);
|
|
@@ -3562,7 +3637,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3562
3637
|
document.body.style.userSelect = "";
|
|
3563
3638
|
}, [isResizing]);
|
|
3564
3639
|
const handleCardHeaderPointerDown = (e) => {
|
|
3565
|
-
if (variant !== "card") return;
|
|
3640
|
+
if (variant !== "card" || isSecondaryMouseButton(e)) return;
|
|
3566
3641
|
const target = e.target;
|
|
3567
3642
|
const isDragHandle = target.closest("[data-card-drag-handle]");
|
|
3568
3643
|
if (!isDragHandle && target.closest("button")) return;
|
|
@@ -3601,14 +3676,12 @@ var DataPanel = React24.forwardRef(
|
|
|
3601
3676
|
}
|
|
3602
3677
|
if (isCardHorizontalDragging && !isMobile) {
|
|
3603
3678
|
const deltaX = currentPos.x - cardDragStateRef.current.startX;
|
|
3604
|
-
const
|
|
3679
|
+
const defaultWidth = Math.min(
|
|
3605
3680
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
3606
3681
|
resolvedCardConfig.maxWidth
|
|
3607
3682
|
);
|
|
3608
|
-
const
|
|
3609
|
-
|
|
3610
|
-
(viewportWidth - cw) / 2
|
|
3611
|
-
);
|
|
3683
|
+
const cw = cardWidth ?? defaultWidth;
|
|
3684
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultWidth);
|
|
3612
3685
|
const minOffset = -(defaultLeftOffset - resolvedCardConfig.horizontalMargin);
|
|
3613
3686
|
const maxOffset = viewportWidth - cw - defaultLeftOffset - resolvedCardConfig.horizontalMargin;
|
|
3614
3687
|
const nextPos = cardDragStateRef.current.startHorizontalPosition + deltaX;
|
|
@@ -3622,6 +3695,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3622
3695
|
viewportWidth,
|
|
3623
3696
|
viewportHeight,
|
|
3624
3697
|
cardExpandedHeight,
|
|
3698
|
+
cardWidth,
|
|
3699
|
+
cardDefaultLeftOffset,
|
|
3625
3700
|
resolvedCardConfig.horizontalMargin,
|
|
3626
3701
|
resolvedCardConfig.maxWidth
|
|
3627
3702
|
]
|
|
@@ -3675,6 +3750,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3675
3750
|
);
|
|
3676
3751
|
const handleCardResizeStart = (e) => {
|
|
3677
3752
|
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
3753
|
+
if (isSecondaryMouseButton(e)) return;
|
|
3678
3754
|
e.preventDefault();
|
|
3679
3755
|
e.stopPropagation();
|
|
3680
3756
|
setIsCardTopResizing(true);
|
|
@@ -3692,6 +3768,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3692
3768
|
CARD_HEADER_HEIGHT * 2,
|
|
3693
3769
|
Math.min(viewportHeight * 0.95, cardTopResizeStartRef.current.startHeight + deltaY)
|
|
3694
3770
|
);
|
|
3771
|
+
cardHeightUserSetRef.current = true;
|
|
3695
3772
|
setCardExpandedHeight(newHeight);
|
|
3696
3773
|
},
|
|
3697
3774
|
[isCardTopResizing, viewportHeight]
|
|
@@ -3705,6 +3782,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3705
3782
|
}, [isCardTopResizing, debouncedSave]);
|
|
3706
3783
|
const handleCardWidthResizeStart = (e, handle) => {
|
|
3707
3784
|
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
3785
|
+
if (isSecondaryMouseButton(e)) return;
|
|
3708
3786
|
e.preventDefault();
|
|
3709
3787
|
e.stopPropagation();
|
|
3710
3788
|
const pos = getPointerPosition(e.nativeEvent);
|
|
@@ -3713,10 +3791,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3713
3791
|
resolvedCardConfig.maxWidth
|
|
3714
3792
|
);
|
|
3715
3793
|
const currentWidth = cardWidth ?? defaultCardWidth;
|
|
3716
|
-
const defaultLeftOffset =
|
|
3717
|
-
resolvedCardConfig.horizontalMargin,
|
|
3718
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
3719
|
-
);
|
|
3794
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
3720
3795
|
cardWidthResizeStateRef.current = {
|
|
3721
3796
|
handle,
|
|
3722
3797
|
startX: pos.x,
|
|
@@ -3744,25 +3819,27 @@ var DataPanel = React24.forwardRef(
|
|
|
3744
3819
|
);
|
|
3745
3820
|
setCardWidth(newWidth);
|
|
3746
3821
|
} else {
|
|
3747
|
-
const
|
|
3748
|
-
const newWidth =
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
)
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3822
|
+
const right = st.startLeft + st.startWidth;
|
|
3823
|
+
const newWidth = Math.max(
|
|
3824
|
+
CARD_MIN_WIDTH,
|
|
3825
|
+
Math.min(
|
|
3826
|
+
resolvedCardConfig.maxWidth,
|
|
3827
|
+
right - resolvedCardConfig.horizontalMargin,
|
|
3828
|
+
st.startWidth - deltaX
|
|
3829
|
+
)
|
|
3830
|
+
);
|
|
3831
|
+
const defaultCardWidth = Math.min(
|
|
3832
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
3833
|
+
resolvedCardConfig.maxWidth
|
|
3834
|
+
);
|
|
3835
|
+
setCardWidth(newWidth);
|
|
3836
|
+
setCardHorizontalPosition(right - newWidth - cardDefaultLeftOffset(defaultCardWidth));
|
|
3761
3837
|
}
|
|
3762
3838
|
},
|
|
3763
3839
|
[
|
|
3764
3840
|
isCardWidthResizing,
|
|
3765
3841
|
viewportWidth,
|
|
3842
|
+
cardDefaultLeftOffset,
|
|
3766
3843
|
resolvedCardConfig.horizontalMargin,
|
|
3767
3844
|
resolvedCardConfig.maxWidth
|
|
3768
3845
|
]
|
|
@@ -3791,6 +3868,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3791
3868
|
else if (e.key === "ArrowDown") delta = -step;
|
|
3792
3869
|
else return;
|
|
3793
3870
|
e.preventDefault();
|
|
3871
|
+
cardHeightUserSetRef.current = true;
|
|
3794
3872
|
setCardExpandedHeight((h) => Math.max(cardHeightMin, Math.min(cardHeightMax, h + delta)));
|
|
3795
3873
|
debouncedSave();
|
|
3796
3874
|
return;
|
|
@@ -3805,9 +3883,11 @@ var DataPanel = React24.forwardRef(
|
|
|
3805
3883
|
}
|
|
3806
3884
|
if (widthDelta === 0) return;
|
|
3807
3885
|
e.preventDefault();
|
|
3886
|
+
const margin = resolvedCardConfig.horizontalMargin;
|
|
3887
|
+
const currentLeft = cardDefaultLeftOffset(cardDefaultWidth) + cardHorizontalPosition;
|
|
3808
3888
|
const maxWidth = Math.min(
|
|
3809
3889
|
resolvedCardConfig.maxWidth,
|
|
3810
|
-
viewportWidth -
|
|
3890
|
+
kind === "width-left" ? currentLeft + cardCurrentWidth - margin : viewportWidth - margin - currentLeft
|
|
3811
3891
|
);
|
|
3812
3892
|
const nextWidth = Math.max(CARD_MIN_WIDTH, Math.min(maxWidth, cardCurrentWidth + widthDelta));
|
|
3813
3893
|
const appliedDelta = nextWidth - cardCurrentWidth;
|
|
@@ -3892,16 +3972,31 @@ var DataPanel = React24.forwardRef(
|
|
|
3892
3972
|
};
|
|
3893
3973
|
}
|
|
3894
3974
|
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
3975
|
+
const resizeStateLatestRef = React24.useRef({ mode, detachedSize });
|
|
3976
|
+
resizeStateLatestRef.current = { mode, detachedSize };
|
|
3977
|
+
const expandedRatio = resolvedCardConfig.expandedRatio;
|
|
3895
3978
|
React24.useEffect(() => {
|
|
3896
3979
|
const onResize = () => {
|
|
3980
|
+
const vh = window.innerHeight;
|
|
3897
3981
|
setViewportWidth(layoutViewportWidth());
|
|
3898
|
-
setViewportHeight(
|
|
3899
|
-
setCardExpandedHeight(
|
|
3982
|
+
setViewportHeight(vh);
|
|
3983
|
+
setCardExpandedHeight(
|
|
3984
|
+
(h) => cardHeightUserSetRef.current ? Math.max(CARD_HEADER_HEIGHT * 2, Math.min(vh * 0.95, h)) : vh * expandedRatio
|
|
3985
|
+
);
|
|
3986
|
+
};
|
|
3987
|
+
const onWindowResize = () => {
|
|
3988
|
+
onResize();
|
|
3989
|
+
const { mode: currentMode, detachedSize: size } = resizeStateLatestRef.current;
|
|
3990
|
+
if (currentMode === "detached") {
|
|
3991
|
+
setDetachedPosition(
|
|
3992
|
+
(p) => constrainPosition(p, size, layoutViewportWidth(), window.innerHeight)
|
|
3993
|
+
);
|
|
3994
|
+
}
|
|
3900
3995
|
};
|
|
3901
3996
|
onResize();
|
|
3902
|
-
window.addEventListener("resize",
|
|
3903
|
-
return () => window.removeEventListener("resize",
|
|
3904
|
-
}, []);
|
|
3997
|
+
window.addEventListener("resize", onWindowResize);
|
|
3998
|
+
return () => window.removeEventListener("resize", onWindowResize);
|
|
3999
|
+
}, [expandedRatio]);
|
|
3905
4000
|
React24.useEffect(() => {
|
|
3906
4001
|
if (isMobile && variant === "card") {
|
|
3907
4002
|
setCardHorizontalPosition(0);
|
|
@@ -3921,10 +4016,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3921
4016
|
resolvedCardConfig.maxWidth
|
|
3922
4017
|
);
|
|
3923
4018
|
const actualCardWidth = cardWidth ?? defaultCardWidth;
|
|
3924
|
-
const defaultLeftOffset =
|
|
3925
|
-
resolvedCardConfig.horizontalMargin,
|
|
3926
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
3927
|
-
);
|
|
4019
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
3928
4020
|
const height = isCardVerticalDragging || isCardHeightTransitioning ? cardDragCurrentHeight : isExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
3929
4021
|
return {
|
|
3930
4022
|
bottom: 0,
|
|
@@ -3961,6 +4053,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3961
4053
|
isCardVerticalDragging,
|
|
3962
4054
|
isCardHeightTransitioning,
|
|
3963
4055
|
isExpanded,
|
|
4056
|
+
cardDefaultLeftOffset,
|
|
3964
4057
|
resolvedCardConfig.horizontalMargin,
|
|
3965
4058
|
resolvedCardConfig.maxWidth,
|
|
3966
4059
|
resolvedCardConfig.borderRadius
|
|
@@ -3982,6 +4075,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3982
4075
|
return /* @__PURE__ */ jsx25(
|
|
3983
4076
|
DataPanelTab,
|
|
3984
4077
|
{
|
|
4078
|
+
ref: tabRef,
|
|
3985
4079
|
title,
|
|
3986
4080
|
subtitle,
|
|
3987
4081
|
edge,
|
|
@@ -4618,7 +4712,7 @@ LiveRegion.displayName = "LiveRegion";
|
|
|
4618
4712
|
import * as React33 from "react";
|
|
4619
4713
|
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
4620
4714
|
var SkipLink = React33.forwardRef(
|
|
4621
|
-
({ targetId, className, children = "Skip to main content", ...props }, ref) => {
|
|
4715
|
+
({ targetId, className, children = "Skip to main content", onClick, ...props }, ref) => {
|
|
4622
4716
|
const handleClick = (e) => {
|
|
4623
4717
|
e.preventDefault();
|
|
4624
4718
|
const target = document.getElementById(targetId);
|
|
@@ -4633,7 +4727,7 @@ var SkipLink = React33.forwardRef(
|
|
|
4633
4727
|
`SkipLink: Target element with id="${targetId}" not found. Ensure the target element exists and has the correct id attribute.`
|
|
4634
4728
|
);
|
|
4635
4729
|
}
|
|
4636
|
-
|
|
4730
|
+
onClick?.(e);
|
|
4637
4731
|
};
|
|
4638
4732
|
return /* @__PURE__ */ jsx34(
|
|
4639
4733
|
"a",
|