@versini/ui-togglegroup 1.2.0 → 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 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 { SpacingProps } from '@versini/ui-private/dist/utilities';
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
- SpacingProps;
27
+ SpacingTypes.Props;
28
28
 
29
29
  type ToggleGroupItemProps = ToggleGroupRadix.ToggleGroupItemProps;
30
30
 
package/dist/index.js CHANGED
@@ -1,51 +1,54 @@
1
- import { jsx as l, Fragment as pe } from "react/jsx-runtime";
2
- import * as a from "react";
3
- import v, { useContext as ge } from "react";
4
- import P from "clsx";
1
+ import { jsx as a, Fragment as ge } from "react/jsx-runtime";
2
+ import * as l from "react";
3
+ import C, { useContext as me } from "react";
4
+ import G from "clsx";
5
5
  /*!
6
- @versini/ui-togglegroup v1.2.0
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.2.0",
12
- buildTime: "12/18/2024 12:35 PM EST",
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
  });
16
16
  } catch {
17
17
  }
18
- const me = "av-togglegroup", ve = "av-togglegroup-item-wrapper", Ce = "av-togglegroup-item";
18
+ const ve = "av-togglegroup", Ce = "av-togglegroup-item-wrapper", he = "av-togglegroup-item";
19
19
  function U(e, t = []) {
20
20
  let o = [];
21
21
  function r(s, c) {
22
- const u = a.createContext(c), i = o.length;
22
+ const u = l.createContext(c), i = o.length;
23
23
  o = [...o, c];
24
- function f(p) {
25
- const { scope: C, children: I, ...d } = p, h = (C == null ? void 0 : C[e][i]) || u, T = a.useMemo(() => d, Object.values(d));
26
- return /* @__PURE__ */ l(h.Provider, { value: T, children: I });
27
- }
28
- function g(p, C) {
29
- const I = (C == null ? void 0 : C[e][i]) || u, d = a.useContext(I);
24
+ const f = (p) => {
25
+ var g;
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
+ };
29
+ f.displayName = s + "Provider";
30
+ function v(p, h) {
31
+ var m;
32
+ const I = ((m = h == null ? void 0 : h[e]) == null ? void 0 : m[i]) || u, d = l.useContext(I);
30
33
  if (d) return d;
31
34
  if (c !== void 0) return c;
32
35
  throw new Error(`\`${p}\` must be used within \`${s}\``);
33
36
  }
34
- return f.displayName = s + "Provider", [f, g];
37
+ return [f, v];
35
38
  }
36
39
  const n = () => {
37
- const s = o.map((c) => a.createContext(c));
40
+ const s = o.map((c) => l.createContext(c));
38
41
  return function(u) {
39
42
  const i = (u == null ? void 0 : u[e]) || s;
40
- return a.useMemo(
43
+ return l.useMemo(
41
44
  () => ({ [`__scope${e}`]: { ...u, [e]: i } }),
42
45
  [u, i]
43
46
  );
44
47
  };
45
48
  };
46
- return n.scopeName = e, [r, he(n, ...t)];
49
+ return n.scopeName = e, [r, be(n, ...t)];
47
50
  }
48
- function he(...e) {
51
+ function be(...e) {
49
52
  const t = e[0];
50
53
  if (e.length === 1) return t;
51
54
  const o = () => {
@@ -58,47 +61,62 @@ function he(...e) {
58
61
  const p = i(s)[`__scope${f}`];
59
62
  return { ...u, ...p };
60
63
  }, {});
61
- return a.useMemo(() => ({ [`__scope${t.scopeName}`]: c }), [c]);
64
+ return l.useMemo(() => ({ [`__scope${t.scopeName}`]: c }), [c]);
62
65
  };
63
66
  };
64
67
  return o.scopeName = t.scopeName, o;
65
68
  }
