@companix/uikit 0.1.42 → 0.1.43

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.
Files changed (83) hide show
  1. package/dist/CounterInput/CounterInput.scss +29 -0
  2. package/dist/CounterInput/index.d.ts +14 -0
  3. package/dist/bundle.es.js +122 -120
  4. package/dist/bundle.es10.js +1 -1
  5. package/dist/bundle.es13.js +4 -4
  6. package/dist/bundle.es14.js +4 -4
  7. package/dist/bundle.es15.js +2 -2
  8. package/dist/bundle.es16.js +1 -1
  9. package/dist/bundle.es17.js +1 -1
  10. package/dist/bundle.es18.js +105 -19
  11. package/dist/bundle.es19.js +21 -34
  12. package/dist/bundle.es20.js +33 -24
  13. package/dist/bundle.es21.js +24 -45
  14. package/dist/bundle.es22.js +46 -26
  15. package/dist/bundle.es23.js +24 -259
  16. package/dist/bundle.es24.js +260 -13
  17. package/dist/bundle.es25.js +14 -21
  18. package/dist/bundle.es26.js +20 -37
  19. package/dist/bundle.es27.js +38 -21
  20. package/dist/bundle.es28.js +20 -18
  21. package/dist/bundle.es29.js +18 -21
  22. package/dist/bundle.es30.js +21 -43
  23. package/dist/bundle.es31.js +37 -114
  24. package/dist/bundle.es32.js +119 -72
  25. package/dist/bundle.es33.js +68 -38
  26. package/dist/bundle.es34.js +42 -10
  27. package/dist/bundle.es35.js +11 -85
  28. package/dist/bundle.es36.js +85 -19
  29. package/dist/bundle.es37.js +20 -7
  30. package/dist/bundle.es38.js +7 -3
  31. package/dist/bundle.es39.js +3 -23
  32. package/dist/bundle.es40.js +16 -45
  33. package/dist/bundle.es41.js +51 -56
  34. package/dist/bundle.es42.js +57 -162
  35. package/dist/bundle.es43.js +160 -79
  36. package/dist/bundle.es44.js +81 -7
  37. package/dist/bundle.es45.js +7 -59
  38. package/dist/bundle.es46.js +58 -33
  39. package/dist/bundle.es47.js +33 -20
  40. package/dist/bundle.es48.js +19 -47
  41. package/dist/bundle.es49.js +49 -11
  42. package/dist/bundle.es50.js +11 -13
  43. package/dist/bundle.es51.js +13 -13
  44. package/dist/bundle.es52.js +13 -30
  45. package/dist/bundle.es53.js +30 -11
  46. package/dist/bundle.es54.js +10 -25
  47. package/dist/bundle.es55.js +17 -29
  48. package/dist/bundle.es56.js +36 -48
  49. package/dist/bundle.es57.js +49 -55
  50. package/dist/bundle.es58.js +56 -8
  51. package/dist/bundle.es59.js +8 -26
  52. package/dist/bundle.es60.js +27 -5
  53. package/dist/bundle.es61.js +5 -66
  54. package/dist/bundle.es62.js +66 -23
  55. package/dist/bundle.es63.js +22 -23
  56. package/dist/bundle.es64.js +24 -90
  57. package/dist/bundle.es65.js +90 -18
  58. package/dist/bundle.es66.js +17 -93
  59. package/dist/bundle.es67.js +93 -73
  60. package/dist/bundle.es68.js +73 -23
  61. package/dist/bundle.es69.js +20 -35
  62. package/dist/bundle.es70.js +39 -24
  63. package/dist/bundle.es71.js +24 -79
  64. package/dist/bundle.es72.js +71 -85
  65. package/dist/bundle.es73.js +93 -10
  66. package/dist/bundle.es74.js +10 -6
  67. package/dist/bundle.es75.js +5 -69
  68. package/dist/bundle.es76.js +68 -10
  69. package/dist/bundle.es77.js +11 -42
  70. package/dist/bundle.es78.js +42 -32
  71. package/dist/bundle.es79.js +31 -64
  72. package/dist/bundle.es80.js +65 -40
  73. package/dist/bundle.es81.js +40 -14
  74. package/dist/bundle.es82.js +15 -32
  75. package/dist/bundle.es83.js +23 -61
  76. package/dist/bundle.es84.js +69 -13
  77. package/dist/bundle.es85.js +13 -74
  78. package/dist/bundle.es86.js +71 -45
  79. package/dist/bundle.es87.js +48 -13
  80. package/dist/bundle.es88.js +16 -0
  81. package/dist/index.d.ts +2 -0
  82. package/dist/index.scss +1 -0
  83. package/package.json +1 -1
