@dynamic-labs-sdk/droplet 1.41.0 → 1.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/copy-button/copy-button.d.ts +3 -2
- package/dist/components/copy-button/copy-button.d.ts.map +1 -1
- package/dist/components/ui/table/table.d.ts.map +1 -1
- package/dist/components/ui/table/table.stories.d.ts +3 -0
- package/dist/components/ui/table/table.stories.d.ts.map +1 -1
- package/dist/index.cjs +167 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +167 -71
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -29,7 +29,7 @@ import { Content as Content$5, Portal as Portal$4, Provider, Root as Root$6, Tri
|
|
|
29
29
|
import Link from "next/link";
|
|
30
30
|
|
|
31
31
|
//#region src/components/unsaved-changes-bar/unsaved-changes-bar.tsx
|
|
32
|
-
const spring$
|
|
32
|
+
const spring$3 = {
|
|
33
33
|
bounce: 0,
|
|
34
34
|
duration: .35,
|
|
35
35
|
type: "spring"
|
|
@@ -67,7 +67,7 @@ const ProgressiveBlur = () => {
|
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
69
|
const popTransition = {
|
|
70
|
-
...spring$
|
|
70
|
+
...spring$3,
|
|
71
71
|
duration: .25
|
|
72
72
|
};
|
|
73
73
|
const StatusIcon = ({ state }) => {
|
|
@@ -166,7 +166,7 @@ const UnsavedChangesBar = ({ hasChanges, onSave, onReset, suppressed = false })
|
|
|
166
166
|
initial: { opacity: 0 },
|
|
167
167
|
animate: { opacity: 1 },
|
|
168
168
|
exit: { opacity: 0 },
|
|
169
|
-
transition: spring$
|
|
169
|
+
transition: spring$3,
|
|
170
170
|
children: /* @__PURE__ */ jsx(ProgressiveBlur, {})
|
|
171
171
|
}, "blur") }), /* @__PURE__ */ jsx("div", {
|
|
172
172
|
className: "fixed bottom-10 left-1/2 -translate-x-1/2 z-50",
|
|
@@ -186,7 +186,7 @@ const UnsavedChangesBar = ({ hasChanges, onSave, onReset, suppressed = false })
|
|
|
186
186
|
scale: .95,
|
|
187
187
|
y: 20
|
|
188
188
|
},
|
|
189
|
-
transition: spring$
|
|
189
|
+
transition: spring$3,
|
|
190
190
|
style: { willChange: "opacity, transform" },
|
|
191
191
|
className: "flex items-center gap-1.5 rounded-xl bg-zinc-900 dark:bg-[oklch(0.940_0.008_231)] shadow-[0_0_0_1px_rgba(0,0,0,0.08),0_8px_24px_-4px_rgba(0,0,0,0.25),0_20px_50px_-8px_rgba(0,0,0,0.20)] dark:shadow-[0_0_0_1px_rgba(0,0,0,0.08),0_8px_20px_-4px_rgba(0,0,0,0.10),0_20px_50px_-8px_rgba(0,0,0,0.08)] pl-3 pr-1.5 py-1.5",
|
|
192
192
|
children: [
|
|
@@ -515,7 +515,7 @@ const AvatarGroupCount = ({ className, ...props }) => {
|
|
|
515
515
|
|
|
516
516
|
//#endregion
|
|
517
517
|
//#region src/components/ui/alert/alert.tsx
|
|
518
|
-
const spring$
|
|
518
|
+
const spring$2 = {
|
|
519
519
|
bounce: 0,
|
|
520
520
|
duration: .35,
|
|
521
521
|
type: "spring"
|
|
@@ -587,7 +587,7 @@ const Alert = ({ variant = "neutral", title, children, dismissible = false, onDi
|
|
|
587
587
|
type: "button",
|
|
588
588
|
"aria-label": "Dismiss",
|
|
589
589
|
whileTap: shouldReduceMotion ? void 0 : { scale: .96 },
|
|
590
|
-
transition: spring$
|
|
590
|
+
transition: spring$2,
|
|
591
591
|
onClick: () => {
|
|
592
592
|
setDismissed(true);
|
|
593
593
|
onDismiss?.();
|
|
@@ -2163,12 +2163,34 @@ const Stepper = ({ steps, currentStep, className, ...props }) => /* @__PURE__ */
|
|
|
2163
2163
|
//#endregion
|
|
2164
2164
|
//#region src/components/ui/table/table.tsx
|
|
2165
2165
|
const Table = ({ className, ...props }) => {
|
|
2166
|
-
|
|
2166
|
+
const containerRef = useRef(null);
|
|
2167
|
+
const [isScrollable, setIsScrollable] = useState(void 0);
|
|
2168
|
+
useEffect(() => {
|
|
2169
|
+
const container = containerRef.current;
|
|
2170
|
+
if (!container) return;
|
|
2171
|
+
const updateScrollability = () => setIsScrollable(container.scrollWidth > container.clientWidth);
|
|
2172
|
+
updateScrollability();
|
|
2173
|
+
window.addEventListener("resize", updateScrollability);
|
|
2174
|
+
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(updateScrollability);
|
|
2175
|
+
if (observer) {
|
|
2176
|
+
observer.observe(container);
|
|
2177
|
+
observer.observe(container.firstElementChild);
|
|
2178
|
+
}
|
|
2179
|
+
return () => {
|
|
2180
|
+
window.removeEventListener("resize", updateScrollability);
|
|
2181
|
+
observer?.disconnect();
|
|
2182
|
+
};
|
|
2183
|
+
}, []);
|
|
2184
|
+
return /* @__PURE__ */ jsx("section", {
|
|
2185
|
+
ref: containerRef,
|
|
2167
2186
|
"data-slot": "table-container",
|
|
2168
|
-
|
|
2187
|
+
"data-tray": "header",
|
|
2188
|
+
tabIndex: isScrollable ? 0 : void 0,
|
|
2189
|
+
"aria-label": isScrollable ? "Scrollable table" : void 0,
|
|
2190
|
+
className: cn("relative w-full rounded-[16px] bg-[var(--tray-chrome)] px-[var(--tray-inset)] pb-[var(--tray-inset)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--ring)]", isScrollable === false ? "overflow-visible" : "overflow-x-auto"),
|
|
2169
2191
|
children: /* @__PURE__ */ jsx("table", {
|
|
2170
2192
|
"data-slot": "table",
|
|
2171
|
-
className: cn("w-full caption-bottom text-sm", className),
|
|
2193
|
+
className: cn("w-full caption-bottom border-separate border-spacing-0 text-sm", className),
|
|
2172
2194
|
...props
|
|
2173
2195
|
})
|
|
2174
2196
|
});
|
|
@@ -2176,28 +2198,28 @@ const Table = ({ className, ...props }) => {
|
|
|
2176
2198
|
const TableHeader = ({ className, ...props }) => {
|
|
2177
2199
|
return /* @__PURE__ */ jsx("thead", {
|
|
2178
2200
|
"data-slot": "table-header",
|
|
2179
|
-
className: cn("
|
|
2201
|
+
className: cn("sticky top-0 z-20 bg-[var(--tray-chrome)] [&_tr]:border-0 [&_tr]:hover:bg-transparent", className),
|
|
2180
2202
|
...props
|
|
2181
2203
|
});
|
|
2182
2204
|
};
|
|
2183
2205
|
const TableBody = ({ className, ...props }) => {
|
|
2184
2206
|
return /* @__PURE__ */ jsx("tbody", {
|
|
2185
2207
|
"data-slot": "table-body",
|
|
2186
|
-
className: cn("[
|
|
2208
|
+
className: cn("relative after:pointer-events-none after:absolute after:inset-0 after:z-10 after:rounded-[var(--tray-shelf-radius)] after:border after:border-[var(--border-divider)] after:content-['']", "[&:has(+tfoot)]:after:rounded-b-none [&:has(+tfoot)]:after:border-b-0", "[&>tr>*]:bg-card [&>tr:first-child>*:first-child]:rounded-tl-[var(--tray-shelf-radius)] [&>tr:first-child>*:last-child]:rounded-tr-[var(--tray-shelf-radius)]", "[&>tr:last-child>*:first-child]:rounded-bl-[var(--tray-shelf-radius)] [&>tr:last-child>*:last-child]:rounded-br-[var(--tray-shelf-radius)]", "[&:has(+tfoot)>tr:last-child>*:first-child]:rounded-bl-none [&:has(+tfoot)>tr:last-child>*:last-child]:rounded-br-none", "[&>tr:not(:last-child)>*]:border-b [&>tr:not(:last-child)>*]:border-[var(--border-divider)]", className),
|
|
2187
2209
|
...props
|
|
2188
2210
|
});
|
|
2189
2211
|
};
|
|
2190
2212
|
const TableFooter = ({ className, ...props }) => {
|
|
2191
2213
|
return /* @__PURE__ */ jsx("tfoot", {
|
|
2192
2214
|
"data-slot": "table-footer",
|
|
2193
|
-
className: cn("bg-
|
|
2215
|
+
className: cn("relative font-medium after:pointer-events-none after:absolute after:inset-0 after:z-10 after:rounded-b-[var(--tray-shelf-radius)] after:border-x after:border-b after:border-[var(--border-divider)] after:content-['']", "[&>tr>*]:bg-card [&>tr>*]:border-t [&>tr>*]:border-[var(--border-divider)]", "[&>tr:last-child>*:first-child]:rounded-bl-[var(--tray-shelf-radius)] [&>tr:last-child>*:last-child]:rounded-br-[var(--tray-shelf-radius)]", className),
|
|
2194
2216
|
...props
|
|
2195
2217
|
});
|
|
2196
2218
|
};
|
|
2197
2219
|
const TableRow = ({ className, ...props }) => {
|
|
2198
2220
|
return /* @__PURE__ */ jsx("tr", {
|
|
2199
2221
|
"data-slot": "table-row",
|
|
2200
|
-
className: cn("hover:bg-[var(--overlay-hover)] data-[state=selected]:bg-[var(--overlay-selected)] border-b border-[var(--border-divider)] transition-[background-color] duration-100", className),
|
|
2222
|
+
className: cn("hover:[&>*]:bg-[var(--overlay-hover)] data-[state=selected]:[&>*]:bg-[var(--overlay-selected)] data-[state=selected]:hover:[&>*]:bg-[var(--overlay-selected-hover)] border-b border-[var(--border-divider)] [&>*]:transition-[background-color] [&>*]:duration-100", className),
|
|
2201
2223
|
...props
|
|
2202
2224
|
});
|
|
2203
2225
|
};
|
|
@@ -2205,14 +2227,14 @@ const TableHead = ({ className, scope, ...props }) => {
|
|
|
2205
2227
|
return /* @__PURE__ */ jsx("th", {
|
|
2206
2228
|
"data-slot": "table-head",
|
|
2207
2229
|
scope: scope ?? "col",
|
|
2208
|
-
className: cn("text-
|
|
2230
|
+
className: cn("text-foreground/75 h-[38px] px-4 text-left align-middle text-xs font-medium whitespace-nowrap tabular-nums [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className),
|
|
2209
2231
|
...props
|
|
2210
2232
|
});
|
|
2211
2233
|
};
|
|
2212
2234
|
const TableCell = ({ className, ...props }) => {
|
|
2213
2235
|
return /* @__PURE__ */ jsx("td", {
|
|
2214
2236
|
"data-slot": "table-cell",
|
|
2215
|
-
className: cn("px-
|
|
2237
|
+
className: cn("px-4 py-2.5 align-middle whitespace-nowrap tabular-nums [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className),
|
|
2216
2238
|
...props
|
|
2217
2239
|
});
|
|
2218
2240
|
};
|
|
@@ -2471,77 +2493,151 @@ const AssetIcon = ({ symbol, size = 32, className }) => {
|
|
|
2471
2493
|
|
|
2472
2494
|
//#endregion
|
|
2473
2495
|
//#region src/components/copy-button/copy-button.tsx
|
|
2474
|
-
const
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2496
|
+
const TIMING = {
|
|
2497
|
+
feedbackHold: 1500,
|
|
2498
|
+
iconSwap: 220,
|
|
2499
|
+
reset: 120
|
|
2500
|
+
};
|
|
2501
|
+
const COPY_STAGE = {
|
|
2502
|
+
copied: 1,
|
|
2503
|
+
error: 2,
|
|
2504
|
+
idle: 0
|
|
2505
|
+
};
|
|
2506
|
+
const ICON = {
|
|
2507
|
+
activeScale: 1,
|
|
2508
|
+
inactiveScale: .72,
|
|
2509
|
+
spring: {
|
|
2510
|
+
bounce: 0,
|
|
2511
|
+
type: "spring",
|
|
2512
|
+
visualDuration: TIMING.iconSwap / 1e3
|
|
2513
|
+
}
|
|
2478
2514
|
};
|
|
2515
|
+
const LABEL = {
|
|
2516
|
+
activeOffset: 0,
|
|
2517
|
+
inactiveOffset: 2,
|
|
2518
|
+
spring: {
|
|
2519
|
+
bounce: 0,
|
|
2520
|
+
type: "spring",
|
|
2521
|
+
visualDuration: TIMING.iconSwap / 1e3
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
const RESET_TRANSITION = {
|
|
2525
|
+
duration: TIMING.reset / 1e3,
|
|
2526
|
+
ease: "easeOut"
|
|
2527
|
+
};
|
|
2528
|
+
const REDUCED_MOTION_TRANSITION = { duration: 0 };
|
|
2529
|
+
/** Copies a value and presents stable, accessible success or failure feedback. */
|
|
2479
2530
|
const CopyButton = ({ value, label, variant = "outline", size = "icon-xs", className }) => {
|
|
2480
|
-
const [
|
|
2531
|
+
const [stage, setStage] = useState(COPY_STAGE.idle);
|
|
2481
2532
|
const timeoutRef = useRef(null);
|
|
2533
|
+
const requestIdRef = useRef(0);
|
|
2482
2534
|
const shouldReduceMotion = useReducedMotion();
|
|
2535
|
+
const animationStyle = { willChange: shouldReduceMotion ? "auto" : "transform, opacity" };
|
|
2483
2536
|
useEffect(() => {
|
|
2484
2537
|
return () => {
|
|
2485
2538
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
2486
2539
|
};
|
|
2487
2540
|
}, []);
|
|
2488
|
-
const
|
|
2489
|
-
|
|
2490
|
-
setCopied(true);
|
|
2541
|
+
const showFeedback = (nextStage) => {
|
|
2542
|
+
setStage(nextStage);
|
|
2491
2543
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
2492
|
-
timeoutRef.current = setTimeout(() =>
|
|
2544
|
+
timeoutRef.current = setTimeout(() => setStage(COPY_STAGE.idle), TIMING.feedbackHold);
|
|
2493
2545
|
};
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2546
|
+
const handleCopy = async () => {
|
|
2547
|
+
const requestId = ++requestIdRef.current;
|
|
2548
|
+
try {
|
|
2549
|
+
await navigator.clipboard.writeText(value);
|
|
2550
|
+
if (requestId === requestIdRef.current) showFeedback(COPY_STAGE.copied);
|
|
2551
|
+
} catch {
|
|
2552
|
+
if (requestId === requestIdRef.current) showFeedback(COPY_STAGE.error);
|
|
2553
|
+
}
|
|
2554
|
+
};
|
|
2555
|
+
let ariaLabel = label || "Copy to clipboard";
|
|
2556
|
+
let announcement = "";
|
|
2557
|
+
if (stage === COPY_STAGE.copied) {
|
|
2558
|
+
ariaLabel = "Copied";
|
|
2559
|
+
announcement = "Copied to clipboard";
|
|
2560
|
+
} else if (stage === COPY_STAGE.error) {
|
|
2561
|
+
ariaLabel = "Copy failed";
|
|
2562
|
+
announcement = "Copy failed";
|
|
2563
|
+
}
|
|
2564
|
+
let iconTransition = ICON.spring;
|
|
2565
|
+
let labelTransition = LABEL.spring;
|
|
2566
|
+
if (stage === COPY_STAGE.idle) {
|
|
2567
|
+
iconTransition = RESET_TRANSITION;
|
|
2568
|
+
labelTransition = RESET_TRANSITION;
|
|
2569
|
+
}
|
|
2570
|
+
if (shouldReduceMotion) {
|
|
2571
|
+
iconTransition = REDUCED_MOTION_TRANSITION;
|
|
2572
|
+
labelTransition = REDUCED_MOTION_TRANSITION;
|
|
2573
|
+
}
|
|
2574
|
+
const visualStates = [
|
|
2575
|
+
{
|
|
2576
|
+
icon: /* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
2577
|
+
icon: Copy01Icon,
|
|
2578
|
+
size: 14
|
|
2579
|
+
}),
|
|
2580
|
+
label,
|
|
2581
|
+
stage: COPY_STAGE.idle
|
|
2582
|
+
},
|
|
2583
|
+
{
|
|
2584
|
+
icon: /* @__PURE__ */ jsx(CheckIcon, {
|
|
2585
|
+
size: 14,
|
|
2586
|
+
strokeWidth: 2
|
|
2587
|
+
}),
|
|
2588
|
+
label: label ? "Copied" : void 0,
|
|
2589
|
+
stage: COPY_STAGE.copied
|
|
2590
|
+
},
|
|
2591
|
+
{
|
|
2592
|
+
icon: /* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
2593
|
+
icon: AlertCircleIcon,
|
|
2594
|
+
size: 14
|
|
2595
|
+
}),
|
|
2596
|
+
label: label ? "Failed" : void 0,
|
|
2597
|
+
stage: COPY_STAGE.error
|
|
2598
|
+
}
|
|
2599
|
+
];
|
|
2600
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
2497
2601
|
variant,
|
|
2498
2602
|
size,
|
|
2499
2603
|
onClick: handleCopy,
|
|
2500
2604
|
"aria-label": ariaLabel,
|
|
2501
|
-
className: cn("
|
|
2502
|
-
children: /* @__PURE__ */ jsx(
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
children:
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
transition: spring$2,
|
|
2538
|
-
className: "flex items-center gap-1.5",
|
|
2539
|
-
children: [/* @__PURE__ */ jsx(HugeiconsIcon, {
|
|
2540
|
-
icon: Copy01Icon,
|
|
2541
|
-
size: 14
|
|
2542
|
-
}), label && /* @__PURE__ */ jsx("span", { children: label })]
|
|
2543
|
-
}, "copy")
|
|
2544
|
-
})
|
|
2605
|
+
className: cn(stage === COPY_STAGE.copied && "text-[var(--text-success)]", stage === COPY_STAGE.error && "text-[var(--text-danger)]", className),
|
|
2606
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2607
|
+
"aria-hidden": "true",
|
|
2608
|
+
className: "grid items-center",
|
|
2609
|
+
children: visualStates.map((visualState) => {
|
|
2610
|
+
const isActive = stage === visualState.stage;
|
|
2611
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
2612
|
+
className: "col-start-1 row-start-1 flex items-center gap-1.5",
|
|
2613
|
+
children: [/* @__PURE__ */ jsx(motion.span, {
|
|
2614
|
+
initial: false,
|
|
2615
|
+
animate: {
|
|
2616
|
+
opacity: isActive ? 1 : 0,
|
|
2617
|
+
scale: isActive ? ICON.activeScale : ICON.inactiveScale
|
|
2618
|
+
},
|
|
2619
|
+
transition: iconTransition,
|
|
2620
|
+
style: animationStyle,
|
|
2621
|
+
className: "flex items-center",
|
|
2622
|
+
children: visualState.icon
|
|
2623
|
+
}), visualState.label && /* @__PURE__ */ jsx(motion.span, {
|
|
2624
|
+
initial: false,
|
|
2625
|
+
style: animationStyle,
|
|
2626
|
+
animate: {
|
|
2627
|
+
opacity: isActive ? 1 : 0,
|
|
2628
|
+
y: isActive ? LABEL.activeOffset : LABEL.inactiveOffset
|
|
2629
|
+
},
|
|
2630
|
+
transition: labelTransition,
|
|
2631
|
+
children: visualState.label
|
|
2632
|
+
})]
|
|
2633
|
+
}, visualState.stage);
|
|
2634
|
+
})
|
|
2635
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2636
|
+
"aria-live": "polite",
|
|
2637
|
+
className: "sr-only",
|
|
2638
|
+
role: "status",
|
|
2639
|
+
children: announcement
|
|
2640
|
+
})]
|
|
2545
2641
|
});
|
|
2546
2642
|
};
|
|
2547
2643
|
|