@vjdesigns/vjdesigns-ui 3.4.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +178 -0
- package/README.md +854 -873
- package/dist/ai/llms-full.txt +759 -584
- package/dist/ai/llms.txt +4 -1
- package/dist/ai/registry.json +481 -27
- package/dist/components/data-display/Accordion/Accordion.cjs.js +1 -1
- package/dist/components/data-display/Accordion/Accordion.mjs +97 -166
- package/dist/components/data-display/Chat/Chat.d.ts +13 -2
- package/dist/components/data-display/Collapsible/Collapsible.cjs.js +1 -0
- package/dist/components/data-display/Collapsible/Collapsible.d.ts +70 -0
- package/dist/components/data-display/Collapsible/Collapsible.mjs +102 -0
- package/dist/components/data-display/Collapsible/Collapsible.module.css.cjs.js +1 -0
- package/dist/components/data-display/Collapsible/Collapsible.module.css.mjs +8 -0
- package/dist/components/data-display/Collapsible/index.d.ts +1 -0
- package/dist/components/feedback/Progress/Progress.cjs.js +1 -1
- package/dist/components/feedback/Progress/Progress.d.ts +32 -2
- package/dist/components/feedback/Progress/Progress.mjs +78 -74
- package/dist/components/feedback/Progress/Progress.module.css.cjs.js +1 -1
- package/dist/components/feedback/Progress/Progress.module.css.mjs +1 -1
- package/dist/components/forms/Radio/Radio.cjs.js +1 -1
- package/dist/components/forms/Radio/Radio.mjs +12 -10
- package/dist/components/forms/ToggleGroup/ToggleGroup.cjs.js +1 -1
- package/dist/components/forms/ToggleGroup/ToggleGroup.d.ts +3 -2
- package/dist/components/forms/ToggleGroup/ToggleGroup.mjs +133 -131
- package/dist/components/navigation/Toolbar/Toolbar.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/Toolbar.d.ts +62 -0
- package/dist/components/navigation/Toolbar/Toolbar.mjs +106 -0
- package/dist/components/navigation/Toolbar/Toolbar.module.css.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/Toolbar.module.css.mjs +11 -0
- package/dist/components/navigation/Toolbar/ToolbarContext.cjs.js +1 -0
- package/dist/components/navigation/Toolbar/ToolbarContext.d.ts +9 -0
- package/dist/components/navigation/Toolbar/ToolbarContext.mjs +4 -0
- package/dist/components/navigation/Toolbar/index.d.ts +1 -0
- package/dist/components/primitives/CopyButton/CopyButton.cjs.js +1 -0
- package/dist/components/primitives/CopyButton/CopyButton.d.ts +39 -0
- package/dist/components/primitives/CopyButton/CopyButton.mjs +49 -0
- package/dist/components/primitives/CopyButton/index.d.ts +1 -0
- package/dist/hooks/useCollapsePresence.cjs.js +1 -0
- package/dist/hooks/useCollapsePresence.d.ts +33 -0
- package/dist/hooks/useCollapsePresence.mjs +83 -0
- package/dist/i18n/en.cjs.js +1 -1
- package/dist/i18n/en.mjs +5 -0
- package/dist/i18n/types.d.ts +8 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +104 -101
- package/dist/locales/ar.cjs.js +1 -1
- package/dist/locales/ar.mjs +5 -0
- package/dist/locales/bn.cjs.js +1 -1
- package/dist/locales/bn.mjs +5 -0
- package/dist/locales/cs.cjs.js +1 -1
- package/dist/locales/cs.mjs +5 -0
- package/dist/locales/da.cjs.js +1 -1
- package/dist/locales/da.mjs +5 -0
- package/dist/locales/de.cjs.js +1 -1
- package/dist/locales/de.mjs +5 -0
- package/dist/locales/el.cjs.js +1 -1
- package/dist/locales/el.mjs +5 -0
- package/dist/locales/es.cjs.js +1 -1
- package/dist/locales/es.mjs +5 -0
- package/dist/locales/fa.cjs.js +1 -1
- package/dist/locales/fa.mjs +5 -0
- package/dist/locales/fi.cjs.js +1 -1
- package/dist/locales/fi.mjs +5 -0
- package/dist/locales/fr.cjs.js +1 -1
- package/dist/locales/fr.mjs +5 -0
- package/dist/locales/he.cjs.js +1 -1
- package/dist/locales/he.mjs +5 -0
- package/dist/locales/hi.cjs.js +1 -1
- package/dist/locales/hi.mjs +5 -0
- package/dist/locales/hu.cjs.js +1 -1
- package/dist/locales/hu.mjs +5 -0
- package/dist/locales/id.cjs.js +1 -1
- package/dist/locales/id.mjs +5 -0
- package/dist/locales/it.cjs.js +1 -1
- package/dist/locales/it.mjs +5 -0
- package/dist/locales/ja.cjs.js +1 -1
- package/dist/locales/ja.mjs +5 -0
- package/dist/locales/ko.cjs.js +1 -1
- package/dist/locales/ko.mjs +5 -0
- package/dist/locales/nb.cjs.js +1 -1
- package/dist/locales/nb.mjs +5 -0
- package/dist/locales/nl.cjs.js +1 -1
- package/dist/locales/nl.mjs +5 -0
- package/dist/locales/pl.cjs.js +1 -1
- package/dist/locales/pl.mjs +5 -0
- package/dist/locales/pt-BR.cjs.js +1 -1
- package/dist/locales/pt-BR.mjs +5 -0
- package/dist/locales/ro.cjs.js +1 -1
- package/dist/locales/ro.mjs +5 -0
- package/dist/locales/ru.cjs.js +1 -1
- package/dist/locales/ru.mjs +5 -0
- package/dist/locales/sv.cjs.js +1 -1
- package/dist/locales/sv.mjs +5 -0
- package/dist/locales/th.cjs.js +1 -1
- package/dist/locales/th.mjs +5 -0
- package/dist/locales/tr.cjs.js +1 -1
- package/dist/locales/tr.mjs +5 -0
- package/dist/locales/uk.cjs.js +1 -1
- package/dist/locales/uk.mjs +5 -0
- package/dist/locales/ur.cjs.js +1 -1
- package/dist/locales/ur.mjs +5 -0
- package/dist/locales/vi.cjs.js +1 -1
- package/dist/locales/vi.mjs +5 -0
- package/dist/locales/zh-Hans.cjs.js +1 -1
- package/dist/locales/zh-Hans.mjs +5 -0
- package/dist/locales/zh-Hant.cjs.js +1 -1
- package/dist/locales/zh-Hant.mjs +5 -0
- package/dist/vjdesigns-ui.css +1 -1
- package/package.json +9 -5
- package/dist/components/feedback/Toast/Toast.storyHelpers.d.ts +0 -21
- package/dist/components/navigation/Sidebar/Sidebar.storyHelpers.d.ts +0 -27
- package/dist/components/overlays/Drawer/Drawer.storyHelpers.d.ts +0 -16
|
@@ -3,199 +3,201 @@ import { useControllableState as e } from "../../../hooks/useControllableState.m
|
|
|
3
3
|
import { cx as t } from "../../../utils/cx.mjs";
|
|
4
4
|
import { assignRef as n } from "../../../utils/refs.mjs";
|
|
5
5
|
import { Icon as r } from "../../primitives/Icon/Icon.mjs";
|
|
6
|
-
import i from "
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
6
|
+
import { ToolbarContext as i } from "../../navigation/Toolbar/ToolbarContext.mjs";
|
|
7
|
+
import a from "./ToggleGroup.module.css.mjs";
|
|
8
|
+
import { createContext as o, useCallback as s, useContext as c, useLayoutEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
9
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
9
10
|
// src/components/forms/ToggleGroup/ToggleGroup.tsx
|
|
10
|
-
var
|
|
11
|
-
solid:
|
|
12
|
-
soft:
|
|
13
|
-
outline:
|
|
14
|
-
ghost:
|
|
15
|
-
}, g = {
|
|
16
|
-
neutral: i.neutral,
|
|
17
|
-
primary: i.primary,
|
|
18
|
-
accent: i.accent,
|
|
19
|
-
success: i.success,
|
|
20
|
-
warning: i.warning,
|
|
21
|
-
danger: i.danger,
|
|
22
|
-
info: i.info
|
|
11
|
+
var g = {
|
|
12
|
+
solid: a.solid,
|
|
13
|
+
soft: a.soft,
|
|
14
|
+
outline: a.outline,
|
|
15
|
+
ghost: a.ghost
|
|
23
16
|
}, _ = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
neutral: a.neutral,
|
|
18
|
+
primary: a.primary,
|
|
19
|
+
accent: a.accent,
|
|
20
|
+
success: a.success,
|
|
21
|
+
warning: a.warning,
|
|
22
|
+
danger: a.danger,
|
|
23
|
+
info: a.info
|
|
27
24
|
}, v = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
md: i.radiusMd,
|
|
32
|
-
lg: i.radiusLg,
|
|
33
|
-
xl: i.radiusXl,
|
|
34
|
-
"2xl": i.radius2xl,
|
|
35
|
-
pill: i.radiusPill
|
|
25
|
+
sm: a.sm,
|
|
26
|
+
md: a.md,
|
|
27
|
+
lg: a.lg
|
|
36
28
|
}, y = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
29
|
+
none: a.radiusNone,
|
|
30
|
+
xs: a.radiusXs,
|
|
31
|
+
sm: a.radiusSm,
|
|
32
|
+
md: a.radiusMd,
|
|
33
|
+
lg: a.radiusLg,
|
|
34
|
+
xl: a.radiusXl,
|
|
35
|
+
"2xl": a.radius2xl,
|
|
36
|
+
pill: a.radiusPill
|
|
37
|
+
}, b = {
|
|
38
|
+
0: a.gap0,
|
|
39
|
+
1: a.gap1,
|
|
40
|
+
2: a.gap2,
|
|
41
|
+
3: a.gap3,
|
|
42
|
+
4: a.gap4,
|
|
43
|
+
5: a.gap5,
|
|
44
|
+
6: a.gap6,
|
|
45
|
+
8: a.gap8,
|
|
46
|
+
10: a.gap10,
|
|
47
|
+
12: a.gap12,
|
|
48
|
+
16: a.gap16,
|
|
49
|
+
20: a.gap20,
|
|
50
|
+
24: a.gap24
|
|
51
|
+
}, x = o(null), S = "data-toggle-group-item", C = "data-toggle-group", w = ({ pressed: e, onToggle: n, variant: i, tone: o, size: s, radius: l, disabled: u, checkmark: d, fullWidth: f, startIcon: b, endIcon: S, icon: C, children: w, className: T, onClick: E, ...D }) => {
|
|
52
|
+
let O = c(x), k = i ?? O?.variant ?? "solid", A = o ?? O?.tone ?? "primary", j = s ?? O?.size ?? "md", M = l ?? O?.radius, N = !!(u || O?.disabled), P = w == null && C != null, F = !P && (f ?? O?.fullWidth ?? !1), I = e && !P && (d ?? O?.checkmark ?? !1), L = typeof w == "string" || typeof w == "number" ? String(w) : void 0, R = (e) => {
|
|
52
53
|
E?.(e), e.defaultPrevented || N || n();
|
|
53
54
|
};
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
+
return /* @__PURE__ */ m("button", {
|
|
55
56
|
...D,
|
|
56
57
|
type: "button",
|
|
57
58
|
"aria-pressed": e,
|
|
58
59
|
disabled: N,
|
|
59
60
|
"data-state": e ? "on" : "off",
|
|
60
|
-
className: t(
|
|
61
|
+
className: t(a.root, g[k], _[A], v[j], M ? y[M] : a.radiusDefault, e && a.pressed, P && a.iconOnly, F && a.fullWidth, !N && a.interactive, N && a.disabled, T),
|
|
61
62
|
onClick: R,
|
|
62
|
-
children: /* @__PURE__ */
|
|
63
|
-
className:
|
|
64
|
-
children: [I && /* @__PURE__ */
|
|
65
|
-
className: t(
|
|
63
|
+
children: /* @__PURE__ */ h("span", {
|
|
64
|
+
className: a.content,
|
|
65
|
+
children: [I && /* @__PURE__ */ m("span", {
|
|
66
|
+
className: t(a.icon, a.check),
|
|
66
67
|
"aria-hidden": "true",
|
|
67
|
-
children: /* @__PURE__ */
|
|
68
|
+
children: /* @__PURE__ */ m(r, {
|
|
68
69
|
name: "check",
|
|
69
70
|
strokeWidth: 3
|
|
70
71
|
})
|
|
71
|
-
}), P ? /* @__PURE__ */
|
|
72
|
-
className:
|
|
72
|
+
}), P ? /* @__PURE__ */ m("span", {
|
|
73
|
+
className: a.icon,
|
|
73
74
|
"aria-hidden": "true",
|
|
74
75
|
children: C
|
|
75
|
-
}) : /* @__PURE__ */
|
|
76
|
-
|
|
77
|
-
className:
|
|
76
|
+
}) : /* @__PURE__ */ h(p, { children: [
|
|
77
|
+
b != null && /* @__PURE__ */ m("span", {
|
|
78
|
+
className: a.icon,
|
|
78
79
|
"aria-hidden": "true",
|
|
79
|
-
children:
|
|
80
|
+
children: b
|
|
80
81
|
}),
|
|
81
|
-
w != null && /* @__PURE__ */
|
|
82
|
-
className:
|
|
82
|
+
w != null && /* @__PURE__ */ m("span", {
|
|
83
|
+
className: a.label,
|
|
83
84
|
"data-text": L,
|
|
84
85
|
children: w
|
|
85
86
|
}),
|
|
86
|
-
S != null && /* @__PURE__ */
|
|
87
|
-
className:
|
|
87
|
+
S != null && /* @__PURE__ */ m("span", {
|
|
88
|
+
className: a.icon,
|
|
88
89
|
"aria-hidden": "true",
|
|
89
90
|
children: S
|
|
90
91
|
})
|
|
91
92
|
] })]
|
|
92
93
|
})
|
|
93
94
|
});
|
|
94
|
-
},
|
|
95
|
+
}, T = ({ pressed: t, defaultPressed: n = !1, onPressedChange: r, ...i }) => {
|
|
95
96
|
let [a, o] = e({
|
|
96
97
|
value: t,
|
|
97
98
|
defaultValue: n,
|
|
98
99
|
onChange: r
|
|
99
100
|
});
|
|
100
|
-
return /* @__PURE__ */
|
|
101
|
+
return /* @__PURE__ */ m(w, {
|
|
101
102
|
...i,
|
|
102
103
|
pressed: a,
|
|
103
104
|
onToggle: () => o((e) => !e)
|
|
104
105
|
});
|
|
105
|
-
},
|
|
106
|
-
let i =
|
|
106
|
+
}, E = ({ value: e, onFocus: t, tabIndex: n, ...r }) => {
|
|
107
|
+
let i = c(x);
|
|
107
108
|
if (!i) throw Error("ToggleGroup.Item must be rendered inside a ToggleGroup.");
|
|
108
109
|
let a = (n) => {
|
|
109
110
|
t?.(n), i.setTabStop(e);
|
|
110
111
|
};
|
|
111
|
-
return /* @__PURE__ */
|
|
112
|
+
return /* @__PURE__ */ m(w, {
|
|
112
113
|
...r,
|
|
113
|
-
[
|
|
114
|
+
[S]: e,
|
|
114
115
|
pressed: i.isPressed(e),
|
|
115
116
|
onToggle: () => i.toggle(e),
|
|
116
117
|
onFocus: a,
|
|
117
118
|
tabIndex: i.rovingFocus ? i.tabStop === e ? 0 : -1 : n
|
|
118
119
|
});
|
|
119
120
|
};
|
|
120
|
-
function
|
|
121
|
-
return Array.from(e.querySelectorAll(`[${
|
|
121
|
+
function D(e) {
|
|
122
|
+
return Array.from(e.querySelectorAll(`[${S}]`)).filter((t) => !t.disabled && t.closest(`[${C}]`) === e);
|
|
122
123
|
}
|
|
123
|
-
var
|
|
124
|
-
let
|
|
125
|
-
value:
|
|
126
|
-
defaultValue:
|
|
127
|
-
onChange:
|
|
128
|
-
}),
|
|
129
|
-
|
|
130
|
-
}, [
|
|
131
|
-
|
|
132
|
-
if (
|
|
124
|
+
var O = Object.assign(({ type: r, value: o, defaultValue: p, onValueChange: h, required: g = !1, attached: _ = !1, orientation: v = "horizontal", gap: y = 2, rovingFocus: w, role: T = "group", size: E, variant: O, tone: k, radius: A, disabled: j, checkmark: M, fullWidth: N, className: P, children: F, onKeyDown: I, ref: L, ...R }) => {
|
|
125
|
+
let z = c(i) !== null, B = w ?? !z, V = r === "multiple", [H, U] = e({
|
|
126
|
+
value: o,
|
|
127
|
+
defaultValue: p ?? (V ? [] : null),
|
|
128
|
+
onChange: h
|
|
129
|
+
}), W = d(null), G = s((e) => {
|
|
130
|
+
W.current = e, n(L, e);
|
|
131
|
+
}, [L]), [K, q] = f(null), J = u(() => Array.isArray(H) ? H : typeof H == "string" ? [H] : [], [H]), Y = s((e) => J.includes(e), [J]), X = s((e) => {
|
|
132
|
+
U((t) => {
|
|
133
|
+
if (V) {
|
|
133
134
|
let n = Array.isArray(t) ? t : [];
|
|
134
|
-
return n.includes(e) ?
|
|
135
|
+
return n.includes(e) ? g && n.length === 1 ? t : n.filter((t) => t !== e) : [...n, e];
|
|
135
136
|
}
|
|
136
|
-
return t === e ?
|
|
137
|
+
return t === e ? g ? t : null : e;
|
|
137
138
|
});
|
|
138
139
|
}, [
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
V,
|
|
141
|
+
g,
|
|
142
|
+
U
|
|
142
143
|
]);
|
|
143
|
-
|
|
144
|
-
let e =
|
|
145
|
-
if (!
|
|
146
|
-
let t =
|
|
147
|
-
if (
|
|
148
|
-
let n = t.find((e) =>
|
|
149
|
-
n !==
|
|
144
|
+
l(() => {
|
|
145
|
+
let e = W.current;
|
|
146
|
+
if (!B || !e) return;
|
|
147
|
+
let t = D(e).map((e) => e.getAttribute(S) ?? "");
|
|
148
|
+
if (K !== null && t.includes(K)) return;
|
|
149
|
+
let n = t.find((e) => J.includes(e)) ?? t[0] ?? null;
|
|
150
|
+
n !== K && q(n);
|
|
150
151
|
});
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
let t =
|
|
154
|
-
if (e.defaultPrevented || !
|
|
155
|
-
let n =
|
|
152
|
+
let Z = (e) => {
|
|
153
|
+
I?.(e);
|
|
154
|
+
let t = W.current;
|
|
155
|
+
if (e.defaultPrevented || !B || !t || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
156
|
+
let n = D(t), r = n.indexOf(e.target);
|
|
156
157
|
if (r === -1) return;
|
|
157
|
-
let i =
|
|
158
|
+
let i = v === "vertical", a = getComputedStyle(t).direction === "rtl", o = i ? "ArrowDown" : a ? "ArrowLeft" : "ArrowRight", s = i ? "ArrowUp" : a ? "ArrowRight" : "ArrowLeft", c = n.length, l = null;
|
|
158
159
|
e.key === o ? l = (r + 1) % c : e.key === s ? l = (r - 1 + c) % c : e.key === "Home" ? l = 0 : e.key === "End" && (l = c - 1), l !== null && (e.preventDefault(), n[l].focus());
|
|
159
|
-
},
|
|
160
|
-
size:
|
|
161
|
-
variant:
|
|
162
|
-
tone:
|
|
163
|
-
radius:
|
|
164
|
-
disabled:
|
|
165
|
-
checkmark:
|
|
166
|
-
fullWidth:
|
|
167
|
-
isPressed:
|
|
168
|
-
toggle:
|
|
169
|
-
rovingFocus:
|
|
170
|
-
tabStop:
|
|
171
|
-
setTabStop:
|
|
160
|
+
}, Q = u(() => ({
|
|
161
|
+
size: E,
|
|
162
|
+
variant: O,
|
|
163
|
+
tone: k,
|
|
164
|
+
radius: A,
|
|
165
|
+
disabled: j,
|
|
166
|
+
checkmark: M,
|
|
167
|
+
fullWidth: N,
|
|
168
|
+
isPressed: Y,
|
|
169
|
+
toggle: X,
|
|
170
|
+
rovingFocus: B,
|
|
171
|
+
tabStop: K,
|
|
172
|
+
setTabStop: q
|
|
172
173
|
}), [
|
|
173
|
-
|
|
174
|
-
T,
|
|
175
|
-
D,
|
|
174
|
+
E,
|
|
176
175
|
O,
|
|
177
176
|
k,
|
|
178
177
|
A,
|
|
179
178
|
j,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
"
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
179
|
+
M,
|
|
180
|
+
N,
|
|
181
|
+
Y,
|
|
182
|
+
X,
|
|
183
|
+
B,
|
|
184
|
+
K
|
|
185
|
+
]), $ = v === "vertical";
|
|
186
|
+
return /* @__PURE__ */ m("div", {
|
|
187
|
+
...R,
|
|
188
|
+
[C]: "",
|
|
189
|
+
ref: G,
|
|
190
|
+
role: T,
|
|
191
|
+
"aria-orientation": T === "toolbar" ? v : void 0,
|
|
192
|
+
"aria-disabled": j ? !0 : void 0,
|
|
193
|
+
"data-orientation": v,
|
|
194
|
+
"data-roving-focus": B ? "" : void 0,
|
|
195
|
+
className: t(a.group, $ && a.groupVertical, _ ? $ ? a.attachedVertical : a.attachedHorizontal : b[y], _ && a.attached, N && a.groupFullWidth, P),
|
|
196
|
+
onKeyDown: Z,
|
|
197
|
+
children: /* @__PURE__ */ m(x.Provider, {
|
|
198
|
+
value: Q,
|
|
199
|
+
children: F
|
|
198
200
|
})
|
|
199
201
|
});
|
|
200
|
-
}, { Item:
|
|
201
|
-
export {
|
|
202
|
+
}, { Item: E });
|
|
203
|
+
export { T as ToggleButton, O as ToggleGroup, E as ToggleGroupItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../../../hooks/useMergedRef.cjs.js"),t=require("../../../utils/cx.cjs.js"),n=require("../../../utils/hotkeys.cjs.js"),r=require("../../layout/Divider/Divider.cjs.js"),i=require("./ToolbarContext.cjs.js"),a=require("./Toolbar.module.css.cjs.js");let o=require("react"),s=require("react/jsx-runtime");var c=globalThis.process?.env?.NODE_ENV!==`production`,l=`button, a[href], input:not([type="hidden"]), select, textarea, [tabindex], [contenteditable=""], [contenteditable="true"]`,u=`[role="radiogroup"], [role="tablist"], [role="listbox"], [role="grid"], [role="treegrid"], [role="tree"], [role="menu"], [role="menubar"], [role="toolbar"], [data-roving-focus]`,d=`data-toolbar-item`;function f(e,t){if(e.disabled||e.closest(`[hidden], [inert]`)||e.getAttribute(`tabindex`)===`-1`&&!e.hasAttribute(d))return!1;let n=e.parentElement?.closest(u);return!n||n===t||!t.contains(n)}function p(e){return Array.from(e.querySelectorAll(l)).filter(t=>f(t,e))}function m(e,t){let n=p(e),r=t&&n.includes(t)?t:n[0]??null;for(let e of n)e.setAttribute(d,``),e.tabIndex=e===r?0:-1;return r}var h={plain:a.default.plain,surface:a.default.surface};function g({orientation:r=`horizontal`,variant:l=`surface`,loop:u=!0,wrap:f=!1,className:g,children:_,onKeyDown:v,onFocus:y,ref:b,...x}){let S=(0,o.useRef)(null),C=e.useMergedRef(b,S),w=(0,o.useRef)(null),T=!!(x[`aria-label`]||x[`aria-labelledby`]);(0,o.useEffect)(()=>{c&&!T&&console.warn(`[Toolbar] Give it a name: aria-label or aria-labelledby.`)},[T]),(0,o.useLayoutEffect)(()=>{let e=S.current;e&&(w.current=m(e,w.current))}),(0,o.useEffect)(()=>{let e=S.current;if(!e||typeof MutationObserver>`u`)return;let t=new MutationObserver(()=>{w.current=m(e,w.current)});return t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`disabled`,`hidden`,`inert`,`role`,`data-roving-focus`]}),()=>t.disconnect()},[]);let E=e=>{y?.(e);let t=S.current,n=e.target;t&&n.hasAttribute(d)&&n!==w.current&&(w.current=m(t,n))},D=e=>{v?.(e);let t=S.current;if(e.defaultPrevented||!t||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let i=e.target,a=p(t),o=a.indexOf(i);if(o===-1)return;let s=r===`vertical`,c=getComputedStyle(t).direction===`rtl`,l=s?`ArrowDown`:c?`ArrowLeft`:`ArrowRight`,d=s?`ArrowUp`:c?`ArrowRight`:`ArrowLeft`;if(n.isTypingTarget(i)){let t=i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement;if(!s||t||e.key===`Home`||e.key===`End`)return}let f=a.length-1,m=null;e.key===l?m=o<f?o+1:u?0:null:e.key===d?m=o>0?o-1:u?f:null:e.key===`Home`?m=0:e.key===`End`&&(m=f),m!==null&&(e.preventDefault(),a[m].focus())},O=(0,o.useMemo)(()=>({orientation:r}),[r]);return(0,s.jsx)(i.ToolbarContext.Provider,{value:O,children:(0,s.jsx)(`div`,{...x,ref:C,role:`toolbar`,"aria-orientation":r,"data-orientation":r,className:t.cx(a.default.toolbar,h[l],r===`vertical`&&a.default.vertical,f&&r===`horizontal`&&a.default.wrap,g),onKeyDown:D,onFocus:E,children:_})})}function _({className:e}){let n=(0,o.useContext)(i.ToolbarContext)?.orientation===`vertical`?`horizontal`:`vertical`;return(0,s.jsx)(r.Divider,{orientation:n,spacing:1,className:t.cx(a.default.separator,e)})}function v({className:e,children:n,...r}){return(0,s.jsx)(`div`,{...r,role:`group`,className:t.cx(a.default.group,e),children:n})}var y=g;y.Separator=_,y.Group=v,exports.Toolbar=y,exports.ToolbarGroup=v,exports.ToolbarSeparator=_;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
import { Orientation } from '../../../types/common';
|
|
3
|
+
/** Visual style of the toolbar container. */
|
|
4
|
+
export type ToolbarVariant = "plain" | "surface";
|
|
5
|
+
export interface ToolbarProps extends Omit<ComponentPropsWithRef<"div">, "role"> {
|
|
6
|
+
/**
|
|
7
|
+
* Direction of the controls. Also picks the arrow keys: Left/Right when
|
|
8
|
+
* horizontal (following the reading direction), Up/Down when vertical.
|
|
9
|
+
* @default "horizontal"
|
|
10
|
+
*/
|
|
11
|
+
orientation?: Orientation;
|
|
12
|
+
/** `surface`: a rounded, bordered bar. `plain`: no container styling. @default "surface" */
|
|
13
|
+
variant?: ToolbarVariant;
|
|
14
|
+
/** Arrow keys wrap from the last control to the first, and back. @default true */
|
|
15
|
+
loop?: boolean;
|
|
16
|
+
/** Let controls wrap onto more lines when there isn't room (horizontal only). @default false */
|
|
17
|
+
wrap?: boolean;
|
|
18
|
+
/** The controls: buttons, toggle groups, links, menus, inputs, `Toolbar.Separator`, and `Toolbar.Group`. */
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A set of controls, such as text formatting or a table's actions, that acts
|
|
23
|
+
* as one Tab stop: the WAI-ARIA toolbar pattern.
|
|
24
|
+
*
|
|
25
|
+
* Keyboard: Tab moves into the toolbar (to the last used control) and out of
|
|
26
|
+
* it. Arrow keys move between controls (Left/Right, mirrored in right-to-left
|
|
27
|
+
* layouts, or Up/Down when vertical), and Home and End jump to the first and
|
|
28
|
+
* last. Disabled controls are skipped. In a text field, the arrow keys, Home,
|
|
29
|
+
* and End keep editing the text. A `ToggleGroup` inside joins the toolbar's
|
|
30
|
+
* arrow keys; other widgets with their own arrow keys (radio groups, tabs,
|
|
31
|
+
* `SegmentedControl`) stay a separate Tab stop.
|
|
32
|
+
*
|
|
33
|
+
* Give it a name with `aria-label` or `aria-labelledby` (e.g. "Text formatting").
|
|
34
|
+
*/
|
|
35
|
+
declare function ToolbarRoot({ orientation, variant, loop, wrap, className, children, onKeyDown, onFocus, ref, ...rest }: ToolbarProps): import("react").JSX.Element;
|
|
36
|
+
export interface ToolbarSeparatorProps {
|
|
37
|
+
/** Additional class for the separator. */
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A line between groups of controls, drawn across the toolbar's direction
|
|
42
|
+
* (`role="separator"`). It isn't focusable, and arrow keys skip it.
|
|
43
|
+
*/
|
|
44
|
+
declare function ToolbarSeparator({ className }: ToolbarSeparatorProps): import("react").JSX.Element;
|
|
45
|
+
export interface ToolbarGroupProps extends Omit<ComponentPropsWithRef<"div">, "role"> {
|
|
46
|
+
/** Related controls. Name the group with `aria-label` (e.g. "Alignment") if the controls don't make it obvious. */
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Keeps related controls together (`role="group"`), so a wrapping toolbar
|
|
51
|
+
* moves them to the next line as one. Its controls stay in the toolbar's
|
|
52
|
+
* arrow-key order.
|
|
53
|
+
*/
|
|
54
|
+
declare function ToolbarGroup({ className, children, ...rest }: ToolbarGroupProps): import("react").JSX.Element;
|
|
55
|
+
type ToolbarComponent = typeof ToolbarRoot & {
|
|
56
|
+
Separator: typeof ToolbarSeparator;
|
|
57
|
+
Group: typeof ToolbarGroup;
|
|
58
|
+
};
|
|
59
|
+
/** A row (or column) of controls that is one Tab stop, with arrow keys between controls. */
|
|
60
|
+
export declare const Toolbar: ToolbarComponent;
|
|
61
|
+
/** Named exports, for React Server Components (which can't dot into a client module). */
|
|
62
|
+
export { ToolbarSeparator, ToolbarGroup };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMergedRef as e } from "../../../hooks/useMergedRef.mjs";
|
|
3
|
+
import { cx as t } from "../../../utils/cx.mjs";
|
|
4
|
+
import { isTypingTarget as n } from "../../../utils/hotkeys.mjs";
|
|
5
|
+
import { Divider as r } from "../../layout/Divider/Divider.mjs";
|
|
6
|
+
import { ToolbarContext as i } from "./ToolbarContext.mjs";
|
|
7
|
+
import a from "./Toolbar.module.css.mjs";
|
|
8
|
+
import { useContext as o, useEffect as s, useLayoutEffect as c, useMemo as l, useRef as u } from "react";
|
|
9
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
10
|
+
// src/components/navigation/Toolbar/Toolbar.tsx
|
|
11
|
+
var f = globalThis.process?.env?.NODE_ENV !== "production", p = "button, a[href], input:not([type=\"hidden\"]), select, textarea, [tabindex], [contenteditable=\"\"], [contenteditable=\"true\"]", m = "[role=\"radiogroup\"], [role=\"tablist\"], [role=\"listbox\"], [role=\"grid\"], [role=\"treegrid\"], [role=\"tree\"], [role=\"menu\"], [role=\"menubar\"], [role=\"toolbar\"], [data-roving-focus]", h = "data-toolbar-item";
|
|
12
|
+
function g(e, t) {
|
|
13
|
+
if (e.disabled || e.closest("[hidden], [inert]") || e.getAttribute("tabindex") === "-1" && !e.hasAttribute(h)) return !1;
|
|
14
|
+
let n = e.parentElement?.closest(m);
|
|
15
|
+
return !n || n === t || !t.contains(n);
|
|
16
|
+
}
|
|
17
|
+
function _(e) {
|
|
18
|
+
return Array.from(e.querySelectorAll(p)).filter((t) => g(t, e));
|
|
19
|
+
}
|
|
20
|
+
function v(e, t) {
|
|
21
|
+
let n = _(e), r = t && n.includes(t) ? t : n[0] ?? null;
|
|
22
|
+
for (let e of n) e.setAttribute(h, ""), e.tabIndex = e === r ? 0 : -1;
|
|
23
|
+
return r;
|
|
24
|
+
}
|
|
25
|
+
var y = {
|
|
26
|
+
plain: a.plain,
|
|
27
|
+
surface: a.surface
|
|
28
|
+
};
|
|
29
|
+
function b({ orientation: r = "horizontal", variant: o = "surface", loop: p = !0, wrap: m = !1, className: g, children: b, onKeyDown: x, onFocus: S, ref: C, ...w }) {
|
|
30
|
+
let T = u(null), E = e(C, T), D = u(null), O = !!(w["aria-label"] || w["aria-labelledby"]);
|
|
31
|
+
s(() => {
|
|
32
|
+
f && !O && console.warn("[Toolbar] Give it a name: aria-label or aria-labelledby.");
|
|
33
|
+
}, [O]), c(() => {
|
|
34
|
+
let e = T.current;
|
|
35
|
+
e && (D.current = v(e, D.current));
|
|
36
|
+
}), s(() => {
|
|
37
|
+
let e = T.current;
|
|
38
|
+
if (!e || typeof MutationObserver > "u") return;
|
|
39
|
+
let t = new MutationObserver(() => {
|
|
40
|
+
D.current = v(e, D.current);
|
|
41
|
+
});
|
|
42
|
+
return t.observe(e, {
|
|
43
|
+
subtree: !0,
|
|
44
|
+
childList: !0,
|
|
45
|
+
attributes: !0,
|
|
46
|
+
attributeFilter: [
|
|
47
|
+
"disabled",
|
|
48
|
+
"hidden",
|
|
49
|
+
"inert",
|
|
50
|
+
"role",
|
|
51
|
+
"data-roving-focus"
|
|
52
|
+
]
|
|
53
|
+
}), () => t.disconnect();
|
|
54
|
+
}, []);
|
|
55
|
+
let k = (e) => {
|
|
56
|
+
S?.(e);
|
|
57
|
+
let t = T.current, n = e.target;
|
|
58
|
+
t && n.hasAttribute(h) && n !== D.current && (D.current = v(t, n));
|
|
59
|
+
}, A = (e) => {
|
|
60
|
+
x?.(e);
|
|
61
|
+
let t = T.current;
|
|
62
|
+
if (e.defaultPrevented || !t || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
63
|
+
let i = e.target, a = _(t), o = a.indexOf(i);
|
|
64
|
+
if (o === -1) return;
|
|
65
|
+
let s = r === "vertical", c = getComputedStyle(t).direction === "rtl", l = s ? "ArrowDown" : c ? "ArrowLeft" : "ArrowRight", u = s ? "ArrowUp" : c ? "ArrowRight" : "ArrowLeft";
|
|
66
|
+
if (n(i)) {
|
|
67
|
+
let t = i instanceof HTMLTextAreaElement || i instanceof HTMLSelectElement;
|
|
68
|
+
if (!s || t || e.key === "Home" || e.key === "End") return;
|
|
69
|
+
}
|
|
70
|
+
let d = a.length - 1, f = null;
|
|
71
|
+
e.key === l ? f = o < d ? o + 1 : p ? 0 : null : e.key === u ? f = o > 0 ? o - 1 : p ? d : null : e.key === "Home" ? f = 0 : e.key === "End" && (f = d), f !== null && (e.preventDefault(), a[f].focus());
|
|
72
|
+
}, j = l(() => ({ orientation: r }), [r]);
|
|
73
|
+
return /* @__PURE__ */ d(i.Provider, {
|
|
74
|
+
value: j,
|
|
75
|
+
children: /* @__PURE__ */ d("div", {
|
|
76
|
+
...w,
|
|
77
|
+
ref: E,
|
|
78
|
+
role: "toolbar",
|
|
79
|
+
"aria-orientation": r,
|
|
80
|
+
"data-orientation": r,
|
|
81
|
+
className: t(a.toolbar, y[o], r === "vertical" && a.vertical, m && r === "horizontal" && a.wrap, g),
|
|
82
|
+
onKeyDown: A,
|
|
83
|
+
onFocus: k,
|
|
84
|
+
children: b
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function x({ className: e }) {
|
|
89
|
+
let n = o(i)?.orientation === "vertical" ? "horizontal" : "vertical";
|
|
90
|
+
return /* @__PURE__ */ d(r, {
|
|
91
|
+
orientation: n,
|
|
92
|
+
spacing: 1,
|
|
93
|
+
className: t(a.separator, e)
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function S({ className: e, children: n, ...r }) {
|
|
97
|
+
return /* @__PURE__ */ d("div", {
|
|
98
|
+
...r,
|
|
99
|
+
role: "group",
|
|
100
|
+
className: t(a.group, e),
|
|
101
|
+
children: n
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
var C = b;
|
|
105
|
+
C.Separator = x, C.Group = S;
|
|
106
|
+
export { C as Toolbar, S as ToolbarGroup, x as ToolbarSeparator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`_toolbar_orlw6_15`,t=`_vertical_orlw6_31`,n=`_wrap_orlw6_43`,r=`_plain_orlw6_57`,i=`_surface_orlw6_65`,a=`_group_orlw6_85`,o=`_separator_orlw6_101`,s={toolbar:e,vertical:t,wrap:n,plain:r,surface:i,group:a,separator:o};exports.default=s,exports.group=a,exports.plain=r,exports.separator=o,exports.surface=i,exports.toolbar=e,exports.vertical=t,exports.wrap=n;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/components/navigation/Toolbar/Toolbar.module.css
|
|
2
|
+
var e = "_toolbar_orlw6_15", t = "_vertical_orlw6_31", n = "_wrap_orlw6_43", r = "_plain_orlw6_57", i = "_surface_orlw6_65", a = "_group_orlw6_85", o = "_separator_orlw6_101", s = {
|
|
3
|
+
toolbar: e,
|
|
4
|
+
vertical: t,
|
|
5
|
+
wrap: n,
|
|
6
|
+
plain: r,
|
|
7
|
+
surface: i,
|
|
8
|
+
group: a,
|
|
9
|
+
separator: o
|
|
10
|
+
};
|
|
11
|
+
export { s as default, a as group, r as plain, o as separator, i as surface, e as toolbar, t as vertical, n as wrap };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=(0,require("react").createContext)(null);exports.ToolbarContext=e;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Orientation } from '../../../types/common';
|
|
2
|
+
/**
|
|
3
|
+
* Internal: set by `Toolbar` so controls inside can adapt (a `ToggleGroup`
|
|
4
|
+
* turns off its own roving focus and joins the toolbar's arrow keys, and
|
|
5
|
+
* `Toolbar.Separator` draws across the toolbar's direction).
|
|
6
|
+
*/
|
|
7
|
+
export declare const ToolbarContext: import('react').Context<{
|
|
8
|
+
orientation: Orientation;
|
|
9
|
+
} | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Toolbar';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../../utilities/LocaleProvider/LocaleProvider.cjs.js"),t=require("../../../utils/announce.cjs.js"),n=require("../../../utils/clipboard.cjs.js"),r=require("../Button/Button.cjs.js"),i=require("../Icon/icons.cjs.js");let a=require("react"),o=require("react/jsx-runtime");function s({value:s,iconOnly:c=!1,children:l,copiedLabel:u,copyErrorLabel:d,timeout:f=2e3,onCopyStatusChange:p,onClick:m,variant:h,tone:g=`neutral`,size:_,"aria-label":v,...y}){let b=e.useMessages().copyButton,x=u??b.copied,S=d??b.copyError,[C,w]=(0,a.useState)(`idle`),T=(0,a.useRef)(void 0),E=(0,a.useRef)(p);E.current=p,(0,a.useEffect)(()=>()=>clearTimeout(T.current),[]);let D=e=>{w(e),E.current?.(e)},O=async e=>{if(m?.(e),!e.defaultPrevented){clearTimeout(T.current);try{await n.copyToClipboard(typeof s==`function`?s():s),D(`copied`),t.announce(x)}catch{D(`error`),t.announce(S)}T.current=setTimeout(()=>D(`idle`),f)}},k=C===`copied`?(0,o.jsx)(i.CheckIcon,{}):C===`error`?(0,o.jsx)(i.ErrorIcon,{}):(0,o.jsx)(i.CopyIcon,{});if(c)return(0,o.jsx)(r.IconButton,{...y,variant:h??`ghost`,tone:g,size:_,"aria-label":v??b.copy,"data-status":C,onClick:O,children:k});let A=C===`copied`?x:C===`error`?S:l??b.copy;return(0,o.jsx)(r.Button,{...y,variant:h??`soft`,tone:g,size:_,"aria-label":v,"data-status":C,startIcon:k,onClick:O,children:A})}exports.CopyButton=s;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
import { ButtonStyleProps } from '../Button';
|
|
3
|
+
/** Result of the last copy: `idle` again after `timeout`. */
|
|
4
|
+
export type CopyStatus = "idle" | "copied" | "error";
|
|
5
|
+
export interface CopyButtonProps extends ButtonStyleProps, Omit<ComponentPropsWithRef<"button">, "value" | "children" | keyof ButtonStyleProps> {
|
|
6
|
+
/**
|
|
7
|
+
* The text to copy, or a function that returns it when clicked (for values
|
|
8
|
+
* that change, such as the current URL).
|
|
9
|
+
*/
|
|
10
|
+
value: string | (() => string);
|
|
11
|
+
/**
|
|
12
|
+
* Show only the icon. The accessible name is `aria-label` if you pass
|
|
13
|
+
* one (e.g. "Copy invite link"), otherwise the translated "Copy".
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
iconOnly?: boolean;
|
|
17
|
+
/** Visible label while idle. @default "Copy" (translated) */
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
/** Label shown and announced after a successful copy. @default "Copied" (translated) */
|
|
20
|
+
copiedLabel?: string;
|
|
21
|
+
/** Label shown and announced when copying fails. @default "Couldn't copy" (translated) */
|
|
22
|
+
copyErrorLabel?: string;
|
|
23
|
+
/** How long the copied or error state shows, in milliseconds. @default 2000 */
|
|
24
|
+
timeout?: number;
|
|
25
|
+
/** Called with each copy result, then with `"idle"` when it resets. */
|
|
26
|
+
onCopyStatusChange?: (status: CopyStatus) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A button that copies text to the clipboard and confirms it: the icon turns
|
|
30
|
+
* into a check and the label into "Copied", and the result is announced to
|
|
31
|
+
* screen readers through a polite live region (a label change on a focused
|
|
32
|
+
* button isn't reliably read). Falls back to a legacy copy method where the
|
|
33
|
+
* Clipboard API is blocked, and shows an error state if both fail.
|
|
34
|
+
*
|
|
35
|
+
* Takes `Button`'s style props (`variant`, `tone`, `size`, `radius`) and any
|
|
36
|
+
* native `<button>` attribute. An `onClick` that calls `preventDefault()`
|
|
37
|
+
* cancels the copy.
|
|
38
|
+
*/
|
|
39
|
+
export declare function CopyButton({ value, iconOnly, children, copiedLabel: copiedLabelProp, copyErrorLabel: copyErrorLabelProp, timeout, onCopyStatusChange, onClick, variant, tone, size, "aria-label": ariaLabel, ...rest }: CopyButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMessages as e } from "../../utilities/LocaleProvider/LocaleProvider.mjs";
|
|
3
|
+
import { announce as t } from "../../../utils/announce.mjs";
|
|
4
|
+
import { copyToClipboard as n } from "../../../utils/clipboard.mjs";
|
|
5
|
+
import { Button as r, IconButton as i } from "../Button/Button.mjs";
|
|
6
|
+
import { CheckIcon as a, CopyIcon as o, ErrorIcon as s } from "../Icon/icons.mjs";
|
|
7
|
+
import { useEffect as c, useRef as l, useState as u } from "react";
|
|
8
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
9
|
+
// src/components/primitives/CopyButton/CopyButton.tsx
|
|
10
|
+
function f({ value: f, iconOnly: p = !1, children: m, copiedLabel: h, copyErrorLabel: g, timeout: _ = 2e3, onCopyStatusChange: v, onClick: y, variant: b, tone: x = "neutral", size: S, "aria-label": C, ...w }) {
|
|
11
|
+
let T = e().copyButton, E = h ?? T.copied, D = g ?? T.copyError, [O, k] = u("idle"), A = l(void 0), j = l(v);
|
|
12
|
+
j.current = v, c(() => () => clearTimeout(A.current), []);
|
|
13
|
+
let M = (e) => {
|
|
14
|
+
k(e), j.current?.(e);
|
|
15
|
+
}, N = async (e) => {
|
|
16
|
+
if (y?.(e), !e.defaultPrevented) {
|
|
17
|
+
clearTimeout(A.current);
|
|
18
|
+
try {
|
|
19
|
+
await n(typeof f == "function" ? f() : f), M("copied"), t(E);
|
|
20
|
+
} catch {
|
|
21
|
+
M("error"), t(D);
|
|
22
|
+
}
|
|
23
|
+
A.current = setTimeout(() => M("idle"), _);
|
|
24
|
+
}
|
|
25
|
+
}, P = d(O === "copied" ? a : O === "error" ? s : o, {});
|
|
26
|
+
if (p) return /* @__PURE__ */ d(i, {
|
|
27
|
+
...w,
|
|
28
|
+
variant: b ?? "ghost",
|
|
29
|
+
tone: x,
|
|
30
|
+
size: S,
|
|
31
|
+
"aria-label": C ?? T.copy,
|
|
32
|
+
"data-status": O,
|
|
33
|
+
onClick: N,
|
|
34
|
+
children: P
|
|
35
|
+
});
|
|
36
|
+
let F = O === "copied" ? E : O === "error" ? D : m ?? T.copy;
|
|
37
|
+
return /* @__PURE__ */ d(r, {
|
|
38
|
+
...w,
|
|
39
|
+
variant: b ?? "soft",
|
|
40
|
+
tone: x,
|
|
41
|
+
size: S,
|
|
42
|
+
"aria-label": C,
|
|
43
|
+
"data-status": O,
|
|
44
|
+
startIcon: P,
|
|
45
|
+
onClick: N,
|
|
46
|
+
children: F
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export { f as CopyButton };
|