@classic-homes/theme-react 0.4.1 → 0.4.3
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 +187 -83
- package/dist/index.mjs +187 -84
- 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,
|
|
@@ -3349,6 +3396,9 @@ var DataPanel = React24.forwardRef(
|
|
|
3349
3396
|
const edge = controlledEdge ?? internalEdge;
|
|
3350
3397
|
const isExpanded = controlledExpanded ?? internalExpanded;
|
|
3351
3398
|
const showContent = variant !== "card" || isExpanded || isCardVerticalDragging;
|
|
3399
|
+
const resizeRight = !disableResize && (variant === "full" && (mode === "detached" || edge === "left") || variant === "card" && isExpanded && !isMobile);
|
|
3400
|
+
const resizeBottom = !disableResize && variant === "full" && (mode === "detached" || edge === "top");
|
|
3401
|
+
const hasFooter = !!(footerContent || actions.length > 0 || footerActions);
|
|
3352
3402
|
const saveTimeoutRef = React24.useRef(null);
|
|
3353
3403
|
const isMountedRef = React24.useRef(true);
|
|
3354
3404
|
React24.useEffect(() => {
|
|
@@ -3395,6 +3445,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3395
3445
|
debouncedSave();
|
|
3396
3446
|
}, [debouncedSave]);
|
|
3397
3447
|
const hasLoadedRef = React24.useRef(false);
|
|
3448
|
+
const hasPersistedPositionRef = React24.useRef(false);
|
|
3398
3449
|
React24.useEffect(() => {
|
|
3399
3450
|
if (!persistKey || hasLoadedRef.current) return;
|
|
3400
3451
|
hasLoadedRef.current = true;
|
|
@@ -3406,14 +3457,26 @@ var DataPanel = React24.forwardRef(
|
|
|
3406
3457
|
if (controlledEdge === void 0 && persisted.edge) setInternalEdge(persisted.edge);
|
|
3407
3458
|
if (controlledExpanded === void 0 && persisted.isExpanded !== void 0)
|
|
3408
3459
|
setInternalExpanded(persisted.isExpanded);
|
|
3409
|
-
if (persisted.detachedPosition)
|
|
3460
|
+
if (persisted.detachedPosition) {
|
|
3461
|
+
const size = persisted.detachedSize ?? import_data_panel_core.DEFAULT_PANEL_STATE.detachedSize;
|
|
3462
|
+
const { x: defaultX, y: defaultY } = import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition;
|
|
3463
|
+
hasPersistedPositionRef.current = persisted.detachedPosition.x !== defaultX || persisted.detachedPosition.y !== defaultY;
|
|
3464
|
+
setDetachedPosition(
|
|
3465
|
+
(0, import_data_panel_core.constrainPosition)(
|
|
3466
|
+
persisted.detachedPosition,
|
|
3467
|
+
size,
|
|
3468
|
+
layoutViewportWidth(),
|
|
3469
|
+
window.innerHeight
|
|
3470
|
+
)
|
|
3471
|
+
);
|
|
3472
|
+
}
|
|
3410
3473
|
if (persisted.detachedSize) setDetachedSize(persisted.detachedSize);
|
|
3411
3474
|
if (persisted.pinnedSize) setPinnedSize(persisted.pinnedSize);
|
|
3412
3475
|
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
3413
3476
|
}
|
|
3414
3477
|
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
3415
3478
|
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) {
|
|
3479
|
+
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
3480
|
setDetachedPosition(
|
|
3418
3481
|
(0, import_data_panel_core.getInitialDetachedPosition)(detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
3419
3482
|
);
|
|
@@ -3428,12 +3491,17 @@ var DataPanel = React24.forwardRef(
|
|
|
3428
3491
|
const isDialog = open && (mode === "detached" || variant === "card" && isExpanded && isMobile);
|
|
3429
3492
|
const focusTrapRef = useFocusTrap({ active: isDialog });
|
|
3430
3493
|
useEscapeKey(
|
|
3431
|
-
() => {
|
|
3494
|
+
(event) => {
|
|
3495
|
+
if (event.defaultPrevented) return;
|
|
3496
|
+
event.preventDefault();
|
|
3432
3497
|
if (!disableClose) handleOpenChange(false);
|
|
3433
3498
|
},
|
|
3434
|
-
{ enabled: isDialog }
|
|
3499
|
+
{ enabled: isDialog, preventDefault: false }
|
|
3435
3500
|
);
|
|
3501
|
+
const panelElRef = React24.useRef(null);
|
|
3502
|
+
const tabRef = React24.useRef(null);
|
|
3436
3503
|
const setPanelRef = (node) => {
|
|
3504
|
+
panelElRef.current = node;
|
|
3437
3505
|
focusTrapRef.current = node;
|
|
3438
3506
|
if (typeof ref === "function") {
|
|
3439
3507
|
ref(node);
|
|
@@ -3459,18 +3527,29 @@ var DataPanel = React24.forwardRef(
|
|
|
3459
3527
|
},
|
|
3460
3528
|
[controlledEdge, onEdgeChange]
|
|
3461
3529
|
);
|
|
3530
|
+
const restoreFocusRef = React24.useRef(false);
|
|
3462
3531
|
const handleExpandedChange = React24.useCallback(
|
|
3463
3532
|
(newExpanded) => {
|
|
3533
|
+
const active = typeof document !== "undefined" ? document.activeElement : null;
|
|
3534
|
+
restoreFocusRef.current = newExpanded !== isExpanded && !!active && active !== document.body;
|
|
3464
3535
|
if (controlledExpanded === void 0) {
|
|
3465
3536
|
setInternalExpanded(newExpanded);
|
|
3466
3537
|
}
|
|
3467
3538
|
onExpandedChange?.(newExpanded);
|
|
3468
3539
|
},
|
|
3469
|
-
[controlledExpanded, onExpandedChange]
|
|
3540
|
+
[controlledExpanded, onExpandedChange, isExpanded]
|
|
3470
3541
|
);
|
|
3542
|
+
React24.useEffect(() => {
|
|
3543
|
+
if (!restoreFocusRef.current) return;
|
|
3544
|
+
restoreFocusRef.current = false;
|
|
3545
|
+
const active = document.activeElement;
|
|
3546
|
+
if (active && active !== document.body) return;
|
|
3547
|
+
const target = tabRef.current ? tabRef.current.querySelector("button") : panelElRef.current?.querySelector("[data-panel-collapse]");
|
|
3548
|
+
(target ?? panelElRef.current)?.focus();
|
|
3549
|
+
}, [isExpanded, mode]);
|
|
3471
3550
|
const handleToggleExpand = () => handleExpandedChange(!isExpanded);
|
|
3472
3551
|
const handleDragStart = (e) => {
|
|
3473
|
-
if (disableDrag) return;
|
|
3552
|
+
if (disableDrag || isSecondaryMouseButton(e)) return;
|
|
3474
3553
|
const target = e.target;
|
|
3475
3554
|
if (!target.closest("[data-panel-header]")) return;
|
|
3476
3555
|
const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
|
|
@@ -3575,7 +3654,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3575
3654
|
document.body.style.userSelect = "";
|
|
3576
3655
|
}, [isPinnedDragging]);
|
|
3577
3656
|
const handleResizeStart = (e, handle) => {
|
|
3578
|
-
if (disableResize) return;
|
|
3657
|
+
if (disableResize || isSecondaryMouseButton(e)) return;
|
|
3579
3658
|
e.preventDefault();
|
|
3580
3659
|
e.stopPropagation();
|
|
3581
3660
|
setIsResizing(true);
|
|
@@ -3638,7 +3717,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3638
3717
|
document.body.style.userSelect = "";
|
|
3639
3718
|
}, [isResizing]);
|
|
3640
3719
|
const handleCardHeaderPointerDown = (e) => {
|
|
3641
|
-
if (variant !== "card") return;
|
|
3720
|
+
if (variant !== "card" || isSecondaryMouseButton(e)) return;
|
|
3642
3721
|
const target = e.target;
|
|
3643
3722
|
const isDragHandle = target.closest("[data-card-drag-handle]");
|
|
3644
3723
|
if (!isDragHandle && target.closest("button")) return;
|
|
@@ -3677,14 +3756,12 @@ var DataPanel = React24.forwardRef(
|
|
|
3677
3756
|
}
|
|
3678
3757
|
if (isCardHorizontalDragging && !isMobile) {
|
|
3679
3758
|
const deltaX = currentPos.x - cardDragStateRef.current.startX;
|
|
3680
|
-
const
|
|
3759
|
+
const defaultWidth = Math.min(
|
|
3681
3760
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
3682
3761
|
resolvedCardConfig.maxWidth
|
|
3683
3762
|
);
|
|
3684
|
-
const
|
|
3685
|
-
|
|
3686
|
-
(viewportWidth - cw) / 2
|
|
3687
|
-
);
|
|
3763
|
+
const cw = cardWidth ?? defaultWidth;
|
|
3764
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultWidth);
|
|
3688
3765
|
const minOffset = -(defaultLeftOffset - resolvedCardConfig.horizontalMargin);
|
|
3689
3766
|
const maxOffset = viewportWidth - cw - defaultLeftOffset - resolvedCardConfig.horizontalMargin;
|
|
3690
3767
|
const nextPos = cardDragStateRef.current.startHorizontalPosition + deltaX;
|
|
@@ -3698,6 +3775,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3698
3775
|
viewportWidth,
|
|
3699
3776
|
viewportHeight,
|
|
3700
3777
|
cardExpandedHeight,
|
|
3778
|
+
cardWidth,
|
|
3779
|
+
cardDefaultLeftOffset,
|
|
3701
3780
|
resolvedCardConfig.horizontalMargin,
|
|
3702
3781
|
resolvedCardConfig.maxWidth
|
|
3703
3782
|
]
|
|
@@ -3751,6 +3830,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3751
3830
|
);
|
|
3752
3831
|
const handleCardResizeStart = (e) => {
|
|
3753
3832
|
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
3833
|
+
if (isSecondaryMouseButton(e)) return;
|
|
3754
3834
|
e.preventDefault();
|
|
3755
3835
|
e.stopPropagation();
|
|
3756
3836
|
setIsCardTopResizing(true);
|
|
@@ -3768,6 +3848,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3768
3848
|
import_data_panel_core.CARD_HEADER_HEIGHT * 2,
|
|
3769
3849
|
Math.min(viewportHeight * 0.95, cardTopResizeStartRef.current.startHeight + deltaY)
|
|
3770
3850
|
);
|
|
3851
|
+
cardHeightUserSetRef.current = true;
|
|
3771
3852
|
setCardExpandedHeight(newHeight);
|
|
3772
3853
|
},
|
|
3773
3854
|
[isCardTopResizing, viewportHeight]
|
|
@@ -3781,6 +3862,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3781
3862
|
}, [isCardTopResizing, debouncedSave]);
|
|
3782
3863
|
const handleCardWidthResizeStart = (e, handle) => {
|
|
3783
3864
|
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
3865
|
+
if (isSecondaryMouseButton(e)) return;
|
|
3784
3866
|
e.preventDefault();
|
|
3785
3867
|
e.stopPropagation();
|
|
3786
3868
|
const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
|
|
@@ -3789,10 +3871,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3789
3871
|
resolvedCardConfig.maxWidth
|
|
3790
3872
|
);
|
|
3791
3873
|
const currentWidth = cardWidth ?? defaultCardWidth;
|
|
3792
|
-
const defaultLeftOffset =
|
|
3793
|
-
resolvedCardConfig.horizontalMargin,
|
|
3794
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
3795
|
-
);
|
|
3874
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
3796
3875
|
cardWidthResizeStateRef.current = {
|
|
3797
3876
|
handle,
|
|
3798
3877
|
startX: pos.x,
|
|
@@ -3820,25 +3899,27 @@ var DataPanel = React24.forwardRef(
|
|
|
3820
3899
|
);
|
|
3821
3900
|
setCardWidth(newWidth);
|
|
3822
3901
|
} else {
|
|
3823
|
-
const
|
|
3824
|
-
const newWidth =
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
)
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3902
|
+
const right = st.startLeft + st.startWidth;
|
|
3903
|
+
const newWidth = Math.max(
|
|
3904
|
+
import_data_panel_core.CARD_MIN_WIDTH,
|
|
3905
|
+
Math.min(
|
|
3906
|
+
resolvedCardConfig.maxWidth,
|
|
3907
|
+
right - resolvedCardConfig.horizontalMargin,
|
|
3908
|
+
st.startWidth - deltaX
|
|
3909
|
+
)
|
|
3910
|
+
);
|
|
3911
|
+
const defaultCardWidth = Math.min(
|
|
3912
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
3913
|
+
resolvedCardConfig.maxWidth
|
|
3914
|
+
);
|
|
3915
|
+
setCardWidth(newWidth);
|
|
3916
|
+
setCardHorizontalPosition(right - newWidth - cardDefaultLeftOffset(defaultCardWidth));
|
|
3837
3917
|
}
|
|
3838
3918
|
},
|
|
3839
3919
|
[
|
|
3840
3920
|
isCardWidthResizing,
|
|
3841
3921
|
viewportWidth,
|
|
3922
|
+
cardDefaultLeftOffset,
|
|
3842
3923
|
resolvedCardConfig.horizontalMargin,
|
|
3843
3924
|
resolvedCardConfig.maxWidth
|
|
3844
3925
|
]
|
|
@@ -3867,6 +3948,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3867
3948
|
else if (e.key === "ArrowDown") delta = -step;
|
|
3868
3949
|
else return;
|
|
3869
3950
|
e.preventDefault();
|
|
3951
|
+
cardHeightUserSetRef.current = true;
|
|
3870
3952
|
setCardExpandedHeight((h) => Math.max(cardHeightMin, Math.min(cardHeightMax, h + delta)));
|
|
3871
3953
|
debouncedSave();
|
|
3872
3954
|
return;
|
|
@@ -3881,9 +3963,11 @@ var DataPanel = React24.forwardRef(
|
|
|
3881
3963
|
}
|
|
3882
3964
|
if (widthDelta === 0) return;
|
|
3883
3965
|
e.preventDefault();
|
|
3966
|
+
const margin = resolvedCardConfig.horizontalMargin;
|
|
3967
|
+
const currentLeft = cardDefaultLeftOffset(cardDefaultWidth) + cardHorizontalPosition;
|
|
3884
3968
|
const maxWidth = Math.min(
|
|
3885
3969
|
resolvedCardConfig.maxWidth,
|
|
3886
|
-
viewportWidth -
|
|
3970
|
+
kind === "width-left" ? currentLeft + cardCurrentWidth - margin : viewportWidth - margin - currentLeft
|
|
3887
3971
|
);
|
|
3888
3972
|
const nextWidth = Math.max(import_data_panel_core.CARD_MIN_WIDTH, Math.min(maxWidth, cardCurrentWidth + widthDelta));
|
|
3889
3973
|
const appliedDelta = nextWidth - cardCurrentWidth;
|
|
@@ -3968,16 +4052,31 @@ var DataPanel = React24.forwardRef(
|
|
|
3968
4052
|
};
|
|
3969
4053
|
}
|
|
3970
4054
|
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
4055
|
+
const resizeStateLatestRef = React24.useRef({ mode, detachedSize });
|
|
4056
|
+
resizeStateLatestRef.current = { mode, detachedSize };
|
|
4057
|
+
const expandedRatio = resolvedCardConfig.expandedRatio;
|
|
3971
4058
|
React24.useEffect(() => {
|
|
3972
4059
|
const onResize = () => {
|
|
4060
|
+
const vh = window.innerHeight;
|
|
3973
4061
|
setViewportWidth(layoutViewportWidth());
|
|
3974
|
-
setViewportHeight(
|
|
3975
|
-
setCardExpandedHeight(
|
|
4062
|
+
setViewportHeight(vh);
|
|
4063
|
+
setCardExpandedHeight(
|
|
4064
|
+
(h) => cardHeightUserSetRef.current ? Math.max(import_data_panel_core.CARD_HEADER_HEIGHT * 2, Math.min(vh * 0.95, h)) : vh * expandedRatio
|
|
4065
|
+
);
|
|
4066
|
+
};
|
|
4067
|
+
const onWindowResize = () => {
|
|
4068
|
+
onResize();
|
|
4069
|
+
const { mode: currentMode, detachedSize: size } = resizeStateLatestRef.current;
|
|
4070
|
+
if (currentMode === "detached") {
|
|
4071
|
+
setDetachedPosition(
|
|
4072
|
+
(p) => (0, import_data_panel_core.constrainPosition)(p, size, layoutViewportWidth(), window.innerHeight)
|
|
4073
|
+
);
|
|
4074
|
+
}
|
|
3976
4075
|
};
|
|
3977
4076
|
onResize();
|
|
3978
|
-
window.addEventListener("resize",
|
|
3979
|
-
return () => window.removeEventListener("resize",
|
|
3980
|
-
}, []);
|
|
4077
|
+
window.addEventListener("resize", onWindowResize);
|
|
4078
|
+
return () => window.removeEventListener("resize", onWindowResize);
|
|
4079
|
+
}, [expandedRatio]);
|
|
3981
4080
|
React24.useEffect(() => {
|
|
3982
4081
|
if (isMobile && variant === "card") {
|
|
3983
4082
|
setCardHorizontalPosition(0);
|
|
@@ -3997,10 +4096,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3997
4096
|
resolvedCardConfig.maxWidth
|
|
3998
4097
|
);
|
|
3999
4098
|
const actualCardWidth = cardWidth ?? defaultCardWidth;
|
|
4000
|
-
const defaultLeftOffset =
|
|
4001
|
-
resolvedCardConfig.horizontalMargin,
|
|
4002
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
4003
|
-
);
|
|
4099
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
4004
4100
|
const height = isCardVerticalDragging || isCardHeightTransitioning ? cardDragCurrentHeight : isExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
|
|
4005
4101
|
return {
|
|
4006
4102
|
bottom: 0,
|
|
@@ -4037,6 +4133,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4037
4133
|
isCardVerticalDragging,
|
|
4038
4134
|
isCardHeightTransitioning,
|
|
4039
4135
|
isExpanded,
|
|
4136
|
+
cardDefaultLeftOffset,
|
|
4040
4137
|
resolvedCardConfig.horizontalMargin,
|
|
4041
4138
|
resolvedCardConfig.maxWidth,
|
|
4042
4139
|
resolvedCardConfig.borderRadius
|
|
@@ -4058,6 +4155,7 @@ var DataPanel = React24.forwardRef(
|
|
|
4058
4155
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4059
4156
|
DataPanelTab,
|
|
4060
4157
|
{
|
|
4158
|
+
ref: tabRef,
|
|
4061
4159
|
title,
|
|
4062
4160
|
subtitle,
|
|
4063
4161
|
edge,
|
|
@@ -4151,7 +4249,13 @@ var DataPanel = React24.forwardRef(
|
|
|
4151
4249
|
}
|
|
4152
4250
|
),
|
|
4153
4251
|
showContent && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
4154
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4252
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4253
|
+
DataPanelContent,
|
|
4254
|
+
{
|
|
4255
|
+
className: cn(resizeRight && "mr-2.5", resizeBottom && !hasFooter && "mb-2.5"),
|
|
4256
|
+
children
|
|
4257
|
+
}
|
|
4258
|
+
),
|
|
4155
4259
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4156
4260
|
DataPanelFooter,
|
|
4157
4261
|
{
|
|
@@ -4694,7 +4798,7 @@ LiveRegion.displayName = "LiveRegion";
|
|
|
4694
4798
|
var React33 = __toESM(require("react"));
|
|
4695
4799
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4696
4800
|
var SkipLink = React33.forwardRef(
|
|
4697
|
-
({ targetId, className, children = "Skip to main content", ...props }, ref) => {
|
|
4801
|
+
({ targetId, className, children = "Skip to main content", onClick, ...props }, ref) => {
|
|
4698
4802
|
const handleClick = (e) => {
|
|
4699
4803
|
e.preventDefault();
|
|
4700
4804
|
const target = document.getElementById(targetId);
|
|
@@ -4709,7 +4813,7 @@ var SkipLink = React33.forwardRef(
|
|
|
4709
4813
|
`SkipLink: Target element with id="${targetId}" not found. Ensure the target element exists and has the correct id attribute.`
|
|
4710
4814
|
);
|
|
4711
4815
|
}
|
|
4712
|
-
|
|
4816
|
+
onClick?.(e);
|
|
4713
4817
|
};
|
|
4714
4818
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4715
4819
|
"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,
|
|
@@ -3273,6 +3319,9 @@ var DataPanel = React24.forwardRef(
|
|
|
3273
3319
|
const edge = controlledEdge ?? internalEdge;
|
|
3274
3320
|
const isExpanded = controlledExpanded ?? internalExpanded;
|
|
3275
3321
|
const showContent = variant !== "card" || isExpanded || isCardVerticalDragging;
|
|
3322
|
+
const resizeRight = !disableResize && (variant === "full" && (mode === "detached" || edge === "left") || variant === "card" && isExpanded && !isMobile);
|
|
3323
|
+
const resizeBottom = !disableResize && variant === "full" && (mode === "detached" || edge === "top");
|
|
3324
|
+
const hasFooter = !!(footerContent || actions.length > 0 || footerActions);
|
|
3276
3325
|
const saveTimeoutRef = React24.useRef(null);
|
|
3277
3326
|
const isMountedRef = React24.useRef(true);
|
|
3278
3327
|
React24.useEffect(() => {
|
|
@@ -3319,6 +3368,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3319
3368
|
debouncedSave();
|
|
3320
3369
|
}, [debouncedSave]);
|
|
3321
3370
|
const hasLoadedRef = React24.useRef(false);
|
|
3371
|
+
const hasPersistedPositionRef = React24.useRef(false);
|
|
3322
3372
|
React24.useEffect(() => {
|
|
3323
3373
|
if (!persistKey || hasLoadedRef.current) return;
|
|
3324
3374
|
hasLoadedRef.current = true;
|
|
@@ -3330,14 +3380,26 @@ var DataPanel = React24.forwardRef(
|
|
|
3330
3380
|
if (controlledEdge === void 0 && persisted.edge) setInternalEdge(persisted.edge);
|
|
3331
3381
|
if (controlledExpanded === void 0 && persisted.isExpanded !== void 0)
|
|
3332
3382
|
setInternalExpanded(persisted.isExpanded);
|
|
3333
|
-
if (persisted.detachedPosition)
|
|
3383
|
+
if (persisted.detachedPosition) {
|
|
3384
|
+
const size = persisted.detachedSize ?? DEFAULT_PANEL_STATE.detachedSize;
|
|
3385
|
+
const { x: defaultX, y: defaultY } = DEFAULT_PANEL_STATE.detachedPosition;
|
|
3386
|
+
hasPersistedPositionRef.current = persisted.detachedPosition.x !== defaultX || persisted.detachedPosition.y !== defaultY;
|
|
3387
|
+
setDetachedPosition(
|
|
3388
|
+
constrainPosition(
|
|
3389
|
+
persisted.detachedPosition,
|
|
3390
|
+
size,
|
|
3391
|
+
layoutViewportWidth(),
|
|
3392
|
+
window.innerHeight
|
|
3393
|
+
)
|
|
3394
|
+
);
|
|
3395
|
+
}
|
|
3334
3396
|
if (persisted.detachedSize) setDetachedSize(persisted.detachedSize);
|
|
3335
3397
|
if (persisted.pinnedSize) setPinnedSize(persisted.pinnedSize);
|
|
3336
3398
|
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
3337
3399
|
}
|
|
3338
3400
|
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
3339
3401
|
React24.useEffect(() => {
|
|
3340
|
-
if (mode === "detached" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
3402
|
+
if (mode === "detached" && !hasPersistedPositionRef.current && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
3341
3403
|
setDetachedPosition(
|
|
3342
3404
|
getInitialDetachedPosition(detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
3343
3405
|
);
|
|
@@ -3352,12 +3414,17 @@ var DataPanel = React24.forwardRef(
|
|
|
3352
3414
|
const isDialog = open && (mode === "detached" || variant === "card" && isExpanded && isMobile);
|
|
3353
3415
|
const focusTrapRef = useFocusTrap({ active: isDialog });
|
|
3354
3416
|
useEscapeKey(
|
|
3355
|
-
() => {
|
|
3417
|
+
(event) => {
|
|
3418
|
+
if (event.defaultPrevented) return;
|
|
3419
|
+
event.preventDefault();
|
|
3356
3420
|
if (!disableClose) handleOpenChange(false);
|
|
3357
3421
|
},
|
|
3358
|
-
{ enabled: isDialog }
|
|
3422
|
+
{ enabled: isDialog, preventDefault: false }
|
|
3359
3423
|
);
|
|
3424
|
+
const panelElRef = React24.useRef(null);
|
|
3425
|
+
const tabRef = React24.useRef(null);
|
|
3360
3426
|
const setPanelRef = (node) => {
|
|
3427
|
+
panelElRef.current = node;
|
|
3361
3428
|
focusTrapRef.current = node;
|
|
3362
3429
|
if (typeof ref === "function") {
|
|
3363
3430
|
ref(node);
|
|
@@ -3383,18 +3450,29 @@ var DataPanel = React24.forwardRef(
|
|
|
3383
3450
|
},
|
|
3384
3451
|
[controlledEdge, onEdgeChange]
|
|
3385
3452
|
);
|
|
3453
|
+
const restoreFocusRef = React24.useRef(false);
|
|
3386
3454
|
const handleExpandedChange = React24.useCallback(
|
|
3387
3455
|
(newExpanded) => {
|
|
3456
|
+
const active = typeof document !== "undefined" ? document.activeElement : null;
|
|
3457
|
+
restoreFocusRef.current = newExpanded !== isExpanded && !!active && active !== document.body;
|
|
3388
3458
|
if (controlledExpanded === void 0) {
|
|
3389
3459
|
setInternalExpanded(newExpanded);
|
|
3390
3460
|
}
|
|
3391
3461
|
onExpandedChange?.(newExpanded);
|
|
3392
3462
|
},
|
|
3393
|
-
[controlledExpanded, onExpandedChange]
|
|
3463
|
+
[controlledExpanded, onExpandedChange, isExpanded]
|
|
3394
3464
|
);
|
|
3465
|
+
React24.useEffect(() => {
|
|
3466
|
+
if (!restoreFocusRef.current) return;
|
|
3467
|
+
restoreFocusRef.current = false;
|
|
3468
|
+
const active = document.activeElement;
|
|
3469
|
+
if (active && active !== document.body) return;
|
|
3470
|
+
const target = tabRef.current ? tabRef.current.querySelector("button") : panelElRef.current?.querySelector("[data-panel-collapse]");
|
|
3471
|
+
(target ?? panelElRef.current)?.focus();
|
|
3472
|
+
}, [isExpanded, mode]);
|
|
3395
3473
|
const handleToggleExpand = () => handleExpandedChange(!isExpanded);
|
|
3396
3474
|
const handleDragStart = (e) => {
|
|
3397
|
-
if (disableDrag) return;
|
|
3475
|
+
if (disableDrag || isSecondaryMouseButton(e)) return;
|
|
3398
3476
|
const target = e.target;
|
|
3399
3477
|
if (!target.closest("[data-panel-header]")) return;
|
|
3400
3478
|
const pos = getPointerPosition(e.nativeEvent);
|
|
@@ -3499,7 +3577,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3499
3577
|
document.body.style.userSelect = "";
|
|
3500
3578
|
}, [isPinnedDragging]);
|
|
3501
3579
|
const handleResizeStart = (e, handle) => {
|
|
3502
|
-
if (disableResize) return;
|
|
3580
|
+
if (disableResize || isSecondaryMouseButton(e)) return;
|
|
3503
3581
|
e.preventDefault();
|
|
3504
3582
|
e.stopPropagation();
|
|
3505
3583
|
setIsResizing(true);
|
|
@@ -3562,7 +3640,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3562
3640
|
document.body.style.userSelect = "";
|
|
3563
3641
|
}, [isResizing]);
|
|
3564
3642
|
const handleCardHeaderPointerDown = (e) => {
|
|
3565
|
-
if (variant !== "card") return;
|
|
3643
|
+
if (variant !== "card" || isSecondaryMouseButton(e)) return;
|
|
3566
3644
|
const target = e.target;
|
|
3567
3645
|
const isDragHandle = target.closest("[data-card-drag-handle]");
|
|
3568
3646
|
if (!isDragHandle && target.closest("button")) return;
|
|
@@ -3601,14 +3679,12 @@ var DataPanel = React24.forwardRef(
|
|
|
3601
3679
|
}
|
|
3602
3680
|
if (isCardHorizontalDragging && !isMobile) {
|
|
3603
3681
|
const deltaX = currentPos.x - cardDragStateRef.current.startX;
|
|
3604
|
-
const
|
|
3682
|
+
const defaultWidth = Math.min(
|
|
3605
3683
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
3606
3684
|
resolvedCardConfig.maxWidth
|
|
3607
3685
|
);
|
|
3608
|
-
const
|
|
3609
|
-
|
|
3610
|
-
(viewportWidth - cw) / 2
|
|
3611
|
-
);
|
|
3686
|
+
const cw = cardWidth ?? defaultWidth;
|
|
3687
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultWidth);
|
|
3612
3688
|
const minOffset = -(defaultLeftOffset - resolvedCardConfig.horizontalMargin);
|
|
3613
3689
|
const maxOffset = viewportWidth - cw - defaultLeftOffset - resolvedCardConfig.horizontalMargin;
|
|
3614
3690
|
const nextPos = cardDragStateRef.current.startHorizontalPosition + deltaX;
|
|
@@ -3622,6 +3698,8 @@ var DataPanel = React24.forwardRef(
|
|
|
3622
3698
|
viewportWidth,
|
|
3623
3699
|
viewportHeight,
|
|
3624
3700
|
cardExpandedHeight,
|
|
3701
|
+
cardWidth,
|
|
3702
|
+
cardDefaultLeftOffset,
|
|
3625
3703
|
resolvedCardConfig.horizontalMargin,
|
|
3626
3704
|
resolvedCardConfig.maxWidth
|
|
3627
3705
|
]
|
|
@@ -3675,6 +3753,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3675
3753
|
);
|
|
3676
3754
|
const handleCardResizeStart = (e) => {
|
|
3677
3755
|
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
3756
|
+
if (isSecondaryMouseButton(e)) return;
|
|
3678
3757
|
e.preventDefault();
|
|
3679
3758
|
e.stopPropagation();
|
|
3680
3759
|
setIsCardTopResizing(true);
|
|
@@ -3692,6 +3771,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3692
3771
|
CARD_HEADER_HEIGHT * 2,
|
|
3693
3772
|
Math.min(viewportHeight * 0.95, cardTopResizeStartRef.current.startHeight + deltaY)
|
|
3694
3773
|
);
|
|
3774
|
+
cardHeightUserSetRef.current = true;
|
|
3695
3775
|
setCardExpandedHeight(newHeight);
|
|
3696
3776
|
},
|
|
3697
3777
|
[isCardTopResizing, viewportHeight]
|
|
@@ -3705,6 +3785,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3705
3785
|
}, [isCardTopResizing, debouncedSave]);
|
|
3706
3786
|
const handleCardWidthResizeStart = (e, handle) => {
|
|
3707
3787
|
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
3788
|
+
if (isSecondaryMouseButton(e)) return;
|
|
3708
3789
|
e.preventDefault();
|
|
3709
3790
|
e.stopPropagation();
|
|
3710
3791
|
const pos = getPointerPosition(e.nativeEvent);
|
|
@@ -3713,10 +3794,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3713
3794
|
resolvedCardConfig.maxWidth
|
|
3714
3795
|
);
|
|
3715
3796
|
const currentWidth = cardWidth ?? defaultCardWidth;
|
|
3716
|
-
const defaultLeftOffset =
|
|
3717
|
-
resolvedCardConfig.horizontalMargin,
|
|
3718
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
3719
|
-
);
|
|
3797
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
3720
3798
|
cardWidthResizeStateRef.current = {
|
|
3721
3799
|
handle,
|
|
3722
3800
|
startX: pos.x,
|
|
@@ -3744,25 +3822,27 @@ var DataPanel = React24.forwardRef(
|
|
|
3744
3822
|
);
|
|
3745
3823
|
setCardWidth(newWidth);
|
|
3746
3824
|
} else {
|
|
3747
|
-
const
|
|
3748
|
-
const newWidth =
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
)
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3825
|
+
const right = st.startLeft + st.startWidth;
|
|
3826
|
+
const newWidth = Math.max(
|
|
3827
|
+
CARD_MIN_WIDTH,
|
|
3828
|
+
Math.min(
|
|
3829
|
+
resolvedCardConfig.maxWidth,
|
|
3830
|
+
right - resolvedCardConfig.horizontalMargin,
|
|
3831
|
+
st.startWidth - deltaX
|
|
3832
|
+
)
|
|
3833
|
+
);
|
|
3834
|
+
const defaultCardWidth = Math.min(
|
|
3835
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
3836
|
+
resolvedCardConfig.maxWidth
|
|
3837
|
+
);
|
|
3838
|
+
setCardWidth(newWidth);
|
|
3839
|
+
setCardHorizontalPosition(right - newWidth - cardDefaultLeftOffset(defaultCardWidth));
|
|
3761
3840
|
}
|
|
3762
3841
|
},
|
|
3763
3842
|
[
|
|
3764
3843
|
isCardWidthResizing,
|
|
3765
3844
|
viewportWidth,
|
|
3845
|
+
cardDefaultLeftOffset,
|
|
3766
3846
|
resolvedCardConfig.horizontalMargin,
|
|
3767
3847
|
resolvedCardConfig.maxWidth
|
|
3768
3848
|
]
|
|
@@ -3791,6 +3871,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3791
3871
|
else if (e.key === "ArrowDown") delta = -step;
|
|
3792
3872
|
else return;
|
|
3793
3873
|
e.preventDefault();
|
|
3874
|
+
cardHeightUserSetRef.current = true;
|
|
3794
3875
|
setCardExpandedHeight((h) => Math.max(cardHeightMin, Math.min(cardHeightMax, h + delta)));
|
|
3795
3876
|
debouncedSave();
|
|
3796
3877
|
return;
|
|
@@ -3805,9 +3886,11 @@ var DataPanel = React24.forwardRef(
|
|
|
3805
3886
|
}
|
|
3806
3887
|
if (widthDelta === 0) return;
|
|
3807
3888
|
e.preventDefault();
|
|
3889
|
+
const margin = resolvedCardConfig.horizontalMargin;
|
|
3890
|
+
const currentLeft = cardDefaultLeftOffset(cardDefaultWidth) + cardHorizontalPosition;
|
|
3808
3891
|
const maxWidth = Math.min(
|
|
3809
3892
|
resolvedCardConfig.maxWidth,
|
|
3810
|
-
viewportWidth -
|
|
3893
|
+
kind === "width-left" ? currentLeft + cardCurrentWidth - margin : viewportWidth - margin - currentLeft
|
|
3811
3894
|
);
|
|
3812
3895
|
const nextWidth = Math.max(CARD_MIN_WIDTH, Math.min(maxWidth, cardCurrentWidth + widthDelta));
|
|
3813
3896
|
const appliedDelta = nextWidth - cardCurrentWidth;
|
|
@@ -3892,16 +3975,31 @@ var DataPanel = React24.forwardRef(
|
|
|
3892
3975
|
};
|
|
3893
3976
|
}
|
|
3894
3977
|
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
3978
|
+
const resizeStateLatestRef = React24.useRef({ mode, detachedSize });
|
|
3979
|
+
resizeStateLatestRef.current = { mode, detachedSize };
|
|
3980
|
+
const expandedRatio = resolvedCardConfig.expandedRatio;
|
|
3895
3981
|
React24.useEffect(() => {
|
|
3896
3982
|
const onResize = () => {
|
|
3983
|
+
const vh = window.innerHeight;
|
|
3897
3984
|
setViewportWidth(layoutViewportWidth());
|
|
3898
|
-
setViewportHeight(
|
|
3899
|
-
setCardExpandedHeight(
|
|
3985
|
+
setViewportHeight(vh);
|
|
3986
|
+
setCardExpandedHeight(
|
|
3987
|
+
(h) => cardHeightUserSetRef.current ? Math.max(CARD_HEADER_HEIGHT * 2, Math.min(vh * 0.95, h)) : vh * expandedRatio
|
|
3988
|
+
);
|
|
3989
|
+
};
|
|
3990
|
+
const onWindowResize = () => {
|
|
3991
|
+
onResize();
|
|
3992
|
+
const { mode: currentMode, detachedSize: size } = resizeStateLatestRef.current;
|
|
3993
|
+
if (currentMode === "detached") {
|
|
3994
|
+
setDetachedPosition(
|
|
3995
|
+
(p) => constrainPosition(p, size, layoutViewportWidth(), window.innerHeight)
|
|
3996
|
+
);
|
|
3997
|
+
}
|
|
3900
3998
|
};
|
|
3901
3999
|
onResize();
|
|
3902
|
-
window.addEventListener("resize",
|
|
3903
|
-
return () => window.removeEventListener("resize",
|
|
3904
|
-
}, []);
|
|
4000
|
+
window.addEventListener("resize", onWindowResize);
|
|
4001
|
+
return () => window.removeEventListener("resize", onWindowResize);
|
|
4002
|
+
}, [expandedRatio]);
|
|
3905
4003
|
React24.useEffect(() => {
|
|
3906
4004
|
if (isMobile && variant === "card") {
|
|
3907
4005
|
setCardHorizontalPosition(0);
|
|
@@ -3921,10 +4019,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3921
4019
|
resolvedCardConfig.maxWidth
|
|
3922
4020
|
);
|
|
3923
4021
|
const actualCardWidth = cardWidth ?? defaultCardWidth;
|
|
3924
|
-
const defaultLeftOffset =
|
|
3925
|
-
resolvedCardConfig.horizontalMargin,
|
|
3926
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
3927
|
-
);
|
|
4022
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
3928
4023
|
const height = isCardVerticalDragging || isCardHeightTransitioning ? cardDragCurrentHeight : isExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
3929
4024
|
return {
|
|
3930
4025
|
bottom: 0,
|
|
@@ -3961,6 +4056,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3961
4056
|
isCardVerticalDragging,
|
|
3962
4057
|
isCardHeightTransitioning,
|
|
3963
4058
|
isExpanded,
|
|
4059
|
+
cardDefaultLeftOffset,
|
|
3964
4060
|
resolvedCardConfig.horizontalMargin,
|
|
3965
4061
|
resolvedCardConfig.maxWidth,
|
|
3966
4062
|
resolvedCardConfig.borderRadius
|
|
@@ -3982,6 +4078,7 @@ var DataPanel = React24.forwardRef(
|
|
|
3982
4078
|
return /* @__PURE__ */ jsx25(
|
|
3983
4079
|
DataPanelTab,
|
|
3984
4080
|
{
|
|
4081
|
+
ref: tabRef,
|
|
3985
4082
|
title,
|
|
3986
4083
|
subtitle,
|
|
3987
4084
|
edge,
|
|
@@ -4075,7 +4172,13 @@ var DataPanel = React24.forwardRef(
|
|
|
4075
4172
|
}
|
|
4076
4173
|
),
|
|
4077
4174
|
showContent && /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
4078
|
-
/* @__PURE__ */ jsx25(
|
|
4175
|
+
/* @__PURE__ */ jsx25(
|
|
4176
|
+
DataPanelContent,
|
|
4177
|
+
{
|
|
4178
|
+
className: cn(resizeRight && "mr-2.5", resizeBottom && !hasFooter && "mb-2.5"),
|
|
4179
|
+
children
|
|
4180
|
+
}
|
|
4181
|
+
),
|
|
4079
4182
|
/* @__PURE__ */ jsx25(
|
|
4080
4183
|
DataPanelFooter,
|
|
4081
4184
|
{
|
|
@@ -4618,7 +4721,7 @@ LiveRegion.displayName = "LiveRegion";
|
|
|
4618
4721
|
import * as React33 from "react";
|
|
4619
4722
|
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
4620
4723
|
var SkipLink = React33.forwardRef(
|
|
4621
|
-
({ targetId, className, children = "Skip to main content", ...props }, ref) => {
|
|
4724
|
+
({ targetId, className, children = "Skip to main content", onClick, ...props }, ref) => {
|
|
4622
4725
|
const handleClick = (e) => {
|
|
4623
4726
|
e.preventDefault();
|
|
4624
4727
|
const target = document.getElementById(targetId);
|
|
@@ -4633,7 +4736,7 @@ var SkipLink = React33.forwardRef(
|
|
|
4633
4736
|
`SkipLink: Target element with id="${targetId}" not found. Ensure the target element exists and has the correct id attribute.`
|
|
4634
4737
|
);
|
|
4635
4738
|
}
|
|
4636
|
-
|
|
4739
|
+
onClick?.(e);
|
|
4637
4740
|
};
|
|
4638
4741
|
return /* @__PURE__ */ jsx34(
|
|
4639
4742
|
"a",
|