haze-ui 1.12.0 → 1.12.2

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 (98) hide show
  1. package/README.md +36 -24
  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 +36 -0
  6. package/dist/components/DateRangePicker/DateRangePicker.js +17 -35
  7. package/dist/components/DateRangePicker/DateRangePickerCore.js +31 -0
  8. package/dist/components/Datepicker/Datepicker.js +15 -39
  9. package/dist/components/Datepicker/DatepickerCore.js +42 -0
  10. package/dist/components/Input/Input.js +11 -22
  11. package/dist/components/Input/InputCore.js +26 -0
  12. package/dist/components/NumberInput/NumberInput.js +16 -53
  13. package/dist/components/NumberInput/NumberInputCore.js +56 -0
  14. package/dist/components/OTPInput/OTPInput.js +11 -45
  15. package/dist/components/OTPInput/OTPInputCore.js +43 -0
  16. package/dist/components/PasswordInput/PasswordInput.js +14 -29
  17. package/dist/components/PasswordInput/PasswordInputCore.js +30 -0
  18. package/dist/components/Radio/RadioGroup.js +12 -21
  19. package/dist/components/Radio/RadioGroupCore.js +24 -0
  20. package/dist/components/Rating/Rating.js +14 -46
  21. package/dist/components/Rating/RatingCore.js +48 -0
  22. package/dist/components/Segmented/Segmented.js +12 -37
  23. package/dist/components/Segmented/SegmentedCore.js +39 -0
  24. package/dist/components/Select/Select.js +12 -23
  25. package/dist/components/Select/SelectCore.js +27 -0
  26. package/dist/components/Slider/Slider.js +10 -15
  27. package/dist/components/Slider/SliderCore.js +19 -0
  28. package/dist/components/Switch/Switch.js +11 -38
  29. package/dist/components/Switch/SwitchCore.js +42 -0
  30. package/dist/components/TagInput/TagInput.js +18 -72
  31. package/dist/components/TagInput/TagInputCore.js +68 -0
  32. package/dist/components/Textarea/Textarea.js +11 -22
  33. package/dist/components/Textarea/TextareaCore.js +26 -0
  34. package/dist/components/TimePicker/TimePicker.js +10 -15
  35. package/dist/components/TimePicker/TimePickerCore.js +18 -0
  36. package/dist/css/checkbox.css +1 -1
  37. package/dist/css/color-picker.css +1 -1
  38. package/dist/css/date-range-picker.css +1 -1
  39. package/dist/css/datepicker.css +1 -1
  40. package/dist/css/input.css +1 -1
  41. package/dist/css/number-input.css +1 -1
  42. package/dist/css/otp-input.css +1 -1
  43. package/dist/css/password-input.css +1 -1
  44. package/dist/css/radio.css +1 -1
  45. package/dist/css/rating.css +1 -1
  46. package/dist/css/segmented.css +1 -1
  47. package/dist/css/select.css +1 -1
  48. package/dist/css/slider.css +1 -1
  49. package/dist/css/switch.css +1 -1
  50. package/dist/css/tag-input.css +1 -1
  51. package/dist/css/textarea.css +1 -1
  52. package/dist/css/time-picker.css +1 -1
  53. package/dist/form/FormItem.js +32 -32
  54. package/dist/haze-ui.css +17 -17
  55. package/dist/index.js +138 -122
  56. package/dist/types/components/Checkbox/CheckboxCore.d.ts +12 -0
  57. package/dist/types/components/Checkbox/index.d.ts +2 -0
  58. package/dist/types/components/ColorPicker/ColorPickerCore.d.ts +8 -0
  59. package/dist/types/components/ColorPicker/index.d.ts +2 -0
  60. package/dist/types/components/DateRangePicker/DateRangePickerCore.d.ts +11 -0
  61. package/dist/types/components/DateRangePicker/index.d.ts +2 -0
  62. package/dist/types/components/Datepicker/DatepickerCore.d.ts +12 -0
  63. package/dist/types/components/Datepicker/index.d.ts +2 -0
  64. package/dist/types/components/Input/InputCore.d.ts +13 -0
  65. package/dist/types/components/Input/index.d.ts +2 -0
  66. package/dist/types/components/NumberInput/NumberInputCore.d.ts +15 -0
  67. package/dist/types/components/NumberInput/index.d.ts +2 -0
  68. package/dist/types/components/OTPInput/OTPInputCore.d.ts +8 -0
  69. package/dist/types/components/OTPInput/index.d.ts +2 -0
  70. package/dist/types/components/PasswordInput/PasswordInputCore.d.ts +9 -0
  71. package/dist/types/components/PasswordInput/index.d.ts +2 -0
  72. package/dist/types/components/Radio/RadioContext.d.ts +1 -2
  73. package/dist/types/components/Radio/RadioGroupCore.d.ts +10 -0
  74. package/dist/types/components/Radio/index.d.ts +2 -0
  75. package/dist/types/components/Rating/RatingCore.d.ts +9 -0
  76. package/dist/types/components/Rating/index.d.ts +2 -0
  77. package/dist/types/components/Segmented/Segmented.d.ts +1 -6
  78. package/dist/types/components/Segmented/SegmentedCore.d.ts +15 -0
  79. package/dist/types/components/Segmented/index.d.ts +2 -0
  80. package/dist/types/components/Select/SelectCore.d.ts +13 -0
  81. package/dist/types/components/Select/index.d.ts +2 -0
  82. package/dist/types/components/Slider/SliderCore.d.ts +11 -0
  83. package/dist/types/components/Slider/index.d.ts +2 -0
  84. package/dist/types/components/Switch/Switch.d.ts +1 -1
  85. package/dist/types/components/Switch/SwitchCore.d.ts +12 -0
  86. package/dist/types/components/Switch/index.d.ts +2 -0
  87. package/dist/types/components/TagInput/TagInputCore.d.ts +20 -0
  88. package/dist/types/components/TagInput/index.d.ts +2 -0
  89. package/dist/types/components/Textarea/TextareaCore.d.ts +12 -0
  90. package/dist/types/components/Textarea/index.d.ts +2 -0
  91. package/dist/types/components/TimePicker/TimePickerCore.d.ts +9 -0
  92. package/dist/types/components/TimePicker/index.d.ts +2 -0
  93. package/dist/types/form/FormItem.d.ts +23 -12
  94. package/dist/types/form/index.d.ts +1 -2
  95. package/dist/types/index.d.ts +35 -35
  96. package/package.json +15 -15
  97. package/dist/form/useFormControl.js +0 -54
  98. package/dist/types/form/useFormControl.d.ts +0 -32
