@duskmoon-dev/components 0.3.1 → 0.4.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 +61 -2
- package/dist/{chunk-r9wkv7xd.js → chunk-fwjzvsrx.js} +3 -3
- package/dist/classes/chat.d.ts +43 -0
- package/dist/classes/console-page.d.ts +16 -0
- package/dist/classes/dropdown.d.ts +5 -5
- package/dist/classes/fab.d.ts +11 -0
- package/dist/classes/index.d.ts +6 -0
- package/dist/classes/index.js +1443 -1210
- package/dist/classes/megamenu.d.ts +10 -0
- package/dist/classes/otp-input.d.ts +12 -0
- package/dist/classes/popover.d.ts +1 -3
- package/dist/classes/swap.d.ts +12 -0
- package/dist/classes/tree-select.d.ts +6 -6
- package/dist/components/anchor/index.js +2 -2
- package/dist/components/app/index.js +211 -151
- package/dist/components/avatar/Avatar.types.d.ts +1 -1
- package/dist/components/avatar/index.js +2 -1
- package/dist/components/badge/index.js +1 -1
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.types.d.ts +8 -0
- package/dist/components/button/index.js +253 -24
- package/dist/components/calendar/index.js +44 -19
- package/dist/components/cascader/index.js +2 -2
- package/dist/components/chat/Chat.d.ts +22 -0
- package/dist/components/chat/Chat.types.d.ts +73 -0
- package/dist/components/chat/index.d.ts +2 -0
- package/dist/components/chat/index.js +309 -0
- package/dist/components/color-picker/ColorPicker.types.d.ts +2 -1
- package/dist/components/color-picker/index.js +210 -13
- package/dist/components/config-provider/index.js +2 -2
- package/dist/components/console-page/ConsolePage.d.ts +2 -0
- package/dist/components/console-page/ConsolePage.types.d.ts +29 -0
- package/dist/components/console-page/index.d.ts +2 -0
- package/dist/components/console-page/index.js +205 -0
- package/dist/components/date-picker/DatePicker.types.d.ts +1 -0
- package/dist/components/date-picker/index.js +537 -35
- package/dist/components/date-picker/usePickerDropdown.d.ts +17 -0
- package/dist/components/dm-breadcrumb/index.js +18 -18
- package/dist/components/dm-date-picker/index.js +635 -133
- package/dist/components/dm-drawer/index.js +269 -40
- package/dist/components/dm-layout/index.js +575 -208
- package/dist/components/dm-menu/index.js +399 -32
- package/dist/components/dm-message/index.js +18 -18
- package/dist/components/dm-page-header/index.js +537 -247
- package/dist/components/dm-pagination/index.js +39 -39
- package/dist/components/dm-pro-table/index.js +2374 -1559
- package/dist/components/dm-provider/index.js +94 -94
- package/dist/components/dm-query/DmQuery.types.d.ts +1 -1
- package/dist/components/dm-query/index.js +955 -210
- package/dist/components/dm-search/DmSearch.types.d.ts +4 -0
- package/dist/components/dm-search/index.js +937 -183
- package/dist/components/dm-splitter/index.js +32 -32
- package/dist/components/dm-status/index.js +25 -25
- package/dist/components/dm-table/index.js +1430 -676
- package/dist/components/dm-tabs/index.js +34 -34
- package/dist/components/dm-toolbar/index.js +423 -133
- package/dist/components/dm-tree/index.js +92 -92
- package/dist/components/dm-truncate/index.js +145 -65
- package/dist/components/dropdown/Dropdown.types.d.ts +1 -1
- package/dist/components/dropdown/index.js +467 -177
- package/dist/components/fab/Fab.d.ts +4 -0
- package/dist/components/fab/Fab.types.d.ts +25 -0
- package/dist/components/fab/index.d.ts +2 -0
- package/dist/components/fab/index.js +480 -0
- package/dist/components/form/Form.types.d.ts +1 -0
- package/dist/components/form/index.js +16 -5
- package/dist/components/grid/index.js +2 -2
- package/dist/components/input/index.js +4 -4
- package/dist/components/markdown/index.js +1 -1
- package/dist/components/megamenu/Megamenu.d.ts +2 -0
- package/dist/components/megamenu/Megamenu.types.d.ts +32 -0
- package/dist/components/megamenu/index.d.ts +2 -0
- package/dist/components/megamenu/index.js +214 -0
- package/dist/components/message/index.js +5 -5
- package/dist/components/modal/index.js +128 -68
- package/dist/components/notification/index.js +2 -2
- package/dist/components/otp-input/OtpInput.d.ts +2 -0
- package/dist/components/otp-input/OtpInput.types.d.ts +16 -0
- package/dist/components/otp-input/index.d.ts +2 -0
- package/dist/components/otp-input/index.js +112 -0
- package/dist/components/popconfirm/index.js +297 -68
- package/dist/components/popover/index.js +24 -4
- package/dist/components/skeleton/index.js +5 -5
- package/dist/components/spin/index.js +2 -2
- package/dist/components/steps/index.js +2 -2
- package/dist/components/swap/Swap.d.ts +3 -0
- package/dist/components/swap/Swap.types.d.ts +22 -0
- package/dist/components/swap/index.d.ts +2 -0
- package/dist/components/swap/index.js +109 -0
- package/dist/components/table/index.js +2 -2
- package/dist/components/tabs/index.js +2 -2
- package/dist/components/tag/index.js +2 -2
- package/dist/components/time-picker/TimePicker.types.d.ts +1 -0
- package/dist/components/time-picker/index.js +167 -29
- package/dist/components/tooltip/Tooltip.types.d.ts +4 -0
- package/dist/components/tooltip/index.js +107 -27
- package/dist/components/tour/index.js +315 -86
- package/dist/components/tree-select/index.js +8 -8
- package/dist/components/typography/index.js +4 -4
- package/dist/components/upload/Upload.types.d.ts +1 -0
- package/dist/components/upload/index.js +7 -5
- package/dist/generated/version.d.ts +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4023 -2134
- package/dist/infrastructure.js +11 -11
- package/dist/styles.css +13677 -9811
- package/dist/theme/index.js +3 -3
- package/dist/utils/index.js +5 -5
- package/package.json +30 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ButtonProps } from "./Button.types";
|
|
3
|
-
export declare function Button({ color, appearance, shape, size, block, isLoading, leftIcon, rightIcon, className, children, disabled, ref, ...props }: ButtonProps): React.JSX.Element;
|
|
3
|
+
export declare function Button({ color, appearance, shape, size, block, isLoading, leftIcon, rightIcon, className, children, disabled, ref, confirm, onClick, ...props }: ButtonProps): React.JSX.Element;
|
|
@@ -12,4 +12,12 @@ export interface ButtonProps extends ComponentProps<"button"> {
|
|
|
12
12
|
isLoading?: boolean;
|
|
13
13
|
leftIcon?: React.ReactNode;
|
|
14
14
|
rightIcon?: React.ReactNode;
|
|
15
|
+
confirm?: boolean | {
|
|
16
|
+
title?: React.ReactNode;
|
|
17
|
+
component?: React.ReactElement;
|
|
18
|
+
message?: React.ReactNode;
|
|
19
|
+
description?: React.ReactNode;
|
|
20
|
+
confirmText?: React.ReactNode;
|
|
21
|
+
cancelText?: React.ReactNode;
|
|
22
|
+
};
|
|
15
23
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
// src/components/button/Button.tsx
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
6
|
+
|
|
3
7
|
// ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
4
8
|
function r(e) {
|
|
5
9
|
var t, f, n = "";
|
|
@@ -48,7 +52,7 @@ var buttonAppearanceClasses = {
|
|
|
48
52
|
};
|
|
49
53
|
var buttonShapeClasses = {
|
|
50
54
|
rect: "",
|
|
51
|
-
circle: "btn-circle",
|
|
55
|
+
circle: "btn-circle btn-icon",
|
|
52
56
|
square: "btn-square"
|
|
53
57
|
};
|
|
54
58
|
var buttonSizeClasses = {
|
|
@@ -68,11 +72,14 @@ function getButtonClasses({
|
|
|
68
72
|
isLoading,
|
|
69
73
|
className
|
|
70
74
|
}) {
|
|
71
|
-
return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
|
|
75
|
+
return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], shape === "circle" && size === "xs" && "btn-icon-sm", shape === "circle" && size === "sm" && "btn-icon-sm", shape === "circle" && size === "lg" && "btn-icon-lg", block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
// src/components/button/Button.tsx
|
|
75
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
79
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
80
|
+
function isPromiseLike(value) {
|
|
81
|
+
return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
82
|
+
}
|
|
76
83
|
function Button({
|
|
77
84
|
color = "primary",
|
|
78
85
|
appearance = "filled",
|
|
@@ -86,8 +93,155 @@ function Button({
|
|
|
86
93
|
children,
|
|
87
94
|
disabled,
|
|
88
95
|
ref,
|
|
96
|
+
confirm,
|
|
97
|
+
onClick,
|
|
89
98
|
...props
|
|
90
99
|
}) {
|
|
100
|
+
const buttonRef = React.useRef(null);
|
|
101
|
+
const popoverRef = React.useRef(null);
|
|
102
|
+
const cancelRef = React.useRef(null);
|
|
103
|
+
const approvalRef = React.useRef("idle");
|
|
104
|
+
const pendingRef = React.useRef(false);
|
|
105
|
+
const actionRef = React.useRef(0);
|
|
106
|
+
const operationRef = React.useRef(0);
|
|
107
|
+
const mountedRef = React.useRef(false);
|
|
108
|
+
const [portalTarget, setPortalTarget] = React.useState(null);
|
|
109
|
+
const [confirmLoading, setConfirmLoading] = React.useState(false);
|
|
110
|
+
const [confirmError, setConfirmError] = React.useState(false);
|
|
111
|
+
const generatedId = React.useId().replace(/:/g, "");
|
|
112
|
+
const popoverId = `button-confirm-${generatedId}`;
|
|
113
|
+
const titleId = `${popoverId}-title`;
|
|
114
|
+
const descriptionId = `${popoverId}-description`;
|
|
115
|
+
const anchor = `--${popoverId}-anchor`;
|
|
116
|
+
const hasConfirm = Boolean(confirm);
|
|
117
|
+
const confirmation = confirm && typeof confirm === "object" ? confirm : undefined;
|
|
118
|
+
const title = confirmation ? confirmation.title : "Confirm action";
|
|
119
|
+
const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
|
|
120
|
+
const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
|
|
121
|
+
const hasContent = content !== undefined && content !== null && content !== false && content !== "";
|
|
122
|
+
const mergedRef = React.useCallback((node) => {
|
|
123
|
+
buttonRef.current = node;
|
|
124
|
+
if (!node) {
|
|
125
|
+
if (typeof ref === "function")
|
|
126
|
+
ref(null);
|
|
127
|
+
else if (ref)
|
|
128
|
+
ref.current = null;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const cleanup = typeof ref === "function" ? ref(node) : undefined;
|
|
132
|
+
if (ref && typeof ref !== "function")
|
|
133
|
+
ref.current = node;
|
|
134
|
+
return () => {
|
|
135
|
+
buttonRef.current = null;
|
|
136
|
+
if (typeof cleanup === "function")
|
|
137
|
+
cleanup();
|
|
138
|
+
else if (typeof ref === "function")
|
|
139
|
+
ref(null);
|
|
140
|
+
else if (ref)
|
|
141
|
+
ref.current = null;
|
|
142
|
+
};
|
|
143
|
+
}, [ref]);
|
|
144
|
+
React.useEffect(() => {
|
|
145
|
+
mountedRef.current = true;
|
|
146
|
+
return () => {
|
|
147
|
+
mountedRef.current = false;
|
|
148
|
+
operationRef.current += 1;
|
|
149
|
+
};
|
|
150
|
+
}, []);
|
|
151
|
+
React.useEffect(() => {
|
|
152
|
+
operationRef.current += 1;
|
|
153
|
+
approvalRef.current = "idle";
|
|
154
|
+
setConfirmError(false);
|
|
155
|
+
setPortalTarget(hasConfirm ? document.body : null);
|
|
156
|
+
}, [hasConfirm]);
|
|
157
|
+
function closePopover() {
|
|
158
|
+
if (popoverRef.current?.matches(":popover-open")) {
|
|
159
|
+
popoverRef.current.hidePopover();
|
|
160
|
+
}
|
|
161
|
+
buttonRef.current?.focus();
|
|
162
|
+
}
|
|
163
|
+
function handleClick(event) {
|
|
164
|
+
if (!confirm) {
|
|
165
|
+
onClick?.(event);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (approvalRef.current === "native") {
|
|
169
|
+
approvalRef.current = "idle";
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (approvalRef.current === "action") {
|
|
173
|
+
approvalRef.current = "idle";
|
|
174
|
+
let result;
|
|
175
|
+
try {
|
|
176
|
+
result = onClick?.(event);
|
|
177
|
+
} catch {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
pendingRef.current = false;
|
|
180
|
+
setConfirmError(true);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (!isPromiseLike(result)) {
|
|
184
|
+
pendingRef.current = false;
|
|
185
|
+
closePopover();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const userPreventedDefault = event.defaultPrevented;
|
|
189
|
+
event.preventDefault();
|
|
190
|
+
setConfirmLoading(true);
|
|
191
|
+
const action = actionRef.current;
|
|
192
|
+
const operation = operationRef.current;
|
|
193
|
+
Promise.resolve(result).then(() => {
|
|
194
|
+
if (!mountedRef.current || action !== actionRef.current)
|
|
195
|
+
return;
|
|
196
|
+
pendingRef.current = false;
|
|
197
|
+
setConfirmLoading(false);
|
|
198
|
+
if (operation !== operationRef.current)
|
|
199
|
+
return;
|
|
200
|
+
closePopover();
|
|
201
|
+
if (!userPreventedDefault && !buttonRef.current?.disabled) {
|
|
202
|
+
approvalRef.current = "native";
|
|
203
|
+
buttonRef.current?.click();
|
|
204
|
+
approvalRef.current = "idle";
|
|
205
|
+
}
|
|
206
|
+
}, () => {
|
|
207
|
+
if (!mountedRef.current || action !== actionRef.current)
|
|
208
|
+
return;
|
|
209
|
+
pendingRef.current = false;
|
|
210
|
+
setConfirmLoading(false);
|
|
211
|
+
if (operation !== operationRef.current)
|
|
212
|
+
return;
|
|
213
|
+
setConfirmError(true);
|
|
214
|
+
cancelRef.current?.focus();
|
|
215
|
+
});
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
if (disabled || isLoading || pendingRef.current)
|
|
220
|
+
return;
|
|
221
|
+
if (popoverRef.current?.matches(":popover-open")) {
|
|
222
|
+
closePopover();
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
setConfirmError(false);
|
|
226
|
+
popoverRef.current?.showPopover();
|
|
227
|
+
cancelRef.current?.focus();
|
|
228
|
+
}
|
|
229
|
+
function handleConfirm(event) {
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
event.stopPropagation();
|
|
232
|
+
const trigger = buttonRef.current;
|
|
233
|
+
if (disabled || isLoading || pendingRef.current || !trigger || trigger.disabled || !event.currentTarget.matches(":popover-open"))
|
|
234
|
+
return;
|
|
235
|
+
setConfirmError(false);
|
|
236
|
+
pendingRef.current = true;
|
|
237
|
+
actionRef.current += 1;
|
|
238
|
+
approvalRef.current = "action";
|
|
239
|
+
trigger.click();
|
|
240
|
+
if (approvalRef.current === "action") {
|
|
241
|
+
approvalRef.current = "idle";
|
|
242
|
+
pendingRef.current = false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
91
245
|
const classes = getButtonClasses({
|
|
92
246
|
color,
|
|
93
247
|
appearance,
|
|
@@ -97,29 +251,104 @@ function Button({
|
|
|
97
251
|
isLoading,
|
|
98
252
|
className
|
|
99
253
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
...props,
|
|
254
|
+
const confirmClasses = getButtonClasses({
|
|
255
|
+
color,
|
|
256
|
+
size: "sm",
|
|
257
|
+
isLoading: confirmLoading
|
|
258
|
+
});
|
|
259
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
107
260
|
children: [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
261
|
+
/* @__PURE__ */ jsxs("button", {
|
|
262
|
+
ref: confirm ? mergedRef : ref,
|
|
263
|
+
className: classes,
|
|
264
|
+
disabled: disabled || isLoading,
|
|
265
|
+
"aria-busy": isLoading,
|
|
266
|
+
"aria-disabled": disabled || isLoading,
|
|
267
|
+
...props,
|
|
268
|
+
style: confirm ? { ...props.style, anchorName: anchor } : props.style,
|
|
269
|
+
"aria-haspopup": confirm ? "dialog" : props["aria-haspopup"],
|
|
270
|
+
"aria-controls": confirm ? popoverId : props["aria-controls"],
|
|
271
|
+
onClick: confirm ? handleClick : onClick,
|
|
272
|
+
children: [
|
|
273
|
+
isLoading && /* @__PURE__ */ jsx("span", {
|
|
274
|
+
className: "btn-spinner"
|
|
275
|
+
}),
|
|
276
|
+
!isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
|
|
277
|
+
className: "btn-icon-left",
|
|
278
|
+
children: leftIcon
|
|
279
|
+
}),
|
|
280
|
+
/* @__PURE__ */ jsx("span", {
|
|
281
|
+
className: "btn-content",
|
|
282
|
+
children
|
|
283
|
+
}),
|
|
284
|
+
!isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
|
|
285
|
+
className: "btn-icon-right",
|
|
286
|
+
children: rightIcon
|
|
287
|
+
})
|
|
288
|
+
]
|
|
118
289
|
}),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
290
|
+
confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs("form", {
|
|
291
|
+
id: popoverId,
|
|
292
|
+
ref: popoverRef,
|
|
293
|
+
popover: "auto",
|
|
294
|
+
role: "dialog",
|
|
295
|
+
"aria-labelledby": hasTitle ? titleId : undefined,
|
|
296
|
+
"aria-label": hasTitle ? undefined : "Confirm action",
|
|
297
|
+
"aria-describedby": hasContent ? descriptionId : undefined,
|
|
298
|
+
className: "popover popover-confirm popover-bottom",
|
|
299
|
+
style: { positionAnchor: anchor },
|
|
300
|
+
onSubmit: handleConfirm,
|
|
301
|
+
onClick: (event) => event.stopPropagation(),
|
|
302
|
+
onToggle: (event) => {
|
|
303
|
+
if (!event.currentTarget.matches(":popover-open")) {
|
|
304
|
+
operationRef.current += 1;
|
|
305
|
+
if (event.currentTarget.contains(document.activeElement) || document.activeElement === document.body) {
|
|
306
|
+
buttonRef.current?.focus();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
children: [
|
|
311
|
+
hasTitle && /* @__PURE__ */ jsx("div", {
|
|
312
|
+
className: "popover-header",
|
|
313
|
+
children: /* @__PURE__ */ jsx("h3", {
|
|
314
|
+
id: titleId,
|
|
315
|
+
className: "popover-title",
|
|
316
|
+
children: title
|
|
317
|
+
})
|
|
318
|
+
}),
|
|
319
|
+
hasContent && /* @__PURE__ */ jsx("div", {
|
|
320
|
+
id: descriptionId,
|
|
321
|
+
className: "popover-body",
|
|
322
|
+
children: content
|
|
323
|
+
}),
|
|
324
|
+
confirmError && /* @__PURE__ */ jsx("div", {
|
|
325
|
+
role: "alert",
|
|
326
|
+
className: "popover-body",
|
|
327
|
+
children: "The action failed. Please try again."
|
|
328
|
+
}),
|
|
329
|
+
/* @__PURE__ */ jsxs("div", {
|
|
330
|
+
className: "popover-footer",
|
|
331
|
+
children: [
|
|
332
|
+
/* @__PURE__ */ jsx("button", {
|
|
333
|
+
ref: cancelRef,
|
|
334
|
+
type: "button",
|
|
335
|
+
className: "btn btn-text btn-sm",
|
|
336
|
+
popoverTarget: popoverId,
|
|
337
|
+
popoverTargetAction: "hide",
|
|
338
|
+
disabled: confirmLoading,
|
|
339
|
+
children: confirmation?.cancelText ?? "Cancel"
|
|
340
|
+
}),
|
|
341
|
+
/* @__PURE__ */ jsx("button", {
|
|
342
|
+
type: "submit",
|
|
343
|
+
className: confirmClasses,
|
|
344
|
+
disabled: disabled || isLoading || confirmLoading,
|
|
345
|
+
"aria-busy": confirmLoading,
|
|
346
|
+
children: confirmation?.confirmText ?? "Confirm"
|
|
347
|
+
})
|
|
348
|
+
]
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
}), portalTarget)
|
|
123
352
|
]
|
|
124
353
|
});
|
|
125
354
|
}
|
|
@@ -140,29 +140,33 @@ function Header({
|
|
|
140
140
|
return /* @__PURE__ */ jsxs("div", {
|
|
141
141
|
className: calendarHeaderClass,
|
|
142
142
|
children: [
|
|
143
|
-
/* @__PURE__ */ jsx("
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
/* @__PURE__ */ jsx("button", {
|
|
144
|
+
type: "button",
|
|
145
|
+
className: calendarNavClass,
|
|
146
|
+
"aria-label": "Previous panel",
|
|
147
|
+
onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, -1) : addMonths(panelDate, -1), mode),
|
|
148
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
149
|
+
"aria-hidden": "true",
|
|
150
|
+
focusable: "false",
|
|
151
|
+
width: "16",
|
|
152
|
+
height: "16",
|
|
153
|
+
viewBox: "0 0 24 24",
|
|
154
|
+
fill: "none",
|
|
155
|
+
stroke: "currentColor",
|
|
156
|
+
strokeWidth: "2",
|
|
157
|
+
strokeLinecap: "round",
|
|
158
|
+
strokeLinejoin: "round",
|
|
159
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
160
|
+
d: "m15 18-6-6 6-6"
|
|
161
|
+
})
|
|
162
|
+
})
|
|
146
163
|
}),
|
|
147
164
|
/* @__PURE__ */ jsxs("div", {
|
|
148
165
|
className: calendarControlsClass,
|
|
149
166
|
children: [
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
className:
|
|
152
|
-
children:
|
|
153
|
-
/* @__PURE__ */ jsx("button", {
|
|
154
|
-
type: "button",
|
|
155
|
-
"aria-label": "Previous panel",
|
|
156
|
-
onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, -1) : addMonths(panelDate, -1), mode),
|
|
157
|
-
children: "Previous"
|
|
158
|
-
}),
|
|
159
|
-
/* @__PURE__ */ jsx("button", {
|
|
160
|
-
type: "button",
|
|
161
|
-
"aria-label": "Next panel",
|
|
162
|
-
onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, 1) : addMonths(panelDate, 1), mode),
|
|
163
|
-
children: "Next"
|
|
164
|
-
})
|
|
165
|
-
]
|
|
167
|
+
/* @__PURE__ */ jsx("div", {
|
|
168
|
+
className: calendarTitleClass,
|
|
169
|
+
children: title
|
|
166
170
|
}),
|
|
167
171
|
/* @__PURE__ */ jsxs("div", {
|
|
168
172
|
className: calendarModeClass,
|
|
@@ -182,6 +186,27 @@ function Header({
|
|
|
182
186
|
]
|
|
183
187
|
})
|
|
184
188
|
]
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ jsx("button", {
|
|
191
|
+
type: "button",
|
|
192
|
+
className: calendarNavClass,
|
|
193
|
+
"aria-label": "Next panel",
|
|
194
|
+
onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, 1) : addMonths(panelDate, 1), mode),
|
|
195
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
196
|
+
"aria-hidden": "true",
|
|
197
|
+
focusable: "false",
|
|
198
|
+
width: "16",
|
|
199
|
+
height: "16",
|
|
200
|
+
viewBox: "0 0 24 24",
|
|
201
|
+
fill: "none",
|
|
202
|
+
stroke: "currentColor",
|
|
203
|
+
strokeWidth: "2",
|
|
204
|
+
strokeLinecap: "round",
|
|
205
|
+
strokeLinejoin: "round",
|
|
206
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
207
|
+
d: "m9 18 6-6-6-6"
|
|
208
|
+
})
|
|
209
|
+
})
|
|
185
210
|
})
|
|
186
211
|
]
|
|
187
212
|
});
|
|
@@ -402,9 +402,9 @@ var CascaderRoot = forwardRef(({
|
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
if (multiple) {
|
|
405
|
-
return selectedPaths.map((
|
|
405
|
+
return selectedPaths.map((path, index) => /* @__PURE__ */ jsx("span", {
|
|
406
406
|
className: cascaderTagClass,
|
|
407
|
-
children: displayRender ? displayRender(labelsForPath(
|
|
407
|
+
children: displayRender ? displayRender(labelsForPath(path, names), path) : defaultDisplay(labelsForPath(path, names))
|
|
408
408
|
}, valueKey(selectedValues[index] ?? [])));
|
|
409
409
|
}
|
|
410
410
|
const path = selectedPaths[0] ?? [];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ChatBubbleProps, ChatComponent, ChatActionsProps, ChatScrollIndicatorProps, ChatToolProps, ChatTypingProps } from "./Chat.types";
|
|
3
|
+
export declare const ChatAvatar: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export declare const ChatHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export declare const ChatBubble: React.ForwardRefExoticComponent<Omit<ChatBubbleProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export declare const ChatFooter: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export declare const ChatStatus: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export declare const ChatStatusItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
9
|
+
export declare const ChatStatusValue: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
10
|
+
export declare const ChatActions: React.ForwardRefExoticComponent<Omit<ChatActionsProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export declare const ChatScroll: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
export declare const ChatScrollBody: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export declare const ChatScrollTrack: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export declare const ChatScrollIndicator: React.ForwardRefExoticComponent<Omit<ChatScrollIndicatorProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
15
|
+
export declare const ChatReasoning: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>, "ref"> & React.RefAttributes<HTMLDetailsElement>>;
|
|
16
|
+
export declare const ChatTool: React.ForwardRefExoticComponent<Omit<ChatToolProps, "ref"> & React.RefAttributes<HTMLDetailsElement>>;
|
|
17
|
+
export declare const ChatToolHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
18
|
+
export declare const ChatToolStatus: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
19
|
+
export declare const ChatToolCall: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export declare const ChatToolResult: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export declare const ChatTyping: React.ForwardRefExoticComponent<Omit<ChatTypingProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
22
|
+
export declare const Chat: ChatComponent;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ComponentProps, ForwardRefExoticComponent, RefAttributes } from "react";
|
|
2
|
+
export type ChatPlacement = "start" | "end";
|
|
3
|
+
export type ChatTimeline = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24;
|
|
4
|
+
export type ChatBubbleColor = "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error";
|
|
5
|
+
export type ChatBubbleSize = "xs" | "sm" | "md" | "lg";
|
|
6
|
+
export type ChatToolState = "pending" | "running" | "success" | "error";
|
|
7
|
+
export interface ChatProps extends ComponentProps<"div"> {
|
|
8
|
+
/** Position the turn at the start or end of the conversation row. */
|
|
9
|
+
placement?: ChatPlacement;
|
|
10
|
+
/** Pair an assistant row with a scroll indicator (slots 1–24). */
|
|
11
|
+
timeline?: ChatTimeline;
|
|
12
|
+
"data-chat-tl"?: string | number;
|
|
13
|
+
}
|
|
14
|
+
export type ChatAvatarProps = ComponentProps<"div">;
|
|
15
|
+
export type ChatHeaderProps = ComponentProps<"div">;
|
|
16
|
+
export type ChatFooterProps = ComponentProps<"div">;
|
|
17
|
+
export type ChatStatusProps = ComponentProps<"div">;
|
|
18
|
+
export type ChatStatusItemProps = ComponentProps<"span">;
|
|
19
|
+
export type ChatStatusValueProps = ComponentProps<"span">;
|
|
20
|
+
export interface ChatActionsProps extends ComponentProps<"div"> {
|
|
21
|
+
/** Reveal actions on message hover or keyboard focus. */
|
|
22
|
+
hover?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export type ChatScrollProps = ComponentProps<"div">;
|
|
25
|
+
export type ChatScrollBodyProps = ComponentProps<"div">;
|
|
26
|
+
export type ChatScrollTrackProps = ComponentProps<"div">;
|
|
27
|
+
export interface ChatScrollIndicatorProps extends ComponentProps<"button"> {
|
|
28
|
+
targetId: string;
|
|
29
|
+
timeline: ChatTimeline;
|
|
30
|
+
}
|
|
31
|
+
export interface ChatBubbleProps extends ComponentProps<"div"> {
|
|
32
|
+
/** Apply a semantic DuskMoon color to the bubble. */
|
|
33
|
+
color?: ChatBubbleColor;
|
|
34
|
+
/** Control the bubble padding and font size. @default "md" */
|
|
35
|
+
size?: ChatBubbleSize;
|
|
36
|
+
/** Use the saturated form of the selected color. */
|
|
37
|
+
filled?: boolean;
|
|
38
|
+
/** Show the live streaming caret after the bubble content. */
|
|
39
|
+
streaming?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export type ChatReasoningProps = ComponentProps<"details">;
|
|
42
|
+
export interface ChatToolProps extends ComponentProps<"details"> {
|
|
43
|
+
/** Reflect the current tool-call state. */
|
|
44
|
+
status?: ChatToolState;
|
|
45
|
+
}
|
|
46
|
+
export type ChatToolHeaderProps = ComponentProps<"summary">;
|
|
47
|
+
export type ChatToolStatusProps = ComponentProps<"span">;
|
|
48
|
+
export type ChatToolCallProps = ComponentProps<"div">;
|
|
49
|
+
export type ChatToolResultProps = ComponentProps<"div">;
|
|
50
|
+
export type ChatTypingProps = Omit<ComponentProps<"span">, "children">;
|
|
51
|
+
type ChatPartComponent<T extends HTMLElement, P> = ForwardRefExoticComponent<P & RefAttributes<T>>;
|
|
52
|
+
export type ChatComponent = ChatPartComponent<HTMLDivElement, ChatProps> & {
|
|
53
|
+
Avatar: ChatPartComponent<HTMLDivElement, ChatAvatarProps>;
|
|
54
|
+
Header: ChatPartComponent<HTMLDivElement, ChatHeaderProps>;
|
|
55
|
+
Bubble: ChatPartComponent<HTMLDivElement, ChatBubbleProps>;
|
|
56
|
+
Footer: ChatPartComponent<HTMLDivElement, ChatFooterProps>;
|
|
57
|
+
Status: ChatPartComponent<HTMLDivElement, ChatStatusProps>;
|
|
58
|
+
StatusItem: ChatPartComponent<HTMLSpanElement, ChatStatusItemProps>;
|
|
59
|
+
StatusValue: ChatPartComponent<HTMLSpanElement, ChatStatusValueProps>;
|
|
60
|
+
Actions: ChatPartComponent<HTMLDivElement, ChatActionsProps>;
|
|
61
|
+
Scroll: ChatPartComponent<HTMLDivElement, ChatScrollProps>;
|
|
62
|
+
ScrollBody: ChatPartComponent<HTMLDivElement, ChatScrollBodyProps>;
|
|
63
|
+
ScrollTrack: ChatPartComponent<HTMLDivElement, ChatScrollTrackProps>;
|
|
64
|
+
ScrollIndicator: ChatPartComponent<HTMLButtonElement, ChatScrollIndicatorProps>;
|
|
65
|
+
Reasoning: ChatPartComponent<HTMLDetailsElement, ChatReasoningProps>;
|
|
66
|
+
Tool: ChatPartComponent<HTMLDetailsElement, ChatToolProps>;
|
|
67
|
+
ToolHeader: ChatPartComponent<HTMLElement, ChatToolHeaderProps>;
|
|
68
|
+
ToolStatus: ChatPartComponent<HTMLSpanElement, ChatToolStatusProps>;
|
|
69
|
+
ToolCall: ChatPartComponent<HTMLDivElement, ChatToolCallProps>;
|
|
70
|
+
ToolResult: ChatPartComponent<HTMLDivElement, ChatToolResultProps>;
|
|
71
|
+
Typing: ChatPartComponent<HTMLSpanElement, ChatTypingProps>;
|
|
72
|
+
};
|
|
73
|
+
export {};
|