66
- function be(e, t) {
67
- typeof e == "function" ? e(t) : e != null && (e.current = t);
69
+ function W(e, t) {
70
+ if (typeof e == "function")
71
+ return e(t);
72
+ e != null && (e.current = t);
68
73
  }
69
- function Y(...e) {
70
- return (t) => e.forEach((o) => be(o, t));
74
+ function z(...e) {
75
+ return (t) => {
76
+ let o = !1;
77
+ const r = e.map((n) => {
78
+ const s = W(n, t);
79
+ return !o && typeof s == "function" && (o = !0), s;
80
+ });
81
+ if (o)
82
+ return () => {
83
+ for (let n = 0; n < r.length; n++) {
84
+ const s = r[n];
85
+ typeof s == "function" ? s() : W(e[n], null);
86
+ }
87
+ };
88
+ };
71
89
  }
72
90
  function D(...e) {
73
- return a.useCallback(Y(...e), e);
91
+ return l.useCallback(z(...e), e);
74
92
  }
75
- var A = a.forwardRef((e, t) => {
76
- const { children: o, ...r } = e, n = a.Children.toArray(o), s = n.find(Te);
93
+ var A = l.forwardRef((e, t) => {
94
+ const { children: o, ...r } = e, n = l.Children.toArray(o), s = n.find(_e);
77
95
  if (s) {
78
- const c = s.props.children, u = n.map((i) => i === s ? a.Children.count(c) > 1 ? a.Children.only(null) : a.isValidElement(c) ? c.props.children : null : i);
79
- return /* @__PURE__ */ l(L, { ...r, ref: t, children: a.isValidElement(c) ? a.cloneElement(c, void 0, u) : null });
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
+ return /* @__PURE__ */ a(L, { ...r, ref: t, children: l.isValidElement(c) ? l.cloneElement(c, void 0, u) : null });
80
98
  }
81
- return /* @__PURE__ */ l(L, { ...r, ref: t, children: o });
99
+ return /* @__PURE__ */ a(L, { ...r, ref: t, children: o });
82
100
  });
83
101
  A.displayName = "Slot";
84
- var L = a.forwardRef((e, t) => {
102
+ var L = l.forwardRef((e, t) => {
85
103
  const { children: o, ...r } = e;
86
- if (a.isValidElement(o)) {
87
- const n = ye(o);
88
- return a.cloneElement(o, {
89
- ...Re(r, o.props),
104
+ if (l.isValidElement(o)) {
105
+ const n = Re(o);
106
+ return l.cloneElement(o, {
107
+ ...Te(r, o.props),
90
108
  // @ts-ignore
91
- ref: t ? Y(t, n) : n
109
+ ref: t ? z(t, n) : n
92
110
  });
93
111
  }
94
- return a.Children.count(o) > 1 ? a.Children.only(null) : null;
112
+ return l.Children.count(o) > 1 ? l.Children.only(null) : null;
95
113
  });
96
114
  L.displayName = "SlotClone";
97
- var Ie = ({ children: e }) => /* @__PURE__ */ l(pe, { children: e });
98
- function Te(e) {
99
- return a.isValidElement(e) && e.type === Ie;
115
+ var Ie = ({ children: e }) => /* @__PURE__ */ a(ge, { children: e });
116
+ function _e(e) {
117
+ return l.isValidElement(e) && e.type === Ie;
100
118
  }
101
- function Re(e, t) {
119
+ function Te(e, t) {
102
120
  const o = { ...t };
103
121
  for (const r in t) {
104
122
  const n = e[r], s = t[r];
@@ -108,12 +126,12 @@ function Re(e, t) {
108
126
  }
109
127
  return { ...e, ...o };
110
128
  }
111
- function ye(e) {
129
+ function Re(e) {
112
130
  var r, n;
113
131
  let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, o = t && "isReactWarning" in t && t.isReactWarning;
114
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);
115
133
  }
116
- var Se = [
134
+ var ye = [
117
135
  "a",
118
136
  "button",
119
137
  "div",
@@ -130,84 +148,84 @@ var Se = [
130
148
  "span",
131
149
  "svg",
132
150
  "ul"
133
- ], w = Se.reduce((e, t) => {
134
- const o = a.forwardRef((r, n) => {
151
+ ], w = ye.reduce((e, t) => {
152
+ const o = l.forwardRef((r, n) => {
135
153
  const { asChild: s, ...c } = r, u = s ? A : t;
136
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ l(u, { ...c, ref: n });
154
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ a(u, { ...c, ref: n });
137
155
  });
138
156
  return o.displayName = `Primitive.${t}`, { ...e, [t]: o };
139
157
  }, {});
140
- function S(e, t, { checkForDefaultPrevented: o = !0 } = {}) {
158
+ function y(e, t, { checkForDefaultPrevented: o = !0 } = {}) {
141
159
  return function(n) {
142
160
  if (e == null || e(n), o === !1 || !n.defaultPrevented)
143
161
  return t == null ? void 0 : t(n);
144
162
  };
145
163
  }
146
- function _e(e) {
164
+ function Se(e) {
147
165
  const t = e + "CollectionProvider", [o, r] = U(t), [n, s] = o(
148
166
  t,
149
167
  { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
150
168
  ), c = (I) => {
151
- const { scope: d, children: h } = I, T = v.useRef(null), m = v.useRef(/* @__PURE__ */ new Map()).current;
152
- return /* @__PURE__ */ l(n, { scope: d, itemMap: m, collectionRef: T, children: h });
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 });
153
171
  };
154
172
  c.displayName = t;
155
- const u = e + "CollectionSlot", i = v.forwardRef(
173
+ const u = e + "CollectionSlot", i = C.forwardRef(
156
174
  (I, d) => {
157
- const { scope: h, children: T } = I, m = s(u, h), b = D(d, m.collectionRef);
158
- return /* @__PURE__ */ l(A, { ref: b, children: T });
175
+ const { scope: m, children: _ } = I, g = s(u, m), b = D(d, g.collectionRef);
176
+ return /* @__PURE__ */ a(A, { ref: b, children: _ });
159
177
  }
160
178
  );
161
179
  i.displayName = u;
162
- const f = e + "CollectionItemSlot", g = "data-radix-collection-item", p = v.forwardRef(
180
+ const f = e + "CollectionItemSlot", v = "data-radix-collection-item", p = C.forwardRef(
163
181
  (I, d) => {
164
- const { scope: h, children: T, ...m } = I, b = v.useRef(null), _ = D(d, b), G = s(f, h);
165
- return v.useEffect(() => (G.itemMap.set(b, { ref: b, ...m }), () => void G.itemMap.delete(b))), /* @__PURE__ */ l(A, { [g]: "", ref: _, children: T });
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: _ });
166
184
  }
167
185
  );
168
186
  p.displayName = f;
169
- function C(I) {
187
+ function h(I) {
170
188
  const d = s(e + "CollectionConsumer", I);
171
- return v.useCallback(() => {
172
- const T = d.collectionRef.current;
173
- if (!T) return [];
174
- const m = Array.from(T.querySelectorAll(`[${g}]`));
189
+ return C.useCallback(() => {
190
+ const _ = d.collectionRef.current;
191
+ if (!_) return [];
192
+ const g = Array.from(_.querySelectorAll(`[${v}]`));
175
193
  return Array.from(d.itemMap.values()).sort(
176
- (G, x) => m.indexOf(G.ref.current) - m.indexOf(x.ref.current)
194
+ (P, x) => g.indexOf(P.ref.current) - g.indexOf(x.ref.current)
177
195
  );
178
196
  }, [d.collectionRef, d.itemMap]);
179
197
  }
180
198
  return [
181
199
  { Provider: c, Slot: i, ItemSlot: p },
182
- C,
200
+ h,
183
201
  r
184
202
  ];
185
203
  }
186
- var Ge = globalThis != null && globalThis.document ? a.useLayoutEffect : () => {
187
- }, Pe = a.useId || (() => {
204
+ var Pe = globalThis != null && globalThis.document ? l.useLayoutEffect : () => {
205
+ }, Ge = l.useId || (() => {
188
206
  }), Ee = 0;
189
207
  function xe(e) {
190
- const [t, o] = a.useState(Pe());
191
- return Ge(() => {
208
+ const [t, o] = l.useState(Ge());
209
+ return Pe(() => {
192
210
  o((r) => r ?? String(Ee++));
193
211
  }, [e]), t ? `radix-${t}` : "";
194
212
  }
195
213
  function $(e) {
196
- const t = a.useRef(e);
197
- return a.useEffect(() => {
214
+ const t = l.useRef(e);
215
+ return l.useEffect(() => {
198
216
  t.current = e;
199
- }), a.useMemo(() => (...o) => {
217
+ }), l.useMemo(() => (...o) => {
200
218
  var r;
201
219
  return (r = t.current) == null ? void 0 : r.call(t, ...o);
202
220
  }, []);
203
221
  }
204
- function k({
222
+ function F({
205
223
  prop: e,
206
224
  defaultProp: t,
207
225
  onChange: o = () => {
208
226
  }
209
227
  }) {
210
- const [r, n] = we({ defaultProp: t, onChange: o }), s = e !== void 0, c = s ? e : r, u = $(o), i = a.useCallback(
228
+ const [r, n] = we({ defaultProp: t, onChange: o }), s = e !== void 0, c = s ? e : r, u = $(o), i = l.useCallback(
211
229
  (f) => {
212
230
  if (s) {
213
231
  const p = typeof f == "function" ? f(e) : f;
@@ -223,24 +241,24 @@ function we({
223
241
  defaultProp: e,
224
242
  onChange: t
225
243
  }) {
226
- const o = a.useState(e), [r] = o, n = a.useRef(r), s = $(t);
227
- return a.useEffect(() => {
244
+ const o = l.useState(e), [r] = o, n = l.useRef(r), s = $(t);
245
+ return l.useEffect(() => {
228
246
  n.current !== r && (s(r), n.current = r);
229
247
  }, [r, n, s]), o;
230
248
  }
231
- var Ae = a.createContext(void 0);
232
- function z(e) {
233
- const t = a.useContext(Ae);
249
+ var Ae = l.createContext(void 0);
250
+ function q(e) {
251
+ const t = l.useContext(Ae);
234
252
  return e || t || "ltr";
235
253
  }
236
- var O = "rovingFocusGroup.onEntryFocus", Fe = { bubbles: !1, cancelable: !0 }, N = "RovingFocusGroup", [V, q, ke] = _e(N), [Ne, Z] = U(
237
- N,
238
- [ke]
239
- ), [Me, Oe] = Ne(N), J = a.forwardRef(
240
- (e, t) => /* @__PURE__ */ l(V.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ l(V.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ l(De, { ...e, ref: t }) }) })
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
+ (e, t) => /* @__PURE__ */ a(V.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ a(V.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ a(De, { ...e, ref: t }) }) })
241
259
  );
242
- J.displayName = N;
243
- var De = a.forwardRef((e, t) => {
260
+ Q.displayName = k;
261
+ var De = l.forwardRef((e, t) => {
244
262
  const {
245
263
  __scopeRovingFocusGroup: o,
246
264
  orientation: r,
@@ -250,68 +268,68 @@ var De = a.forwardRef((e, t) => {
250
268
  defaultCurrentTabStopId: u,
251
269
  onCurrentTabStopIdChange: i,
252
270
  onEntryFocus: f,
253
- preventScrollOnEntryFocus: g = !1,
271
+ preventScrollOnEntryFocus: v = !1,
254
272
  ...p
255
- } = e, C = a.useRef(null), I = D(t, C), d = z(s), [h = null, T] = k({
273
+ } = e, h = l.useRef(null), I = D(t, h), d = q(s), [m = null, _] = F({
256
274
  prop: c,
257
275
  defaultProp: u,
258
276
  onChange: i
259
- }), [m, b] = a.useState(!1), _ = $(f), G = q(o), x = a.useRef(!1), [ae, K] = a.useState(0);
260
- return a.useEffect(() => {
261
- const R = C.current;
262
- if (R)
263
- return R.addEventListener(O, _), () => R.removeEventListener(O, _);
264
- }, [_]), /* @__PURE__ */ l(
277
+ }), [g, b] = l.useState(!1), S = $(f), P = Z(o), x = l.useRef(!1), [ae, K] = l.useState(0);
278
+ return l.useEffect(() => {
279
+ const T = h.current;
280
+ if (T)
281
+ return T.addEventListener(O, S), () => T.removeEventListener(O, S);
282
+ }, [S]), /* @__PURE__ */ a(
265
283
  Me,
266
284
  {
267
285
  scope: o,
268
286
  orientation: r,
269
287
  dir: d,
270
288
  loop: n,
271
- currentTabStopId: h,
272
- onItemFocus: a.useCallback(
273
- (R) => T(R),
274
- [T]
289
+ currentTabStopId: m,
290
+ onItemFocus: l.useCallback(
291
+ (T) => _(T),
292
+ [_]
275
293
  ),
276
- onItemShiftTab: a.useCallback(() => b(!0), []),
277
- onFocusableItemAdd: a.useCallback(
278
- () => K((R) => R + 1),
294
+ onItemShiftTab: l.useCallback(() => b(!0), []),
295
+ onFocusableItemAdd: l.useCallback(
296
+ () => K((T) => T + 1),
279
297
  []
280
298
  ),
281
- onFocusableItemRemove: a.useCallback(
282
- () => K((R) => R - 1),
299
+ onFocusableItemRemove: l.useCallback(
300
+ () => K((T) => T - 1),
283
301
  []
284
302
  ),
285
- children: /* @__PURE__ */ l(
303
+ children: /* @__PURE__ */ a(
286
304
  w.div,
287
305
  {
288
- tabIndex: m || ae === 0 ? -1 : 0,
306
+ tabIndex: g || ae === 0 ? -1 : 0,
289
307
  "data-orientation": r,
290
308
  ...p,
291
309
  ref: I,
292
310
  style: { outline: "none", ...e.style },
293
- onMouseDown: S(e.onMouseDown, () => {
311
+ onMouseDown: y(e.onMouseDown, () => {
294
312
  x.current = !0;
295
313
  }),
296
- onFocus: S(e.onFocus, (R) => {
297
- const le = !x.current;
298
- if (R.target === R.currentTarget && le && !m) {
299
- const j = new CustomEvent(O, Fe);
300
- if (R.currentTarget.dispatchEvent(j), !j.defaultPrevented) {
301
- const M = G().filter((y) => y.focusable), ie = M.find((y) => y.active), de = M.find((y) => y.id === h), fe = [ie, de, ...M].filter(
314
+ onFocus: y(e.onFocus, (T) => {
315
+ const ie = !x.current;
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(
302
320
  Boolean
303
- ).map((y) => y.ref.current);
304
- H(fe, g);
321
+ ).map((R) => R.ref.current);
322
+ ee(pe, v);
305
323
  }
306
324
  }
307
325
  x.current = !1;
308
326
  }),
309
- onBlur: S(e.onBlur, () => b(!1))
327
+ onBlur: y(e.onBlur, () => b(!1))
310
328
  }
311
329
  )
312
330
  }
313
331
  );
314
- }), Q = "RovingFocusGroupItem", X = a.forwardRef(
332
+ }), X = "RovingFocusGroupItem", H = l.forwardRef(
315
333
  (e, t) => {
316
334
  const {
317
335
  __scopeRovingFocusGroup: o,
@@ -319,46 +337,46 @@ var De = a.forwardRef((e, t) => {
319
337
  active: n = !1,
320
338
  tabStopId: s,
321
339
  ...c
322
- } = e, u = xe(), i = s || u, f = Oe(Q, o), g = f.currentTabStopId === i, p = q(o), { onFocusableItemAdd: C, onFocusableItemRemove: I } = f;
323
- return a.useEffect(() => {
340
+ } = e, u = xe(), i = s || u, f = Oe(X, o), v = f.currentTabStopId === i, p = Z(o), { onFocusableItemAdd: h, onFocusableItemRemove: I } = f;
341
+ return l.useEffect(() => {
324
342
  if (r)
325
- return C(), () => I();
326
- }, [r, C, I]), /* @__PURE__ */ l(
343
+ return h(), () => I();
344
+ }, [r, h, I]), /* @__PURE__ */ a(
327
345
  V.ItemSlot,
328
346
  {
329
347
  scope: o,
330
348
  id: i,
331
349
  focusable: r,
332
350
  active: n,
333
- children: /* @__PURE__ */ l(
351
+ children: /* @__PURE__ */ a(
334
352
  w.span,
335
353
  {
336
- tabIndex: g ? 0 : -1,
354
+ tabIndex: v ? 0 : -1,
337
355
  "data-orientation": f.orientation,
338
356
  ...c,
339
357
  ref: t,
340
- onMouseDown: S(e.onMouseDown, (d) => {
358
+ onMouseDown: y(e.onMouseDown, (d) => {
341
359
  r ? f.onItemFocus(i) : d.preventDefault();
342
360
  }),
343
- onFocus: S(e.onFocus, () => f.onItemFocus(i)),
344
- onKeyDown: S(e.onKeyDown, (d) => {
361
+ onFocus: y(e.onFocus, () => f.onItemFocus(i)),
362
+ onKeyDown: y(e.onKeyDown, (d) => {
345
363
  if (d.key === "Tab" && d.shiftKey) {
346
364
  f.onItemShiftTab();
347
365
  return;
348
366
  }
349
367
  if (d.target !== d.currentTarget) return;
350
- const h = Ue(d, f.orientation, f.dir);
351
- if (h !== void 0) {
368
+ const m = Ue(d, f.orientation, f.dir);
369
+ if (m !== void 0) {
352
370
  if (d.metaKey || d.ctrlKey || d.altKey || d.shiftKey) return;
353
371
  d.preventDefault();
354
- let m = p().filter((b) => b.focusable).map((b) => b.ref.current);
355
- if (h === "last") m.reverse();
356
- else if (h === "prev" || h === "next") {
357
- h === "prev" && m.reverse();
358
- const b = m.indexOf(d.currentTarget);
359
- m = f.loop ? $e(m, b + 1) : m.slice(b + 1);
372
+ let g = p().filter((b) => b.focusable).map((b) => b.ref.current);
373
+ if (m === "last") g.reverse();
374
+ else if (m === "prev" || m === "next") {
375
+ m === "prev" && g.reverse();
376
+ const b = g.indexOf(d.currentTarget);
377
+ g = f.loop ? $e(g, b + 1) : g.slice(b + 1);
360
378
  }
361
- setTimeout(() => H(m));
379
+ setTimeout(() => ee(g));
362
380
  }
363
381
  })
364
382
  }
@@ -367,7 +385,7 @@ var De = a.forwardRef((e, t) => {
367
385
  );
368
386
  }
369
387
  );
370
- X.displayName = Q;
388
+ H.displayName = X;
371
389
  var Le = {
372
390
  ArrowLeft: "prev",
373
391
  ArrowUp: "prev",
@@ -386,7 +404,7 @@ function Ue(e, t, o) {
386
404
  if (!(t === "vertical" && ["ArrowLeft", "ArrowRight"].includes(r)) && !(t === "horizontal" && ["ArrowUp", "ArrowDown"].includes(r)))
387
405
  return Le[r];
388
406
  }
389
- function H(e, t = !1) {
407
+ function ee(e, t = !1) {
390
408
  const o = document.activeElement;
391
409
  for (const r of e)
392
410
  if (r === o || (r.focus({ preventScroll: t }), document.activeElement !== o)) return;
@@ -394,13 +412,13 @@ function H(e, t = !1) {
394
412
  function $e(e, t) {
395
413
  return e.map((o, r) => e[(t + r) % e.length]);
396
414
  }
397
- var Be = J, Ke = X, je = "Toggle", ee = a.forwardRef((e, t) => {
398
- const { pressed: o, defaultPressed: r = !1, onPressedChange: n, ...s } = e, [c = !1, u] = k({
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] = F({
399
417
  prop: o,
400
418
  onChange: n,
401
419
  defaultProp: r
402
420
  });
403
- return /* @__PURE__ */ l(
421
+ return /* @__PURE__ */ a(
404
422
  w.button,
405
423
  {
406
424
  type: "button",
@@ -409,79 +427,79 @@ var Be = J, Ke = X, je = "Toggle", ee = a.forwardRef((e, t) => {
409
427
  "data-disabled": e.disabled ? "" : void 0,
410
428
  ...s,
411
429
  ref: t,
412
- onClick: S(e.onClick, () => {
430
+ onClick: y(e.onClick, () => {
413
431
  e.disabled || u(!c);
414
432
  })
415
433
  }
416
434
  );
417
435
  });
418
- ee.displayName = je;
419
- var E = "ToggleGroup", [te, at] = U(E, [
420
- Z
421
- ]), oe = Z(), B = v.forwardRef((e, t) => {
436
+ te.displayName = je;
437
+ var E = "ToggleGroup", [oe, lt] = U(E, [
438
+ J
439
+ ]), re = J(), B = C.forwardRef((e, t) => {
422
440
  const { type: o, ...r } = e;
423
441
  if (o === "single")
424
- return /* @__PURE__ */ l(We, { ...r, ref: t });
442
+ return /* @__PURE__ */ a(We, { ...r, ref: t });
425
443
  if (o === "multiple")
426
- return /* @__PURE__ */ l(Ye, { ...r, ref: t });
444
+ return /* @__PURE__ */ a(Ye, { ...r, ref: t });
427
445
  throw new Error(`Missing prop \`type\` expected on \`${E}\``);
428
446
  });
429
447
  B.displayName = E;
430
- var [re, ne] = te(E), We = v.forwardRef((e, t) => {
448
+ var [ne, se] = oe(E), We = C.forwardRef((e, t) => {
431
449
  const {
432
450
  value: o,
433
451
  defaultValue: r,
434
452
  onValueChange: n = () => {
435
453
  },
436
454
  ...s
437
- } = e, [c, u] = k({
455
+ } = e, [c, u] = F({
438
456
  prop: o,
439
457
  defaultProp: r,
440
458
  onChange: n
441
459
  });
442
- return /* @__PURE__ */ l(
443
- re,
460
+ return /* @__PURE__ */ a(
461
+ ne,
444
462
  {
445
463
  scope: e.__scopeToggleGroup,
446
464
  type: "single",
447
465
  value: c ? [c] : [],
448
466
  onItemActivate: u,
449
- onItemDeactivate: v.useCallback(() => u(""), [u]),
450
- children: /* @__PURE__ */ l(se, { ...s, ref: t })
467
+ onItemDeactivate: C.useCallback(() => u(""), [u]),
468
+ children: /* @__PURE__ */ a(ce, { ...s, ref: t })
451
469
  }
452
470
  );
453
- }), Ye = v.forwardRef((e, t) => {
471
+ }), Ye = C.forwardRef((e, t) => {
454
472
  const {
455
473
  value: o,
456
474
  defaultValue: r,
457
475
  onValueChange: n = () => {
458
476
  },
459
477
  ...s
460
- } = e, [c = [], u] = k({
478
+ } = e, [c = [], u] = F({
461
479
  prop: o,
462
480
  defaultProp: r,
463
481
  onChange: n
464
- }), i = v.useCallback(
465
- (g) => u((p = []) => [...p, g]),
482
+ }), i = C.useCallback(
483
+ (v) => u((p = []) => [...p, v]),
466
484
  [u]
467
- ), f = v.useCallback(
468
- (g) => u((p = []) => p.filter((C) => C !== g)),
485
+ ), f = C.useCallback(
486
+ (v) => u((p = []) => p.filter((h) => h !== v)),
469
487
  [u]
470
488
  );
471
- return /* @__PURE__ */ l(
472
- re,
489
+ return /* @__PURE__ */ a(
490
+ ne,
473
491
  {
474
492
  scope: e.__scopeToggleGroup,
475
493
  type: "multiple",
476
494
  value: c,
477
495
  onItemActivate: i,
478
496
  onItemDeactivate: f,
479
- children: /* @__PURE__ */ l(se, { ...s, ref: t })
497
+ children: /* @__PURE__ */ a(ce, { ...s, ref: t })
480
498
  }
481
499
  );
482
500
  });
483
501
  B.displayName = E;
484
- var [ze, qe] = te(E), se = v.forwardRef(
502
+ var [ze, qe] = oe(E), ce = C.forwardRef(
485
503
  (e, t) => {
486
504
  const {
487
505
  __scopeToggleGroup: o,
@@ -491,23 +509,23 @@ var [ze, qe] = te(E), se = v.forwardRef(
491
509
  dir: c,
492
510
  loop: u = !0,
493
511
  ...i
494
- } = e, f = oe(o), g = z(c), p = { role: "group", dir: g, ...i };
495
- return /* @__PURE__ */ l(ze, { scope: o, rovingFocus: n, disabled: r, children: n ? /* @__PURE__ */ l(
512
+ } = e, f = re(o), v = q(c), p = { role: "group", dir: v, ...i };
513
+ return /* @__PURE__ */ a(ze, { scope: o, rovingFocus: n, disabled: r, children: n ? /* @__PURE__ */ a(
496
514
  Be,
497
515
  {
498
516
  asChild: !0,
499
517
  ...f,
500
518
  orientation: s,
501
- dir: g,
519
+ dir: v,
502
520
  loop: u,
503
- children: /* @__PURE__ */ l(w.div, { ...p, ref: t })
521
+ children: /* @__PURE__ */ a(w.div, { ...p, ref: t })
504
522
  }
505
- ) : /* @__PURE__ */ l(w.div, { ...p, ref: t }) });
523
+ ) : /* @__PURE__ */ a(w.div, { ...p, ref: t }) });
506
524
  }
507
- ), F = "ToggleGroupItem", ce = v.forwardRef(
525
+ ), N = "ToggleGroupItem", ue = C.forwardRef(
508
526
  (e, t) => {
509
- const o = ne(F, e.__scopeToggleGroup), r = qe(F, e.__scopeToggleGroup), n = oe(e.__scopeToggleGroup), s = o.value.includes(e.value), c = r.disabled || e.disabled, u = { ...e, pressed: s, disabled: c }, i = v.useRef(null);
510
- return r.rovingFocus ? /* @__PURE__ */ l(
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
+ return r.rovingFocus ? /* @__PURE__ */ a(
511
529
  Ke,
512
530
  {
513
531
  asChild: !0,
@@ -515,17 +533,17 @@ var [ze, qe] = te(E), se = v.forwardRef(
515
533
  focusable: !c,
516
534
  active: s,
517
535
  ref: i,
518
- children: /* @__PURE__ */ l(W, { ...u, ref: t })
536
+ children: /* @__PURE__ */ a(Y, { ...u, ref: t })
519
537
  }
520
- ) : /* @__PURE__ */ l(W, { ...u, ref: t });
538
+ ) : /* @__PURE__ */ a(Y, { ...u, ref: t });
521
539
  }
522
540
  );
523
- ce.displayName = F;
524
- var W = v.forwardRef(
541
+ ue.displayName = N;
542
+ var Y = C.forwardRef(
525
543
  (e, t) => {
526
- const { __scopeToggleGroup: o, value: r, ...n } = e, s = ne(F, o), c = { role: "radio", "aria-checked": e.pressed, "aria-pressed": void 0 }, u = s.type === "single" ? c : void 0;
527
- return /* @__PURE__ */ l(
528
- ee,
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
+ return /* @__PURE__ */ a(
546
+ te,
529
547
  {
530
548
  ...u,
531
549
  ...n,
@@ -536,12 +554,26 @@ var W = v.forwardRef(
536
554
  }
537
555
  );
538
556
  }
539
- ), Ze = B, Je = ce;
540
- const ue = v.createContext({
557
+ ), Ze = B, Je = ue;
558
+ const le = C.createContext({
541
559
  size: "medium",
542
560
  focusMode: "system",
543
561
  mode: "system"
544
- }), Qe = (e) => {
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) => {
545
577
  let t = "";
546
578
  if (typeof e == "number" || typeof e == "string")
547
579
  t = "m-" + e;
@@ -550,22 +582,22 @@ const ue = v.createContext({
550
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(" ");
551
583
  }
552
584
  return t;
553
- }, Xe = ({ focusMode: e }) => P("focus:outline", "focus:outline-2", "focus:outline-offset", {
585
+ }, Xe = ({ focusMode: e }) => G("focus:outline", "focus:outline-2", "focus:outline-offset", {
554
586
  "focus:outline-focus-light": e === "light",
555
587
  "focus:outline-focus-dark": e === "dark",
556
588
  "focus:outline-focus-light dark:focus:outline-focus-dark": e === "alt-system",
557
589
  "focus:outline-focus-dark dark:focus:outline-focus-light": e === "system"
558
- }), He = ({ mode: e }) => P({
590
+ }), He = ({ mode: e }) => G({
559
591
  "data-[state=on]:bg-surface-medium": e === "dark",
560
592
  "data-[state=on]:bg-surface-lightest": e === "light",
561
593
  "data-[state=on]:bg-surface-lightest dark:data-[state=on]:bg-surface-medium": e === "system",
562
594
  "data-[state=on]:bg-surface-medium dark:data-[state=on]:bg-surface-lightest": e === "alt-system"
563
- }), et = ({ size: e }) => P({
595
+ }), et = ({ size: e }) => G({
564
596
  "h-5 px-2": e === "small",
565
597
  "h-6 px-3": e === "medium",
566
598
  "h-7 px-4": e === "large"
567
- }), tt = ({ mode: e }) => P(
568
- ve,
599
+ }), tt = ({ mode: e }) => G(
600
+ Ce,
569
601
  "px-1",
570
602
  "relative",
571
603
  "border-r",
@@ -584,8 +616,8 @@ const ue = v.createContext({
584
616
  size: o
585
617
  }) => ({
586
618
  wrapperClass: tt({ mode: t }),
587
- itemClass: P(
588
- Ce,
619
+ itemClass: G(
620
+ he,
589
621
  "flex items-center justify-center bg-transparent",
590
622
  "rounded-sm",
591
623
  "transition duration-200 ease",
@@ -596,8 +628,8 @@ const ue = v.createContext({
596
628
  }), rt = ({
597
629
  mode: e,
598
630
  spacing: t
599
- }) => P(
600
- me,
631
+ }) => G(
632
+ ve,
601
633
  Qe(t),
602
634
  "inline-flex p-1",
603
635
  "rounded-sm",
@@ -607,7 +639,7 @@ const ue = v.createContext({
607
639
  "bg-surface-light text-copy-dark dark:bg-surface-darker dark:text-copy-lighter": e === "system",
608
640
  "bg-surface-darker text-copy-lighter dark:bg-surface-light dark:text-copy-dark": e === "alt-system"
609
641
  }
610
- ), lt = ({
642
+ ), at = ({
611
643
  children: e,
612
644
  value: t,
613
645
  onValueChange: o,
@@ -619,12 +651,12 @@ const ue = v.createContext({
619
651
  spacing: i,
620
652
  ...f
621
653
  }) => {
622
- const g = rt({ mode: n, spacing: i }), p = { size: c, focusMode: s, mode: n };
623
- return /* @__PURE__ */ l(ue.Provider, { value: p, children: /* @__PURE__ */ l(
654
+ const v = rt({ mode: n, spacing: i }), p = { size: c, focusMode: s, mode: n };
655
+ return /* @__PURE__ */ a(le.Provider, { value: p, children: /* @__PURE__ */ a(
624
656
  Ze,
625
657
  {
626
658
  disabled: r,
627
- className: g,
659
+ className: v,
628
660
  value: t,
629
661
  defaultValue: u,
630
662
  onValueChange: o,
@@ -634,12 +666,12 @@ const ue = v.createContext({
634
666
  }
635
667
  ) });
636
668
  }, it = ({ value: e, disabled: t }) => {
637
- const { size: o, focusMode: r, mode: n } = ge(ue), { itemClass: s, wrapperClass: c } = ot({
669
+ const { size: o, focusMode: r, mode: n } = me(le), { itemClass: s, wrapperClass: c } = ot({
638
670
  focusMode: r,
639
671
  mode: n,
640
672
  size: o
641
673
  });
642
- return /* @__PURE__ */ l("div", { className: c, children: /* @__PURE__ */ l(
674
+ return /* @__PURE__ */ a("div", { className: c, children: /* @__PURE__ */ a(
643
675
  Je,
644
676
  {
645
677
  disabled: t,
@@ -650,9 +682,9 @@ const ue = v.createContext({
650
682
  ) });
651
683
  };
652
684
  export {
653
- me as TOGGLEGROUP_CLASSNAME,
654
- Ce as TOGGLEGROUP_ITEM_CLASSNAME,
655
- ve as TOGGLEGROUP_ITEM_WRAPPER_CLASSNAME,
656
- lt as ToggleGroup,
685
+ ve as TOGGLEGROUP_CLASSNAME,
686
+ he as TOGGLEGROUP_ITEM_CLASSNAME,
687
+ Ce as TOGGLEGROUP_ITEM_WRAPPER_CLASSNAME,
688
+ at as ToggleGroup,
657
689
  it as ToggleGroupItem
658
690
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/ui-togglegroup",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -38,14 +38,16 @@
38
38
  "react-dom": "^18.3.1 || ^19.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@radix-ui/react-toggle-group": "1.1.0",
41
+ "@radix-ui/react-toggle-group": "1.1.1",
42
42
  "@tailwindcss/typography": "0.5.15",
43
- "@versini/ui-private": "1.5.0",
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
- "tailwindcss": "3.4.15"
47
+ "tailwindcss": "3.4.17"
46
48
  },
47
49
  "sideEffects": [
48
50
  "**/*.css"
49
51
  ],
50
- "gitHead": "413e5c7cd8228d2f135f54fa897101401207229b"
52
+ "gitHead": "cb948414a675c01f3328ed6470ccf4b58f73534f"
51
53
  }