package/README.md CHANGED
@@ -51,34 +51,45 @@ always come from `haze-ui/css/tokens.css`.
51
51
 
52
52
  ## react-f0rm Integration
53
53
 
54
- The form layer (`FormItem`, `useFormControl`; peer dependency
55
- `react-f0rm`) is exported from the main barrel and glues react-f0rm
56
- form state to haze-ui's control-prop system, so any control-prop
57
- component (`Input`, `Select`, `Switch`, `Textarea`, `TagInput`, ...)
58
- binds to a form field with zero adapters.
54
+ react-f0rm owns form field state, and its headless `useField` hook is
55
+ the single binding layer the same channel its built-in
56
+ `Field`/`Checkbox`/`Select` components use. haze-ui contributes the
57
+ views: controlled cores (`InputCore`, `SelectCore`, `SwitchCore`,
58
+ `TextareaCore`, `TagInputCore`, ...) take the plain `{value, onChange}`
59
+ pair with zero adapters, and `FormItem` wraps the hook's state in label,
60
+ error and aria wiring. The sugar components (`Input`, `Select`, ...)
61
+ keep their `Control<T> | T` API for standalone use outside forms.
59
62
 
60
- ### useFormControl(form, name): field → Control
63
+ ### useField: field → {value, onChange}
61
64
 
62
65
  ```jsx
63
- import { useForm, setValue } from 'react-f0rm';
64
- import { Input, useFormControl } from 'haze-ui';
66
+ import { useForm, useField } from 'react-f0rm';
67
+ import { InputCore } from 'haze-ui';
65
68
 
66
69
  function NameField({ form }) {
67
- const name = useFormControl(form, 'name');
68
- return <Input value={name} />; // two-way bound, no onChange wiring
70
+ const { value, onChange } = useField({ form, name: 'name' });
71
+ return <InputCore value={value} onChange={onChange} />; // two-way bound
69
72
  }
70
73
  ```
