@konstructio/ui 0.1.2-alpha.44 → 0.1.2-alpha.47

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 (68) hide show
  1. package/dist/components/AlertDialog/AlertDialog.js +39 -37
  2. package/dist/components/AlertDialog/components/AlertDialogTrigger.js +1 -1
  3. package/dist/components/AlertDialog/components/index.js +1 -1
  4. package/dist/components/Badge/Badge.js +23 -26
  5. package/dist/components/Badge/Badge.variants.js +1 -1
  6. package/dist/components/Button/Button.variants.js +108 -98
  7. package/dist/components/Checkbox/Checkbox.js +104 -100
  8. package/dist/components/Checkbox/Checkbox.variants.js +30 -7
  9. package/dist/components/Counter/Counter.js +210 -0
  10. package/dist/components/Counter/Counter.variants.js +70 -0
  11. package/dist/components/Filter/Filter.js +1 -1
  12. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +9 -10
  13. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.js +76 -43
  14. package/dist/components/Filter/components/ResetButton/ResetButton.js +21 -32
  15. package/dist/components/Filter/events/index.js +3 -3
  16. package/dist/components/ImageUpload/ImageUpload.js +221 -0
  17. package/dist/components/ImageUpload/ImageUpload.variants.js +109 -0
  18. package/dist/components/Input/Input.variants.js +10 -2
  19. package/dist/components/PhoneNumberInput/PhoneNumberInput.variants.js +4 -4
  20. package/dist/components/PhoneNumberInput/components/FlagContent/FlagContent.js +16 -7
  21. package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +92 -74
  22. package/dist/components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js +53 -29
  23. package/dist/components/PhoneNumberInput/components/Wrapper.js +139 -120
  24. package/dist/components/Radio/Radio.js +47 -44
  25. package/dist/components/Radio/Radio.variants.js +12 -8
  26. package/dist/components/Select/Select.js +48 -0
  27. package/dist/components/{Dropdown/Dropdown.variants.js → Select/Select.variants.js} +3 -3
  28. package/dist/components/{Dropdown → Select}/components/List/List.js +48 -43
  29. package/dist/components/{Dropdown → Select}/components/List/List.variants.js +8 -5
  30. package/dist/components/{Dropdown → Select}/components/ListItem/ListItem.js +20 -20
  31. package/dist/components/{Dropdown → Select}/components/ListItem/ListItem.variants.js +3 -2
  32. package/dist/components/{Dropdown → Select}/components/Wrapper.js +70 -70
  33. package/dist/components/Select/contexts/index.js +6 -0
  34. package/dist/components/{Dropdown/contexts/dropdown.context.js → Select/contexts/select.context.js} +2 -2
  35. package/dist/components/Select/contexts/select.hook.js +11 -0
  36. package/dist/components/Select/contexts/select.provider.js +58 -0
  37. package/dist/components/{Dropdown → Select}/hooks/useNavigationList.js +3 -3
  38. package/dist/components/{Dropdown/hooks/useDropdown.js → Select/hooks/useSelect.js} +33 -33
  39. package/dist/components/Switch/Switch.js +153 -125
  40. package/dist/components/Switch/Switch.variants.js +15 -6
  41. package/dist/components/TimePicker/TimePicker.variants.js +11 -6
  42. package/dist/components/TimePicker/components/MeridianList/MeridianList.js +30 -20
  43. package/dist/components/TimePicker/components/Wrapper/Wrapper.js +50 -35
  44. package/dist/components/Typography/Typography.js +24 -28
  45. package/dist/components/Typography/Typography.variants.js +49 -46
  46. package/dist/components/VirtualizedTable/components/Actions/Actions.js +14 -14
  47. package/dist/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.js +10 -10
  48. package/dist/components/VirtualizedTable/components/Skeleton/Skeleton.js +1 -1
  49. package/dist/components/index.js +84 -80
  50. package/dist/{index-CPU02rhe.js → index-D6KzX_ef.js} +13 -12
  51. package/dist/index.d.ts +134 -81
  52. package/dist/index.js +114 -110
  53. package/dist/package.json +4 -4
  54. package/dist/styles.css +1 -1
  55. package/dist/ui/civo-theme.css +6 -5
  56. package/dist/ui/theme.css +27 -0
  57. package/dist/x-BXShoIAM.js +8 -0
  58. package/package.json +4 -4
  59. package/dist/components/Dropdown/Dropdown.js +0 -48
  60. package/dist/components/Dropdown/contexts/dropdown.hook.js +0 -13
  61. package/dist/components/Dropdown/contexts/dropdown.provider.js +0 -58
  62. package/dist/components/Dropdown/contexts/index.js +0 -6
  63. package/dist/components/NumberInput/NumberInput.js +0 -179
  64. package/dist/components/NumberInput/NumberInput.variants.js +0 -50
  65. /package/dist/components/{Dropdown → Select}/components/EmptyList.js +0 -0
  66. /package/dist/components/{Dropdown → Select}/components/index.js +0 -0
  67. /package/dist/components/{Dropdown → Select}/constants/index.js +0 -0
  68. /package/dist/components/{Dropdown → Select}/constants/pagination.js +0 -0
