haze-ui 1.12.2 → 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 (52) hide show
  1. package/README.md +63 -0
  2. package/dist/components/ColorPicker/ColorPickerCore.js +2 -0
  3. package/dist/components/Combobox/Combobox.js +45 -34
  4. package/dist/components/Command/Command.js +72 -37
  5. package/dist/components/ContextMenu/ContextMenu.js +19 -17
  6. package/dist/components/ContextMenu/ContextMenuContent.js +24 -12
  7. package/dist/components/ContextMenu/ContextMenuItem.js +2 -0
  8. package/dist/components/DateRangePicker/DateRangePickerCore.js +2 -0
  9. package/dist/components/Datepicker/Calendar.js +58 -44
  10. package/dist/components/Datepicker/DatepickerCore.js +37 -29
  11. package/dist/components/DropdownMenu/DropdownMenu.js +20 -20
  12. package/dist/components/DropdownMenu/DropdownMenuContent.js +38 -45
  13. package/dist/components/DropdownMenu/DropdownMenuTrigger.js +9 -7
  14. package/dist/components/InlineEdit/InlineEdit.js +1 -0
  15. package/dist/components/Menu/Menu.js +38 -26
  16. package/dist/components/Menu/MenuItem.js +1 -0
  17. package/dist/components/ModelPicker/ModelPicker.js +1 -0
  18. package/dist/components/OTPInput/OTPInputCore.js +1 -0
  19. package/dist/components/PasswordInput/PasswordInputCore.js +1 -0
  20. package/dist/components/Popover/Popover.js +32 -75
  21. package/dist/components/Progress/Progress.js +2 -0
  22. package/dist/components/Tooltip/Tooltip.js +50 -24
  23. package/dist/components/Tree/TreeItem.js +44 -41
  24. package/dist/components/Upload/Upload.js +1 -0
  25. package/dist/css/combobox.css +2 -1
  26. package/dist/css/command.css +1 -1
  27. package/dist/css/context-menu.css +1 -0
  28. package/dist/css/datepicker.css +3 -2
  29. package/dist/css/dropdown-menu.css +2 -1
  30. package/dist/css/menu.css +2 -1
  31. package/dist/css/popover.css +2 -1
  32. package/dist/css/tooltip.css +2 -1
  33. package/dist/form/FormItem.js +23 -15
  34. package/dist/haze-ui.css +15 -8
  35. package/dist/types/components/ContextMenu/ContextMenuContent.d.ts +1 -1
  36. package/dist/types/components/ContextMenu/ContextMenuContext.d.ts +5 -1
  37. package/dist/types/components/DropdownMenu/DropdownMenuContent.d.ts +1 -1
  38. package/dist/types/components/DropdownMenu/DropdownMenuContext.d.ts +3 -0
  39. package/dist/types/components/DropdownMenu/DropdownMenuTrigger.d.ts +1 -1
  40. package/dist/types/components/Tooltip/Tooltip.d.ts +5 -1
  41. package/dist/types/form/FormItem.d.ts +63 -7
  42. package/dist/types/form/index.d.ts +1 -1
  43. package/dist/types/index.d.ts +1 -1
  44. package/dist/types/utils/floating.d.ts +99 -0
  45. package/dist/types/utils/menuKeyboard.d.ts +43 -0
  46. package/dist/utils/floating.js +181 -0
  47. package/dist/utils/menuKeyboard.js +88 -0
  48. package/package.json +34 -8
  49. package/dist/components/DropdownMenu/useMenuKeyboard.js +0 -52
  50. package/dist/types/components/DropdownMenu/useMenuKeyboard.d.ts +0 -19
  51. package/dist/types/hooks/index.d.ts +0 -1
  52. package/dist/types/utils/index.d.ts +0 -1
