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
|
@@ -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,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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|