71
74
 
72
- The handle is a real `Control`: reads subscribe to the field (sibling
73
- fields stay isolated), writes go through `setValueByPath`, and functional
74
- updates evaluate against the live form value. `reset(form, newValues)`
75
- re-seeds every bridged control with no remounting.
75
+ The hook subscribes to the field (sibling fields stay isolated), and
76
+ `onChange` writes through react-f0rm's user-change channel a write
77
+ fires exactly the validation a user typing into the field would fire:
78
+ the field's effective `mode` (a `FormItem`/`useField` per-field override
79
+ included) and the form's `reValidateMode`. With the default
80
+ `mode: 'onSubmit'` + `reValidateMode: 'onChange'`, typing through a bound
81
+ core after a failed submit re-validates per keystroke and clears the
82
+ error as soon as the value is valid — no blur, no resubmit. `onChange`
83
+ accepts plain values only (controlled cores emit the next value, never
84
+ functional updaters; read the previous value from `value` on the next
85
+ render). `reset(form, newValues)` re-seeds every binding with no
86
+ remounting.
76
87
 
77
88
  ### FormItem: label, errors and aria wiring
78
89
 
79
90
  ```jsx
80
91
  import { Form, useForm } from 'react-f0rm';
81
- import { FormItem, Input } from 'haze-ui';
92
+ import { FormItem, InputCore } from 'haze-ui';
82
93
 
83
94
  function ProfileForm() {
84
95
  const form = useForm({ initialValues: { email: '' } });
@@ -90,8 +101,8 @@ function ProfileForm() {
90
101
  label="Email"
91
102
  validate={(v) => (v.includes('@') ? undefined : 'must be an email')}
92
103
  >
93
- {({ id, errorId, invalid, control }) => (
94
- <Input id={id} value={control} aria-invalid={invalid} aria-describedby={errorId} />
104
+ {({ id, errorId, invalid, value, onChange }) => (
105
+ <InputCore id={id} value={value} onChange={onChange} aria-invalid={invalid} aria-describedby={errorId} />
95
106
  )}
96
107
  </FormItem>
97
108
  </Form>
@@ -119,10 +130,11 @@ keep the form's mode.
119
130
  mode="onBlur"
120
131
  validate={(v) => (v.includes('@') ? undefined : 'must be an email')}
121
132
  >
122
- {({ id, errorId, invalid, onBlur, control }) => (
123
- <Input
133
+ {({ id, errorId, invalid, onBlur, value, onChange }) => (
134
+ <InputCore
124
135
  id={id}
125
- value={control}
136
+ value={value}
137
+ onChange={onChange}
126
138
  aria-invalid={invalid}
127
139
  aria-describedby={errorId}
128
140
  onBlur={onBlur}
@@ -131,8 +143,8 @@ keep the form's mode.
131
143
  </FormItem>
132
144
  ```
133
145
 
134
- With `mode="onBlur"` (and the binding's `onBlur` passed to the control,
135
- as above) the email field is validated the moment it loses focus — no
146
+ With `mode="onBlur"` (and the binding's `onBlur` passed to the core, as
147
+ above) the email field is validated the moment it loses focus — no
136
148
  submit needed. `mode` accepts `'onSubmit'`, `'onBlur'`, `'onChange'`,
137
149
  `'onTouched'` or `'all'`; only this field's schedule changes, the rest
138
150
  of the form keeps its own `mode`.
@@ -166,8 +178,8 @@ react-f0rm's `useField`:
166
178
  rules={{ required: 'Email is required' }}
167
179
  validate={(v) => (v.includes('@') ? undefined : 'must be an email')}
168
180
  >
