wimui 0.69.1 → 0.70.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/dist/components/_internal/typeahead.cjs +2 -0
- package/dist/components/_internal/typeahead.d.ts +45 -0
- package/dist/components/_internal/typeahead.js +24 -0
- package/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.js +119 -119
- package/dist/components/form/Cascader/Cascader.cjs +1 -1
- package/dist/components/form/Cascader/Cascader.js +168 -151
- package/dist/components/form/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/form/MultiSelect/MultiSelect.js +131 -111
- package/dist/components/form/Select/useSelect.cjs +1 -1
- package/dist/components/form/Select/useSelect.js +83 -75
- package/dist/components/form/Transfer/Transfer.cjs +1 -1
- package/dist/components/form/Transfer/Transfer.js +147 -141
- package/dist/components/navigation/Menubar/Menubar.cjs +1 -1
- package/dist/components/navigation/Menubar/Menubar.js +133 -122
- package/dist/components/overlay/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/overlay/Dropdown/Dropdown.js +131 -122
- package/dist/components/overlay/Menu/Menu.cjs +1 -1
- package/dist/components/overlay/Menu/Menu.js +100 -89
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +2 -2
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
3
|
import { Transition as n } from "../../layout/Transition/Transition.js";
|
|
4
4
|
import { BaseListItem as r } from "../../_internal/BaseListItem/BaseListItem.js";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import p from "
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
5
|
+
import { findTypeaheadIndex as i, isTypeaheadKey as a, useTypeahead as o } from "../../_internal/typeahead.js";
|
|
6
|
+
import { mergeRefs as s } from "../../_internal/mergeRefs.js";
|
|
7
|
+
import c from "./dropdown.module.js";
|
|
8
|
+
import l, { forwardRef as u, useCallback as d, useEffect as f, useId as p, useRef as m, useState as h } from "react";
|
|
9
|
+
import g from "classnames";
|
|
10
|
+
import { jsx as _ } from "react/jsx-runtime";
|
|
11
|
+
import { FloatingPortal as v, autoUpdate as y, flip as b, offset as x, shift as S, useFloating as C } from "@floating-ui/react";
|
|
11
12
|
//#region src/components/overlay/Dropdown/Dropdown.tsx
|
|
12
|
-
var
|
|
13
|
+
var w = l.createContext({
|
|
13
14
|
isOpen: !1,
|
|
14
15
|
toggle: () => {},
|
|
15
16
|
close: () => {},
|
|
@@ -26,177 +27,185 @@ var x = o.createContext({
|
|
|
26
27
|
floatingStyles: {},
|
|
27
28
|
floatingRef: { current: null },
|
|
28
29
|
setAlign: () => {}
|
|
29
|
-
}),
|
|
30
|
-
let [
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
open:
|
|
34
|
-
placement:
|
|
35
|
-
whileElementsMounted:
|
|
30
|
+
}), T = u(({ children: n, className: r, asChild: l = !1, defaultOpen: u = !1, open: v, onOpenChange: T, ...E }, D) => {
|
|
31
|
+
let [O, k] = h(u), A = v ?? O, j = d((e) => {
|
|
32
|
+
v === void 0 && k(e), T?.(e);
|
|
33
|
+
}, [v, T]), [M, N] = h(-1), P = m(null), F = m(0), [I, L] = h("left"), { refs: R, floatingStyles: z } = C({
|
|
34
|
+
open: A,
|
|
35
|
+
placement: I === "right" ? "bottom-end" : "bottom-start",
|
|
36
|
+
whileElementsMounted: y,
|
|
36
37
|
middleware: [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
x(4),
|
|
39
|
+
b(),
|
|
40
|
+
S({ padding: 8 })
|
|
40
41
|
]
|
|
41
|
-
}),
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
}), B = s(P, D);
|
|
43
|
+
f(() => {
|
|
44
|
+
F.current = 0;
|
|
44
45
|
});
|
|
45
|
-
let
|
|
46
|
-
let e =
|
|
47
|
-
return
|
|
48
|
-
},
|
|
49
|
-
let e = !
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
let e =
|
|
53
|
-
|
|
46
|
+
let V = () => {
|
|
47
|
+
let e = F.current;
|
|
48
|
+
return F.current += 1, e;
|
|
49
|
+
}, H = p(), [U, W] = h(void 0), [G, K] = h(void 0), q = G ?? `wim-dropdown-menu-${H}`, J = U ?? `wim-dropdown-trigger-${H}`, Y = () => {
|
|
50
|
+
let e = !A;
|
|
51
|
+
j(e), N(e ? 0 : -1);
|
|
52
|
+
}, X = d(() => {
|
|
53
|
+
let e = R.floating.current, t = !!e && e.contains(document.activeElement);
|
|
54
|
+
j(!1), N(-1), t && R.reference.current?.focus?.({ preventScroll: !0 });
|
|
54
55
|
}, [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
j,
|
|
57
|
+
R.floating,
|
|
58
|
+
R.reference
|
|
58
59
|
]);
|
|
59
|
-
|
|
60
|
+
f(() => {
|
|
60
61
|
let e = (e) => {
|
|
61
|
-
let t = e.target, n =
|
|
62
|
-
|
|
62
|
+
let t = e.target, n = R.floating.current?.contains(t) ?? !1;
|
|
63
|
+
P.current && !P.current.contains(t) && !n && X();
|
|
63
64
|
}, t = (e) => {
|
|
64
|
-
e.key === "Escape" &&
|
|
65
|
+
e.key === "Escape" && X();
|
|
65
66
|
};
|
|
66
|
-
return
|
|
67
|
+
return A && (document.addEventListener("mousedown", e), document.addEventListener("keydown", t)), () => {
|
|
67
68
|
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
68
69
|
};
|
|
69
70
|
}, [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
A,
|
|
72
|
+
R.floating,
|
|
73
|
+
X
|
|
73
74
|
]);
|
|
74
|
-
let
|
|
75
|
-
if (!
|
|
76
|
-
let t = Array.from((
|
|
77
|
-
|
|
75
|
+
let Z = o(), Q = (e) => {
|
|
76
|
+
if (!A) return;
|
|
77
|
+
let t = Array.from((R.floating.current ?? P.current)?.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])") || []);
|
|
78
|
+
if (a(e, Z.typing())) {
|
|
79
|
+
let n = i({
|
|
80
|
+
query: Z.push(e.key),
|
|
81
|
+
current: M,
|
|
82
|
+
count: t.length,
|
|
83
|
+
getText: (e) => t[e].textContent ?? ""
|
|
84
|
+
});
|
|
85
|
+
n >= 0 && (e.preventDefault(), N(n));
|
|
86
|
+
} else switch (e.key) {
|
|
78
87
|
case "ArrowDown":
|
|
79
|
-
e.preventDefault(),
|
|
88
|
+
e.preventDefault(), N((e) => e < t.length - 1 ? e + 1 : 0);
|
|
80
89
|
break;
|
|
81
90
|
case "ArrowUp":
|
|
82
|
-
e.preventDefault(),
|
|
91
|
+
e.preventDefault(), N((e) => e > 0 ? e - 1 : t.length - 1);
|
|
83
92
|
break;
|
|
84
93
|
case "Home":
|
|
85
|
-
e.preventDefault(),
|
|
94
|
+
e.preventDefault(), N(0);
|
|
86
95
|
break;
|
|
87
96
|
case "End":
|
|
88
|
-
e.preventDefault(),
|
|
97
|
+
e.preventDefault(), N(t.length - 1);
|
|
89
98
|
break;
|
|
90
|
-
case "Tab":
|
|
99
|
+
case "Tab": X();
|
|
91
100
|
}
|
|
92
101
|
};
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
f(() => {
|
|
103
|
+
A && M >= 0 && Array.from((R.floating.current ?? P.current)?.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])") || [])[M]?.focus({ preventScroll: !0 });
|
|
95
104
|
}, [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
M,
|
|
106
|
+
A,
|
|
107
|
+
R.floating
|
|
99
108
|
]);
|
|
100
|
-
let
|
|
101
|
-
return /* @__PURE__ */
|
|
109
|
+
let $ = l ? e : "div";
|
|
110
|
+
return /* @__PURE__ */ _(w.Provider, {
|
|
102
111
|
value: {
|
|
103
|
-
isOpen:
|
|
104
|
-
toggle:
|
|
105
|
-
close:
|
|
106
|
-
menuId:
|
|
107
|
-
triggerId:
|
|
108
|
-
setTriggerIdOverride:
|
|
109
|
-
setMenuIdOverride:
|
|
110
|
-
focusedIndex:
|
|
111
|
-
setFocusedIndex:
|
|
112
|
-
registerItem:
|
|
113
|
-
containerRef:
|
|
114
|
-
setReference:
|
|
115
|
-
setFloating:
|
|
116
|
-
floatingStyles:
|
|
117
|
-
floatingRef:
|
|
118
|
-
setAlign:
|
|
112
|
+
isOpen: A,
|
|
113
|
+
toggle: Y,
|
|
114
|
+
close: X,
|
|
115
|
+
menuId: q,
|
|
116
|
+
triggerId: J,
|
|
117
|
+
setTriggerIdOverride: W,
|
|
118
|
+
setMenuIdOverride: K,
|
|
119
|
+
focusedIndex: M,
|
|
120
|
+
setFocusedIndex: N,
|
|
121
|
+
registerItem: V,
|
|
122
|
+
containerRef: P,
|
|
123
|
+
setReference: R.setReference,
|
|
124
|
+
setFloating: R.setFloating,
|
|
125
|
+
floatingStyles: z,
|
|
126
|
+
floatingRef: R.floating,
|
|
127
|
+
setAlign: L
|
|
119
128
|
},
|
|
120
|
-
children: /* @__PURE__ */
|
|
121
|
-
...
|
|
129
|
+
children: /* @__PURE__ */ _($, {
|
|
130
|
+
...E,
|
|
122
131
|
role: "none",
|
|
123
|
-
className:
|
|
124
|
-
ref:
|
|
125
|
-
onKeyDown:
|
|
126
|
-
children: /* @__PURE__ */
|
|
132
|
+
className: g("wim-dropdown", c.root, r),
|
|
133
|
+
ref: B,
|
|
134
|
+
onKeyDown: Q,
|
|
135
|
+
children: /* @__PURE__ */ _(t, { children: n })
|
|
127
136
|
})
|
|
128
137
|
});
|
|
129
138
|
});
|
|
130
|
-
|
|
131
|
-
var
|
|
132
|
-
let { toggle:
|
|
133
|
-
|
|
134
|
-
let b =
|
|
135
|
-
return /* @__PURE__ */
|
|
136
|
-
...
|
|
137
|
-
ref:
|
|
138
|
-
id:
|
|
139
|
-
className:
|
|
140
|
-
onClick:
|
|
139
|
+
T.displayName = "Dropdown";
|
|
140
|
+
var E = u(({ children: n, className: r, asChild: i = !1, id: a, ...o }, u) => {
|
|
141
|
+
let { toggle: d, isOpen: p, menuId: m, triggerId: h, setTriggerIdOverride: v, setReference: y } = l.useContext(w);
|
|
142
|
+
f(() => (v(a), () => v(void 0)), [a, v]);
|
|
143
|
+
let b = i ? e : "div", x = s(y, u);
|
|
144
|
+
return /* @__PURE__ */ _(b, {
|
|
145
|
+
...o,
|
|
146
|
+
ref: x,
|
|
147
|
+
id: a ?? h,
|
|
148
|
+
className: g(c.trigger, r),
|
|
149
|
+
onClick: d,
|
|
141
150
|
"aria-haspopup": "menu",
|
|
142
|
-
"aria-expanded":
|
|
143
|
-
"aria-controls":
|
|
151
|
+
"aria-expanded": p,
|
|
152
|
+
"aria-controls": p ? m : void 0,
|
|
144
153
|
role: "button",
|
|
145
154
|
tabIndex: 0,
|
|
146
155
|
onKeyDown: (e) => {
|
|
147
|
-
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown" && !
|
|
156
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown" && !p) && (e.preventDefault(), d());
|
|
148
157
|
},
|
|
149
|
-
children: /* @__PURE__ */
|
|
158
|
+
children: /* @__PURE__ */ _(t, { children: n })
|
|
150
159
|
});
|
|
151
160
|
});
|
|
152
|
-
|
|
153
|
-
var
|
|
154
|
-
let { isOpen:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}, [r,
|
|
158
|
-
let T =
|
|
159
|
-
return /* @__PURE__ */
|
|
160
|
-
...
|
|
161
|
+
E.displayName = "Dropdown.Trigger";
|
|
162
|
+
var D = u(({ children: e, className: t, align: r = "left", show: i, style: a, id: o, "aria-labelledby": u, ...d }, p) => {
|
|
163
|
+
let { isOpen: m, menuId: h, triggerId: y, setMenuIdOverride: b, setFloating: x, floatingStyles: S, setAlign: C } = l.useContext(w);
|
|
164
|
+
f(() => (b(o), () => b(void 0)), [o, b]), f(() => {
|
|
165
|
+
C(r);
|
|
166
|
+
}, [r, C]);
|
|
167
|
+
let T = s(x, p);
|
|
168
|
+
return /* @__PURE__ */ _(v, { children: /* @__PURE__ */ _(n, {
|
|
169
|
+
...d,
|
|
161
170
|
ref: T,
|
|
162
|
-
show:
|
|
171
|
+
show: i === void 0 ? m : i,
|
|
163
172
|
preset: "fade",
|
|
164
|
-
id:
|
|
173
|
+
id: o ?? h,
|
|
165
174
|
style: {
|
|
166
|
-
...
|
|
167
|
-
...
|
|
175
|
+
...S,
|
|
176
|
+
...a
|
|
168
177
|
},
|
|
169
|
-
className:
|
|
178
|
+
className: g(c.menu, t),
|
|
170
179
|
role: "menu",
|
|
171
|
-
"aria-labelledby":
|
|
180
|
+
"aria-labelledby": u ?? y,
|
|
172
181
|
children: e
|
|
173
182
|
}) });
|
|
174
183
|
});
|
|
175
|
-
|
|
176
|
-
var
|
|
177
|
-
let { close:
|
|
178
|
-
n || (e.stopPropagation(), t && t(),
|
|
184
|
+
D.displayName = "Dropdown.Menu";
|
|
185
|
+
var O = u(({ children: e, onClick: t, disabled: n = !1, className: i, ...a }, o) => {
|
|
186
|
+
let { close: s, focusedIndex: u, setFocusedIndex: d, registerItem: f } = l.useContext(w), [p] = h(() => f()), m = u === p, v = (e) => {
|
|
187
|
+
n || (e.stopPropagation(), t && t(), s());
|
|
179
188
|
};
|
|
180
|
-
return /* @__PURE__ */
|
|
181
|
-
...
|
|
182
|
-
ref:
|
|
183
|
-
className:
|
|
189
|
+
return /* @__PURE__ */ _(r, {
|
|
190
|
+
...a,
|
|
191
|
+
ref: o,
|
|
192
|
+
className: g(c.item, i),
|
|
184
193
|
onClick: v,
|
|
185
|
-
onFocus: () => d(
|
|
194
|
+
onFocus: () => d(p),
|
|
186
195
|
disabled: n,
|
|
187
196
|
role: "menuitem",
|
|
188
|
-
tabIndex:
|
|
197
|
+
tabIndex: m ? 0 : -1,
|
|
189
198
|
onKeyDown: (e) => {
|
|
190
199
|
!n && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), v(e));
|
|
191
200
|
},
|
|
192
201
|
children: e
|
|
193
202
|
});
|
|
194
203
|
});
|
|
195
|
-
|
|
196
|
-
var
|
|
204
|
+
O.displayName = "Dropdown.Item";
|
|
205
|
+
var k = u((e, t) => /* @__PURE__ */ _(T, {
|
|
197
206
|
...e,
|
|
198
207
|
ref: t
|
|
199
208
|
}));
|
|
200
|
-
|
|
209
|
+
k.displayName = "Dropdown", k.Trigger = E, k.Menu = D, k.Item = O;
|
|
201
210
|
//#endregion
|
|
202
|
-
export {
|
|
211
|
+
export { k as Dropdown, k as default, O as DropdownItem, D as DropdownMenu, E as DropdownTrigger };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../layout/Transition/Transition.cjs"),r=require("../../../icon/chevron-right.cjs"),i=require("../../media/Icon/Icon.cjs"),a=require("../../_internal/BaseListItem/BaseListItem.cjs"),o=require("./menu.module.cjs");let
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../layout/Transition/Transition.cjs"),r=require("../../../icon/chevron-right.cjs"),i=require("../../media/Icon/Icon.cjs"),a=require("../../_internal/BaseListItem/BaseListItem.cjs"),o=require("../../_internal/typeahead.cjs"),s=require("./menu.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=c.default.createContext({expandedItems:new Set,toggleItem:()=>{},containerRef:{current:null},mode:`vertical`,focusedIndex:0,setFocusedIndex:()=>{},registerItem:()=>0}),f=()=>{let e=c.default.useContext(d);if(!e)throw Error(`Menu sub-components must be used within a Menu`);return e},p=({children:e,className:n,asChild:r=!1,mode:i=`vertical`,defaultOpenKeys:a=[],"aria-label":f,"aria-labelledby":p})=>{let[m,h]=(0,c.useState)(new Set(a)),[g,_]=(0,c.useState)(0),v=c.default.useRef(0);c.default.useEffect(()=>{v.current=0});let y=()=>{let e=v.current;return v.current+=1,e},b=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},x=c.default.useRef(null),S=o.useTypeahead(),C=e=>{let t=Array.from(x.current?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)||[]),n=t.indexOf(document.activeElement);if(n!==-1){if(o.isTypeaheadKey(e,S.typing())){let r=o.findTypeaheadIndex({query:S.push(e.key),current:n,count:t.length,getText:e=>t[e].textContent??``});r>=0&&(e.preventDefault(),_(r),t[r].focus())}else{if(i===`vertical`||i===`inline`){if(e.key===`ArrowDown`)e.preventDefault(),t[(n+1)%t.length]?.focus();else if(e.key===`ArrowUp`)e.preventDefault(),t[(n-1+t.length)%t.length]?.focus();else if(e.key===`ArrowRight`){let r=t[n];r.getAttribute(`aria-haspopup`)===`true`&&r.getAttribute(`aria-expanded`)===`false`&&(e.preventDefault(),r.click())}else if(e.key===`ArrowLeft`){let r=t[n];r.getAttribute(`aria-haspopup`)===`true`&&r.getAttribute(`aria-expanded`)===`true`&&(e.preventDefault(),r.click())}}else if(i===`horizontal`){if(e.key===`ArrowRight`)e.preventDefault(),t[(n+1)%t.length]?.focus();else if(e.key===`ArrowLeft`)e.preventDefault(),t[(n-1+t.length)%t.length]?.focus();else if(e.key===`ArrowDown`){let r=t[n];r.getAttribute(`aria-haspopup`)===`true`&&r.getAttribute(`aria-expanded`)===`false`&&(e.preventDefault(),r.click())}}e.key===`Home`?(e.preventDefault(),_(0),t[0]?.focus()):e.key===`End`&&(e.preventDefault(),_(t.length-1),t[t.length-1]?.focus())}}},w=r?t.Root:`ul`;return(0,u.jsx)(d.Provider,{value:{expandedItems:m,toggleItem:b,containerRef:x,mode:i,focusedIndex:g,setFocusedIndex:_,registerItem:y},children:(0,u.jsx)(w,{ref:x,className:(0,l.default)(`wim-menu`,s.default.root,s.default[i],n),role:`menu`,"aria-label":p?void 0:f,"aria-labelledby":p,onKeyDown:C,children:(0,u.jsx)(t.Slottable,{children:e})})})},m=({children:e,onClick:t,disabled:n=!1,danger:r=!1,className:i,icon:o,asChild:d=!1,...p})=>{let{focusedIndex:m,setFocusedIndex:h,registerItem:g}=f(),[_]=(0,c.useState)(()=>g()),v=m===_,y=e=>{e.stopPropagation(),!n&&t&&t()},b={className:(0,l.default)(s.default.item,i),onClick:y,onFocus:()=>h(_),disabled:n,danger:r,icon:o,role:`menuitem`,tabIndex:v?0:-1,onKeyDown:e=>{!n&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),y(e))},...p};return d?(0,u.jsx)(`li`,{role:`none`,children:(0,u.jsx)(a.BaseListItem,{asChild:!0,...b,children:e})}):(0,u.jsx)(a.BaseListItem,{asChild:!0,...b,children:(0,u.jsx)(`li`,{children:e})})},h=({children:e,title:t,className:n})=>(0,u.jsxs)(`li`,{className:(0,l.default)(s.default.itemGroup,n),role:`none`,children:[t&&(0,u.jsx)(`div`,{className:s.default.itemGroupTitle,"aria-hidden":`true`,children:t}),(0,u.jsx)(`ul`,{className:s.default.itemGroupList,role:`group`,"aria-label":t||void 0,children:e})]}),g=({children:e,title:t,className:o,icon:d,itemKey:p})=>{let{expandedItems:m,toggleItem:h,registerItem:g,focusedIndex:_,setFocusedIndex:v}=f(),y=m.has(p),[b]=(0,c.useState)(()=>g()),x=_===b,S=c.default.useId(),C=e=>{e.stopPropagation(),h(p)};return(0,u.jsxs)(`li`,{className:(0,l.default)(s.default.submenu,y&&s.default.open,o),role:`none`,children:[(0,u.jsx)(a.BaseListItem,{id:S,className:s.default.submenuTitle,onClick:C,onFocus:()=>v(b),icon:d,rightSection:(0,u.jsx)(`span`,{className:(0,l.default)(s.default.submenuArrow,y&&s.default.open),children:(0,u.jsx)(i.Icon,{component:r.default,size:`sm`})}),role:`menuitem`,"aria-haspopup":`true`,"aria-expanded":y,tabIndex:x?0:-1,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),C(e))},children:t}),(0,u.jsx)(n.Transition,{show:y,preset:`fade`,className:s.default.submenuList,children:(0,u.jsx)(`ul`,{className:s.default.submenuList,role:`menu`,"aria-labelledby":S,children:e})})]})},_=({className:e})=>(0,u.jsx)(`li`,{className:(0,l.default)(s.default.divider,e),role:`separator`}),v=Object.assign(p,{Item:m,Group:h,SubMenu:g,Divider:_});exports.Menu=v,exports.default=v,exports.MenuDivider=_,exports.MenuItem=m,exports.MenuItemGroup=h,exports.SubMenu=g;
|
|
@@ -4,12 +4,13 @@ import { Transition as n } from "../../layout/Transition/Transition.js";
|
|
|
4
4
|
import r from "../../../icon/chevron-right.js";
|
|
5
5
|
import { Icon as i } from "../../media/Icon/Icon.js";
|
|
6
6
|
import { BaseListItem as a } from "../../_internal/BaseListItem/BaseListItem.js";
|
|
7
|
-
import o from "
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
7
|
+
import { findTypeaheadIndex as o, isTypeaheadKey as s, useTypeahead as c } from "../../_internal/typeahead.js";
|
|
8
|
+
import l from "./menu.module.js";
|
|
9
|
+
import u, { useState as d } from "react";
|
|
10
|
+
import f from "classnames";
|
|
11
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
11
12
|
//#region src/components/overlay/Menu/Menu.tsx
|
|
12
|
-
var
|
|
13
|
+
var h = u.createContext({
|
|
13
14
|
expandedItems: /* @__PURE__ */ new Set(),
|
|
14
15
|
toggleItem: () => {},
|
|
15
16
|
containerRef: { current: null },
|
|
@@ -17,125 +18,135 @@ var f = s.createContext({
|
|
|
17
18
|
focusedIndex: 0,
|
|
18
19
|
setFocusedIndex: () => {},
|
|
19
20
|
registerItem: () => 0
|
|
20
|
-
}),
|
|
21
|
-
let e =
|
|
21
|
+
}), g = () => {
|
|
22
|
+
let e = u.useContext(h);
|
|
22
23
|
if (!e) throw Error("Menu sub-components must be used within a Menu");
|
|
23
24
|
return e;
|
|
24
|
-
},
|
|
25
|
-
let [
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
}, _ = ({ children: n, className: r, asChild: i = !1, mode: a = "vertical", defaultOpenKeys: m = [], "aria-label": g, "aria-labelledby": _ }) => {
|
|
26
|
+
let [v, y] = d(new Set(m)), [b, x] = d(0), S = u.useRef(0);
|
|
27
|
+
u.useEffect(() => {
|
|
28
|
+
S.current = 0;
|
|
28
29
|
});
|
|
29
|
-
let
|
|
30
|
-
let e =
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
|
|
30
|
+
let C = () => {
|
|
31
|
+
let e = S.current;
|
|
32
|
+
return S.current += 1, e;
|
|
33
|
+
}, w = (e) => {
|
|
34
|
+
y((t) => {
|
|
34
35
|
let n = new Set(t);
|
|
35
36
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
36
37
|
});
|
|
37
|
-
},
|
|
38
|
-
let t = Array.from(
|
|
38
|
+
}, T = u.useRef(null), E = c(), D = (e) => {
|
|
39
|
+
let t = Array.from(T.current?.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])") || []), n = t.indexOf(document.activeElement);
|
|
39
40
|
if (n !== -1) {
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
if (s(e, E.typing())) {
|
|
42
|
+
let r = o({
|
|
43
|
+
query: E.push(e.key),
|
|
44
|
+
current: n,
|
|
45
|
+
count: t.length,
|
|
46
|
+
getText: (e) => t[e].textContent ?? ""
|
|
47
|
+
});
|
|
48
|
+
r >= 0 && (e.preventDefault(), x(r), t[r].focus());
|
|
49
|
+
} else {
|
|
50
|
+
if (a === "vertical" || a === "inline") {
|
|
51
|
+
if (e.key === "ArrowDown") e.preventDefault(), t[(n + 1) % t.length]?.focus();
|
|
52
|
+
else if (e.key === "ArrowUp") e.preventDefault(), t[(n - 1 + t.length) % t.length]?.focus();
|
|
53
|
+
else if (e.key === "ArrowRight") {
|
|
54
|
+
let r = t[n];
|
|
55
|
+
r.getAttribute("aria-haspopup") === "true" && r.getAttribute("aria-expanded") === "false" && (e.preventDefault(), r.click());
|
|
56
|
+
} else if (e.key === "ArrowLeft") {
|
|
57
|
+
let r = t[n];
|
|
58
|
+
r.getAttribute("aria-haspopup") === "true" && r.getAttribute("aria-expanded") === "true" && (e.preventDefault(), r.click());
|
|
59
|
+
}
|
|
60
|
+
} else if (a === "horizontal") {
|
|
61
|
+
if (e.key === "ArrowRight") e.preventDefault(), t[(n + 1) % t.length]?.focus();
|
|
62
|
+
else if (e.key === "ArrowLeft") e.preventDefault(), t[(n - 1 + t.length) % t.length]?.focus();
|
|
63
|
+
else if (e.key === "ArrowDown") {
|
|
64
|
+
let r = t[n];
|
|
65
|
+
r.getAttribute("aria-haspopup") === "true" && r.getAttribute("aria-expanded") === "false" && (e.preventDefault(), r.click());
|
|
66
|
+
}
|
|
56
67
|
}
|
|
68
|
+
e.key === "Home" ? (e.preventDefault(), x(0), t[0]?.focus()) : e.key === "End" && (e.preventDefault(), x(t.length - 1), t[t.length - 1]?.focus());
|
|
57
69
|
}
|
|
58
|
-
e.key === "Home" ? (e.preventDefault(), v(0), t[0]?.focus()) : e.key === "End" && (e.preventDefault(), v(t.length - 1), t[t.length - 1]?.focus());
|
|
59
70
|
}
|
|
60
|
-
},
|
|
61
|
-
return /* @__PURE__ */
|
|
71
|
+
}, O = i ? e : "ul";
|
|
72
|
+
return /* @__PURE__ */ p(h.Provider, {
|
|
62
73
|
value: {
|
|
63
|
-
expandedItems:
|
|
64
|
-
toggleItem:
|
|
65
|
-
containerRef:
|
|
74
|
+
expandedItems: v,
|
|
75
|
+
toggleItem: w,
|
|
76
|
+
containerRef: T,
|
|
66
77
|
mode: a,
|
|
67
|
-
focusedIndex:
|
|
68
|
-
setFocusedIndex:
|
|
69
|
-
registerItem:
|
|
78
|
+
focusedIndex: b,
|
|
79
|
+
setFocusedIndex: x,
|
|
80
|
+
registerItem: C
|
|
70
81
|
},
|
|
71
|
-
children: /* @__PURE__ */
|
|
72
|
-
ref:
|
|
73
|
-
className:
|
|
82
|
+
children: /* @__PURE__ */ p(O, {
|
|
83
|
+
ref: T,
|
|
84
|
+
className: f("wim-menu", l.root, l[a], r),
|
|
74
85
|
role: "menu",
|
|
75
|
-
"aria-label":
|
|
76
|
-
"aria-labelledby":
|
|
77
|
-
onKeyDown:
|
|
78
|
-
children: /* @__PURE__ */
|
|
86
|
+
"aria-label": _ ? void 0 : g,
|
|
87
|
+
"aria-labelledby": _,
|
|
88
|
+
onKeyDown: D,
|
|
89
|
+
children: /* @__PURE__ */ p(t, { children: n })
|
|
79
90
|
})
|
|
80
91
|
});
|
|
81
|
-
},
|
|
82
|
-
let { focusedIndex:
|
|
92
|
+
}, v = ({ children: e, onClick: t, disabled: n = !1, danger: r = !1, className: i, icon: o, asChild: s = !1, ...c }) => {
|
|
93
|
+
let { focusedIndex: u, setFocusedIndex: m, registerItem: h } = g(), [_] = d(() => h()), v = u === _, y = (e) => {
|
|
83
94
|
e.stopPropagation(), !n && t && t();
|
|
84
95
|
}, b = {
|
|
85
|
-
className: l
|
|
96
|
+
className: f(l.item, i),
|
|
86
97
|
onClick: y,
|
|
87
|
-
onFocus: () =>
|
|
98
|
+
onFocus: () => m(_),
|
|
88
99
|
disabled: n,
|
|
89
100
|
danger: r,
|
|
90
|
-
icon:
|
|
101
|
+
icon: o,
|
|
91
102
|
role: "menuitem",
|
|
92
103
|
tabIndex: v ? 0 : -1,
|
|
93
104
|
onKeyDown: (e) => {
|
|
94
105
|
!n && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), y(e));
|
|
95
106
|
},
|
|
96
|
-
...
|
|
107
|
+
...c
|
|
97
108
|
};
|
|
98
|
-
return
|
|
109
|
+
return s ? /* @__PURE__ */ p("li", {
|
|
99
110
|
role: "none",
|
|
100
|
-
children: /* @__PURE__ */
|
|
111
|
+
children: /* @__PURE__ */ p(a, {
|
|
101
112
|
asChild: !0,
|
|
102
113
|
...b,
|
|
103
114
|
children: e
|
|
104
115
|
})
|
|
105
|
-
}) : /* @__PURE__ */
|
|
116
|
+
}) : /* @__PURE__ */ p(a, {
|
|
106
117
|
asChild: !0,
|
|
107
118
|
...b,
|
|
108
|
-
children: /* @__PURE__ */
|
|
119
|
+
children: /* @__PURE__ */ p("li", { children: e })
|
|
109
120
|
});
|
|
110
|
-
},
|
|
111
|
-
className: l
|
|
121
|
+
}, y = ({ children: e, title: t, className: n }) => /* @__PURE__ */ m("li", {
|
|
122
|
+
className: f(l.itemGroup, n),
|
|
112
123
|
role: "none",
|
|
113
|
-
children: [t && /* @__PURE__ */
|
|
114
|
-
className:
|
|
124
|
+
children: [t && /* @__PURE__ */ p("div", {
|
|
125
|
+
className: l.itemGroupTitle,
|
|
115
126
|
"aria-hidden": "true",
|
|
116
127
|
children: t
|
|
117
|
-
}), /* @__PURE__ */
|
|
118
|
-
className:
|
|
128
|
+
}), /* @__PURE__ */ p("ul", {
|
|
129
|
+
className: l.itemGroupList,
|
|
119
130
|
role: "group",
|
|
120
131
|
"aria-label": t || void 0,
|
|
121
132
|
children: e
|
|
122
133
|
})]
|
|
123
|
-
}),
|
|
124
|
-
let { expandedItems:
|
|
125
|
-
e.stopPropagation(), _(
|
|
134
|
+
}), b = ({ children: e, title: t, className: o, icon: s, itemKey: c }) => {
|
|
135
|
+
let { expandedItems: h, toggleItem: _, registerItem: v, focusedIndex: y, setFocusedIndex: b } = g(), x = h.has(c), [S] = d(() => v()), C = y === S, w = u.useId(), T = (e) => {
|
|
136
|
+
e.stopPropagation(), _(c);
|
|
126
137
|
};
|
|
127
|
-
return /* @__PURE__ */
|
|
128
|
-
className: l
|
|
138
|
+
return /* @__PURE__ */ m("li", {
|
|
139
|
+
className: f(l.submenu, x && l.open, o),
|
|
129
140
|
role: "none",
|
|
130
|
-
children: [/* @__PURE__ */
|
|
141
|
+
children: [/* @__PURE__ */ p(a, {
|
|
131
142
|
id: w,
|
|
132
|
-
className:
|
|
143
|
+
className: l.submenuTitle,
|
|
133
144
|
onClick: T,
|
|
134
145
|
onFocus: () => b(S),
|
|
135
|
-
icon:
|
|
136
|
-
rightSection: /* @__PURE__ */
|
|
137
|
-
className: l
|
|
138
|
-
children: /* @__PURE__ */
|
|
146
|
+
icon: s,
|
|
147
|
+
rightSection: /* @__PURE__ */ p("span", {
|
|
148
|
+
className: f(l.submenuArrow, x && l.open),
|
|
149
|
+
children: /* @__PURE__ */ p(i, {
|
|
139
150
|
component: r,
|
|
140
151
|
size: "sm"
|
|
141
152
|
})
|
|
@@ -148,26 +159,26 @@ var f = s.createContext({
|
|
|
148
159
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), T(e));
|
|
149
160
|
},
|
|
150
161
|
children: t
|
|
151
|
-
}), /* @__PURE__ */
|
|
162
|
+
}), /* @__PURE__ */ p(n, {
|
|
152
163
|
show: x,
|
|
153
164
|
preset: "fade",
|
|
154
|
-
className:
|
|
155
|
-
children: /* @__PURE__ */
|
|
156
|
-
className:
|
|
165
|
+
className: l.submenuList,
|
|
166
|
+
children: /* @__PURE__ */ p("ul", {
|
|
167
|
+
className: l.submenuList,
|
|
157
168
|
role: "menu",
|
|
158
169
|
"aria-labelledby": w,
|
|
159
170
|
children: e
|
|
160
171
|
})
|
|
161
172
|
})]
|
|
162
173
|
});
|
|
163
|
-
},
|
|
164
|
-
className: l
|
|
174
|
+
}, x = ({ className: e }) => /* @__PURE__ */ p("li", {
|
|
175
|
+
className: f(l.divider, e),
|
|
165
176
|
role: "separator"
|
|
166
|
-
}),
|
|
167
|
-
Item:
|
|
168
|
-
Group:
|
|
169
|
-
SubMenu:
|
|
170
|
-
Divider:
|
|
177
|
+
}), S = Object.assign(_, {
|
|
178
|
+
Item: v,
|
|
179
|
+
Group: y,
|
|
180
|
+
SubMenu: b,
|
|
181
|
+
Divider: x
|
|
171
182
|
});
|
|
172
183
|
//#endregion
|
|
173
|
-
export {
|
|
184
|
+
export { S as Menu, S as default, x as MenuDivider, v as MenuItem, y as MenuItemGroup, b as SubMenu };
|
package/dist/llms-full.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## What this is
|
|
6
6
|
|
|
7
|
-
**wimui** v0.
|
|
7
|
+
**wimui** v0.70.0 — a React 19 component library: 230 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
|
|
8
8
|
|
|
9
9
|
## Install & required setup
|
|
10
10
|
|