wimui 0.60.0 → 0.61.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/useInlineFloating.cjs +2 -0
- package/dist/components/_internal/useInlineFloating.d.ts +54 -0
- package/dist/components/_internal/useInlineFloating.js +61 -0
- package/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.js +96 -89
- package/dist/components/ai/ModelSelector/model-selector.module.cjs +1 -1
- package/dist/components/ai/ModelSelector/model-selector.module.js +1 -1
- package/dist/components/form/Cascader/Cascader.cjs +1 -1
- package/dist/components/form/Cascader/Cascader.js +89 -85
- package/dist/components/form/Cascader/cascader.module.cjs +1 -1
- package/dist/components/form/Cascader/cascader.module.js +6 -6
- package/dist/components/form/Combobox/Combobox.cjs +1 -1
- package/dist/components/form/Combobox/Combobox.js +108 -102
- package/dist/components/form/Combobox/combobox.module.cjs +1 -1
- package/dist/components/form/Combobox/combobox.module.js +1 -1
- package/dist/components/form/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/form/DatePicker/DatePicker.js +90 -85
- package/dist/components/form/DatePicker/date-picker.module.cjs +1 -1
- package/dist/components/form/DatePicker/date-picker.module.js +1 -1
- package/dist/components/form/Mentions/Mentions.cjs +1 -1
- package/dist/components/form/Mentions/Mentions.js +4 -4
- package/dist/components/form/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/form/MultiSelect/MultiSelect.js +80 -77
- package/dist/components/form/MultiSelect/multiselect.module.cjs +1 -1
- package/dist/components/form/MultiSelect/multiselect.module.js +1 -1
- package/dist/components/form/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/form/PhoneInput/PhoneInput.js +117 -111
- package/dist/components/form/PhoneInput/phone-input.module.cjs +1 -1
- package/dist/components/form/PhoneInput/phone-input.module.js +1 -1
- package/dist/components/form/Select/Select.cjs +1 -1
- package/dist/components/form/Select/Select.js +96 -89
- package/dist/components/form/Select/select.module.cjs +1 -1
- package/dist/components/form/Select/select.module.js +1 -1
- package/dist/components/form/SplitButton/SplitButton.cjs +1 -1
- package/dist/components/form/SplitButton/SplitButton.js +35 -31
- package/dist/components/form/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/form/TreeSelect/TreeSelect.js +115 -112
- package/dist/components/form/TreeSelect/tree-select.module.cjs +1 -1
- package/dist/components/form/TreeSelect/tree-select.module.js +6 -6
- package/dist/components/navigation/Anchor/Anchor.cjs +1 -1
- package/dist/components/navigation/Anchor/Anchor.d.ts +5 -1
- package/dist/components/navigation/Anchor/Anchor.js +32 -29
- package/dist/components/navigation/Menubar/Menubar.cjs +1 -1
- package/dist/components/navigation/Menubar/Menubar.js +102 -92
- package/dist/components/navigation/Menubar/menubar.module.cjs +1 -1
- package/dist/components/navigation/Menubar/menubar.module.js +1 -1
- package/dist/components/overlay/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/overlay/BottomSheet/BottomSheet.d.ts +7 -1
- package/dist/components/overlay/BottomSheet/BottomSheet.js +7 -6
- package/dist/components/overlay/HoverCard/HoverCard.cjs +1 -1
- package/dist/components/overlay/HoverCard/HoverCard.js +49 -43
- package/dist/components/overlay/HoverCard/hover-card.module.cjs +1 -1
- package/dist/components/overlay/HoverCard/hover-card.module.js +1 -1
- package/dist/llms-full.txt +3 -1
- package/dist/llms.txt +1 -1
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +4 -4
|
@@ -1,166 +1,169 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
3
|
import { useMergedRef as n } from "../../../hooks/useMergedRef.js";
|
|
4
|
-
import { Transition as
|
|
5
|
-
import { FocusTrap as
|
|
6
|
-
import { InputBase as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import p from "
|
|
12
|
-
import
|
|
4
|
+
import { Transition as r } from "../../layout/Transition/Transition.js";
|
|
5
|
+
import { FocusTrap as i } from "../../overlay/FocusTrap/FocusTrap.js";
|
|
6
|
+
import { InputBase as a } from "../InputBase/InputBase.js";
|
|
7
|
+
import { useInlineFloating as o } from "../../_internal/useInlineFloating.js";
|
|
8
|
+
import { FieldTemplate as s } from "../FieldTemplate/FieldTemplate.js";
|
|
9
|
+
import { TreeView as c } from "../../data-display/TreeView/TreeView.js";
|
|
10
|
+
import l from "./tree-select.module.js";
|
|
11
|
+
import { forwardRef as u, useEffect as d, useId as ee, useMemo as f, useRef as p, useState as m } from "react";
|
|
12
|
+
import h from "classnames";
|
|
13
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
13
14
|
//#region src/components/form/TreeSelect/TreeSelect.tsx
|
|
14
|
-
function
|
|
15
|
+
function v(e) {
|
|
15
16
|
return e.map((e) => ({
|
|
16
17
|
value: e.value,
|
|
17
18
|
label: e.label,
|
|
18
19
|
disabled: e.disabled,
|
|
19
20
|
icon: e.icon,
|
|
20
|
-
children: e.children ?
|
|
21
|
+
children: e.children ? v(e.children) : void 0
|
|
21
22
|
}));
|
|
22
23
|
}
|
|
23
|
-
var
|
|
24
|
-
let
|
|
25
|
-
|
|
24
|
+
var y = u(({ treeData: u = [], value: y, onChange: b, placeholder: x, label: S, error: C, required: w, layout: T, className: E, disabled: D = !1, multiple: O = !1, searchable: k = !1, defaultExpandedKeys: A = [], allowClear: te = !1, checkStrategy: ne = "cascade", id: re, width: ie, fullWidth: j = !1, asChild: ae = !1, children: oe, ...se }, ce) => {
|
|
25
|
+
let le = ee(), M = re || `wim-tree-select-${le}`, N = S ? `${M}-label` : void 0, P = C ? `${M}-error` : void 0, F = `${M}-trigger`, I = `${M}-dropdown`, [L, R] = m(!1), [z, B] = m(O ? [] : ""), V = p(null), H = p(null), U = y !== void 0, W = U ? y : z;
|
|
26
|
+
d(() => {
|
|
26
27
|
let e = (e) => {
|
|
27
|
-
|
|
28
|
+
V.current && !V.current.contains(e.target) && R(!1);
|
|
28
29
|
};
|
|
29
30
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
30
|
-
}, []),
|
|
31
|
-
if (
|
|
31
|
+
}, []), d(() => {
|
|
32
|
+
if (L) {
|
|
32
33
|
let e = setTimeout(() => {
|
|
33
|
-
let e =
|
|
34
|
-
e ? e.focus() : (
|
|
34
|
+
let e = V.current?.querySelector("[data-testid=\"tree-view-search-input\"]");
|
|
35
|
+
e ? e.focus() : (V.current?.querySelector("[data-testid=\"tree-view-root\"]"))?.focus();
|
|
35
36
|
}, 100);
|
|
36
37
|
return () => clearTimeout(e);
|
|
37
38
|
}
|
|
38
|
-
}, [
|
|
39
|
-
let
|
|
40
|
-
if (!
|
|
41
|
-
let e = !
|
|
42
|
-
|
|
39
|
+
}, [L]);
|
|
40
|
+
let G = () => {
|
|
41
|
+
if (!D) {
|
|
42
|
+
let e = !L;
|
|
43
|
+
R(e), e || H.current?.focus();
|
|
43
44
|
}
|
|
44
|
-
},
|
|
45
|
-
if (!
|
|
46
|
-
if (!
|
|
47
|
-
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(),
|
|
45
|
+
}, ue = (e) => {
|
|
46
|
+
if (!D) {
|
|
47
|
+
if (!L) {
|
|
48
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), R(!0));
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
51
|
+
e.key === "Escape" && (e.preventDefault(), R(!1), H.current?.focus());
|
|
51
52
|
}
|
|
52
|
-
},
|
|
53
|
+
}, K = f(() => {
|
|
53
54
|
let e = {}, t = (n) => {
|
|
54
55
|
n.forEach((n) => {
|
|
55
56
|
e[n.value] = n, n.children && t(n.children);
|
|
56
57
|
});
|
|
57
58
|
};
|
|
58
|
-
return t(
|
|
59
|
-
}, [
|
|
60
|
-
if (
|
|
61
|
-
let e = Array.isArray(
|
|
62
|
-
return e.length === 0 ? null : e.map((e) =>
|
|
59
|
+
return t(u), e;
|
|
60
|
+
}, [u]), de = () => {
|
|
61
|
+
if (O) {
|
|
62
|
+
let e = Array.isArray(W) ? W : [];
|
|
63
|
+
return e.length === 0 ? null : e.map((e) => K[e] ? K[e].label : e).reduce((e, t) => [
|
|
63
64
|
e,
|
|
64
65
|
", ",
|
|
65
66
|
t
|
|
66
67
|
]);
|
|
67
68
|
}
|
|
68
69
|
{
|
|
69
|
-
let e =
|
|
70
|
-
return e ?
|
|
70
|
+
let e = W;
|
|
71
|
+
return e ? K[e] ? K[e].label : e : null;
|
|
71
72
|
}
|
|
72
|
-
},
|
|
73
|
+
}, q = (e) => {
|
|
73
74
|
let t;
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
if (
|
|
77
|
-
let e =
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
label:
|
|
82
|
-
error:
|
|
83
|
-
required:
|
|
84
|
-
layout:
|
|
85
|
-
labelId:
|
|
86
|
-
errorId:
|
|
87
|
-
className:
|
|
88
|
-
children: /* @__PURE__ */
|
|
89
|
-
className:
|
|
90
|
-
ref:
|
|
91
|
-
...
|
|
75
|
+
O ? t = e : (t = e[0] || "", R(!1), H.current?.focus()), U || B(t), b && b(t);
|
|
76
|
+
}, fe = () => {
|
|
77
|
+
if (D) return;
|
|
78
|
+
let e = O ? [] : "";
|
|
79
|
+
U || B(e), b && b(e);
|
|
80
|
+
}, pe = f(() => v(u), [u]), J = f(() => O ? Array.isArray(W) ? W : [] : W ? [W] : [], [W, O]), Y = de(), { "aria-label": X, "aria-labelledby": Z, "aria-describedby": me, ...he } = se, Q = typeof x == "string" ? x : "Select", ge = ae ? e : "div", { setReference: $, setFloating: _e, floatingProps: ve } = o({ open: L && !D }), ye = n(V, ce, $);
|
|
81
|
+
return /* @__PURE__ */ g(s, {
|
|
82
|
+
label: S,
|
|
83
|
+
error: C,
|
|
84
|
+
required: w,
|
|
85
|
+
layout: T,
|
|
86
|
+
labelId: N,
|
|
87
|
+
errorId: P,
|
|
88
|
+
className: h(l.container, E),
|
|
89
|
+
children: /* @__PURE__ */ _(ge, {
|
|
90
|
+
className: h("wim-tree-select", l.root, j && l.fullWidth),
|
|
91
|
+
ref: ye,
|
|
92
|
+
...he,
|
|
92
93
|
children: [
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
disabled:
|
|
96
|
-
allowClear:
|
|
97
|
-
hasValue: !!
|
|
98
|
-
onClear:
|
|
99
|
-
intent:
|
|
100
|
-
width:
|
|
94
|
+
/* @__PURE__ */ g(t, { children: oe }),
|
|
95
|
+
/* @__PURE__ */ g(a, {
|
|
96
|
+
disabled: D,
|
|
97
|
+
allowClear: te,
|
|
98
|
+
hasValue: !!Y,
|
|
99
|
+
onClear: fe,
|
|
100
|
+
intent: C ? "danger" : "default",
|
|
101
|
+
width: ie,
|
|
101
102
|
fullWidth: j,
|
|
102
103
|
rightIcons: [{
|
|
103
104
|
name: "ChevronDownIcon",
|
|
104
|
-
rotated:
|
|
105
|
-
onClick:
|
|
105
|
+
rotated: L,
|
|
106
|
+
onClick: G,
|
|
106
107
|
decorative: !0
|
|
107
108
|
}],
|
|
108
|
-
className:
|
|
109
|
-
children: /* @__PURE__ */
|
|
110
|
-
id:
|
|
111
|
-
className:
|
|
112
|
-
onClick:
|
|
113
|
-
onKeyDown:
|
|
114
|
-
tabIndex:
|
|
109
|
+
className: h(L && l.open),
|
|
110
|
+
children: /* @__PURE__ */ g("div", {
|
|
111
|
+
id: F,
|
|
112
|
+
className: h(l.trigger, D && l.disabled),
|
|
113
|
+
onClick: G,
|
|
114
|
+
onKeyDown: ue,
|
|
115
|
+
tabIndex: D ? -1 : 0,
|
|
115
116
|
role: "combobox",
|
|
116
|
-
"aria-expanded":
|
|
117
|
+
"aria-expanded": L,
|
|
117
118
|
"aria-haspopup": "tree",
|
|
118
|
-
"aria-controls":
|
|
119
|
-
"aria-disabled":
|
|
120
|
-
"aria-labelledby":
|
|
121
|
-
"aria-label":
|
|
122
|
-
"aria-describedby":
|
|
123
|
-
"aria-required":
|
|
124
|
-
"aria-invalid": !!
|
|
125
|
-
ref:
|
|
126
|
-
children: /* @__PURE__ */
|
|
127
|
-
className:
|
|
128
|
-
children:
|
|
119
|
+
"aria-controls": L ? I : void 0,
|
|
120
|
+
"aria-disabled": D,
|
|
121
|
+
"aria-labelledby": N || Z,
|
|
122
|
+
"aria-label": S ? void 0 : X || Q,
|
|
123
|
+
"aria-describedby": P || me,
|
|
124
|
+
"aria-required": w,
|
|
125
|
+
"aria-invalid": !!C,
|
|
126
|
+
ref: H,
|
|
127
|
+
children: /* @__PURE__ */ g("div", {
|
|
128
|
+
className: h(l.value, !Y && l.placeholder),
|
|
129
|
+
children: Y || x
|
|
129
130
|
})
|
|
130
131
|
})
|
|
131
132
|
}),
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
show:
|
|
133
|
+
/* @__PURE__ */ g(r, {
|
|
134
|
+
show: L && !D,
|
|
134
135
|
preset: "fade",
|
|
135
|
-
className:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
className: l.dropdown,
|
|
137
|
+
ref: _e,
|
|
138
|
+
...ve,
|
|
139
|
+
children: /* @__PURE__ */ g("div", {
|
|
140
|
+
id: I,
|
|
141
|
+
children: /* @__PURE__ */ g(i, {
|
|
142
|
+
active: L,
|
|
140
143
|
initialFocus: !1,
|
|
141
|
-
children: /* @__PURE__ */
|
|
144
|
+
children: /* @__PURE__ */ g("div", {
|
|
142
145
|
role: "dialog",
|
|
143
146
|
"aria-modal": "true",
|
|
144
|
-
"aria-labelledby":
|
|
145
|
-
"aria-label":
|
|
147
|
+
"aria-labelledby": N || Z,
|
|
148
|
+
"aria-label": S ? void 0 : X || Q,
|
|
146
149
|
onKeyDown: (e) => {
|
|
147
|
-
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(),
|
|
150
|
+
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), R(!1), H.current?.focus());
|
|
148
151
|
},
|
|
149
|
-
children: /* @__PURE__ */
|
|
150
|
-
multiSelect:
|
|
151
|
-
defaultSelectedValues:
|
|
152
|
-
defaultCheckedValues:
|
|
153
|
-
nodes:
|
|
154
|
-
onCheckedChange:
|
|
155
|
-
onSelectedChange:
|
|
156
|
-
checkable:
|
|
157
|
-
checkStrategy:
|
|
158
|
-
searchable:
|
|
159
|
-
defaultExpandedValues:
|
|
152
|
+
children: /* @__PURE__ */ g(c, {
|
|
153
|
+
multiSelect: O,
|
|
154
|
+
defaultSelectedValues: J,
|
|
155
|
+
defaultCheckedValues: O ? J : [],
|
|
156
|
+
nodes: pe,
|
|
157
|
+
onCheckedChange: q,
|
|
158
|
+
onSelectedChange: q,
|
|
159
|
+
checkable: O,
|
|
160
|
+
checkStrategy: ne,
|
|
161
|
+
searchable: k,
|
|
162
|
+
defaultExpandedValues: A,
|
|
160
163
|
styles: {
|
|
161
|
-
root:
|
|
162
|
-
item:
|
|
163
|
-
search:
|
|
164
|
+
root: l.treeView,
|
|
165
|
+
item: l.treeViewItem,
|
|
166
|
+
search: l.treeViewSearch
|
|
164
167
|
}
|
|
165
168
|
})
|
|
166
169
|
})
|
|
@@ -171,6 +174,6 @@ var _ = s(({ treeData: s = [], value: _, onChange: v, placeholder: y, label: b,
|
|
|
171
174
|
})
|
|
172
175
|
});
|
|
173
176
|
});
|
|
174
|
-
|
|
177
|
+
y.displayName = "TreeSelect";
|
|
175
178
|
//#endregion
|
|
176
|
-
export {
|
|
179
|
+
export { y as TreeSelect };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_container_133hu_322`,t=`_root_133hu_332`,n=`_fullWidth_133hu_345`,r=`_label_133hu_349`,i=`_trigger_133hu_356`,a=`_disabled_133hu_369`,o=`_open_133hu_381`,s=`_value_133hu_389`,c=`_placeholder_133hu_390`,l=`_icon_133hu_393`,u=`_clear_133hu_413`,d=`_dropdown_133hu_425`,f=`_treeView_133hu_455`,p=`_treeViewItem_133hu_463`,m=`_treeViewSearch_133hu_466`,h={"wim-docs-container":`_wim-docs-container_133hu_87`,"wim-t":`_wim-t_133hu_290`,"react-flow":`_react-flow_133hu_313`,"react-flow__edges":`_react-flow__edges_133hu_314`,"react-flow__connectionline":`_react-flow__connectionline_133hu_315`,container:e,root:t,fullWidth:n,label:r,trigger:i,disabled:a,open:o,value:s,placeholder:c,icon:l,clear:u,dropdown:d,treeView:f,treeViewItem:p,treeViewSearch:m};exports.clear=u,exports.container=e,exports.default=h,exports.disabled=a,exports.dropdown=d,exports.fullWidth=n,exports.icon=l,exports.label=r,exports.open=o,exports.placeholder=c,exports.root=t,exports.treeView=f,exports.treeViewItem=p,exports.treeViewSearch=m,exports.trigger=i,exports.value=s;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/TreeSelect/tree-select.module.scss
|
|
3
|
-
var e = "
|
|
4
|
-
"wim-docs-container": "_wim-docs-
|
|
5
|
-
"wim-t": "_wim-
|
|
6
|
-
"react-flow": "_react-
|
|
7
|
-
"react-flow__edges": "_react-
|
|
8
|
-
"react-flow__connectionline": "_react-
|
|
3
|
+
var e = "_container_133hu_322", t = "_root_133hu_332", n = "_fullWidth_133hu_345", r = "_label_133hu_349", i = "_trigger_133hu_356", a = "_disabled_133hu_369", o = "_open_133hu_381", s = "_value_133hu_389", c = "_placeholder_133hu_390", l = "_icon_133hu_393", u = "_clear_133hu_413", d = "_dropdown_133hu_425", f = "_treeView_133hu_455", p = "_treeViewItem_133hu_463", m = "_treeViewSearch_133hu_466", h = {
|
|
4
|
+
"wim-docs-container": "_wim-docs-container_133hu_87",
|
|
5
|
+
"wim-t": "_wim-t_133hu_290",
|
|
6
|
+
"react-flow": "_react-flow_133hu_313",
|
|
7
|
+
"react-flow__edges": "_react-flow__edges_133hu_314",
|
|
8
|
+
"react-flow__connectionline": "_react-flow__connectionline_133hu_315",
|
|
9
9
|
container: e,
|
|
10
10
|
root: t,
|
|
11
11
|
fullWidth: n,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./anchor.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a=({items:e=[],bounds:a=5,offset:o=0,direction:s=`vertical`,className:c,style:l})=>{let[
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./anchor.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a=({items:e=[],bounds:a=5,offset:o=0,direction:s=`vertical`,className:c,style:l,"aria-label":u,"aria-labelledby":d})=>{let[f,p]=(0,n.useState)(``),[m,h]=(0,n.useState)({}),g=(0,n.useRef)(null),_=(e,t)=>{e.preventDefault();let n=t.replace(`#`,``),r=document.getElementById(n);r&&(window.scrollTo({top:r.offsetTop-o,behavior:`smooth`}),p(t))};(0,n.useLayoutEffect)(()=>{let t=()=>{let t=(e,n)=>{let r=[];return e.forEach(e=>{r.push({href:e.href,parentHref:n}),e.children&&(r=r.concat(t(e.children,n||e.href)))}),r},n=t(e),r=``,i=window.scrollY||document.documentElement.scrollTop,c=document.documentElement.scrollHeight,l=document.documentElement.clientHeight;if(i>0&&Math.ceil(i+l)>=c&&n.length>0){let e=n[n.length-1];r=s===`horizontal`&&e.parentHref?e.parentHref:e.href}else for(let e of n){let t=e.href.replace(`#`,``),n=document.getElementById(t);if(n){if(n.getBoundingClientRect().top<=o+a)r=s===`horizontal`&&e.parentHref?e.parentHref:e.href;else break}}r&&r!==f&&p(r)};return window.addEventListener(`scroll`,t),t(),()=>window.removeEventListener(`scroll`,t)},[e,o,a,f,s]);let v=(0,n.useCallback)(()=>{if(!f||!g.current)return;let e=g.current.querySelector(`a[href="${f}"]`);if(e){let n=g.current.getBoundingClientRect();if(s===`vertical`){let t=e.getBoundingClientRect();h({top:t.top-n.top,height:t.height,opacity:1})}else{let r=g.current.querySelector(`.${t.default.list}`);if(r){let t=e.getBoundingClientRect(),i=r.getBoundingClientRect(),a=t.left-i.left+r.scrollLeft,o=a-i.width/2+t.width/2,s=r.scrollWidth-i.width,c=Math.max(0,Math.min(o,s)),l=a-c+(i.left-n.left);h({left:l,width:t.width,opacity:1}),r.scrollTo({left:c,behavior:`smooth`})}else{let t=e.getBoundingClientRect();h({left:t.left-g.current.getBoundingClientRect().left,width:t.width,opacity:1})}}}else h({opacity:0})},[f,s]);(0,n.useLayoutEffect)(()=>{v()},[v]),(0,n.useEffect)(()=>{let e=g.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>v());return t.observe(e),e.querySelectorAll(`a`).forEach(e=>t.observe(e)),()=>t.disconnect()},[v,e]);let y=e=>(0,i.jsx)(`ul`,{className:(0,r.default)(t.default.list,t.default[s]),children:e.map(e=>(0,i.jsxs)(`li`,{className:(0,r.default)(t.default.item,f===e.href&&t.default.active),children:[(0,i.jsx)(`a`,{href:e.href,className:t.default.link,"aria-current":f===e.href?`location`:void 0,onClick:t=>_(t,e.href),title:typeof e.title==`string`?e.title:void 0,children:e.title}),e.children&&s===`vertical`&&y(e.children)]},e.key))});return(0,i.jsxs)(`div`,{className:(0,r.default)(`wim-anchor`,t.default.root,t.default[s],c),style:l,ref:g,role:u||d?`navigation`:void 0,"aria-label":d?void 0:u,"aria-labelledby":d,children:[(0,i.jsx)(`div`,{className:t.default.ink,children:(0,i.jsx)(`span`,{className:t.default.inkBall,style:m})}),y(e)]})};exports.Anchor=a,exports.default=a;
|
|
@@ -22,6 +22,10 @@ export interface AnchorProps {
|
|
|
22
22
|
className?: string;
|
|
23
23
|
/** Style attribute */
|
|
24
24
|
style?: React.CSSProperties;
|
|
25
|
+
/** Accessible name. When set, the anchor is exposed as a navigation landmark with this name. */
|
|
26
|
+
"aria-label"?: string;
|
|
27
|
+
/** ID of the element that labels the anchor. Takes precedence over `aria-label`. */
|
|
28
|
+
"aria-labelledby"?: string;
|
|
25
29
|
}
|
|
26
|
-
export declare const Anchor: ({ items, bounds, offset, direction, className, style, }: AnchorProps) => React.JSX.Element;
|
|
30
|
+
export declare const Anchor: ({ items, bounds, offset, direction, className, style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: AnchorProps) => React.JSX.Element;
|
|
27
31
|
export default Anchor;
|
|
@@ -4,14 +4,14 @@ import { useCallback as t, useEffect as n, useLayoutEffect as r, useRef as i, us
|
|
|
4
4
|
import o from "classnames";
|
|
5
5
|
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/navigation/Anchor/Anchor.tsx
|
|
7
|
-
var l = ({ items: l = [], bounds: u = 5, offset: d = 0, direction: f = "vertical", className: p, style: m }) => {
|
|
8
|
-
let [
|
|
7
|
+
var l = ({ items: l = [], bounds: u = 5, offset: d = 0, direction: f = "vertical", className: p, style: m, "aria-label": h, "aria-labelledby": g }) => {
|
|
8
|
+
let [_, v] = a(""), [y, b] = a({}), x = i(null), S = (e, t) => {
|
|
9
9
|
e.preventDefault();
|
|
10
10
|
let n = t.replace("#", ""), r = document.getElementById(n);
|
|
11
11
|
r && (window.scrollTo({
|
|
12
12
|
top: r.offsetTop - d,
|
|
13
13
|
behavior: "smooth"
|
|
14
|
-
}),
|
|
14
|
+
}), v(t));
|
|
15
15
|
};
|
|
16
16
|
r(() => {
|
|
17
17
|
let e = () => {
|
|
@@ -34,33 +34,33 @@ var l = ({ items: l = [], bounds: u = 5, offset: d = 0, direction: f = "vertical
|
|
|
34
34
|
else break;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
n && n !==
|
|
37
|
+
n && n !== _ && v(n);
|
|
38
38
|
};
|
|
39
39
|
return window.addEventListener("scroll", e), e(), () => window.removeEventListener("scroll", e);
|
|
40
40
|
}, [
|
|
41
41
|
l,
|
|
42
42
|
d,
|
|
43
43
|
u,
|
|
44
|
-
|
|
44
|
+
_,
|
|
45
45
|
f
|
|
46
46
|
]);
|
|
47
|
-
let
|
|
48
|
-
if (!
|
|
49
|
-
let t =
|
|
47
|
+
let C = t(() => {
|
|
48
|
+
if (!_ || !x.current) return;
|
|
49
|
+
let t = x.current.querySelector(`a[href="${_}"]`);
|
|
50
50
|
if (t) {
|
|
51
|
-
let n =
|
|
51
|
+
let n = x.current.getBoundingClientRect();
|
|
52
52
|
if (f === "vertical") {
|
|
53
53
|
let e = t.getBoundingClientRect();
|
|
54
|
-
|
|
54
|
+
b({
|
|
55
55
|
top: e.top - n.top,
|
|
56
56
|
height: e.height,
|
|
57
57
|
opacity: 1
|
|
58
58
|
});
|
|
59
59
|
} else {
|
|
60
|
-
let r =
|
|
60
|
+
let r = x.current.querySelector(`.${e.list}`);
|
|
61
61
|
if (r) {
|
|
62
62
|
let e = t.getBoundingClientRect(), i = r.getBoundingClientRect(), a = e.left - i.left + r.scrollLeft, o = a - i.width / 2 + e.width / 2, s = r.scrollWidth - i.width, c = Math.max(0, Math.min(o, s)), l = a - c + (i.left - n.left);
|
|
63
|
-
|
|
63
|
+
b({
|
|
64
64
|
left: l,
|
|
65
65
|
width: e.width,
|
|
66
66
|
opacity: 1
|
|
@@ -70,48 +70,51 @@ var l = ({ items: l = [], bounds: u = 5, offset: d = 0, direction: f = "vertical
|
|
|
70
70
|
});
|
|
71
71
|
} else {
|
|
72
72
|
let e = t.getBoundingClientRect();
|
|
73
|
-
|
|
74
|
-
left: e.left -
|
|
73
|
+
b({
|
|
74
|
+
left: e.left - x.current.getBoundingClientRect().left,
|
|
75
75
|
width: e.width,
|
|
76
76
|
opacity: 1
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
} else
|
|
81
|
-
}, [
|
|
80
|
+
} else b({ opacity: 0 });
|
|
81
|
+
}, [_, f]);
|
|
82
82
|
r(() => {
|
|
83
|
-
|
|
84
|
-
}, [
|
|
85
|
-
let e =
|
|
83
|
+
C();
|
|
84
|
+
}, [C]), n(() => {
|
|
85
|
+
let e = x.current;
|
|
86
86
|
if (!e || typeof ResizeObserver > "u") return;
|
|
87
|
-
let t = new ResizeObserver(() =>
|
|
87
|
+
let t = new ResizeObserver(() => C());
|
|
88
88
|
return t.observe(e), e.querySelectorAll("a").forEach((e) => t.observe(e)), () => t.disconnect();
|
|
89
|
-
}, [
|
|
90
|
-
let
|
|
89
|
+
}, [C, l]);
|
|
90
|
+
let w = (t) => /* @__PURE__ */ s("ul", {
|
|
91
91
|
className: o(e.list, e[f]),
|
|
92
92
|
children: t.map((t) => /* @__PURE__ */ c("li", {
|
|
93
|
-
className: o(e.item,
|
|
93
|
+
className: o(e.item, _ === t.href && e.active),
|
|
94
94
|
children: [/* @__PURE__ */ s("a", {
|
|
95
95
|
href: t.href,
|
|
96
96
|
className: e.link,
|
|
97
|
-
"aria-current":
|
|
98
|
-
onClick: (e) =>
|
|
97
|
+
"aria-current": _ === t.href ? "location" : void 0,
|
|
98
|
+
onClick: (e) => S(e, t.href),
|
|
99
99
|
title: typeof t.title == "string" ? t.title : void 0,
|
|
100
100
|
children: t.title
|
|
101
|
-
}), t.children && f === "vertical" &&
|
|
101
|
+
}), t.children && f === "vertical" && w(t.children)]
|
|
102
102
|
}, t.key))
|
|
103
103
|
});
|
|
104
104
|
return /* @__PURE__ */ c("div", {
|
|
105
105
|
className: o("wim-anchor", e.root, e[f], p),
|
|
106
106
|
style: m,
|
|
107
|
-
ref:
|
|
107
|
+
ref: x,
|
|
108
|
+
role: h || g ? "navigation" : void 0,
|
|
109
|
+
"aria-label": g ? void 0 : h,
|
|
110
|
+
"aria-labelledby": g,
|
|
108
111
|
children: [/* @__PURE__ */ s("div", {
|
|
109
112
|
className: e.ink,
|
|
110
113
|
children: /* @__PURE__ */ s("span", {
|
|
111
114
|
className: e.inkBall,
|
|
112
|
-
style:
|
|
115
|
+
style: y
|
|
113
116
|
})
|
|
114
|
-
}),
|
|
117
|
+
}), w(l)]
|
|
115
118
|
});
|
|
116
119
|
};
|
|
117
120
|
//#endregion
|
|
@@ -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("../../_internal/BaseListItem/BaseListItem.cjs"),i=require("./menubar.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("../../_internal/BaseListItem/BaseListItem.cjs"),i=require("../../_internal/useInlineFloating.cjs"),a=require("./menubar.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=(0,o.createContext)(null),u=(0,o.createContext)(null),d=()=>{let e=(0,o.useContext)(l);if(!e)throw Error(`Menubar compound parts must be used within <Menubar>`);return e},f=()=>{let e=(0,o.useContext)(u);if(!e)throw Error(`Menubar.Trigger/Content/Item must be used within <Menubar.Menu>`);return e},p=o.default.forwardRef(({asChild:e=!1,className:n,children:r,onKeyDown:i,...u},d)=>{let[f,p]=(0,o.useState)(null),m=(0,o.useRef)(new Map),h=(0,o.useRef)(null),g=(0,o.useCallback)(e=>{h.current=e,typeof d==`function`?d(e):d&&(d.current=e)},[d]),_=(0,o.useCallback)((e,t)=>{t?m.current.set(e,t):m.current.delete(e)},[]),v=(0,o.useCallback)(()=>Array.from(m.current.keys()),[]),y=(0,o.useCallback)(e=>{m.current.get(e)?.focus()},[]);(0,o.useEffect)(()=>{if(!f)return;let e=e=>{h.current&&!h.current.contains(e.target)&&p(null)},t=e=>{e.key===`Escape`&&(p(null),f&&y(f))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[f,y]);let b=e=>{if(i?.(e),e.defaultPrevented)return;let t=v();if(t.length===0)return;let n=f??t.find(e=>m.current.get(e)===document.activeElement)??null;if(!n)return;let r=t.indexOf(n);if(!(r<0)){if(e.key===`ArrowRight`){e.preventDefault();let n=t[(r+1)%t.length];f&&p(n),y(n)}else if(e.key===`ArrowLeft`){e.preventDefault();let n=t[(r-1+t.length)%t.length];f&&p(n),y(n)}else if(e.key===`Home`){e.preventDefault();let n=t[0];f&&p(n),y(n)}else if(e.key===`End`){e.preventDefault();let n=t[t.length-1];f&&p(n),y(n)}}},x=(0,o.useMemo)(()=>({openMenuId:f,setOpenMenuId:p,registerTrigger:_,getTriggerIds:v,focusTrigger:y}),[f,_,v,y]),S=e?t.Root:`div`;return(0,c.jsx)(l.Provider,{value:x,children:(0,c.jsx)(S,{ref:g,role:`menubar`,className:(0,s.default)(`wim-menubar`,a.default.root,n),onKeyDown:b,...u,children:(0,c.jsx)(t.Slottable,{children:r})})})});p.displayName=`Menubar`;var m=o.default.forwardRef(({value:e,disabled:t=!1,className:n,children:r,...i},l)=>{let{openMenuId:f,setOpenMenuId:p,focusTrigger:m}=d(),h=(0,o.useId)(),g=`wim-menubar-trigger-${e}-${h}`,_=`wim-menubar-content-${e}-${h}`,v=f===e,y=()=>{t||p(e)},b=()=>{m(e),p(null)},x=()=>{t||p(v?null:e)},S=(0,o.useMemo)(()=>({menuId:e,triggerId:g,contentId:_,isOpen:v,open:y,close:b,toggle:x}),[e,g,_,v,t]);return(0,c.jsx)(u.Provider,{value:S,children:(0,c.jsx)(`div`,{ref:l,role:`none`,"data-disabled":t||void 0,className:(0,s.default)(a.default.menu,n),...i,children:r})})});m.displayName=`Menubar.Menu`;var h=o.default.forwardRef(({asChild:e=!1,className:n,children:r,onKeyDown:i,onMouseEnter:l,...u},p)=>{let{openMenuId:m,registerTrigger:h}=d(),{triggerId:g,contentId:_,isOpen:v,open:y,toggle:b,menuId:x}=f(),S=!!u.disabled,C=(0,o.useCallback)(e=>{h(x,e),typeof p==`function`?p(e):p&&(p.current=e)},[h,x,p]),w=e=>{i?.(e),!(e.defaultPrevented||S)&&(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),y())},T=e=>{l?.(e),m&&!S&&y()};return(0,c.jsx)(e?t.Root:`button`,{...u,ref:C,type:e?void 0:`button`,id:g,role:`menuitem`,"aria-haspopup":`menu`,"aria-expanded":v,"aria-controls":v?_:void 0,disabled:S,className:(0,s.default)(a.default.trigger,v&&a.default.triggerOpen,n),onClick:b,onKeyDown:w,onMouseEnter:T,children:(0,c.jsx)(t.Slottable,{children:r})})});h.displayName=`Menubar.Trigger`;var g=o.default.forwardRef(({align:e=`start`,className:t,children:r,...l},u)=>{let{contentId:d,triggerId:p,isOpen:m,close:h}=f(),[g,_]=(0,o.useState)(-1),[v,y]=(0,o.useState)(m),b=(0,o.useRef)(null);m!==v&&(y(m),_(m?0:-1));let{setReference:x,setFloating:S,floatingProps:C}=i.useInlineFloating({open:m}),w=(0,o.useCallback)(e=>{b.current=e,S(e),x(e?.parentElement??null),typeof u==`function`?u(e):u&&(u.current=e)},[u,S,x]);(0,o.useEffect)(()=>{!m||g<0||Array.from(b.current?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)??[])[g]?.focus()},[g,m]);let T=e=>{let t=Array.from(b.current?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)??[]);if(t.length!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),_(e=>e<t.length-1?e+1:0);break;case`ArrowUp`:e.preventDefault(),_(e=>e>0?e-1:t.length-1);break;case`Home`:e.preventDefault(),_(0);break;case`End`:e.preventDefault(),_(t.length-1);break;case`Tab`:h()}};return(0,c.jsx)(n.Transition,{...l,ref:w,show:m,preset:`fade`,id:d,role:`menu`,"aria-labelledby":p,className:(0,s.default)(a.default.content,e===`end`?a.default.alignEnd:a.default.alignStart,t),onKeyDown:T,"data-side":C[`data-side`],style:{...l.style,...C.style},children:r})});g.displayName=`Menubar.Content`;var _=o.default.forwardRef(({children:e,onSelect:t,onClick:n,disabled:i=!1,className:o,...l},u)=>{let{close:d}=f(),p=e=>{i||(e.stopPropagation(),t?.(),n?.(e),d())};return(0,c.jsx)(r.BaseListItem,{...l,ref:u,className:(0,s.default)(a.default.item,o),disabled:i,role:`menuitem`,tabIndex:-1,onClick:p,onKeyDown:e=>{!i&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p(e))},children:e})});_.displayName=`Menubar.Item`;var v=o.default.forwardRef(({className:e,...t},n)=>(0,c.jsx)(`div`,{ref:n,role:`separator`,className:(0,s.default)(a.default.separator,e),...t}));v.displayName=`Menubar.Separator`;var y=p;y.Menu=m,y.Trigger=h,y.Content=g,y.Item=_,y.Separator=v,exports.Menubar=y,exports.default=y;
|