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.
- package/README.md +99 -31
- package/dist/components/Checkbox/Checkbox.js +13 -20
- package/dist/components/Checkbox/CheckboxCore.js +23 -0
- package/dist/components/ColorPicker/ColorPicker.js +13 -42
- package/dist/components/ColorPicker/ColorPickerCore.js +38 -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/DateRangePicker.js +17 -35
- package/dist/components/DateRangePicker/DateRangePickerCore.js +33 -0
- package/dist/components/Datepicker/Calendar.js +58 -44
- package/dist/components/Datepicker/Datepicker.js +15 -39
- package/dist/components/Datepicker/DatepickerCore.js +50 -0
- 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/Input/Input.js +11 -22
- package/dist/components/Input/InputCore.js +26 -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/NumberInput/NumberInput.js +16 -53
- package/dist/components/NumberInput/NumberInputCore.js +56 -0
- package/dist/components/OTPInput/OTPInput.js +11 -45
- package/dist/components/OTPInput/OTPInputCore.js +44 -0
- package/dist/components/PasswordInput/PasswordInput.js +14 -29
- package/dist/components/PasswordInput/PasswordInputCore.js +31 -0
- package/dist/components/Popover/Popover.js +32 -75
- package/dist/components/Progress/Progress.js +2 -0
- package/dist/components/Radio/RadioGroup.js +12 -21
- package/dist/components/Radio/RadioGroupCore.js +24 -0
- package/dist/components/Rating/Rating.js +14 -46
- package/dist/components/Rating/RatingCore.js +48 -0
- package/dist/components/Segmented/Segmented.js +12 -37
- package/dist/components/Segmented/SegmentedCore.js +39 -0
- package/dist/components/Select/Select.js +12 -23
- package/dist/components/Select/SelectCore.js +27 -0
- package/dist/components/Slider/Slider.js +10 -15
- package/dist/components/Slider/SliderCore.js +19 -0
- package/dist/components/Switch/Switch.js +11 -38
- package/dist/components/Switch/SwitchCore.js +42 -0
- package/dist/components/TagInput/TagInput.js +18 -72
- package/dist/components/TagInput/TagInputCore.js +68 -0
- package/dist/components/Textarea/Textarea.js +11 -22
- package/dist/components/Textarea/TextareaCore.js +26 -0
- package/dist/components/TimePicker/TimePicker.js +10 -15
- package/dist/components/TimePicker/TimePickerCore.js +18 -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/checkbox.css +1 -1
- package/dist/css/color-picker.css +1 -1
- 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/date-range-picker.css +1 -1
- package/dist/css/datepicker.css +3 -2
- package/dist/css/dropdown-menu.css +2 -1
- package/dist/css/input.css +1 -1
- package/dist/css/menu.css +2 -1
- package/dist/css/number-input.css +1 -1
- package/dist/css/otp-input.css +1 -1
- package/dist/css/password-input.css +1 -1
- package/dist/css/popover.css +2 -1
- package/dist/css/radio.css +1 -1
- package/dist/css/rating.css +1 -1
- package/dist/css/segmented.css +1 -1
- package/dist/css/select.css +1 -1
- package/dist/css/slider.css +1 -1
- package/dist/css/switch.css +1 -1
- package/dist/css/tag-input.css +1 -1
- package/dist/css/textarea.css +1 -1
- package/dist/css/time-picker.css +1 -1
- package/dist/css/tooltip.css +2 -1
- package/dist/form/FormItem.js +41 -33
- package/dist/haze-ui.css +31 -24
- package/dist/index.js +138 -122
- package/dist/types/components/Checkbox/CheckboxCore.d.ts +12 -0
- package/dist/types/components/Checkbox/index.d.ts +2 -0
- package/dist/types/components/ColorPicker/ColorPickerCore.d.ts +8 -0
- package/dist/types/components/ColorPicker/index.d.ts +2 -0
- package/dist/types/components/ContextMenu/ContextMenuContent.d.ts +1 -1
- package/dist/types/components/ContextMenu/ContextMenuContext.d.ts +5 -1
- package/dist/types/components/DateRangePicker/DateRangePickerCore.d.ts +11 -0
- package/dist/types/components/DateRangePicker/index.d.ts +2 -0
- package/dist/types/components/Datepicker/DatepickerCore.d.ts +12 -0
- package/dist/types/components/Datepicker/index.d.ts +2 -0
- 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/Input/InputCore.d.ts +13 -0
- package/dist/types/components/Input/index.d.ts +2 -0
- package/dist/types/components/NumberInput/NumberInputCore.d.ts +15 -0
- package/dist/types/components/NumberInput/index.d.ts +2 -0
- package/dist/types/components/OTPInput/OTPInputCore.d.ts +8 -0
- package/dist/types/components/OTPInput/index.d.ts +2 -0
- package/dist/types/components/PasswordInput/PasswordInputCore.d.ts +9 -0
- package/dist/types/components/PasswordInput/index.d.ts +2 -0
- package/dist/types/components/Radio/RadioContext.d.ts +1 -2
- package/dist/types/components/Radio/RadioGroupCore.d.ts +10 -0
- package/dist/types/components/Radio/index.d.ts +2 -0
- package/dist/types/components/Rating/RatingCore.d.ts +9 -0
- package/dist/types/components/Rating/index.d.ts +2 -0
- package/dist/types/components/Segmented/Segmented.d.ts +1 -6
- package/dist/types/components/Segmented/SegmentedCore.d.ts +15 -0
- package/dist/types/components/Segmented/index.d.ts +2 -0
- package/dist/types/components/Select/SelectCore.d.ts +13 -0
- package/dist/types/components/Select/index.d.ts +2 -0
- package/dist/types/components/Slider/SliderCore.d.ts +11 -0
- package/dist/types/components/Slider/index.d.ts +2 -0
- package/dist/types/components/Switch/Switch.d.ts +1 -1
- package/dist/types/components/Switch/SwitchCore.d.ts +12 -0
- package/dist/types/components/Switch/index.d.ts +2 -0
- package/dist/types/components/TagInput/TagInputCore.d.ts +20 -0
- package/dist/types/components/TagInput/index.d.ts +2 -0
- package/dist/types/components/Textarea/TextareaCore.d.ts +12 -0
- package/dist/types/components/Textarea/index.d.ts +2 -0
- package/dist/types/components/TimePicker/TimePickerCore.d.ts +9 -0
- package/dist/types/components/TimePicker/index.d.ts +2 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +5 -1
- package/dist/types/form/FormItem.d.ts +86 -19
- package/dist/types/form/index.d.ts +2 -3
- package/dist/types/index.d.ts +36 -36
- 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 +45 -19
- package/dist/components/DropdownMenu/useMenuKeyboard.js +0 -52
- package/dist/form/useFormControl.js +0 -54
- package/dist/types/components/DropdownMenu/useMenuKeyboard.d.ts +0 -19
- package/dist/types/form/useFormControl.d.ts +0 -35
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/utils/index.d.ts +0 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
|
|
2
|
+
import { classnames as e } from "./classnames.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
5
|
+
import { useCallback as n, useEffect as r, useId as i, useRef as a, useState as o } from "react";
|
|
6
|
+
//#region src/lib/utils/floating.tsx
|
|
7
|
+
var s = 500;
|
|
8
|
+
function c() {
|
|
9
|
+
return typeof HTMLElement < "u" && "popover" in HTMLElement.prototype;
|
|
10
|
+
}
|
|
11
|
+
function l() {
|
|
12
|
+
return c() && typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("anchor-name: --haze-floating-probe");
|
|
13
|
+
}
|
|
14
|
+
var u = "haze-floating__floatingNative", d = "haze-floating__floatingAnchored", f = "haze-floating__floatingFixed", p = "haze-floating__floatingHidden", m = "haze-floating__anchoredBottom", h = "haze-floating__anchoredBottomSpan", g = "haze-floating__anchoredBottomCenter", _ = "haze-floating__anchoredBottomEnd", v = "haze-floating__anchoredTop", y = "haze-floating__anchoredLeft", b = "haze-floating__anchoredRight", x = "haze-floating__fallbackBottom", S = x, C = "haze-floating__fallbackBottomCenter", w = "haze-floating__fallbackBottomEnd", T = "haze-floating__fallbackTop", E = "haze-floating__fallbackLeft", D = "haze-floating__fallbackRight", O = "haze-floating__gapBelow", k = "haze-floating__gapAbove", A = "haze-floating__gapBefore", j = "haze-floating__gapAfter", M = {
|
|
15
|
+
bottom: m,
|
|
16
|
+
"bottom-span": h,
|
|
17
|
+
"bottom-center": g,
|
|
18
|
+
"bottom-end": _,
|
|
19
|
+
top: v,
|
|
20
|
+
left: y,
|
|
21
|
+
right: b
|
|
22
|
+
}, N = {
|
|
23
|
+
bottom: x,
|
|
24
|
+
"bottom-span": S,
|
|
25
|
+
"bottom-center": C,
|
|
26
|
+
"bottom-end": w,
|
|
27
|
+
top: T,
|
|
28
|
+
left: E,
|
|
29
|
+
right: D
|
|
30
|
+
}, P = {
|
|
31
|
+
bottom: O,
|
|
32
|
+
"bottom-span": O,
|
|
33
|
+
"bottom-center": O,
|
|
34
|
+
"bottom-end": O,
|
|
35
|
+
top: k,
|
|
36
|
+
left: A,
|
|
37
|
+
right: j
|
|
38
|
+
};
|
|
39
|
+
function F({ open: e, setOpen: t, triggerRef: m, panelRef: h }) {
|
|
40
|
+
let g = `--haze-floating-${i().replace(/[^a-zA-Z0-9]/g, "")}`, _ = c(), v = l(), y = a(!1), [b, x] = o(!1), S = a(null), C = a(-Infinity), w = a(-Infinity);
|
|
41
|
+
r(() => {
|
|
42
|
+
let n = h.current;
|
|
43
|
+
if (!n || !_) return;
|
|
44
|
+
n !== S.current && (S.current = n, y.current = !1, x(!1));
|
|
45
|
+
let r = (n) => {
|
|
46
|
+
let r = n.newState;
|
|
47
|
+
y.current = r === "open", x(y.current), r === "closed" && e ? (performance.now() - C.current < s && (w.current = performance.now()), C.current = -Infinity, t(!1)) : r === "open" && !e && t(!0);
|
|
48
|
+
};
|
|
49
|
+
return n.addEventListener("toggle", r), e && !y.current ? n.showPopover() : !e && y.current && n.hidePopover(), () => n.removeEventListener("toggle", r);
|
|
50
|
+
}, [
|
|
51
|
+
_,
|
|
52
|
+
e,
|
|
53
|
+
t,
|
|
54
|
+
h
|
|
55
|
+
]), r(() => {
|
|
56
|
+
if (_ || !e) return;
|
|
57
|
+
let n = (e) => e instanceof Node && !!(m.current?.contains(e) || h.current?.contains(e)), r = (e) => {
|
|
58
|
+
n(e.target) || t(!1);
|
|
59
|
+
}, i = (e) => {
|
|
60
|
+
e.key === "Escape" && t(!1);
|
|
61
|
+
};
|
|
62
|
+
return document.addEventListener("pointerdown", r), document.addEventListener("keydown", i), () => {
|
|
63
|
+
document.removeEventListener("pointerdown", r), document.removeEventListener("keydown", i);
|
|
64
|
+
};
|
|
65
|
+
}, [
|
|
66
|
+
_,
|
|
67
|
+
e,
|
|
68
|
+
t,
|
|
69
|
+
m,
|
|
70
|
+
h
|
|
71
|
+
]);
|
|
72
|
+
let T = n(() => {
|
|
73
|
+
e && (C.current = performance.now());
|
|
74
|
+
}, [e]), E = n(() => {
|
|
75
|
+
if (performance.now() - w.current < s) {
|
|
76
|
+
w.current = -Infinity;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
t((e) => !e);
|
|
80
|
+
}, [t]);
|
|
81
|
+
return {
|
|
82
|
+
open: e,
|
|
83
|
+
native: _,
|
|
84
|
+
anchored: v,
|
|
85
|
+
shown: _ ? b : e,
|
|
86
|
+
anchorName: g,
|
|
87
|
+
triggerStyle: v ? { anchorName: g } : void 0,
|
|
88
|
+
onTriggerPointerDown: T,
|
|
89
|
+
onTriggerClick: E,
|
|
90
|
+
panelAttrs: {
|
|
91
|
+
popover: _ ? "auto" : void 0,
|
|
92
|
+
style: v ? { "--haze-floating-anchor": g } : void 0
|
|
93
|
+
},
|
|
94
|
+
panelClasses: [
|
|
95
|
+
_ && u,
|
|
96
|
+
_ && v && d,
|
|
97
|
+
_ && !v && f,
|
|
98
|
+
!_ && !e && p
|
|
99
|
+
],
|
|
100
|
+
triggerRef: m,
|
|
101
|
+
panelRef: h
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function I(e, t) {
|
|
105
|
+
return t === "point" ? [] : [
|
|
106
|
+
e.native && e.anchored && M[t],
|
|
107
|
+
e.native && !e.anchored && P[t],
|
|
108
|
+
!e.native && N[t]
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
function L(e, t) {
|
|
112
|
+
return parseFloat(getComputedStyle(e)[t]) || 0;
|
|
113
|
+
}
|
|
114
|
+
function R(e, t, n) {
|
|
115
|
+
if (n === "point") return;
|
|
116
|
+
let r = t.getBoundingClientRect(), i = e.getBoundingClientRect(), a = r.left + r.width / 2 - i.width / 2, o = r.top + r.height / 2 - i.height / 2;
|
|
117
|
+
switch (n) {
|
|
118
|
+
case "bottom":
|
|
119
|
+
case "bottom-span":
|
|
120
|
+
e.style.top = `${r.bottom + L(e, "marginTop")}px`, e.style.left = `${r.left}px`;
|
|
121
|
+
return;
|
|
122
|
+
case "bottom-center":
|
|
123
|
+
e.style.top = `${r.bottom + L(e, "marginTop")}px`, e.style.left = `${a}px`;
|
|
124
|
+
return;
|
|
125
|
+
case "bottom-end":
|
|
126
|
+
e.style.top = `${r.bottom + L(e, "marginTop")}px`, e.style.left = `${r.right - i.width}px`;
|
|
127
|
+
return;
|
|
128
|
+
case "top":
|
|
129
|
+
e.style.top = `${r.top - i.height - L(e, "marginBottom")}px`, e.style.left = `${a}px`;
|
|
130
|
+
return;
|
|
131
|
+
case "left":
|
|
132
|
+
e.style.top = `${o}px`, e.style.left = `${r.left - i.width - L(e, "marginRight")}px`;
|
|
133
|
+
return;
|
|
134
|
+
case "right":
|
|
135
|
+
e.style.top = `${o}px`, e.style.left = `${r.right + L(e, "marginLeft")}px`;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function z({ behavior: e, placement: t }) {
|
|
140
|
+
let { native: n, anchored: i, open: a, triggerRef: o, panelRef: s } = e;
|
|
141
|
+
r(() => {
|
|
142
|
+
if (!n || i || t === "point" || !a) return;
|
|
143
|
+
let e = s.current, r = o.current;
|
|
144
|
+
if (!e || !r) return;
|
|
145
|
+
let c = () => R(e, r, t);
|
|
146
|
+
return c(), window.addEventListener("scroll", c, !0), window.addEventListener("resize", c), () => {
|
|
147
|
+
window.removeEventListener("scroll", c, !0), window.removeEventListener("resize", c);
|
|
148
|
+
};
|
|
149
|
+
}, [
|
|
150
|
+
n,
|
|
151
|
+
i,
|
|
152
|
+
a,
|
|
153
|
+
t,
|
|
154
|
+
o,
|
|
155
|
+
s
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
function B({ behavior: n, placement: r, visualClass: i, className: a, style: o, children: s, ...c }) {
|
|
159
|
+
z({
|
|
160
|
+
behavior: n,
|
|
161
|
+
placement: r ?? "point"
|
|
162
|
+
});
|
|
163
|
+
let l = n.panelAttrs.style || o ? {
|
|
164
|
+
...n.panelAttrs.style,
|
|
165
|
+
...o
|
|
166
|
+
} : void 0;
|
|
167
|
+
return /* @__PURE__ */ t("div", {
|
|
168
|
+
...c,
|
|
169
|
+
...n.panelAttrs,
|
|
170
|
+
style: l,
|
|
171
|
+
className: e([
|
|
172
|
+
i,
|
|
173
|
+
...n.panelClasses,
|
|
174
|
+
...r ? I(n, r) : [],
|
|
175
|
+
a
|
|
176
|
+
]),
|
|
177
|
+
children: s
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { B as FloatingPanel, I as floatingPlacementClasses, l as supportsAnchorPositioning, c as supportsNativePopover, F as useFloating, z as useFloatingPosition };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useRef as n } from "react";
|
|
2
|
+
//#region src/lib/utils/menuKeyboard.ts
|
|
3
|
+
var r = 500, i = "[role=\"menuitem\"]:not([disabled])";
|
|
4
|
+
function a(e, t = i) {
|
|
5
|
+
return e ? Array.from(e.querySelectorAll(t)) : [];
|
|
6
|
+
}
|
|
7
|
+
function o({ menuRef: i, onClose: o, selector: s }) {
|
|
8
|
+
let c = n(""), l = n(0);
|
|
9
|
+
return t(() => () => window.clearTimeout(l.current), []), e((e) => {
|
|
10
|
+
let t = a(i.current, s);
|
|
11
|
+
if (t.length === 0) return;
|
|
12
|
+
let n = t.indexOf(document.activeElement), u = (e) => t[e]?.focus();
|
|
13
|
+
switch (e.key) {
|
|
14
|
+
case "ArrowDown":
|
|
15
|
+
e.preventDefault(), u((n + 1) % t.length);
|
|
16
|
+
return;
|
|
17
|
+
case "ArrowUp":
|
|
18
|
+
e.preventDefault(), u((n - 1 + t.length) % t.length);
|
|
19
|
+
return;
|
|
20
|
+
case "Home":
|
|
21
|
+
e.preventDefault(), u(0);
|
|
22
|
+
return;
|
|
23
|
+
case "End":
|
|
24
|
+
e.preventDefault(), u(t.length - 1);
|
|
25
|
+
return;
|
|
26
|
+
case "Escape":
|
|
27
|
+
e.preventDefault(), o();
|
|
28
|
+
return;
|
|
29
|
+
case "Tab":
|
|
30
|
+
e.preventDefault(), o();
|
|
31
|
+
return;
|
|
32
|
+
default: {
|
|
33
|
+
if (e.key.length !== 1 || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
let i = (c.current + e.key).toLowerCase();
|
|
36
|
+
c.current = i, window.clearTimeout(l.current), l.current = window.setTimeout(() => {
|
|
37
|
+
c.current = "";
|
|
38
|
+
}, r);
|
|
39
|
+
let a = n + 1;
|
|
40
|
+
for (let e = 0; e < t.length; e++) {
|
|
41
|
+
let n = (a + e) % t.length;
|
|
42
|
+
if (t[n].textContent.toLowerCase().startsWith(i)) {
|
|
43
|
+
u(n);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, [
|
|
50
|
+
i,
|
|
51
|
+
o,
|
|
52
|
+
s
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
function s({ menuRef: e, active: n, selector: r = i }) {
|
|
56
|
+
t(() => {
|
|
57
|
+
let t = e.current;
|
|
58
|
+
if (!n || !t) return;
|
|
59
|
+
let i = () => {
|
|
60
|
+
let e = a(t, r);
|
|
61
|
+
if (e.length === 0) return;
|
|
62
|
+
let n = e.findIndex((e) => e.tabIndex === 0), i = n >= 0 ? n : 0;
|
|
63
|
+
e.forEach((e, t) => {
|
|
64
|
+
e.tabIndex = t === i ? 0 : -1;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
i();
|
|
68
|
+
let o = new MutationObserver(i);
|
|
69
|
+
o.observe(t, {
|
|
70
|
+
childList: !0,
|
|
71
|
+
subtree: !0
|
|
72
|
+
});
|
|
73
|
+
let s = (e) => {
|
|
74
|
+
a(t, r).forEach((t) => {
|
|
75
|
+
t.tabIndex = t === e.target ? 0 : -1;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
return t.addEventListener("focusin", s), () => {
|
|
79
|
+
o.disconnect(), t.removeEventListener("focusin", s);
|
|
80
|
+
};
|
|
81
|
+
}, [
|
|
82
|
+
e,
|
|
83
|
+
n,
|
|
84
|
+
r
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { a as getEnabledMenuItems, o as useMenuKeyboard, s as useRovingTabindex };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "haze-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React UI component library powered by react-use-control and Linaria",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/types/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js"
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
13
14
|
},
|
|
14
15
|
"./styles.css": "./dist/haze-ui.css",
|
|
15
16
|
"./css/*": "./dist/css/*"
|
|
@@ -29,9 +30,11 @@
|
|
|
29
30
|
"lint": "eslint --fix src *.mjs",
|
|
30
31
|
"deploy": "npm run build:demo && gh-pages -d dist",
|
|
31
32
|
"test": "vitest run --passWithNoTests",
|
|
33
|
+
"test:e2e": "playwright test --config e2e/playwright.config.ts",
|
|
32
34
|
"test:watch": "vitest",
|
|
33
35
|
"prepublishOnly": "npm run build",
|
|
34
|
-
"serve": "vite preview"
|
|
36
|
+
"serve": "vite preview",
|
|
37
|
+
"size": "size-limit"
|
|
35
38
|
},
|
|
36
39
|
"repository": {
|
|
37
40
|
"type": "git",
|
|
@@ -49,11 +52,10 @@
|
|
|
49
52
|
"peerDependencies": {
|
|
50
53
|
"@linaria/core": "^7.0.0 || ^8.0.0",
|
|
51
54
|
"react": "^19.0.0",
|
|
52
|
-
"react-f0rm": ">=0.7.0"
|
|
55
|
+
"react-f0rm": ">=0.7.0 <0.9.0"
|
|
53
56
|
},
|
|
54
57
|
"dependencies": {
|
|
55
|
-
"react-
|
|
56
|
-
"react-use-control": "^1.3.2"
|
|
58
|
+
"react-use-control": "^1.4.0"
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|
|
59
61
|
"@babel/core": "^8.0.1",
|
|
@@ -62,20 +64,22 @@
|
|
|
62
64
|
"@faker-js/faker": "^10.6.0",
|
|
63
65
|
"@for-fun/event-emitter": "^1.0.1",
|
|
64
66
|
"@linaria/core": "^8.2.0",
|
|
65
|
-
"@native-router/core": "^1.
|
|
66
|
-
"@native-router/react": "^1.
|
|
67
|
+
"@native-router/core": "^1.10.0",
|
|
68
|
+
"@native-router/react": "^1.9.0",
|
|
69
|
+
"@playwright/test": "^1.62.1",
|
|
70
|
+
"@size-limit/file": "^13.0.3",
|
|
67
71
|
"@testing-library/jest-dom": "^7.0.1",
|
|
68
|
-
"@testing-library/react": "^16.3.
|
|
72
|
+
"@testing-library/react": "^16.3.3",
|
|
69
73
|
"@testing-library/user-event": "^14.6.6",
|
|
70
74
|
"@types/jest-axe": "^3.5.9",
|
|
71
|
-
"@types/node": "^26.
|
|
75
|
+
"@types/node": "^26.4.0",
|
|
72
76
|
"@types/ramda": "^0.32.0",
|
|
73
77
|
"@types/react": "^19.2.18",
|
|
74
78
|
"@types/react-dom": "^19.2.5",
|
|
75
|
-
"@vitejs/plugin-react": "^6.1.
|
|
79
|
+
"@vitejs/plugin-react": "^6.1.1",
|
|
76
80
|
"@vitest/coverage-v8": "4.1.11",
|
|
77
|
-
"@wyw-in-js/babel-preset": "^2.4.
|
|
78
|
-
"@wyw-in-js/vite": "^2.4.
|
|
81
|
+
"@wyw-in-js/babel-preset": "^2.4.4",
|
|
82
|
+
"@wyw-in-js/vite": "^2.4.4",
|
|
79
83
|
"babel-plugin-transform-jsx-class": "^0.1.3",
|
|
80
84
|
"babel-plugin-transform-jsx-condition": "^0.1.3",
|
|
81
85
|
"commitizen": "^4.3.2",
|
|
@@ -88,22 +92,44 @@
|
|
|
88
92
|
"jest-axe": "^11.0.0",
|
|
89
93
|
"jsdom": "^30.0.1",
|
|
90
94
|
"json-schema-faker": "^0.6.3",
|
|
91
|
-
"lint-staged": "^17.
|
|
92
|
-
"lucide-react": "^1.
|
|
95
|
+
"lint-staged": "^17.4.1",
|
|
96
|
+
"lucide-react": "^1.37.0",
|
|
93
97
|
"prettier": "^3.9.6",
|
|
94
98
|
"qss": "^3.0.0",
|
|
95
99
|
"ramda": "^0.32.0",
|
|
96
100
|
"react": "^19.2.8",
|
|
97
101
|
"react-dom": "^19.2.8",
|
|
98
|
-
"react-f0rm": "^0.
|
|
102
|
+
"react-f0rm": "^0.8.0",
|
|
99
103
|
"react-icons": "^5.7.0",
|
|
104
|
+
"react-toolroom": "^0.18.4",
|
|
100
105
|
"rollup-plugin-type-as-json-schema": "^0.2.6",
|
|
101
106
|
"semantic-release": "^25.0.9",
|
|
102
|
-
"
|
|
103
|
-
"
|
|
107
|
+
"size-limit": "^13.0.3",
|
|
108
|
+
"terser": "^5.51.2",
|
|
109
|
+
"tools-config": "^0.3.1",
|
|
104
110
|
"tsc-alias": "^1.9.2",
|
|
105
111
|
"typescript": "^6.0.3",
|
|
106
112
|
"vite": "^8.2.2",
|
|
107
113
|
"vitest": "^4.1.11"
|
|
108
|
-
}
|
|
114
|
+
},
|
|
115
|
+
"size-limit": [
|
|
116
|
+
{
|
|
117
|
+
"path": "dist/index.js",
|
|
118
|
+
"limit": "16 KB"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"path": "dist/index.js",
|
|
122
|
+
"limit": "4 KB",
|
|
123
|
+
"gzip": true
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"path": "dist/haze-ui.css",
|
|
127
|
+
"limit": "136 KB"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"path": "dist/haze-ui.css",
|
|
131
|
+
"limit": "19 KB",
|
|
132
|
+
"gzip": true
|
|
133
|
+
}
|
|
134
|
+
]
|
|
109
135
|
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { useCallback as e, useEffect as t, useRef as n } from "react";
|
|
2
|
-
//#region src/lib/components/DropdownMenu/useMenuKeyboard.ts
|
|
3
|
-
var r = 500;
|
|
4
|
-
function i(e) {
|
|
5
|
-
return e ? Array.from(e.querySelectorAll("[role=\"menuitem\"]:not([disabled])")) : [];
|
|
6
|
-
}
|
|
7
|
-
function a({ menuRef: a, onClose: o }) {
|
|
8
|
-
let s = n(""), c = n(0);
|
|
9
|
-
return t(() => () => window.clearTimeout(c.current), []), e((e) => {
|
|
10
|
-
let t = i(a.current);
|
|
11
|
-
if (t.length === 0) return;
|
|
12
|
-
let n = t.indexOf(document.activeElement), l = (e) => t[e]?.focus();
|
|
13
|
-
switch (e.key) {
|
|
14
|
-
case "ArrowDown":
|
|
15
|
-
e.preventDefault(), l((n + 1) % t.length);
|
|
16
|
-
return;
|
|
17
|
-
case "ArrowUp":
|
|
18
|
-
e.preventDefault(), l((n - 1 + t.length) % t.length);
|
|
19
|
-
return;
|
|
20
|
-
case "Home":
|
|
21
|
-
e.preventDefault(), l(0);
|
|
22
|
-
return;
|
|
23
|
-
case "End":
|
|
24
|
-
e.preventDefault(), l(t.length - 1);
|
|
25
|
-
return;
|
|
26
|
-
case "Escape":
|
|
27
|
-
e.preventDefault(), o();
|
|
28
|
-
return;
|
|
29
|
-
case "Tab":
|
|
30
|
-
e.preventDefault(), o();
|
|
31
|
-
return;
|
|
32
|
-
default: {
|
|
33
|
-
if (e.key.length !== 1 || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
34
|
-
e.preventDefault();
|
|
35
|
-
let i = (s.current + e.key).toLowerCase();
|
|
36
|
-
s.current = i, window.clearTimeout(c.current), c.current = window.setTimeout(() => {
|
|
37
|
-
s.current = "";
|
|
38
|
-
}, r);
|
|
39
|
-
let a = n + 1;
|
|
40
|
-
for (let e = 0; e < t.length; e++) {
|
|
41
|
-
let n = (a + e) % t.length;
|
|
42
|
-
if (t[n].textContent.toLowerCase().startsWith(i)) {
|
|
43
|
-
l(n);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}, [a, o]);
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
52
|
-
export { i as getEnabledMenuItems, a as useMenuKeyboard };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { useControl as e, useThru as t } from "react-use-control";
|
|
2
|
-
import { useMemo as n } from "react";
|
|
3
|
-
import { changeValueByPath as r, getValueByPath as i, useValueByPath as a } from "react-f0rm";
|
|
4
|
-
//#region src/lib/form/useFormControl.ts
|
|
5
|
-
var o = /* @__PURE__ */ new Map();
|
|
6
|
-
function s(e) {
|
|
7
|
-
let t = [], n = "", r = () => {
|
|
8
|
-
t.push(n), n = "";
|
|
9
|
-
};
|
|
10
|
-
for (let i = 0; i < e.length; i++) {
|
|
11
|
-
let a = e[i];
|
|
12
|
-
if (a === ".") n !== "" && r();
|
|
13
|
-
else if (a === "[") {
|
|
14
|
-
n !== "" && r();
|
|
15
|
-
let a = e[i + 1];
|
|
16
|
-
if (a === "\"" || a === "'") {
|
|
17
|
-
let n = e.indexOf(a, i + 2);
|
|
18
|
-
if (n === -1) throw TypeError(`Unterminated quote in path: ${e}`);
|
|
19
|
-
if (e[n + 1] !== "]") throw TypeError(`Expected "]" after quoted segment in path: ${e}`);
|
|
20
|
-
t.push(e.slice(i + 2, n)), i = n + 1;
|
|
21
|
-
} else {
|
|
22
|
-
let n = e.indexOf("]", i + 1);
|
|
23
|
-
if (n === -1) throw TypeError(`Unterminated bracket in path: ${e}`);
|
|
24
|
-
let r = e.slice(i + 1, n);
|
|
25
|
-
t.push(/^-?\d+$/.test(r) ? Number(r) : r), i = n;
|
|
26
|
-
}
|
|
27
|
-
} else n += a;
|
|
28
|
-
}
|
|
29
|
-
return (n !== "" || t.length === 0) && r(), t;
|
|
30
|
-
}
|
|
31
|
-
function c(e) {
|
|
32
|
-
if (typeof e != "string") return {
|
|
33
|
-
value: e,
|
|
34
|
-
key: JSON.stringify(e)
|
|
35
|
-
};
|
|
36
|
-
let t = o.get(e);
|
|
37
|
-
return t || (t = s(e), o.set(e, t)), {
|
|
38
|
-
value: t,
|
|
39
|
-
key: JSON.stringify(t)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function l(e) {
|
|
43
|
-
let t = typeof e == "string" ? e : JSON.stringify(e);
|
|
44
|
-
return n(() => c(e), [t]);
|
|
45
|
-
}
|
|
46
|
-
function u(n, o) {
|
|
47
|
-
let s = l(o), c = a(n, s), [, , u] = e();
|
|
48
|
-
return t(u, () => [c, (e) => {
|
|
49
|
-
let t = i(n, s), a = typeof e == "function" ? e(t) : e;
|
|
50
|
-
r(n, s, a);
|
|
51
|
-
}]);
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { u as useFormControl };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { KeyboardEvent as ReactKeyboardEvent, RefObject } from 'react';
|
|
2
|
-
/** Enabled menu items inside a menu container, in DOM order. */
|
|
3
|
-
export declare function getEnabledMenuItems(container: HTMLElement | null): HTMLElement[];
|
|
4
|
-
type UseMenuKeyboardOptions = {
|
|
5
|
-
/** Element containing the `[role=menuitem]` children. */
|
|
6
|
-
menuRef: RefObject<HTMLElement | null>;
|
|
7
|
-
/** Called when the menu should close via keyboard; the caller returns
|
|
8
|
-
* focus to the trigger. */
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Keyboard behavior for a `role="menu"` container with roving-tabindex
|
|
13
|
-
* items: ↑/↓ move focus (wrapping, skipping disabled items), Home/End
|
|
14
|
-
* jump to the ends, Escape closes (returning focus to the trigger), Tab
|
|
15
|
-
* closes, and printable characters run typeahead — matching the WAI-ARIA
|
|
16
|
-
* Menu Button pattern.
|
|
17
|
-
*/
|
|
18
|
-
export declare function useMenuKeyboard({ menuRef, onClose }: UseMenuKeyboardOptions): (event: ReactKeyboardEvent) => void;
|
|
19
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Control } from 'react-use-control';
|
|
2
|
-
import type { FieldPath, FormInstance, Name, PathValueOf } from 'react-f0rm';
|
|
3
|
-
export type { FormInstance, PathValueOf };
|
|
4
|
-
/**
|
|
5
|
-
* Bind a react-f0rm field to haze-ui's Control system.
|
|
6
|
-
*
|
|
7
|
-
* The returned handle can be passed to any control-prop of a haze-ui
|
|
8
|
-
* component (`value`, `checked`, ...) exactly like a local control:
|
|
9
|
-
*
|
|
10
|
-
* ```tsx
|
|
11
|
-
* const form = useForm({initialValues: {email: ''}});
|
|
12
|
-
* const email = useFormControl(form, 'email');
|
|
13
|
-
* return <Input value={email} />;
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* How it works: the handle carries a `[form value, dispatch → form]` state
|
|
17
|
-
* pair — the form owns the state, the handle only forwards it. Reads return
|
|
18
|
-
* `getValueByPath` at render time (kept fresh by a `useValueByPath`
|
|
19
|
-
* subscription that re-renders this component on own-field changes — and
|
|
20
|
-
* only those, so sibling fields stay isolated); writes go through
|
|
21
|
-
* `changeValueByPath` — react-f0rm's user-change channel — so a control
|
|
22
|
-
* write fires exactly the validation a user typing into the field would
|
|
23
|
-
* fire (the field's effective `mode`, per-field override included, and the
|
|
24
|
-
* form's `reValidateMode`). The setter accepts either a plain value or a
|
|
25
|
-
* functional updater that is evaluated against the live form value.
|
|
26
|
-
*
|
|
27
|
-
* The handle's identity is stable across re-renders, including own-field
|
|
28
|
-
* value changes.
|
|
29
|
-
*
|
|
30
|
-
* @param form react-f0rm form instance
|
|
31
|
-
* @param name field path — dotted string ('user.email', 'tags[0]') or
|
|
32
|
-
* segments array (['user', 0, 'name'])
|
|
33
|
-
* @return a `Control` bound to the field's value
|
|
34
|
-
*/
|
|
35
|
-
export declare function useFormControl<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name>(form: FormInstance<TValues>, name: P): Control<PathValueOf<TValues, P>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|