@versini/ui-togglegroup 1.2.1 → 1.3.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/index.d.ts +2 -2
- package/dist/index.js +119 -105
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as ToggleGroupRadix from '@radix-ui/react-toggle-group';
|
|
3
|
-
import {
|
|
3
|
+
import { SpacingTypes } from '@versini/ui-spacing-types';
|
|
4
4
|
|
|
5
5
|
declare const TOGGLEGROUP_CLASSNAME = "av-togglegroup";
|
|
6
6
|
declare const TOGGLEGROUP_ITEM_WRAPPER_CLASSNAME = "av-togglegroup-item-wrapper";
|
|
@@ -24,7 +24,7 @@ type ToggleGroupProps = {
|
|
|
24
24
|
*/
|
|
25
25
|
size?: Size;
|
|
26
26
|
} & Omit<ToggleGroupRadix.ToggleGroupSingleProps, "type", "defaultValue"> &
|
|
27
|
-
|
|
27
|
+
SpacingTypes.Props;
|
|
28
28
|
|
|
29
29
|
type ToggleGroupItemProps = ToggleGroupRadix.ToggleGroupItemProps;
|
|
30
30
|
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as a, Fragment as ge } from "react/jsx-runtime";
|
|
2
2
|
import * as l from "react";
|
|
3
3
|
import C, { useContext as me } from "react";
|
|
4
|
-
import
|
|
4
|
+
import G from "clsx";
|
|
5
5
|
/*!
|
|
6
|
-
@versini/ui-togglegroup v1.
|
|
6
|
+
@versini/ui-togglegroup v1.3.0
|
|
7
7
|
© 2024 gizmette.com
|
|
8
8
|
*/
|
|
9
9
|
try {
|
|
10
10
|
window.__VERSINI_UI_TOGGLEGROUP__ || (window.__VERSINI_UI_TOGGLEGROUP__ = {
|
|
11
|
-
version: "1.
|
|
12
|
-
buildTime: "12/
|
|
11
|
+
version: "1.3.0",
|
|
12
|
+
buildTime: "12/24/2024 06:47 PM EST",
|
|
13
13
|
homepage: "https://github.com/aversini/ui-components",
|
|
14
14
|
license: "MIT"
|
|
15
15
|
});
|
|
@@ -21,20 +21,20 @@ function U(e, t = []) {
|
|
|
21
21
|
function r(s, c) {
|
|
22
22
|
const u = l.createContext(c), i = o.length;
|
|
23
23
|
o = [...o, c];
|
|
24
|
-
const
|
|
24
|
+
const f = (p) => {
|
|
25
25
|
var g;
|
|
26
|
-
const { scope: h, children: I, ...
|
|
27
|
-
return /* @__PURE__ */ a(m.Provider, { value:
|
|
26
|
+
const { scope: h, children: I, ...d } = p, m = ((g = h == null ? void 0 : h[e]) == null ? void 0 : g[i]) || u, _ = l.useMemo(() => d, Object.values(d));
|
|
27
|
+
return /* @__PURE__ */ a(m.Provider, { value: _, children: I });
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
f.displayName = s + "Provider";
|
|
30
30
|
function v(p, h) {
|
|
31
31
|
var m;
|
|
32
|
-
const I = ((m = h == null ? void 0 : h[e]) == null ? void 0 : m[i]) || u,
|
|
33
|
-
if (
|
|
32
|
+
const I = ((m = h == null ? void 0 : h[e]) == null ? void 0 : m[i]) || u, d = l.useContext(I);
|
|
33
|
+
if (d) return d;
|
|
34
34
|
if (c !== void 0) return c;
|
|
35
35
|
throw new Error(`\`${p}\` must be used within \`${s}\``);
|
|
36
36
|
}
|
|
37
|
-
return [
|
|
37
|
+
return [f, v];
|
|
38
38
|
}
|
|
39
39
|
const n = () => {
|
|
40
40
|
const s = o.map((c) => l.createContext(c));
|
|
@@ -57,8 +57,8 @@ function be(...e) {
|
|
|
57
57
|
scopeName: n.scopeName
|
|
58
58
|
}));
|
|
59
59
|
return function(s) {
|
|
60
|
-
const c = r.reduce((u, { useScope: i, scopeName:
|
|
61
|
-
const p = i(s)[`__scope${
|
|
60
|
+
const c = r.reduce((u, { useScope: i, scopeName: f }) => {
|
|
61
|
+
const p = i(s)[`__scope${f}`];
|
|
62
62
|
return { ...u, ...p };
|
|
63
63
|
}, {});
|
|
64
64
|
return l.useMemo(() => ({ [`__scope${t.scopeName}`]: c }), [c]);
|
|
@@ -91,7 +91,7 @@ function D(...e) {
|
|
|
91
91
|
return l.useCallback(z(...e), e);
|
|
92
92
|
}
|
|
93
93
|
var A = l.forwardRef((e, t) => {
|
|
94
|
-
const { children: o, ...r } = e, n = l.Children.toArray(o), s = n.find(
|
|
94
|
+
const { children: o, ...r } = e, n = l.Children.toArray(o), s = n.find(_e);
|
|
95
95
|
if (s) {
|
|
96
96
|
const c = s.props.children, u = n.map((i) => i === s ? l.Children.count(c) > 1 ? l.Children.only(null) : l.isValidElement(c) ? c.props.children : null : i);
|
|
97
97
|
return /* @__PURE__ */ a(L, { ...r, ref: t, children: l.isValidElement(c) ? l.cloneElement(c, void 0, u) : null });
|
|
@@ -104,7 +104,7 @@ var L = l.forwardRef((e, t) => {
|
|
|
104
104
|
if (l.isValidElement(o)) {
|
|
105
105
|
const n = Re(o);
|
|
106
106
|
return l.cloneElement(o, {
|
|
107
|
-
...
|
|
107
|
+
...Te(r, o.props),
|
|
108
108
|
// @ts-ignore
|
|
109
109
|
ref: t ? z(t, n) : n
|
|
110
110
|
});
|
|
@@ -113,10 +113,10 @@ var L = l.forwardRef((e, t) => {
|
|
|
113
113
|
});
|
|
114
114
|
L.displayName = "SlotClone";
|
|
115
115
|
var Ie = ({ children: e }) => /* @__PURE__ */ a(ge, { children: e });
|
|
116
|
-
function
|
|
116
|
+
function _e(e) {
|
|
117
117
|
return l.isValidElement(e) && e.type === Ie;
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function Te(e, t) {
|
|
120
120
|
const o = { ...t };
|
|
121
121
|
for (const r in t) {
|
|
122
122
|
const n = e[r], s = t[r];
|
|
@@ -131,7 +131,7 @@ function Re(e) {
|
|
|
131
131
|
let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, o = t && "isReactWarning" in t && t.isReactWarning;
|
|
132
132
|
return o ? e.ref : (t = (n = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : n.get, o = t && "isReactWarning" in t && t.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
|
|
133
133
|
}
|
|
134
|
-
var
|
|
134
|
+
var ye = [
|
|
135
135
|
"a",
|
|
136
136
|
"button",
|
|
137
137
|
"div",
|
|
@@ -148,52 +148,52 @@ var Se = [
|
|
|
148
148
|
"span",
|
|
149
149
|
"svg",
|
|
150
150
|
"ul"
|
|
151
|
-
], w =
|
|
151
|
+
], w = ye.reduce((e, t) => {
|
|
152
152
|
const o = l.forwardRef((r, n) => {
|
|
153
153
|
const { asChild: s, ...c } = r, u = s ? A : t;
|
|
154
154
|
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ a(u, { ...c, ref: n });
|
|
155
155
|
});
|
|
156
156
|
return o.displayName = `Primitive.${t}`, { ...e, [t]: o };
|
|
157
157
|
}, {});
|
|
158
|
-
function
|
|
158
|
+
function y(e, t, { checkForDefaultPrevented: o = !0 } = {}) {
|
|
159
159
|
return function(n) {
|
|
160
160
|
if (e == null || e(n), o === !1 || !n.defaultPrevented)
|
|
161
161
|
return t == null ? void 0 : t(n);
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function Se(e) {
|
|
165
165
|
const t = e + "CollectionProvider", [o, r] = U(t), [n, s] = o(
|
|
166
166
|
t,
|
|
167
167
|
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
|
|
168
168
|
), c = (I) => {
|
|
169
|
-
const { scope:
|
|
170
|
-
return /* @__PURE__ */ a(n, { scope:
|
|
169
|
+
const { scope: d, children: m } = I, _ = C.useRef(null), g = C.useRef(/* @__PURE__ */ new Map()).current;
|
|
170
|
+
return /* @__PURE__ */ a(n, { scope: d, itemMap: g, collectionRef: _, children: m });
|
|
171
171
|
};
|
|
172
172
|
c.displayName = t;
|
|
173
173
|
const u = e + "CollectionSlot", i = C.forwardRef(
|
|
174
|
-
(I,
|
|
175
|
-
const { scope: m, children:
|
|
176
|
-
return /* @__PURE__ */ a(A, { ref: b, children:
|
|
174
|
+
(I, d) => {
|
|
175
|
+
const { scope: m, children: _ } = I, g = s(u, m), b = D(d, g.collectionRef);
|
|
176
|
+
return /* @__PURE__ */ a(A, { ref: b, children: _ });
|
|
177
177
|
}
|
|
178
178
|
);
|
|
179
179
|
i.displayName = u;
|
|
180
|
-
const
|
|
181
|
-
(I,
|
|
182
|
-
const { scope: m, children:
|
|
183
|
-
return C.useEffect(() => (
|
|
180
|
+
const f = e + "CollectionItemSlot", v = "data-radix-collection-item", p = C.forwardRef(
|
|
181
|
+
(I, d) => {
|
|
182
|
+
const { scope: m, children: _, ...g } = I, b = C.useRef(null), S = D(d, b), P = s(f, m);
|
|
183
|
+
return C.useEffect(() => (P.itemMap.set(b, { ref: b, ...g }), () => void P.itemMap.delete(b))), /* @__PURE__ */ a(A, { [v]: "", ref: S, children: _ });
|
|
184
184
|
}
|
|
185
185
|
);
|
|
186
|
-
p.displayName =
|
|
186
|
+
p.displayName = f;
|
|
187
187
|
function h(I) {
|
|
188
|
-
const
|
|
188
|
+
const d = s(e + "CollectionConsumer", I);
|
|
189
189
|
return C.useCallback(() => {
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
192
|
-
const g = Array.from(
|
|
193
|
-
return Array.from(
|
|
194
|
-
(
|
|
190
|
+
const _ = d.collectionRef.current;
|
|
191
|
+
if (!_) return [];
|
|
192
|
+
const g = Array.from(_.querySelectorAll(`[${v}]`));
|
|
193
|
+
return Array.from(d.itemMap.values()).sort(
|
|
194
|
+
(P, x) => g.indexOf(P.ref.current) - g.indexOf(x.ref.current)
|
|
195
195
|
);
|
|
196
|
-
}, [
|
|
196
|
+
}, [d.collectionRef, d.itemMap]);
|
|
197
197
|
}
|
|
198
198
|
return [
|
|
199
199
|
{ Provider: c, Slot: i, ItemSlot: p },
|
|
@@ -201,12 +201,12 @@ function _e(e) {
|
|
|
201
201
|
r
|
|
202
202
|
];
|
|
203
203
|
}
|
|
204
|
-
var
|
|
205
|
-
},
|
|
204
|
+
var Pe = globalThis != null && globalThis.document ? l.useLayoutEffect : () => {
|
|
205
|
+
}, Ge = l.useId || (() => {
|
|
206
206
|
}), Ee = 0;
|
|
207
207
|
function xe(e) {
|
|
208
|
-
const [t, o] = l.useState(
|
|
209
|
-
return
|
|
208
|
+
const [t, o] = l.useState(Ge());
|
|
209
|
+
return Pe(() => {
|
|
210
210
|
o((r) => r ?? String(Ee++));
|
|
211
211
|
}, [e]), t ? `radix-${t}` : "";
|
|
212
212
|
}
|
|
@@ -219,19 +219,19 @@ function $(e) {
|
|
|
219
219
|
return (r = t.current) == null ? void 0 : r.call(t, ...o);
|
|
220
220
|
}, []);
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function F({
|
|
223
223
|
prop: e,
|
|
224
224
|
defaultProp: t,
|
|
225
225
|
onChange: o = () => {
|
|
226
226
|
}
|
|
227
227
|
}) {
|
|
228
228
|
const [r, n] = we({ defaultProp: t, onChange: o }), s = e !== void 0, c = s ? e : r, u = $(o), i = l.useCallback(
|
|
229
|
-
(
|
|
229
|
+
(f) => {
|
|
230
230
|
if (s) {
|
|
231
|
-
const p = typeof
|
|
231
|
+
const p = typeof f == "function" ? f(e) : f;
|
|
232
232
|
p !== e && u(p);
|
|
233
233
|
} else
|
|
234
|
-
n(
|
|
234
|
+
n(f);
|
|
235
235
|
},
|
|
236
236
|
[s, e, n, u]
|
|
237
237
|
);
|
|
@@ -251,13 +251,13 @@ function q(e) {
|
|
|
251
251
|
const t = l.useContext(Ae);
|
|
252
252
|
return e || t || "ltr";
|
|
253
253
|
}
|
|
254
|
-
var O = "rovingFocusGroup.onEntryFocus",
|
|
255
|
-
|
|
256
|
-
[
|
|
257
|
-
), [Me, Oe] =
|
|
254
|
+
var O = "rovingFocusGroup.onEntryFocus", Ne = { bubbles: !1, cancelable: !0 }, k = "RovingFocusGroup", [V, Z, Fe] = Se(k), [ke, J] = U(
|
|
255
|
+
k,
|
|
256
|
+
[Fe]
|
|
257
|
+
), [Me, Oe] = ke(k), Q = l.forwardRef(
|
|
258
258
|
(e, t) => /* @__PURE__ */ a(V.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ a(V.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ a(De, { ...e, ref: t }) }) })
|
|
259
259
|
);
|
|
260
|
-
Q.displayName =
|
|
260
|
+
Q.displayName = k;
|
|
261
261
|
var De = l.forwardRef((e, t) => {
|
|
262
262
|
const {
|
|
263
263
|
__scopeRovingFocusGroup: o,
|
|
@@ -267,37 +267,37 @@ var De = l.forwardRef((e, t) => {
|
|
|
267
267
|
currentTabStopId: c,
|
|
268
268
|
defaultCurrentTabStopId: u,
|
|
269
269
|
onCurrentTabStopIdChange: i,
|
|
270
|
-
onEntryFocus:
|
|
270
|
+
onEntryFocus: f,
|
|
271
271
|
preventScrollOnEntryFocus: v = !1,
|
|
272
272
|
...p
|
|
273
|
-
} = e, h = l.useRef(null), I = D(t, h),
|
|
273
|
+
} = e, h = l.useRef(null), I = D(t, h), d = q(s), [m = null, _] = F({
|
|
274
274
|
prop: c,
|
|
275
275
|
defaultProp: u,
|
|
276
276
|
onChange: i
|
|
277
|
-
}), [g, b] = l.useState(!1),
|
|
277
|
+
}), [g, b] = l.useState(!1), S = $(f), P = Z(o), x = l.useRef(!1), [ae, K] = l.useState(0);
|
|
278
278
|
return l.useEffect(() => {
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
return
|
|
282
|
-
}, [
|
|
279
|
+
const T = h.current;
|
|
280
|
+
if (T)
|
|
281
|
+
return T.addEventListener(O, S), () => T.removeEventListener(O, S);
|
|
282
|
+
}, [S]), /* @__PURE__ */ a(
|
|
283
283
|
Me,
|
|
284
284
|
{
|
|
285
285
|
scope: o,
|
|
286
286
|
orientation: r,
|
|
287
|
-
dir:
|
|
287
|
+
dir: d,
|
|
288
288
|
loop: n,
|
|
289
289
|
currentTabStopId: m,
|
|
290
290
|
onItemFocus: l.useCallback(
|
|
291
|
-
(
|
|
292
|
-
[
|
|
291
|
+
(T) => _(T),
|
|
292
|
+
[_]
|
|
293
293
|
),
|
|
294
294
|
onItemShiftTab: l.useCallback(() => b(!0), []),
|
|
295
295
|
onFocusableItemAdd: l.useCallback(
|
|
296
|
-
() => K((
|
|
296
|
+
() => K((T) => T + 1),
|
|
297
297
|
[]
|
|
298
298
|
),
|
|
299
299
|
onFocusableItemRemove: l.useCallback(
|
|
300
|
-
() => K((
|
|
300
|
+
() => K((T) => T - 1),
|
|
301
301
|
[]
|
|
302
302
|
),
|
|
303
303
|
children: /* @__PURE__ */ a(
|
|
@@ -308,15 +308,15 @@ var De = l.forwardRef((e, t) => {
|
|
|
308
308
|
...p,
|
|
309
309
|
ref: I,
|
|
310
310
|
style: { outline: "none", ...e.style },
|
|
311
|
-
onMouseDown:
|
|
311
|
+
onMouseDown: y(e.onMouseDown, () => {
|
|
312
312
|
x.current = !0;
|
|
313
313
|
}),
|
|
314
|
-
onFocus:
|
|
314
|
+
onFocus: y(e.onFocus, (T) => {
|
|
315
315
|
const ie = !x.current;
|
|
316
|
-
if (
|
|
317
|
-
const j = new CustomEvent(O,
|
|
318
|
-
if (
|
|
319
|
-
const M =
|
|
316
|
+
if (T.target === T.currentTarget && ie && !g) {
|
|
317
|
+
const j = new CustomEvent(O, Ne);
|
|
318
|
+
if (T.currentTarget.dispatchEvent(j), !j.defaultPrevented) {
|
|
319
|
+
const M = P().filter((R) => R.focusable), de = M.find((R) => R.active), fe = M.find((R) => R.id === m), pe = [de, fe, ...M].filter(
|
|
320
320
|
Boolean
|
|
321
321
|
).map((R) => R.ref.current);
|
|
322
322
|
ee(pe, v);
|
|
@@ -324,7 +324,7 @@ var De = l.forwardRef((e, t) => {
|
|
|
324
324
|
}
|
|
325
325
|
x.current = !1;
|
|
326
326
|
}),
|
|
327
|
-
onBlur:
|
|
327
|
+
onBlur: y(e.onBlur, () => b(!1))
|
|
328
328
|
}
|
|
329
329
|
)
|
|
330
330
|
}
|
|
@@ -337,7 +337,7 @@ var De = l.forwardRef((e, t) => {
|
|
|
337
337
|
active: n = !1,
|
|
338
338
|
tabStopId: s,
|
|
339
339
|
...c
|
|
340
|
-
} = e, u = xe(), i = s || u,
|
|
340
|
+
} = e, u = xe(), i = s || u, f = Oe(X, o), v = f.currentTabStopId === i, p = Z(o), { onFocusableItemAdd: h, onFocusableItemRemove: I } = f;
|
|
341
341
|
return l.useEffect(() => {
|
|
342
342
|
if (r)
|
|
343
343
|
return h(), () => I();
|
|
@@ -352,29 +352,29 @@ var De = l.forwardRef((e, t) => {
|
|
|
352
352
|
w.span,
|
|
353
353
|
{
|
|
354
354
|
tabIndex: v ? 0 : -1,
|
|
355
|
-
"data-orientation":
|
|
355
|
+
"data-orientation": f.orientation,
|
|
356
356
|
...c,
|
|
357
357
|
ref: t,
|
|
358
|
-
onMouseDown:
|
|
359
|
-
r ?
|
|
358
|
+
onMouseDown: y(e.onMouseDown, (d) => {
|
|
359
|
+
r ? f.onItemFocus(i) : d.preventDefault();
|
|
360
360
|
}),
|
|
361
|
-
onFocus:
|
|
362
|
-
onKeyDown:
|
|
363
|
-
if (
|
|
364
|
-
|
|
361
|
+
onFocus: y(e.onFocus, () => f.onItemFocus(i)),
|
|
362
|
+
onKeyDown: y(e.onKeyDown, (d) => {
|
|
363
|
+
if (d.key === "Tab" && d.shiftKey) {
|
|
364
|
+
f.onItemShiftTab();
|
|
365
365
|
return;
|
|
366
366
|
}
|
|
367
|
-
if (
|
|
368
|
-
const m = Ue(
|
|
367
|
+
if (d.target !== d.currentTarget) return;
|
|
368
|
+
const m = Ue(d, f.orientation, f.dir);
|
|
369
369
|
if (m !== void 0) {
|
|
370
|
-
if (
|
|
371
|
-
|
|
370
|
+
if (d.metaKey || d.ctrlKey || d.altKey || d.shiftKey) return;
|
|
371
|
+
d.preventDefault();
|
|
372
372
|
let g = p().filter((b) => b.focusable).map((b) => b.ref.current);
|
|
373
373
|
if (m === "last") g.reverse();
|
|
374
374
|
else if (m === "prev" || m === "next") {
|
|
375
375
|
m === "prev" && g.reverse();
|
|
376
|
-
const b = g.indexOf(
|
|
377
|
-
g =
|
|
376
|
+
const b = g.indexOf(d.currentTarget);
|
|
377
|
+
g = f.loop ? $e(g, b + 1) : g.slice(b + 1);
|
|
378
378
|
}
|
|
379
379
|
setTimeout(() => ee(g));
|
|
380
380
|
}
|
|
@@ -413,7 +413,7 @@ function $e(e, t) {
|
|
|
413
413
|
return e.map((o, r) => e[(t + r) % e.length]);
|
|
414
414
|
}
|
|
415
415
|
var Be = Q, Ke = H, je = "Toggle", te = l.forwardRef((e, t) => {
|
|
416
|
-
const { pressed: o, defaultPressed: r = !1, onPressedChange: n, ...s } = e, [c = !1, u] =
|
|
416
|
+
const { pressed: o, defaultPressed: r = !1, onPressedChange: n, ...s } = e, [c = !1, u] = F({
|
|
417
417
|
prop: o,
|
|
418
418
|
onChange: n,
|
|
419
419
|
defaultProp: r
|
|
@@ -427,7 +427,7 @@ var Be = Q, Ke = H, je = "Toggle", te = l.forwardRef((e, t) => {
|
|
|
427
427
|
"data-disabled": e.disabled ? "" : void 0,
|
|
428
428
|
...s,
|
|
429
429
|
ref: t,
|
|
430
|
-
onClick:
|
|
430
|
+
onClick: y(e.onClick, () => {
|
|
431
431
|
e.disabled || u(!c);
|
|
432
432
|
})
|
|
433
433
|
}
|
|
@@ -452,7 +452,7 @@ var [ne, se] = oe(E), We = C.forwardRef((e, t) => {
|
|
|
452
452
|
onValueChange: n = () => {
|
|
453
453
|
},
|
|
454
454
|
...s
|
|
455
|
-
} = e, [c, u] =
|
|
455
|
+
} = e, [c, u] = F({
|
|
456
456
|
prop: o,
|
|
457
457
|
defaultProp: r,
|
|
458
458
|
onChange: n
|
|
@@ -475,14 +475,14 @@ var [ne, se] = oe(E), We = C.forwardRef((e, t) => {
|
|
|
475
475
|
onValueChange: n = () => {
|
|
476
476
|
},
|
|
477
477
|
...s
|
|
478
|
-
} = e, [c = [], u] =
|
|
478
|
+
} = e, [c = [], u] = F({
|
|
479
479
|
prop: o,
|
|
480
480
|
defaultProp: r,
|
|
481
481
|
onChange: n
|
|
482
482
|
}), i = C.useCallback(
|
|
483
483
|
(v) => u((p = []) => [...p, v]),
|
|
484
484
|
[u]
|
|
485
|
-
),
|
|
485
|
+
), f = C.useCallback(
|
|
486
486
|
(v) => u((p = []) => p.filter((h) => h !== v)),
|
|
487
487
|
[u]
|
|
488
488
|
);
|
|
@@ -493,7 +493,7 @@ var [ne, se] = oe(E), We = C.forwardRef((e, t) => {
|
|
|
493
493
|
type: "multiple",
|
|
494
494
|
value: c,
|
|
495
495
|
onItemActivate: i,
|
|
496
|
-
onItemDeactivate:
|
|
496
|
+
onItemDeactivate: f,
|
|
497
497
|
children: /* @__PURE__ */ a(ce, { ...s, ref: t })
|
|
498
498
|
}
|
|
499
499
|
);
|
|
@@ -509,12 +509,12 @@ var [ze, qe] = oe(E), ce = C.forwardRef(
|
|
|
509
509
|
dir: c,
|
|
510
510
|
loop: u = !0,
|
|
511
511
|
...i
|
|
512
|
-
} = e,
|
|
512
|
+
} = e, f = re(o), v = q(c), p = { role: "group", dir: v, ...i };
|
|
513
513
|
return /* @__PURE__ */ a(ze, { scope: o, rovingFocus: n, disabled: r, children: n ? /* @__PURE__ */ a(
|
|
514
514
|
Be,
|
|
515
515
|
{
|
|
516
516
|
asChild: !0,
|
|
517
|
-
...
|
|
517
|
+
...f,
|
|
518
518
|
orientation: s,
|
|
519
519
|
dir: v,
|
|
520
520
|
loop: u,
|
|
@@ -522,9 +522,9 @@ var [ze, qe] = oe(E), ce = C.forwardRef(
|
|
|
522
522
|
}
|
|
523
523
|
) : /* @__PURE__ */ a(w.div, { ...p, ref: t }) });
|
|
524
524
|
}
|
|
525
|
-
),
|
|
525
|
+
), N = "ToggleGroupItem", ue = C.forwardRef(
|
|
526
526
|
(e, t) => {
|
|
527
|
-
const o = se(
|
|
527
|
+
const o = se(N, e.__scopeToggleGroup), r = qe(N, e.__scopeToggleGroup), n = re(e.__scopeToggleGroup), s = o.value.includes(e.value), c = r.disabled || e.disabled, u = { ...e, pressed: s, disabled: c }, i = C.useRef(null);
|
|
528
528
|
return r.rovingFocus ? /* @__PURE__ */ a(
|
|
529
529
|
Ke,
|
|
530
530
|
{
|
|
@@ -538,10 +538,10 @@ var [ze, qe] = oe(E), ce = C.forwardRef(
|
|
|
538
538
|
) : /* @__PURE__ */ a(Y, { ...u, ref: t });
|
|
539
539
|
}
|
|
540
540
|
);
|
|
541
|
-
ue.displayName =
|
|
541
|
+
ue.displayName = N;
|
|
542
542
|
var Y = C.forwardRef(
|
|
543
543
|
(e, t) => {
|
|
544
|
-
const { __scopeToggleGroup: o, value: r, ...n } = e, s = se(
|
|
544
|
+
const { __scopeToggleGroup: o, value: r, ...n } = e, s = se(N, o), c = { role: "radio", "aria-checked": e.pressed, "aria-pressed": void 0 }, u = s.type === "single" ? c : void 0;
|
|
545
545
|
return /* @__PURE__ */ a(
|
|
546
546
|
te,
|
|
547
547
|
{
|
|
@@ -559,7 +559,21 @@ const le = C.createContext({
|
|
|
559
559
|
size: "medium",
|
|
560
560
|
focusMode: "system",
|
|
561
561
|
mode: "system"
|
|
562
|
-
})
|
|
562
|
+
});
|
|
563
|
+
/*!
|
|
564
|
+
@versini/ui-spacing v1.0.0
|
|
565
|
+
© 2024 gizmette.com
|
|
566
|
+
*/
|
|
567
|
+
try {
|
|
568
|
+
window.__VERSINI_UI_SPACING__ || (window.__VERSINI_UI_SPACING__ = {
|
|
569
|
+
version: "1.0.0",
|
|
570
|
+
buildTime: "12/24/2024 06:47 PM EST",
|
|
571
|
+
homepage: "https://github.com/aversini/ui-components",
|
|
572
|
+
license: "MIT"
|
|
573
|
+
});
|
|
574
|
+
} catch {
|
|
575
|
+
}
|
|
576
|
+
const Qe = (e) => {
|
|
563
577
|
let t = "";
|
|
564
578
|
if (typeof e == "number" || typeof e == "string")
|
|
565
579
|
t = "m-" + e;
|
|
@@ -568,21 +582,21 @@ const le = C.createContext({
|
|
|
568
582
|
(e == null ? void 0 : e.t) !== void 0 && o.push(`mt-${e.t}`), (e == null ? void 0 : e.r) !== void 0 && o.push(`mr-${e.r}`), (e == null ? void 0 : e.b) !== void 0 && o.push(`mb-${e.b}`), (e == null ? void 0 : e.l) !== void 0 && o.push(`ml-${e.l}`), t = o.join(" ");
|
|
569
583
|
}
|
|
570
584
|
return t;
|
|
571
|
-
}, Xe = ({ focusMode: e }) =>
|
|
585
|
+
}, Xe = ({ focusMode: e }) => G("focus:outline", "focus:outline-2", "focus:outline-offset", {
|
|
572
586
|
"focus:outline-focus-light": e === "light",
|
|
573
587
|
"focus:outline-focus-dark": e === "dark",
|
|
574
588
|
"focus:outline-focus-light dark:focus:outline-focus-dark": e === "alt-system",
|
|
575
589
|
"focus:outline-focus-dark dark:focus:outline-focus-light": e === "system"
|
|
576
|
-
}), He = ({ mode: e }) =>
|
|
590
|
+
}), He = ({ mode: e }) => G({
|
|
577
591
|
"data-[state=on]:bg-surface-medium": e === "dark",
|
|
578
592
|
"data-[state=on]:bg-surface-lightest": e === "light",
|
|
579
593
|
"data-[state=on]:bg-surface-lightest dark:data-[state=on]:bg-surface-medium": e === "system",
|
|
580
594
|
"data-[state=on]:bg-surface-medium dark:data-[state=on]:bg-surface-lightest": e === "alt-system"
|
|
581
|
-
}), et = ({ size: e }) =>
|
|
595
|
+
}), et = ({ size: e }) => G({
|
|
582
596
|
"h-5 px-2": e === "small",
|
|
583
597
|
"h-6 px-3": e === "medium",
|
|
584
598
|
"h-7 px-4": e === "large"
|
|
585
|
-
}), tt = ({ mode: e }) =>
|
|
599
|
+
}), tt = ({ mode: e }) => G(
|
|
586
600
|
Ce,
|
|
587
601
|
"px-1",
|
|
588
602
|
"relative",
|
|
@@ -602,7 +616,7 @@ const le = C.createContext({
|
|
|
602
616
|
size: o
|
|
603
617
|
}) => ({
|
|
604
618
|
wrapperClass: tt({ mode: t }),
|
|
605
|
-
itemClass:
|
|
619
|
+
itemClass: G(
|
|
606
620
|
he,
|
|
607
621
|
"flex items-center justify-center bg-transparent",
|
|
608
622
|
"rounded-sm",
|
|
@@ -614,7 +628,7 @@ const le = C.createContext({
|
|
|
614
628
|
}), rt = ({
|
|
615
629
|
mode: e,
|
|
616
630
|
spacing: t
|
|
617
|
-
}) =>
|
|
631
|
+
}) => G(
|
|
618
632
|
ve,
|
|
619
633
|
Qe(t),
|
|
620
634
|
"inline-flex p-1",
|
|
@@ -635,7 +649,7 @@ const le = C.createContext({
|
|
|
635
649
|
size: c = "medium",
|
|
636
650
|
defaultValue: u,
|
|
637
651
|
spacing: i,
|
|
638
|
-
...
|
|
652
|
+
...f
|
|
639
653
|
}) => {
|
|
640
654
|
const v = rt({ mode: n, spacing: i }), p = { size: c, focusMode: s, mode: n };
|
|
641
655
|
return /* @__PURE__ */ a(le.Provider, { value: p, children: /* @__PURE__ */ a(
|
|
@@ -646,7 +660,7 @@ const le = C.createContext({
|
|
|
646
660
|
value: t,
|
|
647
661
|
defaultValue: u,
|
|
648
662
|
onValueChange: o,
|
|
649
|
-
...
|
|
663
|
+
...f,
|
|
650
664
|
type: "single",
|
|
651
665
|
children: e
|
|
652
666
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-togglegroup",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -40,12 +40,14 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@radix-ui/react-toggle-group": "1.1.1",
|
|
42
42
|
"@tailwindcss/typography": "0.5.15",
|
|
43
|
-
"@versini/ui-private": "1.
|
|
43
|
+
"@versini/ui-private": "1.6.0",
|
|
44
|
+
"@versini/ui-spacing": "1.0.0",
|
|
45
|
+
"@versini/ui-spacing-types": "1.0.0",
|
|
44
46
|
"clsx": "2.1.1",
|
|
45
47
|
"tailwindcss": "3.4.17"
|
|
46
48
|
},
|
|
47
49
|
"sideEffects": [
|
|
48
50
|
"**/*.css"
|
|
49
51
|
],
|
|
50
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "cb948414a675c01f3328ed6470ccf4b58f73534f"
|
|
51
53
|
}
|