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
@@ -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
  },
@@ -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,33 @@
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
+ "aria-label": "Start date",
14
+ value: o,
15
+ onChange: (e) => c(e.target.value),
16
+ className: e([i])
17
+ }),
18
+ /* @__PURE__ */ t("span", {
19
+ className: e([a]),
20
+ children: u
21
+ }),
22
+ /* @__PURE__ */ t("input", {
23
+ type: "date",
24
+ "aria-label": "End date",
25
+ value: s,
26
+ onChange: (e) => l(e.target.value),
27
+ className: e([i])
28
+ })
29
+ ]
30
+ });
31
+ }
32
+ //#endregion
33
+ export { o as default };
@@ -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 };
@@ -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,50 @@
1
+
2
+ import { classnames as e } from "../../utils/classnames.js";
3
+ import { FloatingPanel as t, useFloating as n } from "../../utils/floating.js";
4
+ import r from "./Calendar.js";
5
+ /* empty css */
6
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
7
+ import { useCallback as o, useId as s, useRef as c } from "react";
8
+ //#region src/lib/components/Datepicker/DatepickerCore.tsx
9
+ var l = "haze-DatepickerCore__wrapper", u = "haze-DatepickerCore__input", d = "haze-DatepickerCore__dropdown";
10
+ function f({ value: f, onChange: p, open: m, onOpenChange: h, min: g, max: _, placeholder: v = "Select date", className: y }) {
11
+ let b = c(null), x = c(null), S = s(), C = o((e) => h(typeof e == "function" ? e(m) : e), [h, m]), w = n({
12
+ open: m,
13
+ setOpen: C,
14
+ triggerRef: b,
15
+ panelRef: x
16
+ });
17
+ return /* @__PURE__ */ a("div", {
18
+ className: e([l, y]),
19
+ children: [/* @__PURE__ */ i("input", {
20
+ ref: b,
21
+ readOnly: !0,
22
+ style: w.triggerStyle,
23
+ className: u,
24
+ value: f,
25
+ placeholder: v,
26
+ role: "combobox",
27
+ "aria-haspopup": "dialog",
28
+ "aria-expanded": m,
29
+ "aria-controls": S,
30
+ onPointerDown: w.onTriggerPointerDown,
31
+ onClick: w.onTriggerClick
32
+ }), /* @__PURE__ */ i(t, {
33
+ ref: x,
34
+ behavior: w,
35
+ placement: "bottom",
36
+ visualClass: d,
37
+ id: S,
38
+ children: /* @__PURE__ */ i(r, {
39
+ value: f,
40
+ min: g,
41
+ max: _,
42
+ onSelect: (e) => {
43
+ p(e), h(!1);
44
+ }
45
+ })
46
+ })]
47
+ });
48
+ }
49
+ //#endregion
50
+ export { f as default };
@@ -1,38 +1,38 @@
1
1
 
2
2
  import { classnames as e } from "../../utils/classnames.js";
3
- import { DropdownMenuProvider as t } from "./DropdownMenuContext.js";
3
+ import { useFloating as t } from "../../utils/floating.js";
4
+ import { DropdownMenuProvider as n } from "./DropdownMenuContext.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, useId as o, useRef 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, useId as o, useRef as s } from "react";
8
9
  //#region src/lib/components/DropdownMenu/DropdownMenu.tsx
9
10
  var c = "haze-DropdownMenu__wrapper";
