haze-ui 1.27.0 → 1.28.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/Calendar/Calendar.js +222 -151
- package/dist/components/Cascader/Cascader.js +180 -146
- package/dist/components/Chart/Chart.js +12 -9
- package/dist/components/Chart/chart-elements.js +118 -42
- package/dist/components/CodeBlock/CodeBlock.js +39 -9
- package/dist/components/Combobox/Combobox.js +107 -99
- package/dist/components/DataTable/DataTable.js +224 -221
- package/dist/components/DataTable/csv.js +29 -0
- package/dist/components/DataTable/index.js +3 -2
- package/dist/components/DateRangePicker/DateRangePicker.js +31 -16
- package/dist/components/DateRangePicker/presets.js +43 -0
- package/dist/components/Datepicker/Datepicker.js +12 -11
- package/dist/components/Datepicker/DatepickerCore.js +72 -51
- package/dist/components/Datepicker/datetime.js +23 -0
- package/dist/components/Descriptions/Descriptions.js +46 -0
- package/dist/components/Descriptions/index.js +3 -0
- package/dist/components/DiffViewer/DiffViewer.js +31 -30
- package/dist/components/FilePreview/FilePreview.js +135 -0
- package/dist/components/FilePreview/file-preview-format.js +23 -0
- package/dist/components/FilePreview/index.js +3 -0
- package/dist/components/FloatButton/FloatButton.js +42 -0
- package/dist/components/FloatButton/FloatButtonGroup.js +58 -0
- package/dist/components/FloatButton/float-button-context.js +9 -0
- package/dist/components/FloatButton/float-button-glyphs.js +26 -0
- package/dist/components/FloatButton/float-button-styles.js +14 -0
- package/dist/components/FloatButton/index.js +4 -0
- package/dist/components/InlineCompletion/InlineCompletion.js +81 -0
- package/dist/components/InlineCompletion/index.js +3 -0
- package/dist/components/JsonView/JsonView.js +209 -0
- package/dist/components/JsonView/index.js +3 -0
- package/dist/components/JsonView/json-view-utils.js +24 -0
- package/dist/components/LocaleProvider/index.js +5 -4
- package/dist/components/LocaleProvider/ja-jp.js +222 -0
- package/dist/components/LocaleProvider/locale.js +42 -4
- package/dist/components/LocaleProvider/useStrings.js +13 -11
- package/dist/components/LocaleProvider/zh-cn.js +42 -4
- package/dist/components/Masonry/Masonry.js +29 -0
- package/dist/components/Masonry/index.js +3 -0
- package/dist/components/Masonry/masonry-distribute.js +15 -0
- package/dist/components/Select/Select.js +14 -13
- package/dist/components/Select/SelectCore.js +27 -26
- package/dist/components/Select/SelectFloating.js +76 -68
- package/dist/components/Signature/Signature.js +165 -0
- package/dist/components/Signature/index.js +3 -0
- package/dist/components/Signature/signature-points.js +28 -0
- package/dist/components/Sources/Sources.js +109 -0
- package/dist/components/Sources/index.js +3 -0
- package/dist/components/TagGroup/SortableTagGroup.js +26 -0
- package/dist/components/TagGroup/TagGroup.js +7 -21
- package/dist/components/TagGroup/TagGroupItem.js +1 -1
- package/dist/components/TagGroup/index.js +2 -1
- package/dist/components/TagGroup/tag-group-styles.js +7 -0
- package/dist/components/TagInput/SortableTagInput.js +24 -0
- package/dist/components/TagInput/SortableTagInputCore.js +52 -0
- package/dist/components/TagInput/TagInput.js +9 -10
- package/dist/components/TagInput/TagInputCore.js +61 -84
- package/dist/components/TagInput/index.js +3 -1
- package/dist/components/TagInput/tag-input-styles.js +7 -0
- package/dist/components/Toast/Toast.js +44 -43
- package/dist/components/Tree/Tree.js +184 -121
- package/dist/components/Tree/TreeItem.js +91 -57
- package/dist/components/Tree/utils.js +57 -1
- package/dist/components/Upload/Upload.js +12 -9
- package/dist/components/Upload/UploadCore.js +130 -124
- package/dist/components/Upload/UploadList.js +164 -36
- package/dist/css/bottom-sheet.css +1 -1
- package/dist/css/cascader.css +1 -1
- package/dist/css/datepicker.css +1 -1
- package/dist/css/descriptions.css +2 -0
- package/dist/css/dialog.css +1 -1
- package/dist/css/drawer.css +1 -1
- package/dist/css/file-preview.css +2 -0
- package/dist/css/float-button.css +2 -0
- package/dist/css/inline-completion.css +2 -0
- package/dist/css/json-view.css +2 -0
- package/dist/css/masonry.css +2 -0
- package/dist/css/signature.css +2 -0
- package/dist/css/sources.css +2 -0
- package/dist/css/tag-group.css +2 -2
- package/dist/css/tag-input.css +2 -3
- package/dist/css/tree.css +2 -2
- package/dist/css/upload.css +1 -1
- package/dist/css-manifest.json +15 -0
- package/dist/haze-ui.css +20 -13
- package/dist/headless/index.js +18 -6
- package/dist/hooks/useDarkMode.js +27 -0
- package/dist/index.js +207 -192
- package/dist/registry.json +210 -34
- package/dist/types/components/Cascader/Cascader.d.ts +20 -1
- package/dist/types/components/Chart/Chart.d.ts +27 -13
- package/dist/types/components/Chart/chart-elements.d.ts +62 -10
- package/dist/types/components/Chart/index.d.ts +1 -1
- package/dist/types/components/CodeBlock/CodeBlock.d.ts +19 -2
- package/dist/types/components/CodeBlock/index.d.ts +1 -1
- package/dist/types/components/Combobox/Combobox.d.ts +11 -1
- package/dist/types/components/DataTable/DataTable.d.ts +36 -1
- package/dist/types/components/DataTable/csv.d.ts +36 -0
- package/dist/types/components/DataTable/features.d.ts +6 -0
- package/dist/types/components/DataTable/index.d.ts +2 -0
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +15 -3
- package/dist/types/components/DateRangePicker/index.d.ts +1 -1
- package/dist/types/components/DateRangePicker/presets.d.ts +23 -0
- package/dist/types/components/Datepicker/Datepicker.d.ts +5 -1
- package/dist/types/components/Datepicker/DatepickerCore.d.ts +6 -1
- package/dist/types/components/Datepicker/datetime.d.ts +27 -0
- package/dist/types/components/Descriptions/Descriptions.d.ts +30 -0
- package/dist/types/components/Descriptions/index.d.ts +2 -0
- package/dist/types/components/FilePreview/FilePreview.d.ts +35 -0
- package/dist/types/components/FilePreview/file-preview-format.d.ts +20 -0
- package/dist/types/components/FilePreview/index.d.ts +2 -0
- package/dist/types/components/FloatButton/FloatButton.d.ts +43 -0
- package/dist/types/components/FloatButton/FloatButtonGroup.d.ts +33 -0
- package/dist/types/components/FloatButton/float-button-context.d.ts +11 -0
- package/dist/types/components/FloatButton/float-button-glyphs.d.ts +3 -0
- package/dist/types/components/FloatButton/float-button-styles.d.ts +58 -0
- package/dist/types/components/FloatButton/index.d.ts +4 -0
- package/dist/types/components/InlineCompletion/InlineCompletion.d.ts +29 -0
- package/dist/types/components/InlineCompletion/index.d.ts +2 -0
- package/dist/types/components/JsonView/JsonView.d.ts +26 -0
- package/dist/types/components/JsonView/index.d.ts +2 -0
- package/dist/types/components/JsonView/json-view-utils.d.ts +22 -0
- package/dist/types/components/LocaleProvider/index.d.ts +1 -0
- package/dist/types/components/LocaleProvider/ja-jp.d.ts +13 -0
- package/dist/types/components/LocaleProvider/locale.d.ts +44 -0
- package/dist/types/components/Masonry/Masonry.d.ts +34 -0
- package/dist/types/components/Masonry/index.d.ts +2 -0
- package/dist/types/components/Masonry/masonry-distribute.d.ts +16 -0
- package/dist/types/components/Select/Select.d.ts +13 -1
- package/dist/types/components/Select/SelectCore.d.ts +10 -1
- package/dist/types/components/Select/SelectFloating.d.ts +12 -1
- package/dist/types/components/Signature/Signature.d.ts +51 -0
- package/dist/types/components/Signature/index.d.ts +2 -0
- package/dist/types/components/Signature/signature-points.d.ts +31 -0
- package/dist/types/components/Sources/Sources.d.ts +37 -0
- package/dist/types/components/Sources/index.d.ts +2 -0
- package/dist/types/components/TagGroup/SortableTagGroup.d.ts +20 -0
- package/dist/types/components/TagGroup/TagGroup.d.ts +4 -13
- package/dist/types/components/TagGroup/index.d.ts +2 -0
- package/dist/types/components/TagGroup/tag-group-styles.d.ts +7 -0
- package/dist/types/components/TagInput/SortableTagInput.d.ts +34 -0
- package/dist/types/components/TagInput/SortableTagInputCore.d.ts +18 -0
- package/dist/types/components/TagInput/TagInput.d.ts +1 -8
- package/dist/types/components/TagInput/TagInputCore.d.ts +4 -10
- package/dist/types/components/TagInput/index.d.ts +4 -0
- package/dist/types/components/TagInput/tag-input-styles.d.ts +12 -0
- package/dist/types/components/Tree/Tree.d.ts +1 -1
- package/dist/types/components/Tree/TreeItem.d.ts +11 -1
- package/dist/types/components/Tree/types.d.ts +25 -0
- package/dist/types/components/Tree/utils.d.ts +41 -0
- package/dist/types/components/Upload/Upload.d.ts +10 -1
- package/dist/types/components/Upload/UploadCore.d.ts +21 -1
- package/dist/types/components/Upload/UploadList.d.ts +8 -2
- package/dist/types/headless/index.d.ts +221 -4
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/useDarkMode.d.ts +40 -0
- package/dist/types/index.d.ts +28 -11
- package/dist/types/utils/sortable-handle.d.ts +25 -0
- package/dist/types/utils/sortable-shared.d.ts +12 -24
- package/dist/utils/sortable-handle.js +12 -0
- package/dist/utils/sortable-shared.js +8 -16
- package/dist/utils/sortable.js +2 -1
- package/dist/utils/submenu.js +7 -5
- package/package.json +65 -5
|
@@ -1,88 +1,164 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
|
-
import { Area as r, AreaChart as i, Bar as a, BarChart as o, CartesianGrid as s, Legend as c, Line as l, LineChart as u,
|
|
3
|
+
import { Area as r, AreaChart as i, Bar as a, BarChart as o, CartesianGrid as s, Legend as c, Line as l, LineChart as u, Pie as d, PieChart as f, ResponsiveContainer as p, Tooltip as m, XAxis as h, YAxis as g } from "recharts";
|
|
4
4
|
//#region src/lib/components/Chart/chart-elements.tsx
|
|
5
|
-
var
|
|
5
|
+
var _ = [
|
|
6
6
|
"var(--haze-color-primary)",
|
|
7
7
|
"var(--haze-color-info)",
|
|
8
8
|
"var(--haze-color-success)",
|
|
9
9
|
"var(--haze-color-warning)",
|
|
10
10
|
"var(--haze-color-danger)"
|
|
11
|
-
],
|
|
11
|
+
], v = "var(--haze-color-border)", y = {
|
|
12
12
|
fontSize: "var(--haze-text-sm)",
|
|
13
13
|
fill: "var(--haze-color-text-secondary)"
|
|
14
|
-
},
|
|
14
|
+
}, b = {
|
|
15
15
|
fontSize: "var(--haze-text-sm)",
|
|
16
16
|
color: "var(--haze-color-text)"
|
|
17
|
-
},
|
|
18
|
-
function
|
|
19
|
-
return e
|
|
17
|
+
}, x = { fontSize: "var(--haze-text-sm)" };
|
|
18
|
+
function S(e) {
|
|
19
|
+
return _[e % _.length];
|
|
20
|
+
}
|
|
21
|
+
function C(e) {
|
|
22
|
+
return e.map((e) => ({
|
|
20
23
|
key: e.key,
|
|
21
24
|
label: e.label ?? e.key,
|
|
22
|
-
color: e.color
|
|
25
|
+
color: e.color
|
|
23
26
|
}));
|
|
24
27
|
}
|
|
25
|
-
function
|
|
26
|
-
let { key:
|
|
28
|
+
function w(e, n, i = 0) {
|
|
29
|
+
let { key: o, label: s } = n, c = n.color ?? S(i);
|
|
27
30
|
switch (e) {
|
|
28
31
|
case "area": return /* @__PURE__ */ t(r, {
|
|
29
|
-
dataKey:
|
|
30
|
-
name:
|
|
31
|
-
stroke:
|
|
32
|
-
fill:
|
|
33
|
-
},
|
|
32
|
+
dataKey: o,
|
|
33
|
+
name: s,
|
|
34
|
+
stroke: c,
|
|
35
|
+
fill: c
|
|
36
|
+
}, o);
|
|
34
37
|
case "bar": return /* @__PURE__ */ t(a, {
|
|
35
|
-
dataKey:
|
|
36
|
-
name:
|
|
37
|
-
fill:
|
|
38
|
-
},
|
|
38
|
+
dataKey: o,
|
|
39
|
+
name: s,
|
|
40
|
+
fill: c
|
|
41
|
+
}, o);
|
|
39
42
|
case "line": return /* @__PURE__ */ t(l, {
|
|
40
|
-
dataKey:
|
|
41
|
-
name:
|
|
42
|
-
stroke:
|
|
43
|
-
},
|
|
43
|
+
dataKey: o,
|
|
44
|
+
name: s,
|
|
45
|
+
stroke: c
|
|
46
|
+
}, o);
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
|
-
function
|
|
49
|
+
function T(e, t, n) {
|
|
50
|
+
if (t <= 1) return {
|
|
51
|
+
innerRadius: n,
|
|
52
|
+
outerRadius: "80%"
|
|
53
|
+
};
|
|
54
|
+
let r = typeof n == "string" ? Number.parseFloat(n) : 0, i = Number.isFinite(r) ? Math.max(r, 0) : 0, a = (80 - i) / t;
|
|
55
|
+
return {
|
|
56
|
+
innerRadius: `${i + e * a}%`,
|
|
57
|
+
outerRadius: `${i + (e + 1) * a}%`
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function E(e) {
|
|
61
|
+
let { entry: n, data: r, nameKey: i, ringIndex: a, ringCount: o, innerRadius: s } = e, c = T(a, o, s), l = r.map((e, t) => ({
|
|
62
|
+
...e,
|
|
63
|
+
fill: n.color ?? S(t)
|
|
64
|
+
}));
|
|
65
|
+
return /* @__PURE__ */ t(d, {
|
|
66
|
+
data: l,
|
|
67
|
+
dataKey: n.key,
|
|
68
|
+
nameKey: i,
|
|
69
|
+
innerRadius: c.innerRadius,
|
|
70
|
+
outerRadius: c.outerRadius,
|
|
71
|
+
stroke: "var(--haze-color-bg)"
|
|
72
|
+
}, n.key);
|
|
73
|
+
}
|
|
74
|
+
function D(e, n, r, a = "horizontal") {
|
|
47
75
|
switch (e) {
|
|
48
76
|
case "area": return /* @__PURE__ */ t(i, {
|
|
49
77
|
data: n,
|
|
78
|
+
layout: a,
|
|
50
79
|
children: r
|
|
51
80
|
});
|
|
52
81
|
case "bar": return /* @__PURE__ */ t(o, {
|
|
53
82
|
data: n,
|
|
83
|
+
layout: a,
|
|
54
84
|
children: r
|
|
55
85
|
});
|
|
56
86
|
case "line": return /* @__PURE__ */ t(u, {
|
|
87
|
+
data: n,
|
|
88
|
+
layout: a,
|
|
89
|
+
children: r
|
|
90
|
+
});
|
|
91
|
+
case "pie": return /* @__PURE__ */ t(f, {
|
|
57
92
|
data: n,
|
|
58
93
|
children: r
|
|
59
94
|
});
|
|
60
95
|
}
|
|
61
96
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
97
|
+
function O(e) {
|
|
98
|
+
return (t) => {
|
|
99
|
+
let { payload: n, label: r } = t;
|
|
100
|
+
return e({
|
|
101
|
+
label: r,
|
|
102
|
+
entries: (n ?? []).map((e) => ({
|
|
103
|
+
name: String(e.name ?? e.dataKey ?? ""),
|
|
104
|
+
value: e.value ?? "",
|
|
105
|
+
color: e.color ?? "",
|
|
106
|
+
dataEntry: e.payload
|
|
107
|
+
}))
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function k(r) {
|
|
112
|
+
let { type: i, data: a, xKey: o, showGrid: l, showTooltip: u, showLegend: d, series: f, layout: _ = "horizontal", innerRadius: S = 0, renderTooltip: C } = r, T = C ? O(C) : void 0;
|
|
113
|
+
return i === "pie" ? /* @__PURE__ */ t(p, {
|
|
114
|
+
width: "100%",
|
|
115
|
+
height: "100%",
|
|
116
|
+
children: D(i, a, /* @__PURE__ */ n(e, { children: [
|
|
117
|
+
u && /* @__PURE__ */ t(m, {
|
|
118
|
+
contentStyle: b,
|
|
119
|
+
content: T
|
|
120
|
+
}),
|
|
121
|
+
d && /* @__PURE__ */ t(c, { wrapperStyle: x }),
|
|
122
|
+
f.map((e, t) => E({
|
|
123
|
+
entry: e,
|
|
124
|
+
data: a,
|
|
125
|
+
nameKey: o,
|
|
126
|
+
ringIndex: t,
|
|
127
|
+
ringCount: f.length,
|
|
128
|
+
innerRadius: S
|
|
129
|
+
}))
|
|
130
|
+
] }))
|
|
131
|
+
}) : /* @__PURE__ */ t(p, {
|
|
65
132
|
width: "100%",
|
|
66
133
|
height: "100%",
|
|
67
|
-
children:
|
|
134
|
+
children: D(i, a, /* @__PURE__ */ n(e, { children: [
|
|
68
135
|
l && /* @__PURE__ */ t(s, { stroke: "var(--haze-color-border)" }),
|
|
69
|
-
/* @__PURE__ */ t(
|
|
136
|
+
_ === "vertical" ? /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t(h, {
|
|
137
|
+
type: "number",
|
|
138
|
+
stroke: v,
|
|
139
|
+
tick: y
|
|
140
|
+
}), /* @__PURE__ */ t(g, {
|
|
141
|
+
type: "category",
|
|
70
142
|
dataKey: o,
|
|
71
|
-
stroke:
|
|
72
|
-
tick:
|
|
73
|
-
}),
|
|
74
|
-
|
|
75
|
-
stroke:
|
|
76
|
-
tick:
|
|
77
|
-
}),
|
|
78
|
-
|
|
143
|
+
stroke: v,
|
|
144
|
+
tick: y
|
|
145
|
+
})] }) : /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t(h, {
|
|
146
|
+
dataKey: o,
|
|
147
|
+
stroke: v,
|
|
148
|
+
tick: y
|
|
149
|
+
}), /* @__PURE__ */ t(g, {
|
|
150
|
+
stroke: v,
|
|
151
|
+
tick: y
|
|
152
|
+
})] }),
|
|
153
|
+
u && /* @__PURE__ */ t(m, {
|
|
79
154
|
cursor: { stroke: "var(--haze-color-border)" },
|
|
80
|
-
contentStyle:
|
|
155
|
+
contentStyle: b,
|
|
156
|
+
content: T
|
|
81
157
|
}),
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
] }))
|
|
158
|
+
d && /* @__PURE__ */ t(c, { wrapperStyle: x }),
|
|
159
|
+
f.map((e, t) => w(i, e, t))
|
|
160
|
+
] }), _)
|
|
85
161
|
});
|
|
86
162
|
}
|
|
87
163
|
//#endregion
|
|
88
|
-
export {
|
|
164
|
+
export { v as AXIS_STROKE, y as AXIS_TICK, x as LEGEND_STYLE, b as TOOLTIP_STYLE, O as buildTooltipContent, D as chartElement, k as chartTree, E as pieElement, T as pieRingRadii, C as resolveChartSeries, w as seriesElement };
|
|
@@ -2,19 +2,49 @@
|
|
|
2
2
|
import { classnames as e } from "../../utils/classnames.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect as r, useMemo as i, useState as a } from "react";
|
|
5
6
|
//#region src/lib/components/CodeBlock/CodeBlock.tsx
|
|
6
|
-
var
|
|
7
|
-
function
|
|
7
|
+
var o = "haze-CodeBlock__block", s = "haze-CodeBlock__pre", c = "haze-CodeBlock__lang";
|
|
8
|
+
function l({ children: l, language: u, highlight: d, className: f }) {
|
|
9
|
+
let p = typeof l == "string" ? l : void 0, m = i(() => {
|
|
10
|
+
if (d !== void 0 && p !== void 0) try {
|
|
11
|
+
return d(p, u ?? "");
|
|
12
|
+
} catch {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
}, [
|
|
16
|
+
d,
|
|
17
|
+
p,
|
|
18
|
+
u
|
|
19
|
+
]), h = m instanceof Promise ? m : void 0, [g, _] = a(null);
|
|
20
|
+
r(() => {
|
|
21
|
+
if (h === void 0) return;
|
|
22
|
+
let e = !0;
|
|
23
|
+
return h.then((t) => {
|
|
24
|
+
e && _({
|
|
25
|
+
pending: h,
|
|
26
|
+
html: t
|
|
27
|
+
});
|
|
28
|
+
}, () => {
|
|
29
|
+
e && _({
|
|
30
|
+
pending: h,
|
|
31
|
+
html: null
|
|
32
|
+
});
|
|
33
|
+
}), () => {
|
|
34
|
+
e = !1;
|
|
35
|
+
};
|
|
36
|
+
}, [h]);
|
|
37
|
+
let v = typeof m == "string" ? m : g !== null && g.pending === h ? g.html : null;
|
|
8
38
|
return /* @__PURE__ */ n("div", {
|
|
9
|
-
className: e([
|
|
10
|
-
children: [
|
|
11
|
-
className: e([
|
|
12
|
-
children:
|
|
39
|
+
className: e([o, f]),
|
|
40
|
+
children: [u && /* @__PURE__ */ t("span", {
|
|
41
|
+
className: e([c]),
|
|
42
|
+
children: u
|
|
13
43
|
}), /* @__PURE__ */ t("pre", {
|
|
14
|
-
className: e([
|
|
15
|
-
children: /* @__PURE__ */ t("code", { children:
|
|
44
|
+
className: e([s]),
|
|
45
|
+
children: v === null ? /* @__PURE__ */ t("code", { children: l }) : /* @__PURE__ */ t("code", { dangerouslySetInnerHTML: { __html: v } })
|
|
16
46
|
})]
|
|
17
47
|
});
|
|
18
48
|
}
|
|
19
49
|
//#endregion
|
|
20
|
-
export {
|
|
50
|
+
export { l as default };
|
|
@@ -9,47 +9,47 @@ import ne from "../Chip/Chip.js";
|
|
|
9
9
|
import re from "../Spinner/Spinner.js";
|
|
10
10
|
import ie from "../VirtualList/VirtualList.js";
|
|
11
11
|
import ae from "./ComboboxGroup.js";
|
|
12
|
-
import
|
|
12
|
+
import oe from "./ComboboxOption.js";
|
|
13
13
|
/* empty css */
|
|
14
|
-
import { Fragment as
|
|
15
|
-
import { useCallback as
|
|
14
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
15
|
+
import { useCallback as se, useEffect as s, useId as ce, useMemo as le, useRef as c, useState as l } from "react";
|
|
16
16
|
import { useControl as u } from "react-use-control";
|
|
17
17
|
//#region src/lib/components/Combobox/Combobox.tsx
|
|
18
18
|
var ue = "haze-Combobox__wrapper", de = "haze-Combobox__input", fe = "haze-Combobox__multiBox", pe = "haze-Combobox__multiInput", d = "haze-Combobox__matchMark", f = "haze-Combobox__stateRow", me = "haze-Combobox__groupHeadingText", he = "haze-Combobox__listbox", ge = "haze-Combobox__listboxVirtual", _e = 200, ve = 37, ye = "haze-Combobox__virtualRow";
|
|
19
19
|
function be(t, n) {
|
|
20
20
|
if (n === "") return t;
|
|
21
21
|
let r = t.toLowerCase().indexOf(n.toLowerCase());
|
|
22
|
-
return r < 0 ? t : /* @__PURE__ */
|
|
22
|
+
return r < 0 ? t : /* @__PURE__ */ o(i, { children: [
|
|
23
23
|
t.slice(0, r),
|
|
24
|
-
/* @__PURE__ */
|
|
24
|
+
/* @__PURE__ */ a("mark", {
|
|
25
25
|
className: e([d]),
|
|
26
26
|
children: t.slice(r, r + n.length)
|
|
27
27
|
}),
|
|
28
28
|
t.slice(r + n.length)
|
|
29
29
|
] });
|
|
30
30
|
}
|
|
31
|
-
function p({ value:
|
|
32
|
-
let
|
|
33
|
-
open:
|
|
34
|
-
setOpen:
|
|
35
|
-
triggerRef: m ?
|
|
36
|
-
panelRef:
|
|
31
|
+
function p({ value: i, open: d, options: p, multiple: m = !1, onValuesChange: h, creatable: xe = !1, onCreate: Se, onSearch: g, loading: _ = !1, empty: Ce, highlightMatches: we = !1, maxHeight: v, placeholder: Te, virtualThreshold: y = 100, virtualized: b, className: Ee, ref: x }) {
|
|
32
|
+
let S = r("combobox"), [C, w] = u(i, m ? [] : ""), [T, De] = l([]), [E, D] = l(""), [O, k] = u(d, !1), [A, j] = l(-1), [Oe, ke] = l(E), M = ce(), N = c(null), Ae = se((e) => t(N, x)(e), [N, x]), P = c(null), F = c(null), I = c(null), L = c(null), R = te({
|
|
33
|
+
open: O,
|
|
34
|
+
setOpen: k,
|
|
35
|
+
triggerRef: m ? P : N,
|
|
36
|
+
panelRef: F,
|
|
37
37
|
animated: !0
|
|
38
|
-
}),
|
|
39
|
-
if (
|
|
40
|
-
let e = new Set(p.map((e) => e.value)), t =
|
|
38
|
+
}), z = Array.isArray(C) ? C : [], B = le(() => {
|
|
39
|
+
if (T.length === 0) return p;
|
|
40
|
+
let e = new Set(p.map((e) => e.value)), t = T.filter((t) => !e.has(t)).map((e) => ({
|
|
41
41
|
value: e,
|
|
42
42
|
label: e
|
|
43
43
|
}));
|
|
44
44
|
return t.length > 0 ? [...p, ...t] : p;
|
|
45
|
-
}, [p,
|
|
46
|
-
value:
|
|
47
|
-
label:
|
|
48
|
-
}, ...
|
|
49
|
-
for (let e = 0; e <
|
|
50
|
-
let t =
|
|
45
|
+
}, [p, T]), V = g ? B : B.filter((e) => e.label.toLowerCase().includes(E.toLowerCase())), H = xe && !_ && E.trim() !== "" && V.length === 0, U = E.trim(), je = n(S.create, { query: U }), W = H ? [{
|
|
46
|
+
value: U,
|
|
47
|
+
label: U
|
|
48
|
+
}, ...V] : V, G = typeof b == "object" ? b : void 0, K = (b === void 0 ? void 0 : !!b) ?? (y > 0 && W.length > y), q = G?.itemHeight ?? ve, Me = G?.overscan, J = (e) => `${M}-option-${e}`, Ne = O && W[A] ? J(A) : void 0, Y = [];
|
|
49
|
+
for (let e = 0; e < W.length; e++) {
|
|
50
|
+
let t = W[e];
|
|
51
51
|
if (t === void 0) continue;
|
|
52
|
-
let n =
|
|
52
|
+
let n = Y[Y.length - 1];
|
|
53
53
|
if (t.group !== void 0 && n?.label === t.group) {
|
|
54
54
|
n.rows.push({
|
|
55
55
|
option: t,
|
|
@@ -57,7 +57,7 @@ function p({ value: a, open: d, options: p, multiple: m = !1, onValuesChange: h,
|
|
|
57
57
|
});
|
|
58
58
|
continue;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
Y.push(t.group === void 0 ? {
|
|
61
61
|
key: `row-${t.value}`,
|
|
62
62
|
label: void 0,
|
|
63
63
|
rows: [{
|
|
@@ -73,134 +73,142 @@ function p({ value: a, open: d, options: p, multiple: m = !1, onValuesChange: h,
|
|
|
73
73
|
}]
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
let Pe =
|
|
77
|
-
|
|
78
|
-
if (!
|
|
79
|
-
if (
|
|
80
|
-
|
|
76
|
+
let Pe = Y.some((e) => e.label !== void 0);
|
|
77
|
+
s(() => {
|
|
78
|
+
if (!R.shown || A < 0) return;
|
|
79
|
+
if (K) {
|
|
80
|
+
I.current?.scrollToIndex(A, "auto");
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
let e =
|
|
83
|
+
let e = L.current;
|
|
84
84
|
e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
|
|
85
85
|
}, [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
])
|
|
90
|
-
let
|
|
91
|
-
|
|
86
|
+
K,
|
|
87
|
+
R.shown,
|
|
88
|
+
A
|
|
89
|
+
]);
|
|
90
|
+
let X = c(g);
|
|
91
|
+
s(() => {
|
|
92
|
+
X.current = g;
|
|
93
|
+
}, [g]);
|
|
94
|
+
let Z = c(E);
|
|
95
|
+
s(() => {
|
|
96
|
+
Z.current !== E && (Z.current = E, X.current?.(E));
|
|
97
|
+
}, [E]), E !== Oe && (ke(E), j(-1));
|
|
98
|
+
let Fe = (e) => m ? z.includes(e) : C === e, Ie = (e) => B.find((t) => t.value === e)?.label ?? e, Le = (e, t) => {
|
|
99
|
+
let n = t ?? B.find((t) => t.value === e)?.label ?? e;
|
|
92
100
|
if (m) {
|
|
93
|
-
let t =
|
|
94
|
-
|
|
95
|
-
} else
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
Se?.(
|
|
99
|
-
},
|
|
100
|
-
if (
|
|
101
|
-
|
|
101
|
+
let t = z.includes(e) ? z.filter((t) => t !== e) : [...z, e];
|
|
102
|
+
w(t), h?.(t), D("");
|
|
103
|
+
} else w(e), h?.(e), D(n), k(!1);
|
|
104
|
+
N.current?.focus();
|
|
105
|
+
}, Re = () => {
|
|
106
|
+
Se?.(U), De((e) => e.includes(U) ? e : [...e, U]), Le(U, U);
|
|
107
|
+
}, ze = (e) => {
|
|
108
|
+
if (H && e === U) {
|
|
109
|
+
Re();
|
|
102
110
|
return;
|
|
103
111
|
}
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
if (e.key === "ArrowDown") e.preventDefault(),
|
|
107
|
-
else if (e.key === "ArrowUp") e.preventDefault(),
|
|
108
|
-
else if (e.key === "Enter" &&
|
|
109
|
-
else if (e.key === "Escape")
|
|
110
|
-
else if (e.key === "Backspace" && m &&
|
|
112
|
+
Le(e);
|
|
113
|
+
}, Be = (e) => {
|
|
114
|
+
if (e.key === "ArrowDown") e.preventDefault(), k(!0), j((e) => Math.min(e + 1, W.length - 1));
|
|
115
|
+
else if (e.key === "ArrowUp") e.preventDefault(), k(!0), j((e) => Math.max(e - 1, 0));
|
|
116
|
+
else if (e.key === "Enter" && A >= 0 && W[A]) e.preventDefault(), ze(W[A].value);
|
|
117
|
+
else if (e.key === "Escape") k(!1);
|
|
118
|
+
else if (e.key === "Backspace" && m && E === "" && z.length > 0) {
|
|
111
119
|
e.preventDefault();
|
|
112
|
-
let t =
|
|
113
|
-
|
|
120
|
+
let t = z.slice(0, -1);
|
|
121
|
+
w(t), h?.(t);
|
|
114
122
|
}
|
|
115
|
-
}, Q = (e, t, n) => /* @__PURE__ */
|
|
116
|
-
ref: !n && t ===
|
|
123
|
+
}, Q = (e, t, n) => /* @__PURE__ */ a(oe, {
|
|
124
|
+
ref: !n && t === A ? L : void 0,
|
|
117
125
|
value: e.value,
|
|
118
|
-
id:
|
|
119
|
-
setSize:
|
|
126
|
+
id: J(t),
|
|
127
|
+
setSize: W.length,
|
|
120
128
|
posInSet: t + 1,
|
|
121
|
-
highlighted: t ===
|
|
122
|
-
selected:
|
|
123
|
-
onSelect:
|
|
129
|
+
highlighted: t === A,
|
|
130
|
+
selected: Fe(e.value),
|
|
131
|
+
onSelect: ze,
|
|
124
132
|
className: n ? ye : void 0,
|
|
125
|
-
children:
|
|
126
|
-
}, e.value), $ = /* @__PURE__ */
|
|
133
|
+
children: H && t === 0 ? je : we ? be(e.label, E) : e.label
|
|
134
|
+
}, e.value), $ = /* @__PURE__ */ a("input", {
|
|
127
135
|
ref: Ae,
|
|
128
136
|
role: "combobox",
|
|
129
|
-
style: m ? void 0 :
|
|
130
|
-
"aria-expanded":
|
|
131
|
-
"aria-controls":
|
|
137
|
+
style: m ? void 0 : R.triggerStyle,
|
|
138
|
+
"aria-expanded": O,
|
|
139
|
+
"aria-controls": M,
|
|
132
140
|
"aria-autocomplete": "list",
|
|
133
141
|
"aria-activedescendant": Ne,
|
|
134
|
-
"aria-busy":
|
|
142
|
+
"aria-busy": _ || void 0,
|
|
135
143
|
className: m ? pe : de,
|
|
136
|
-
value:
|
|
144
|
+
value: E,
|
|
137
145
|
placeholder: Te,
|
|
138
146
|
onChange: (e) => {
|
|
139
|
-
|
|
147
|
+
D(e.target.value), k(!0);
|
|
140
148
|
},
|
|
141
|
-
onPointerDown: m ? void 0 :
|
|
142
|
-
onClick: m ? void 0 :
|
|
143
|
-
onKeyDown:
|
|
149
|
+
onPointerDown: m ? void 0 : R.onTriggerPointerDown,
|
|
150
|
+
onClick: m ? void 0 : R.onTriggerClick,
|
|
151
|
+
onKeyDown: Be
|
|
144
152
|
});
|
|
145
|
-
return /* @__PURE__ */
|
|
153
|
+
return /* @__PURE__ */ o("div", {
|
|
146
154
|
className: e([ue, Ee]),
|
|
147
|
-
children: [m ? /* @__PURE__ */
|
|
148
|
-
ref:
|
|
149
|
-
style:
|
|
150
|
-
onPointerDown:
|
|
155
|
+
children: [m ? /* @__PURE__ */ o("div", {
|
|
156
|
+
ref: P,
|
|
157
|
+
style: R.triggerStyle,
|
|
158
|
+
onPointerDown: R.onTriggerPointerDown,
|
|
151
159
|
onClick: () => {
|
|
152
|
-
|
|
160
|
+
R.onTriggerClick(), N.current?.focus();
|
|
153
161
|
},
|
|
154
162
|
className: e(fe),
|
|
155
|
-
children: [
|
|
163
|
+
children: [z.map((e) => /* @__PURE__ */ a("span", {
|
|
156
164
|
onClick: (e) => e.stopPropagation(),
|
|
157
|
-
children: /* @__PURE__ */
|
|
165
|
+
children: /* @__PURE__ */ a(ne, {
|
|
158
166
|
color: "primary",
|
|
159
167
|
onClose: () => {
|
|
160
|
-
let t =
|
|
161
|
-
|
|
168
|
+
let t = z.filter((t) => t !== e);
|
|
169
|
+
w(t), h?.(t);
|
|
162
170
|
},
|
|
163
|
-
children:
|
|
171
|
+
children: Ie(e)
|
|
164
172
|
})
|
|
165
173
|
}, e)), $]
|
|
166
|
-
}) : $, /* @__PURE__ */
|
|
167
|
-
ref:
|
|
168
|
-
behavior:
|
|
174
|
+
}) : $, /* @__PURE__ */ a(ee, {
|
|
175
|
+
ref: F,
|
|
176
|
+
behavior: R,
|
|
169
177
|
placement: "bottom-span",
|
|
170
|
-
id:
|
|
178
|
+
id: M,
|
|
171
179
|
role: "listbox",
|
|
172
180
|
"aria-multiselectable": m ? "true" : void 0,
|
|
173
|
-
visualClass:
|
|
174
|
-
style:
|
|
175
|
-
children:
|
|
181
|
+
visualClass: K ? ge : he,
|
|
182
|
+
style: v !== void 0 && !K ? { maxHeight: `${v}px` } : void 0,
|
|
183
|
+
children: _ ? /* @__PURE__ */ a("div", {
|
|
176
184
|
role: "option",
|
|
177
185
|
"aria-selected": !1,
|
|
178
186
|
"aria-disabled": "true",
|
|
179
187
|
className: e([f]),
|
|
180
|
-
children: /* @__PURE__ */
|
|
181
|
-
}) :
|
|
188
|
+
children: /* @__PURE__ */ a(re, { size: "sm" })
|
|
189
|
+
}) : W.length === 0 ? /* @__PURE__ */ a("div", {
|
|
182
190
|
role: "option",
|
|
183
191
|
"aria-selected": !1,
|
|
184
192
|
"aria-disabled": "true",
|
|
185
193
|
className: e([f]),
|
|
186
|
-
children: Ce ??
|
|
187
|
-
}) :
|
|
188
|
-
ref:
|
|
194
|
+
children: Ce ?? S.noResults
|
|
195
|
+
}) : K ? /* @__PURE__ */ a(ie, {
|
|
196
|
+
ref: I,
|
|
189
197
|
"data-virtualized": !0,
|
|
190
|
-
items:
|
|
191
|
-
height: Math.min(
|
|
192
|
-
itemHeight:
|
|
198
|
+
items: W,
|
|
199
|
+
height: Math.min(v ?? _e, W.length * q),
|
|
200
|
+
itemHeight: q,
|
|
193
201
|
overscan: Me,
|
|
194
|
-
groups: Pe ?
|
|
202
|
+
groups: Pe ? Y.filter((e) => e.label !== void 0).map((t) => ({
|
|
195
203
|
startIndex: t.rows[0]?.index ?? 0,
|
|
196
204
|
key: t.key,
|
|
197
|
-
render: () => /* @__PURE__ */
|
|
205
|
+
render: () => /* @__PURE__ */ a("div", {
|
|
198
206
|
className: e([me]),
|
|
199
207
|
children: t.label
|
|
200
208
|
})
|
|
201
209
|
})) : void 0,
|
|
202
210
|
renderItem: (e, t) => Q(e, t, !0)
|
|
203
|
-
}) :
|
|
211
|
+
}) : Y.flatMap((e) => e.label === void 0 ? e.rows.map(({ option: e, index: t }) => Q(e, t, !1)) : [/* @__PURE__ */ a(ae, {
|
|
204
212
|
label: e.label,
|
|
205
213
|
children: e.rows.map(({ option: e, index: t }) => Q(e, t, !1))
|
|
206
214
|
}, e.key)])
|