@justanarthur/modo-ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/LICENSE.beui +21 -0
- package/LICENSE.fluid-functionalism +21 -0
- package/LICENSE.motion-primitives +21 -0
- package/LICENSE.sileo +21 -0
- package/README.md +608 -2
- package/dist/base.css +994 -0
- package/dist/blocks/sidebar-app/index.d.ts +34 -0
- package/dist/blocks/sidebar-app/index.js +34 -0
- package/dist/components/badge/index.d.ts +59 -0
- package/dist/components/badge/index.js +18 -0
- package/dist/components/button/index.d.ts +59 -0
- package/dist/components/button/index.js +16 -0
- package/dist/components/card/index.d.ts +141 -0
- package/dist/components/card/index.js +44 -0
- package/dist/components/inputs/checkbox-group/index.d.ts +50 -0
- package/dist/components/inputs/checkbox-group/index.js +23 -0
- package/dist/components/inputs/color-picker/index.d.ts +137 -0
- package/dist/components/inputs/color-picker/index.js +37 -0
- package/dist/components/inputs/combobox/index.d.ts +161 -0
- package/dist/components/inputs/combobox/index.js +41 -0
- package/dist/components/inputs/date-time/calendar/index.d.ts +45 -0
- package/dist/components/inputs/date-time/calendar/index.js +20 -0
- package/dist/components/inputs/date-time/date-picker/index.d.ts +82 -0
- package/dist/components/inputs/date-time/date-picker/index.js +34 -0
- package/dist/components/inputs/date-time/date-range-picker/index.d.ts +64 -0
- package/dist/components/inputs/date-time/date-range-picker/index.js +33 -0
- package/dist/components/inputs/date-time/duration-picker/index.d.ts +57 -0
- package/dist/components/inputs/date-time/duration-picker/index.js +33 -0
- package/dist/components/inputs/date-time/month-picker/index.d.ts +57 -0
- package/dist/components/inputs/date-time/month-picker/index.js +32 -0
- package/dist/components/inputs/date-time/time-picker/index.d.ts +59 -0
- package/dist/components/inputs/date-time/time-picker/index.js +33 -0
- package/dist/components/inputs/input/index.d.ts +84 -0
- package/dist/components/inputs/input/index.js +20 -0
- package/dist/components/inputs/input-copy/index.d.ts +44 -0
- package/dist/components/inputs/input-copy/index.js +18 -0
- package/dist/components/inputs/input-message/index.d.ts +125 -0
- package/dist/components/inputs/input-message/index.js +27 -0
- package/dist/components/inputs/radio-group/index.d.ts +58 -0
- package/dist/components/inputs/radio-group/index.js +22 -0
- package/dist/components/inputs/search/index.d.ts +83 -0
- package/dist/components/inputs/search/index.js +28 -0
- package/dist/components/inputs/select/index.d.ts +105 -0
- package/dist/components/inputs/select/index.js +37 -0
- package/dist/components/inputs/slider/index.d.ts +108 -0
- package/dist/components/inputs/slider/index.js +16 -0
- package/dist/components/inputs/switch/index.d.ts +43 -0
- package/dist/components/inputs/switch/index.js +16 -0
- package/dist/components/navigation/accordion/index.d.ts +117 -0
- package/dist/components/navigation/accordion/index.js +30 -0
- package/dist/components/navigation/sidebar/index.d.ts +388 -0
- package/dist/components/navigation/sidebar/index.js +101 -0
- package/dist/components/navigation/tabs/index.d.ts +70 -0
- package/dist/components/navigation/tabs/index.js +25 -0
- package/dist/components/navigation/tabs-subtle/index.d.ts +73 -0
- package/dist/components/navigation/tabs-subtle/index.js +23 -0
- package/dist/components/overlays/alert-dialog/index.d.ts +67 -0
- package/dist/components/overlays/alert-dialog/index.js +24 -0
- package/dist/components/overlays/command/index.d.ts +121 -0
- package/dist/components/overlays/command/index.js +39 -0
- package/dist/components/overlays/context-menu/index.d.ts +97 -0
- package/dist/components/overlays/context-menu/index.js +32 -0
- package/dist/components/overlays/dialog/index.d.ts +130 -0
- package/dist/components/overlays/dialog/index.js +39 -0
- package/dist/components/overlays/dropdown/index.d.ts +222 -0
- package/dist/components/overlays/dropdown/index.js +47 -0
- package/dist/components/overlays/popover/index.d.ts +87 -0
- package/dist/components/overlays/popover/index.js +28 -0
- package/dist/components/overlays/preview-card/index.d.ts +75 -0
- package/dist/components/overlays/preview-card/index.js +21 -0
- package/dist/components/overlays/sheet/index.d.ts +67 -0
- package/dist/components/overlays/sheet/index.js +26 -0
- package/dist/components/overlays/toast/index.d.ts +107 -0
- package/dist/components/overlays/toast/index.js +23 -0
- package/dist/components/overlays/tooltip/index.d.ts +75 -0
- package/dist/components/overlays/tooltip/index.js +19 -0
- package/dist/components/table/index.d.ts +44 -0
- package/dist/components/table/index.js +28 -0
- package/dist/components/thinking-indicator/index.d.ts +32 -0
- package/dist/components/thinking-indicator/index.js +15 -0
- package/dist/index.d.ts +3926 -0
- package/dist/index.js +513 -0
- package/dist/preset.d.ts +104 -0
- package/dist/preset.js +124 -0
- package/dist/primitives/code/index.d.ts +23 -0
- package/dist/primitives/code/index.js +12 -0
- package/dist/primitives/craft/index.d.ts +31 -0
- package/dist/primitives/craft/index.js +13 -0
- package/dist/primitives/fluid-hover/index.d.ts +233 -0
- package/dist/primitives/fluid-hover/index.js +27 -0
- package/dist/primitives/morph/index.d.ts +127 -0
- package/dist/primitives/morph/index.js +21 -0
- package/dist/primitives/motion/index.d.ts +115 -0
- package/dist/primitives/motion/index.js +20 -0
- package/dist/primitives/scroll-area/index.d.ts +41 -0
- package/dist/primitives/scroll-area/index.js +13 -0
- package/dist/primitives/sizes/index.d.ts +128 -0
- package/dist/primitives/sizes/index.js +22 -0
- package/dist/primitives/surface/index.d.ts +69 -0
- package/dist/primitives/surface/index.js +18 -0
- package/dist/shared/components-0f0as45n.js +17 -0
- package/dist/shared/components-40j34hdb.js +986 -0
- package/dist/shared/components-4hh0gm0v.js +292 -0
- package/dist/shared/components-4xxddc44.js +15 -0
- package/dist/shared/components-4xxtggzp.js +110 -0
- package/dist/shared/components-54nf2x99.js +293 -0
- package/dist/shared/components-5pkcfprd.js +232 -0
- package/dist/shared/components-5vxtcp88.js +9 -0
- package/dist/shared/components-5zry9te1.js +152 -0
- package/dist/shared/components-61ckf42z.js +220 -0
- package/dist/shared/components-6hzwfmfd.js +58 -0
- package/dist/shared/components-6phwsry6.js +361 -0
- package/dist/shared/components-6t6nr33r.js +86 -0
- package/dist/shared/components-6y1th6k4.js +111 -0
- package/dist/shared/components-74c20v2f.js +32 -0
- package/dist/shared/components-7cqq1sqy.js +193 -0
- package/dist/shared/components-7gv95yfy.js +496 -0
- package/dist/shared/components-7nww01w4.js +375 -0
- package/dist/shared/components-7zp99w5d.js +62 -0
- package/dist/shared/components-8hk9ve3r.js +1200 -0
- package/dist/shared/components-8hzbsfbd.js +123 -0
- package/dist/shared/components-9p8s8n5q.js +171 -0
- package/dist/shared/components-aaq3yk4f.js +304 -0
- package/dist/shared/components-bf2d9k02.js +484 -0
- package/dist/shared/components-bkvb6nem.js +63 -0
- package/dist/shared/components-brnzrp2t.js +262 -0
- package/dist/shared/components-csxz9f52.js +42 -0
- package/dist/shared/components-de8xsm9y.js +22 -0
- package/dist/shared/components-dg0w8g5p.js +26 -0
- package/dist/shared/components-dphg9gjr.js +42 -0
- package/dist/shared/components-e46kf6cp.js +298 -0
- package/dist/shared/components-ed7cmssr.js +105 -0
- package/dist/shared/components-ess3ch6w.js +137 -0
- package/dist/shared/components-gjfrycb5.js +984 -0
- package/dist/shared/components-gndm6am4.js +128 -0
- package/dist/shared/components-hjkrv00c.js +191 -0
- package/dist/shared/components-hzfp4tjb.js +270 -0
- package/dist/shared/components-j65qt1mq.js +719 -0
- package/dist/shared/components-jw16snbn.js +19 -0
- package/dist/shared/components-jxgznftn.js +146 -0
- package/dist/shared/components-kf2ehztc.js +216 -0
- package/dist/shared/components-kpbcms10.js +9 -0
- package/dist/shared/components-m5br529r.js +141 -0
- package/dist/shared/components-nn6xezy2.js +1828 -0
- package/dist/shared/components-nnnd2xef.js +9 -0
- package/dist/shared/components-p2vmyfe1.js +345 -0
- package/dist/shared/components-peg09pzs.js +79 -0
- package/dist/shared/components-r22vtgqc.js +45 -0
- package/dist/shared/components-r2gke5p6.js +1759 -0
- package/dist/shared/components-r43mqnd6.js +160 -0
- package/dist/shared/components-r4jt6hgd.js +58 -0
- package/dist/shared/components-rc63qsy6.js +159 -0
- package/dist/shared/components-s3yfvfkr.js +149 -0
- package/dist/shared/components-s5pkbjx1.js +445 -0
- package/dist/shared/components-tad5h7ta.js +346 -0
- package/dist/shared/components-taxmgbnh.js +120 -0
- package/dist/shared/components-tm88ghva.js +215 -0
- package/dist/shared/components-v7es8aan.js +144 -0
- package/dist/shared/components-vb033rns.js +28 -0
- package/dist/shared/components-vc1k7yv2.js +30 -0
- package/dist/shared/components-vktws5r6.js +667 -0
- package/dist/shared/components-x2xyckd5.js +198 -0
- package/dist/shared/components-x3rz4cyn.js +61 -0
- package/dist/shared/components-xszag63d.js +141 -0
- package/dist/shared/components-y3cqdrgy.js +291 -0
- package/dist/shared/components-zvb11ker.js +288 -0
- package/dist/shared/components-zx2hr57f.js +124 -0
- package/dist/styles.css +1949 -0
- package/dist/tailwind.css +219 -0
- package/dist/tokens.css +345 -0
- package/package.json +102 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// lib/reduced-motion.ts
|
|
2
|
+
import { useReducedMotion, useReducedMotionConfig } from "motion/react";
|
|
3
|
+
function useReduceMotion() {
|
|
4
|
+
const os = useReducedMotion() ?? false;
|
|
5
|
+
const config = useReducedMotionConfig() ?? false;
|
|
6
|
+
return os || config;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { useReduceMotion };
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Tooltip
|
|
3
|
+
} from "./components-gndm6am4.js";
|
|
4
|
+
import {
|
|
5
|
+
useIcon
|
|
6
|
+
} from "./components-m5br529r.js";
|
|
7
|
+
import {
|
|
8
|
+
GooFilter
|
|
9
|
+
} from "./components-jxgznftn.js";
|
|
10
|
+
import {
|
|
11
|
+
useShape
|
|
12
|
+
} from "./components-7zp99w5d.js";
|
|
13
|
+
import {
|
|
14
|
+
GOO_BLUR_RATIO
|
|
15
|
+
} from "./components-7nww01w4.js";
|
|
16
|
+
import {
|
|
17
|
+
useReduceMotion
|
|
18
|
+
} from "./components-nnnd2xef.js";
|
|
19
|
+
import {
|
|
20
|
+
spring
|
|
21
|
+
} from "./components-vc1k7yv2.js";
|
|
22
|
+
import {
|
|
23
|
+
useSize
|
|
24
|
+
} from "./components-x3rz4cyn.js";
|
|
25
|
+
import {
|
|
26
|
+
cn
|
|
27
|
+
} from "./components-0f0as45n.js";
|
|
28
|
+
|
|
29
|
+
// components/inputs/input-copy/index.tsx
|
|
30
|
+
import { AnimatePresence, animate, motion, useMotionValue } from "motion/react";
|
|
31
|
+
import {
|
|
32
|
+
forwardRef,
|
|
33
|
+
useCallback,
|
|
34
|
+
useEffect,
|
|
35
|
+
useId,
|
|
36
|
+
useLayoutEffect,
|
|
37
|
+
useRef,
|
|
38
|
+
useState
|
|
39
|
+
} from "react";
|
|
40
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
41
|
+
var GLYPH = 14;
|
|
42
|
+
var DISC = 20;
|
|
43
|
+
var UNIT = GLYPH / 24;
|
|
44
|
+
var sheet = (at) => ({ x: at * UNIT, y: at * UNIT, w: 14 * UNIT, h: 14 * UNIT, r: 2 * UNIT });
|
|
45
|
+
var BACK = sheet(2);
|
|
46
|
+
var FRONT = sheet(8);
|
|
47
|
+
var DISC_RECT = { x: (GLYPH - DISC) / 2, y: (GLYPH - DISC) / 2, w: DISC, h: DISC, r: DISC / 2 };
|
|
48
|
+
var BLUR = DISC / 2 * GOO_BLUR_RATIO;
|
|
49
|
+
var LAYER = { at: DISC_RECT.x - BLUR * 3, size: DISC + BLUR * 6 };
|
|
50
|
+
var TONE_BG = { copied: "bg-status-success", error: "bg-status-error" };
|
|
51
|
+
var TONE_TEXT = { copied: "text-status-success", error: "text-status-error" };
|
|
52
|
+
var CHECK_STROKE = {
|
|
53
|
+
icon: "[&_svg]:stroke-[1.5] [&_svg]:transition-[stroke-width] [&_svg]:duration-fast group-hover:[&_svg]:stroke-[2]",
|
|
54
|
+
button: "[&_svg]:stroke-[2]"
|
|
55
|
+
};
|
|
56
|
+
var { exit: _exit, ...enter } = spring.slow;
|
|
57
|
+
function placeSheet(el, a, b, p) {
|
|
58
|
+
if (!el)
|
|
59
|
+
return;
|
|
60
|
+
const lerp = (from, to) => from + (to - from) * p;
|
|
61
|
+
const w = Math.max(0, lerp(a.w, b.w));
|
|
62
|
+
const h = Math.max(0, lerp(a.h, b.h));
|
|
63
|
+
el.style.left = `${lerp(a.x, b.x) - LAYER.at}px`;
|
|
64
|
+
el.style.top = `${lerp(a.y, b.y) - LAYER.at}px`;
|
|
65
|
+
el.style.width = `${w}px`;
|
|
66
|
+
el.style.height = `${h}px`;
|
|
67
|
+
el.style.borderRadius = `${Math.min(Math.max(0, lerp(a.r, b.r)), w / 2, h / 2)}px`;
|
|
68
|
+
}
|
|
69
|
+
function CopyDisc({ status }) {
|
|
70
|
+
const layer = useRef(null);
|
|
71
|
+
const back = useRef(null);
|
|
72
|
+
const front = useRef(null);
|
|
73
|
+
const progress = useMotionValue(0);
|
|
74
|
+
const reduced = useReduceMotion();
|
|
75
|
+
const gooId = `copy-goo-${useId().replace(/:/g, "")}`;
|
|
76
|
+
const tone = useRef("copied");
|
|
77
|
+
const on = status !== "idle";
|
|
78
|
+
if (on)
|
|
79
|
+
tone.current = status;
|
|
80
|
+
useLayoutEffect(() => {
|
|
81
|
+
if (!on && progress.get() === 0)
|
|
82
|
+
return;
|
|
83
|
+
const render = (p) => {
|
|
84
|
+
if (layer.current)
|
|
85
|
+
layer.current.style.visibility = p > 0 ? "visible" : "hidden";
|
|
86
|
+
placeSheet(back.current, BACK, DISC_RECT, p);
|
|
87
|
+
placeSheet(front.current, FRONT, DISC_RECT, p);
|
|
88
|
+
};
|
|
89
|
+
const target = on ? 1 : 0;
|
|
90
|
+
if (reduced) {
|
|
91
|
+
progress.jump(target);
|
|
92
|
+
return render(target);
|
|
93
|
+
}
|
|
94
|
+
const controls = animate(progress, target, { ...on ? enter : spring.slow.exit, onUpdate: render });
|
|
95
|
+
return () => controls.stop();
|
|
96
|
+
}, [on, reduced]);
|
|
97
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
98
|
+
"aria-hidden": true,
|
|
99
|
+
className: "pointer-events-none absolute",
|
|
100
|
+
style: { left: LAYER.at, top: LAYER.at, width: LAYER.size, height: LAYER.size },
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ jsx(GooFilter, {
|
|
103
|
+
id: gooId,
|
|
104
|
+
blur: BLUR
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ jsxs("span", {
|
|
107
|
+
ref: layer,
|
|
108
|
+
className: "invisible absolute inset-0 opacity-16",
|
|
109
|
+
style: { filter: `url(#${gooId})` },
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx("span", {
|
|
112
|
+
ref: back,
|
|
113
|
+
className: cn("absolute", TONE_BG[tone.current])
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ jsx("span", {
|
|
116
|
+
ref: front,
|
|
117
|
+
className: cn("absolute", TONE_BG[tone.current])
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
var CHECK_PATH = "M6 12L10 16L18 8";
|
|
125
|
+
var ERROR_PATH = "M9 9L15 15M15 9L9 15";
|
|
126
|
+
function CopyGlyph({
|
|
127
|
+
status,
|
|
128
|
+
copyCount,
|
|
129
|
+
variant,
|
|
130
|
+
CopyIcon
|
|
131
|
+
}) {
|
|
132
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
133
|
+
className: "relative flex size-3.5 shrink-0 items-center justify-center",
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ jsx(CopyDisc, {
|
|
136
|
+
status
|
|
137
|
+
}),
|
|
138
|
+
/* @__PURE__ */ jsx(AnimatePresence, {
|
|
139
|
+
initial: false,
|
|
140
|
+
children: status === "idle" ? /* @__PURE__ */ jsx(motion.span, {
|
|
141
|
+
initial: { opacity: 0, scale: 0.8 },
|
|
142
|
+
animate: { opacity: 1, scale: 1 },
|
|
143
|
+
exit: { opacity: 0, scale: 0.8, transition: spring.fast.exit },
|
|
144
|
+
transition: spring.fast,
|
|
145
|
+
className: "absolute inset-0 flex items-center justify-center",
|
|
146
|
+
children: /* @__PURE__ */ jsx(CopyIcon, {
|
|
147
|
+
size: 14,
|
|
148
|
+
strokeWidth: 1.5,
|
|
149
|
+
className: "transition-[stroke-width] duration-fast group-hover:stroke-[2]"
|
|
150
|
+
})
|
|
151
|
+
}, "copy") : /* @__PURE__ */ jsx(motion.span, {
|
|
152
|
+
initial: { opacity: 0, scale: 0.6 },
|
|
153
|
+
animate: { opacity: 1, scale: 1 },
|
|
154
|
+
exit: { opacity: 0, scale: 0.8, transition: spring.fast.exit },
|
|
155
|
+
transition: spring.fast,
|
|
156
|
+
className: cn("absolute inset-0 flex items-center justify-center", TONE_TEXT[status], CHECK_STROKE[variant]),
|
|
157
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
158
|
+
width: 14,
|
|
159
|
+
height: 14,
|
|
160
|
+
viewBox: "2 4 20 16",
|
|
161
|
+
fill: "none",
|
|
162
|
+
stroke: "currentColor",
|
|
163
|
+
strokeLinecap: "round",
|
|
164
|
+
strokeLinejoin: "round",
|
|
165
|
+
children: /* @__PURE__ */ jsx(motion.path, {
|
|
166
|
+
d: status === "error" ? ERROR_PATH : CHECK_PATH,
|
|
167
|
+
initial: { pathLength: 0 },
|
|
168
|
+
animate: {
|
|
169
|
+
pathLength: 1,
|
|
170
|
+
transition: { duration: spring.fast.duration, ease: "easeOut" }
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
}, `${status}-${copyCount}`)
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
var InputCopy = forwardRef(({ value, label, onCopy, disabled, variant = "icon", align = "right", size, className, ...props }, ref) => {
|
|
180
|
+
const CopyIcon = useIcon("copy");
|
|
181
|
+
const [status, setStatus] = useState("idle");
|
|
182
|
+
const [copyCount, setCopyCount] = useState(0);
|
|
183
|
+
const [tooltipState, setTooltipState] = useState("idle");
|
|
184
|
+
const timeoutRef = useRef(null);
|
|
185
|
+
const tooltipVisibleRef = useRef(false);
|
|
186
|
+
const tooltipWasVisibleRef = useRef(false);
|
|
187
|
+
const shape = useShape();
|
|
188
|
+
const sizeClasses = useSize(size);
|
|
189
|
+
const rowPy = sizeClasses.variant === "compact" ? "py-1" : "py-2";
|
|
190
|
+
const generatedId = useId();
|
|
191
|
+
const labelId = label ? `${generatedId}-label` : undefined;
|
|
192
|
+
const buttonId = `${generatedId}-button`;
|
|
193
|
+
const handlePointerDown = useCallback(() => {
|
|
194
|
+
tooltipWasVisibleRef.current = tooltipVisibleRef.current;
|
|
195
|
+
}, []);
|
|
196
|
+
const copyViaExecCommand = useCallback(() => {
|
|
197
|
+
const textarea = document.createElement("textarea");
|
|
198
|
+
textarea.value = value;
|
|
199
|
+
textarea.setAttribute("readonly", "");
|
|
200
|
+
textarea.style.position = "fixed";
|
|
201
|
+
textarea.style.opacity = "0";
|
|
202
|
+
document.body.appendChild(textarea);
|
|
203
|
+
textarea.select();
|
|
204
|
+
let ok = false;
|
|
205
|
+
try {
|
|
206
|
+
ok = document.execCommand("copy");
|
|
207
|
+
} catch {
|
|
208
|
+
ok = false;
|
|
209
|
+
}
|
|
210
|
+
document.body.removeChild(textarea);
|
|
211
|
+
return ok;
|
|
212
|
+
}, [value]);
|
|
213
|
+
const handleCopy = useCallback(async () => {
|
|
214
|
+
if (disabled)
|
|
215
|
+
return;
|
|
216
|
+
let ok = true;
|
|
217
|
+
try {
|
|
218
|
+
await navigator.clipboard.writeText(value);
|
|
219
|
+
} catch {
|
|
220
|
+
ok = copyViaExecCommand();
|
|
221
|
+
}
|
|
222
|
+
setStatus(ok ? "copied" : "error");
|
|
223
|
+
setCopyCount((c) => c + 1);
|
|
224
|
+
setTooltipState(tooltipWasVisibleRef.current ? "copied" : "suppressed");
|
|
225
|
+
if (ok)
|
|
226
|
+
onCopy?.();
|
|
227
|
+
if (timeoutRef.current)
|
|
228
|
+
clearTimeout(timeoutRef.current);
|
|
229
|
+
timeoutRef.current = setTimeout(() => {
|
|
230
|
+
setStatus("idle");
|
|
231
|
+
setTooltipState("suppressed");
|
|
232
|
+
}, 2000);
|
|
233
|
+
}, [value, disabled, onCopy, copyViaExecCommand]);
|
|
234
|
+
const handleTooltipOpenChange = useCallback((open) => {
|
|
235
|
+
tooltipVisibleRef.current = open;
|
|
236
|
+
}, []);
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
return () => {
|
|
239
|
+
if (timeoutRef.current)
|
|
240
|
+
clearTimeout(timeoutRef.current);
|
|
241
|
+
};
|
|
242
|
+
}, []);
|
|
243
|
+
const handleMouseEnter = useCallback(() => {
|
|
244
|
+
setTooltipState((prev) => prev === "suppressed" ? "idle" : prev);
|
|
245
|
+
}, []);
|
|
246
|
+
const handleMouseLeave = useCallback(() => {
|
|
247
|
+
setTooltipState((prev) => prev === "copied" ? "suppressed" : prev);
|
|
248
|
+
}, []);
|
|
249
|
+
const actionElement = variant === "button" ? /* @__PURE__ */ jsxs("span", {
|
|
250
|
+
className: cn("shrink-0 flex items-center gap-1.5 px-1.5 transition-colors duration-fast", rowPy, sizeClasses.text, "text-muted-foreground group-hover:text-foreground", "weight-normal"),
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ jsx(CopyGlyph, {
|
|
253
|
+
status,
|
|
254
|
+
copyCount,
|
|
255
|
+
variant: "button",
|
|
256
|
+
CopyIcon
|
|
257
|
+
}),
|
|
258
|
+
/* @__PURE__ */ jsxs("span", {
|
|
259
|
+
className: "select-none inline-grid text-left",
|
|
260
|
+
children: [
|
|
261
|
+
/* @__PURE__ */ jsx("span", {
|
|
262
|
+
className: "col-start-1 row-start-1 invisible",
|
|
263
|
+
"aria-hidden": "true",
|
|
264
|
+
children: "Copied"
|
|
265
|
+
}),
|
|
266
|
+
/* @__PURE__ */ jsx(AnimatePresence, {
|
|
267
|
+
mode: "wait",
|
|
268
|
+
initial: false,
|
|
269
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
270
|
+
className: cn("col-start-1 row-start-1", status === "error" && "text-destructive"),
|
|
271
|
+
initial: { opacity: 0, scale: 0.6 },
|
|
272
|
+
animate: { opacity: 1, scale: 1 },
|
|
273
|
+
exit: { opacity: 0, scale: 0.8, transition: spring.fast.exit },
|
|
274
|
+
transition: spring.fast,
|
|
275
|
+
children: status === "copied" ? "Copied" : status === "error" ? "Failed" : "Copy"
|
|
276
|
+
}, status)
|
|
277
|
+
})
|
|
278
|
+
]
|
|
279
|
+
})
|
|
280
|
+
]
|
|
281
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
282
|
+
className: cn("shrink-0 flex px-1.5 transition-colors duration-fast", rowPy, "text-muted-foreground group-hover:text-foreground"),
|
|
283
|
+
children: /* @__PURE__ */ jsx(CopyGlyph, {
|
|
284
|
+
status,
|
|
285
|
+
copyCount,
|
|
286
|
+
variant: "icon",
|
|
287
|
+
CopyIcon
|
|
288
|
+
})
|
|
289
|
+
});
|
|
290
|
+
const valueElement = /* @__PURE__ */ jsx("span", {
|
|
291
|
+
className: cn("flex-1 min-w-0 text-left text-foreground font-mono select-none truncate", sizeClasses.text, rowPy, align === "left" ? "pl-1" : "pl-0", "weight-normal"),
|
|
292
|
+
children: /* @__PURE__ */ jsx("mark", {
|
|
293
|
+
className: "bg-transparent text-foreground transition-colors duration-fast group-hover:bg-brand/20 group-hover:text-foreground",
|
|
294
|
+
children: value
|
|
295
|
+
})
|
|
296
|
+
});
|
|
297
|
+
const buttonContent = align === "left" ? /* @__PURE__ */ jsxs(Fragment, {
|
|
298
|
+
children: [
|
|
299
|
+
actionElement,
|
|
300
|
+
valueElement
|
|
301
|
+
]
|
|
302
|
+
}) : /* @__PURE__ */ jsxs(Fragment, {
|
|
303
|
+
children: [
|
|
304
|
+
valueElement,
|
|
305
|
+
actionElement
|
|
306
|
+
]
|
|
307
|
+
});
|
|
308
|
+
const button = /* @__PURE__ */ jsx("button", {
|
|
309
|
+
id: buttonId,
|
|
310
|
+
type: "button",
|
|
311
|
+
onPointerDown: handlePointerDown,
|
|
312
|
+
onClick: handleCopy,
|
|
313
|
+
disabled,
|
|
314
|
+
"aria-label": status === "copied" ? "Copied" : status === "error" ? "Copy failed" : label ? "Copy" : "Copy to clipboard",
|
|
315
|
+
"aria-labelledby": label ? `${buttonId} ${labelId}` : undefined,
|
|
316
|
+
className: cn("group flex items-center w-full cursor-pointer outline-none transition-all duration-fast", "focus-visible:ring-1 focus-visible:ring-focus-ring", shape.input),
|
|
317
|
+
children: buttonContent
|
|
318
|
+
});
|
|
319
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
320
|
+
ref,
|
|
321
|
+
className: cn("flex flex-col gap-0.5", disabled && "opacity-50 pointer-events-none", className),
|
|
322
|
+
onMouseEnter: handleMouseEnter,
|
|
323
|
+
onMouseLeave: handleMouseLeave,
|
|
324
|
+
...props,
|
|
325
|
+
children: [
|
|
326
|
+
label && /* @__PURE__ */ jsx("span", {
|
|
327
|
+
id: labelId,
|
|
328
|
+
className: cn("text-muted-foreground", sizeClasses.text, align === "left" ? "pl-1" : "pl-0", "weight-normal"),
|
|
329
|
+
children: label
|
|
330
|
+
}),
|
|
331
|
+
variant === "icon" ? /* @__PURE__ */ jsx(Tooltip, {
|
|
332
|
+
content: tooltipState === "idle" ? "Copy to clipboard" : status === "error" ? "Copy failed" : "Copied",
|
|
333
|
+
delayDuration: 500,
|
|
334
|
+
sideOffset: 2,
|
|
335
|
+
forceOpen: tooltipState === "copied" ? true : tooltipState === "suppressed" ? false : undefined,
|
|
336
|
+
onOpenChange: handleTooltipOpenChange,
|
|
337
|
+
children: button
|
|
338
|
+
}) : button
|
|
339
|
+
]
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
InputCopy.displayName = "InputCopy";
|
|
343
|
+
var input_copy_default = InputCopy;
|
|
344
|
+
|
|
345
|
+
export { InputCopy, input_copy_default };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
button_default
|
|
3
|
+
} from "./components-5pkcfprd.js";
|
|
4
|
+
import {
|
|
5
|
+
useControllableState
|
|
6
|
+
} from "./components-dg0w8g5p.js";
|
|
7
|
+
import {
|
|
8
|
+
spring
|
|
9
|
+
} from "./components-vc1k7yv2.js";
|
|
10
|
+
import {
|
|
11
|
+
cn
|
|
12
|
+
} from "./components-0f0as45n.js";
|
|
13
|
+
|
|
14
|
+
// primitives/motion/index.tsx
|
|
15
|
+
import { MotionConfig, motion } from "motion/react";
|
|
16
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
function Motion({
|
|
18
|
+
tier = "moderate",
|
|
19
|
+
show,
|
|
20
|
+
defaultShow = true,
|
|
21
|
+
onShowChange,
|
|
22
|
+
sameExit = false,
|
|
23
|
+
reducedMotion = "user",
|
|
24
|
+
className,
|
|
25
|
+
children
|
|
26
|
+
}) {
|
|
27
|
+
const [shown, setShown] = useControllableState(show, defaultShow, onShowChange);
|
|
28
|
+
const enter = spring[tier];
|
|
29
|
+
const leave = sameExit ? enter : enter.exit;
|
|
30
|
+
return /* @__PURE__ */ jsx(MotionConfig, {
|
|
31
|
+
reducedMotion,
|
|
32
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
33
|
+
className: cn("flex flex-col items-center gap-3", className),
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ jsx(motion.div, {
|
|
36
|
+
initial: false,
|
|
37
|
+
"aria-hidden": shown ? undefined : true,
|
|
38
|
+
animate: shown ? { opacity: 1, scale: 1, y: 0, visibility: "visible", transition: enter } : {
|
|
39
|
+
opacity: 0,
|
|
40
|
+
scale: 0.95,
|
|
41
|
+
y: 6,
|
|
42
|
+
visibility: "visible",
|
|
43
|
+
transition: leave,
|
|
44
|
+
transitionEnd: { visibility: "hidden" }
|
|
45
|
+
},
|
|
46
|
+
children
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsxs("div", {
|
|
49
|
+
className: "flex flex-wrap items-center justify-center gap-x-2 gap-y-1",
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsx(button_default, {
|
|
52
|
+
variant: "tertiary",
|
|
53
|
+
size: "compact",
|
|
54
|
+
"aria-pressed": shown,
|
|
55
|
+
"aria-label": `${shown ? "Hide" : "Show"} (spring.${tier})`,
|
|
56
|
+
onClick: () => setShown((v) => !v),
|
|
57
|
+
children: shown ? "Hide" : "Show"
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ jsxs("span", {
|
|
60
|
+
className: "font-mono text-caption-compact text-muted-foreground",
|
|
61
|
+
children: [
|
|
62
|
+
"spring.",
|
|
63
|
+
tier,
|
|
64
|
+
" ",
|
|
65
|
+
enter.duration,
|
|
66
|
+
"s",
|
|
67
|
+
enter.bounce ? ` bounce ${enter.bounce}` : "",
|
|
68
|
+
" · exit ",
|
|
69
|
+
leave.duration,
|
|
70
|
+
"s"
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export { Motion };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GooIndicator
|
|
3
|
+
} from "./components-kf2ehztc.js";
|
|
4
|
+
import {
|
|
5
|
+
spring
|
|
6
|
+
} from "./components-vc1k7yv2.js";
|
|
7
|
+
import {
|
|
8
|
+
cn
|
|
9
|
+
} from "./components-0f0as45n.js";
|
|
10
|
+
|
|
11
|
+
// lib/fluid-hover-highlight.tsx
|
|
12
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
var fade = { duration: 0.08 };
|
|
15
|
+
function resolveHighlightSource(props) {
|
|
16
|
+
if (props.hover) {
|
|
17
|
+
const { activeIndex, itemRects, isMeasured, sessionRef } = props.hover;
|
|
18
|
+
const rect = !props.hidden && isMeasured && activeIndex !== null ? itemRects[activeIndex] ?? null : null;
|
|
19
|
+
return { rect, session: sessionRef.current };
|
|
20
|
+
}
|
|
21
|
+
return { rect: props.rect, session: props.session };
|
|
22
|
+
}
|
|
23
|
+
function FluidHoverHighlight(props) {
|
|
24
|
+
const { from, className, transition } = props;
|
|
25
|
+
const { rect, session } = resolveHighlightSource(props);
|
|
26
|
+
const reduceMotion = useReducedMotion() ?? false;
|
|
27
|
+
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
28
|
+
children: rect && /* @__PURE__ */ jsx(motion.div, {
|
|
29
|
+
"data-slot": "fluid-hover-highlight",
|
|
30
|
+
className: "pointer-events-none absolute top-0 left-0",
|
|
31
|
+
initial: { opacity: 0 },
|
|
32
|
+
animate: { opacity: 1 },
|
|
33
|
+
exit: { opacity: 0, transition: spring.fast.exit },
|
|
34
|
+
transition: fade,
|
|
35
|
+
children: /* @__PURE__ */ jsx(GooIndicator, {
|
|
36
|
+
rect,
|
|
37
|
+
from,
|
|
38
|
+
className: cn("bg-hover", className),
|
|
39
|
+
transition: transition === false || reduceMotion ? false : transition ?? spring.fast
|
|
40
|
+
})
|
|
41
|
+
}, session)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { FluidHoverHighlight };
|