@@ -1,48 +1,27 @@
1
- import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
- import h from "classnames";
3
- import { useId as N } from "react";
4
- import * as l from "@radix-ui/react-radio-group";
5
- import { attr as s } from "@companix/utils-browser";
6
- const R = (t) => {
7
- const { options: m, value: a, onChange: r, disabled: i, required: e, size: n, className: c } = t;
8
- return /* @__PURE__ */ o(
9
- l.Root,
10
- {
11
- className: h("radio-group", c),
12
- disabled: i,
13
- "data-required": s(e && !a),
14
- "data-v": a,
15
- value: a,
16
- onValueChange: (d) => r(d),
17
- children: m.map((d, u) => /* @__PURE__ */ o(
18
- f,
19
- {
20
- ...d,
21
- size: n,
22
- disabled: i,
23
- required: e && !a
24
- },
25
- `radio-${d.value}-${u}`
26
- ))
27
- }
28
- );
29
- }, f = ({ value: t, label: m, size: a = "md", disabled: r, required: i }) => {
30
- const e = N();
31
- return /* @__PURE__ */ p(
32
- "span",
33
- {
34
- className: "radio",
35
- "data-disabled": s(r),
36
- "data-size": a,
37
- "data-required": s(i),
38
- children: [
39
- /* @__PURE__ */ o(l.Item, { className: "radio-box", value: t, disabled: r, id: e, children: /* @__PURE__ */ o(l.Indicator, { className: "radio-mark" }) }),
40
- /* @__PURE__ */ o("label", { className: "radio-label", htmlFor: e, "data-disabled": s(r), children: m })
41
- ]
42
- }
43
- );
1
+ import { jsxs as d, jsx as c } from "react/jsx-runtime";
2
+ import * as r from "@radix-ui/react-switch";
3
+ import { attr as a } from "@companix/utils-browser";
4
+ import { useId as n } from "react";
5
+ const u = (m) => {
6
+ const { checked: e, disabled: s, onCheckedChange: o, uncheckedIcon: i, checkedIcon: t, label: h } = m, l = n();
7
+ return /* @__PURE__ */ d("div", { className: "switch", "data-disabled": a(s), children: [
8
+ /* @__PURE__ */ c(
9
+ r.Root,
10
+ {
11
+ className: "switch-track",
12
+ checked: e,
13
+ onCheckedChange: o,
14
+ disabled: s,
15
+ id: l,
16
+ children: /* @__PURE__ */ d(r.Thumb, { className: "switch-thumb", children: [
17
+ i && /* @__PURE__ */ c("span", { className: "switch-thumb-icon", "data-visible": a(!e), children: i }),
18
+ t && /* @__PURE__ */ c("span", { className: "switch-thumb-icon", "data-visible": a(e), children: t })
19
+ ] })
20
+ }
21
+ ),
22
+ h && /* @__PURE__ */ c("label", { className: "switch-label", htmlFor: l, "data-disabled": s, children: h })
23
+ ] });
44
24
  };
45
25
  export {
46
- f as Radio,
47
- R as RadioGroup
26
+ u as Switch
48
27
  };
@@ -1,28 +1,48 @@
1
- import { jsx as c } from "react/jsx-runtime";
2
- import r from "classnames";
3
- import { customCSS as i } from "@companix/utils-browser";
4
- import { PopupLayout as o } from "./bundle.es25.js";
5
- const l = ({
6
- direction: e,
7
- children: t,
8
- size: a,
9
- overlayClassName: m,
10
- className: s,
11
- ...p
12
- }) => /* @__PURE__ */ c(
13
- o,
14
- {
15
- ...p,
16
- overlay: { className: r("drawer-overlay", m) },
17
- content: {
18
- className: r("popup drawer", s),
19
- style: i({ "--drawer-size": a ?? "50%" }),
20
- "data-direction": e
21
- },
22
- children: t
23
- }
24
- );
25
- l.Close = o.Close;
1
+ import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
+ import h from "classnames";
3
+ import { useId as N } from "react";
4
+ import * as l from "@radix-ui/react-radio-group";
5
+ import { attr as s } from "@companix/utils-browser";
6
+ const R = (t) => {
7
+ const { options: m, value: a, onChange: r, disabled: i, required: e, size: n, className: c } = t;
8
+ return /* @__PURE__ */ o(
9
+ l.Root,
10
+ {
11
+ className: h("radio-group", c),
12
+ disabled: i,
13
+ "data-required": s(e && !a),
14
+ "data-v": a,
15
+ value: a,
16
+ onValueChange: (d) => r(d),
17
+ children: m.map((d, u) => /* @__PURE__ */ o(
18
+ f,
19
+ {
20
+ ...d,
21
+ size: n,
22
+ disabled: i,
23
+ required: e && !a
24
+ },
25
+ `radio-${d.value}-${u}`
26
+ ))
27
+ }
28
+ );
29
+ }, f = ({ value: t, label: m, size: a = "md", disabled: r, required: i }) => {
30
+ const e = N();
31
+ return /* @__PURE__ */ p(
32
+ "span",
33
+ {
34
+ className: "radio",
35
+ "data-disabled": s(r),
36
+ "data-size": a,
37
+ "data-required": s(i),
38
+ children: [
39
+ /* @__PURE__ */ o(l.Item, { className: "radio-box", value: t, disabled: r, id: e, children: /* @__PURE__ */ o(l.Indicator, { className: "radio-mark" }) }),
40
+ /* @__PURE__ */ o("label", { className: "radio-label", htmlFor: e, "data-disabled": s(r), children: m })
41
+ ]
42
+ }
43
+ );
44
+ };
26
45
  export {
27
- l as Drawer
46
+ f as Radio,
47
+ R as RadioGroup
28
48
  };
@@ -1,263 +1,28 @@
1
- import { jsx as s, jsxs as q } from "react/jsx-runtime";
2
- import t from "react";
3
- import G from "classnames";
4
- import * as E from "@radix-ui/react-dialog";
5
- import { VisuallyHidden as K } from "@radix-ui/react-visually-hidden";
6
- import { customCSS as oe } from "@companix/utils-browser";
7
- import { RemoveListener as se } from "./bundle.es60.js";
8
- import { DrawerContext as ie, useDrawerContext as J } from "./bundle.es70.js";
9
- import { set as R, reset as ae, composeRefs as Q, isInput as ce, isMobileFirefox as ue, getTranslate as W, isIOS as le, dampenValue as fe } from "./bundle.es71.js";
10
- import { usePreventScroll as de } from "./bundle.es72.js";
11
- import { DRAG_CLASS as j, VELOCITY_THRESHOLD as ge, CLOSE_THRESHOLD as me, SCROLL_LOCK_TIMEOUT as pe, TRANSITIONS as Y, WINDOW_TOP_OFFSET as he } from "./bundle.es73.js";
12
- const we = (m) => {
13
- const { open: p, onOpenChange: l, onClosed: D, children: y, defaultOpen: S = !1, disableEsc: f } = m, [M, P] = t.useState(!1), [T, v] = t.useState(!1), [_, A] = t.useState(!1), x = t.useRef(null), H = t.useRef(null), I = t.useRef(null), L = t.useRef(null), o = t.useRef(null), d = t.useRef(!1), h = t.useRef(0), b = t.useRef(!1), N = t.useRef(!S), e = t.useRef(null), O = t.useRef(e.current?.getBoundingClientRect().height || 0), g = t.useRef(0), C = t.useRef(0), w = p ?? !1, V = t.useCallback(
14
- (r) => {
15
- l(r);
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import r from "classnames";
3
+ import { customCSS as i } from "@companix/utils-browser";
4
+ import { PopupLayout as o } from "./bundle.es26.js";
5
+ const l = ({
6
+ direction: e,
7
+ children: t,
8
+ size: a,
9
+ overlayClassName: m,
10
+ className: s,
11
+ ...p
12
+ }) => /* @__PURE__ */ c(
13
+ o,
14
+ {
15
+ ...p,
16
+ overlay: { className: r("drawer-overlay", m) },
17
+ content: {
18
+ className: r("popup drawer", s),
19
+ style: i({ "--drawer-size": a ?? "50%" }),
20
+ "data-direction": e
16
21
  },
17
- [l]
18
- );
19
- de({
20
- isDisabled: !w || T || _ || !M
21
- });
22
- const ee = (r) => {
23
- e.current && !e.current.contains(r.target) || (O.current = e.current?.getBoundingClientRect().height || 0, v(!0), I.current = /* @__PURE__ */ new Date(), le() && window.addEventListener("touchend", () => d.current = !1, { once: !0 }), r.target.setPointerCapture(r.pointerId), h.current = r.pageY);
24
- }, z = (r, c) => {
25
- let n = r;
26
- const u = window.getSelection()?.toString(), i = e.current ? W(e.current) : null, a = /* @__PURE__ */ new Date();
27
- if (n.tagName === "SELECT" || n.hasAttribute("data-no-drag") || n.closest("[data-no-drag]") || H.current && a.getTime() - H.current.getTime() < 500)
28
- return !1;
29
- if (i !== null && i > 0)
30
- return !0;
31
- if (u && u.length > 0)
32
- return !1;
33
- if (o.current && a.getTime() - o.current.getTime() < pe && i === 0 || c)
34
- return o.current = a, !1;
35
- for (; n; ) {
36
- if (n.scrollHeight > n.clientHeight) {
37
- if (n.scrollTop !== 0)
38
- return o.current = /* @__PURE__ */ new Date(), !1;
39
- if (n.getAttribute("role") === "dialog")
40
- return !0;
41
- }
42
- n = n.parentNode;
43
- }
44
- return !0;
45
- }, te = (r) => {
46
- if (e.current && T) {
47
- const c = h.current - r.pageY, n = c > 0, u = Math.abs(c), i = O.current, a = u / i;
48
- if (!d.current && !z(r.target, n)) return;
49
- if (e.current.classList.add(j), d.current = !0, R(e.current, {
50
- transition: "none"
51
- }), R(x.current, {
52
- transition: "none"
53
- }), n) {
54
- const F = fe(c), U = Math.min(F * -1, 0) * 1;
55
- R(e.current, {
56
- transform: `translate3d(0, ${U}px, 0)`
57
- });
58
- return;
59
- }
60
- const k = 1 - a;
61
- R(
62
- x.current,
63
- {
64
- opacity: `${k}`,
65
- transition: "none"
66
- },
67
- !0
68
- );
69
- const $ = u;
70
- R(e.current, {
71
- transform: `translate3d(0, ${$}px, 0)`
72
- });
73
- }
74
- };
75
- t.useEffect(() => {
76
- window.requestAnimationFrame(() => {
77
- N.current = !0;
78
- });
79
- }, []), t.useEffect(() => {
80
- const r = () => {
81
- if (!e.current) return;
82
- const c = document.activeElement;
83
- if (ce(c) || b.current) {
84
- const n = window.visualViewport?.height || 0, u = window.innerHeight, i = u - n, a = e.current.getBoundingClientRect().height || 0, k = a > u * 0.8;
85
- g.current || (g.current = a);
86
- const $ = e.current.getBoundingClientRect().top;
87
- if (Math.abs(C.current - i) > 60 && (b.current = !b.current), C.current = i, a > n || b.current) {
88
- const F = e.current.getBoundingClientRect().height;
89
- let U = F;
90
- F > n && (U = n - (k ? $ : he)), e.current.style.height = `${Math.max(
91
- U,
92
- n - $
93
- )}px`;
94
- } else ue() || (e.current.style.height = `${g.current}px`);
95
- e.current.style.bottom = `${Math.max(i, 0)}px`;
96
- }
97
- };
98
- return window.visualViewport?.addEventListener("resize", r), () => window.visualViewport?.removeEventListener("resize", r);
99
- }, []);
100
- const B = (r) => {
101
- re(), r || V(!1);
102
- }, X = () => {
103
- e.current && (R(e.current, {
104
- transform: "translate3d(0, 0, 0)",
105
- transition: `transform ${Y.DURATION}s cubic-bezier(${Y.EASE.join(",")})`
106
- }), R(x.current, {
107
- transition: `opacity ${Y.DURATION}s cubic-bezier(${Y.EASE.join(",")})`,
108
- opacity: "1"
109
- }));
110
- }, re = () => {
111
- !T || !e.current || (e.current.classList.remove(j), d.current = !1, v(!1), L.current = /* @__PURE__ */ new Date());
112
- }, ne = (r) => {
113
- if (!T || !e.current) return;
114
- e.current.classList.remove(j), d.current = !1, v(!1), L.current = /* @__PURE__ */ new Date();
115
- const c = W(e.current);
116
- if (!r || !z(r.target, !1) || !c || Number.isNaN(c) || I.current === null) return;
117
- const n = L.current.getTime() - I.current.getTime(), u = h.current - r.pageY, i = Math.abs(u) / n;
118
- if (i > 0.05 && (A(!0), setTimeout(() => {
119
- A(!1);
120
- }, 200)), u > 0) {
121
- X();
122
- return;
123
- }
124
- if (i > ge) {
125
- B();
126
- return;
127
- }
128
- const a = Math.min(
129
- e.current.getBoundingClientRect().height ?? 0,
130
- window.innerHeight
131
- );
132
- if (Math.abs(c) >= a * me) {
133
- B();
134
- return;
135
- }
136
- X();
137
- };
138
- return t.useEffect(() => (w && (P(!0), R(document.documentElement, {
139
- scrollBehavior: "auto"
140
- }), H.current = /* @__PURE__ */ new Date()), () => {
141
- ae(document.documentElement, "scrollBehavior");
142
- }), [w]), /* @__PURE__ */ s(
143
- E.Root,
144
- {
145
- defaultOpen: S,
146
- onOpenChange: (r) => {
147
- r ? P(!0) : B(!0), V(r);
148
- },
149
- open: w,
150
- modal: !0,
151
- children: /* @__PURE__ */ s(
152
- ie.Provider,
153
- {
154
- value: {
155
- drawerRef: e,
156
- overlayRef: x,
157
- onPress: ee,
158
- onRelease: ne,
159
- onDrag: te,
160
- isOpen: w,
161
- isDragging: T,
162
- keyboardIsOpen: b,
163
- closeDrawer: () => B(),
164
- shouldAnimate: N,
165
- onClosed: D,
166
- disableEsc: f
167
- },
168
- children: y
169
- }
170
- )
171
- }
172
- );
173
- }, Re = t.forwardRef(
174
- ({ className: m, ...p }, l) => {
175
- const { overlayRef: D, onRelease: y, shouldAnimate: S } = J(), f = Q(l, D), M = t.useCallback(
176
- (P) => y(P),
177
- [y]
178
- );
179
- return /* @__PURE__ */ s(
180
- E.Overlay,
181
- {
182
- onMouseUp: M,
183
- ref: f,
184
- "data-animate": S?.current ? "true" : "false",
185
- className: G("popup-overlay drawer-overlay", m),
186
- ...p
187
- }
188
- );
22
+ children: t
189
23
  }
190
- ), De = t.forwardRef(
191
- ({ onPointerDownOutside: m, style: p, onOpenAutoFocus: l, className: D, size: y, children: S, ...f }, M) => {
192
- const {
193
- drawerRef: P,
194
- onPress: T,
195
- onRelease: v,
196
- onDrag: _,
197
- keyboardIsOpen: A,
198
- shouldAnimate: x,
199
- onClosed: H,
200
- disableEsc: I
201
- } = J(), L = Q(M, P), o = t.useRef(null), d = t.useRef(null), h = t.useRef(!1), b = (e, O = 0) => {
202
- if (h.current) return !0;
203
- const g = Math.abs(e.y), w = Math.abs(e.x) > g;
204
- return !(e.y * 1 < 0) && g >= 0 && g <= O ? !w : (h.current = !0, !0);
205
- }, N = (e) => {
206
- o.current = null, h.current = !1, v(e);
207
- };
208
- return /* @__PURE__ */ q(
209
- E.Content,
210
- {
211
- "data-direction": "bottom",
212
- "data-animate": x?.current ? "true" : "false",
213
- className: G("popup drawer drawer-mobile", D),
214
- style: { ...oe({ "--drawer-size": y ?? "50%" }), ...p },
215
- ...f,
216
- ref: L,
217
- onPointerDown: (e) => {
218
- f.onPointerDown?.(e), o.current = { x: e.pageX, y: e.pageY }, T(e);
219
- },
220
- onOpenAutoFocus: (e) => {
221
- l?.(e), e.preventDefault();
222
- },
223
- onEscapeKeyDown: (e) => {
224
- I && e.preventDefault();
225
- },
226
- onPointerDownOutside: (e) => {
227
- m?.(e), !e.defaultPrevented && A.current && (A.current = !1);
228
- },
229
- onPointerMove: (e) => {
230
- if (d.current = e, f.onPointerMove?.(e), !o.current) return;
231
- const O = e.pageY - o.current.y, g = e.pageX - o.current.x, C = e.pointerType === "touch" ? 10 : 2;
232
- b({ x: g, y: O }, C) ? _(e) : (Math.abs(g) > C || Math.abs(O) > C) && (o.current = null);
233
- },
234
- onPointerUp: (e) => {
235
- f.onPointerUp?.(e), o.current = null, h.current = !1, v(e);
236
- },
237
- onPointerOut: (e) => {
238
- f.onPointerOut?.(e), N(d.current);
239
- },
240
- onContextMenu: (e) => {
241
- f.onContextMenu?.(e), d.current && N(d.current);
242
- },
243
- children: [
244
- /* @__PURE__ */ s(se, { callback: H }),
245
- /* @__PURE__ */ s(K, { children: /* @__PURE__ */ s(E.Title, {}) }),
246
- /* @__PURE__ */ s(K, { children: /* @__PURE__ */ s(E.Description, {}) }),
247
- S
248
- ]
249
- }
250
- );
251
- }
252
- ), Te = t.forwardRef(
253
- ({ children: m, ...p }, l) => /* @__PURE__ */ s("div", { className: "drawer-handle", "aria-hidden": "true", ref: l, ...p, children: /* @__PURE__ */ s("span", { className: "drawer-handle-hitarea", "aria-hidden": "true", children: m }) })
254
- ), Z = ({ children: m, className: p, size: l, ...D }) => /* @__PURE__ */ s(we, { ...D, children: /* @__PURE__ */ q(E.Portal, { children: [
255
- /* @__PURE__ */ s(Re, {}),
256
- /* @__PURE__ */ s(De, { className: p, size: l, children: m })
257
- ] }) });
258
- Z.Close = E.Close;
259
- Z.Handle = Te;
24
+ );
25
+ l.Close = o.Close;
260
26
  export {
261
- Te as Handle,
262
- Z as MobileDrawer
27
+ l as Drawer
263
28
  };