package/README.md CHANGED
@@ -114,6 +114,46 @@ function ProfileForm() {
114
114
  surfaces the first error in a `role="alert"` element — no manual
115
115
  `FieldError` wiring.
116
116
 
117
+ #### `as`: declarative binding (react-f0rm Field-style)
118
+
119
+ Skip the render-prop: pass any component as `as` and `FormItem` wires the
120
+ id, aria attributes, `onBlur` and `onChange` itself — the same props shape
121
+ as react-f0rm's `Field`, not Radix's `asChild`. `as` and the children
122
+ render-prop are mutually exclusive.
123
+
124
+ ```jsx
125
+ // text field: nothing else to wire
126
+ <FormItem form={form} name="email" label="Email" as={InputCore} />
127
+
128
+ // checkbox-style control: value lives in `checked`
129
+ <FormItem
130
+ form={form}
131
+ name="subscribed"
132
+ label="Subscribe"
133
+ as={CheckboxCore}
134
+ valueToProps={(checked) => ({ checked: !!checked })}
135
+ />
136
+
137
+ // DOM-element-shaped control: adapt event and value in one line each
138
+ <FormItem
139
+ form={form}
140
+ name="email"
141
+ as={NativeInput}
142
+ eventToValue={(e) => e.target.value}
143
+ renderError={(error, id) => <em id={id}>{error}</em>}
144
+ />
145
+ ```
146
+
147
+ - `eventToValue` defaults to identity — haze cores' `onChange` emits the
148
+ next plain value; pass `(e) => e.target.value` when `as` is a raw DOM
149
+ element component.
150
+ - `asProps` spreads extra props onto the control before the value props,
151
+ so `value`/`valueToProps` win conflicts (Field.tsx precedence).
152
+ - `renderError(error, id)` replaces the built-in error span's content;
153
+ the span itself (`id`, `role="alert"`, styling) stays FormItem's.
154
+ - With a typed form, `validate`'s value argument is the field's actual
155
+ type (`PathValueOf<TValues, P>`), not `any`.
156
+
117
157
  #### `mode`: per-field validation timing (react-f0rm ≥ 0.6)
118
158
 
119
159
  Pass `mode` to validate one field on its own schedule instead of the
@@ -199,3 +239,26 @@ Anyone and everyone is welcome to contribute.
199
239
  ## License
200
240
 
201
241
  [MIT](https://choosealicense.com/licenses/mit/)
242
+
243
+ ## FAQ
244
+
245
+ ### Components render without any styles
246
+
247
+ haze-ui ships styles as separate CSS subpaths — the JS entry does not
248
+ import any stylesheet. Import the full bundle once:
249
+
250
+ ```js
251
+ import 'haze-ui/styles.css';
252
+ ```
253
+
254
+ or import the tokens plus each component's own rules:
255
+
256
+ ```js
257
+ import 'haze-ui/css/tokens.css';
258
+ import 'haze-ui/css/button.css';
259
+ ```
260
+
261
+ ### Is there a CommonJS build?
262
+
263
+ No — haze-ui is ESM-only (`"type": "module"`). Use a bundler or runtime
264
+ with ESM support (Vite, webpack 5, Next.js, Node ≥ 18, …).
@@ -12,11 +12,13 @@ function u({ value: u, onChange: d, presets: f, className: p }) {
12
12
  children: [/* @__PURE__ */ t("input", {
13
13
  type: "color",
14
14
  value: u,
15
+ "aria-label": "Pick color",
15
16
  onChange: (e) => d(e.target.value),
16
17
  className: e([a])
17
18
  }), /* @__PURE__ */ t("input", {
18
19
  type: "text",
19
20
  value: u,
21
+ "aria-label": "Hex color",
20
22
  onChange: (e) => d(e.target.value),
21
23
  className: e([o])
22
24
  })]
@@ -1,53 +1,64 @@
1
1
 
2
2
  import { classnames as e } from "../../utils/classnames.js";
3
- import t from "./ComboboxOption.js";
3
+ import { FloatingPanel as t, useFloating as n } from "../../utils/floating.js";
4
+ import r from "./ComboboxOption.js";
4
5
  /* 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, useId as o, useRef as s, useState as c } from "react";
6
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
7
+ import { useControl as o } from "react-use-control";
8
+ import { useEffect as s, useId as c, useRef as l, useState as u } from "react";
8
9
  //#region src/lib/components/Combobox/Combobox.tsx
9
- var l = "haze-Combobox__wrapper", u = "haze-Combobox__input", d = "haze-Combobox__listbox", f = "haze-Combobox__hidden";
10
- function p({ value: p, open: m, options: h, placeholder: g, className: _ }) {
11
- let [v, y] = i(p, ""), [b, x] = c(""), [S, C] = i(m, !1), [w, T] = c(-1), E = o(), D = s(null), O = h.filter((e) => e.label.toLowerCase().includes(b.toLowerCase()));
12
- a(() => {
13
- T(-1);
14
- }, [b]);
15
- let k = (e) => {
16
- y(e);
17
- let t = h.find((t) => t.value === e)?.label ?? e;
18
- x(t), C(!1), D.current?.focus();
10
+ var d = "haze-Combobox__wrapper", f = "haze-Combobox__input", p = "haze-Combobox__listbox";
11
+ function m({ value: m, open: h, options: g, placeholder: _, className: v }) {
12
+ let [y, b] = o(m, ""), [x, S] = u(""), [C, w] = o(h, !1), [T, E] = u(-1), D = c(), O = l(null), k = l(null), A = n({
13
+ open: C,
14
+ setOpen: w,
15
+ triggerRef: O,
16
+ panelRef: k
17
+ }), j = g.filter((e) => e.label.toLowerCase().includes(x.toLowerCase()));
18
+ s(() => {
19
+ E(-1);
20
+ }, [x]);
21
+ let M = (e) => {
22
+ b(e);
23
+ let t = g.find((t) => t.value === e)?.label ?? e;
24
+ S(t), w(!1), O.current?.focus();
19
25
  };
20
- return /* @__PURE__ */ r("div", {
21
- className: e([l, _]),
22
- children: [/* @__PURE__ */ n("input", {
23
- ref: D,
26
+ return /* @__PURE__ */ a("div", {
27
+ className: e([d, v]),
28
+ children: [/* @__PURE__ */ i("input", {
29
+ ref: O,
24
30
  role: "combobox",
25
- "aria-expanded": S,
26
- "aria-controls": E,
31
+ style: A.triggerStyle,
32
+ "aria-expanded": C,
33
+ "aria-controls": D,
27
34
  "aria-autocomplete": "list",
28
- className: u,
29
- value: b,
30
- placeholder: g,
35
+ className: f,
36
+ value: x,
37
+ placeholder: _,
31
38
  onChange: (e) => {
32
- x(e.target.value), C(!0);
39
+ S(e.target.value), w(!0);
33
40
  },
34
- onFocus: () => C(!0),
41
+ onFocus: () => w(!0),
42
+ onClick: () => w(!0),
35
43
  onKeyDown: (e) => {
36
- e.key === "ArrowDown" ? (e.preventDefault(), T((e) => Math.min(e + 1, O.length - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), T((e) => Math.max(e - 1, 0))) : e.key === "Enter" && w >= 0 && O[w] ? (e.preventDefault(), k(O[w].value)) : e.key === "Escape" && C(!1);
44
+ e.key === "ArrowDown" ? (e.preventDefault(), E((e) => Math.min(e + 1, j.length - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), E((e) => Math.max(e - 1, 0))) : e.key === "Enter" && T >= 0 && j[T] ? (e.preventDefault(), M(j[T].value)) : e.key === "Escape" && w(!1);
37
45
  }
38
- }), /* @__PURE__ */ n("div", {
39
- id: E,
46
+ }), /* @__PURE__ */ i(t, {
47
+ ref: k,
48
+ behavior: A,
49
+ placement: "bottom-span",
50
+ id: D,
40
51
  role: "listbox",
41
- className: e([d, !S && f]),
42
- children: O.map((e, r) => /* @__PURE__ */ n(t, {
52
+ visualClass: p,
53
+ children: j.map((e, t) => /* @__PURE__ */ i(r, {
43
54
  value: e.value,
44
- highlighted: r === w,
45
- selected: e.value === v,
46
- onSelect: k,
55
+ highlighted: t === T,
56
+ selected: e.value === y,
57
+ onSelect: M,
47
58
  children: e.label
48
59
  }, e.value))
49
60
  })]
50
61
  });
51
62
  }
52
63
  //#endregion
53
- export { p as default };
64
+ export { m as default };
@@ -1,59 +1,94 @@
1
1
 
2
2
  import { classnames as e } from "../../utils/classnames.js";
3
+ import { getEnabledMenuItems as t, useMenuKeyboard as n, useRovingTabindex as r } from "../../utils/menuKeyboard.js";
3
4
  /* empty css */
4
- import { jsx as t } from "react/jsx-runtime";
5
- import { useControl as n } from "react-use-control";
6
- import { createContext as r, useContext as i, useMemo as a } from "react";
5
+ import { jsx as i } from "react/jsx-runtime";
6
+ import { useControl as a } from "react-use-control";
7
+ import { createContext as o, useContext as s, useId as c, useMemo as l, useRef as u } from "react";
7
8
  //#region src/lib/components/Command/Command.tsx
8
- var o = r(void 0);
9
- function s() {
10
- let e = i(o);
9
+ var d = "[role=\"option\"]", f = o(void 0);
10
+ function p() {
11
+ let e = s(f);
11
12
  if (!e) throw Error("Command sub-components must be used within <Command>");
12
13
  return e;
13
14
  }
14
- var c = "haze-Command__base";
15
- function l({ query: r, children: i, className: s }) {
16
- let [l, u] = n(r, ""), d = a(() => ({
17
- query: l,
18
- setQuery: u
19
- }), [l, u]);
20
- return /* @__PURE__ */ t(o.Provider, {
21
- value: d,
22
- children: t("div", {
15
+ var m = "haze-Command__base";
16
+ function h({ query: t, children: n, className: r }) {
17
+ let [o, s] = a(t, ""), d = u(null), p = u(null), h = c(), g = l(() => ({
18
+ query: o,
19
+ setQuery: s,
20
+ inputRef: d,
21
+ listRef: p,
22
+ listId: h
23
+ }), [
24
+ o,
25
+ s,
26
+ h
27
+ ]);
28
+ return /* @__PURE__ */ i(f.Provider, {
29
+ value: g,
30
+ children: i("div", {
23
31
  role: "combobox",
24
- className: e([c, s]),
25
- children: i
32
+ "aria-expanded": !0,
33
+ "aria-controls": h,
34
+ className: e([m, r]),
35
+ children: n
26
36
  })
27
37
  });
28
38
  }
29
- var u = "haze-Command__inputStyle";
30
- function d({ placeholder: n, className: r }) {
31
- let { query: i, setQuery: a } = s();
32
- return /* @__PURE__ */ t("input", {
39
+ var g = "haze-Command__inputStyle";
40
+ function _({ placeholder: n, className: r }) {
41
+ let { query: a, setQuery: o, inputRef: s, listRef: c } = p();
42
+ return /* @__PURE__ */ i("input", {
43
+ ref: s,
33
44
  type: "text",
34
45
  placeholder: n,
35
- value: i,
36
- onChange: (e) => a(e.target.value),
37
- className: e([u, r])
46
+ value: a,
47
+ onChange: (e) => o(e.target.value),
48
+ onKeyDown: (e) => {
49
+ if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
50
+ e.preventDefault();
51
+ let n = t(c.current, d);
52
+ (e.key === "ArrowDown" ? n[0] : n[n.length - 1])?.focus();
53
+ },
54
+ className: e([g, r])
38
55
  });
39
56
  }
40
- var f = "haze-Command__listStyle";
41
- function p({ children: n, className: r }) {
42
- return /* @__PURE__ */ t("div", {
57
+ var v = "haze-Command__listStyle";
58
+ function y({ children: t, className: a }) {
59
+ let { inputRef: o, listRef: s, listId: c } = p();
60
+ r({
61
+ menuRef: s,
62
+ active: !0,
63
+ selector: d
64
+ });
65
+ let l = n({
66
+ menuRef: s,
67
+ selector: d,
68
+ onClose: () => o.current?.focus()
69
+ });
70
+ return /* @__PURE__ */ i("div", {
71
+ ref: s,
43
72
  role: "listbox",
44
- className: e([f, r]),
45
- children: n
73
+ id: c,
74
+ onKeyDown: l,
75
+ className: e([v, a]),
76
+ children: t
46
77
  });
47
78
  }
48
- var m = "haze-Command__itemStyle";
49
- function h({ children: n, className: r, onSelect: i }) {
50
- let { query: a } = s();
51
- return !a || (typeof n == "string" ? n : "").toLowerCase().includes(a.toLowerCase()) ? /* @__PURE__ */ t("div", {
79
+ var b = "haze-Command__itemStyle";
80
+ function x({ children: t, className: n, onSelect: r }) {
81
+ let { query: a } = p();
82
+ return !a || (typeof t == "string" ? t : "").toLowerCase().includes(a.toLowerCase()) ? /* @__PURE__ */ i("div", {
52
83
  role: "option",
53
- onClick: i,
54
- className: e([m, r]),
55
- children: n
84
+ tabIndex: -1,
85
+ onClick: r,
86
+ onKeyDown: (e) => {
87
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), r?.());
88
+ },
89
+ className: e([b, n]),
90
+ children: t
56
91
  }) : null;
57
92
  }
58
93
  //#endregion
59
- export { d as CommandInput, h as CommandItem, p as CommandList, l as default };
94
+ export { _ as CommandInput, x as CommandItem, y as CommandList, h as default };
@@ -1,38 +1,40 @@
1
1
 
2
2
  import { classnames as e } from "../../utils/classnames.js";
3
- import { ContextMenuProvider as t } from "./ContextMenuContext.js";
3
+ import { useFloating as t } from "../../utils/floating.js";
4
+ import { ContextMenuProvider as n } from "./ContextMenuContext.js";
4
5
  /* empty css */
5
- import { jsx as n } from "react/jsx-runtime";
6
- import { useControl as r } from "react-use-control";
7
- import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
6
+ import { jsx as r } from "react/jsx-runtime";
7
+ import { useControl as i } from "react-use-control";
8
+ import { useCallback as a, useRef as o, useState as s } from "react";
8
9
  //#region src/lib/components/ContextMenu/ContextMenu.tsx
9
10
  var c = "haze-ContextMenu__wrapper";
10
11
  function l({ open: l, onOpenChange: u, children: d, className: f }) {
11
- let [p, m] = r(l, !1), [h, g] = s(0), [_, v] = s(0), y = o(null), b = i((e) => {
12
+ let [p, m] = i(l, !1), [h, g] = s(0), [_, v] = s(0), y = o(null), b = o(null), x = a((e) => {
12
13
  let t = typeof e == "function" ? e(p) : e;
13
14
  m(t), u?.(t);
14
15
  }, [
15
16
  p,
16
17
  m,
17
18
  u
18
- ]), x = i((e, t) => {
19
+ ]), S = a((e, t) => {
19
20
  g(e), v(t);
20
- }, []);
21
- return a(() => {
22
- if (!p) return;
23
- let e = (e) => {
24
- y.current && !y.current.contains(e.target) && b(!1);
25
- };
26
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
27
- }, [p, b]), /* @__PURE__ */ n(t, {
21
+ }, []), C = t({
22
+ open: p,
23
+ setOpen: x,
24
+ triggerRef: y,
25
+ panelRef: b
26
+ });
27
+ return /* @__PURE__ */ r(n, {
28
28
  value: {
29
29
  open: p,
30
- setOpen: b,
30
+ setOpen: x,
31
31
  x: h,
32
32
  y: _,
33
- setPosition: x
33
+ setPosition: S,
34
+ contentRef: b,
35
+ floating: C
34
36
  },
35
- children: n("div", {
37
+ children: r("div", {
36
38
  ref: y,
37
39
  className: e([c, f]),
38
40
  children: d
@@ -1,20 +1,32 @@
1
1
 
2
- import { classnames as e } from "../../utils/classnames.js";
3
- import { useContextMenuContext as t } from "./ContextMenuContext.js";
2
+ import { FloatingPanel as e } from "../../utils/floating.js";
3
+ import { useMenuKeyboard as t, useRovingTabindex as n } from "../../utils/menuKeyboard.js";
4
+ import { useContextMenuContext as r } from "./ContextMenuContext.js";
4
5
  /* empty css */
5
- import { jsx as n } from "react/jsx-runtime";
6
+ import { jsx as i } from "react/jsx-runtime";
6
7
  //#region src/lib/components/ContextMenu/ContextMenuContent.tsx
7
- var r = "haze-ContextMenuContent__content";
8
- function i({ children: i, className: a }) {
9
- let { open: o, x: s, y: c } = t();
10
- return o ? /* @__PURE__ */ n("div", {
8
+ var a = "haze-ContextMenuContent__content";
9
+ function o({ children: o, className: s }) {
10
+ let { open: c, setOpen: l, x: u, y: d, contentRef: f, floating: p } = r(), m = t({
11
+ menuRef: f,
12
+ onClose: () => l(!1)
13
+ });
14
+ return n({
15
+ menuRef: f,
16
+ active: c
17
+ }), c ? /* @__PURE__ */ i(e, {
18
+ ref: f,
19
+ behavior: p,
20
+ role: "menu",
21
+ visualClass: a,
22
+ className: s,
11
23
  style: {
12
- left: s,
13
- top: c
24
+ left: u,
25
+ top: d
14
26
  },
15
- className: e([r, a]),
16
- children: i
27
+ onKeyDown: m,
28
+ children: o
17
29
  }) : null;
18
30
  }
19
31
  //#endregion
20
- export { i as default };
32
+ export { o as default };
@@ -9,6 +9,8 @@ function i({ children: i, onClick: a, disabled: o, className: s }) {
9
9
  let { setOpen: c } = t();
10
10
  return /* @__PURE__ */ n("button", {
11
11
  type: "button",
12
+ role: "menuitem",
13
+ tabIndex: -1,
12
14
  onClick: () => {
13
15
  o || (a?.(), c(!1));
14
16
  },
@@ -10,6 +10,7 @@ function o({ startDate: o, endDate: s, onStartChange: c, onEndChange: l, separat
10
10
  children: [
11
11
  /* @__PURE__ */ t("input", {
12
12
  type: "date",
13
+ "aria-label": "Start date",
13
14
  value: o,
14
15
  onChange: (e) => c(e.target.value),
15
16
  className: e([i])
@@ -20,6 +21,7 @@ function o({ startDate: o, endDate: s, onStartChange: c, onEndChange: l, separat
20
21
  }),
21
22
  /* @__PURE__ */ t("input", {
22
23
  type: "date",
24
+ "aria-label": "End date",
23
25
  value: s,
24
26
  onChange: (e) => l(e.target.value),
25
27
  className: e([i])
@@ -4,7 +4,7 @@ import { classnames as e } from "../../utils/classnames.js";
4
4
  import { jsx as t, jsxs as n } from "react/jsx-runtime";
5
5
  import { useState as r } from "react";
6
6
  //#region src/lib/components/Datepicker/Calendar.tsx
7
- var i = "haze-Calendar__calendarWrapper", a = "haze-Calendar__header", o = "haze-Calendar__headerBtn", s = "haze-Calendar__headerTitle", c = "haze-Calendar__grid", l = "haze-Calendar__weekday", u = "haze-Calendar__dayBtn", d = "haze-Calendar__daySelected", f = "haze-Calendar__dayOutside", p = [
7
+ var i = "haze-Calendar__calendarWrapper", a = "haze-Calendar__header", o = "haze-Calendar__headerBtn", s = "haze-Calendar__headerTitle", c = "haze-Calendar__grid", l = "haze-Calendar__rowContents", u = "haze-Calendar__cellContents", d = "haze-Calendar__weekday", f = "haze-Calendar__dayBtn", p = "haze-Calendar__daySelected", m = "haze-Calendar__dayOutside", h = [
8
8
  "Su",
9
9
  "Mo",
10
10
  "Tu",
@@ -13,94 +13,108 @@ var i = "haze-Calendar__calendarWrapper", a = "haze-Calendar__header", o = "haze
13
13
  "Fr",
14
14
  "Sa"
15
15
  ];
16
- function m(e, t) {
16
+ function g(e, t) {
17
17
  return new Date(e, t + 1, 0).getDate();
18
18
  }
19
- function h(e, t, n) {
19
+ function _(e, t, n) {
20
20
  return `${e}-${String(t + 1).padStart(2, "0")}-${String(n).padStart(2, "0")}`;
21
21
  }
22
- function g({ value: g, min: _, max: v, onSelect: y }) {
23
- let b = g ? new Date(g) : /* @__PURE__ */ new Date(), [x, S] = r(b.getFullYear()), [C, w] = r(b.getMonth()), T = m(x, C), E = new Date(x, C, 1).getDay(), D = m(x, C - 1), O = () => {
24
- w((e) => e === 0 ? (S((e) => e - 1), 11) : e - 1);
25
- }, k = () => {
26
- w((e) => e === 11 ? (S((e) => e + 1), 0) : e + 1);
27
- }, A = (e) => !!(_ && e < _ || v && e > v), j = [];
28
- for (let e = E - 1; e >= 0; e--) {
29
- let t = C === 0 ? 11 : C - 1, n = C === 0 ? x - 1 : x;
30
- j.push({
31
- day: D - e,
22
+ function v({ value: v, min: y, max: b, onSelect: x }) {
23
+ let S = v ? new Date(v) : /* @__PURE__ */ new Date(), [C, w] = r(S.getFullYear()), [T, E] = r(S.getMonth()), D = g(C, T), O = new Date(C, T, 1).getDay(), k = g(C, T - 1), A = () => {
24
+ E((e) => e === 0 ? (w((e) => e - 1), 11) : e - 1);
25
+ }, j = () => {
26
+ E((e) => e === 11 ? (w((e) => e + 1), 0) : e + 1);
27
+ }, M = (e) => !!(y && e < y || b && e > b), N = [];
28
+ for (let e = O - 1; e >= 0; e--) {
29
+ let t = T === 0 ? 11 : T - 1, n = T === 0 ? C - 1 : C;
30
+ N.push({
31
+ day: k - e,
32
32
  month: t,
33
33
  year: n,
34
34
  outside: !0
35
35
  });
36
36
  }
37
- for (let e = 1; e <= T; e++) j.push({
37
+ for (let e = 1; e <= D; e++) N.push({
38
38
  day: e,
39
- month: C,
40
- year: x,
39
+ month: T,
40
+ year: C,
41
41
  outside: !1
42
42
  });
43
- let M = 7 - j.length % 7;
44
- if (M < 7) for (let e = 1; e <= M; e++) {
45
- let t = C === 11 ? 0 : C + 1, n = C === 11 ? x + 1 : x;
46
- j.push({
43
+ let P = 7 - N.length % 7;
44
+ if (P < 7) for (let e = 1; e <= P; e++) {
45
+ let t = T === 11 ? 0 : T + 1, n = T === 11 ? C + 1 : C;
46
+ N.push({
47
47
  day: e,
48
48
  month: t,
49
49
  year: n,
50
50
  outside: !0
51
51
  });
52
52
  }
53
- let N = new Date(x, C).toLocaleString("default", {
53
+ let F = new Date(C, T).toLocaleString("default", {
54
54
  month: "long",
55
55
  year: "numeric"
56
- });
56
+ }), I = [];
57
+ for (let e = 0; e < N.length; e += 7) I.push(N.slice(e, e + 7));
57
58
  return /* @__PURE__ */ n("div", {
58
- role: "grid",
59
- "aria-label": N,
60
59
  className: e([i]),
61
60
  children: [/* @__PURE__ */ n("div", {
62
61
  className: e([a]),
63
62
  children: [
64
63
  /* @__PURE__ */ t("button", {
65
64
  type: "button",
66
- onClick: O,
65
+ onClick: A,
67
66
  "aria-label": "Previous month",
68
67
  className: e([o]),
69
68
  children: "‹"
70
69
  }),
71
70
  /* @__PURE__ */ t("span", {
72
71
  className: e([s]),
73
- children: N
72
+ children: F
74
73
  }),
75
74
  /* @__PURE__ */ t("button", {
76
75
  type: "button",
77
- onClick: k,
76
+ onClick: j,
78
77
  "aria-label": "Next month",
79
78
  className: e([o]),
80
79
  children: "›"
81
80
  })
82
81
  ]
83
82
  }), /* @__PURE__ */ n("div", {
83
+ role: "grid",
84
+ "aria-label": F,
84
85
  className: e([c]),
85
- children: [p.map((n) => /* @__PURE__ */ t("span", {
86
+ children: [/* @__PURE__ */ t("div", {
87
+ role: "row",
86
88
  className: e([l]),
87
- children: n
88
- }, n)), j.map((n, r) => {
89
- let i = h(n.year, n.month, n.day);
90
- return /* @__PURE__ */ t("button", {
91
- type: "button",
92
- disabled: A(i),
93
- onClick: () => y(i),
94
- className: e([
95
- u,
96
- i === g && d,
97
- n.outside && f
98
- ]),
99
- children: n.day
100
- }, r);
101
- })]
89
+ children: h.map((n) => /* @__PURE__ */ t("span", {
90
+ role: "columnheader",
91
+ className: e([d]),
92
+ children: n
93
+ }, n))
94
+ }), I.map((n, r) => /* @__PURE__ */ t("div", {
95
+ role: "row",
96
+ className: e([l]),
97
+ children: n.map((n) => {
98
+ let r = _(n.year, n.month, n.day);
99
+ return /* @__PURE__ */ t("span", {
100
+ role: "gridcell",
101
+ className: e([u]),
102
+ children: /* @__PURE__ */ t("button", {
103
+ type: "button",
104
+ disabled: M(r),
105
+ onClick: () => x(r),
106
+ className: e([
107
+ f,
108
+ r === v && p,
109
+ n.outside && m
110
+ ]),
111
+ children: n.day
112
+ })
113
+ }, r);
114
+ })
115
+ }, r))]
102
116
  })]
103
117
  });
104
118
  }
105
119
  //#endregion
106
- export { g as default };
120
+ export { v as default };