haze-ui 1.12.1 → 1.13.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.
Files changed (137) hide show
  1. package/README.md +99 -31
  2. package/dist/components/Checkbox/Checkbox.js +13 -20
  3. package/dist/components/Checkbox/CheckboxCore.js +23 -0
  4. package/dist/components/ColorPicker/ColorPicker.js +13 -42
  5. package/dist/components/ColorPicker/ColorPickerCore.js +38 -0
  6. package/dist/components/Combobox/Combobox.js +45 -34
  7. package/dist/components/Command/Command.js +72 -37
  8. package/dist/components/ContextMenu/ContextMenu.js +19 -17
  9. package/dist/components/ContextMenu/ContextMenuContent.js +24 -12
  10. package/dist/components/ContextMenu/ContextMenuItem.js +2 -0
  11. package/dist/components/DateRangePicker/DateRangePicker.js +17 -35
  12. package/dist/components/DateRangePicker/DateRangePickerCore.js +33 -0
  13. package/dist/components/Datepicker/Calendar.js +58 -44
  14. package/dist/components/Datepicker/Datepicker.js +15 -39
  15. package/dist/components/Datepicker/DatepickerCore.js +50 -0
  16. package/dist/components/DropdownMenu/DropdownMenu.js +20 -20
  17. package/dist/components/DropdownMenu/DropdownMenuContent.js +38 -45
  18. package/dist/components/DropdownMenu/DropdownMenuTrigger.js +9 -7
  19. package/dist/components/InlineEdit/InlineEdit.js +1 -0
  20. package/dist/components/Input/Input.js +11 -22
  21. package/dist/components/Input/InputCore.js +26 -0
  22. package/dist/components/Menu/Menu.js +38 -26
  23. package/dist/components/Menu/MenuItem.js +1 -0
  24. package/dist/components/ModelPicker/ModelPicker.js +1 -0
  25. package/dist/components/NumberInput/NumberInput.js +16 -53
  26. package/dist/components/NumberInput/NumberInputCore.js +56 -0
  27. package/dist/components/OTPInput/OTPInput.js +11 -45
  28. package/dist/components/OTPInput/OTPInputCore.js +44 -0
  29. package/dist/components/PasswordInput/PasswordInput.js +14 -29
  30. package/dist/components/PasswordInput/PasswordInputCore.js +31 -0
  31. package/dist/components/Popover/Popover.js +32 -75
  32. package/dist/components/Progress/Progress.js +2 -0
  33. package/dist/components/Radio/RadioGroup.js +12 -21
  34. package/dist/components/Radio/RadioGroupCore.js +24 -0
  35. package/dist/components/Rating/Rating.js +14 -46
  36. package/dist/components/Rating/RatingCore.js +48 -0
  37. package/dist/components/Segmented/Segmented.js +12 -37
  38. package/dist/components/Segmented/SegmentedCore.js +39 -0
  39. package/dist/components/Select/Select.js +12 -23
  40. package/dist/components/Select/SelectCore.js +27 -0
  41. package/dist/components/Slider/Slider.js +10 -15
  42. package/dist/components/Slider/SliderCore.js +19 -0
  43. package/dist/components/Switch/Switch.js +11 -38
  44. package/dist/components/Switch/SwitchCore.js +42 -0
  45. package/dist/components/TagInput/TagInput.js +18 -72
  46. package/dist/components/TagInput/TagInputCore.js +68 -0
  47. package/dist/components/Textarea/Textarea.js +11 -22
  48. package/dist/components/Textarea/TextareaCore.js +26 -0
  49. package/dist/components/TimePicker/TimePicker.js +10 -15
  50. package/dist/components/TimePicker/TimePickerCore.js +18 -0
  51. package/dist/components/Tooltip/Tooltip.js +50 -24
  52. package/dist/components/Tree/TreeItem.js +44 -41
  53. package/dist/components/Upload/Upload.js +1 -0
  54. package/dist/css/checkbox.css +1 -1
  55. package/dist/css/color-picker.css +1 -1
  56. package/dist/css/combobox.css +2 -1
  57. package/dist/css/command.css +1 -1
  58. package/dist/css/context-menu.css +1 -0
  59. package/dist/css/date-range-picker.css +1 -1
  60. package/dist/css/datepicker.css +3 -2
  61. package/dist/css/dropdown-menu.css +2 -1
  62. package/dist/css/input.css +1 -1
  63. package/dist/css/menu.css +2 -1
  64. package/dist/css/number-input.css +1 -1
  65. package/dist/css/otp-input.css +1 -1
  66. package/dist/css/password-input.css +1 -1
  67. package/dist/css/popover.css +2 -1
  68. package/dist/css/radio.css +1 -1
  69. package/dist/css/rating.css +1 -1
  70. package/dist/css/segmented.css +1 -1
  71. package/dist/css/select.css +1 -1
  72. package/dist/css/slider.css +1 -1
  73. package/dist/css/switch.css +1 -1
  74. package/dist/css/tag-input.css +1 -1
  75. package/dist/css/textarea.css +1 -1
  76. package/dist/css/time-picker.css +1 -1
  77. package/dist/css/tooltip.css +2 -1
  78. package/dist/form/FormItem.js +41 -33
  79. package/dist/haze-ui.css +31 -24
  80. package/dist/index.js +138 -122
  81. package/dist/types/components/Checkbox/CheckboxCore.d.ts +12 -0
  82. package/dist/types/components/Checkbox/index.d.ts +2 -0
  83. package/dist/types/components/ColorPicker/ColorPickerCore.d.ts +8 -0
  84. package/dist/types/components/ColorPicker/index.d.ts +2 -0
  85. package/dist/types/components/ContextMenu/ContextMenuContent.d.ts +1 -1
  86. package/dist/types/components/ContextMenu/ContextMenuContext.d.ts +5 -1
  87. package/dist/types/components/DateRangePicker/DateRangePickerCore.d.ts +11 -0
  88. package/dist/types/components/DateRangePicker/index.d.ts +2 -0
  89. package/dist/types/components/Datepicker/DatepickerCore.d.ts +12 -0
  90. package/dist/types/components/Datepicker/index.d.ts +2 -0
  91. package/dist/types/components/DropdownMenu/DropdownMenuContent.d.ts +1 -1
  92. package/dist/types/components/DropdownMenu/DropdownMenuContext.d.ts +3 -0
  93. package/dist/types/components/DropdownMenu/DropdownMenuTrigger.d.ts +1 -1
  94. package/dist/types/components/Input/InputCore.d.ts +13 -0
  95. package/dist/types/components/Input/index.d.ts +2 -0
  96. package/dist/types/components/NumberInput/NumberInputCore.d.ts +15 -0
  97. package/dist/types/components/NumberInput/index.d.ts +2 -0
  98. package/dist/types/components/OTPInput/OTPInputCore.d.ts +8 -0
  99. package/dist/types/components/OTPInput/index.d.ts +2 -0
  100. package/dist/types/components/PasswordInput/PasswordInputCore.d.ts +9 -0
  101. package/dist/types/components/PasswordInput/index.d.ts +2 -0
  102. package/dist/types/components/Radio/RadioContext.d.ts +1 -2
  103. package/dist/types/components/Radio/RadioGroupCore.d.ts +10 -0
  104. package/dist/types/components/Radio/index.d.ts +2 -0
  105. package/dist/types/components/Rating/RatingCore.d.ts +9 -0
  106. package/dist/types/components/Rating/index.d.ts +2 -0
  107. package/dist/types/components/Segmented/Segmented.d.ts +1 -6
  108. package/dist/types/components/Segmented/SegmentedCore.d.ts +15 -0
  109. package/dist/types/components/Segmented/index.d.ts +2 -0
  110. package/dist/types/components/Select/SelectCore.d.ts +13 -0
  111. package/dist/types/components/Select/index.d.ts +2 -0
  112. package/dist/types/components/Slider/SliderCore.d.ts +11 -0
  113. package/dist/types/components/Slider/index.d.ts +2 -0
  114. package/dist/types/components/Switch/Switch.d.ts +1 -1
  115. package/dist/types/components/Switch/SwitchCore.d.ts +12 -0
  116. package/dist/types/components/Switch/index.d.ts +2 -0
  117. package/dist/types/components/TagInput/TagInputCore.d.ts +20 -0
  118. package/dist/types/components/TagInput/index.d.ts +2 -0
  119. package/dist/types/components/Textarea/TextareaCore.d.ts +12 -0
  120. package/dist/types/components/Textarea/index.d.ts +2 -0
  121. package/dist/types/components/TimePicker/TimePickerCore.d.ts +9 -0
  122. package/dist/types/components/TimePicker/index.d.ts +2 -0
  123. package/dist/types/components/Tooltip/Tooltip.d.ts +5 -1
  124. package/dist/types/form/FormItem.d.ts +86 -19
  125. package/dist/types/form/index.d.ts +2 -3
  126. package/dist/types/index.d.ts +36 -36
  127. package/dist/types/utils/floating.d.ts +99 -0
  128. package/dist/types/utils/menuKeyboard.d.ts +43 -0
  129. package/dist/utils/floating.js +181 -0
  130. package/dist/utils/menuKeyboard.js +88 -0
  131. package/package.json +45 -19
  132. package/dist/components/DropdownMenu/useMenuKeyboard.js +0 -52
  133. package/dist/form/useFormControl.js +0 -54
  134. package/dist/types/components/DropdownMenu/useMenuKeyboard.d.ts +0 -19
  135. package/dist/types/form/useFormControl.d.ts +0 -35
  136. package/dist/types/hooks/index.d.ts +0 -1
  137. package/dist/types/utils/index.d.ts +0 -1
