@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,5 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
// src/components/popconfirm/Popconfirm.tsx
|
|
4
|
+
import {
|
|
5
|
+
forwardRef,
|
|
6
|
+
useId,
|
|
7
|
+
useState
|
|
8
|
+
} from "react";
|
|
9
|
+
|
|
3
10
|
// ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
4
11
|
function r(e) {
|
|
5
12
|
var t, f, n = "";
|
|
@@ -25,6 +32,45 @@ function clsx() {
|
|
|
25
32
|
function cn(...inputs) {
|
|
26
33
|
return clsx(inputs);
|
|
27
34
|
}
|
|
35
|
+
// src/classes/popconfirm.ts
|
|
36
|
+
var popconfirmWrapperClass = "popover-wrapper popconfirm-wrapper";
|
|
37
|
+
var popconfirmBaseClass = "popover popconfirm";
|
|
38
|
+
var popconfirmOpenClass = "popover-show popconfirm-open";
|
|
39
|
+
var popconfirmArrowClass = "popover-arrow popconfirm-arrow";
|
|
40
|
+
var popconfirmNoArrowClass = "popover-no-arrow popconfirm-no-arrow";
|
|
41
|
+
var popconfirmBodyClass = "popconfirm-body";
|
|
42
|
+
var popconfirmIconClass = "popconfirm-icon";
|
|
43
|
+
var popconfirmContentClass = "popconfirm-content";
|
|
44
|
+
var popconfirmTitleClass = "popconfirm-title";
|
|
45
|
+
var popconfirmDescriptionClass = "popconfirm-description";
|
|
46
|
+
var popconfirmActionsClass = "popconfirm-actions";
|
|
47
|
+
var popconfirmPlacementClasses = {
|
|
48
|
+
top: "popover-top popconfirm-top",
|
|
49
|
+
bottom: "popover-bottom popconfirm-bottom",
|
|
50
|
+
left: "popover-left popconfirm-left",
|
|
51
|
+
right: "popover-right popconfirm-right",
|
|
52
|
+
topLeft: "popover-top popconfirm-top-left",
|
|
53
|
+
topRight: "popover-top popconfirm-top-right",
|
|
54
|
+
bottomLeft: "popover-bottom popconfirm-bottom-left",
|
|
55
|
+
bottomRight: "popover-bottom popconfirm-bottom-right",
|
|
56
|
+
leftTop: "popover-left popconfirm-left-top",
|
|
57
|
+
leftBottom: "popover-left popconfirm-left-bottom",
|
|
58
|
+
rightTop: "popover-right popconfirm-right-top",
|
|
59
|
+
rightBottom: "popover-right popconfirm-right-bottom"
|
|
60
|
+
};
|
|
61
|
+
function getPopconfirmClasses({
|
|
62
|
+
placement = "top",
|
|
63
|
+
open,
|
|
64
|
+
arrow = true,
|
|
65
|
+
className
|
|
66
|
+
}) {
|
|
67
|
+
return cn(popconfirmBaseClass, popconfirmPlacementClasses[placement], open && popconfirmOpenClass, !arrow && popconfirmNoArrowClass, className);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/components/button/Button.tsx
|
|
71
|
+
import React from "react";
|
|
72
|
+
import { createPortal } from "react-dom";
|
|
73
|
+
|
|
28
74
|
// src/classes/button.ts
|
|
29
75
|
var buttonBaseClass = "btn";
|
|
30
76
|
var buttonColorClasses = {
|
|
@@ -48,7 +94,7 @@ var buttonAppearanceClasses = {
|
|
|
48
94
|
};
|
|
49
95
|
var buttonShapeClasses = {
|
|
50
96
|
rect: "",
|
|
51
|
-
circle: "btn-circle",
|
|
97
|
+
circle: "btn-circle btn-icon",
|
|
52
98
|
square: "btn-square"
|
|
53
99
|
};
|
|
54
100
|
var buttonSizeClasses = {
|
|
@@ -68,11 +114,14 @@ function getButtonClasses({
|
|
|
68
114
|
isLoading,
|
|
69
115
|
className
|
|
70
116
|
}) {
|
|
71
|
-
return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
|
|
117
|
+
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
118
|
}
|
|
73
119
|
|
|
74
120
|
// src/components/button/Button.tsx
|
|
75
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
121
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
122
|
+
function isPromiseLike(value) {
|
|
123
|
+
return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
124
|
+
}
|
|
76
125
|
function Button({
|
|
77
126
|
color = "primary",
|
|
78
127
|
appearance = "filled",
|
|
@@ -86,8 +135,155 @@ function Button({
|
|
|
86
135
|
children,
|
|
87
136
|
disabled,
|
|
88
137
|
ref,
|
|
138
|
+
confirm,
|
|
139
|
+
onClick,
|
|
89
140
|
...props
|
|
90
141
|
}) {
|
|
142
|
+
const buttonRef = React.useRef(null);
|
|
143
|
+
const popoverRef = React.useRef(null);
|
|
144
|
+
const cancelRef = React.useRef(null);
|
|
145
|
+
const approvalRef = React.useRef("idle");
|
|
146
|
+
const pendingRef = React.useRef(false);
|
|
147
|
+
const actionRef = React.useRef(0);
|
|
148
|
+
const operationRef = React.useRef(0);
|
|
149
|
+
const mountedRef = React.useRef(false);
|
|
150
|
+
const [portalTarget, setPortalTarget] = React.useState(null);
|
|
151
|
+
const [confirmLoading, setConfirmLoading] = React.useState(false);
|
|
152
|
+
const [confirmError, setConfirmError] = React.useState(false);
|
|
153
|
+
const generatedId = React.useId().replace(/:/g, "");
|
|
154
|
+
const popoverId = `button-confirm-${generatedId}`;
|
|
155
|
+
const titleId = `${popoverId}-title`;
|
|
156
|
+
const descriptionId = `${popoverId}-description`;
|
|
157
|
+
const anchor = `--${popoverId}-anchor`;
|
|
158
|
+
const hasConfirm = Boolean(confirm);
|
|
159
|
+
const confirmation = confirm && typeof confirm === "object" ? confirm : undefined;
|
|
160
|
+
const title = confirmation ? confirmation.title : "Confirm action";
|
|
161
|
+
const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
|
|
162
|
+
const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
|
|
163
|
+
const hasContent = content !== undefined && content !== null && content !== false && content !== "";
|
|
164
|
+
const mergedRef = React.useCallback((node) => {
|
|
165
|
+
buttonRef.current = node;
|
|
166
|
+
if (!node) {
|
|
167
|
+
if (typeof ref === "function")
|
|
168
|
+
ref(null);
|
|
169
|
+
else if (ref)
|
|
170
|
+
ref.current = null;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const cleanup = typeof ref === "function" ? ref(node) : undefined;
|
|
174
|
+
if (ref && typeof ref !== "function")
|
|
175
|
+
ref.current = node;
|
|
176
|
+
return () => {
|
|
177
|
+
buttonRef.current = null;
|
|
178
|
+
if (typeof cleanup === "function")
|
|
179
|
+
cleanup();
|
|
180
|
+
else if (typeof ref === "function")
|
|
181
|
+
ref(null);
|
|
182
|
+
else if (ref)
|
|
183
|
+
ref.current = null;
|
|
184
|
+
};
|
|
185
|
+
}, [ref]);
|
|
186
|
+
React.useEffect(() => {
|
|
187
|
+
mountedRef.current = true;
|
|
188
|
+
return () => {
|
|
189
|
+
mountedRef.current = false;
|
|
190
|
+
operationRef.current += 1;
|
|
191
|
+
};
|
|
192
|
+
}, []);
|
|
193
|
+
React.useEffect(() => {
|
|
194
|
+
operationRef.current += 1;
|
|
195
|
+
approvalRef.current = "idle";
|
|
196
|
+
setConfirmError(false);
|
|
197
|
+
setPortalTarget(hasConfirm ? document.body : null);
|
|
198
|
+
}, [hasConfirm]);
|
|
199
|
+
function closePopover() {
|
|
200
|
+
if (popoverRef.current?.matches(":popover-open")) {
|
|
201
|
+
popoverRef.current.hidePopover();
|
|
202
|
+
}
|
|
203
|
+
buttonRef.current?.focus();
|
|
204
|
+
}
|
|
205
|
+
function handleClick(event) {
|
|
206
|
+
if (!confirm) {
|
|
207
|
+
onClick?.(event);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (approvalRef.current === "native") {
|
|
211
|
+
approvalRef.current = "idle";
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (approvalRef.current === "action") {
|
|
215
|
+
approvalRef.current = "idle";
|
|
216
|
+
let result;
|
|
217
|
+
try {
|
|
218
|
+
result = onClick?.(event);
|
|
219
|
+
} catch {
|
|
220
|
+
event.preventDefault();
|
|
221
|
+
pendingRef.current = false;
|
|
222
|
+
setConfirmError(true);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (!isPromiseLike(result)) {
|
|
226
|
+
pendingRef.current = false;
|
|
227
|
+
closePopover();
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const userPreventedDefault = event.defaultPrevented;
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
setConfirmLoading(true);
|
|
233
|
+
const action = actionRef.current;
|
|
234
|
+
const operation = operationRef.current;
|
|
235
|
+
Promise.resolve(result).then(() => {
|
|
236
|
+
if (!mountedRef.current || action !== actionRef.current)
|
|
237
|
+
return;
|
|
238
|
+
pendingRef.current = false;
|
|
239
|
+
setConfirmLoading(false);
|
|
240
|
+
if (operation !== operationRef.current)
|
|
241
|
+
return;
|
|
242
|
+
closePopover();
|
|
243
|
+
if (!userPreventedDefault && !buttonRef.current?.disabled) {
|
|
244
|
+
approvalRef.current = "native";
|
|
245
|
+
buttonRef.current?.click();
|
|
246
|
+
approvalRef.current = "idle";
|
|
247
|
+
}
|
|
248
|
+
}, () => {
|
|
249
|
+
if (!mountedRef.current || action !== actionRef.current)
|
|
250
|
+
return;
|
|
251
|
+
pendingRef.current = false;
|
|
252
|
+
setConfirmLoading(false);
|
|
253
|
+
if (operation !== operationRef.current)
|
|
254
|
+
return;
|
|
255
|
+
setConfirmError(true);
|
|
256
|
+
cancelRef.current?.focus();
|
|
257
|
+
});
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
event.preventDefault();
|
|
261
|
+
if (disabled || isLoading || pendingRef.current)
|
|
262
|
+
return;
|
|
263
|
+
if (popoverRef.current?.matches(":popover-open")) {
|
|
264
|
+
closePopover();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
setConfirmError(false);
|
|
268
|
+
popoverRef.current?.showPopover();
|
|
269
|
+
cancelRef.current?.focus();
|
|
270
|
+
}
|
|
271
|
+
function handleConfirm(event) {
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
event.stopPropagation();
|
|
274
|
+
const trigger = buttonRef.current;
|
|
275
|
+
if (disabled || isLoading || pendingRef.current || !trigger || trigger.disabled || !event.currentTarget.matches(":popover-open"))
|
|
276
|
+
return;
|
|
277
|
+
setConfirmError(false);
|
|
278
|
+
pendingRef.current = true;
|
|
279
|
+
actionRef.current += 1;
|
|
280
|
+
approvalRef.current = "action";
|
|
281
|
+
trigger.click();
|
|
282
|
+
if (approvalRef.current === "action") {
|
|
283
|
+
approvalRef.current = "idle";
|
|
284
|
+
pendingRef.current = false;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
91
287
|
const classes = getButtonClasses({
|
|
92
288
|
color,
|
|
93
289
|
appearance,
|
|
@@ -97,74 +293,107 @@ function Button({
|
|
|
97
293
|
isLoading,
|
|
98
294
|
className
|
|
99
295
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
...props,
|
|
296
|
+
const confirmClasses = getButtonClasses({
|
|
297
|
+
color,
|
|
298
|
+
size: "sm",
|
|
299
|
+
isLoading: confirmLoading
|
|
300
|
+
});
|
|
301
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
107
302
|
children: [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
303
|
+
/* @__PURE__ */ jsxs("button", {
|
|
304
|
+
ref: confirm ? mergedRef : ref,
|
|
305
|
+
className: classes,
|
|
306
|
+
disabled: disabled || isLoading,
|
|
307
|
+
"aria-busy": isLoading,
|
|
308
|
+
"aria-disabled": disabled || isLoading,
|
|
309
|
+
...props,
|
|
310
|
+
style: confirm ? { ...props.style, anchorName: anchor } : props.style,
|
|
311
|
+
"aria-haspopup": confirm ? "dialog" : props["aria-haspopup"],
|
|
312
|
+
"aria-controls": confirm ? popoverId : props["aria-controls"],
|
|
313
|
+
onClick: confirm ? handleClick : onClick,
|
|
314
|
+
children: [
|
|
315
|
+
isLoading && /* @__PURE__ */ jsx("span", {
|
|
316
|
+
className: "btn-spinner"
|
|
317
|
+
}),
|
|
318
|
+
!isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
|
|
319
|
+
className: "btn-icon-left",
|
|
320
|
+
children: leftIcon
|
|
321
|
+
}),
|
|
322
|
+
/* @__PURE__ */ jsx("span", {
|
|
323
|
+
className: "btn-content",
|
|
324
|
+
children
|
|
325
|
+
}),
|
|
326
|
+
!isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
|
|
327
|
+
className: "btn-icon-right",
|
|
328
|
+
children: rightIcon
|
|
329
|
+
})
|
|
330
|
+
]
|
|
118
331
|
}),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
332
|
+
confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs("form", {
|
|
333
|
+
id: popoverId,
|
|
334
|
+
ref: popoverRef,
|
|
335
|
+
popover: "auto",
|
|
336
|
+
role: "dialog",
|
|
337
|
+
"aria-labelledby": hasTitle ? titleId : undefined,
|
|
338
|
+
"aria-label": hasTitle ? undefined : "Confirm action",
|
|
339
|
+
"aria-describedby": hasContent ? descriptionId : undefined,
|
|
340
|
+
className: "popover popover-confirm popover-bottom",
|
|
341
|
+
style: { positionAnchor: anchor },
|
|
342
|
+
onSubmit: handleConfirm,
|
|
343
|
+
onClick: (event) => event.stopPropagation(),
|
|
344
|
+
onToggle: (event) => {
|
|
345
|
+
if (!event.currentTarget.matches(":popover-open")) {
|
|
346
|
+
operationRef.current += 1;
|
|
347
|
+
if (event.currentTarget.contains(document.activeElement) || document.activeElement === document.body) {
|
|
348
|
+
buttonRef.current?.focus();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
children: [
|
|
353
|
+
hasTitle && /* @__PURE__ */ jsx("div", {
|
|
354
|
+
className: "popover-header",
|
|
355
|
+
children: /* @__PURE__ */ jsx("h3", {
|
|
356
|
+
id: titleId,
|
|
357
|
+
className: "popover-title",
|
|
358
|
+
children: title
|
|
359
|
+
})
|
|
360
|
+
}),
|
|
361
|
+
hasContent && /* @__PURE__ */ jsx("div", {
|
|
362
|
+
id: descriptionId,
|
|
363
|
+
className: "popover-body",
|
|
364
|
+
children: content
|
|
365
|
+
}),
|
|
366
|
+
confirmError && /* @__PURE__ */ jsx("div", {
|
|
367
|
+
role: "alert",
|
|
368
|
+
className: "popover-body",
|
|
369
|
+
children: "The action failed. Please try again."
|
|
370
|
+
}),
|
|
371
|
+
/* @__PURE__ */ jsxs("div", {
|
|
372
|
+
className: "popover-footer",
|
|
373
|
+
children: [
|
|
374
|
+
/* @__PURE__ */ jsx("button", {
|
|
375
|
+
ref: cancelRef,
|
|
376
|
+
type: "button",
|
|
377
|
+
className: "btn btn-text btn-sm",
|
|
378
|
+
popoverTarget: popoverId,
|
|
379
|
+
popoverTargetAction: "hide",
|
|
380
|
+
disabled: confirmLoading,
|
|
381
|
+
children: confirmation?.cancelText ?? "Cancel"
|
|
382
|
+
}),
|
|
383
|
+
/* @__PURE__ */ jsx("button", {
|
|
384
|
+
type: "submit",
|
|
385
|
+
className: confirmClasses,
|
|
386
|
+
disabled: disabled || isLoading || confirmLoading,
|
|
387
|
+
"aria-busy": confirmLoading,
|
|
388
|
+
children: confirmation?.confirmText ?? "Confirm"
|
|
389
|
+
})
|
|
390
|
+
]
|
|
391
|
+
})
|
|
392
|
+
]
|
|
393
|
+
}), portalTarget)
|
|
123
394
|
]
|
|
124
395
|
});
|
|
125
396
|
}
|
|
126
|
-
// src/components/popconfirm/Popconfirm.tsx
|
|
127
|
-
import {
|
|
128
|
-
forwardRef,
|
|
129
|
-
useId,
|
|
130
|
-
useState
|
|
131
|
-
} from "react";
|
|
132
|
-
|
|
133
|
-
// src/classes/popconfirm.ts
|
|
134
|
-
var popconfirmWrapperClass = "popover-wrapper popconfirm-wrapper";
|
|
135
|
-
var popconfirmBaseClass = "popover popconfirm";
|
|
136
|
-
var popconfirmOpenClass = "popover-show popconfirm-open";
|
|
137
|
-
var popconfirmArrowClass = "popover-arrow popconfirm-arrow";
|
|
138
|
-
var popconfirmNoArrowClass = "popover-no-arrow popconfirm-no-arrow";
|
|
139
|
-
var popconfirmBodyClass = "popconfirm-body";
|
|
140
|
-
var popconfirmIconClass = "popconfirm-icon";
|
|
141
|
-
var popconfirmContentClass = "popconfirm-content";
|
|
142
|
-
var popconfirmTitleClass = "popconfirm-title";
|
|
143
|
-
var popconfirmDescriptionClass = "popconfirm-description";
|
|
144
|
-
var popconfirmActionsClass = "popconfirm-actions";
|
|
145
|
-
var popconfirmPlacementClasses = {
|
|
146
|
-
top: "popover-top popconfirm-top",
|
|
147
|
-
bottom: "popover-bottom popconfirm-bottom",
|
|
148
|
-
left: "popover-left popconfirm-left",
|
|
149
|
-
right: "popover-right popconfirm-right",
|
|
150
|
-
topLeft: "popover-top popconfirm-top-left",
|
|
151
|
-
topRight: "popover-top popconfirm-top-right",
|
|
152
|
-
bottomLeft: "popover-bottom popconfirm-bottom-left",
|
|
153
|
-
bottomRight: "popover-bottom popconfirm-bottom-right",
|
|
154
|
-
leftTop: "popover-left popconfirm-left-top",
|
|
155
|
-
leftBottom: "popover-left popconfirm-left-bottom",
|
|
156
|
-
rightTop: "popover-right popconfirm-right-top",
|
|
157
|
-
rightBottom: "popover-right popconfirm-right-bottom"
|
|
158
|
-
};
|
|
159
|
-
function getPopconfirmClasses({
|
|
160
|
-
placement = "top",
|
|
161
|
-
open,
|
|
162
|
-
arrow = true,
|
|
163
|
-
className
|
|
164
|
-
}) {
|
|
165
|
-
return cn(popconfirmBaseClass, popconfirmPlacementClasses[placement], open && popconfirmOpenClass, !arrow && popconfirmNoArrowClass, className);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
397
|
// src/components/popconfirm/Popconfirm.tsx
|
|
169
398
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
170
399
|
function normalizeTriggers(trigger) {
|
|
@@ -173,7 +402,7 @@ function normalizeTriggers(trigger) {
|
|
|
173
402
|
function hasTrigger(triggers, trigger) {
|
|
174
403
|
return normalizeTriggers(triggers).includes(trigger);
|
|
175
404
|
}
|
|
176
|
-
function
|
|
405
|
+
function isPromiseLike2(value) {
|
|
177
406
|
return Boolean(value && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function");
|
|
178
407
|
}
|
|
179
408
|
var Popconfirm = forwardRef(({
|
|
@@ -228,7 +457,7 @@ var Popconfirm = forwardRef(({
|
|
|
228
457
|
event.preventDefault();
|
|
229
458
|
event.stopPropagation();
|
|
230
459
|
const result = action?.(event);
|
|
231
|
-
if (!
|
|
460
|
+
if (!isPromiseLike2(result)) {
|
|
232
461
|
close();
|
|
233
462
|
return;
|
|
234
463
|
}
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
forwardRef,
|
|
7
7
|
isValidElement,
|
|
8
8
|
useId,
|
|
9
|
+
useLayoutEffect,
|
|
10
|
+
useRef,
|
|
9
11
|
useState
|
|
10
12
|
} from "react";
|
|
11
13
|
|
|
@@ -37,7 +39,6 @@ function cn(...inputs) {
|
|
|
37
39
|
// src/classes/popover.ts
|
|
38
40
|
var popoverWrapperClass = "popover-wrapper";
|
|
39
41
|
var popoverBaseClass = "popover";
|
|
40
|
-
var popoverShowClass = "popover-show";
|
|
41
42
|
var popoverArrowClass = "popover-arrow";
|
|
42
43
|
var popoverNoArrowClass = "popover-no-arrow";
|
|
43
44
|
var popoverPlacementClasses = {
|
|
@@ -48,11 +49,10 @@ var popoverPlacementClasses = {
|
|
|
48
49
|
};
|
|
49
50
|
function getPopoverClasses({
|
|
50
51
|
placement = "top",
|
|
51
|
-
open,
|
|
52
52
|
arrow = true,
|
|
53
53
|
className
|
|
54
54
|
}) {
|
|
55
|
-
return cn(popoverBaseClass, popoverPlacementClasses[placement],
|
|
55
|
+
return cn(popoverBaseClass, popoverPlacementClasses[placement], !arrow && popoverNoArrowClass, className);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// src/components/popover/Popover.tsx
|
|
@@ -110,7 +110,19 @@ var Popover = forwardRef(({
|
|
|
110
110
|
const [internalOpen, setInternalOpen] = useState(Boolean(defaultOpen));
|
|
111
111
|
const generatedId = useId();
|
|
112
112
|
const tooltipId = id ? `${id}-popover` : generatedId;
|
|
113
|
+
const anchorName = `--dm-popover-${generatedId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
114
|
+
const popoverRef = useRef(null);
|
|
113
115
|
const visible = isControlled ? open : internalOpen;
|
|
116
|
+
useLayoutEffect(() => {
|
|
117
|
+
const popover = popoverRef.current;
|
|
118
|
+
if (!popover || typeof popover.showPopover !== "function")
|
|
119
|
+
return;
|
|
120
|
+
if (visible && !popover.matches(":popover-open")) {
|
|
121
|
+
popover.showPopover();
|
|
122
|
+
} else if (!visible && popover.matches(":popover-open")) {
|
|
123
|
+
popover.hidePopover();
|
|
124
|
+
}
|
|
125
|
+
}, [visible, destroyTooltipOnHide]);
|
|
114
126
|
function updateOpen(nextOpen) {
|
|
115
127
|
if (!isControlled) {
|
|
116
128
|
setInternalOpen(nextOpen);
|
|
@@ -189,14 +201,22 @@ var Popover = forwardRef(({
|
|
|
189
201
|
...props,
|
|
190
202
|
ref,
|
|
191
203
|
className: popoverWrapperClass,
|
|
204
|
+
style: { ...props.style, anchorName },
|
|
192
205
|
children: [
|
|
193
206
|
triggerNode,
|
|
194
207
|
shouldRenderContent ? /* @__PURE__ */ jsxs("span", {
|
|
208
|
+
ref: popoverRef,
|
|
195
209
|
id: tooltipId,
|
|
210
|
+
popover: "auto",
|
|
196
211
|
role: "tooltip",
|
|
212
|
+
style: { positionAnchor: anchorName },
|
|
213
|
+
onToggle: (event) => {
|
|
214
|
+
const nextOpen = event.newState === "open";
|
|
215
|
+
if (nextOpen !== visible)
|
|
216
|
+
updateOpen(nextOpen);
|
|
217
|
+
},
|
|
197
218
|
className: getPopoverClasses({
|
|
198
219
|
placement,
|
|
199
|
-
open: visible,
|
|
200
220
|
arrow,
|
|
201
221
|
className
|
|
202
222
|
}),
|
|
@@ -229,10 +229,10 @@ var Skeleton = Object.assign(SkeletonRoot, {
|
|
|
229
229
|
Node: SkeletonNode
|
|
230
230
|
});
|
|
231
231
|
export {
|
|
232
|
-
|
|
233
|
-
SkeletonInput,
|
|
234
|
-
SkeletonImage,
|
|
235
|
-
SkeletonButton,
|
|
232
|
+
Skeleton,
|
|
236
233
|
SkeletonAvatar,
|
|
237
|
-
|
|
234
|
+
SkeletonButton,
|
|
235
|
+
SkeletonImage,
|
|
236
|
+
SkeletonInput,
|
|
237
|
+
SkeletonNode
|
|
238
238
|
};
|
|
@@ -65,8 +65,8 @@ function useDelayedSpinning(spinning, delay) {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
if (!spinning) {
|
|
68
|
-
const
|
|
69
|
-
return () => window.clearTimeout(
|
|
68
|
+
const resetTimer = window.setTimeout(() => setDelayedActive(false), 0);
|
|
69
|
+
return () => window.clearTimeout(resetTimer);
|
|
70
70
|
}
|
|
71
71
|
const resetTimer = window.setTimeout(() => setDelayedActive(false), 0);
|
|
72
72
|
const showTimer = window.setTimeout(() => setDelayedActive(true), delay);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SwapButtonProps, SwapProps } from "./Swap.types";
|
|
2
|
+
export declare const Swap: import("react").ForwardRefExoticComponent<Omit<SwapProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
3
|
+
export declare const SwapButton: import("react").ForwardRefExoticComponent<Omit<SwapButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ChangeEventHandler, ComponentProps, ReactNode } from "react";
|
|
2
|
+
export interface SwapProps extends Omit<ComponentProps<"input">, "checked" | "children" | "className" | "defaultChecked" | "onChange" | "size" | "type"> {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
defaultChecked?: boolean;
|
|
5
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
6
|
+
/** Decorative, noninteractive content shown while unchecked. */
|
|
7
|
+
off?: ReactNode;
|
|
8
|
+
/** Decorative, noninteractive content shown while checked. */
|
|
9
|
+
on?: ReactNode;
|
|
10
|
+
rotate?: boolean;
|
|
11
|
+
/** Additional class names for the wrapping label. */
|
|
12
|
+
wrapperClassName?: string;
|
|
13
|
+
/** Additional class names for the native checkbox. */
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SwapButtonProps extends Omit<ComponentProps<"button">, "children" | "aria-pressed"> {
|
|
17
|
+
"aria-label": string;
|
|
18
|
+
on: ReactNode;
|
|
19
|
+
off: ReactNode;
|
|
20
|
+
rotate?: boolean;
|
|
21
|
+
pressed: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/swap/Swap.tsx
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
|
|
6
|
+
// ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
7
|
+
function r(e) {
|
|
8
|
+
var t, f, n = "";
|
|
9
|
+
if (typeof e == "string" || typeof e == "number")
|
|
10
|
+
n += e;
|
|
11
|
+
else if (typeof e == "object")
|
|
12
|
+
if (Array.isArray(e)) {
|
|
13
|
+
var o = e.length;
|
|
14
|
+
for (t = 0;t < o; t++)
|
|
15
|
+
e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
16
|
+
} else
|
|
17
|
+
for (f in e)
|
|
18
|
+
e[f] && (n && (n += " "), n += f);
|
|
19
|
+
return n;
|
|
20
|
+
}
|
|
21
|
+
function clsx() {
|
|
22
|
+
for (var e, t, f = 0, n = "", o = arguments.length;f < o; f++)
|
|
23
|
+
(e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/utils/cn.ts
|
|
28
|
+
function cn(...inputs) {
|
|
29
|
+
return clsx(inputs);
|
|
30
|
+
}
|
|
31
|
+
// src/classes/swap.ts
|
|
32
|
+
var swapBaseClass = "swap";
|
|
33
|
+
var swapInputClass = "swap-input";
|
|
34
|
+
var swapOffClass = "swap-off";
|
|
35
|
+
var swapOnClass = "swap-on";
|
|
36
|
+
var swapRotateClass = "swap-rotate";
|
|
37
|
+
function getSwapClasses({
|
|
38
|
+
rotate = false,
|
|
39
|
+
wrapperClassName
|
|
40
|
+
}) {
|
|
41
|
+
return cn(swapBaseClass, rotate && swapRotateClass, wrapperClassName);
|
|
42
|
+
}
|
|
43
|
+
function getSwapInputClasses({ className }) {
|
|
44
|
+
return cn(swapInputClass, className);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/components/swap/Swap.tsx
|
|
48
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
49
|
+
var Swap = forwardRef(({
|
|
50
|
+
checked,
|
|
51
|
+
defaultChecked,
|
|
52
|
+
onChange,
|
|
53
|
+
disabled,
|
|
54
|
+
off,
|
|
55
|
+
on,
|
|
56
|
+
rotate = false,
|
|
57
|
+
wrapperClassName,
|
|
58
|
+
className,
|
|
59
|
+
...inputProps
|
|
60
|
+
}, ref) => /* @__PURE__ */ jsxs("label", {
|
|
61
|
+
className: getSwapClasses({ rotate, wrapperClassName }),
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ jsx("input", {
|
|
64
|
+
...inputProps,
|
|
65
|
+
ref,
|
|
66
|
+
type: "checkbox",
|
|
67
|
+
className: getSwapInputClasses({ className }),
|
|
68
|
+
checked,
|
|
69
|
+
defaultChecked,
|
|
70
|
+
onChange,
|
|
71
|
+
disabled
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ jsx("span", {
|
|
74
|
+
className: swapOffClass,
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
children: off
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ jsx("span", {
|
|
79
|
+
className: swapOnClass,
|
|
80
|
+
"aria-hidden": "true",
|
|
81
|
+
children: on
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
}));
|
|
85
|
+
Swap.displayName = "Swap";
|
|
86
|
+
var SwapButton = forwardRef(({ on, off, rotate, className, pressed, type = "button", ...buttonProps }, ref) => /* @__PURE__ */ jsxs("button", {
|
|
87
|
+
...buttonProps,
|
|
88
|
+
ref,
|
|
89
|
+
type,
|
|
90
|
+
"aria-pressed": pressed,
|
|
91
|
+
className: getSwapClasses({ rotate, wrapperClassName: className }),
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx("span", {
|
|
94
|
+
className: swapOffClass,
|
|
95
|
+
"aria-hidden": "true",
|
|
96
|
+
children: off
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx("span", {
|
|
99
|
+
className: swapOnClass,
|
|
100
|
+
"aria-hidden": "true",
|
|
101
|
+
children: on
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
}));
|
|
105
|
+
SwapButton.displayName = "SwapButton";
|
|
106
|
+
export {
|
|
107
|
+
Swap,
|
|
108
|
+
SwapButton
|
|
109
|
+
};
|