169
- {({ id, errorId, invalid, control }) => (
170
- <Input id={id} value={control} aria-invalid={invalid} aria-describedby={errorId} />
181
+ {({ id, errorId, invalid, value, onChange }) => (
182
+ <InputCore id={id} value={value} onChange={onChange} aria-invalid={invalid} aria-describedby={errorId} />
171
183
  )}
172
184
  </FormItem>
173
185
  ```
@@ -1,24 +1,17 @@
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";
1
+ import e from "./CheckboxCore.js";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { useControl as n } from "react-use-control";
6
4
  //#region src/lib/components/Checkbox/Checkbox.tsx
7
- var i = "haze-Checkbox__base", a = "haze-Checkbox__labelText";
8
- function o({ checked: o, className: s, label: c, onChange: l, ...u }) {
9
- let [d, f] = r(o, !1), p = /* @__PURE__ */ t("input", {
10
- type: "checkbox",
11
- checked: d,
12
- onChange: (e) => {
13
- f(e.target.checked), l?.(e);
14
- },
15
- ...u,
16
- className: e([i, s])
17
- });
18
- return c === void 0 ? p : /* @__PURE__ */ n("label", {
19
- className: e(a),
20
- children: [p, c]
5
+ function r({ checked: r, className: i, label: a, onChange: o, ...s }) {
6
+ let [c, l] = n(r, !1);
7
+ return /* @__PURE__ */ t(e, {
8
+ checked: c,
9
+ onChange: l,
10
+ onNativeChange: o,
11
+ className: i,
12
+ label: a,
13
+ ...s
21
14
  });
22
15
  }
23
16
  //#endregion
24
- export { o as default };
17
+ export { r as default };
@@ -0,0 +1,23 @@
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
+ //#region src/lib/components/Checkbox/CheckboxCore.tsx
6
+ var r = "haze-CheckboxCore__base", i = "haze-CheckboxCore__labelText";
7
+ function a({ checked: a, onChange: o, onNativeChange: s, className: c, label: l, ...u }) {
8
+ let d = /* @__PURE__ */ t("input", {
9
+ type: "checkbox",
10
+ checked: a,
11
+ onChange: (e) => {
12
+ o(e.target.checked), s?.(e);
13
+ },
14
+ ...u,
15
+ className: e([r, c])
16
+ });
17
+ return l === void 0 ? d : /* @__PURE__ */ n("label", {
18
+ className: e(i),
19
+ children: [d, l]
20
+ });
21
+ }
22
+ //#endregion
23
+ export { a as default };
@@ -1,46 +1,17 @@
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";
1
+ import e from "./ColorPickerCore.js";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { useControl as n } from "react-use-control";
6
4
  //#region src/lib/components/ColorPicker/ColorPicker.tsx
7
- var i = "haze-ColorPicker__container", a = "haze-ColorPicker__previewRow", o = "haze-ColorPicker__colorInput", s = "haze-ColorPicker__textInput", c = "haze-ColorPicker__presetsRow", l = "haze-ColorPicker__presetBtn", u = "haze-ColorPicker__activePreset";
8
- function d({ value: d, presets: f, onChange: p, className: m }) {
9
- let [h, g] = r(d, "#000000"), _ = (e) => {
10
- let t = e.target.value;
11
- g(t), p?.(t);
12
- }, v = (e) => {
13
- let t = e.target.value;
14
- g(t), p?.(t);
15
- }, y = (e) => {
16
- g(e), p?.(e);
17
- };
18
- return /* @__PURE__ */ n("div", {
19
- className: e([i, m]),
20
- children: [/* @__PURE__ */ n("div", {
21
- className: e([a]),
22
- children: [/* @__PURE__ */ t("input", {
23
- type: "color",
24
- value: h,
25
- onChange: v,
26
- className: e([o])
27
- }), /* @__PURE__ */ t("input", {
28
- type: "text",
29
- value: h,
30
- onChange: _,
31
- className: e([s])
32
- })]
33
- }), f && f.length > 0 && /* @__PURE__ */ t("div", {
34
- className: e([c]),
35
- children: f.map((n) => /* @__PURE__ */ t("button", {
36
- type: "button",
37
- style: { background: n },
38
- "aria-label": n,
39
- onClick: () => y(n),
40
- className: e([l, h === n && u])
41
- }, n))
42
- })]
5
+ function r({ value: r, presets: i, onChange: a, className: o }) {
6
+ let [s, c] = n(r, "#000000");
7
+ return /* @__PURE__ */ t(e, {
8
+ value: s,
9
+ onChange: (e) => {
10
+ c(e), a?.(e);
11
+ },
12
+ presets: i,
13
+ className: o
43
14
  });
44
15
  }
45
16
  //#endregion
46
- export { d as default };
17
+ export { r as default };
@@ -0,0 +1,36 @@
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
+ //#region src/lib/components/ColorPicker/ColorPickerCore.tsx
6
+ var r = "haze-ColorPickerCore__container", i = "haze-ColorPickerCore__previewRow", a = "haze-ColorPickerCore__colorInput", o = "haze-ColorPickerCore__textInput", s = "haze-ColorPickerCore__presetsRow", c = "haze-ColorPickerCore__presetBtn", l = "haze-ColorPickerCore__activePreset";
7
+ function u({ value: u, onChange: d, presets: f, className: p }) {
8
+ return /* @__PURE__ */ n("div", {
9
+ className: e([r, p]),
10
+ children: [/* @__PURE__ */ n("div", {
11
+ className: e([i]),
12
+ children: [/* @__PURE__ */ t("input", {
13
+ type: "color",
14
+ value: u,
15
+ onChange: (e) => d(e.target.value),
16
+ className: e([a])
17
+ }), /* @__PURE__ */ t("input", {
18
+ type: "text",
19
+ value: u,
20
+ onChange: (e) => d(e.target.value),
21
+ className: e([o])
22
+ })]
23
+ }), f && f.length > 0 && /* @__PURE__ */ t("div", {
24
+ className: e([s]),
25
+ children: f.map((n) => /* @__PURE__ */ t("button", {
26
+ type: "button",
27
+ style: { background: n },
28
+ "aria-label": n,
29
+ onClick: () => d(n),
30
+ className: e([c, u === n && l])
31
+ }, n))
32
+ })]
33
+ });
34
+ }
35
+ //#endregion
36
+ export { u as default };
@@ -1,39 +1,21 @@
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";
1
+ import e from "./DateRangePickerCore.js";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { useControl as n } from "react-use-control";
6
4
  //#region src/lib/components/DateRangePicker/DateRangePicker.tsx
7
- var i = "haze-DateRangePicker__container", a = "haze-DateRangePicker__input", o = "haze-DateRangePicker__sep";
8
- function s({ startDate: s, endDate: c, onStartChange: l, onEndChange: u, separator: d = "", className: f }) {
9
- let [p, m] = r(s, ""), [h, g] = r(c, "");
10
- return /* @__PURE__ */ n("div", {
11
- className: e([i, f]),
12
- children: [
13
- /* @__PURE__ */ t("input", {
14
- type: "date",
15
- value: p,
16
- onChange: (e) => {
17
- let t = e.target.value;
18
- m(t), l?.(t);
19
- },
20
- className: e([a])
21
- }),
22
- /* @__PURE__ */ t("span", {
23
- className: e([o]),
24
- children: d
25
- }),
26
- /* @__PURE__ */ t("input", {
27
- type: "date",
28
- value: h,
29
- onChange: (e) => {
30
- let t = e.target.value;
31
- g(t), u?.(t);
32
- },
33
- className: e([a])
34
- })
35
- ]
5
+ function r({ startDate: r, endDate: i, onStartChange: a, onEndChange: o, separator: s, className: c }) {
6
+ let [l, u] = n(r, ""), [d, f] = n(i, "");
7
+ return /* @__PURE__ */ t(e, {
8
+ startDate: l,
9
+ endDate: d,
10
+ onStartChange: (e) => {
11
+ u(e), a?.(e);
12
+ },
13
+ onEndChange: (e) => {
14
+ f(e), o?.(e);
15
+ },
16
+ separator: s,
17
+ className: c
36
18
  });
37
19
  }
38
20
  //#endregion
39
- export { s as default };
21
+ export { r as default };
@@ -0,0 +1,31 @@
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
+ //#region src/lib/components/DateRangePicker/DateRangePickerCore.tsx
6
+ var r = "haze-DateRangePickerCore__container", i = "haze-DateRangePickerCore__input", a = "haze-DateRangePickerCore__sep";
7
+ function o({ startDate: o, endDate: s, onStartChange: c, onEndChange: l, separator: u = "–", className: d }) {
8
+ return /* @__PURE__ */ n("div", {
9
+ className: e([r, d]),
10
+ children: [
11
+ /* @__PURE__ */ t("input", {
12
+ type: "date",
13
+ value: o,
14
+ onChange: (e) => c(e.target.value),
15
+ className: e([i])
16
+ }),
17
+ /* @__PURE__ */ t("span", {
18
+ className: e([a]),
19
+ children: u
20
+ }),
21
+ /* @__PURE__ */ t("input", {
22
+ type: "date",
23
+ value: s,
24
+ onChange: (e) => l(e.target.value),
25
+ className: e([i])
26
+ })
27
+ ]
28
+ });
29
+ }
30
+ //#endregion
31
+ export { o as default };
@@ -1,43 +1,19 @@
1
-
2
- import { classnames as e } from "../../utils/classnames.js";
3
- import t from "./Calendar.js";
4
- /* empty css */
5
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
6
- import { useControl as i } from "react-use-control";
7
- import { useEffect as a, useRef as o } from "react";
1
+ import e from "./DatepickerCore.js";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { useControl as n } from "react-use-control";
8
4
  //#region src/lib/components/Datepicker/Datepicker.tsx
9
- var s = "haze-Datepicker__wrapper", c = "haze-Datepicker__input", l = "haze-Datepicker__dropdown", u = "haze-Datepicker__hiddenStyle";
10
- function d({ value: d, open: f, min: p, max: m, placeholder: h = "Select date", className: g }) {
11
- let [_, v] = i(d, ""), [y, b] = i(f, !1), x = o(null);
12
- return a(() => {
13
- if (!y) return;
14
- let e = (e) => {
15
- x.current && !x.current.contains(e.target) && b(!1);
16
- };
17
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
18
- }, [y, b]), /* @__PURE__ */ r("div", {
19
- ref: x,
20
- className: e([s, g]),
21
- children: [/* @__PURE__ */ n("input", {
22
- readOnly: !0,
23
- className: c,
24
- value: _,
25
- placeholder: h,
26
- onClick: () => b((e) => !e),
27
- "aria-haspopup": "dialog",
28
- "aria-expanded": y
29
- }), /* @__PURE__ */ n("div", {
30
- className: e([l, !y && u]),
31
- children: /* @__PURE__ */ n(t, {
32
- value: _,
33
- min: p,
34
- max: m,
35
- onSelect: (e) => {
36
- v(e), b(!1);
37
- }
38
- })
39
- })]
5
+ function r({ value: r, open: i, min: a, max: o, placeholder: s, className: c }) {
6
+ let [l, u] = n(r, ""), [d, f] = n(i, !1);
7
+ return /* @__PURE__ */ t(e, {
8
+ value: l,
9
+ onChange: u,
10
+ open: d,
11
+ onOpenChange: f,
12
+ min: a,
13
+ max: o,
14
+ placeholder: s,
15
+ className: c
40
16
  });
41
17
  }
42
18
  //#endregion
43
- export { d as default };
19
+ export { r as default };
@@ -0,0 +1,42 @@
1
+
2
+ import { classnames as e } from "../../utils/classnames.js";
3
+ import t from "./Calendar.js";
4
+ /* empty css */
5
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
6
+ import { useEffect as i, useRef as a } from "react";
7
+ //#region src/lib/components/Datepicker/DatepickerCore.tsx
8
+ var o = "haze-DatepickerCore__wrapper", s = "haze-DatepickerCore__input", c = "haze-DatepickerCore__dropdown", l = "haze-DatepickerCore__hiddenStyle";
9
+ function u({ value: u, onChange: d, open: f, onOpenChange: p, min: m, max: h, placeholder: g = "Select date", className: _ }) {
10
+ let v = a(null);
11
+ return i(() => {
12
+ if (!f) return;
13
+ let e = (e) => {
14
+ v.current && !v.current.contains(e.target) && p(!1);
15
+ };
16
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
17
+ }, [f, p]), /* @__PURE__ */ r("div", {
18
+ ref: v,
19
+ className: e([o, _]),
20
+ children: [/* @__PURE__ */ n("input", {
21
+ readOnly: !0,
22
+ className: s,
23
+ value: u,
24
+ placeholder: g,
25
+ onClick: () => p(!f),
26
+ "aria-haspopup": "dialog",
27
+ "aria-expanded": f
28
+ }), /* @__PURE__ */ n("div", {
29
+ className: e([c, !f && l]),
30
+ children: /* @__PURE__ */ n(t, {
31
+ value: u,
32
+ min: m,
33
+ max: h,
34
+ onSelect: (e) => {
35
+ d(e), p(!1);
36
+ }
37
+ })
38
+ })]
39
+ });
40
+ }
41
+ //#endregion
42
+ export { u as default };
@@ -1,28 +1,17 @@
1
-
2
- import { classnames as e } from "../../utils/classnames.js";
3
- /* empty css */
1
+ import e from "./InputCore.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/Input/Input.tsx
7
- var r = "haze-Input__base", i = {
8
- sm: "haze-Input__sm",
9
- md: "haze-Input__md",
10
- lg: "haze-Input__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("input", {
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 };
@@ -0,0 +1,26 @@
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/Input/InputCore.tsx
6
+ var n = "haze-InputCore__base", r = {
7
+ sm: "haze-InputCore__sm",
8
+ md: "haze-InputCore__md",
9
+ lg: "haze-InputCore__lg"
10
+ };
11
+ function i({ value: i, onChange: a, onNativeChange: o, size: s = "md", className: c, ...l }) {
12
+ return /* @__PURE__ */ t("input", {
13
+ value: i,
14
+ onChange: (e) => {
15
+ a(e.target.value), o?.(e);
16
+ },
17
+ ...l,
18
+ className: e([
19
+ n,
20
+ r[s],
21
+ c
22
+ ])
23
+ });
24
+ }
25
+ //#endregion
26
+ export { i as default };
@@ -1,57 +1,20 @@
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";
1
+ import e from "./NumberInputCore.js";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { useControl as n } from "react-use-control";
6
4
  //#region src/lib/components/NumberInput/NumberInput.tsx
7
- var i = "haze-NumberInput__wrapper", a = "haze-NumberInput__input", o = "haze-NumberInput__stepBtn", s = "haze-NumberInput__inputSm", c = "haze-NumberInput__inputMd", l = "haze-NumberInput__inputLg", u = "haze-NumberInput__btnSm", d = "haze-NumberInput__btnMd", f = "haze-NumberInput__btnLg", p = {
8
- sm: s,
9
- md: c,
10
- lg: l
11
- }, m = {
12
- sm: u,
13
- md: d,
14
- lg: f
15
- };
16
- function h({ value: s, min: c, max: l, step: u = 1, size: d = "md", className: f, onChange: h, ...g }) {
17
- let [_, v] = r(s, 0), y = (e) => {
18
- let t = Math.round(e * 1e10) / 1e10;
19
- return c !== void 0 && t < c ? c : l !== void 0 && t > l ? l : t;
20
- };
21
- return /* @__PURE__ */ n("div", {
22
- className: e([i, f]),
23
- children: [
24
- /* @__PURE__ */ t("button", {
25
- type: "button",
26
- onClick: () => v(y(_ - u)),
27
- disabled: c !== void 0 && _ <= c,
28
- "aria-label": "Decrease",
29
- className: e([o, m[d]]),
30
- children: "−"
31
- }),
32
- /* @__PURE__ */ t("input", {
33
- type: "number",
34
- value: _,
35
- min: c,
36
- max: l,
37
- step: u,
38
- onChange: (e) => {
39
- let t = Number(e.target.value);
40
- Number.isNaN(t) || v(y(t)), h?.(e);
41
- },
42
- ...g,
43
- className: e([a, p[d]])
44
- }),
45
- /* @__PURE__ */ t("button", {
46
- type: "button",
47
- onClick: () => v(y(_ + u)),
48
- disabled: l !== void 0 && _ >= l,
49
- "aria-label": "Increase",
50
- className: e([o, m[d]]),
51
- children: "+"
52
- })
53
- ]
5
+ function r({ value: r, min: i, max: a, step: o, size: s, className: c, onChange: l, ...u }) {
6
+ let [d, f] = n(r, 0);
7
+ return /* @__PURE__ */ t(e, {
8
+ value: d,
9
+ onChange: f,
10
+ onNativeChange: l,
11
+ min: i,
12
+ max: a,
13
+ step: o,
14
+ size: s,
15
+ className: c,
16
+ ...u
54
17
  });
55
18
  }
56
19
  //#endregion
57
- export { h as default };
20
+ export { r as default };