@@ -0,0 +1,24 @@
1
+
2
+ import { classnames as e } from "../../utils/classnames.js";
3
+ import { RadioProvider as t } from "./RadioContext.js";
4
+ /* empty css */
5
+ import { jsx as n } from "react/jsx-runtime";
6
+ import { useId as r } from "react";
7
+ //#region src/lib/components/Radio/RadioGroupCore.tsx
8
+ var i = "haze-RadioGroupCore__base";
9
+ function a({ value: a, onChange: o, name: s, className: c, children: l }) {
10
+ let u = r();
11
+ return /* @__PURE__ */ n("fieldset", {
12
+ className: e([i, c]),
13
+ children: n(t, {
14
+ value: {
15
+ name: s ?? u,
16
+ value: a,
17
+ setValue: o
18
+ },
19
+ children: l
20
+ })
21
+ });
22
+ }
23
+ //#endregion
24
+ export { a as default };
@@ -1,50 +1,18 @@
1
-
2
- import { classnames as e } from "../../utils/classnames.js";
3
- /* empty css */
4
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
5
- import { useControl as r } from "react-use-control";
6
- import { useState as i } from "react";
1
+ import e from "./RatingCore.js";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { useControl as n } from "react-use-control";
7
4
  //#region src/lib/components/Rating/Rating.tsx
