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.
- package/README.md +63 -0
- package/dist/components/ColorPicker/ColorPickerCore.js +2 -0
- package/dist/components/Combobox/Combobox.js +45 -34
- package/dist/components/Command/Command.js +72 -37
- package/dist/components/ContextMenu/ContextMenu.js +19 -17
- package/dist/components/ContextMenu/ContextMenuContent.js +24 -12
- package/dist/components/ContextMenu/ContextMenuItem.js +2 -0
- package/dist/components/DateRangePicker/DateRangePickerCore.js +2 -0
- package/dist/components/Datepicker/Calendar.js +58 -44
- package/dist/components/Datepicker/DatepickerCore.js +37 -29
- package/dist/components/DropdownMenu/DropdownMenu.js +20 -20
- package/dist/components/DropdownMenu/DropdownMenuContent.js +38 -45
- package/dist/components/DropdownMenu/DropdownMenuTrigger.js +9 -7
- package/dist/components/InlineEdit/InlineEdit.js +1 -0
- package/dist/components/Menu/Menu.js +38 -26
- package/dist/components/Menu/MenuItem.js +1 -0
- package/dist/components/ModelPicker/ModelPicker.js +1 -0
- package/dist/components/OTPInput/OTPInputCore.js +1 -0
- package/dist/components/PasswordInput/PasswordInputCore.js +1 -0
- package/dist/components/Popover/Popover.js +32 -75
- package/dist/components/Progress/Progress.js +2 -0
- package/dist/components/Tooltip/Tooltip.js +50 -24
- package/dist/components/Tree/TreeItem.js +44 -41
- package/dist/components/Upload/Upload.js +1 -0
- package/dist/css/combobox.css +2 -1
- package/dist/css/command.css +1 -1
- package/dist/css/context-menu.css +1 -0
- package/dist/css/datepicker.css +3 -2
- package/dist/css/dropdown-menu.css +2 -1
- package/dist/css/menu.css +2 -1
- package/dist/css/popover.css +2 -1
- package/dist/css/tooltip.css +2 -1
- package/dist/form/FormItem.js +23 -15
- package/dist/haze-ui.css +15 -8
- package/dist/types/components/ContextMenu/ContextMenuContent.d.ts +1 -1
- package/dist/types/components/ContextMenu/ContextMenuContext.d.ts +5 -1
- package/dist/types/components/DropdownMenu/DropdownMenuContent.d.ts +1 -1
- package/dist/types/components/DropdownMenu/DropdownMenuContext.d.ts +3 -0
- package/dist/types/components/DropdownMenu/DropdownMenuTrigger.d.ts +1 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts +5 -1
- package/dist/types/form/FormItem.d.ts +63 -7
- package/dist/types/form/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/floating.d.ts +99 -0
- package/dist/types/utils/menuKeyboard.d.ts +43 -0
- package/dist/utils/floating.js +181 -0
- package/dist/utils/menuKeyboard.js +88 -0
- package/package.json +34 -8
- package/dist/components/DropdownMenu/useMenuKeyboard.js +0 -52
- package/dist/types/components/DropdownMenu/useMenuKeyboard.d.ts +0 -19
- package/dist/types/hooks/index.d.ts +0 -1
- 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 "
|
|
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
|
|
6
|
-
import { useControl as
|
|
7
|
-
import { useEffect as
|
|
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
|
|
10
|
-
function
|
|
11
|
-
let [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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__ */
|
|
21
|
-
className: e([
|
|
22
|
-
children: [/* @__PURE__ */
|
|
23
|
-
ref:
|
|
26
|
+
return /* @__PURE__ */ a("div", {
|
|
27
|
+
className: e([d, v]),
|
|
28
|
+
children: [/* @__PURE__ */ i("input", {
|
|
29
|
+
ref: O,
|
|
24
30
|
role: "combobox",
|
|
25
|
-
|
|
26
|
-
"aria-
|
|
31
|
+
style: A.triggerStyle,
|
|
32
|
+
"aria-expanded": C,
|
|
33
|
+
"aria-controls": D,
|
|
27
34
|
"aria-autocomplete": "list",
|
|
28
|
-
className:
|
|
29
|
-
value:
|
|
30
|
-
placeholder:
|
|
35
|
+
className: f,
|
|
36
|
+
value: x,
|
|
37
|
+
placeholder: _,
|
|
31
38
|
onChange: (e) => {
|
|
32
|
-
|
|
39
|
+
S(e.target.value), w(!0);
|
|
33
40
|
},
|
|
34
|
-
onFocus: () =>
|
|
41
|
+
onFocus: () => w(!0),
|
|
42
|
+
onClick: () => w(!0),
|
|
35
43
|
onKeyDown: (e) => {
|
|
36
|
-
e.key === "ArrowDown" ? (e.preventDefault(),
|
|
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__ */
|
|
39
|
-
|
|
46
|
+
}), /* @__PURE__ */ i(t, {
|
|
47
|
+
ref: k,
|
|
48
|
+
behavior: A,
|
|
49
|
+
placement: "bottom-span",
|
|
50
|
+
id: D,
|
|
40
51
|
role: "listbox",
|
|
41
|
-
|
|
42
|
-
children:
|
|
52
|
+
visualClass: p,
|
|
53
|
+
children: j.map((e, t) => /* @__PURE__ */ i(r, {
|
|
43
54
|
value: e.value,
|
|
44
|
-
highlighted:
|
|
45
|
-
selected: e.value ===
|
|
46
|
-
onSelect:
|
|
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 {
|
|
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
|
|
5
|
-
import { useControl as
|
|
6
|
-
import { createContext as
|
|
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
|
|
9
|
-
function
|
|
10
|
-
let e =
|
|
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
|
|
15
|
-
function
|
|
16
|
-
let [
|
|
17
|
-
query:
|
|
18
|
-
setQuery:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
25
|
-
|
|
32
|
+
"aria-expanded": !0,
|
|
33
|
+
"aria-controls": h,
|
|
34
|
+
className: e([m, r]),
|
|
35
|
+
children: n
|
|
26
36
|
})
|
|
27
37
|
});
|
|
28
38
|
}
|
|
29
|
-
var
|
|
30
|
-
function
|
|
31
|
-
let { query:
|
|
32
|
-
return /* @__PURE__ */
|
|
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:
|
|
36
|
-
onChange: (e) =>
|
|
37
|
-
|
|
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
|
|
41
|
-
function
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
73
|
+
id: c,
|
|
74
|
+
onKeyDown: l,
|
|
75
|
+
className: e([v, a]),
|
|
76
|
+
children: t
|
|
46
77
|
});
|
|
47
78
|
}
|
|
48
|
-
var
|
|
49
|
-
function
|
|
50
|
-
let { query: a } =
|
|
51
|
-
return !a || (typeof
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 {
|
|
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 {
|
|
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
|
|
6
|
-
import { useControl as
|
|
7
|
-
import { useCallback as
|
|
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] =
|
|
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
|
-
]),
|
|
19
|
+
]), S = a((e, t) => {
|
|
19
20
|
g(e), v(t);
|
|
20
|
-
}, [])
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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:
|
|
30
|
+
setOpen: x,
|
|
31
31
|
x: h,
|
|
32
32
|
y: _,
|
|
33
|
-
setPosition:
|
|
33
|
+
setPosition: S,
|
|
34
|
+
contentRef: b,
|
|
35
|
+
floating: C
|
|
34
36
|
},
|
|
35
|
-
children:
|
|
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 {
|
|
3
|
-
import {
|
|
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
|
|
6
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
6
7
|
//#region src/lib/components/ContextMenu/ContextMenuContent.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
let { open:
|
|
10
|
-
|
|
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:
|
|
13
|
-
top:
|
|
24
|
+
left: u,
|
|
25
|
+
top: d
|
|
14
26
|
},
|
|
15
|
-
|
|
16
|
-
children:
|
|
27
|
+
onKeyDown: m,
|
|
28
|
+
children: o
|
|
17
29
|
}) : null;
|
|
18
30
|
}
|
|
19
31
|
//#endregion
|
|
20
|
-
export {
|
|
32
|
+
export { o as default };
|
|
@@ -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-
|
|
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
|
|
16
|
+
function g(e, t) {
|
|
17
17
|
return new Date(e, t + 1, 0).getDate();
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function _(e, t, n) {
|
|
20
20
|
return `${e}-${String(t + 1).padStart(2, "0")}-${String(n).padStart(2, "0")}`;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
for (let e =
|
|
29
|
-
let t =
|
|
30
|
-
|
|
31
|
-
day:
|
|
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 <=
|
|
37
|
+
for (let e = 1; e <= D; e++) N.push({
|
|
38
38
|
day: e,
|
|
39
|
-
month:
|
|
40
|
-
year:
|
|
39
|
+
month: T,
|
|
40
|
+
year: C,
|
|
41
41
|
outside: !1
|
|
42
42
|
});
|
|
43
|
-
let
|
|
44
|
-
if (
|
|
45
|
-
let t =
|
|
46
|
-
|
|
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
|
|
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:
|
|
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:
|
|
72
|
+
children: F
|
|
74
73
|
}),
|
|
75
74
|
/* @__PURE__ */ t("button", {
|
|
76
75
|
type: "button",
|
|
77
|
-
onClick:
|
|
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: [
|
|
86
|
+
children: [/* @__PURE__ */ t("div", {
|
|
87
|
+
role: "row",
|
|
86
88
|
className: e([l]),
|
|
87
|
-
children: n
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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 {
|
|
120
|
+
export { v as default };
|