@@ -1,8 +1,8 @@
1
1
  import { jsx as u, jsxs as B, Fragment as U } from "react/jsx-runtime";
2
- import * as h from "react";
2
+ import * as m from "react";
3
3
  import S, { forwardRef as z, useId as V, useCallback as X } from "react";
4
4
  import { u as L } from "../../index-DLcqcWxM.js";
5
- import { c as J, P as w, a as Q, b as j } from "../../index-DKfEnhKr.js";
5
+ import { c as J, P as R, a as Q, b as j } from "../../index-DKfEnhKr.js";
6
6
  import { u as Y } from "../../index-BZPx6jYI.js";
7
7
  import { u as Z } from "../../index-DtEcCIrM.js";
8
8
  import { P as ee } from "../../index-AV6ZtGhy.js";
@@ -10,43 +10,43 @@ import { cn as T } from "../../utils/index.js";
10
10
  import { checkboxVariants as te, labelVariants as re } from "./Checkbox.variants.js";
11
11
  import { useToggle as oe } from "../../hooks/useToggle.js";
12
12
  import { P as y } from "../../index-BOE_3f_Z.js";
13
- function R() {
14
- return R = Object.assign || function(e) {
15
- for (var a = 1; a < arguments.length; a++) {
16
- var o = arguments[a];
17
- for (var n in o)
18
- Object.prototype.hasOwnProperty.call(o, n) && (e[n] = o[n]);
13
+ function E() {
14
+ return E = Object.assign || function(e) {
15
+ for (var c = 1; c < arguments.length; c++) {
16
+ var n = arguments[c];
17
+ for (var r in n)
18
+ Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
19
19
  }
20
20
  return e;
21
- }, R.apply(this, arguments);
21
+ }, E.apply(this, arguments);
22
22
  }
23
- function ne(e, a) {
23
+ function ne(e, c) {
24
24
  if (e == null) return {};
25
- var o = ae(e, a), n, r;
25
+ var n = ce(e, c), r, o;
26
26
  if (Object.getOwnPropertySymbols) {
27
27
  var t = Object.getOwnPropertySymbols(e);
28
- for (r = 0; r < t.length; r++)
29
- n = t[r], !(a.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (o[n] = e[n]);
28
+ for (o = 0; o < t.length; o++)
29
+ r = t[o], !(c.indexOf(r) >= 0) && Object.prototype.propertyIsEnumerable.call(e, r) && (n[r] = e[r]);
30
30
  }
31
- return o;
31
+ return n;
32
32
  }
33
- function ae(e, a) {
33
+ function ce(e, c) {
34
34
  if (e == null) return {};
35
- var o = {}, n = Object.keys(e), r, t;
36
- for (t = 0; t < n.length; t++)
37
- r = n[t], !(a.indexOf(r) >= 0) && (o[r] = e[r]);
38
- return o;
35
+ var n = {}, r = Object.keys(e), o, t;
36
+ for (t = 0; t < r.length; t++)
37
+ o = r[t], !(c.indexOf(o) >= 0) && (n[o] = e[o]);
38
+ return n;
39
39
  }
40
- var I = z(function(e, a) {
41
- var o = e.color, n = o === void 0 ? "currentColor" : o, r = e.size, t = r === void 0 ? 24 : r, l = ne(e, ["color", "size"]);
42
- return /* @__PURE__ */ S.createElement("svg", R({
43
- ref: a,
40
+ var I = z(function(e, c) {
41
+ var n = e.color, r = n === void 0 ? "currentColor" : n, o = e.size, t = o === void 0 ? 24 : o, l = ne(e, ["color", "size"]);
42
+ return /* @__PURE__ */ S.createElement("svg", E({
43
+ ref: c,
44
44
  xmlns: "http://www.w3.org/2000/svg",
45
45
  width: t,
46
46
  height: t,
47
47
  viewBox: "0 0 24 24",
48
48
  fill: "none",
49
- stroke: n,
49
+ stroke: r,
50
50
  strokeWidth: "2",
51
51
  strokeLinecap: "round",
52
52
  strokeLinejoin: "round"
@@ -59,13 +59,13 @@ I.propTypes = {
59
59
  size: y.oneOfType([y.string, y.number])
60
60
  };
61
61
  I.displayName = "Check";
62
- var P = "Checkbox", [ce, ye] = J(P), [se, N] = ce(P);
62
+ var P = "Checkbox", [ae, ye] = J(P), [se, N] = ae(P);
63
63
  function ie(e) {
64
64
  const {
65
- __scopeCheckbox: a,
66
- checked: o,
67
- children: n,
68
- defaultChecked: r,
65
+ __scopeCheckbox: c,
66
+ checked: n,
67
+ children: r,
68
+ defaultChecked: o,
69
69
  disabled: t,
70
70
  form: l,
71
71
  name: f,
@@ -75,40 +75,40 @@ function ie(e) {
75
75
  // @ts-expect-error
76
76
  internal_do_not_use_render: i
77
77
  } = e, [p, x] = Q({
78
- prop: o,
79
- defaultProp: r ?? !1,
78
+ prop: n,
79
+ defaultProp: o ?? !1,
80
80
  onChange: d,
81
81
  caller: P
82
- }), [m, C] = h.useState(null), [g, c] = h.useState(null), s = h.useRef(!1), _ = m ? !!l || !!m.closest("form") : (
82
+ }), [h, C] = m.useState(null), [g, a] = m.useState(null), s = m.useRef(!1), _ = h ? !!l || !!h.closest("form") : (
83
83
  // We set this to true by default so that events bubble to forms without JS (SSR)
84
84
  !0
85
- ), E = {
85
+ ), w = {
86
86
  checked: p,
87
87
  disabled: t,
88
88
  setChecked: x,
89
- control: m,
89
+ control: h,
90
90
  setControl: C,
91
91
  name: f,
92
92
  form: l,
93
93
  value: k,
94
94
  hasConsumerStoppedPropagationRef: s,
95
95
  required: b,
96
- defaultChecked: v(r) ? !1 : r,
96
+ defaultChecked: v(o) ? !1 : o,
97
97
  isFormControl: _,
98
98
  bubbleInput: g,
99
- setBubbleInput: c
99
+ setBubbleInput: a
100
100
  };
101
101
  return /* @__PURE__ */ u(
102
102
  se,
103
103
  {
104
- scope: a,
105
- ...E,
106
- children: le(i) ? i(E) : n
104
+ scope: c,
105
+ ...w,
106
+ children: le(i) ? i(w) : r
107
107
  }
108
108
  );
109
109
  }
110
- var M = "CheckboxTrigger", q = h.forwardRef(
111
- ({ __scopeCheckbox: e, onKeyDown: a, onClick: o, ...n }, r) => {
110
+ var M = "CheckboxTrigger", q = m.forwardRef(
111
+ ({ __scopeCheckbox: e, onKeyDown: c, onClick: n, ...r }, o) => {
112
112
  const {
113
113
  control: t,
114
114
  value: l,
@@ -119,16 +119,16 @@ var M = "CheckboxTrigger", q = h.forwardRef(
119
119
  setChecked: i,
120
120
  hasConsumerStoppedPropagationRef: p,
121
121
  isFormControl: x,
122
- bubbleInput: m
123
- } = N(M, e), C = L(r, k), g = h.useRef(d);
124
- return h.useEffect(() => {
125
- const c = t?.form;
126
- if (c) {
122
+ bubbleInput: h
123
+ } = N(M, e), C = L(o, k), g = m.useRef(d);
124
+ return m.useEffect(() => {
125
+ const a = t?.form;
126
+ if (a) {
127
127
  const s = () => i(g.current);
128
- return c.addEventListener("reset", s), () => c.removeEventListener("reset", s);
128
+ return a.addEventListener("reset", s), () => a.removeEventListener("reset", s);
129
129
  }
130
130
  }, [t, i]), /* @__PURE__ */ u(
131
- w.button,
131
+ R.button,
132
132
  {
133
133
  type: "button",
134
134
  role: "checkbox",
@@ -138,25 +138,25 @@ var M = "CheckboxTrigger", q = h.forwardRef(
138
138
  "data-disabled": f ? "" : void 0,
139
139
  disabled: f,
140
140
  value: l,
141
- ...n,
141
+ ...r,
142
142
  ref: C,
143
- onKeyDown: j(a, (c) => {
144
- c.key === "Enter" && c.preventDefault();
143
+ onKeyDown: j(c, (a) => {
144
+ a.key === "Enter" && a.preventDefault();
145
145
  }),
146
- onClick: j(o, (c) => {
147
- i((s) => v(s) ? !0 : !s), m && x && (p.current = c.isPropagationStopped(), p.current || c.stopPropagation());
146
+ onClick: j(n, (a) => {
147
+ i((s) => v(s) ? !0 : !s), h && x && (p.current = a.isPropagationStopped(), p.current || a.stopPropagation());
148
148
  })
149
149
  }
150
150
  );
151
151
  }
152
152
  );
153
153
  q.displayName = M;
154
- var A = h.forwardRef(
155
- (e, a) => {
154
+ var A = m.forwardRef(
155
+ (e, c) => {
156
156
  const {
157
- __scopeCheckbox: o,
158
- name: n,
159
- checked: r,
157
+ __scopeCheckbox: n,
158
+ name: r,
159
+ checked: o,
160
160
  defaultChecked: t,
161
161
  required: l,
162
162
  disabled: f,
@@ -168,13 +168,13 @@ var A = h.forwardRef(
168
168
  return /* @__PURE__ */ u(
169
169
  ie,
170
170
  {
171
- __scopeCheckbox: o,
172
- checked: r,
171
+ __scopeCheckbox: n,
172
+ checked: o,
173
173
  defaultChecked: t,
174
174
  disabled: f,
175
175
  required: l,
176
176
  onCheckedChange: b,
177
- name: n,
177
+ name: r,
178
178
  form: k,
179
179
  value: d,
180
180
  internal_do_not_use_render: ({ isFormControl: p }) => /* @__PURE__ */ B(U, { children: [
@@ -182,14 +182,14 @@ var A = h.forwardRef(
182
182
  q,
183
183
  {
184
184
  ...i,
185
- ref: a,
186
- __scopeCheckbox: o
185
+ ref: c,
186
+ __scopeCheckbox: n
187
187
  }
188
188
  ),
189
189
  p && /* @__PURE__ */ u(
190
190
  K,
191
191
  {
192
- __scopeCheckbox: o
192
+ __scopeCheckbox: n
193
193
  }
194
194
  )
195
195
  ] })
@@ -198,20 +198,20 @@ var A = h.forwardRef(
198
198
  }
199
199
  );
200
200
  A.displayName = P;
201
- var F = "CheckboxIndicator", D = h.forwardRef(
202
- (e, a) => {
203
- const { __scopeCheckbox: o, forceMount: n, ...r } = e, t = N(F, o);
201
+ var F = "CheckboxIndicator", D = m.forwardRef(
202
+ (e, c) => {
203
+ const { __scopeCheckbox: n, forceMount: r, ...o } = e, t = N(F, n);
204
204
  return /* @__PURE__ */ u(
205
205
  ee,
206
206
  {
207
- present: n || v(t.checked) || t.checked === !0,
207
+ present: r || v(t.checked) || t.checked === !0,
208
208
  children: /* @__PURE__ */ u(
209
- w.span,
209
+ R.span,
210
210
  {
211
211
  "data-state": W(t.checked),
212
212
  "data-disabled": t.disabled ? "" : void 0,
213
- ...r,
214
- ref: a,
213
+ ...o,
214
+ ref: c,
215
215
  style: { pointerEvents: "none", ...e.style }
216
216
  }
217
217
  )
@@ -220,11 +220,11 @@ var F = "CheckboxIndicator", D = h.forwardRef(
220
220
  }
221
221
  );
222
222
  D.displayName = F;
223
- var H = "CheckboxBubbleInput", K = h.forwardRef(
224
- ({ __scopeCheckbox: e, ...a }, o) => {
223
+ var H = "CheckboxBubbleInput", K = m.forwardRef(
224
+ ({ __scopeCheckbox: e, ...c }, n) => {
225
225
  const {
226
- control: n,
227
- hasConsumerStoppedPropagationRef: r,
226
+ control: r,
227
+ hasConsumerStoppedPropagationRef: o,
228
228
  checked: t,
229
229
  defaultChecked: l,
230
230
  required: f,
@@ -234,36 +234,36 @@ var H = "CheckboxBubbleInput", K = h.forwardRef(
234
234
  form: i,
235
235
  bubbleInput: p,
236
236
  setBubbleInput: x
237
- } = N(H, e), m = L(o, x), C = Y(t), g = Z(n);
238
- h.useEffect(() => {
237
+ } = N(H, e), h = L(n, x), C = Y(t), g = Z(r);
238
+ m.useEffect(() => {
239
239
  const s = p;
240
240
  if (!s) return;
241
241
  const _ = window.HTMLInputElement.prototype, O = Object.getOwnPropertyDescriptor(
242
242
  _,
243
243
  "checked"
244
- ).set, $ = !r.current;
244
+ ).set, $ = !o.current;
245
245
  if (C !== t && O) {
246
246
  const G = new Event("click", { bubbles: $ });
247
247
  s.indeterminate = v(t), O.call(s, v(t) ? !1 : t), s.dispatchEvent(G);
248
248
  }
249
- }, [p, C, t, r]);
250
- const c = h.useRef(v(t) ? !1 : t);
249
+ }, [p, C, t, o]);
250
+ const a = m.useRef(v(t) ? !1 : t);
251
251
  return /* @__PURE__ */ u(
252
- w.input,
252
+ R.input,
253
253
  {
254
254
  type: "checkbox",
255
255
  "aria-hidden": !0,
256
- defaultChecked: l ?? c.current,
256
+ defaultChecked: l ?? a.current,
257
257
  required: f,
258
258
  disabled: d,
259
259
  name: b,
260
260
  value: k,
261
261
  form: i,
262
- ...a,
262
+ ...c,
263
263
  tabIndex: -1,
264
- ref: m,
264
+ ref: h,
265
265
  style: {
266
- ...a.style,
266
+ ...c.style,
267
267
  ...g,
268
268
  position: "absolute",
269
269
  pointerEvents: "none",
@@ -291,10 +291,10 @@ function W(e) {
291
291
  const de = z(
292
292
  ({
293
293
  ariaLabelledBy: e,
294
- className: a,
295
- defaultChecked: o,
296
- disabled: n,
297
- id: r,
294
+ className: c,
295
+ defaultChecked: n,
296
+ disabled: r,
297
+ id: o,
298
298
  label: t,
299
299
  labelClassName: l,
300
300
  name: f,
@@ -304,44 +304,48 @@ const de = z(
304
304
  onChange: i,
305
305
  ...p
306
306
  }, x) => {
307
- const [m, C] = oe(o ?? !1), g = V(), c = X(
307
+ const [h, C] = oe(n ?? !1), g = V(), a = X(
308
308
  (s) => {
309
309
  C(s), i?.(s);
310
310
  },
311
311
  [i, C]
312
312
  );
313
- return /* @__PURE__ */ B("div", { className: "flex items-center gap-2", "data-theme": d, children: [
313
+ return /* @__PURE__ */ B("div", { className: "flex items-center gap-4", "data-theme": d, children: [
314
314
  /* @__PURE__ */ u(
315
315
  A,
316
316
  {
317
- id: r ?? g,
318
- checked: m,
317
+ id: o ?? g,
318
+ checked: h,
319
319
  ref: x,
320
320
  name: f,
321
- disabled: n,
321
+ disabled: r,
322
322
  "aria-labelledby": e,
323
323
  title: b,
324
324
  className: T(
325
325
  te({
326
- className: a,
326
+ className: c,
327
327
  variant: k,
328
- checked: m
328
+ checked: h
329
329
  })
330
330
  ),
331
- onCheckedChange: c,
331
+ onCheckedChange: a,
332
332
  ...p,
333
- children: /* @__PURE__ */ u(D, { children: /* @__PURE__ */ u(I, { className: "w-4 h-4 stroke-2 civo:text-slate-700" }) })
333
+ children: /* @__PURE__ */ u(D, { children: /* @__PURE__ */ u(I, { className: "w-4 h-4 stroke-2" }) })
334
334
  }
335
335
  ),
336
336
  t ? /* @__PURE__ */ u(
337
337
  "label",
338
338
  {
339
- htmlFor: f ?? r,
339
+ htmlFor: f ?? o,
340
340
  className: T(
341
341
  re({
342
342
  className: l
343
- })
343
+ }),
344
+ {
345
+ "cursor-not-allowed": r
346
+ }
344
347
  ),
348
+ onClick: () => !r && a(!h),
345
349
  children: t
346
350
  }
347
351
  ) : null
@@ -1,5 +1,5 @@
1
- import { c as r } from "../../index-D29mdTf5.js";
2
- const e = r(
1
+ import { c as e } from "../../index-D29mdTf5.js";
2
+ const t = e(
3
3
  [
4
4
  "cursor-pointer",
5
5
  "border",
@@ -12,8 +12,7 @@ const e = r(
12
12
  "transition-all",
13
13
  "text-slate-800",
14
14
  "border-zinc-400",
15
- "kubefirst:border-kubefirst-primary",
16
- "kubefirst:text-white"
15
+ "disabled:cursor-not-allowed"
17
16
  ],
18
17
  {
19
18
  variants: {
@@ -29,9 +28,31 @@ const e = r(
29
28
  {
30
29
  checked: !0,
31
30
  class: [
31
+ "kubefirst:border-kubefirst-primary",
32
32
  "kubefirst:bg-kubefirst-primary",
33
33
  "bg-aurora-500",
34
- "border-aurora-500"
34
+ "border-aurora-500",
35
+ "disabled:bg-zinc-300",
36
+ "disabled:border-transparent",
37
+ "*:text-metal-900",
38
+ "kubefirst:*:text-white",
39
+ "disabled:*:text-white",
40
+ "dark:disabled:*:text-metal-900",
41
+ "dark:disabled:bg-aurora-500/45"
42
+ ]
43
+ },
44
+ {
45
+ checked: !1,
46
+ class: [
47
+ "kubefirst:border-kubefirst-primary",
48
+ "kubefirst:text-white",
49
+ "border-zinc-400",
50
+ "disabled:bg-zinc-50",
51
+ "disabled:border-zinc-300",
52
+ "dark:disabled:bg-metal-800",
53
+ "dark:disabled:border-metal-600",
54
+ "dark:border-metal-600",
55
+ "dark:bg-metal-800"
35
56
  ]
36
57
  }
37
58
  ],
@@ -39,12 +60,14 @@ const e = r(
39
60
  variant: "default"
40
61
  }
41
62
  }
42
- ), a = r([
63
+ ), a = e([
64
+ "select-none",
43
65
  "cursor-pointer",
66
+ "text-sm",
44
67
  "text-slate-800",
45
68
  "dark:text-slate-50"
46
69
  ]);
47
70
  export {
48
- e as checkboxVariants,
71
+ t as checkboxVariants,
49
72
  a as labelVariants
50
73
  };
@@ -0,0 +1,210 @@
1
+ import { jsxs as f, jsx as u } from "react/jsx-runtime";
2
+ import { R as x } from "../../index-BKjcReYh.js";
3
+ import p, { forwardRef as g, useId as $, useCallback as N } from "react";
4
+ import { cn as y } from "../../utils/index.js";
5
+ import { labelVariants as T, buttonVariants as P, counterVariants as W } from "./Counter.variants.js";
6
+ import { Typography as V } from "../Typography/Typography.js";
7
+ import { P as a } from "../../index-BOE_3f_Z.js";
8
+ function v() {
9
+ return v = Object.assign || function(e) {
10
+ for (var o = 1; o < arguments.length; o++) {
11
+ var r = arguments[o];
12
+ for (var t in r)
13
+ Object.prototype.hasOwnProperty.call(r, t) && (e[t] = r[t]);
14
+ }
15
+ return e;
16
+ }, v.apply(this, arguments);
17
+ }
18
+ function M(e, o) {
19
+ if (e == null) return {};
20
+ var r = R(e, o), t, n;
21
+ if (Object.getOwnPropertySymbols) {
22
+ var i = Object.getOwnPropertySymbols(e);
23
+ for (n = 0; n < i.length; n++)
24
+ t = i[n], !(o.indexOf(t) >= 0) && Object.prototype.propertyIsEnumerable.call(e, t) && (r[t] = e[t]);
25
+ }
26
+ return r;
27
+ }
28
+ function R(e, o) {
29
+ if (e == null) return {};
30
+ var r = {}, t = Object.keys(e), n, i;
31
+ for (i = 0; i < t.length; i++)
32
+ n = t[i], !(o.indexOf(n) >= 0) && (r[n] = e[n]);
33
+ return r;
34
+ }
35
+ var O = g(function(e, o) {
36
+ var r = e.color, t = r === void 0 ? "currentColor" : r, n = e.size, i = n === void 0 ? 24 : n, l = M(e, ["color", "size"]);
37
+ return /* @__PURE__ */ p.createElement("svg", v({
38
+ ref: o,
39
+ xmlns: "http://www.w3.org/2000/svg",
40
+ width: i,
41
+ height: i,
42
+ viewBox: "0 0 24 24",
43
+ fill: "none",
44
+ stroke: t,
45
+ strokeWidth: "2",
46
+ strokeLinecap: "round",
47
+ strokeLinejoin: "round"
48
+ }, l), /* @__PURE__ */ p.createElement("line", {
49
+ x1: "5",
50
+ y1: "12",
51
+ x2: "19",
52
+ y2: "12"
53
+ }));
54
+ });
55
+ O.propTypes = {
56
+ color: a.string,
57
+ size: a.oneOfType([a.string, a.number])
58
+ };
59
+ O.displayName = "Minus";
60
+ function b() {
61
+ return b = Object.assign || function(e) {
62
+ for (var o = 1; o < arguments.length; o++) {
63
+ var r = arguments[o];
64
+ for (var t in r)
65
+ Object.prototype.hasOwnProperty.call(r, t) && (e[t] = r[t]);
66
+ }
67
+ return e;
68
+ }, b.apply(this, arguments);
69
+ }
70
+ function C(e, o) {
71
+ if (e == null) return {};
72
+ var r = B(e, o), t, n;
73
+ if (Object.getOwnPropertySymbols) {
74
+ var i = Object.getOwnPropertySymbols(e);
75
+ for (n = 0; n < i.length; n++)
76
+ t = i[n], !(o.indexOf(t) >= 0) && Object.prototype.propertyIsEnumerable.call(e, t) && (r[t] = e[t]);
77
+ }
78
+ return r;
79
+ }
80
+ function B(e, o) {
81
+ if (e == null) return {};
82
+ var r = {}, t = Object.keys(e), n, i;
83
+ for (i = 0; i < t.length; i++)
84
+ n = t[i], !(o.indexOf(n) >= 0) && (r[n] = e[n]);
85
+ return r;
86
+ }
87
+ var w = g(function(e, o) {
88
+ var r = e.color, t = r === void 0 ? "currentColor" : r, n = e.size, i = n === void 0 ? 24 : n, l = C(e, ["color", "size"]);
89
+ return /* @__PURE__ */ p.createElement("svg", b({
90
+ ref: o,
91
+ xmlns: "http://www.w3.org/2000/svg",
92
+ width: i,
93
+ height: i,
94
+ viewBox: "0 0 24 24",
95
+ fill: "none",
96
+ stroke: t,
97
+ strokeWidth: "2",
98
+ strokeLinecap: "round",
99
+ strokeLinejoin: "round"
100
+ }, l), /* @__PURE__ */ p.createElement("line", {
101
+ x1: "12",
102
+ y1: "5",
103
+ x2: "12",
104
+ y2: "19"
105
+ }), /* @__PURE__ */ p.createElement("line", {
106
+ x1: "5",
107
+ y1: "12",
108
+ x2: "19",
109
+ y2: "12"
110
+ }));
111
+ });
112
+ w.propTypes = {
113
+ color: a.string,
114
+ size: a.oneOfType([a.string, a.number])
115
+ };
116
+ w.displayName = "Plus";
117
+ const J = g(
118
+ ({
119
+ canDecrement: e = !0,
120
+ canIncrement: o = !0,
121
+ className: r,
122
+ decrementButtonClassName: t,
123
+ incrementButtonClassName: n,
124
+ isRequired: i,
125
+ label: l,
126
+ max: d = -1 / 0,
127
+ min: h = 1 / 0,
128
+ name: j,
129
+ theme: k,
130
+ value: z,
131
+ onChange: m
132
+ }, I) => {
133
+ const _ = $(), s = z ?? 0, E = N(() => {
134
+ let c = 0;
135
+ h === 1 / 0 ? c = s - 1 : c = Math.max(h, s - 1), m?.({ target: { value: c } });
136
+ }, [s, h, m]), L = N(() => {
137
+ let c = 0;
138
+ d === -1 / 0 ? c = s + 1 : c = Math.min(d, s + 1), m?.({ target: { value: c } });
139
+ }, [s, d, m]);
140
+ return /* @__PURE__ */ f("div", { className: "flex flex-col gap-1", "data-theme": k, children: [
141
+ l ? /* @__PURE__ */ f(
142
+ V,
143
+ {
144
+ component: "label",
145
+ htmlFor: j ?? _,
146
+ variant: "labelLarge",
147
+ className: y(T()),
148
+ children: [
149
+ "Number of nodes",
150
+ " ",
151
+ i && /* @__PURE__ */ u("span", { className: "text-red-600", children: "*" })
152
+ ]
153
+ }
154
+ ) : null,
155
+ /* @__PURE__ */ f("div", { className: "flex items-center", role: "presentation", children: [
156
+ /* @__PURE__ */ f(
157
+ "button",
158
+ {
159
+ type: "button",
160
+ onClick: E,
161
+ className: y(
162
+ P({
163
+ button: "rigth",
164
+ className: t
165
+ })
166
+ ),
167
+ disabled: !e,
168
+ children: [
169
+ /* @__PURE__ */ u(O, { className: "w-4 h-4" }),
170
+ /* @__PURE__ */ u(x, { children: "Decrement" })
171
+ ]
172
+ }
173
+ ),
174
+ /* @__PURE__ */ u(
175
+ "input",
176
+ {
177
+ ref: I,
178
+ type: "number",
179
+ value: s,
180
+ name: j,
181
+ className: y(W({ className: r })),
182
+ readOnly: !0,
183
+ "aria-label": typeof l == "string" ? l : "number input"
184
+ }
185
+ ),
186
+ /* @__PURE__ */ f(
187
+ "button",
188
+ {
189
+ type: "button",
190
+ onClick: L,
191
+ className: y(
192
+ P({
193
+ button: "left",
194
+ className: n
195
+ })
196
+ ),
197
+ disabled: !o,
198
+ children: [
199
+ /* @__PURE__ */ u(w, { className: "w-4 h-4" }),
200
+ /* @__PURE__ */ u(x, { children: "Increment" })
201
+ ]
202
+ }
203
+ )
204
+ ] })
205
+ ] });
206
+ }
207
+ );
208
+ export {
209
+ J as Counter
210
+ };