8
- var a = "haze-Rating__container", o = "haze-Rating__star", s = "haze-Rating__starActive";
9
- function c({ value: c, count: l = 5, allowHalf: u = !1, onChange: d, className: f }) {
10
- let [p, m] = r(c, 0), [h, g] = i(null), _ = (e) => {
11
- let t = e + 1;
12
- m(t), d?.(t);
13
- }, v = h ?? p;
14
- return /* @__PURE__ */ t("div", {
15
- role: "radiogroup",
16
- className: e([a, f]),
17
- children: Array.from({ length: l }, (r, i) => {
18
- let a = v >= i + 1, c = u && v >= i + .5 && v < i + 1;
19
- return /* @__PURE__ */ t("span", {
20
- role: "radio",
21
- "aria-checked": p >= i + 1 ? "true" : "false",
22
- "aria-label": `${i + 1} star${i > 0 ? "s" : ""}`,
23
- onClick: () => _(i),
24
- onMouseEnter: () => g(i + 1),
25
- onMouseLeave: () => g(null),
26
- className: e([o, (a || c) && s]),
27
- children: /* @__PURE__ */ n("svg", {
28
- width: "18",
29
- height: "18",
30
- viewBox: "0 0 24 24",
31
- fill: a ? "currentColor" : c ? "url(#half)" : "none",
32
- stroke: "currentColor",
33
- strokeWidth: "2",
34
- children: [c && /* @__PURE__ */ t("defs", { children: /* @__PURE__ */ n("linearGradient", {
35
- id: "half",
36
- children: [/* @__PURE__ */ t("stop", {
37
- offset: "50%",
38
- stopColor: "currentColor"
39
- }), /* @__PURE__ */ t("stop", {
40
- offset: "50%",
41
- stopColor: "transparent"
42
- })]
43
- }) }), /* @__PURE__ */ t("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" })]
44
- })
45
- }, i);
46
- })
5
+ function r({ value: r, count: i, allowHalf: a, onChange: o, className: s }) {
6
+ let [c, l] = n(r, 0);
7
+ return /* @__PURE__ */ t(e, {
8
+ value: c,
9
+ onChange: (e) => {
10
+ l(e), o?.(e);
11
+ },
12
+ count: i,
13
+ allowHalf: a,
14
+ className: s
47
15
  });
48
16
  }
49
17
  //#endregion
50
- export { c as default };
18
+ export { r as default };
@@ -0,0 +1,48 @@
1
+
2
+ import { classnames as e } from "../../utils/classnames.js";
3
+ /* empty css */
4
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
5
+ import { useState as r } from "react";
6
+ //#region src/lib/components/Rating/RatingCore.tsx
7
+ var i = "haze-RatingCore__container", a = "haze-RatingCore__star", o = "haze-RatingCore__starActive";
8
+ function s({ value: s, onChange: c, count: l = 5, allowHalf: u = !1, className: d }) {
9
+ let [f, p] = r(null), m = (e) => {
10
+ c(e + 1);
11
+ }, h = f ?? s;
12
+ return /* @__PURE__ */ t("div", {
13
+ role: "radiogroup",
14
+ className: e([i, d]),
15
+ children: Array.from({ length: l }, (r, i) => {
16
+ let c = h >= i + 1, l = u && h >= i + .5 && h < i + 1;
17
+ return /* @__PURE__ */ t("span", {
18
+ role: "radio",
19
+ "aria-checked": s >= i + 1 ? "true" : "false",
20
+ "aria-label": `${i + 1} star${i > 0 ? "s" : ""}`,
21
+ onClick: () => m(i),
22
+ onMouseEnter: () => p(i + 1),
23
+ onMouseLeave: () => p(null),
24
+ className: e([a, (c || l) && o]),
25
+ children: /* @__PURE__ */ n("svg", {
26
+ width: "18",
27
+ height: "18",
28
+ viewBox: "0 0 24 24",
29
+ fill: c ? "currentColor" : l ? "url(#half)" : "none",
30
+ stroke: "currentColor",
31
+ strokeWidth: "2",
32
+ children: [l && /* @__PURE__ */ t("defs", { children: /* @__PURE__ */ n("linearGradient", {
33
+ id: "half",
34
+ children: [/* @__PURE__ */ t("stop", {
35
+ offset: "50%",
36
+ stopColor: "currentColor"
37
+ }), /* @__PURE__ */ t("stop", {
38
+ offset: "50%",
39
+ stopColor: "transparent"
40
+ })]
41
+ }) }), /* @__PURE__ */ t("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" })]
42
+ })
43
+ }, i);
44
+ })
45
+ });
46
+ }
47
+ //#endregion
48
+ export { s as default };
@@ -1,43 +1,18 @@
1
-
2
- import { classnames as e } from "../../utils/classnames.js";
3
- /* empty css */
1
+ import e from "./SegmentedCore.js";
4
2
  import { jsx as t } from "react/jsx-runtime";
5
3
  import { useControl as n } from "react-use-control";
6
4
  //#region src/lib/components/Segmented/Segmented.tsx
7
- var r = "haze-Segmented__container", i = {
8
- sm: "haze-Segmented__sm",
9
- md: "haze-Segmented__md",
10
- lg: "haze-Segmented__lg"
11
- }, a = "haze-Segmented__btn", o = "haze-Segmented__activeBtn";
12
- function s(e) {
13
- return typeof e == "string" ? {
14
- value: e,
15
- label: e,
16
- disabled: !1
17
- } : e;
18
- }
19
- function c({ options: c, value: l, onChange: u, size: d = "md", className: f }) {
20
- let [p, m] = n(l, ""), h = (e) => {
21
- m(e), u?.(e);
22
- };
23
- return /* @__PURE__ */ t("div", {
24
- role: "group",
25
- className: e([
26
- r,
27
- i[d],
28
- f
29
- ]),
30
- children: c.map((n) => {
31
- let { value: r, label: i, disabled: c } = s(n);
32
- return /* @__PURE__ */ t("button", {
33
- type: "button",
34
- disabled: c,
35
- onClick: () => h(r),
36
- className: e([a, p === r && o]),
37
- children: i
38
- }, r);
39
- })
5
+ function r({ options: r, value: i, onChange: a, size: o, className: s }) {
6
+ let [c, l] = n(i, "");
7
+ return /* @__PURE__ */ t(e, {
8
+ options: r,
9
+ value: c,
10
+ onChange: (e) => {
11
+ l(e), a?.(e);
12
+ },
13
+ size: o,
14
+ className: s
40
15
  });
41
16
  }
42
17
  //#endregion
43
- export { c as default };
18
+ export { r as default };
@@ -0,0 +1,39 @@
1
+
2
+ import { classnames as e } from "../../utils/classnames.js";
3
+ /* empty css */
4
+ import { jsx as t } from "react/jsx-runtime";
5
+ //#region src/lib/components/Segmented/SegmentedCore.tsx
6
+ var n = "haze-SegmentedCore__container", r = {
7
+ sm: "haze-SegmentedCore__sm",
8
+ md: "haze-SegmentedCore__md",
9
+ lg: "haze-SegmentedCore__lg"
10
+ }, i = "haze-SegmentedCore__btn", a = "haze-SegmentedCore__activeBtn";
11
+ function o(e) {
12
+ return typeof e == "string" ? {
13
+ value: e,
14
+ label: e,
15
+ disabled: !1
16
+ } : e;
17
+ }
18
+ function s({ options: s, value: c, onChange: l, size: u = "md", className: d }) {
19
+ return /* @__PURE__ */ t("div", {
20
+ role: "group",
21
+ className: e([
22
+ n,
23
+ r[u],
24
+ d
25
+ ]),
26
+ children: s.map((n) => {
27
+ let { value: r, label: s, disabled: u } = o(n);
28
+ return /* @__PURE__ */ t("button", {
29
+ type: "button",
30
+ disabled: u,
31
+ onClick: () => l(r),
32
+ className: e([i, c === r && a]),
33
+ children: s
34
+ }, r);
35
+ })
36
+ });
37
+ }
38
+ //#endregion
39
+ export { s as default };
@@ -1,29 +1,18 @@
1
-
2
- import { classnames as e } from "../../utils/classnames.js";
3
- /* empty css */
1
+ import e from "./SelectCore.js";
4
2
  import { jsx as t } from "react/jsx-runtime";
5
3
  import { useControl as n } from "react-use-control";
6
4
  //#region src/lib/components/Select/Select.tsx
7
- var r = "haze-Select__base", i = {
8
- sm: "haze-Select__sm",
9
- md: "haze-Select__md",
10
- lg: "haze-Select__lg"
11
- };
12
- function a({ value: a, size: o = "md", className: s, children: c, onChange: l, ...u }) {
13
- let [d, f] = n(a, "");
14
- return /* @__PURE__ */ t("select", {
15
- value: d,
16
- onChange: (e) => {
17
- f(e.target.value), l?.(e);
18
- },
19
- ...u,
20
- className: e([
21
- r,
22
- i[o],
23
- s
24
- ]),
25
- children: c
5
+ function r({ value: r, size: i, className: a, children: o, onChange: s, ...c }) {
6
+ let [l, u] = n(r, "");
7
+ return /* @__PURE__ */ t(e, {
8
+ value: l,
9
+ onChange: u,
10
+ onNativeChange: s,
11
+ size: i,
12
+ className: a,
13
+ ...c,
14
+ children: o
26
15
  });
27
16
  }
28
17
  //#endregion
29
- export { a as default };
18
+ export { r as default };
@@ -0,0 +1,27 @@
1
+
2
+ import { classnames as e } from "../../utils/classnames.js";
3
+ /* empty css */
4
+ import { jsx as t } from "react/jsx-runtime";
5
+ //#region src/lib/components/Select/SelectCore.tsx
6
+ var n = "haze-SelectCore__base", r = {
7
+ sm: "haze-SelectCore__sm",
8
+ md: "haze-SelectCore__md",
9
+ lg: "haze-SelectCore__lg"
10
+ };
11
+ function i({ value: i, onChange: a, onNativeChange: o, size: s = "md", className: c, children: l, ...u }) {
12
+ return /* @__PURE__ */ t("select", {
13
+ value: i,
14
+ onChange: (e) => {
15
+ a(e.target.value), o?.(e);
16
+ },
17
+ ...u,
18
+ className: e([
19
+ n,
20
+ r[s],
21
+ c
22
+ ]),
23
+ children: l
24
+ });
25
+ }
26
+ //#endregion
27
+ export { i as default };
@@ -1,21 +1,16 @@
1
-
2
- import { classnames as e } from "../../utils/classnames.js";
3
- /* empty css */
1
+ import e from "./SliderCore.js";
4
2
  import { jsx as t } from "react/jsx-runtime";
5
3
  import { useControl as n } from "react-use-control";
6
4
  //#region src/lib/components/Slider/Slider.tsx
7
- var r = "haze-Slider__base";
8
- function i({ value: i, className: a, onChange: o, ...s }) {
9
- let [c, l] = n(i, 50);
10
- return /* @__PURE__ */ t("input", {
11
- type: "range",
12
- value: c,
13
- onChange: (e) => {
14
- l(Number(e.target.value)), o?.(e);
15
- },
16
- ...s,
17
- className: e([r, a])
5
+ function r({ value: r, className: i, onChange: a, ...o }) {
6
+ let [s, c] = n(r, 50);
7
+ return /* @__PURE__ */ t(e, {
8
+ value: s,
9
+ onChange: c,
10
+ onNativeChange: a,
11
+ className: i,
12
+ ...o
18
13
  });
19
14
  }
20
15
  //#endregion
21
- export { i as default };
16
+ export { r as default };
@@ -0,0 +1,19 @@
1
+
2
+ import { classnames as e } from "../../utils/classnames.js";
3
+ /* empty css */
4
+ import { jsx as t } from "react/jsx-runtime";
5
+ //#region src/lib/components/Slider/SliderCore.tsx
6
+ var n = "haze-SliderCore__base";
7
+ function r({ value: r, onChange: i, onNativeChange: a, className: o, ...s }) {
8
+ return /* @__PURE__ */ t("input", {
9
+ type: "range",
10
+ value: r,
11
+ onChange: (e) => {
12
+ i(Number(e.target.value)), a?.(e);
13
+ },
14
+ ...s,
15
+ className: e([n, o])
16
+ });
17
+ }
18
+ //#endregion
19
+ export { r as default };
@@ -1,44 +1,17 @@
1
-
2
- import { classnames as e } from "../../utils/classnames.js";
3
- /* empty css */
1
+ import e from "./SwitchCore.js";
4
2
  import { jsx as t } from "react/jsx-runtime";
5
3
  import { useControl as n } from "react-use-control";
6
4
  //#region src/lib/components/Switch/Switch.tsx
7
- var r = "haze-Switch__track", i = "haze-Switch__trackChecked", a = "haze-Switch__thumb", o = "haze-Switch__trackSm", s = "haze-Switch__trackMd", c = "haze-Switch__trackLg", l = "haze-Switch__thumbSm", u = "haze-Switch__thumbMd", d = "haze-Switch__thumbLg", f = "haze-Switch__thumbCheckedSm", p = "haze-Switch__thumbCheckedMd", m = "haze-Switch__thumbCheckedLg", h = {
8
- sm: o,
9
- md: s,
10
- lg: c
11
- }, g = {
12
- sm: l,
13
- md: u,
14
- lg: d
15
- }, _ = {
16
- sm: f,
17
- md: p,
18
- lg: m
19
- };
20
- function v({ checked: o, size: s = "md", className: c, onClick: l, ...u }) {
21
- let [d, f] = n(o, !1);
22
- return /* @__PURE__ */ t("button", {
23
- type: "button",
24
- role: "switch",
25
- "aria-checked": d,
26
- onClick: (e) => {
27
- f((e) => !e), l?.(e);
28
- },
29
- ...u,
30
- className: e([
31
- r,
32
- h[s],
33
- d && i,
34
- c
35
- ]),
36
- children: t("span", { className: e([
37
- a,
38
- g[s],
39
- d && _[s]
40
- ]) })
5
+ function r({ checked: r, size: i, className: a, onClick: o, ...s }) {
6
+ let [c, l] = n(r, !1);
7
+ return /* @__PURE__ */ t(e, {
8
+ checked: c,
9
+ onChange: l,
10
+ onNativeClick: o,
11
+ size: i,
12
+ className: a,
13
+ ...s
41
14
  });
42
15
  }
43
16
  //#endregion
44
- export { v as default };
17
+ export { r as default };
@@ -0,0 +1,42 @@
1
+
2
+ import { classnames as e } from "../../utils/classnames.js";
3
+ /* empty css */
4
+ import { jsx as t } from "react/jsx-runtime";
5
+ //#region src/lib/components/Switch/SwitchCore.tsx
6
+ var n = "haze-SwitchCore__track", r = "haze-SwitchCore__trackChecked", i = "haze-SwitchCore__thumb", a = "haze-SwitchCore__trackSm", o = "haze-SwitchCore__trackMd", s = "haze-SwitchCore__trackLg", c = "haze-SwitchCore__thumbSm", l = "haze-SwitchCore__thumbMd", u = "haze-SwitchCore__thumbLg", d = "haze-SwitchCore__thumbCheckedSm", f = "haze-SwitchCore__thumbCheckedMd", p = "haze-SwitchCore__thumbCheckedLg", m = {
7
+ sm: a,
8
+ md: o,
9
+ lg: s
10
+ }, h = {
11
+ sm: c,
12
+ md: l,
13
+ lg: u
14
+ }, g = {
15
+ sm: d,
16
+ md: f,
17
+ lg: p
18
+ };
19
+ function _({ checked: a, onChange: o, onNativeClick: s, size: c = "md", className: l, ...u }) {
20
+ return /* @__PURE__ */ t("button", {
21
+ type: "button",
22
+ role: "switch",
23
+ "aria-checked": a,
24
+ onClick: (e) => {
25
+ o(!a), s?.(e);
26
+ },
27
+ ...u,
28
+ className: e([
29
+ n,
30
+ m[c],
31
+ a && r,
32
+ l
33
+ ]),
34
+ children: t("span", { className: e([
35
+ i,
36
+ h[c],
37
+ a && g[c]
38
+ ]) })
39
+ });
40
+ }
41
+ //#endregion
42
+ export { _ as default };
@@ -1,76 +1,22 @@
1
-
2
- import { classnames as e } from "../../utils/classnames.js";
3
- /* empty css */
4
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
5
- import { useControl as r } from "react-use-control";
6
- import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
1
+ import e from "./TagInputCore.js";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { useControl as n } from "react-use-control";
7
4
  //#region src/lib/components/TagInput/TagInput.tsx
8
- var c = "haze-TagInput__container", l = "haze-TagInput__listWrap", u = "haze-TagInput__tag", d = "haze-TagInput__removeBtn", f = "haze-TagInput__inputEl";
9
- function p({ value: p, onChange: m, placeholder: h, maxTags: g, disabled: _, className: v, id: y, "aria-invalid": b, "aria-describedby": x }) {
10
- let [S, C] = r(p, []), [w, T] = s(""), E = o(null), D = o(null), O = o(null);
11
- a(() => {
12
- let e = O.current;
13
- if (e === null) return;
14
- if (O.current = null, S.length === 0) {
15
- D.current?.focus();
16
- return;
17
- }
18
- let t = Math.min(e, S.length - 1);
19
- (E.current?.querySelectorAll("[aria-label^=\"Remove \"]"))?.[t]?.focus();
20
- }, [S]);
21
- let k = i((e) => {
22
- let t = e.trim();
23
- if (!t || S.includes(t) || g && S.length >= g) return;
24
- let n = [...S, t];
25
- C(n), m?.(n), T("");
26
- }, [
27
- S,
28
- g,
29
- C,
30
- m
31
- ]), A = i((e) => {
32
- let t = S.filter((t, n) => n !== e);
33
- C(t), m?.(t), O.current = t.length === 0 ? 0 : Math.min(e, t.length - 1);
34
- }, [
35
- S,
36
- C,
37
- m
38
- ]), j = (e) => {
39
- e.key === "Enter" || e.key === "," ? (e.preventDefault(), k(w)) : e.key === "Backspace" && !w && S.length > 0 && A(S.length - 1);
40
- }, M = h || "Add tag", N = `${S.length} tag${S.length === 1 ? "" : "s"}`;
41
- return /* @__PURE__ */ n("div", {
42
- ref: E,
43
- className: e([c, v]),
44
- children: [/* @__PURE__ */ t("ul", {
45
- className: e([l]),
46
- children: S.map((r, i) => /* @__PURE__ */ n("li", {
47
- className: e([u]),
48
- children: [r, /* @__PURE__ */ t("button", {
49
- type: "button",
50
- onClick: () => A(i),
51
- onKeyDown: (e) => {
52
- e.key === "Backspace" && (e.preventDefault(), A(i));
53
- },
54
- "aria-label": `Remove ${r}`,
55
- disabled: _,
56
- className: e([d]),
57
- children: "x"
58
- })]
59
- }, i))
60
- }), /* @__PURE__ */ t("input", {
61
- ref: D,
62
- id: y,
63
- "aria-invalid": b,
64
- "aria-describedby": x,
65
- value: w,
66
- onChange: (e) => T(e.target.value),
67
- onKeyDown: j,
68
- placeholder: S.length === 0 ? h : void 0,
69
- "aria-label": S.length > 0 ? `${M}, ${N}` : M,
70
- disabled: _,
71
- className: e([f])
72
- })]
5
+ function r({ value: r, onChange: i, placeholder: a, maxTags: o, disabled: s, className: c, id: l, "aria-invalid": u, "aria-describedby": d }) {
6
+ let [f, p] = n(r, []);
7
+ return /* @__PURE__ */ t(e, {
8
+ value: f,
9
+ onChange: (e) => {
10
+ p(e), i?.(e);
11
+ },
12
+ placeholder: a,
13
+ maxTags: o,
14
+ disabled: s,
15
+ className: c,
16
+ id: l,
17
+ "aria-invalid": u,
18
+ "aria-describedby": d
73
19
  });
74
20
  }
75
21
  //#endregion
76
- export { p as default };
22
+ export { r as default };
@@ -0,0 +1,68 @@
1
+
2
+ import { classnames as e } from "../../utils/classnames.js";
3
+ /* empty css */
4
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
5
+ import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
6
+ //#region src/lib/components/TagInput/TagInputCore.tsx
7
+ var s = "haze-TagInputCore__container", c = "haze-TagInputCore__listWrap", l = "haze-TagInputCore__tag", u = "haze-TagInputCore__removeBtn", d = "haze-TagInputCore__inputEl";
8
+ function f({ value: f, onChange: p, placeholder: m, maxTags: h, disabled: g, className: _, id: v, "aria-invalid": y, "aria-describedby": b }) {
9
+ let [x, S] = o(""), C = a(null), w = a(null), T = a(null);
10
+ i(() => {
11
+ let e = T.current;
12
+ if (e === null) return;
13
+ if (T.current = null, f.length === 0) {
14
+ w.current?.focus();
15
+ return;
16
+ }
17
+ let t = Math.min(e, f.length - 1);
18
+ (C.current?.querySelectorAll("[aria-label^=\"Remove \"]"))?.[t]?.focus();
19
+ }, [f]);
20
+ let E = r((e) => {
21
+ let t = e.trim();
22
+ !t || f.includes(t) || h && f.length >= h || (p([...f, t]), S(""));
23
+ }, [
24
+ f,
25
+ h,
26
+ p
27
+ ]), D = r((e) => {
28
+ let t = f.filter((t, n) => n !== e);
29
+ p(t), T.current = t.length === 0 ? 0 : Math.min(e, t.length - 1);
30
+ }, [f, p]), O = (e) => {
31
+ e.key === "Enter" || e.key === "," ? (e.preventDefault(), E(x)) : e.key === "Backspace" && !x && f.length > 0 && D(f.length - 1);
32
+ }, k = m || "Add tag", A = `${f.length} tag${f.length === 1 ? "" : "s"}`;
33
+ return /* @__PURE__ */ n("div", {
34
+ ref: C,
35
+ className: e([s, _]),
36
+ children: [/* @__PURE__ */ t("ul", {
37
+ className: e([c]),
38
+ children: f.map((r, i) => /* @__PURE__ */ n("li", {
39
+ className: e([l]),
40
+ children: [r, /* @__PURE__ */ t("button", {
41
+ type: "button",
42
+ onClick: () => D(i),
43
+ onKeyDown: (e) => {
44
+ e.key === "Backspace" && (e.preventDefault(), D(i));
45
+ },
46
+ "aria-label": `Remove ${r}`,
47
+ disabled: g,
48
+ className: e([u]),
49
+ children: "x"
50
+ })]
51
+ }, i))
52
+ }), /* @__PURE__ */ t("input", {
53
+ ref: w,
54
+ id: v,
55
+ "aria-invalid": y,
56
+ "aria-describedby": b,
57
+ value: x,
58
+ onChange: (e) => S(e.target.value),
59
+ onKeyDown: O,
60
+ placeholder: f.length === 0 ? m : void 0,
61
+ "aria-label": f.length > 0 ? `${k}, ${A}` : k,
62
+ disabled: g,
63
+ className: e([d])
64
+ })]
65
+ });
66
+ }
67
+ //#endregion
68
+ export { f as default };
@@ -1,28 +1,17 @@
1
-
2
- import { classnames as e } from "../../utils/classnames.js";
3
- /* empty css */
1
+ import e from "./TextareaCore.js";
4
2
  import { jsx as t } from "react/jsx-runtime";
5
3
  import { useControl as n } from "react-use-control";
6
4
  //#region src/lib/components/Textarea/Textarea.tsx
7
- var r = "haze-Textarea__base", i = {
8
- sm: "haze-Textarea__sm",
9
- md: "haze-Textarea__md",
10
- lg: "haze-Textarea__lg"
11
- };
12
- function a({ value: a, size: o = "md", className: s, onChange: c, ...l }) {
13
- let [u, d] = n(a, "");
14
- return /* @__PURE__ */ t("textarea", {
15
- value: u,
16
- onChange: (e) => {
17
- d(e.target.value), c?.(e);
18
- },
19
- ...l,
20
- className: e([
21
- r,
22
- i[o],
23
- s
24
- ])
5
+ function r({ value: r, size: i, className: a, onChange: o, ...s }) {
6
+ let [c, l] = n(r, "");
7
+ return /* @__PURE__ */ t(e, {
8
+ value: c,
9
+ onChange: l,
10
+ onNativeChange: o,
11
+ size: i,
12
+ className: a,
13
+ ...s
25
14
  });
26
15
  }
27
16
  //#endregion
28
- export { a as default };
17
+ export { r as default };