@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,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
// src/components/dm-page-header/DmPageHeader.tsx
|
|
4
|
+
import React5, { useMemo as useMemo2 } from "react";
|
|
5
|
+
|
|
3
6
|
// ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
4
7
|
function r(e) {
|
|
5
8
|
var t, f, n = "";
|
|
@@ -25,104 +28,25 @@ function clsx() {
|
|
|
25
28
|
function cn(...inputs) {
|
|
26
29
|
return clsx(inputs);
|
|
27
30
|
}
|
|
28
|
-
// src/classes/
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var buttonAppearanceClasses = {
|
|
43
|
-
filled: "",
|
|
44
|
-
outline: "btn-outline",
|
|
45
|
-
tonal: "btn-tonal",
|
|
46
|
-
ghost: "btn-ghost",
|
|
47
|
-
text: "btn-text"
|
|
48
|
-
};
|
|
49
|
-
var buttonShapeClasses = {
|
|
50
|
-
rect: "",
|
|
51
|
-
circle: "btn-circle",
|
|
52
|
-
square: "btn-square"
|
|
53
|
-
};
|
|
54
|
-
var buttonSizeClasses = {
|
|
55
|
-
xs: "btn-xs",
|
|
56
|
-
sm: "btn-sm",
|
|
57
|
-
md: "btn-md",
|
|
58
|
-
lg: "btn-lg"
|
|
59
|
-
};
|
|
60
|
-
var buttonBlockClass = "btn-block";
|
|
61
|
-
var buttonIsLoadingClass = "btn-loading";
|
|
62
|
-
function getButtonClasses({
|
|
63
|
-
color = "primary",
|
|
64
|
-
appearance = "filled",
|
|
65
|
-
shape = "rect",
|
|
66
|
-
size = "md",
|
|
67
|
-
block,
|
|
68
|
-
isLoading,
|
|
31
|
+
// src/classes/dm-page-header.ts
|
|
32
|
+
var dmPageHeaderBaseClass = "dm-page-header";
|
|
33
|
+
var dmPageHeaderMainClass = "dm-page-header-main";
|
|
34
|
+
var dmPageHeaderBackClass = "dm-page-header-back";
|
|
35
|
+
var dmPageHeaderDividerClass = "dm-page-header-divider";
|
|
36
|
+
var dmPageHeaderContentClass = "dm-page-header-content";
|
|
37
|
+
var dmPageHeaderTitleClass = "dm-page-header-title";
|
|
38
|
+
var dmPageHeaderTitleListClass = "dm-page-header-title-list";
|
|
39
|
+
var dmPageHeaderTitleItemClass = "dm-page-header-title-item";
|
|
40
|
+
var dmPageHeaderExtraClass = "dm-page-header-extra";
|
|
41
|
+
var dmPageHeaderBodyClass = "dm-page-header-body";
|
|
42
|
+
var dmPageHeaderBreadcrumbClass = "dm-page-header-breadcrumb";
|
|
43
|
+
function getDmPageHeaderClasses({
|
|
44
|
+
hasExtra,
|
|
69
45
|
className
|
|
70
46
|
}) {
|
|
71
|
-
return cn(
|
|
47
|
+
return cn(dmPageHeaderBaseClass, hasExtra && "dm-page-header-has-extra", className);
|
|
72
48
|
}
|
|
73
49
|
|
|
74
|
-
// src/components/button/Button.tsx
|
|
75
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
76
|
-
function Button({
|
|
77
|
-
color = "primary",
|
|
78
|
-
appearance = "filled",
|
|
79
|
-
shape = "rect",
|
|
80
|
-
size = "md",
|
|
81
|
-
block,
|
|
82
|
-
isLoading,
|
|
83
|
-
leftIcon,
|
|
84
|
-
rightIcon,
|
|
85
|
-
className,
|
|
86
|
-
children,
|
|
87
|
-
disabled,
|
|
88
|
-
ref,
|
|
89
|
-
...props
|
|
90
|
-
}) {
|
|
91
|
-
const classes = getButtonClasses({
|
|
92
|
-
color,
|
|
93
|
-
appearance,
|
|
94
|
-
shape,
|
|
95
|
-
size,
|
|
96
|
-
block,
|
|
97
|
-
isLoading,
|
|
98
|
-
className
|
|
99
|
-
});
|
|
100
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
101
|
-
ref,
|
|
102
|
-
className: classes,
|
|
103
|
-
disabled: disabled || isLoading,
|
|
104
|
-
"aria-busy": isLoading,
|
|
105
|
-
"aria-disabled": disabled || isLoading,
|
|
106
|
-
...props,
|
|
107
|
-
children: [
|
|
108
|
-
isLoading && /* @__PURE__ */ jsx("span", {
|
|
109
|
-
className: "btn-spinner"
|
|
110
|
-
}),
|
|
111
|
-
!isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
|
|
112
|
-
className: "btn-icon-left",
|
|
113
|
-
children: leftIcon
|
|
114
|
-
}),
|
|
115
|
-
/* @__PURE__ */ jsx("span", {
|
|
116
|
-
className: "btn-content",
|
|
117
|
-
children
|
|
118
|
-
}),
|
|
119
|
-
!isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
|
|
120
|
-
className: "btn-icon-right",
|
|
121
|
-
children: rightIcon
|
|
122
|
-
})
|
|
123
|
-
]
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
50
|
// src/components/breadcrumb/Breadcrumb.tsx
|
|
127
51
|
import React, { forwardRef } from "react";
|
|
128
52
|
|
|
@@ -155,7 +79,7 @@ function getBreadcrumbLinkClasses({
|
|
|
155
79
|
}
|
|
156
80
|
|
|
157
81
|
// src/components/breadcrumb/Breadcrumb.tsx
|
|
158
|
-
import { jsx
|
|
82
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
159
83
|
var defaultSeparator = "/";
|
|
160
84
|
function isSeparatorItem(item) {
|
|
161
85
|
return "type" in item && item.type === "separator";
|
|
@@ -208,9 +132,9 @@ function activateOnKeyboard(event) {
|
|
|
208
132
|
}
|
|
209
133
|
function renderItemBody(item) {
|
|
210
134
|
const title = getItemTitle(item);
|
|
211
|
-
return /* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
212
136
|
children: [
|
|
213
|
-
item.icon ? /* @__PURE__ */
|
|
137
|
+
item.icon ? /* @__PURE__ */ jsx("span", {
|
|
214
138
|
className: breadcrumbIconClass,
|
|
215
139
|
"aria-hidden": "true",
|
|
216
140
|
children: item.icon
|
|
@@ -257,7 +181,7 @@ function renderMenuItems(menu, items = []) {
|
|
|
257
181
|
item.onClick?.(event);
|
|
258
182
|
menu.onClick?.({ key, item, domEvent: event });
|
|
259
183
|
}
|
|
260
|
-
const content = item.disabled ? /* @__PURE__ */
|
|
184
|
+
const content = item.disabled ? /* @__PURE__ */ jsx("span", {
|
|
261
185
|
role: "menuitem",
|
|
262
186
|
"aria-disabled": "true",
|
|
263
187
|
className: getBreadcrumbLinkClasses({
|
|
@@ -265,23 +189,23 @@ function renderMenuItems(menu, items = []) {
|
|
|
265
189
|
className: breadcrumbMenuItemClass
|
|
266
190
|
}),
|
|
267
191
|
children: label
|
|
268
|
-
}) : href ? /* @__PURE__ */
|
|
192
|
+
}) : href ? /* @__PURE__ */ jsx("a", {
|
|
269
193
|
role: "menuitem",
|
|
270
194
|
className: cn(breadcrumbMenuItemClass, getBreadcrumbLinkClasses({})),
|
|
271
195
|
href,
|
|
272
196
|
onClick: handleClick,
|
|
273
197
|
children: label
|
|
274
|
-
}) : /* @__PURE__ */
|
|
198
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
275
199
|
type: "button",
|
|
276
200
|
role: "menuitem",
|
|
277
201
|
className: cn(breadcrumbMenuItemClass, getBreadcrumbLinkClasses({})),
|
|
278
202
|
onClick: handleClick,
|
|
279
203
|
children: label
|
|
280
204
|
});
|
|
281
|
-
return /* @__PURE__ */
|
|
205
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
282
206
|
children: [
|
|
283
207
|
content,
|
|
284
|
-
item.children?.length ? /* @__PURE__ */
|
|
208
|
+
item.children?.length ? /* @__PURE__ */ jsx("ul", {
|
|
285
209
|
className: breadcrumbMenuListClass,
|
|
286
210
|
role: "menu",
|
|
287
211
|
children: renderMenuItems(menu, item.children)
|
|
@@ -297,7 +221,7 @@ function renderDefaultItemContent(item, paths, active) {
|
|
|
297
221
|
}
|
|
298
222
|
const href = item.href ?? (!active ? getHref(item, paths) : undefined);
|
|
299
223
|
if (href) {
|
|
300
|
-
return /* @__PURE__ */
|
|
224
|
+
return /* @__PURE__ */ jsx("a", {
|
|
301
225
|
className: getBreadcrumbLinkClasses({}),
|
|
302
226
|
href,
|
|
303
227
|
onClick: item.onClick,
|
|
@@ -305,7 +229,7 @@ function renderDefaultItemContent(item, paths, active) {
|
|
|
305
229
|
});
|
|
306
230
|
}
|
|
307
231
|
if (item.onClick) {
|
|
308
|
-
return /* @__PURE__ */
|
|
232
|
+
return /* @__PURE__ */ jsx("span", {
|
|
309
233
|
role: "button",
|
|
310
234
|
tabIndex: 0,
|
|
311
235
|
className: getBreadcrumbLinkClasses({}),
|
|
@@ -317,18 +241,18 @@ function renderDefaultItemContent(item, paths, active) {
|
|
|
317
241
|
return body;
|
|
318
242
|
}
|
|
319
243
|
function renderMenuItem(item, menu, children, disabled) {
|
|
320
|
-
return /* @__PURE__ */
|
|
244
|
+
return /* @__PURE__ */ jsxs("details", {
|
|
321
245
|
className: getBreadcrumbItemClasses({
|
|
322
246
|
disabled,
|
|
323
247
|
className: cn(breadcrumbMenuClass, item.className)
|
|
324
248
|
}),
|
|
325
249
|
"aria-disabled": disabled || undefined,
|
|
326
250
|
children: [
|
|
327
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ jsx("summary", {
|
|
328
252
|
className: getBreadcrumbLinkClasses({ disabled }),
|
|
329
253
|
children
|
|
330
254
|
}),
|
|
331
|
-
/* @__PURE__ */
|
|
255
|
+
/* @__PURE__ */ jsx("ul", {
|
|
332
256
|
className: breadcrumbMenuListClass,
|
|
333
257
|
role: "menu",
|
|
334
258
|
children: renderMenuItems(menu, menu.items)
|
|
@@ -349,7 +273,7 @@ var Breadcrumb = forwardRef(({
|
|
|
349
273
|
}, ref) => {
|
|
350
274
|
const entries = items ?? routes;
|
|
351
275
|
if (!entries?.length) {
|
|
352
|
-
return /* @__PURE__ */
|
|
276
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
353
277
|
...props,
|
|
354
278
|
ref,
|
|
355
279
|
"aria-label": ariaLabel,
|
|
@@ -360,7 +284,7 @@ var Breadcrumb = forwardRef(({
|
|
|
360
284
|
const routeEntries = entries.filter((item) => !isSeparatorItem(item));
|
|
361
285
|
let routeIndex = -1;
|
|
362
286
|
let previousRenderedItemWasSeparator = true;
|
|
363
|
-
return /* @__PURE__ */
|
|
287
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
364
288
|
...props,
|
|
365
289
|
ref,
|
|
366
290
|
"aria-label": ariaLabel,
|
|
@@ -368,7 +292,7 @@ var Breadcrumb = forwardRef(({
|
|
|
368
292
|
children: entries.map((entry, index) => {
|
|
369
293
|
if (isSeparatorItem(entry)) {
|
|
370
294
|
previousRenderedItemWasSeparator = true;
|
|
371
|
-
return /* @__PURE__ */
|
|
295
|
+
return /* @__PURE__ */ jsx("span", {
|
|
372
296
|
className: cn(breadcrumbSeparatorClass, entry.className),
|
|
373
297
|
"aria-hidden": "true",
|
|
374
298
|
children: entry.separator ?? separator
|
|
@@ -383,14 +307,14 @@ var Breadcrumb = forwardRef(({
|
|
|
383
307
|
const applyActiveClass = active && !itemRender && !entry.href && !entry.onClick;
|
|
384
308
|
const insertSeparator = !previousRenderedItemWasSeparator;
|
|
385
309
|
previousRenderedItemWasSeparator = false;
|
|
386
|
-
return /* @__PURE__ */
|
|
310
|
+
return /* @__PURE__ */ jsxs(React.Fragment, {
|
|
387
311
|
children: [
|
|
388
|
-
insertSeparator ? /* @__PURE__ */
|
|
312
|
+
insertSeparator ? /* @__PURE__ */ jsx("span", {
|
|
389
313
|
className: breadcrumbSeparatorClass,
|
|
390
314
|
"aria-hidden": "true",
|
|
391
315
|
children: separator
|
|
392
316
|
}) : null,
|
|
393
|
-
menu?.items?.length ? renderMenuItem(entry, menu, content, entry.disabled) : /* @__PURE__ */
|
|
317
|
+
menu?.items?.length ? renderMenuItem(entry, menu, content, entry.disabled) : /* @__PURE__ */ jsx("span", {
|
|
394
318
|
className: getBreadcrumbItemClasses({
|
|
395
319
|
active: applyActiveClass,
|
|
396
320
|
disabled: entry.disabled,
|
|
@@ -406,39 +330,383 @@ var Breadcrumb = forwardRef(({
|
|
|
406
330
|
});
|
|
407
331
|
});
|
|
408
332
|
Breadcrumb.displayName = "Breadcrumb";
|
|
333
|
+
// src/components/dm-toolbar/DmToolbar.tsx
|
|
334
|
+
import { useMemo } from "react";
|
|
335
|
+
|
|
336
|
+
// src/classes/dm-toolbar.ts
|
|
337
|
+
var dmToolbarBaseClass = "dm-toolbar";
|
|
338
|
+
var dmToolbarItemClass = "dm-toolbar-item";
|
|
339
|
+
var dmToolbarPrimaryItemClass = "dm-toolbar-primary-item";
|
|
340
|
+
var dmToolbarSecondaryItemClass = "dm-toolbar-secondary-item";
|
|
341
|
+
var dmToolbarMoreClass = "dm-toolbar-more";
|
|
342
|
+
function getDmToolbarClasses({ className }) {
|
|
343
|
+
return cn(dmToolbarBaseClass, className);
|
|
344
|
+
}
|
|
345
|
+
function getDmToolbarItemClasses({
|
|
346
|
+
primary,
|
|
347
|
+
className
|
|
348
|
+
}) {
|
|
349
|
+
return cn(dmToolbarItemClass, primary ? dmToolbarPrimaryItemClass : dmToolbarSecondaryItemClass, className);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// src/components/button/Button.tsx
|
|
353
|
+
import React2 from "react";
|
|
354
|
+
import { createPortal } from "react-dom";
|
|
355
|
+
|
|
356
|
+
// src/classes/button.ts
|
|
357
|
+
var buttonBaseClass = "btn";
|
|
358
|
+
var buttonColorClasses = {
|
|
359
|
+
primary: "btn-primary",
|
|
360
|
+
secondary: "btn-secondary",
|
|
361
|
+
tertiary: "btn-tertiary",
|
|
362
|
+
accent: "btn-accent",
|
|
363
|
+
neutral: "btn-neutral",
|
|
364
|
+
base: "btn-base",
|
|
365
|
+
info: "btn-info",
|
|
366
|
+
success: "btn-success",
|
|
367
|
+
warning: "btn-warning",
|
|
368
|
+
error: "btn-error"
|
|
369
|
+
};
|
|
370
|
+
var buttonAppearanceClasses = {
|
|
371
|
+
filled: "",
|
|
372
|
+
outline: "btn-outline",
|
|
373
|
+
tonal: "btn-tonal",
|
|
374
|
+
ghost: "btn-ghost",
|
|
375
|
+
text: "btn-text"
|
|
376
|
+
};
|
|
377
|
+
var buttonShapeClasses = {
|
|
378
|
+
rect: "",
|
|
379
|
+
circle: "btn-circle btn-icon",
|
|
380
|
+
square: "btn-square"
|
|
381
|
+
};
|
|
382
|
+
var buttonSizeClasses = {
|
|
383
|
+
xs: "btn-xs",
|
|
384
|
+
sm: "btn-sm",
|
|
385
|
+
md: "btn-md",
|
|
386
|
+
lg: "btn-lg"
|
|
387
|
+
};
|
|
388
|
+
var buttonBlockClass = "btn-block";
|
|
389
|
+
var buttonIsLoadingClass = "btn-loading";
|
|
390
|
+
function getButtonClasses({
|
|
391
|
+
color = "primary",
|
|
392
|
+
appearance = "filled",
|
|
393
|
+
shape = "rect",
|
|
394
|
+
size = "md",
|
|
395
|
+
block,
|
|
396
|
+
isLoading,
|
|
397
|
+
className
|
|
398
|
+
}) {
|
|
399
|
+
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);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// src/components/button/Button.tsx
|
|
403
|
+
import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
404
|
+
function isPromiseLike(value) {
|
|
405
|
+
return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
406
|
+
}
|
|
407
|
+
function Button({
|
|
408
|
+
color = "primary",
|
|
409
|
+
appearance = "filled",
|
|
410
|
+
shape = "rect",
|
|
411
|
+
size = "md",
|
|
412
|
+
block,
|
|
413
|
+
isLoading,
|
|
414
|
+
leftIcon,
|
|
415
|
+
rightIcon,
|
|
416
|
+
className,
|
|
417
|
+
children,
|
|
418
|
+
disabled,
|
|
419
|
+
ref,
|
|
420
|
+
confirm,
|
|
421
|
+
onClick,
|
|
422
|
+
...props
|
|
423
|
+
}) {
|
|
424
|
+
const buttonRef = React2.useRef(null);
|
|
425
|
+
const popoverRef = React2.useRef(null);
|
|
426
|
+
const cancelRef = React2.useRef(null);
|
|
427
|
+
const approvalRef = React2.useRef("idle");
|
|
428
|
+
const pendingRef = React2.useRef(false);
|
|
429
|
+
const actionRef = React2.useRef(0);
|
|
430
|
+
const operationRef = React2.useRef(0);
|
|
431
|
+
const mountedRef = React2.useRef(false);
|
|
432
|
+
const [portalTarget, setPortalTarget] = React2.useState(null);
|
|
433
|
+
const [confirmLoading, setConfirmLoading] = React2.useState(false);
|
|
434
|
+
const [confirmError, setConfirmError] = React2.useState(false);
|
|
435
|
+
const generatedId = React2.useId().replace(/:/g, "");
|
|
436
|
+
const popoverId = `button-confirm-${generatedId}`;
|
|
437
|
+
const titleId = `${popoverId}-title`;
|
|
438
|
+
const descriptionId = `${popoverId}-description`;
|
|
439
|
+
const anchor = `--${popoverId}-anchor`;
|
|
440
|
+
const hasConfirm = Boolean(confirm);
|
|
441
|
+
const confirmation = confirm && typeof confirm === "object" ? confirm : undefined;
|
|
442
|
+
const title = confirmation ? confirmation.title : "Confirm action";
|
|
443
|
+
const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
|
|
444
|
+
const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
|
|
445
|
+
const hasContent = content !== undefined && content !== null && content !== false && content !== "";
|
|
446
|
+
const mergedRef = React2.useCallback((node) => {
|
|
447
|
+
buttonRef.current = node;
|
|
448
|
+
if (!node) {
|
|
449
|
+
if (typeof ref === "function")
|
|
450
|
+
ref(null);
|
|
451
|
+
else if (ref)
|
|
452
|
+
ref.current = null;
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
const cleanup = typeof ref === "function" ? ref(node) : undefined;
|
|
456
|
+
if (ref && typeof ref !== "function")
|
|
457
|
+
ref.current = node;
|
|
458
|
+
return () => {
|
|
459
|
+
buttonRef.current = null;
|
|
460
|
+
if (typeof cleanup === "function")
|
|
461
|
+
cleanup();
|
|
462
|
+
else if (typeof ref === "function")
|
|
463
|
+
ref(null);
|
|
464
|
+
else if (ref)
|
|
465
|
+
ref.current = null;
|
|
466
|
+
};
|
|
467
|
+
}, [ref]);
|
|
468
|
+
React2.useEffect(() => {
|
|
469
|
+
mountedRef.current = true;
|
|
470
|
+
return () => {
|
|
471
|
+
mountedRef.current = false;
|
|
472
|
+
operationRef.current += 1;
|
|
473
|
+
};
|
|
474
|
+
}, []);
|
|
475
|
+
React2.useEffect(() => {
|
|
476
|
+
operationRef.current += 1;
|
|
477
|
+
approvalRef.current = "idle";
|
|
478
|
+
setConfirmError(false);
|
|
479
|
+
setPortalTarget(hasConfirm ? document.body : null);
|
|
480
|
+
}, [hasConfirm]);
|
|
481
|
+
function closePopover() {
|
|
482
|
+
if (popoverRef.current?.matches(":popover-open")) {
|
|
483
|
+
popoverRef.current.hidePopover();
|
|
484
|
+
}
|
|
485
|
+
buttonRef.current?.focus();
|
|
486
|
+
}
|
|
487
|
+
function handleClick(event) {
|
|
488
|
+
if (!confirm) {
|
|
489
|
+
onClick?.(event);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (approvalRef.current === "native") {
|
|
493
|
+
approvalRef.current = "idle";
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (approvalRef.current === "action") {
|
|
497
|
+
approvalRef.current = "idle";
|
|
498
|
+
let result;
|
|
499
|
+
try {
|
|
500
|
+
result = onClick?.(event);
|
|
501
|
+
} catch {
|
|
502
|
+
event.preventDefault();
|
|
503
|
+
pendingRef.current = false;
|
|
504
|
+
setConfirmError(true);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
if (!isPromiseLike(result)) {
|
|
508
|
+
pendingRef.current = false;
|
|
509
|
+
closePopover();
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
const userPreventedDefault = event.defaultPrevented;
|
|
513
|
+
event.preventDefault();
|
|
514
|
+
setConfirmLoading(true);
|
|
515
|
+
const action = actionRef.current;
|
|
516
|
+
const operation = operationRef.current;
|
|
517
|
+
Promise.resolve(result).then(() => {
|
|
518
|
+
if (!mountedRef.current || action !== actionRef.current)
|
|
519
|
+
return;
|
|
520
|
+
pendingRef.current = false;
|
|
521
|
+
setConfirmLoading(false);
|
|
522
|
+
if (operation !== operationRef.current)
|
|
523
|
+
return;
|
|
524
|
+
closePopover();
|
|
525
|
+
if (!userPreventedDefault && !buttonRef.current?.disabled) {
|
|
526
|
+
approvalRef.current = "native";
|
|
527
|
+
buttonRef.current?.click();
|
|
528
|
+
approvalRef.current = "idle";
|
|
529
|
+
}
|
|
530
|
+
}, () => {
|
|
531
|
+
if (!mountedRef.current || action !== actionRef.current)
|
|
532
|
+
return;
|
|
533
|
+
pendingRef.current = false;
|
|
534
|
+
setConfirmLoading(false);
|
|
535
|
+
if (operation !== operationRef.current)
|
|
536
|
+
return;
|
|
537
|
+
setConfirmError(true);
|
|
538
|
+
cancelRef.current?.focus();
|
|
539
|
+
});
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
event.preventDefault();
|
|
543
|
+
if (disabled || isLoading || pendingRef.current)
|
|
544
|
+
return;
|
|
545
|
+
if (popoverRef.current?.matches(":popover-open")) {
|
|
546
|
+
closePopover();
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
setConfirmError(false);
|
|
550
|
+
popoverRef.current?.showPopover();
|
|
551
|
+
cancelRef.current?.focus();
|
|
552
|
+
}
|
|
553
|
+
function handleConfirm(event) {
|
|
554
|
+
event.preventDefault();
|
|
555
|
+
event.stopPropagation();
|
|
556
|
+
const trigger = buttonRef.current;
|
|
557
|
+
if (disabled || isLoading || pendingRef.current || !trigger || trigger.disabled || !event.currentTarget.matches(":popover-open"))
|
|
558
|
+
return;
|
|
559
|
+
setConfirmError(false);
|
|
560
|
+
pendingRef.current = true;
|
|
561
|
+
actionRef.current += 1;
|
|
562
|
+
approvalRef.current = "action";
|
|
563
|
+
trigger.click();
|
|
564
|
+
if (approvalRef.current === "action") {
|
|
565
|
+
approvalRef.current = "idle";
|
|
566
|
+
pendingRef.current = false;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
const classes = getButtonClasses({
|
|
570
|
+
color,
|
|
571
|
+
appearance,
|
|
572
|
+
shape,
|
|
573
|
+
size,
|
|
574
|
+
block,
|
|
575
|
+
isLoading,
|
|
576
|
+
className
|
|
577
|
+
});
|
|
578
|
+
const confirmClasses = getButtonClasses({
|
|
579
|
+
color,
|
|
580
|
+
size: "sm",
|
|
581
|
+
isLoading: confirmLoading
|
|
582
|
+
});
|
|
583
|
+
return /* @__PURE__ */ jsxs2(Fragment2, {
|
|
584
|
+
children: [
|
|
585
|
+
/* @__PURE__ */ jsxs2("button", {
|
|
586
|
+
ref: confirm ? mergedRef : ref,
|
|
587
|
+
className: classes,
|
|
588
|
+
disabled: disabled || isLoading,
|
|
589
|
+
"aria-busy": isLoading,
|
|
590
|
+
"aria-disabled": disabled || isLoading,
|
|
591
|
+
...props,
|
|
592
|
+
style: confirm ? { ...props.style, anchorName: anchor } : props.style,
|
|
593
|
+
"aria-haspopup": confirm ? "dialog" : props["aria-haspopup"],
|
|
594
|
+
"aria-controls": confirm ? popoverId : props["aria-controls"],
|
|
595
|
+
onClick: confirm ? handleClick : onClick,
|
|
596
|
+
children: [
|
|
597
|
+
isLoading && /* @__PURE__ */ jsx2("span", {
|
|
598
|
+
className: "btn-spinner"
|
|
599
|
+
}),
|
|
600
|
+
!isLoading && leftIcon && /* @__PURE__ */ jsx2("span", {
|
|
601
|
+
className: "btn-icon-left",
|
|
602
|
+
children: leftIcon
|
|
603
|
+
}),
|
|
604
|
+
/* @__PURE__ */ jsx2("span", {
|
|
605
|
+
className: "btn-content",
|
|
606
|
+
children
|
|
607
|
+
}),
|
|
608
|
+
!isLoading && rightIcon && /* @__PURE__ */ jsx2("span", {
|
|
609
|
+
className: "btn-icon-right",
|
|
610
|
+
children: rightIcon
|
|
611
|
+
})
|
|
612
|
+
]
|
|
613
|
+
}),
|
|
614
|
+
confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs2("form", {
|
|
615
|
+
id: popoverId,
|
|
616
|
+
ref: popoverRef,
|
|
617
|
+
popover: "auto",
|
|
618
|
+
role: "dialog",
|
|
619
|
+
"aria-labelledby": hasTitle ? titleId : undefined,
|
|
620
|
+
"aria-label": hasTitle ? undefined : "Confirm action",
|
|
621
|
+
"aria-describedby": hasContent ? descriptionId : undefined,
|
|
622
|
+
className: "popover popover-confirm popover-bottom",
|
|
623
|
+
style: { positionAnchor: anchor },
|
|
624
|
+
onSubmit: handleConfirm,
|
|
625
|
+
onClick: (event) => event.stopPropagation(),
|
|
626
|
+
onToggle: (event) => {
|
|
627
|
+
if (!event.currentTarget.matches(":popover-open")) {
|
|
628
|
+
operationRef.current += 1;
|
|
629
|
+
if (event.currentTarget.contains(document.activeElement) || document.activeElement === document.body) {
|
|
630
|
+
buttonRef.current?.focus();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
children: [
|
|
635
|
+
hasTitle && /* @__PURE__ */ jsx2("div", {
|
|
636
|
+
className: "popover-header",
|
|
637
|
+
children: /* @__PURE__ */ jsx2("h3", {
|
|
638
|
+
id: titleId,
|
|
639
|
+
className: "popover-title",
|
|
640
|
+
children: title
|
|
641
|
+
})
|
|
642
|
+
}),
|
|
643
|
+
hasContent && /* @__PURE__ */ jsx2("div", {
|
|
644
|
+
id: descriptionId,
|
|
645
|
+
className: "popover-body",
|
|
646
|
+
children: content
|
|
647
|
+
}),
|
|
648
|
+
confirmError && /* @__PURE__ */ jsx2("div", {
|
|
649
|
+
role: "alert",
|
|
650
|
+
className: "popover-body",
|
|
651
|
+
children: "The action failed. Please try again."
|
|
652
|
+
}),
|
|
653
|
+
/* @__PURE__ */ jsxs2("div", {
|
|
654
|
+
className: "popover-footer",
|
|
655
|
+
children: [
|
|
656
|
+
/* @__PURE__ */ jsx2("button", {
|
|
657
|
+
ref: cancelRef,
|
|
658
|
+
type: "button",
|
|
659
|
+
className: "btn btn-text btn-sm",
|
|
660
|
+
popoverTarget: popoverId,
|
|
661
|
+
popoverTargetAction: "hide",
|
|
662
|
+
disabled: confirmLoading,
|
|
663
|
+
children: confirmation?.cancelText ?? "Cancel"
|
|
664
|
+
}),
|
|
665
|
+
/* @__PURE__ */ jsx2("button", {
|
|
666
|
+
type: "submit",
|
|
667
|
+
className: confirmClasses,
|
|
668
|
+
disabled: disabled || isLoading || confirmLoading,
|
|
669
|
+
"aria-busy": confirmLoading,
|
|
670
|
+
children: confirmation?.confirmText ?? "Confirm"
|
|
671
|
+
})
|
|
672
|
+
]
|
|
673
|
+
})
|
|
674
|
+
]
|
|
675
|
+
}), portalTarget)
|
|
676
|
+
]
|
|
677
|
+
});
|
|
678
|
+
}
|
|
409
679
|
// src/components/dropdown/Dropdown.tsx
|
|
410
680
|
import {
|
|
411
681
|
cloneElement,
|
|
412
682
|
forwardRef as forwardRef2,
|
|
413
683
|
isValidElement,
|
|
684
|
+
useEffect,
|
|
414
685
|
useId,
|
|
686
|
+
useRef,
|
|
415
687
|
useState
|
|
416
688
|
} from "react";
|
|
417
689
|
|
|
418
690
|
// src/classes/dropdown.ts
|
|
419
|
-
var dropdownWrapperClass = "dropdown
|
|
420
|
-
var dropdownBaseClass = "
|
|
421
|
-
var
|
|
422
|
-
var dropdownArrowClass = "popover-arrow dropdown-arrow";
|
|
691
|
+
var dropdownWrapperClass = "dropdown";
|
|
692
|
+
var dropdownBaseClass = "dropdown-content";
|
|
693
|
+
var dropdownArrowClass = "dropdown-arrow";
|
|
423
694
|
var dropdownMenuClass = "menu dropdown-menu";
|
|
424
695
|
var dropdownButtonClass = "dropdown-button";
|
|
425
696
|
var dropdownPlacementClasses = {
|
|
426
|
-
top: "
|
|
427
|
-
bottom: "
|
|
428
|
-
left: "
|
|
429
|
-
right: "
|
|
430
|
-
topLeft: "
|
|
431
|
-
topRight: "
|
|
432
|
-
bottomLeft: "
|
|
433
|
-
bottomRight: "
|
|
697
|
+
top: "dropdown-block-start",
|
|
698
|
+
bottom: "dropdown-block-end",
|
|
699
|
+
left: "dropdown-inline-start",
|
|
700
|
+
right: "dropdown-inline-end",
|
|
701
|
+
topLeft: "dropdown-block-start",
|
|
702
|
+
topRight: "dropdown-block-start",
|
|
703
|
+
bottomLeft: "dropdown-block-end",
|
|
704
|
+
bottomRight: "dropdown-block-end"
|
|
434
705
|
};
|
|
435
706
|
function getDropdownClasses({
|
|
436
|
-
placement = "bottomLeft",
|
|
437
|
-
open,
|
|
438
|
-
arrow,
|
|
439
707
|
className
|
|
440
708
|
}) {
|
|
441
|
-
return cn(dropdownBaseClass,
|
|
709
|
+
return cn(dropdownBaseClass, className);
|
|
442
710
|
}
|
|
443
711
|
|
|
444
712
|
// src/classes/menu.ts
|
|
@@ -491,9 +759,6 @@ function getMenuItemClasses({
|
|
|
491
759
|
|
|
492
760
|
// src/components/dropdown/Dropdown.tsx
|
|
493
761
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
494
|
-
function hasTrigger(triggers, trigger) {
|
|
495
|
-
return (triggers ?? ["hover"]).includes(trigger);
|
|
496
|
-
}
|
|
497
762
|
function callHandler(handler, event) {
|
|
498
763
|
handler?.(event);
|
|
499
764
|
}
|
|
@@ -545,85 +810,103 @@ var DropdownRoot = forwardRef2(({
|
|
|
545
810
|
...props
|
|
546
811
|
}, ref) => {
|
|
547
812
|
const [internalOpen, setInternalOpen] = useState(Boolean(defaultOpen));
|
|
548
|
-
const
|
|
549
|
-
const visible =
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
|
|
813
|
+
const [nativeOpen, setNativeOpen] = useState(Boolean(open ?? defaultOpen));
|
|
814
|
+
const visible = open ?? internalOpen;
|
|
815
|
+
const popupRef = useRef(null);
|
|
816
|
+
const popupId = useId();
|
|
817
|
+
const anchorName = `--dm-dropdown-${popupId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
818
|
+
const clickTrigger = trigger.includes("click") || trigger.includes("hover");
|
|
819
|
+
useEffect(() => {
|
|
820
|
+
const popup = popupRef.current;
|
|
821
|
+
if (!popup?.showPopover || !popup?.hidePopover)
|
|
553
822
|
return;
|
|
554
|
-
if (!
|
|
823
|
+
if (visible && !popup.matches(":popover-open"))
|
|
824
|
+
popup.showPopover();
|
|
825
|
+
if (!visible && popup.matches(":popover-open"))
|
|
826
|
+
popup.hidePopover();
|
|
827
|
+
}, [visible]);
|
|
828
|
+
function setVisible(nextOpen) {
|
|
829
|
+
if (open === undefined)
|
|
555
830
|
setInternalOpen(nextOpen);
|
|
556
|
-
}
|
|
557
831
|
onOpenChange?.(nextOpen);
|
|
558
832
|
}
|
|
559
|
-
|
|
560
|
-
|
|
833
|
+
function close() {
|
|
834
|
+
const popup = popupRef.current;
|
|
835
|
+
if (popup?.matches(":popover-open"))
|
|
836
|
+
popup.hidePopover();
|
|
837
|
+
else
|
|
838
|
+
setVisible(false);
|
|
839
|
+
}
|
|
561
840
|
const menuNode = overlay ?? (menu?.items ? /* @__PURE__ */ jsx3("ul", {
|
|
562
841
|
className: dropdownMenuClass,
|
|
563
842
|
children: menu.items.map((item) => renderMenuItem2(item, menu.onClick, close))
|
|
564
843
|
}) : null);
|
|
565
844
|
const popup = dropdownRender ? dropdownRender(menuNode) : menuNode;
|
|
566
|
-
const
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
toggleVisible();
|
|
576
|
-
} : undefined
|
|
845
|
+
const show = () => !disabled && popupRef.current?.showPopover?.();
|
|
846
|
+
const hide = () => !disabled && popupRef.current?.hidePopover?.();
|
|
847
|
+
const toggle = () => {
|
|
848
|
+
if (disabled)
|
|
849
|
+
return;
|
|
850
|
+
if (popupRef.current?.matches(":popover-open"))
|
|
851
|
+
hide();
|
|
852
|
+
else
|
|
853
|
+
show();
|
|
577
854
|
};
|
|
855
|
+
const childIsButton = isValidElement(children) && (children.type === "button" || children.type === Button);
|
|
578
856
|
const triggerNode = isValidElement(children) ? cloneElement(children, {
|
|
579
|
-
|
|
580
|
-
|
|
857
|
+
popoverTarget: childIsButton && clickTrigger && !disabled ? popupId : undefined,
|
|
858
|
+
style: {
|
|
859
|
+
...children.props.style,
|
|
860
|
+
anchorName
|
|
861
|
+
},
|
|
862
|
+
"aria-controls": popupId,
|
|
863
|
+
"aria-expanded": nativeOpen,
|
|
864
|
+
disabled: disabled || children.props.disabled,
|
|
581
865
|
onMouseEnter: (event) => {
|
|
582
866
|
callHandler(children.props.onMouseEnter, event);
|
|
583
|
-
|
|
867
|
+
if (trigger.includes("hover"))
|
|
868
|
+
show();
|
|
584
869
|
onMouseEnter?.(event);
|
|
585
870
|
},
|
|
586
871
|
onMouseLeave: (event) => {
|
|
587
872
|
callHandler(children.props.onMouseLeave, event);
|
|
588
|
-
triggerProps.onMouseLeave?.();
|
|
589
873
|
onMouseLeave?.(event);
|
|
590
874
|
},
|
|
591
875
|
onClick: (event) => {
|
|
592
876
|
callHandler(children.props.onClick, event);
|
|
593
|
-
triggerProps.onClick?.();
|
|
594
877
|
onClick?.(event);
|
|
878
|
+
if (!childIsButton && clickTrigger && !event.defaultPrevented)
|
|
879
|
+
toggle();
|
|
595
880
|
},
|
|
596
881
|
onContextMenu: (event) => {
|
|
597
882
|
callHandler(children.props.onContextMenu, event);
|
|
598
|
-
|
|
883
|
+
if (trigger.includes("contextMenu")) {
|
|
884
|
+
event.preventDefault();
|
|
885
|
+
toggle();
|
|
886
|
+
}
|
|
599
887
|
onContextMenu?.(event);
|
|
600
888
|
}
|
|
601
|
-
}) : /* @__PURE__ */ jsx3("
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
"aria-
|
|
889
|
+
}) : /* @__PURE__ */ jsx3("button", {
|
|
890
|
+
type: "button",
|
|
891
|
+
disabled,
|
|
892
|
+
popoverTarget: clickTrigger && !disabled ? popupId : undefined,
|
|
893
|
+
style: { anchorName },
|
|
894
|
+
"aria-controls": popupId,
|
|
895
|
+
"aria-expanded": nativeOpen,
|
|
607
896
|
onMouseEnter: (event) => {
|
|
608
|
-
|
|
897
|
+
if (trigger.includes("hover"))
|
|
898
|
+
show();
|
|
609
899
|
onMouseEnter?.(event);
|
|
610
900
|
},
|
|
611
901
|
onMouseLeave: (event) => {
|
|
612
|
-
triggerProps.onMouseLeave?.();
|
|
613
902
|
onMouseLeave?.(event);
|
|
614
903
|
},
|
|
615
|
-
onClick
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
},
|
|
619
|
-
onKeyDown: (event) => {
|
|
620
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
904
|
+
onClick,
|
|
905
|
+
onContextMenu: (event) => {
|
|
906
|
+
if (trigger.includes("contextMenu")) {
|
|
621
907
|
event.preventDefault();
|
|
622
|
-
|
|
908
|
+
toggle();
|
|
623
909
|
}
|
|
624
|
-
},
|
|
625
|
-
onContextMenu: (event) => {
|
|
626
|
-
triggerProps.onContextMenu?.(event);
|
|
627
910
|
onContextMenu?.(event);
|
|
628
911
|
},
|
|
629
912
|
children
|
|
@@ -631,25 +914,30 @@ var DropdownRoot = forwardRef2(({
|
|
|
631
914
|
return /* @__PURE__ */ jsxs3("span", {
|
|
632
915
|
...props,
|
|
633
916
|
ref,
|
|
634
|
-
className: dropdownWrapperClass,
|
|
917
|
+
className: cn(dropdownWrapperClass, dropdownPlacementClasses[placement]),
|
|
918
|
+
onMouseLeave: trigger.includes("hover") ? hide : undefined,
|
|
635
919
|
children: [
|
|
636
920
|
triggerNode,
|
|
637
|
-
|
|
638
|
-
id:
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
921
|
+
/* @__PURE__ */ jsxs3("span", {
|
|
922
|
+
id: popupId,
|
|
923
|
+
ref: popupRef,
|
|
924
|
+
popover: "auto",
|
|
925
|
+
style: { positionAnchor: anchorName },
|
|
926
|
+
className: getDropdownClasses({ className, arrow }),
|
|
927
|
+
onToggle: (event) => {
|
|
928
|
+
if (event.target !== event.currentTarget)
|
|
929
|
+
return;
|
|
930
|
+
const nextOpen = event.nativeEvent.newState === "open";
|
|
931
|
+
setNativeOpen(nextOpen);
|
|
932
|
+
setVisible(nextOpen);
|
|
933
|
+
},
|
|
646
934
|
children: [
|
|
647
|
-
popup,
|
|
935
|
+
!destroyPopupOnHide || visible ? popup : null,
|
|
648
936
|
arrow ? /* @__PURE__ */ jsx3("span", {
|
|
649
937
|
className: dropdownArrowClass
|
|
650
938
|
}) : null
|
|
651
939
|
]
|
|
652
|
-
})
|
|
940
|
+
})
|
|
653
941
|
]
|
|
654
942
|
});
|
|
655
943
|
});
|
|
@@ -661,56 +949,80 @@ var DropdownButton = forwardRef2(({
|
|
|
661
949
|
menu,
|
|
662
950
|
onClick,
|
|
663
951
|
trigger = ["click"],
|
|
952
|
+
color = "base",
|
|
953
|
+
appearance = "outline",
|
|
954
|
+
size,
|
|
955
|
+
shape,
|
|
956
|
+
block,
|
|
957
|
+
isLoading,
|
|
958
|
+
leftIcon,
|
|
959
|
+
rightIcon,
|
|
960
|
+
confirm,
|
|
664
961
|
...props
|
|
665
962
|
}, ref) => {
|
|
963
|
+
const buttonStyle = { color, appearance, size, shape };
|
|
666
964
|
const buttons = [
|
|
667
965
|
/* @__PURE__ */ jsx3(Button, {
|
|
966
|
+
...buttonStyle,
|
|
668
967
|
disabled,
|
|
968
|
+
isLoading,
|
|
969
|
+
leftIcon,
|
|
970
|
+
rightIcon,
|
|
971
|
+
confirm,
|
|
669
972
|
onClick,
|
|
670
973
|
children
|
|
671
974
|
}, "primary"),
|
|
672
975
|
/* @__PURE__ */ jsx3(Button, {
|
|
976
|
+
...buttonStyle,
|
|
977
|
+
type: "button",
|
|
673
978
|
"aria-label": "Open dropdown",
|
|
674
|
-
disabled,
|
|
675
|
-
children: "
|
|
979
|
+
disabled: disabled || isLoading,
|
|
980
|
+
children: /* @__PURE__ */ jsxs3("svg", {
|
|
981
|
+
"aria-hidden": "true",
|
|
982
|
+
width: "18",
|
|
983
|
+
height: "18",
|
|
984
|
+
viewBox: "0 0 24 24",
|
|
985
|
+
fill: "currentColor",
|
|
986
|
+
children: [
|
|
987
|
+
/* @__PURE__ */ jsx3("circle", {
|
|
988
|
+
cx: "5",
|
|
989
|
+
cy: "12",
|
|
990
|
+
r: "1.75"
|
|
991
|
+
}),
|
|
992
|
+
/* @__PURE__ */ jsx3("circle", {
|
|
993
|
+
cx: "12",
|
|
994
|
+
cy: "12",
|
|
995
|
+
r: "1.75"
|
|
996
|
+
}),
|
|
997
|
+
/* @__PURE__ */ jsx3("circle", {
|
|
998
|
+
cx: "19",
|
|
999
|
+
cy: "12",
|
|
1000
|
+
r: "1.75"
|
|
1001
|
+
})
|
|
1002
|
+
]
|
|
1003
|
+
})
|
|
676
1004
|
}, "trigger")
|
|
677
1005
|
];
|
|
678
1006
|
const renderedButtons = buttonsRender ? buttonsRender(buttons) : buttons;
|
|
679
|
-
return /* @__PURE__ */
|
|
680
|
-
...props,
|
|
1007
|
+
return /* @__PURE__ */ jsxs3("span", {
|
|
681
1008
|
ref,
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
1009
|
+
className: cn(dropdownButtonClass, block && "dropdown-button-block"),
|
|
1010
|
+
children: [
|
|
1011
|
+
renderedButtons[0],
|
|
1012
|
+
/* @__PURE__ */ jsx3(DropdownRoot, {
|
|
1013
|
+
...props,
|
|
1014
|
+
menu,
|
|
1015
|
+
trigger,
|
|
1016
|
+
disabled: disabled || isLoading,
|
|
1017
|
+
children: renderedButtons[1]
|
|
1018
|
+
})
|
|
1019
|
+
]
|
|
689
1020
|
});
|
|
690
1021
|
});
|
|
691
1022
|
DropdownButton.displayName = "Dropdown.Button";
|
|
692
1023
|
var Dropdown = Object.assign(DropdownRoot, {
|
|
693
1024
|
Button: DropdownButton
|
|
694
1025
|
});
|
|
695
|
-
// src/components/dm-toolbar/DmToolbar.tsx
|
|
696
|
-
import { useMemo } from "react";
|
|
697
|
-
|
|
698
|
-
// src/classes/dm-toolbar.ts
|
|
699
|
-
var dmToolbarBaseClass = "dm-toolbar";
|
|
700
|
-
var dmToolbarItemClass = "dm-toolbar-item";
|
|
701
|
-
var dmToolbarPrimaryItemClass = "dm-toolbar-primary-item";
|
|
702
|
-
var dmToolbarSecondaryItemClass = "dm-toolbar-secondary-item";
|
|
703
|
-
var dmToolbarMoreClass = "dm-toolbar-more";
|
|
704
|
-
function getDmToolbarClasses({ className }) {
|
|
705
|
-
return cn(dmToolbarBaseClass, className);
|
|
706
|
-
}
|
|
707
|
-
function getDmToolbarItemClasses({
|
|
708
|
-
primary,
|
|
709
|
-
className
|
|
710
|
-
}) {
|
|
711
|
-
return cn(dmToolbarItemClass, primary ? dmToolbarPrimaryItemClass : dmToolbarSecondaryItemClass, className);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
1026
|
// src/components/dm-toolbar/DmToolbar.tsx
|
|
715
1027
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
716
1028
|
function isPrimary(item) {
|
|
@@ -764,12 +1076,12 @@ function DmToolbar({
|
|
|
764
1076
|
maxVisibleSecondaryItems
|
|
765
1077
|
}) {
|
|
766
1078
|
const { visibleSecondaryItems, overflowSecondaryItems, primaryItems } = useMemo(() => {
|
|
767
|
-
const
|
|
1079
|
+
const primaryItems = items.filter(isPrimary);
|
|
768
1080
|
const secondaryItems = items.filter((item) => !isPrimary(item));
|
|
769
1081
|
const visibleLimit = maxVisibleSecondaryItems === undefined ? secondaryItems.length : Math.max(0, maxVisibleSecondaryItems);
|
|
770
|
-
const
|
|
771
|
-
const
|
|
772
|
-
return { visibleSecondaryItems
|
|
1082
|
+
const visibleSecondaryItems = visibleLimit === 0 ? [] : secondaryItems.slice(-visibleLimit);
|
|
1083
|
+
const overflowSecondaryItems = visibleLimit >= secondaryItems.length ? [] : secondaryItems.slice(0, secondaryItems.length - visibleLimit);
|
|
1084
|
+
return { visibleSecondaryItems, overflowSecondaryItems, primaryItems };
|
|
773
1085
|
}, [items, maxVisibleSecondaryItems]);
|
|
774
1086
|
const showMore = overflowSecondaryItems.length > 0;
|
|
775
1087
|
return /* @__PURE__ */ jsxs4("div", {
|
|
@@ -800,34 +1112,12 @@ function DmToolbar({
|
|
|
800
1112
|
}
|
|
801
1113
|
DmToolbar.displayName = "DmToolbar";
|
|
802
1114
|
// src/components/dm-page-header/DmPageHeader.tsx
|
|
803
|
-
import
|
|
804
|
-
|
|
805
|
-
// src/classes/dm-page-header.ts
|
|
806
|
-
var dmPageHeaderBaseClass = "dm-page-header";
|
|
807
|
-
var dmPageHeaderMainClass = "dm-page-header-main";
|
|
808
|
-
var dmPageHeaderBackClass = "dm-page-header-back";
|
|
809
|
-
var dmPageHeaderDividerClass = "dm-page-header-divider";
|
|
810
|
-
var dmPageHeaderContentClass = "dm-page-header-content";
|
|
811
|
-
var dmPageHeaderTitleClass = "dm-page-header-title";
|
|
812
|
-
var dmPageHeaderTitleListClass = "dm-page-header-title-list";
|
|
813
|
-
var dmPageHeaderTitleItemClass = "dm-page-header-title-item";
|
|
814
|
-
var dmPageHeaderExtraClass = "dm-page-header-extra";
|
|
815
|
-
var dmPageHeaderBodyClass = "dm-page-header-body";
|
|
816
|
-
var dmPageHeaderBreadcrumbClass = "dm-page-header-breadcrumb";
|
|
817
|
-
function getDmPageHeaderClasses({
|
|
818
|
-
hasExtra,
|
|
819
|
-
className
|
|
820
|
-
}) {
|
|
821
|
-
return cn(dmPageHeaderBaseClass, hasExtra && "dm-page-header-has-extra", className);
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
// src/components/dm-page-header/DmPageHeader.tsx
|
|
825
|
-
import { jsx as jsx5, jsxs as jsxs5, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
1115
|
+
import { jsx as jsx5, jsxs as jsxs5, Fragment as Fragment3 } from "react/jsx-runtime";
|
|
826
1116
|
function isTitleList(title) {
|
|
827
1117
|
return Array.isArray(title);
|
|
828
1118
|
}
|
|
829
1119
|
function isToolbarProps(extra) {
|
|
830
|
-
return Boolean(extra && typeof extra === "object" && !
|
|
1120
|
+
return Boolean(extra && typeof extra === "object" && !React5.isValidElement(extra) && "items" in extra);
|
|
831
1121
|
}
|
|
832
1122
|
function DmPageHeader({
|
|
833
1123
|
backClick,
|
|
@@ -881,7 +1171,7 @@ function DmPageHeader({
|
|
|
881
1171
|
/* @__PURE__ */ jsxs5("div", {
|
|
882
1172
|
className: dmPageHeaderMainClass,
|
|
883
1173
|
children: [
|
|
884
|
-
handleBack ? /* @__PURE__ */ jsxs5(
|
|
1174
|
+
handleBack ? /* @__PURE__ */ jsxs5(Fragment3, {
|
|
885
1175
|
children: [
|
|
886
1176
|
/* @__PURE__ */ jsx5("button", {
|
|
887
1177
|
type: "button",
|