10
11
  function l({ open: l, onOpenChange: u, children: d, className: f }) {
11
- let [p, m] = r(l, !1), h = s(null), g = s(null), _ = s(null), v = o(), y = s(null), b = i((e) => {
12
+ let [p, m] = i(l, !1), h = s(null), g = s(null), _ = o(), v = s(null), y = 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
- ]);
19
- return a(() => {
20
- if (!p) return;
21
- let e = (e) => {
22
- h.current && !h.current.contains(e.target) && b(!1);
23
- };
24
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
25
- }, [p, b]), /* @__PURE__ */ n(t, {
19
+ ]), b = t({
20
+ open: p,
21
+ setOpen: y,
22
+ triggerRef: h,
23
+ panelRef: g
24
+ });
25
+ return /* @__PURE__ */ r(n, {
26
26
  value: {
27
27
  open: p,
28
- setOpen: b,
29
- triggerRef: g,
30
- contentRef: _,
31
- contentId: v,
32
- focusRequestRef: y
28
+ setOpen: y,
29
+ triggerRef: h,
30
+ contentRef: g,
31
+ contentId: _,
32
+ focusRequestRef: v,
33
+ floating: b
33
34
  },
34
- children: n("div", {
35
- ref: h,
35
+ children: r("div", {
36
36
  className: e([c, f]),
37
37
  children: d
38
38
  })
@@ -1,55 +1,48 @@
1
1
 
2
- import { classnames as e } from "../../utils/classnames.js";
3
- import { useDropdownMenuContext as t } from "./DropdownMenuContext.js";
4
- import { getEnabledMenuItems as n, useMenuKeyboard as r } from "./useMenuKeyboard.js";
2
+ import { FloatingPanel as e } from "../../utils/floating.js";
3
+ import { getEnabledMenuItems as t, useMenuKeyboard as n, useRovingTabindex as r } from "../../utils/menuKeyboard.js";
4
+ import { useDropdownMenuContext as i } from "./DropdownMenuContext.js";
5
5
  /* empty css */
6
- import { jsx as i } from "react/jsx-runtime";
7
- import { useCallback as a, useEffect as o } from "react";
6
+ import { jsx as a } from "react/jsx-runtime";
7
+ import { useCallback as o, useEffect as s } from "react";
8
8
  //#region src/lib/components/DropdownMenu/DropdownMenuContent.tsx
9
- var s = "haze-DropdownMenuContent__content", c = {
10
- start: "haze-DropdownMenuContent__alignStart",
11
- center: "haze-DropdownMenuContent__alignCenter",
12
- end: "haze-DropdownMenuContent__alignEnd"
9
+ var c = "haze-DropdownMenuContent__content", l = {
10
+ start: "bottom",
11
+ center: "bottom-center",
12
+ end: "bottom-end"
13
13
  };
14
- function l({ children: l, align: u = "start", className: d }) {
15
- let { open: f, setOpen: p, triggerRef: m, contentRef: h, contentId: g, focusRequestRef: _ } = t(), v = a(() => {
16
- p(!1), m.current?.focus();
17
- }, [p, m]), y = r({
18
- menuRef: h,
19
- onClose: v
14
+ function u({ children: u, align: d = "start", className: f }) {
15
+ let { open: p, setOpen: m, triggerRef: h, contentRef: g, contentId: _, focusRequestRef: v, floating: y } = i(), b = o(() => {
16
+ m(!1), h.current?.focus();
17
+ }, [m, h]), x = n({
18
+ menuRef: g,
19
+ onClose: b
20
20
  });
21
- return o(() => {
22
- if (!f) return;
23
- let e = h.current;
24
- if (!e) return;
25
- let t = n(e);
26
- t.forEach((e) => {
27
- e.tabIndex = -1;
28
- }), t[0] && (t[0].tabIndex = 0);
29
- let r = _.current;
30
- _.current = null, r && (r === "first" ? t[0] : t[t.length - 1])?.focus();
31
- let i = (t) => {
32
- n(e).forEach((e) => {
33
- e.tabIndex = e === t.target ? 0 : -1;
34
- });
35
- };
36
- return e.addEventListener("focusin", i), () => e.removeEventListener("focusin", i);
21
+ return r({
22
+ menuRef: g,
23
+ active: p
24
+ }), s(() => {
25
+ if (!p || !y.shown) return;
26
+ let e = v.current;
27
+ if (v.current = null, !e) return;
28
+ let n = t(g.current);
29
+ (e === "first" ? n[0] : n[n.length - 1])?.focus();
37
30
  }, [
38
- f,
39
- h,
40
- _
41
- ]), f ? /* @__PURE__ */ i("div", {
42
- ref: h,
43
- id: g,
31
+ p,
32
+ y.shown,
33
+ g,
34
+ v
35
+ ]), p ? /* @__PURE__ */ a(e, {
36
+ ref: g,
37
+ behavior: y,
38
+ placement: l[d],
39
+ id: _,
44
40
  role: "menu",
45
- onKeyDown: y,
46
- className: e([
47
- s,
48
- c[u],
49
- d
50
- ]),
51
- children: l
41
+ visualClass: c,
42
+ className: f,
43
+ onKeyDown: x,
44
+ children: u
52
45
  }) : null;
53
46
  }
54
47
  //#endregion
55
- export { l as default };
48
+ export { u as default };
@@ -1,16 +1,16 @@
1
1
 
2
2
  import { classnames as e } from "../../utils/classnames.js";
3
- import { useDropdownMenuContext as t } from "./DropdownMenuContext.js";
4
- import { getEnabledMenuItems as n } from "./useMenuKeyboard.js";
3
+ import { getEnabledMenuItems as t } from "../../utils/menuKeyboard.js";
4
+ import { useDropdownMenuContext as n } from "./DropdownMenuContext.js";
5
5
  /* empty css */
6
6
  import { jsx as r } from "react/jsx-runtime";
7
7
  //#region src/lib/components/DropdownMenu/DropdownMenuTrigger.tsx
8
8
  var i = "haze-DropdownMenuTrigger__trigger";
9
9
  function a({ children: a, className: o }) {
10
- let { open: s, setOpen: c, triggerRef: l, contentRef: u, contentId: d, focusRequestRef: f } = t(), p = (e) => {
10
+ let { open: s, setOpen: c, triggerRef: l, contentRef: u, contentId: d, focusRequestRef: f, floating: p } = n(), m = (e) => {
11
11
  if (s) {
12
- let t = n(u.current);
13
- (e === "first" ? t[0] : t[t.length - 1])?.focus();
12
+ let n = t(u.current);
13
+ (e === "first" ? n[0] : n[n.length - 1])?.focus();
14
14
  } else f.current = e, c(!0);
15
15
  };
16
16
  return /* @__PURE__ */ r("button", {
@@ -19,9 +19,11 @@ function a({ children: a, className: o }) {
19
19
  "aria-haspopup": "menu",
20
20
  "aria-expanded": s,
21
21
  "aria-controls": s ? d : void 0,
22
- onClick: () => c((e) => !e),
22
+ style: p.triggerStyle,
23
+ onPointerDown: p.onTriggerPointerDown,
24
+ onClick: p.onTriggerClick,
23
25
  onKeyDown: (e) => {
24
- e.key === "ArrowDown" ? (e.preventDefault(), p("first")) : e.key === "ArrowUp" && (e.preventDefault(), p("last"));
26
+ e.key === "ArrowDown" ? (e.preventDefault(), m("first")) : e.key === "ArrowUp" && (e.preventDefault(), m("last"));
25
27
  },
26
28
  className: e([i, o]),
27
29
  children: a
@@ -20,6 +20,7 @@ function l({ value: l, onChange: u, placeholder: d = "Click to edit", disabled:
20
20
  };
21
21
  return g ? /* @__PURE__ */ t("input", {
22
22
  ref: b,
23
+ "aria-label": d,
23
24
  value: v,
24
25
  onChange: (e) => y(e.target.value),
25
26
  onBlur: S,