haze-ui 1.24.0 → 1.25.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 +139 -0
- package/dist/components/Alert/Alert.js +19 -18
- package/dist/components/ApprovalCard/ApprovalCard.js +27 -25
- package/dist/components/AsyncSection/AsyncSection.js +32 -30
- package/dist/components/AvatarGroup/AvatarGroup.js +29 -0
- package/dist/components/AvatarGroup/index.js +2 -0
- package/dist/components/BackToTop/BackToTop.js +15 -14
- package/dist/components/Banner/Banner.js +19 -18
- package/dist/components/Breadcrumb/Breadcrumb.js +18 -17
- package/dist/components/Calendar/Calendar.js +152 -0
- package/dist/components/Calendar/index.js +2 -0
- package/dist/components/Carousel/Carousel.js +42 -40
- package/dist/components/Cascader/Cascader.js +227 -0
- package/dist/components/Cascader/index.js +2 -0
- package/dist/components/ChatInput/ChatInput.js +30 -29
- package/dist/components/ChatMessage/ChatMessage.js +28 -27
- package/dist/components/Chip/Chip.js +20 -19
- package/dist/components/ColorPicker/ColorPickerCore.js +28 -26
- package/dist/components/Combobox/Combobox.js +62 -43
- package/dist/components/Command/Command.js +2 -2
- package/dist/components/ConfirmDialog/ConfirmDialog.js +40 -39
- package/dist/components/DataTable/DataTable.js +151 -0
- package/dist/components/DataTable/index.js +2 -0
- package/dist/components/DateRangePicker/DateRangePickerCore.js +21 -19
- package/dist/components/Datepicker/Datepicker.js +10 -8
- package/dist/components/Datepicker/DatepickerCore.js +18 -16
- package/dist/components/Empty/Empty.js +21 -19
- package/dist/components/FileInput/FileInput.js +14 -13
- package/dist/components/HoverCard/HoverCard.js +53 -0
- package/dist/components/HoverCard/index.js +2 -0
- package/dist/components/InlineEdit/InlineEdit.js +32 -31
- package/dist/components/Kbd/Kbd.js +21 -0
- package/dist/components/Kbd/index.js +2 -0
- package/dist/components/LocaleProvider/LocaleContext.js +5 -0
- package/dist/components/LocaleProvider/LocaleProvider.js +21 -0
- package/dist/components/LocaleProvider/index.js +4 -0
- package/dist/components/LocaleProvider/locale.js +126 -0
- package/dist/components/LocaleProvider/useStrings.js +17 -0
- package/dist/components/LogViewer/LogViewer.js +44 -43
- package/dist/components/MarkdownRenderer/MarkdownRenderer.js +19 -19
- package/dist/components/MarkdownRenderer/markdown-blocks.js +41 -0
- package/dist/components/ModelPicker/ModelPicker.js +16 -15
- package/dist/components/NumberInput/NumberInputCore.js +34 -33
- package/dist/components/OTPInput/OTPInputCore.js +35 -30
- package/dist/components/Pagination/Pagination.js +31 -30
- package/dist/components/PasswordInput/PasswordInputCore.js +22 -21
- package/dist/components/Progress/Progress.js +40 -39
- package/dist/components/Rating/RatingCore.js +28 -26
- package/dist/components/Sidebar/Sidebar.js +112 -0
- package/dist/components/Sidebar/index.js +2 -0
- package/dist/components/Spinner/Spinner.js +14 -12
- package/dist/components/StreamingText/StreamingText.js +39 -20
- package/dist/components/Tag/Tag.js +16 -14
- package/dist/components/TagGroup/TagGroupItem.js +12 -10
- package/dist/components/TagInput/TagInputCore.js +52 -50
- package/dist/components/ThinkingIndicator/ThinkingIndicator.js +13 -11
- package/dist/components/Toast/ToastContainer.js +44 -28
- package/dist/components/Toast/index.js +4 -3
- package/dist/components/Toast/toast2.js +44 -0
- package/dist/components/TokenCounter/TokenCounter.js +19 -18
- package/dist/components/ToolCallCard/ToolCallCard.js +39 -37
- package/dist/components/Toolbar/Toolbar.js +59 -0
- package/dist/components/Toolbar/ToolbarButton.js +25 -0
- package/dist/components/Toolbar/ToolbarContext.js +8 -0
- package/dist/components/Toolbar/ToolbarSeparator.js +22 -0
- package/dist/components/Toolbar/index.js +4 -0
- package/dist/components/Tour/Tour.js +197 -0
- package/dist/components/Tour/index.js +2 -0
- package/dist/components/Transfer/TransferCore.js +61 -67
- package/dist/components/Tree/TreeItem.js +56 -55
- package/dist/components/Upload/UploadCore.js +36 -35
- package/dist/components/VirtualList/VirtualList.js +140 -26
- package/dist/css/affix.css +1 -1
- package/dist/css/avatar-group.css +2 -0
- package/dist/css/calendar.css +2 -0
- package/dist/css/carousel.css +1 -1
- package/dist/css/cascader.css +2 -0
- package/dist/css/chat-message.css +1 -1
- package/dist/css/chip.css +1 -1
- package/dist/css/code-block.css +1 -1
- package/dist/css/combobox.css +1 -1
- package/dist/css/container.css +1 -1
- package/dist/css/context-menu.css +1 -1
- package/dist/css/conversation-list.css +1 -1
- package/dist/css/data-table.css +2 -0
- package/dist/css/datepicker.css +0 -1
- package/dist/css/diff-viewer.css +1 -1
- package/dist/css/dropdown-menu.css +1 -1
- package/dist/css/hover-card.css +2 -0
- package/dist/css/kbd.css +2 -0
- package/dist/css/list.css +1 -1
- package/dist/css/markdown-renderer.css +1 -1
- package/dist/css/menu.css +1 -1
- package/dist/css/model-picker.css +1 -1
- package/dist/css/navigation-bar.css +1 -1
- package/dist/css/password-input.css +1 -1
- package/dist/css/radio.css +1 -1
- package/dist/css/select.css +1 -1
- package/dist/css/sidebar.css +2 -0
- package/dist/css/step-timeline.css +1 -1
- package/dist/css/stepper.css +1 -1
- package/dist/css/streaming-text.css +1 -1
- package/dist/css/table.css +1 -1
- package/dist/css/toolbar.css +4 -0
- package/dist/css/tour.css +2 -0
- package/dist/css/tree.css +1 -1
- package/dist/css/virtual-list.css +1 -1
- package/dist/css-manifest.json +19 -0
- package/dist/haze-ui.css +36 -26
- package/dist/index.js +130 -115
- package/dist/registry.json +247 -0
- package/dist/types/components/AvatarGroup/AvatarGroup.d.ts +9 -0
- package/dist/types/components/AvatarGroup/index.d.ts +2 -0
- package/dist/types/components/Calendar/Calendar.d.ts +21 -0
- package/dist/types/components/Calendar/index.d.ts +2 -0
- package/dist/types/components/Cascader/Cascader.d.ts +26 -0
- package/dist/types/components/Cascader/index.d.ts +2 -0
- package/dist/types/components/Combobox/Combobox.d.ts +7 -1
- package/dist/types/components/DataTable/DataTable.d.ts +61 -0
- package/dist/types/components/DataTable/index.d.ts +2 -0
- package/dist/types/components/Datepicker/Datepicker.d.ts +3 -1
- package/dist/types/components/Datepicker/DatepickerCore.d.ts +3 -1
- package/dist/types/components/HoverCard/HoverCard.d.ts +49 -0
- package/dist/types/components/HoverCard/index.d.ts +2 -0
- package/dist/types/components/Kbd/Kbd.d.ts +6 -0
- package/dist/types/components/Kbd/index.d.ts +2 -0
- package/dist/types/components/LocaleProvider/LocaleContext.d.ts +19 -0
- package/dist/types/components/LocaleProvider/LocaleProvider.d.ts +13 -0
- package/dist/types/components/LocaleProvider/index.d.ts +6 -0
- package/dist/types/components/LocaleProvider/locale.d.ts +176 -0
- package/dist/types/components/LocaleProvider/useStrings.d.ts +9 -0
- package/dist/types/components/MarkdownRenderer/markdown-blocks.d.ts +6 -0
- package/dist/types/components/Sidebar/Sidebar.d.ts +64 -0
- package/dist/types/components/Sidebar/index.d.ts +4 -0
- package/dist/types/components/Toast/index.d.ts +2 -0
- package/dist/types/components/Toast/toast.d.ts +46 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +16 -0
- package/dist/types/components/Toolbar/ToolbarButton.d.ts +20 -0
- package/dist/types/components/Toolbar/ToolbarContext.d.ts +5 -0
- package/dist/types/components/Toolbar/ToolbarSeparator.d.ts +14 -0
- package/dist/types/components/Toolbar/index.d.ts +6 -0
- package/dist/types/components/Tour/Tour.d.ts +46 -0
- package/dist/types/components/Tour/index.d.ts +2 -0
- package/dist/types/components/VirtualList/VirtualList.d.ts +58 -4
- package/dist/types/components/VirtualList/index.d.ts +1 -1
- package/dist/types/index.d.ts +24 -3
- package/dist/utils/floating.js +20 -22
- package/package.json +39 -25
- package/dist/components/Datepicker/Calendar.js +0 -120
- package/dist/types/components/Datepicker/Calendar.d.ts +0 -8
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
|
|
2
|
+
import { classnames as e } from "../../utils/classnames.js";
|
|
3
|
+
import { useStrings as t } from "../LocaleProvider/useStrings.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
6
|
+
import { useState as i } from "react";
|
|
7
|
+
import { useControl as a } from "react-use-control";
|
|
8
|
+
//#region src/lib/components/Calendar/Calendar.tsx
|
|
9
|
+
var o = "haze-Calendar__calendarWrapper", s = "haze-Calendar__header", c = "haze-Calendar__headerBtn", l = "haze-Calendar__headerTitle", u = "haze-Calendar__headerTrailing", d = "haze-Calendar__grid", f = "haze-Calendar__rowContents", p = "haze-Calendar__cellContents", m = "haze-Calendar__weekday", h = "haze-Calendar__dayBtn", g = "haze-Calendar__daySelected", _ = "haze-Calendar__dayOutside", v = [
|
|
10
|
+
"Su",
|
|
11
|
+
"Mo",
|
|
12
|
+
"Tu",
|
|
13
|
+
"We",
|
|
14
|
+
"Th",
|
|
15
|
+
"Fr",
|
|
16
|
+
"Sa"
|
|
17
|
+
];
|
|
18
|
+
function y(e, t) {
|
|
19
|
+
if (t !== void 0) return t;
|
|
20
|
+
if (e === void 0) return 0;
|
|
21
|
+
try {
|
|
22
|
+
let t = new Intl.Locale(e).getWeekInfo?.().firstDay;
|
|
23
|
+
return t === void 0 || t === 7 ? 0 : t;
|
|
24
|
+
} catch {
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function b(e, t) {
|
|
29
|
+
if (e === void 0) return Array.from({ length: 7 }, (e, n) => v[(t + n) % 7]);
|
|
30
|
+
let n = new Intl.DateTimeFormat(e, { weekday: "short" }), r = Array.from({ length: 7 }, (e, t) => n.format(new Date(2024, 0, 7 + t)));
|
|
31
|
+
return Array.from({ length: 7 }, (e, n) => r[(t + n) % 7]);
|
|
32
|
+
}
|
|
33
|
+
function x(e, t) {
|
|
34
|
+
return new Date(e, t + 1, 0).getDate();
|
|
35
|
+
}
|
|
36
|
+
function S(e, t, n) {
|
|
37
|
+
return `${e}-${String(t + 1).padStart(2, "0")}-${String(n).padStart(2, "0")}`;
|
|
38
|
+
}
|
|
39
|
+
function C({ value: v, min: C, max: w, locale: T, weekStartsOn: E, onSelect: D, className: O, ...k }) {
|
|
40
|
+
let [A, j] = a(v, ""), M = t("calendar"), N = A ? new Date(A) : /* @__PURE__ */ new Date(), [P, F] = i(N.getFullYear()), [I, L] = i(N.getMonth()), R = y(T, E), z = b(T, R), B = x(P, I), V = new Date(P, I, 1).getDay(), H = x(P, I - 1), U = (V - R + 7) % 7, W = () => {
|
|
41
|
+
L((e) => e === 0 ? (F((e) => e - 1), 11) : e - 1);
|
|
42
|
+
}, G = () => {
|
|
43
|
+
L((e) => e === 11 ? (F((e) => e + 1), 0) : e + 1);
|
|
44
|
+
}, K = () => {
|
|
45
|
+
let e = /* @__PURE__ */ new Date();
|
|
46
|
+
F(e.getFullYear()), L(e.getMonth());
|
|
47
|
+
}, q = (e) => !!(C && e < C || w && e > w), J = [];
|
|
48
|
+
for (let e = U - 1; e >= 0; e--) {
|
|
49
|
+
let t = I === 0 ? 11 : I - 1, n = I === 0 ? P - 1 : P;
|
|
50
|
+
J.push({
|
|
51
|
+
day: H - e,
|
|
52
|
+
month: t,
|
|
53
|
+
year: n,
|
|
54
|
+
outside: !0
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
for (let e = 1; e <= B; e++) J.push({
|
|
58
|
+
day: e,
|
|
59
|
+
month: I,
|
|
60
|
+
year: P,
|
|
61
|
+
outside: !1
|
|
62
|
+
});
|
|
63
|
+
let Y = 7 - J.length % 7;
|
|
64
|
+
if (Y < 7) for (let e = 1; e <= Y; e++) {
|
|
65
|
+
let t = I === 11 ? 0 : I + 1, n = I === 11 ? P + 1 : P;
|
|
66
|
+
J.push({
|
|
67
|
+
day: e,
|
|
68
|
+
month: t,
|
|
69
|
+
year: n,
|
|
70
|
+
outside: !0
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
let X = new Intl.DateTimeFormat(T ?? "default", {
|
|
74
|
+
month: "long",
|
|
75
|
+
year: "numeric"
|
|
76
|
+
}).format(new Date(P, I)), Z = [];
|
|
77
|
+
for (let e = 0; e < J.length; e += 7) Z.push(J.slice(e, e + 7));
|
|
78
|
+
return /* @__PURE__ */ r("div", {
|
|
79
|
+
...k,
|
|
80
|
+
className: e([o, O]),
|
|
81
|
+
children: [/* @__PURE__ */ r("div", {
|
|
82
|
+
className: e([s]),
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ n("button", {
|
|
85
|
+
type: "button",
|
|
86
|
+
onClick: W,
|
|
87
|
+
"aria-label": M.previousMonth,
|
|
88
|
+
className: e([c]),
|
|
89
|
+
children: "‹"
|
|
90
|
+
}),
|
|
91
|
+
/* @__PURE__ */ n("span", {
|
|
92
|
+
className: e([l]),
|
|
93
|
+
children: X
|
|
94
|
+
}),
|
|
95
|
+
/* @__PURE__ */ r("span", {
|
|
96
|
+
className: e([u]),
|
|
97
|
+
children: [/* @__PURE__ */ n("button", {
|
|
98
|
+
type: "button",
|
|
99
|
+
onClick: K,
|
|
100
|
+
className: e([c]),
|
|
101
|
+
children: M.today
|
|
102
|
+
}), /* @__PURE__ */ n("button", {
|
|
103
|
+
type: "button",
|
|
104
|
+
onClick: G,
|
|
105
|
+
"aria-label": M.nextMonth,
|
|
106
|
+
className: e([c]),
|
|
107
|
+
children: "›"
|
|
108
|
+
})]
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}), /* @__PURE__ */ r("div", {
|
|
112
|
+
role: "grid",
|
|
113
|
+
"aria-label": X,
|
|
114
|
+
className: e([d]),
|
|
115
|
+
children: [/* @__PURE__ */ n("div", {
|
|
116
|
+
role: "row",
|
|
117
|
+
className: e([f]),
|
|
118
|
+
children: z.map((t, r) => /* @__PURE__ */ n("span", {
|
|
119
|
+
role: "columnheader",
|
|
120
|
+
className: e([m]),
|
|
121
|
+
children: t
|
|
122
|
+
}, r))
|
|
123
|
+
}), Z.map((t, r) => /* @__PURE__ */ n("div", {
|
|
124
|
+
role: "row",
|
|
125
|
+
className: e([f]),
|
|
126
|
+
children: t.map((t) => {
|
|
127
|
+
let r = S(t.year, t.month, t.day);
|
|
128
|
+
return /* @__PURE__ */ n("span", {
|
|
129
|
+
role: "gridcell",
|
|
130
|
+
"aria-selected": r === A,
|
|
131
|
+
className: e([p]),
|
|
132
|
+
children: /* @__PURE__ */ n("button", {
|
|
133
|
+
type: "button",
|
|
134
|
+
disabled: q(r),
|
|
135
|
+
onClick: () => {
|
|
136
|
+
j(r), D?.(r);
|
|
137
|
+
},
|
|
138
|
+
className: e([
|
|
139
|
+
h,
|
|
140
|
+
r === A && g,
|
|
141
|
+
t.outside && _
|
|
142
|
+
]),
|
|
143
|
+
children: t.day
|
|
144
|
+
})
|
|
145
|
+
}, r);
|
|
146
|
+
})
|
|
147
|
+
}, r))]
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
export { C as default };
|
|
@@ -1,68 +1,70 @@
|
|
|
1
1
|
|
|
2
2
|
import { classnames as e } from "../../utils/classnames.js";
|
|
3
|
+
import { formatString as t } from "../LocaleProvider/locale.js";
|
|
4
|
+
import { useStrings as n } from "../LocaleProvider/useStrings.js";
|
|
3
5
|
/* empty css */
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { Children as
|
|
6
|
-
import { useControl as
|
|
6
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
7
|
+
import { Children as o, useEffect as s, useRef as c } from "react";
|
|
8
|
+
import { useControl as l } from "react-use-control";
|
|
7
9
|
//#region src/lib/components/Carousel/Carousel.tsx
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
let [
|
|
11
|
-
return
|
|
12
|
-
let e =
|
|
10
|
+
var u = "haze-Carousel__wrapper", d = "haze-Carousel__track", f = "haze-Carousel__navBtn", p = "haze-Carousel__prevBtn", m = "haze-Carousel__nextBtn", h = "haze-Carousel__indicators", g = "haze-Carousel__dot", _ = "haze-Carousel__dotActive";
|
|
11
|
+
function v({ value: v, autoPlay: y = !1, interval: b = 5e3, className: x, children: S }) {
|
|
12
|
+
let [C, w] = l(v, 0), T = c(null), E = o.count(S), D = n("carousel");
|
|
13
|
+
return s(() => {
|
|
14
|
+
let e = T.current;
|
|
13
15
|
if (!e) return;
|
|
14
|
-
let t = e.children[
|
|
16
|
+
let t = e.children[C];
|
|
15
17
|
t && t.scrollIntoView({
|
|
16
18
|
behavior: "smooth",
|
|
17
19
|
block: "nearest",
|
|
18
20
|
inline: "start"
|
|
19
21
|
});
|
|
20
|
-
}, [
|
|
21
|
-
if (!
|
|
22
|
+
}, [C]), s(() => {
|
|
23
|
+
if (!y || E <= 1) return;
|
|
22
24
|
let e = setInterval(() => {
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
+
w((e) => (e + 1) % E);
|
|
26
|
+
}, b);
|
|
25
27
|
return () => clearInterval(e);
|
|
26
28
|
}, [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
]), /* @__PURE__ */
|
|
29
|
+
y,
|
|
30
|
+
b,
|
|
31
|
+
E,
|
|
32
|
+
w
|
|
33
|
+
]), /* @__PURE__ */ a("div", {
|
|
32
34
|
role: "region",
|
|
33
35
|
"aria-roledescription": "carousel",
|
|
34
|
-
"aria-label":
|
|
35
|
-
className: e([
|
|
36
|
-
children: [/* @__PURE__ */
|
|
37
|
-
ref:
|
|
38
|
-
className:
|
|
39
|
-
children:
|
|
40
|
-
}),
|
|
41
|
-
/* @__PURE__ */
|
|
36
|
+
"aria-label": D.label,
|
|
37
|
+
className: e([u, x]),
|
|
38
|
+
children: [/* @__PURE__ */ i("div", {
|
|
39
|
+
ref: T,
|
|
40
|
+
className: d,
|
|
41
|
+
children: S
|
|
42
|
+
}), E > 1 && /* @__PURE__ */ a(r, { children: [
|
|
43
|
+
/* @__PURE__ */ i("button", {
|
|
42
44
|
type: "button",
|
|
43
|
-
onClick: () =>
|
|
44
|
-
"aria-label":
|
|
45
|
-
className: e([
|
|
45
|
+
onClick: () => w((e) => (e - 1 + E) % E),
|
|
46
|
+
"aria-label": D.previousSlide,
|
|
47
|
+
className: e([f, p]),
|
|
46
48
|
children: "‹"
|
|
47
49
|
}),
|
|
48
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ i("button", {
|
|
49
51
|
type: "button",
|
|
50
|
-
onClick: () =>
|
|
51
|
-
"aria-label":
|
|
52
|
-
className: e([
|
|
52
|
+
onClick: () => w((e) => (e + 1) % E),
|
|
53
|
+
"aria-label": D.nextSlide,
|
|
54
|
+
className: e([f, m]),
|
|
53
55
|
children: "›"
|
|
54
56
|
}),
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
className:
|
|
57
|
-
children: Array.from({ length:
|
|
57
|
+
/* @__PURE__ */ i("div", {
|
|
58
|
+
className: h,
|
|
59
|
+
children: Array.from({ length: E }, (n, r) => /* @__PURE__ */ i("button", {
|
|
58
60
|
type: "button",
|
|
59
|
-
onClick: () =>
|
|
60
|
-
"aria-label":
|
|
61
|
-
className: e([
|
|
61
|
+
onClick: () => w(r),
|
|
62
|
+
"aria-label": t(D.goToSlide, { index: r + 1 }),
|
|
63
|
+
className: e([g, r === C && _])
|
|
62
64
|
}, r))
|
|
63
65
|
})
|
|
64
66
|
] })]
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
69
|
//#endregion
|
|
68
|
-
export {
|
|
70
|
+
export { v as default };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
|
|
2
|
+
import { classnames as e } from "../../utils/classnames.js";
|
|
3
|
+
import { useFocusScope as t } from "../../utils/focus-scope.js";
|
|
4
|
+
import { FloatingPanel as n, useFloating as r } from "../../utils/floating.js";
|
|
5
|
+
import { useStrings as i } from "../LocaleProvider/useStrings.js";
|
|
6
|
+
/* empty css */
|
|
7
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment as ee, useCallback as s, useEffect as c, useId as te, useRef as l, useState as ne } from "react";
|
|
9
|
+
import { isControl as u, useControl as d, useThru as f, watch as p } from "react-use-control";
|
|
10
|
+
//#region src/lib/components/Cascader/Cascader.tsx
|
|
11
|
+
var m = "haze-Cascader__wrapper", h = "haze-Cascader__trigger", g = "haze-Cascader__triggerValue", _ = "haze-Cascader__triggerPlaceholder", re = "haze-Cascader__triggerCaret", ie = "haze-Cascader__separator", ae = "haze-Cascader__panel", oe = "haze-Cascader__column", se = "haze-Cascader__item", v = "haze-Cascader__itemInPath", y = "haze-Cascader__itemLabel", b = "haze-Cascader__chevron", x = () => /* @__PURE__ */ a("svg", {
|
|
12
|
+
viewBox: "0 0 12 12",
|
|
13
|
+
fill: "none",
|
|
14
|
+
stroke: "currentColor",
|
|
15
|
+
strokeWidth: "2",
|
|
16
|
+
strokeLinecap: "round",
|
|
17
|
+
strokeLinejoin: "round",
|
|
18
|
+
"aria-hidden": "true",
|
|
19
|
+
focusable: "false",
|
|
20
|
+
children: a("path", { d: "M4 2l4 4-4 4" })
|
|
21
|
+
}), S = () => /* @__PURE__ */ a("svg", {
|
|
22
|
+
viewBox: "0 0 12 12",
|
|
23
|
+
fill: "none",
|
|
24
|
+
stroke: "currentColor",
|
|
25
|
+
strokeWidth: "2",
|
|
26
|
+
strokeLinecap: "round",
|
|
27
|
+
strokeLinejoin: "round",
|
|
28
|
+
"aria-hidden": "true",
|
|
29
|
+
focusable: "false",
|
|
30
|
+
children: a("path", { d: "M2 4l4 4 4-4" })
|
|
31
|
+
}), C = "[role=\"menuitem\"]";
|
|
32
|
+
function w(e) {
|
|
33
|
+
return e ? Array.from(e.querySelectorAll("[data-haze-cascader-column]")) : [];
|
|
34
|
+
}
|
|
35
|
+
function T(e) {
|
|
36
|
+
return e ? Array.from(e.querySelectorAll(C)) : [];
|
|
37
|
+
}
|
|
38
|
+
function E({ options: E, value: D, onChange: O, placeholder: k, changeOnSelect: A = !1, expandTrigger: j = "click", className: M, ...N }) {
|
|
39
|
+
let P = i("cascader"), [F, I] = d(!1, !1), L = u(D), [R, z] = d(f(L ? D : void 0, p((e) => O?.(e))), L ? [] : D ?? []), [B, V] = ne([]), H = te(), U = l(null), W = l(null), G = l(null), K = l(!1), q = r({
|
|
40
|
+
open: F,
|
|
41
|
+
setOpen: I,
|
|
42
|
+
triggerRef: U,
|
|
43
|
+
panelRef: W,
|
|
44
|
+
animated: !0
|
|
45
|
+
}), J = t({
|
|
46
|
+
enabled: F,
|
|
47
|
+
autoFocus: !1,
|
|
48
|
+
returnFocus: !0
|
|
49
|
+
}), Y = l(!1);
|
|
50
|
+
c(() => {
|
|
51
|
+
let e = F && !Y.current;
|
|
52
|
+
Y.current = F, e && V(R);
|
|
53
|
+
}, [F, R]), c(() => {
|
|
54
|
+
if (!F) {
|
|
55
|
+
K.current = !1, G.current = null;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!q.shown) return;
|
|
59
|
+
let e = G.current;
|
|
60
|
+
if (e) {
|
|
61
|
+
G.current = null;
|
|
62
|
+
let t = T(w(W.current)[e.level]), n = e.value === void 0 ? e.index : t.findIndex((t) => t.dataset.value === e.value);
|
|
63
|
+
(n >= 0 ? t[n] : t[0])?.focus();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (K.current) return;
|
|
67
|
+
let t = W.current;
|
|
68
|
+
if (!t) return;
|
|
69
|
+
let n = Array.from(t.querySelectorAll(C)), r = R.length - 1, i = R[r], a;
|
|
70
|
+
if (i !== void 0) {
|
|
71
|
+
if (a = n.find((e) => e.dataset.level === String(r) && e.dataset.value === i), !a) return;
|
|
72
|
+
} else a = n.find((e) => e.dataset.level === "0");
|
|
73
|
+
a && (K.current = !0, a.focus());
|
|
74
|
+
}, [
|
|
75
|
+
F,
|
|
76
|
+
q.shown,
|
|
77
|
+
B,
|
|
78
|
+
R
|
|
79
|
+
]);
|
|
80
|
+
let ce = s((e) => {
|
|
81
|
+
W.current = e, J(e);
|
|
82
|
+
}, [W, J]), X = [E];
|
|
83
|
+
for (let e of B) {
|
|
84
|
+
let t = X.at(-1).find((t) => t.value === e)?.children;
|
|
85
|
+
if (!t?.length) break;
|
|
86
|
+
X.push(t);
|
|
87
|
+
}
|
|
88
|
+
let Z = [], Q = E;
|
|
89
|
+
for (let e of R) {
|
|
90
|
+
let t = Q.find((t) => t.value === e);
|
|
91
|
+
if (!t) break;
|
|
92
|
+
Z.push(t), Q = t.children ?? [];
|
|
93
|
+
}
|
|
94
|
+
let $ = (e, t) => {
|
|
95
|
+
let n = [...B.slice(0, t), e.value];
|
|
96
|
+
e.children?.length ? (V(n), A && z(n)) : (z(n), I(!1), U.current?.focus());
|
|
97
|
+
}, le = (e, t) => {
|
|
98
|
+
j === "hover" && V([...B.slice(0, t), e.value]);
|
|
99
|
+
}, ue = (e) => {
|
|
100
|
+
!F && (e.key === "ArrowDown" || e.key === "ArrowUp") && (e.preventDefault(), I(!0));
|
|
101
|
+
}, de = (e) => {
|
|
102
|
+
let t = W.current;
|
|
103
|
+
if (!t) return;
|
|
104
|
+
let n = (document.activeElement instanceof HTMLElement ? document.activeElement : null)?.closest(C) ?? void 0, r = n?.closest("[data-haze-cascader-column]"), i = n ? Number(n.dataset.level) : 0;
|
|
105
|
+
switch (e.key) {
|
|
106
|
+
case "ArrowDown":
|
|
107
|
+
case "ArrowUp": {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
let i = T(r ?? w(t)[0]);
|
|
110
|
+
if (i.length === 0) return;
|
|
111
|
+
let a = n ? i.indexOf(n) : -1;
|
|
112
|
+
i[a < 0 ? e.key === "ArrowDown" ? 0 : i.length - 1 : (a + (e.key === "ArrowDown" ? 1 : -1) + i.length) % i.length]?.focus();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
case "ArrowRight":
|
|
116
|
+
if (n?.getAttribute("aria-haspopup") !== "true") return;
|
|
117
|
+
e.preventDefault(), V([...B.slice(0, i), n.dataset.value]), G.current = {
|
|
118
|
+
level: i + 1,
|
|
119
|
+
index: 0
|
|
120
|
+
};
|
|
121
|
+
return;
|
|
122
|
+
case "ArrowLeft": {
|
|
123
|
+
if (!n || B.length === 0) return;
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
let t = B[B.length - 1];
|
|
126
|
+
V(B.slice(0, -1)), G.current = {
|
|
127
|
+
level: B.length - 1,
|
|
128
|
+
index: 0,
|
|
129
|
+
value: t
|
|
130
|
+
};
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
case "Home":
|
|
134
|
+
case "End": {
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
let n = T(r ?? w(t)[0]);
|
|
137
|
+
if (n.length === 0) return;
|
|
138
|
+
(e.key === "Home" ? n[0] : n[n.length - 1])?.focus();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
case "Enter": {
|
|
142
|
+
if (!n) return;
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
let t = X[i]?.find((e) => e.value === n.dataset.value);
|
|
145
|
+
if (!t) return;
|
|
146
|
+
t.children?.length ? (V([...B.slice(0, i), t.value]), G.current = {
|
|
147
|
+
level: i + 1,
|
|
148
|
+
index: 0
|
|
149
|
+
}) : $(t, i);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
case "Escape":
|
|
153
|
+
case "Tab":
|
|
154
|
+
e.preventDefault(), I(!1);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
return /* @__PURE__ */ o("div", {
|
|
159
|
+
...N,
|
|
160
|
+
className: e([m, M]),
|
|
161
|
+
children: [/* @__PURE__ */ o("button", {
|
|
162
|
+
ref: U,
|
|
163
|
+
type: "button",
|
|
164
|
+
style: q.triggerStyle,
|
|
165
|
+
"aria-haspopup": "menu",
|
|
166
|
+
"aria-expanded": F,
|
|
167
|
+
"aria-controls": H,
|
|
168
|
+
onPointerDown: q.onTriggerPointerDown,
|
|
169
|
+
onClick: q.onTriggerClick,
|
|
170
|
+
onKeyDown: ue,
|
|
171
|
+
className: e(h),
|
|
172
|
+
children: [/* @__PURE__ */ a("span", {
|
|
173
|
+
className: e(g),
|
|
174
|
+
children: Z.length === 0 ? /* @__PURE__ */ a("span", {
|
|
175
|
+
className: e(_),
|
|
176
|
+
children: k
|
|
177
|
+
}) : Z.map((t, n) => /* @__PURE__ */ o(ee, { children: [n > 0 && /* @__PURE__ */ a("span", {
|
|
178
|
+
className: e(ie),
|
|
179
|
+
children: " / "
|
|
180
|
+
}), t.label] }, t.value))
|
|
181
|
+
}), /* @__PURE__ */ a("span", {
|
|
182
|
+
"aria-hidden": "true",
|
|
183
|
+
className: e(re),
|
|
184
|
+
children: /* @__PURE__ */ a(S, {})
|
|
185
|
+
})]
|
|
186
|
+
}), /* @__PURE__ */ a(n, {
|
|
187
|
+
ref: ce,
|
|
188
|
+
behavior: q,
|
|
189
|
+
placement: "bottom",
|
|
190
|
+
id: H,
|
|
191
|
+
role: "menu",
|
|
192
|
+
visualClass: ae,
|
|
193
|
+
onKeyDown: de,
|
|
194
|
+
children: X.map((t, n) => /* @__PURE__ */ a("div", {
|
|
195
|
+
role: "menu",
|
|
196
|
+
"data-haze-cascader-column": n,
|
|
197
|
+
className: e(oe),
|
|
198
|
+
children: t.map((t) => {
|
|
199
|
+
let r = !!t.children?.length, i = B[n] === t.value;
|
|
200
|
+
return /* @__PURE__ */ o("button", {
|
|
201
|
+
type: "button",
|
|
202
|
+
role: "menuitem",
|
|
203
|
+
tabIndex: -1,
|
|
204
|
+
"data-level": n,
|
|
205
|
+
"data-value": t.value,
|
|
206
|
+
"aria-haspopup": r ? "true" : void 0,
|
|
207
|
+
"aria-expanded": r ? i : void 0,
|
|
208
|
+
onClick: () => $(t, n),
|
|
209
|
+
onMouseEnter: () => le(t, n),
|
|
210
|
+
className: e([se, i && v]),
|
|
211
|
+
children: [/* @__PURE__ */ a("span", {
|
|
212
|
+
className: e(y),
|
|
213
|
+
children: t.label
|
|
214
|
+
}), r && /* @__PURE__ */ a("span", {
|
|
215
|
+
role: "img",
|
|
216
|
+
"aria-label": P.expand,
|
|
217
|
+
className: e(b),
|
|
218
|
+
children: /* @__PURE__ */ a(x, {})
|
|
219
|
+
})]
|
|
220
|
+
}, t.value);
|
|
221
|
+
})
|
|
222
|
+
}, n))
|
|
223
|
+
})]
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
export { E as default };
|
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
|
|
2
2
|
import { classnames as e } from "../../utils/classnames.js";
|
|
3
|
+
import { useStrings as t } from "../LocaleProvider/useStrings.js";
|
|
3
4
|
/* empty css */
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useCallback as
|
|
6
|
-
import { useControl as
|
|
5
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
6
|
+
import { useCallback as i, useRef as a } from "react";
|
|
7
|
+
import { useControl as o } from "react-use-control";
|
|
7
8
|
//#region src/lib/components/ChatInput/ChatInput.tsx
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
let [
|
|
11
|
-
let e =
|
|
12
|
-
|
|
9
|
+
var s = "haze-ChatInput__wrapper", c = "haze-ChatInput__textarea", l = "haze-ChatInput__sendBtn";
|
|
10
|
+
function u({ value: u, onSend: d, placeholder: f, disabled: p, maxLength: m, className: h }) {
|
|
11
|
+
let [g, _] = o(u, ""), v = a(null), y = t("chatInput"), b = f ?? y.placeholder, x = i(() => {
|
|
12
|
+
let e = g.trim();
|
|
13
|
+
e && !p && (d?.(e), _(""), v.current && (v.current.style.height = "auto"));
|
|
13
14
|
}, [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
g,
|
|
16
|
+
p,
|
|
17
|
+
d,
|
|
18
|
+
_
|
|
18
19
|
]);
|
|
19
|
-
return /* @__PURE__ */
|
|
20
|
-
className: e([
|
|
21
|
-
children: [/* @__PURE__ */
|
|
22
|
-
ref:
|
|
23
|
-
value:
|
|
20
|
+
return /* @__PURE__ */ r("div", {
|
|
21
|
+
className: e([s, h]),
|
|
22
|
+
children: [/* @__PURE__ */ n("textarea", {
|
|
23
|
+
ref: v,
|
|
24
|
+
value: g,
|
|
24
25
|
onChange: (e) => {
|
|
25
|
-
|
|
26
|
+
_(e.target.value), v.current && (v.current.style.height = "auto", v.current.style.height = `${v.current.scrollHeight}px`);
|
|
26
27
|
},
|
|
27
28
|
onKeyDown: (e) => {
|
|
28
|
-
e.key === "Enter" && !e.shiftKey && (e.preventDefault(),
|
|
29
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), x());
|
|
29
30
|
},
|
|
30
|
-
placeholder:
|
|
31
|
-
disabled:
|
|
32
|
-
maxLength:
|
|
31
|
+
placeholder: b,
|
|
32
|
+
disabled: p,
|
|
33
|
+
maxLength: m,
|
|
33
34
|
rows: 1,
|
|
34
|
-
className: e([
|
|
35
|
-
}), /* @__PURE__ */
|
|
35
|
+
className: e([c])
|
|
36
|
+
}), /* @__PURE__ */ n("button", {
|
|
36
37
|
type: "button",
|
|
37
|
-
onClick:
|
|
38
|
-
disabled:
|
|
39
|
-
"aria-label":
|
|
40
|
-
className: e([
|
|
38
|
+
onClick: x,
|
|
39
|
+
disabled: p || !g.trim(),
|
|
40
|
+
"aria-label": y.send,
|
|
41
|
+
className: e([l]),
|
|
41
42
|
children: "↑"
|
|
42
43
|
})]
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
//#endregion
|
|
46
|
-
export {
|
|
47
|
+
export { u as default };
|
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
|
|
2
2
|
import { classnames as e } from "../../utils/classnames.js";
|
|
3
|
+
import { useStrings as t } from "../LocaleProvider/useStrings.js";
|
|
3
4
|
/* empty css */
|
|
4
|
-
import { jsx as
|
|
5
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
6
|
//#region src/lib/components/ChatMessage/ChatMessage.tsx
|
|
6
|
-
var
|
|
7
|
-
user:
|
|
8
|
-
assistant:
|
|
9
|
-
system:
|
|
7
|
+
var i = "haze-ChatMessage__wrapper", a = "haze-ChatMessage__wrapperUser", o = "haze-ChatMessage__avatarSlot", s = "haze-ChatMessage__body", c = "haze-ChatMessage__header", l = "haze-ChatMessage__headerUser", u = "haze-ChatMessage__bubble", d = "haze-ChatMessage__bubbleUser", f = "haze-ChatMessage__bubbleAssistant", p = "haze-ChatMessage__bubbleSystem", m = "haze-ChatMessage__statusText", h = "haze-ChatMessage__statusError", g = {
|
|
8
|
+
user: d,
|
|
9
|
+
assistant: f,
|
|
10
|
+
system: p
|
|
10
11
|
};
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
return /* @__PURE__ */
|
|
12
|
+
function _({ role: d, avatar: f, name: p, timestamp: _, status: v, children: y, className: b }) {
|
|
13
|
+
let x = d === "user", S = t("chatMessage");
|
|
14
|
+
return /* @__PURE__ */ r("div", {
|
|
14
15
|
className: e([
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
i,
|
|
17
|
+
x && a,
|
|
18
|
+
b
|
|
18
19
|
]),
|
|
19
|
-
children: [
|
|
20
|
-
className: e([a]),
|
|
21
|
-
children: d || (u === "user" ? "U" : "A")
|
|
22
|
-
}), /* @__PURE__ */ n("div", {
|
|
20
|
+
children: [d !== "system" && /* @__PURE__ */ n("div", {
|
|
23
21
|
className: e([o]),
|
|
22
|
+
children: f || (d === "user" ? "U" : "A")
|
|
23
|
+
}), /* @__PURE__ */ r("div", {
|
|
24
|
+
className: e([s]),
|
|
24
25
|
children: [
|
|
25
|
-
(
|
|
26
|
-
className: e([
|
|
27
|
-
children: [
|
|
26
|
+
(p || _) && /* @__PURE__ */ r("div", {
|
|
27
|
+
className: e([c, x && l]),
|
|
28
|
+
children: [p && /* @__PURE__ */ n("span", { children: p }), _ && /* @__PURE__ */ n("span", { children: _ })]
|
|
28
29
|
}),
|
|
29
|
-
/* @__PURE__ */
|
|
30
|
-
className: e([
|
|
31
|
-
children:
|
|
30
|
+
/* @__PURE__ */ n("div", {
|
|
31
|
+
className: e([u, g[d]]),
|
|
32
|
+
children: y
|
|
32
33
|
}),
|
|
33
|
-
|
|
34
|
-
className: e([
|
|
34
|
+
v && /* @__PURE__ */ r("div", {
|
|
35
|
+
className: e([m, v === "error" && h]),
|
|
35
36
|
children: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
v === "sending" && S.sending,
|
|
38
|
+
v === "sent" && S.sent,
|
|
39
|
+
v === "error" && S.failedToSend
|
|
39
40
|
]
|
|
40
41
|
})
|
|
41
42
|
]
|
|
@@ -43,4 +44,4 @@ function g({ role: u, avatar: d, name: f, timestamp: g, status: _, children: v,
|
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
//#endregion
|
|
46
|
-
export {
|
|
47
|
+
export { _ as default };
|