@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
|
@@ -25,6 +25,20 @@ function clsx() {
|
|
|
25
25
|
function cn(...inputs) {
|
|
26
26
|
return clsx(inputs);
|
|
27
27
|
}
|
|
28
|
+
// src/classes/dm-pro-table.ts
|
|
29
|
+
var dmProTableBaseClass = "dm-pro-table";
|
|
30
|
+
var dmProTableHeaderClass = "dm-pro-table-header";
|
|
31
|
+
var dmProTableTitleClass = "dm-pro-table-title";
|
|
32
|
+
var dmProTableToolbarClass = "dm-pro-table-toolbar";
|
|
33
|
+
var dmProTableColumnSettingClass = "dm-pro-table-column-setting";
|
|
34
|
+
function getDmProTableClasses({ className }) {
|
|
35
|
+
return cn(dmProTableBaseClass, className);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/components/button/Button.tsx
|
|
39
|
+
import React from "react";
|
|
40
|
+
import { createPortal } from "react-dom";
|
|
41
|
+
|
|
28
42
|
// src/classes/button.ts
|
|
29
43
|
var buttonBaseClass = "btn";
|
|
30
44
|
var buttonColorClasses = {
|
|
@@ -48,7 +62,7 @@ var buttonAppearanceClasses = {
|
|
|
48
62
|
};
|
|
49
63
|
var buttonShapeClasses = {
|
|
50
64
|
rect: "",
|
|
51
|
-
circle: "btn-circle",
|
|
65
|
+
circle: "btn-circle btn-icon",
|
|
52
66
|
square: "btn-square"
|
|
53
67
|
};
|
|
54
68
|
var buttonSizeClasses = {
|
|
@@ -68,11 +82,14 @@ function getButtonClasses({
|
|
|
68
82
|
isLoading,
|
|
69
83
|
className
|
|
70
84
|
}) {
|
|
71
|
-
return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
|
|
85
|
+
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
86
|
}
|
|
73
87
|
|
|
74
88
|
// src/components/button/Button.tsx
|
|
75
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
89
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
90
|
+
function isPromiseLike(value) {
|
|
91
|
+
return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
92
|
+
}
|
|
76
93
|
function Button({
|
|
77
94
|
color = "primary",
|
|
78
95
|
appearance = "filled",
|
|
@@ -86,8 +103,155 @@ function Button({
|
|
|
86
103
|
children,
|
|
87
104
|
disabled,
|
|
88
105
|
ref,
|
|
106
|
+
confirm,
|
|
107
|
+
onClick,
|
|
89
108
|
...props
|
|
90
109
|
}) {
|
|
110
|
+
const buttonRef = React.useRef(null);
|
|
111
|
+
const popoverRef = React.useRef(null);
|
|
112
|
+
const cancelRef = React.useRef(null);
|
|
113
|
+
const approvalRef = React.useRef("idle");
|
|
114
|
+
const pendingRef = React.useRef(false);
|
|
115
|
+
const actionRef = React.useRef(0);
|
|
116
|
+
const operationRef = React.useRef(0);
|
|
117
|
+
const mountedRef = React.useRef(false);
|
|
118
|
+
const [portalTarget, setPortalTarget] = React.useState(null);
|
|
119
|
+
const [confirmLoading, setConfirmLoading] = React.useState(false);
|
|
120
|
+
const [confirmError, setConfirmError] = React.useState(false);
|
|
121
|
+
const generatedId = React.useId().replace(/:/g, "");
|
|
122
|
+
const popoverId = `button-confirm-${generatedId}`;
|
|
123
|
+
const titleId = `${popoverId}-title`;
|
|
124
|
+
const descriptionId = `${popoverId}-description`;
|
|
125
|
+
const anchor = `--${popoverId}-anchor`;
|
|
126
|
+
const hasConfirm = Boolean(confirm);
|
|
127
|
+
const confirmation = confirm && typeof confirm === "object" ? confirm : undefined;
|
|
128
|
+
const title = confirmation ? confirmation.title : "Confirm action";
|
|
129
|
+
const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
|
|
130
|
+
const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
|
|
131
|
+
const hasContent = content !== undefined && content !== null && content !== false && content !== "";
|
|
132
|
+
const mergedRef = React.useCallback((node) => {
|
|
133
|
+
buttonRef.current = node;
|
|
134
|
+
if (!node) {
|
|
135
|
+
if (typeof ref === "function")
|
|
136
|
+
ref(null);
|
|
137
|
+
else if (ref)
|
|
138
|
+
ref.current = null;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const cleanup = typeof ref === "function" ? ref(node) : undefined;
|
|
142
|
+
if (ref && typeof ref !== "function")
|
|
143
|
+
ref.current = node;
|
|
144
|
+
return () => {
|
|
145
|
+
buttonRef.current = null;
|
|
146
|
+
if (typeof cleanup === "function")
|
|
147
|
+
cleanup();
|
|
148
|
+
else if (typeof ref === "function")
|
|
149
|
+
ref(null);
|
|
150
|
+
else if (ref)
|
|
151
|
+
ref.current = null;
|
|
152
|
+
};
|
|
153
|
+
}, [ref]);
|
|
154
|
+
React.useEffect(() => {
|
|
155
|
+
mountedRef.current = true;
|
|
156
|
+
return () => {
|
|
157
|
+
mountedRef.current = false;
|
|
158
|
+
operationRef.current += 1;
|
|
159
|
+
};
|
|
160
|
+
}, []);
|
|
161
|
+
React.useEffect(() => {
|
|
162
|
+
operationRef.current += 1;
|
|
163
|
+
approvalRef.current = "idle";
|
|
164
|
+
setConfirmError(false);
|
|
165
|
+
setPortalTarget(hasConfirm ? document.body : null);
|
|
166
|
+
}, [hasConfirm]);
|
|
167
|
+
function closePopover() {
|
|
168
|
+
if (popoverRef.current?.matches(":popover-open")) {
|
|
169
|
+
popoverRef.current.hidePopover();
|
|
170
|
+
}
|
|
171
|
+
buttonRef.current?.focus();
|
|
172
|
+
}
|
|
173
|
+
function handleClick(event) {
|
|
174
|
+
if (!confirm) {
|
|
175
|
+
onClick?.(event);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (approvalRef.current === "native") {
|
|
179
|
+
approvalRef.current = "idle";
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (approvalRef.current === "action") {
|
|
183
|
+
approvalRef.current = "idle";
|
|
184
|
+
let result;
|
|
185
|
+
try {
|
|
186
|
+
result = onClick?.(event);
|
|
187
|
+
} catch {
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
pendingRef.current = false;
|
|
190
|
+
setConfirmError(true);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (!isPromiseLike(result)) {
|
|
194
|
+
pendingRef.current = false;
|
|
195
|
+
closePopover();
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const userPreventedDefault = event.defaultPrevented;
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
setConfirmLoading(true);
|
|
201
|
+
const action = actionRef.current;
|
|
202
|
+
const operation = operationRef.current;
|
|
203
|
+
Promise.resolve(result).then(() => {
|
|
204
|
+
if (!mountedRef.current || action !== actionRef.current)
|
|
205
|
+
return;
|
|
206
|
+
pendingRef.current = false;
|
|
207
|
+
setConfirmLoading(false);
|
|
208
|
+
if (operation !== operationRef.current)
|
|
209
|
+
return;
|
|
210
|
+
closePopover();
|
|
211
|
+
if (!userPreventedDefault && !buttonRef.current?.disabled) {
|
|
212
|
+
approvalRef.current = "native";
|
|
213
|
+
buttonRef.current?.click();
|
|
214
|
+
approvalRef.current = "idle";
|
|
215
|
+
}
|
|
216
|
+
}, () => {
|
|
217
|
+
if (!mountedRef.current || action !== actionRef.current)
|
|
218
|
+
return;
|
|
219
|
+
pendingRef.current = false;
|
|
220
|
+
setConfirmLoading(false);
|
|
221
|
+
if (operation !== operationRef.current)
|
|
222
|
+
return;
|
|
223
|
+
setConfirmError(true);
|
|
224
|
+
cancelRef.current?.focus();
|
|
225
|
+
});
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
event.preventDefault();
|
|
229
|
+
if (disabled || isLoading || pendingRef.current)
|
|
230
|
+
return;
|
|
231
|
+
if (popoverRef.current?.matches(":popover-open")) {
|
|
232
|
+
closePopover();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
setConfirmError(false);
|
|
236
|
+
popoverRef.current?.showPopover();
|
|
237
|
+
cancelRef.current?.focus();
|
|
238
|
+
}
|
|
239
|
+
function handleConfirm(event) {
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
event.stopPropagation();
|
|
242
|
+
const trigger = buttonRef.current;
|
|
243
|
+
if (disabled || isLoading || pendingRef.current || !trigger || trigger.disabled || !event.currentTarget.matches(":popover-open"))
|
|
244
|
+
return;
|
|
245
|
+
setConfirmError(false);
|
|
246
|
+
pendingRef.current = true;
|
|
247
|
+
actionRef.current += 1;
|
|
248
|
+
approvalRef.current = "action";
|
|
249
|
+
trigger.click();
|
|
250
|
+
if (approvalRef.current === "action") {
|
|
251
|
+
approvalRef.current = "idle";
|
|
252
|
+
pendingRef.current = false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
91
255
|
const classes = getButtonClasses({
|
|
92
256
|
color,
|
|
93
257
|
appearance,
|
|
@@ -97,32 +261,125 @@ function Button({
|
|
|
97
261
|
isLoading,
|
|
98
262
|
className
|
|
99
263
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
...props,
|
|
264
|
+
const confirmClasses = getButtonClasses({
|
|
265
|
+
color,
|
|
266
|
+
size: "sm",
|
|
267
|
+
isLoading: confirmLoading
|
|
268
|
+
});
|
|
269
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
107
270
|
children: [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
271
|
+
/* @__PURE__ */ jsxs("button", {
|
|
272
|
+
ref: confirm ? mergedRef : ref,
|
|
273
|
+
className: classes,
|
|
274
|
+
disabled: disabled || isLoading,
|
|
275
|
+
"aria-busy": isLoading,
|
|
276
|
+
"aria-disabled": disabled || isLoading,
|
|
277
|
+
...props,
|
|
278
|
+
style: confirm ? { ...props.style, anchorName: anchor } : props.style,
|
|
279
|
+
"aria-haspopup": confirm ? "dialog" : props["aria-haspopup"],
|
|
280
|
+
"aria-controls": confirm ? popoverId : props["aria-controls"],
|
|
281
|
+
onClick: confirm ? handleClick : onClick,
|
|
282
|
+
children: [
|
|
283
|
+
isLoading && /* @__PURE__ */ jsx("span", {
|
|
284
|
+
className: "btn-spinner"
|
|
285
|
+
}),
|
|
286
|
+
!isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
|
|
287
|
+
className: "btn-icon-left",
|
|
288
|
+
children: leftIcon
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ jsx("span", {
|
|
291
|
+
className: "btn-content",
|
|
292
|
+
children
|
|
293
|
+
}),
|
|
294
|
+
!isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
|
|
295
|
+
className: "btn-icon-right",
|
|
296
|
+
children: rightIcon
|
|
297
|
+
})
|
|
298
|
+
]
|
|
118
299
|
}),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
300
|
+
confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs("form", {
|
|
301
|
+
id: popoverId,
|
|
302
|
+
ref: popoverRef,
|
|
303
|
+
popover: "auto",
|
|
304
|
+
role: "dialog",
|
|
305
|
+
"aria-labelledby": hasTitle ? titleId : undefined,
|
|
306
|
+
"aria-label": hasTitle ? undefined : "Confirm action",
|
|
307
|
+
"aria-describedby": hasContent ? descriptionId : undefined,
|
|
308
|
+
className: "popover popover-confirm popover-bottom",
|
|
309
|
+
style: { positionAnchor: anchor },
|
|
310
|
+
onSubmit: handleConfirm,
|
|
311
|
+
onClick: (event) => event.stopPropagation(),
|
|
312
|
+
onToggle: (event) => {
|
|
313
|
+
if (!event.currentTarget.matches(":popover-open")) {
|
|
314
|
+
operationRef.current += 1;
|
|
315
|
+
if (event.currentTarget.contains(document.activeElement) || document.activeElement === document.body) {
|
|
316
|
+
buttonRef.current?.focus();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
children: [
|
|
321
|
+
hasTitle && /* @__PURE__ */ jsx("div", {
|
|
322
|
+
className: "popover-header",
|
|
323
|
+
children: /* @__PURE__ */ jsx("h3", {
|
|
324
|
+
id: titleId,
|
|
325
|
+
className: "popover-title",
|
|
326
|
+
children: title
|
|
327
|
+
})
|
|
328
|
+
}),
|
|
329
|
+
hasContent && /* @__PURE__ */ jsx("div", {
|
|
330
|
+
id: descriptionId,
|
|
331
|
+
className: "popover-body",
|
|
332
|
+
children: content
|
|
333
|
+
}),
|
|
334
|
+
confirmError && /* @__PURE__ */ jsx("div", {
|
|
335
|
+
role: "alert",
|
|
336
|
+
className: "popover-body",
|
|
337
|
+
children: "The action failed. Please try again."
|
|
338
|
+
}),
|
|
339
|
+
/* @__PURE__ */ jsxs("div", {
|
|
340
|
+
className: "popover-footer",
|
|
341
|
+
children: [
|
|
342
|
+
/* @__PURE__ */ jsx("button", {
|
|
343
|
+
ref: cancelRef,
|
|
344
|
+
type: "button",
|
|
345
|
+
className: "btn btn-text btn-sm",
|
|
346
|
+
popoverTarget: popoverId,
|
|
347
|
+
popoverTargetAction: "hide",
|
|
348
|
+
disabled: confirmLoading,
|
|
349
|
+
children: confirmation?.cancelText ?? "Cancel"
|
|
350
|
+
}),
|
|
351
|
+
/* @__PURE__ */ jsx("button", {
|
|
352
|
+
type: "submit",
|
|
353
|
+
className: confirmClasses,
|
|
354
|
+
disabled: disabled || isLoading || confirmLoading,
|
|
355
|
+
"aria-busy": confirmLoading,
|
|
356
|
+
children: confirmation?.confirmText ?? "Confirm"
|
|
357
|
+
})
|
|
358
|
+
]
|
|
359
|
+
})
|
|
360
|
+
]
|
|
361
|
+
}), portalTarget)
|
|
123
362
|
]
|
|
124
363
|
});
|
|
125
364
|
}
|
|
365
|
+
// src/components/dm-table/DmTable.tsx
|
|
366
|
+
import { useMemo as useMemo8, useState as useState10 } from "react";
|
|
367
|
+
|
|
368
|
+
// src/classes/dm-table.ts
|
|
369
|
+
var dmTableBaseClass = "dm-table";
|
|
370
|
+
var dmTableSearchClass = "dm-table-search";
|
|
371
|
+
var dmTableCardClass = "dm-table-card";
|
|
372
|
+
var dmTableHeaderClass = "dm-table-header";
|
|
373
|
+
var dmTableTitleClass = "dm-table-title";
|
|
374
|
+
var dmTableExtraClass = "dm-table-extra";
|
|
375
|
+
var dmTableIndicatorsClass = "dm-table-indicators";
|
|
376
|
+
var dmTableTableExtraClass = "dm-table-table-extra";
|
|
377
|
+
var dmTableColumnSettingClass = "dm-table-column-setting";
|
|
378
|
+
var dmTablePaginationClass = "dm-table-pagination";
|
|
379
|
+
function getDmTableClasses({ className }) {
|
|
380
|
+
return cn(dmTableBaseClass, className);
|
|
381
|
+
}
|
|
382
|
+
|
|
126
383
|
// src/classes/card.ts
|
|
127
384
|
var cardBaseClass = "card";
|
|
128
385
|
var cardAppearanceClasses = {
|
|
@@ -166,1154 +423,1288 @@ function Card({
|
|
|
166
423
|
children
|
|
167
424
|
});
|
|
168
425
|
}
|
|
169
|
-
// src/components/
|
|
170
|
-
import {
|
|
426
|
+
// src/components/dm-pagination/DmPagination.tsx
|
|
427
|
+
import {
|
|
428
|
+
forwardRef as forwardRef2,
|
|
429
|
+
useEffect,
|
|
430
|
+
useMemo as useMemo2,
|
|
431
|
+
useRef,
|
|
432
|
+
useState as useState2
|
|
433
|
+
} from "react";
|
|
171
434
|
|
|
172
|
-
// src/classes/
|
|
173
|
-
var
|
|
174
|
-
var
|
|
175
|
-
var
|
|
176
|
-
var
|
|
177
|
-
var
|
|
178
|
-
var
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
var datePickerSizeClasses = {
|
|
184
|
-
sm: "datepicker-sm",
|
|
185
|
-
md: "",
|
|
186
|
-
lg: "datepicker-lg"
|
|
187
|
-
};
|
|
188
|
-
var datePickerStatusClasses = {
|
|
189
|
-
error: "datepicker-error",
|
|
190
|
-
success: "datepicker-success"
|
|
435
|
+
// src/classes/dm-pagination.ts
|
|
436
|
+
var dmPaginationBaseClass = "dm-pagination";
|
|
437
|
+
var dmPaginationHiddenClass = "dm-pagination-hidden";
|
|
438
|
+
var dmPaginationPagerClass = "dm-pagination-pager";
|
|
439
|
+
var dmPaginationRefreshClass = "dm-pagination-refresh";
|
|
440
|
+
var dmPaginationRefreshLoadingClass = "dm-pagination-refresh-loading";
|
|
441
|
+
var dmPaginationSelectedClass = "dm-pagination-selected";
|
|
442
|
+
var dmPaginationAlignClasses = {
|
|
443
|
+
left: "dm-pagination-left",
|
|
444
|
+
center: "dm-pagination-center",
|
|
445
|
+
right: "dm-pagination-right"
|
|
191
446
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
447
|
+
function getDmPaginationClasses({
|
|
448
|
+
align = "right",
|
|
449
|
+
hidden,
|
|
450
|
+
className
|
|
451
|
+
}) {
|
|
452
|
+
return cn(dmPaginationBaseClass, dmPaginationAlignClasses[align], hidden && dmPaginationHiddenClass, className);
|
|
453
|
+
}
|
|
454
|
+
function getDmPaginationRefreshClasses({
|
|
455
|
+
loading,
|
|
456
|
+
className
|
|
457
|
+
}) {
|
|
458
|
+
return cn(dmPaginationRefreshClass, loading && dmPaginationRefreshLoadingClass, className);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// src/components/pagination/Pagination.tsx
|
|
462
|
+
import {
|
|
463
|
+
forwardRef,
|
|
464
|
+
useMemo,
|
|
465
|
+
useState
|
|
466
|
+
} from "react";
|
|
467
|
+
|
|
468
|
+
// src/classes/pagination.ts
|
|
469
|
+
var paginationBaseClass = "pagination";
|
|
470
|
+
var paginationItemClass = "pagination-item";
|
|
471
|
+
var paginationItemActiveClass = "pagination-item-active";
|
|
472
|
+
var paginationItemDisabledClass = "pagination-item-disabled";
|
|
473
|
+
var paginationPrevClass = "pagination-prev";
|
|
474
|
+
var paginationNextClass = "pagination-next";
|
|
475
|
+
var paginationEllipsisClass = "pagination-ellipsis";
|
|
476
|
+
var paginationCompactClass = "pagination-compact";
|
|
477
|
+
var paginationInfoClass = "pagination-info";
|
|
478
|
+
var paginationInfoTextClass = "pagination-info-text";
|
|
479
|
+
var paginationInputClass = "pagination-input";
|
|
480
|
+
var paginationResponsiveClass = "pagination-responsive";
|
|
481
|
+
var paginationSizeClasses = {
|
|
482
|
+
sm: "pagination-sm",
|
|
483
|
+
md: "",
|
|
484
|
+
lg: "pagination-lg"
|
|
199
485
|
};
|
|
200
|
-
function
|
|
486
|
+
function getPaginationClasses({
|
|
201
487
|
size = "md",
|
|
202
|
-
|
|
203
|
-
picker = "date",
|
|
204
|
-
open,
|
|
205
|
-
disabled,
|
|
206
|
-
range,
|
|
488
|
+
compact,
|
|
207
489
|
className
|
|
208
490
|
}) {
|
|
209
|
-
return cn(
|
|
491
|
+
return cn(paginationBaseClass, paginationResponsiveClass, paginationSizeClasses[size], compact && paginationCompactClass, className);
|
|
210
492
|
}
|
|
211
|
-
function
|
|
212
|
-
|
|
213
|
-
|
|
493
|
+
function getPaginationItemClasses({
|
|
494
|
+
active,
|
|
495
|
+
disabled
|
|
214
496
|
}) {
|
|
215
|
-
return cn(
|
|
497
|
+
return cn(paginationItemClass, active && paginationItemActiveClass, disabled && paginationItemDisabledClass);
|
|
216
498
|
}
|
|
217
499
|
|
|
218
|
-
// src/components/
|
|
500
|
+
// src/components/pagination/Pagination.tsx
|
|
219
501
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return `${year}-${month}`;
|
|
227
|
-
if (picker === "year")
|
|
228
|
-
return String(year);
|
|
229
|
-
if (picker === "time")
|
|
230
|
-
return "00:00";
|
|
231
|
-
return `${year}-${month}-${day}`;
|
|
502
|
+
var defaultPageSizeOptions = [10, 20, 50, 100];
|
|
503
|
+
function toPositiveInteger(value, fallback) {
|
|
504
|
+
if (!Number.isFinite(value) || value === undefined) {
|
|
505
|
+
return fallback;
|
|
506
|
+
}
|
|
507
|
+
return Math.max(1, Math.floor(value));
|
|
232
508
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
return "month";
|
|
236
|
-
if (picker === "week")
|
|
237
|
-
return "week";
|
|
238
|
-
if (picker === "time")
|
|
239
|
-
return "time";
|
|
240
|
-
return picker === "year" || picker === "quarter" ? "text" : "date";
|
|
509
|
+
function clampPage(page, pageCount) {
|
|
510
|
+
return Math.min(pageCount, Math.max(1, Math.floor(page)));
|
|
241
511
|
}
|
|
242
|
-
function
|
|
243
|
-
|
|
244
|
-
return "Select month";
|
|
245
|
-
if (picker === "week")
|
|
246
|
-
return "Select week";
|
|
247
|
-
if (picker === "quarter")
|
|
248
|
-
return "Select quarter";
|
|
249
|
-
if (picker === "year")
|
|
250
|
-
return "Select year";
|
|
251
|
-
if (picker === "time")
|
|
252
|
-
return "Select time";
|
|
253
|
-
return "Select date";
|
|
512
|
+
function getPageCount(total, pageSize) {
|
|
513
|
+
return Math.max(1, Math.ceil(Math.max(0, total) / pageSize));
|
|
254
514
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
515
|
+
function getRange(current, pageSize, total) {
|
|
516
|
+
if (total <= 0) {
|
|
517
|
+
return [0, 0];
|
|
518
|
+
}
|
|
519
|
+
const start = (current - 1) * pageSize + 1;
|
|
520
|
+
const end = Math.min(total, current * pageSize);
|
|
521
|
+
return [start, end];
|
|
257
522
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
523
|
+
function getPageTokens(current, pageCount) {
|
|
524
|
+
if (pageCount <= 7) {
|
|
525
|
+
return Array.from({ length: pageCount }, (_, index) => index + 1);
|
|
526
|
+
}
|
|
527
|
+
const pages = new Set([1, pageCount, current - 1, current, current + 1]);
|
|
528
|
+
if (current <= 4) {
|
|
529
|
+
[2, 3, 4, 5].forEach((page) => pages.add(page));
|
|
530
|
+
}
|
|
531
|
+
if (current >= pageCount - 3) {
|
|
532
|
+
[pageCount - 4, pageCount - 3, pageCount - 2, pageCount - 1].forEach((page) => pages.add(page));
|
|
533
|
+
}
|
|
534
|
+
const sortedPages = Array.from(pages).filter((page) => page >= 1 && page <= pageCount).sort((first, second) => first - second);
|
|
535
|
+
return sortedPages.reduce((tokens, page) => {
|
|
536
|
+
const previous = tokens[tokens.length - 1];
|
|
537
|
+
if (typeof previous === "number") {
|
|
538
|
+
const gap = page - previous;
|
|
539
|
+
if (gap === 2) {
|
|
540
|
+
tokens.push(previous + 1);
|
|
541
|
+
} else if (gap > 2) {
|
|
542
|
+
tokens.push("ellipsis");
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
tokens.push(page);
|
|
546
|
+
return tokens;
|
|
547
|
+
}, []);
|
|
548
|
+
}
|
|
549
|
+
function getSizeOptions(pageSize) {
|
|
550
|
+
return Array.from(new Set([...defaultPageSizeOptions, pageSize])).sort((first, second) => first - second);
|
|
551
|
+
}
|
|
552
|
+
var Pagination = forwardRef(({
|
|
553
|
+
current,
|
|
554
|
+
defaultCurrent = 1,
|
|
555
|
+
pageSize,
|
|
556
|
+
defaultPageSize = 10,
|
|
557
|
+
total = 0,
|
|
558
|
+
onChange,
|
|
559
|
+
disabled,
|
|
560
|
+
simple,
|
|
561
|
+
showSizeChanger,
|
|
562
|
+
showQuickJumper,
|
|
563
|
+
showTotal,
|
|
564
|
+
size = "md",
|
|
565
|
+
className,
|
|
277
566
|
...props
|
|
278
567
|
}, ref) => {
|
|
279
|
-
const
|
|
280
|
-
const
|
|
281
|
-
const [
|
|
282
|
-
const [
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
568
|
+
const isCurrentControlled = current !== undefined;
|
|
569
|
+
const isPageSizeControlled = pageSize !== undefined;
|
|
570
|
+
const [internalCurrent, setInternalCurrent] = useState(defaultCurrent);
|
|
571
|
+
const [internalPageSize, setInternalPageSize] = useState(defaultPageSize);
|
|
572
|
+
const [quickJumpValue, setQuickJumpValue] = useState("");
|
|
573
|
+
const mergedPageSize = toPositiveInteger(pageSize ?? internalPageSize, defaultPageSize);
|
|
574
|
+
const pageCount = getPageCount(total, mergedPageSize);
|
|
575
|
+
const mergedCurrent = clampPage(toPositiveInteger(current ?? internalCurrent, defaultCurrent), pageCount);
|
|
576
|
+
const pageTokens = useMemo(() => getPageTokens(mergedCurrent, pageCount), [mergedCurrent, pageCount]);
|
|
577
|
+
const range = getRange(mergedCurrent, mergedPageSize, total);
|
|
578
|
+
function changePage(nextPage, nextPageSize = mergedPageSize) {
|
|
579
|
+
const nextPageCount = getPageCount(total, nextPageSize);
|
|
580
|
+
const normalizedPage = clampPage(nextPage, nextPageCount);
|
|
581
|
+
if (!isCurrentControlled) {
|
|
582
|
+
setInternalCurrent(normalizedPage);
|
|
289
583
|
}
|
|
290
|
-
|
|
584
|
+
if (!isPageSizeControlled) {
|
|
585
|
+
setInternalPageSize(nextPageSize);
|
|
586
|
+
}
|
|
587
|
+
onChange?.(normalizedPage, nextPageSize);
|
|
291
588
|
}
|
|
292
|
-
function
|
|
293
|
-
|
|
589
|
+
function handlePageSizeChange(event) {
|
|
590
|
+
const nextPageSize = toPositiveInteger(Number(event.currentTarget.value), mergedPageSize);
|
|
591
|
+
const nextPage = clampPage(mergedCurrent, getPageCount(total, nextPageSize));
|
|
592
|
+
changePage(nextPage, nextPageSize);
|
|
593
|
+
}
|
|
594
|
+
function jumpToInputPage(value) {
|
|
595
|
+
const nextPage = Number(value);
|
|
596
|
+
if (!Number.isFinite(nextPage)) {
|
|
294
597
|
return;
|
|
295
598
|
}
|
|
296
|
-
|
|
297
|
-
|
|
599
|
+
changePage(nextPage);
|
|
600
|
+
setQuickJumpValue("");
|
|
601
|
+
}
|
|
602
|
+
function handleQuickJumpKeyDown(event) {
|
|
603
|
+
if (event.key !== "Enter") {
|
|
604
|
+
return;
|
|
298
605
|
}
|
|
299
|
-
|
|
606
|
+
jumpToInputPage(event.currentTarget.value);
|
|
300
607
|
}
|
|
301
|
-
const
|
|
302
|
-
|
|
608
|
+
const previousDisabled = disabled || mergedCurrent <= 1;
|
|
609
|
+
const nextDisabled = disabled || mergedCurrent >= pageCount;
|
|
610
|
+
return /* @__PURE__ */ jsxs2("nav", {
|
|
303
611
|
...props,
|
|
304
612
|
ref,
|
|
305
|
-
className:
|
|
306
|
-
size,
|
|
307
|
-
status,
|
|
308
|
-
picker,
|
|
309
|
-
open: visible,
|
|
310
|
-
disabled,
|
|
311
|
-
className
|
|
312
|
-
}),
|
|
613
|
+
className: getPaginationClasses({ size, compact: simple, className }),
|
|
313
614
|
children: [
|
|
314
|
-
/* @__PURE__ */ jsx3("
|
|
315
|
-
className:
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
onFocus: (event) => {
|
|
321
|
-
onFocus?.(event);
|
|
322
|
-
setVisible(true);
|
|
323
|
-
},
|
|
324
|
-
onBlur: (event) => {
|
|
325
|
-
onBlur?.(event);
|
|
326
|
-
setVisible(false);
|
|
327
|
-
},
|
|
328
|
-
onChange: (event) => emitChange(event.currentTarget.value || undefined)
|
|
329
|
-
}),
|
|
330
|
-
allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx3("button", {
|
|
331
|
-
type: "button",
|
|
332
|
-
className: datePickerClearClass,
|
|
333
|
-
"aria-label": "Clear date",
|
|
334
|
-
onMouseDown: (event) => event.preventDefault(),
|
|
335
|
-
onClick: () => emitChange(undefined),
|
|
336
|
-
children: "x"
|
|
615
|
+
showTotal ? /* @__PURE__ */ jsx3("div", {
|
|
616
|
+
className: paginationInfoClass,
|
|
617
|
+
children: /* @__PURE__ */ jsx3("span", {
|
|
618
|
+
className: paginationInfoTextClass,
|
|
619
|
+
children: showTotal(total, range)
|
|
620
|
+
})
|
|
337
621
|
}) : null,
|
|
338
|
-
/* @__PURE__ */ jsx3("
|
|
339
|
-
|
|
340
|
-
|
|
622
|
+
/* @__PURE__ */ jsx3("button", {
|
|
623
|
+
type: "button",
|
|
624
|
+
className: paginationPrevClass,
|
|
625
|
+
disabled: previousDisabled,
|
|
626
|
+
"aria-label": "Previous page",
|
|
627
|
+
onClick: () => changePage(mergedCurrent - 1),
|
|
628
|
+
children: "Prev"
|
|
341
629
|
}),
|
|
342
|
-
|
|
343
|
-
className:
|
|
630
|
+
simple ? /* @__PURE__ */ jsxs2("div", {
|
|
631
|
+
className: paginationInputClass,
|
|
344
632
|
children: [
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
633
|
+
/* @__PURE__ */ jsx3("input", {
|
|
634
|
+
"aria-label": "Current page",
|
|
635
|
+
type: "number",
|
|
636
|
+
min: 1,
|
|
637
|
+
max: pageCount,
|
|
638
|
+
value: quickJumpValue || String(mergedCurrent),
|
|
639
|
+
disabled,
|
|
640
|
+
onChange: (event) => setQuickJumpValue(event.currentTarget.value),
|
|
641
|
+
onKeyDown: handleQuickJumpKeyDown,
|
|
642
|
+
onBlur: (event) => {
|
|
643
|
+
if (event.currentTarget.value !== String(mergedCurrent)) {
|
|
644
|
+
jumpToInputPage(event.currentTarget.value);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}),
|
|
648
|
+
/* @__PURE__ */ jsxs2("span", {
|
|
649
|
+
className: paginationInfoTextClass,
|
|
650
|
+
children: [
|
|
651
|
+
"/ ",
|
|
652
|
+
pageCount
|
|
653
|
+
]
|
|
654
|
+
})
|
|
361
655
|
]
|
|
656
|
+
}) : pageTokens.map((pageToken, index) => pageToken === "ellipsis" ? /* @__PURE__ */ jsx3("span", {
|
|
657
|
+
"aria-hidden": "true",
|
|
658
|
+
className: paginationEllipsisClass
|
|
659
|
+
}, `ellipsis-${index}`) : /* @__PURE__ */ jsx3("button", {
|
|
660
|
+
type: "button",
|
|
661
|
+
className: getPaginationItemClasses({
|
|
662
|
+
active: pageToken === mergedCurrent,
|
|
663
|
+
disabled
|
|
664
|
+
}),
|
|
665
|
+
disabled,
|
|
666
|
+
"aria-current": pageToken === mergedCurrent ? "page" : undefined,
|
|
667
|
+
"aria-label": `Page ${pageToken}`,
|
|
668
|
+
onClick: () => changePage(pageToken),
|
|
669
|
+
children: pageToken
|
|
670
|
+
}, pageToken)),
|
|
671
|
+
/* @__PURE__ */ jsx3("button", {
|
|
672
|
+
type: "button",
|
|
673
|
+
className: paginationNextClass,
|
|
674
|
+
disabled: nextDisabled,
|
|
675
|
+
"aria-label": "Next page",
|
|
676
|
+
onClick: () => changePage(mergedCurrent + 1),
|
|
677
|
+
children: "Next"
|
|
678
|
+
}),
|
|
679
|
+
showSizeChanger ? /* @__PURE__ */ jsx3("div", {
|
|
680
|
+
className: paginationInputClass,
|
|
681
|
+
children: /* @__PURE__ */ jsx3("select", {
|
|
682
|
+
"aria-label": "Page size",
|
|
683
|
+
value: mergedPageSize,
|
|
684
|
+
disabled,
|
|
685
|
+
onChange: handlePageSizeChange,
|
|
686
|
+
children: getSizeOptions(mergedPageSize).map((option) => /* @__PURE__ */ jsxs2("option", {
|
|
687
|
+
value: option,
|
|
688
|
+
children: [
|
|
689
|
+
option,
|
|
690
|
+
" / page"
|
|
691
|
+
]
|
|
692
|
+
}, option))
|
|
693
|
+
})
|
|
694
|
+
}) : null,
|
|
695
|
+
showQuickJumper && !simple ? /* @__PURE__ */ jsx3("div", {
|
|
696
|
+
className: paginationInputClass,
|
|
697
|
+
children: /* @__PURE__ */ jsx3("input", {
|
|
698
|
+
"aria-label": "Jump to page",
|
|
699
|
+
type: "number",
|
|
700
|
+
min: 1,
|
|
701
|
+
max: pageCount,
|
|
702
|
+
value: quickJumpValue,
|
|
703
|
+
disabled,
|
|
704
|
+
onChange: (event) => setQuickJumpValue(event.currentTarget.value),
|
|
705
|
+
onKeyDown: handleQuickJumpKeyDown
|
|
706
|
+
})
|
|
362
707
|
}) : null
|
|
363
708
|
]
|
|
364
709
|
});
|
|
365
710
|
});
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
711
|
+
Pagination.displayName = "Pagination";
|
|
712
|
+
// src/components/dm-pagination/DmPagination.tsx
|
|
713
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
714
|
+
var defaultLocale = {
|
|
715
|
+
refresh: "Refresh",
|
|
716
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} of ${total}`,
|
|
717
|
+
showTotalSimple: (total, range) => `${range[0]}-${range[1]} / ${total}`,
|
|
718
|
+
selected: (selectedTotal) => `, ${selectedTotal} selected`
|
|
719
|
+
};
|
|
720
|
+
function getResponsiveSimple({
|
|
721
|
+
width,
|
|
722
|
+
total,
|
|
723
|
+
showRefresh,
|
|
724
|
+
showSizeChanger
|
|
725
|
+
}) {
|
|
726
|
+
let reservedWidth = 0;
|
|
727
|
+
if (!showRefresh)
|
|
728
|
+
reservedWidth += 100;
|
|
729
|
+
if (!showSizeChanger)
|
|
730
|
+
reservedWidth += 100;
|
|
731
|
+
if (width < 900 - reservedWidth)
|
|
732
|
+
return total >= 100;
|
|
733
|
+
if (width < 1100 - reservedWidth)
|
|
734
|
+
return total >= 1000;
|
|
735
|
+
if (width < 1220 - reservedWidth)
|
|
736
|
+
return total >= 99999;
|
|
737
|
+
if (width < 1300 - reservedWidth)
|
|
738
|
+
return total >= 999999;
|
|
739
|
+
if (width < 1450 - reservedWidth)
|
|
740
|
+
return total >= 9999999;
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
function useElementWidth() {
|
|
744
|
+
const ref = useRef(null);
|
|
745
|
+
const [width, setWidth] = useState2(1000);
|
|
746
|
+
useEffect(() => {
|
|
747
|
+
const element = ref.current;
|
|
748
|
+
if (!element || typeof ResizeObserver === "undefined")
|
|
749
|
+
return;
|
|
750
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
751
|
+
setWidth(entry?.contentRect.width || element.getBoundingClientRect().width);
|
|
752
|
+
});
|
|
753
|
+
observer.observe(element);
|
|
754
|
+
return () => observer.disconnect();
|
|
755
|
+
}, []);
|
|
756
|
+
return [ref, width];
|
|
757
|
+
}
|
|
758
|
+
function renderSelected(selectedTotal, locale) {
|
|
759
|
+
if (!selectedTotal)
|
|
760
|
+
return null;
|
|
761
|
+
return /* @__PURE__ */ jsx4("span", {
|
|
762
|
+
className: dmPaginationSelectedClass,
|
|
763
|
+
children: locale.selected(selectedTotal)
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
var DmPagination = forwardRef2(({
|
|
767
|
+
selectedTotal = 0,
|
|
768
|
+
loading = false,
|
|
769
|
+
total = 0,
|
|
770
|
+
showRefresh = true,
|
|
771
|
+
showPagination = true,
|
|
772
|
+
wrapperStyle,
|
|
773
|
+
className,
|
|
774
|
+
align = "right",
|
|
775
|
+
showTotalFullMessage = false,
|
|
776
|
+
showSizeChanger = true,
|
|
777
|
+
responsiveSimple = true,
|
|
778
|
+
refresh,
|
|
779
|
+
simple,
|
|
780
|
+
showQuickJumper,
|
|
781
|
+
showTotal,
|
|
782
|
+
locale,
|
|
783
|
+
...props
|
|
784
|
+
}, ref) => {
|
|
785
|
+
const [measureRef, width] = useElementWidth();
|
|
786
|
+
const mergedLocale = useMemo2(() => ({ ...defaultLocale, ...locale }), [locale]);
|
|
787
|
+
const isRefreshVisible = showRefresh && Boolean(refresh);
|
|
788
|
+
const shouldRender = showPagination || isRefreshVisible;
|
|
789
|
+
const responsiveSimpleMode = responsiveSimple ? getResponsiveSimple({
|
|
790
|
+
width,
|
|
791
|
+
total,
|
|
792
|
+
showRefresh,
|
|
793
|
+
showSizeChanger
|
|
794
|
+
}) : false;
|
|
795
|
+
const mergedSimple = simple ?? responsiveSimpleMode;
|
|
796
|
+
const mergedShowQuickJumper = showQuickJumper ?? !mergedSimple;
|
|
797
|
+
const totalRenderer = useMemo2(() => {
|
|
798
|
+
if (showTotal)
|
|
799
|
+
return showTotal;
|
|
800
|
+
return (nextTotal, range) => {
|
|
801
|
+
if (Number(nextTotal) === 0)
|
|
802
|
+
return "";
|
|
803
|
+
const selected = renderSelected(selectedTotal, mergedLocale);
|
|
804
|
+
const message = mergedSimple && !showTotalFullMessage ? mergedLocale.showTotalSimple(nextTotal, range, selectedTotal) : mergedLocale.showTotal(nextTotal, range, selectedTotal);
|
|
805
|
+
return /* @__PURE__ */ jsxs3("span", {
|
|
806
|
+
title: `${mergedLocale.showTotal(nextTotal, range, selectedTotal)}${selectedTotal ? mergedLocale.selected(selectedTotal) : ""}`,
|
|
807
|
+
children: [
|
|
808
|
+
message,
|
|
809
|
+
selected
|
|
810
|
+
]
|
|
811
|
+
});
|
|
812
|
+
};
|
|
813
|
+
}, [
|
|
814
|
+
mergedLocale,
|
|
815
|
+
mergedSimple,
|
|
816
|
+
selectedTotal,
|
|
817
|
+
showTotal,
|
|
818
|
+
showTotalFullMessage
|
|
819
|
+
]);
|
|
820
|
+
if (!shouldRender)
|
|
821
|
+
return null;
|
|
822
|
+
return /* @__PURE__ */ jsxs3("div", {
|
|
823
|
+
ref: (element) => {
|
|
824
|
+
measureRef.current = element;
|
|
825
|
+
if (typeof ref === "function") {
|
|
826
|
+
ref(element);
|
|
827
|
+
} else if (ref) {
|
|
828
|
+
ref.current = element;
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
className: getDmPaginationClasses({ align, className }),
|
|
832
|
+
style: wrapperStyle,
|
|
833
|
+
children: [
|
|
834
|
+
showPagination ? /* @__PURE__ */ jsx4("div", {
|
|
835
|
+
className: dmPaginationPagerClass,
|
|
836
|
+
children: /* @__PURE__ */ jsx4(Pagination, {
|
|
837
|
+
...props,
|
|
838
|
+
total,
|
|
839
|
+
simple: mergedSimple,
|
|
840
|
+
showQuickJumper: mergedShowQuickJumper,
|
|
841
|
+
showSizeChanger,
|
|
842
|
+
showTotal: totalRenderer
|
|
843
|
+
})
|
|
844
|
+
}) : null,
|
|
845
|
+
isRefreshVisible ? /* @__PURE__ */ jsxs3("button", {
|
|
431
846
|
type: "button",
|
|
432
|
-
className:
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
847
|
+
className: getDmPaginationRefreshClasses({ loading }),
|
|
848
|
+
disabled: loading || props.disabled,
|
|
849
|
+
"aria-busy": loading || undefined,
|
|
850
|
+
onClick: refresh,
|
|
851
|
+
children: [
|
|
852
|
+
/* @__PURE__ */ jsx4("span", {
|
|
853
|
+
"aria-hidden": "true",
|
|
854
|
+
children: "Reload"
|
|
855
|
+
}),
|
|
856
|
+
/* @__PURE__ */ jsx4("span", {
|
|
857
|
+
children: mergedLocale.refresh
|
|
858
|
+
})
|
|
859
|
+
]
|
|
436
860
|
}) : null
|
|
437
861
|
]
|
|
438
862
|
});
|
|
439
863
|
});
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
const Picker = forwardRef((props, ref) => /* @__PURE__ */ jsx3(DatePickerRoot, {
|
|
443
|
-
...props,
|
|
444
|
-
ref,
|
|
445
|
-
picker
|
|
446
|
-
}));
|
|
447
|
-
Picker.displayName = displayName;
|
|
448
|
-
return Picker;
|
|
449
|
-
}
|
|
450
|
-
var DatePicker = Object.assign(DatePickerRoot, {
|
|
451
|
-
RangePicker,
|
|
452
|
-
WeekPicker: withPicker("week", "DatePicker.WeekPicker"),
|
|
453
|
-
MonthPicker: withPicker("month", "DatePicker.MonthPicker"),
|
|
454
|
-
QuarterPicker: withPicker("quarter", "DatePicker.QuarterPicker"),
|
|
455
|
-
YearPicker: withPicker("year", "DatePicker.YearPicker")
|
|
456
|
-
});
|
|
457
|
-
// src/components/dropdown/Dropdown.tsx
|
|
864
|
+
DmPagination.displayName = "DmPagination";
|
|
865
|
+
// src/components/dm-search/DmSearch.tsx
|
|
458
866
|
import {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
useState as
|
|
867
|
+
forwardRef as forwardRef7,
|
|
868
|
+
useEffect as useEffect3,
|
|
869
|
+
useImperativeHandle as useImperativeHandle3,
|
|
870
|
+
useMemo as useMemo6,
|
|
871
|
+
useState as useState8
|
|
464
872
|
} from "react";
|
|
465
873
|
|
|
466
|
-
// src/classes/
|
|
467
|
-
var
|
|
468
|
-
var
|
|
469
|
-
var
|
|
470
|
-
var
|
|
471
|
-
var
|
|
472
|
-
var
|
|
473
|
-
var
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
right: "popover-right dropdown-right",
|
|
478
|
-
topLeft: "popover-top dropdown-top-left",
|
|
479
|
-
topRight: "popover-top dropdown-top-right",
|
|
480
|
-
bottomLeft: "popover-bottom dropdown-bottom-left",
|
|
481
|
-
bottomRight: "popover-bottom dropdown-bottom-right"
|
|
482
|
-
};
|
|
483
|
-
function getDropdownClasses({
|
|
484
|
-
placement = "bottomLeft",
|
|
485
|
-
open,
|
|
486
|
-
arrow,
|
|
874
|
+
// src/classes/dm-search.ts
|
|
875
|
+
var dmSearchBaseClass = "dm-search";
|
|
876
|
+
var dmSearchCompactClass = "dm-search-compact";
|
|
877
|
+
var dmSearchCollapsedClass = "dm-search-collapsed";
|
|
878
|
+
var dmSearchFieldsClass = "dm-search-fields";
|
|
879
|
+
var dmSearchFieldClass = "dm-search-field";
|
|
880
|
+
var dmSearchActionsClass = "dm-search-actions";
|
|
881
|
+
var dmSearchFastFilterClass = "dm-search-fast-filter";
|
|
882
|
+
function getDmSearchClasses({
|
|
883
|
+
compact,
|
|
884
|
+
collapsed,
|
|
487
885
|
className
|
|
488
886
|
}) {
|
|
489
|
-
return cn(
|
|
887
|
+
return cn(dmSearchBaseClass, compact && dmSearchCompactClass, collapsed && dmSearchCollapsedClass, className);
|
|
490
888
|
}
|
|
491
889
|
|
|
492
|
-
// src/
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
var
|
|
500
|
-
var
|
|
501
|
-
var
|
|
502
|
-
var
|
|
503
|
-
var
|
|
504
|
-
var
|
|
505
|
-
var
|
|
506
|
-
var
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
};
|
|
515
|
-
var menuSizeClasses = {
|
|
516
|
-
sm: menuCompactClass,
|
|
517
|
-
md: "",
|
|
518
|
-
lg: menuWideClass
|
|
519
|
-
};
|
|
520
|
-
function getMenuClasses({
|
|
521
|
-
mode = "vertical",
|
|
522
|
-
theme = "light",
|
|
523
|
-
size = "md",
|
|
524
|
-
inlineCollapsed,
|
|
525
|
-
disabled,
|
|
890
|
+
// src/components/date-picker/DatePicker.tsx
|
|
891
|
+
import { forwardRef as forwardRef4, useMemo as useMemo4, useState as useState5 } from "react";
|
|
892
|
+
|
|
893
|
+
// src/components/calendar/Calendar.tsx
|
|
894
|
+
import { forwardRef as forwardRef3, useMemo as useMemo3, useState as useState3 } from "react";
|
|
895
|
+
|
|
896
|
+
// src/classes/calendar.ts
|
|
897
|
+
var calendarBaseClass = "datepicker calendar";
|
|
898
|
+
var calendarHeaderClass = "calendar-header";
|
|
899
|
+
var calendarTitleClass = "calendar-title";
|
|
900
|
+
var calendarControlsClass = "calendar-controls";
|
|
901
|
+
var calendarNavClass = "calendar-nav";
|
|
902
|
+
var calendarModeClass = "calendar-mode";
|
|
903
|
+
var calendarWeekdaysClass = "calendar-weekdays";
|
|
904
|
+
var calendarWeekdayClass = "calendar-weekday";
|
|
905
|
+
var calendarBodyClass = "calendar-body";
|
|
906
|
+
var calendarDateGridClass = "calendar-date-grid";
|
|
907
|
+
var calendarMonthGridClass = "calendar-month-grid";
|
|
908
|
+
var calendarCellContentClass = "calendar-cell-content";
|
|
909
|
+
function getCalendarClasses({
|
|
910
|
+
fullscreen = true,
|
|
911
|
+
mode = "month",
|
|
526
912
|
className
|
|
527
913
|
}) {
|
|
528
|
-
return cn(
|
|
914
|
+
return cn(calendarBaseClass, fullscreen ? "calendar-fullscreen" : "calendar-card", mode === "year" && "calendar-year-mode", className);
|
|
529
915
|
}
|
|
530
|
-
function
|
|
531
|
-
|
|
916
|
+
function getCalendarCellClasses({
|
|
917
|
+
selected,
|
|
918
|
+
today,
|
|
919
|
+
outside,
|
|
532
920
|
disabled,
|
|
533
|
-
danger,
|
|
534
|
-
submenu,
|
|
535
921
|
className
|
|
536
922
|
}) {
|
|
537
|
-
return cn(
|
|
923
|
+
return cn("calendar-cell", selected && "calendar-cell-selected", today && "calendar-cell-today", outside && "calendar-cell-outside", disabled && "calendar-cell-disabled", className);
|
|
538
924
|
}
|
|
539
925
|
|
|
540
|
-
// src/components/
|
|
541
|
-
import { jsx as
|
|
542
|
-
|
|
543
|
-
|
|
926
|
+
// src/components/calendar/Calendar.tsx
|
|
927
|
+
import { jsx as jsx5, jsxs as jsxs4, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
928
|
+
var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
929
|
+
var MONTHS = [
|
|
930
|
+
"Jan",
|
|
931
|
+
"Feb",
|
|
932
|
+
"Mar",
|
|
933
|
+
"Apr",
|
|
934
|
+
"May",
|
|
935
|
+
"Jun",
|
|
936
|
+
"Jul",
|
|
937
|
+
"Aug",
|
|
938
|
+
"Sep",
|
|
939
|
+
"Oct",
|
|
940
|
+
"Nov",
|
|
941
|
+
"Dec"
|
|
942
|
+
];
|
|
943
|
+
function pad(value) {
|
|
944
|
+
return String(value).padStart(2, "0");
|
|
945
|
+
}
|
|
946
|
+
function formatDate(date) {
|
|
947
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
948
|
+
}
|
|
949
|
+
function formatMonth(date) {
|
|
950
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-01`;
|
|
951
|
+
}
|
|
952
|
+
function parseDate(value) {
|
|
953
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) {
|
|
954
|
+
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
955
|
+
}
|
|
956
|
+
if (typeof value === "string" && value.length > 0) {
|
|
957
|
+
const [year, month = "1", day = "1"] = value.split("-");
|
|
958
|
+
const parsed = new Date(Number(year), Number(month) - 1, Number(day));
|
|
959
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
960
|
+
return parsed;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
const today = new Date;
|
|
964
|
+
return new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
965
|
+
}
|
|
966
|
+
function addMonths(date, amount) {
|
|
967
|
+
return new Date(date.getFullYear(), date.getMonth() + amount, 1);
|
|
968
|
+
}
|
|
969
|
+
function addYears(date, amount) {
|
|
970
|
+
return new Date(date.getFullYear() + amount, date.getMonth(), 1);
|
|
971
|
+
}
|
|
972
|
+
function startOfCalendarGrid(panelDate) {
|
|
973
|
+
const firstOfMonth = new Date(panelDate.getFullYear(), panelDate.getMonth(), 1);
|
|
974
|
+
const start = new Date(firstOfMonth);
|
|
975
|
+
start.setDate(firstOfMonth.getDate() - firstOfMonth.getDay());
|
|
976
|
+
return start;
|
|
977
|
+
}
|
|
978
|
+
function buildDateGrid(panelDate) {
|
|
979
|
+
const start = startOfCalendarGrid(panelDate);
|
|
980
|
+
return Array.from({ length: 42 }, (_, index) => {
|
|
981
|
+
const date = new Date(start);
|
|
982
|
+
date.setDate(start.getDate() + index);
|
|
983
|
+
return date;
|
|
984
|
+
});
|
|
544
985
|
}
|
|
545
|
-
function
|
|
546
|
-
|
|
986
|
+
function isSameMonth(left, right) {
|
|
987
|
+
return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();
|
|
547
988
|
}
|
|
548
|
-
function
|
|
549
|
-
if (
|
|
550
|
-
return
|
|
551
|
-
className: menuDividerClass
|
|
552
|
-
}, String(item.key));
|
|
989
|
+
function isOutsideRange(date, validRange) {
|
|
990
|
+
if (!validRange) {
|
|
991
|
+
return false;
|
|
553
992
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
993
|
+
const current = formatDate(date);
|
|
994
|
+
const start = formatDate(parseDate(validRange[0]));
|
|
995
|
+
const end = formatDate(parseDate(validRange[1]));
|
|
996
|
+
return current < start || current > end;
|
|
997
|
+
}
|
|
998
|
+
function Header({
|
|
999
|
+
panelDate,
|
|
1000
|
+
mode,
|
|
1001
|
+
setPanelDate,
|
|
1002
|
+
setMode
|
|
1003
|
+
}) {
|
|
1004
|
+
const title = mode === "year" ? String(panelDate.getFullYear()) : `${MONTHS[panelDate.getMonth()]} ${panelDate.getFullYear()}`;
|
|
1005
|
+
return /* @__PURE__ */ jsxs4("div", {
|
|
1006
|
+
className: calendarHeaderClass,
|
|
1007
|
+
children: [
|
|
1008
|
+
/* @__PURE__ */ jsx5("button", {
|
|
1009
|
+
type: "button",
|
|
1010
|
+
className: calendarNavClass,
|
|
1011
|
+
"aria-label": "Previous panel",
|
|
1012
|
+
onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, -1) : addMonths(panelDate, -1), mode),
|
|
1013
|
+
children: /* @__PURE__ */ jsx5("svg", {
|
|
1014
|
+
"aria-hidden": "true",
|
|
1015
|
+
focusable: "false",
|
|
1016
|
+
width: "16",
|
|
1017
|
+
height: "16",
|
|
1018
|
+
viewBox: "0 0 24 24",
|
|
1019
|
+
fill: "none",
|
|
1020
|
+
stroke: "currentColor",
|
|
1021
|
+
strokeWidth: "2",
|
|
1022
|
+
strokeLinecap: "round",
|
|
1023
|
+
strokeLinejoin: "round",
|
|
1024
|
+
children: /* @__PURE__ */ jsx5("path", {
|
|
1025
|
+
d: "m15 18-6-6 6-6"
|
|
1026
|
+
})
|
|
570
1027
|
})
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
1028
|
+
}),
|
|
1029
|
+
/* @__PURE__ */ jsxs4("div", {
|
|
1030
|
+
className: calendarControlsClass,
|
|
1031
|
+
children: [
|
|
1032
|
+
/* @__PURE__ */ jsx5("div", {
|
|
1033
|
+
className: calendarTitleClass,
|
|
1034
|
+
children: title
|
|
1035
|
+
}),
|
|
1036
|
+
/* @__PURE__ */ jsxs4("div", {
|
|
1037
|
+
className: calendarModeClass,
|
|
1038
|
+
children: [
|
|
1039
|
+
/* @__PURE__ */ jsx5("button", {
|
|
1040
|
+
type: "button",
|
|
1041
|
+
"aria-pressed": mode === "month",
|
|
1042
|
+
onClick: () => setMode("month"),
|
|
1043
|
+
children: "Month"
|
|
1044
|
+
}),
|
|
1045
|
+
/* @__PURE__ */ jsx5("button", {
|
|
1046
|
+
type: "button",
|
|
1047
|
+
"aria-pressed": mode === "year",
|
|
1048
|
+
onClick: () => setMode("year"),
|
|
1049
|
+
children: "Year"
|
|
1050
|
+
})
|
|
1051
|
+
]
|
|
1052
|
+
})
|
|
1053
|
+
]
|
|
1054
|
+
}),
|
|
1055
|
+
/* @__PURE__ */ jsx5("button", {
|
|
1056
|
+
type: "button",
|
|
1057
|
+
className: calendarNavClass,
|
|
1058
|
+
"aria-label": "Next panel",
|
|
1059
|
+
onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, 1) : addMonths(panelDate, 1), mode),
|
|
1060
|
+
children: /* @__PURE__ */ jsx5("svg", {
|
|
1061
|
+
"aria-hidden": "true",
|
|
1062
|
+
focusable: "false",
|
|
1063
|
+
width: "16",
|
|
1064
|
+
height: "16",
|
|
1065
|
+
viewBox: "0 0 24 24",
|
|
1066
|
+
fill: "none",
|
|
1067
|
+
stroke: "currentColor",
|
|
1068
|
+
strokeWidth: "2",
|
|
1069
|
+
strokeLinecap: "round",
|
|
1070
|
+
strokeLinejoin: "round",
|
|
1071
|
+
children: /* @__PURE__ */ jsx5("path", {
|
|
1072
|
+
d: "m9 18 6-6-6-6"
|
|
1073
|
+
})
|
|
1074
|
+
})
|
|
1075
|
+
})
|
|
1076
|
+
]
|
|
1077
|
+
});
|
|
574
1078
|
}
|
|
575
|
-
var
|
|
576
|
-
arrow,
|
|
577
|
-
children,
|
|
1079
|
+
var Calendar = forwardRef3(({
|
|
578
1080
|
className,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
1081
|
+
value,
|
|
1082
|
+
defaultValue,
|
|
1083
|
+
mode,
|
|
1084
|
+
defaultMode = "month",
|
|
1085
|
+
fullscreen = true,
|
|
1086
|
+
validRange,
|
|
1087
|
+
disabledDate,
|
|
1088
|
+
dateCellRender,
|
|
1089
|
+
dateFullCellRender,
|
|
1090
|
+
monthCellRender,
|
|
1091
|
+
monthFullCellRender,
|
|
1092
|
+
cellRender,
|
|
1093
|
+
fullCellRender,
|
|
1094
|
+
headerRender,
|
|
1095
|
+
onChange,
|
|
1096
|
+
onSelect,
|
|
1097
|
+
onPanelChange,
|
|
593
1098
|
...props
|
|
594
1099
|
}, ref) => {
|
|
595
|
-
const
|
|
596
|
-
const
|
|
597
|
-
const
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
1100
|
+
const selectedDate = parseDate(value ?? defaultValue);
|
|
1101
|
+
const [innerValue, setInnerValue] = useState3(() => formatDate(selectedDate));
|
|
1102
|
+
const [panelDate, setInnerPanelDate] = useState3(selectedDate);
|
|
1103
|
+
const [innerMode, setInnerMode] = useState3(mode ?? defaultMode);
|
|
1104
|
+
const currentMode = mode ?? innerMode;
|
|
1105
|
+
const currentValue = value === undefined ? innerValue : formatDate(parseDate(value));
|
|
1106
|
+
const today = useMemo3(() => formatDate(new Date), []);
|
|
1107
|
+
const dateGrid = useMemo3(() => buildDateGrid(panelDate), [panelDate]);
|
|
1108
|
+
function emitPanelChange(nextDate, nextMode = currentMode) {
|
|
1109
|
+
setInnerPanelDate(nextDate);
|
|
1110
|
+
onPanelChange?.(formatDate(nextDate), nextMode);
|
|
1111
|
+
}
|
|
1112
|
+
function setCalendarMode(nextMode) {
|
|
1113
|
+
if (mode === undefined) {
|
|
1114
|
+
setInnerMode(nextMode);
|
|
604
1115
|
}
|
|
605
|
-
|
|
1116
|
+
onPanelChange?.(formatDate(panelDate), nextMode);
|
|
606
1117
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
children: menu.items.map((item) => renderMenuItem(item, menu.onClick, close))
|
|
612
|
-
}) : null);
|
|
613
|
-
const popup = dropdownRender ? dropdownRender(menuNode) : menuNode;
|
|
614
|
-
const shouldRenderPopup = !destroyPopupOnHide || visible;
|
|
615
|
-
const triggerProps = {
|
|
616
|
-
"aria-controls": visible ? overlayId : undefined,
|
|
617
|
-
"aria-expanded": visible || undefined,
|
|
618
|
-
onMouseEnter: hasTrigger(trigger, "hover") ? () => setVisible(true) : undefined,
|
|
619
|
-
onMouseLeave: hasTrigger(trigger, "hover") ? () => setVisible(false) : undefined,
|
|
620
|
-
onClick: hasTrigger(trigger, "click") ? toggleVisible : undefined,
|
|
621
|
-
onContextMenu: hasTrigger(trigger, "contextMenu") ? (event) => {
|
|
622
|
-
event.preventDefault();
|
|
623
|
-
toggleVisible();
|
|
624
|
-
} : undefined
|
|
625
|
-
};
|
|
626
|
-
const triggerNode = isValidElement(children) ? cloneElement(children, {
|
|
627
|
-
"aria-controls": triggerProps["aria-controls"] ?? children.props["aria-controls"],
|
|
628
|
-
"aria-expanded": triggerProps["aria-expanded"] ?? children.props["aria-expanded"],
|
|
629
|
-
onMouseEnter: (event) => {
|
|
630
|
-
callHandler(children.props.onMouseEnter, event);
|
|
631
|
-
triggerProps.onMouseEnter?.();
|
|
632
|
-
onMouseEnter?.(event);
|
|
633
|
-
},
|
|
634
|
-
onMouseLeave: (event) => {
|
|
635
|
-
callHandler(children.props.onMouseLeave, event);
|
|
636
|
-
triggerProps.onMouseLeave?.();
|
|
637
|
-
onMouseLeave?.(event);
|
|
638
|
-
},
|
|
639
|
-
onClick: (event) => {
|
|
640
|
-
callHandler(children.props.onClick, event);
|
|
641
|
-
triggerProps.onClick?.();
|
|
642
|
-
onClick?.(event);
|
|
643
|
-
},
|
|
644
|
-
onContextMenu: (event) => {
|
|
645
|
-
callHandler(children.props.onContextMenu, event);
|
|
646
|
-
triggerProps.onContextMenu?.(event);
|
|
647
|
-
onContextMenu?.(event);
|
|
1118
|
+
function commitValue(nextDate, source) {
|
|
1119
|
+
const nextValue = source === "month" ? formatMonth(nextDate) : formatDate(nextDate);
|
|
1120
|
+
if (disabledDate?.(nextValue) || isOutsideRange(nextDate, validRange)) {
|
|
1121
|
+
return;
|
|
648
1122
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
1123
|
+
if (value === undefined) {
|
|
1124
|
+
setInnerValue(nextValue);
|
|
1125
|
+
}
|
|
1126
|
+
setInnerPanelDate(nextDate);
|
|
1127
|
+
onSelect?.(nextValue, { source });
|
|
1128
|
+
onChange?.(nextValue);
|
|
1129
|
+
}
|
|
1130
|
+
function renderDateCell(date) {
|
|
1131
|
+
const dateValue = formatDate(date);
|
|
1132
|
+
const originNode = /* @__PURE__ */ jsxs4("div", {
|
|
1133
|
+
className: calendarCellContentClass,
|
|
1134
|
+
children: [
|
|
1135
|
+
/* @__PURE__ */ jsx5("span", {
|
|
1136
|
+
children: date.getDate()
|
|
1137
|
+
}),
|
|
1138
|
+
dateCellRender?.(dateValue)
|
|
1139
|
+
]
|
|
1140
|
+
});
|
|
1141
|
+
const info = {
|
|
1142
|
+
originNode,
|
|
1143
|
+
today,
|
|
1144
|
+
type: "month"
|
|
1145
|
+
};
|
|
1146
|
+
const content = fullCellRender?.(dateValue, info) ?? dateFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
|
|
1147
|
+
const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
|
|
1148
|
+
return /* @__PURE__ */ jsx5("button", {
|
|
1149
|
+
type: "button",
|
|
1150
|
+
"aria-label": dateValue,
|
|
1151
|
+
disabled,
|
|
1152
|
+
className: getCalendarCellClasses({
|
|
1153
|
+
selected: dateValue === currentValue,
|
|
1154
|
+
today: dateValue === today,
|
|
1155
|
+
outside: !isSameMonth(date, panelDate),
|
|
1156
|
+
disabled
|
|
1157
|
+
}),
|
|
1158
|
+
onClick: () => commitValue(date, "date"),
|
|
1159
|
+
children: content
|
|
1160
|
+
}, dateValue);
|
|
1161
|
+
}
|
|
1162
|
+
function renderMonthCell(month) {
|
|
1163
|
+
const date = new Date(panelDate.getFullYear(), month, 1);
|
|
1164
|
+
const dateValue = formatMonth(date);
|
|
1165
|
+
const originNode = /* @__PURE__ */ jsxs4("div", {
|
|
1166
|
+
className: calendarCellContentClass,
|
|
1167
|
+
children: [
|
|
1168
|
+
/* @__PURE__ */ jsx5("span", {
|
|
1169
|
+
children: MONTHS[month]
|
|
1170
|
+
}),
|
|
1171
|
+
monthCellRender?.(dateValue)
|
|
1172
|
+
]
|
|
1173
|
+
});
|
|
1174
|
+
const info = {
|
|
1175
|
+
originNode,
|
|
1176
|
+
today,
|
|
1177
|
+
type: "year"
|
|
1178
|
+
};
|
|
1179
|
+
const content = fullCellRender?.(dateValue, info) ?? monthFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
|
|
1180
|
+
const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
|
|
1181
|
+
return /* @__PURE__ */ jsx5("button", {
|
|
1182
|
+
type: "button",
|
|
1183
|
+
"aria-label": dateValue,
|
|
1184
|
+
disabled,
|
|
1185
|
+
className: getCalendarCellClasses({
|
|
1186
|
+
selected: dateValue === formatMonth(parseDate(currentValue)),
|
|
1187
|
+
today: dateValue === formatMonth(new Date),
|
|
1188
|
+
disabled
|
|
1189
|
+
}),
|
|
1190
|
+
onClick: () => commitValue(date, "month"),
|
|
1191
|
+
children: content
|
|
1192
|
+
}, dateValue);
|
|
1193
|
+
}
|
|
1194
|
+
return /* @__PURE__ */ jsxs4("div", {
|
|
680
1195
|
...props,
|
|
681
1196
|
ref,
|
|
682
|
-
className:
|
|
1197
|
+
className: getCalendarClasses({
|
|
1198
|
+
fullscreen,
|
|
1199
|
+
mode: currentMode,
|
|
1200
|
+
className
|
|
1201
|
+
}),
|
|
683
1202
|
children: [
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
1203
|
+
headerRender ? headerRender({
|
|
1204
|
+
value: formatDate(panelDate),
|
|
1205
|
+
type: currentMode,
|
|
1206
|
+
onChange: (nextValue) => emitPanelChange(parseDate(nextValue)),
|
|
1207
|
+
onTypeChange: setCalendarMode
|
|
1208
|
+
}) : /* @__PURE__ */ jsx5(Header, {
|
|
1209
|
+
panelDate,
|
|
1210
|
+
mode: currentMode,
|
|
1211
|
+
setPanelDate: emitPanelChange,
|
|
1212
|
+
setMode: setCalendarMode
|
|
1213
|
+
}),
|
|
1214
|
+
/* @__PURE__ */ jsx5("div", {
|
|
1215
|
+
className: calendarBodyClass,
|
|
1216
|
+
children: currentMode === "month" ? /* @__PURE__ */ jsxs4(Fragment2, {
|
|
1217
|
+
children: [
|
|
1218
|
+
/* @__PURE__ */ jsx5("div", {
|
|
1219
|
+
className: calendarWeekdaysClass,
|
|
1220
|
+
"aria-hidden": "true",
|
|
1221
|
+
children: WEEKDAYS.map((weekday) => /* @__PURE__ */ jsx5("span", {
|
|
1222
|
+
className: calendarWeekdayClass,
|
|
1223
|
+
children: weekday
|
|
1224
|
+
}, weekday))
|
|
1225
|
+
}),
|
|
1226
|
+
/* @__PURE__ */ jsx5("div", {
|
|
1227
|
+
className: calendarDateGridClass,
|
|
1228
|
+
children: dateGrid.map(renderDateCell)
|
|
1229
|
+
})
|
|
1230
|
+
]
|
|
1231
|
+
}) : /* @__PURE__ */ jsx5("div", {
|
|
1232
|
+
className: calendarMonthGridClass,
|
|
1233
|
+
children: MONTHS.map((_, month) => renderMonthCell(month))
|
|
1234
|
+
})
|
|
1235
|
+
})
|
|
701
1236
|
]
|
|
702
1237
|
});
|
|
703
1238
|
});
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
1239
|
+
Calendar.displayName = "Calendar";
|
|
1240
|
+
// src/components/date-picker/usePickerDropdown.ts
|
|
1241
|
+
import { useEffect as useEffect2, useId, useImperativeHandle, useRef as useRef2, useState as useState4 } from "react";
|
|
1242
|
+
function usePickerDropdown({
|
|
1243
|
+
open,
|
|
1244
|
+
defaultOpen,
|
|
708
1245
|
disabled,
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
}
|
|
1246
|
+
onOpenChange,
|
|
1247
|
+
ref
|
|
1248
|
+
}) {
|
|
1249
|
+
const rootRef = useRef2(null);
|
|
1250
|
+
const inputRef = useRef2(null);
|
|
1251
|
+
const skipFocus = useRef2(false);
|
|
1252
|
+
const panelId = useId();
|
|
1253
|
+
const [innerOpen, setInnerOpen] = useState4(Boolean(defaultOpen));
|
|
1254
|
+
const visible = !disabled && (open ?? innerOpen);
|
|
1255
|
+
useImperativeHandle(ref, () => rootRef.current, []);
|
|
1256
|
+
function setVisible(next) {
|
|
1257
|
+
if (disabled || next === visible)
|
|
1258
|
+
return;
|
|
1259
|
+
if (open === undefined)
|
|
1260
|
+
setInnerOpen(next);
|
|
1261
|
+
onOpenChange?.(next);
|
|
1262
|
+
}
|
|
1263
|
+
function closeAndFocus() {
|
|
1264
|
+
skipFocus.current = true;
|
|
1265
|
+
inputRef.current?.focus();
|
|
1266
|
+
skipFocus.current = false;
|
|
1267
|
+
setVisible(false);
|
|
1268
|
+
}
|
|
1269
|
+
useEffect2(() => {
|
|
1270
|
+
function handleOutside(event) {
|
|
1271
|
+
if (visible && !rootRef.current?.contains(event.target))
|
|
1272
|
+
setVisible(false);
|
|
1273
|
+
}
|
|
1274
|
+
function handleKeyDown(event) {
|
|
1275
|
+
if (event.defaultPrevented || !rootRef.current?.contains(event.target))
|
|
1276
|
+
return;
|
|
1277
|
+
if (event.key === "Escape" && visible) {
|
|
1278
|
+
event.preventDefault();
|
|
1279
|
+
closeAndFocus();
|
|
1280
|
+
} else if (event.key === "ArrowDown" && event.target === inputRef.current) {
|
|
1281
|
+
event.preventDefault();
|
|
1282
|
+
setVisible(true);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
document.addEventListener("pointerdown", handleOutside);
|
|
1286
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
1287
|
+
return () => {
|
|
1288
|
+
document.removeEventListener("pointerdown", handleOutside);
|
|
1289
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
1290
|
+
};
|
|
737
1291
|
});
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
1292
|
+
return {
|
|
1293
|
+
rootRef,
|
|
1294
|
+
inputRef,
|
|
1295
|
+
panelId,
|
|
1296
|
+
visible,
|
|
1297
|
+
setVisible,
|
|
1298
|
+
closeAndFocus,
|
|
1299
|
+
onInputFocus: () => {
|
|
1300
|
+
if (!skipFocus.current)
|
|
1301
|
+
setVisible(true);
|
|
1302
|
+
},
|
|
1303
|
+
onRootBlur: (event) => {
|
|
1304
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
1305
|
+
setVisible(false);
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
745
1309
|
|
|
746
|
-
// src/classes/
|
|
747
|
-
var
|
|
748
|
-
var
|
|
749
|
-
var
|
|
750
|
-
var
|
|
751
|
-
var
|
|
752
|
-
|
|
753
|
-
|
|
1310
|
+
// src/classes/date-picker.ts
|
|
1311
|
+
var datePickerBaseClass = "datepicker";
|
|
1312
|
+
var datePickerInputClass = "datepicker-input";
|
|
1313
|
+
var datePickerIconClass = "datepicker-icon";
|
|
1314
|
+
var datePickerDropdownClass = "datepicker-dropdown";
|
|
1315
|
+
var datePickerDropdownOpenClass = "datepicker-dropdown-open";
|
|
1316
|
+
var datePickerFooterClass = "datepicker-footer";
|
|
1317
|
+
var datePickerPresetClass = "datepicker-preset";
|
|
1318
|
+
var datePickerRangeClass = "datepicker-range";
|
|
1319
|
+
var datePickerSeparatorClass = "datepicker-range-separator";
|
|
1320
|
+
var datePickerClearClass = "datepicker-clear";
|
|
1321
|
+
var datePickerSizeClasses = {
|
|
1322
|
+
sm: "datepicker-sm",
|
|
1323
|
+
md: "",
|
|
1324
|
+
lg: "datepicker-lg"
|
|
1325
|
+
};
|
|
1326
|
+
var datePickerStatusClasses = {
|
|
1327
|
+
error: "datepicker-error",
|
|
1328
|
+
success: "datepicker-success"
|
|
1329
|
+
};
|
|
1330
|
+
var datePickerPickerClasses = {
|
|
1331
|
+
date: "",
|
|
1332
|
+
week: "datepicker-week",
|
|
1333
|
+
month: "datepicker-month-picker",
|
|
1334
|
+
quarter: "datepicker-quarter-picker",
|
|
1335
|
+
year: "datepicker-year-picker",
|
|
1336
|
+
time: "datepicker-time-picker"
|
|
1337
|
+
};
|
|
1338
|
+
function getDatePickerClasses({
|
|
1339
|
+
size = "md",
|
|
1340
|
+
status,
|
|
1341
|
+
picker = "date",
|
|
1342
|
+
open,
|
|
1343
|
+
disabled,
|
|
1344
|
+
range,
|
|
1345
|
+
className
|
|
1346
|
+
}) {
|
|
1347
|
+
return cn(datePickerBaseClass, datePickerSizeClasses[size], status && datePickerStatusClasses[status], datePickerPickerClasses[picker], open && "datepicker-open", disabled && "datepicker-disabled", range && datePickerRangeClass, className);
|
|
754
1348
|
}
|
|
755
|
-
function
|
|
756
|
-
|
|
1349
|
+
function getDatePickerDropdownClasses({
|
|
1350
|
+
open,
|
|
757
1351
|
className
|
|
758
1352
|
}) {
|
|
759
|
-
return cn(
|
|
1353
|
+
return cn(datePickerDropdownClass, open && datePickerDropdownOpenClass, className);
|
|
760
1354
|
}
|
|
761
1355
|
|
|
762
|
-
// src/components/
|
|
763
|
-
import { jsx as
|
|
764
|
-
function
|
|
765
|
-
|
|
1356
|
+
// src/components/date-picker/DatePicker.tsx
|
|
1357
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1358
|
+
function todayValue(picker) {
|
|
1359
|
+
const today = new Date;
|
|
1360
|
+
const year = today.getFullYear();
|
|
1361
|
+
const month = String(today.getMonth() + 1).padStart(2, "0");
|
|
1362
|
+
const day = String(today.getDate()).padStart(2, "0");
|
|
1363
|
+
if (picker === "month")
|
|
1364
|
+
return `${year}-${month}`;
|
|
1365
|
+
if (picker === "year")
|
|
1366
|
+
return String(year);
|
|
1367
|
+
if (picker === "time")
|
|
1368
|
+
return "00:00";
|
|
1369
|
+
return `${year}-${month}-${day}`;
|
|
766
1370
|
}
|
|
767
|
-
function
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
...buttonPropsWithKey
|
|
776
|
-
} = item;
|
|
777
|
-
const buttonProps = { ...buttonPropsWithKey };
|
|
778
|
-
delete buttonProps.key;
|
|
779
|
-
const button = /* @__PURE__ */ jsx5(Button, {
|
|
780
|
-
...buttonProps,
|
|
781
|
-
type: htmlType,
|
|
782
|
-
color: color ?? (type === "primary" ? "primary" : "secondary"),
|
|
783
|
-
appearance: appearance ?? (type === "primary" ? "filled" : "outline"),
|
|
784
|
-
children: title
|
|
785
|
-
});
|
|
786
|
-
if (!menu?.items?.length)
|
|
787
|
-
return button;
|
|
788
|
-
return /* @__PURE__ */ jsx5(Dropdown, {
|
|
789
|
-
trigger: ["click"],
|
|
790
|
-
menu,
|
|
791
|
-
children: button
|
|
792
|
-
}, `dropdown-${index}`);
|
|
793
|
-
}
|
|
794
|
-
function toOverflowMenu(items) {
|
|
795
|
-
return {
|
|
796
|
-
items: items.map((item, index) => ({
|
|
797
|
-
key: item.key ?? index,
|
|
798
|
-
label: item.title,
|
|
799
|
-
disabled: item.disabled
|
|
800
|
-
})),
|
|
801
|
-
onClick: ({ key, domEvent }) => {
|
|
802
|
-
const target = items.find((item, index) => String(item.key ?? index) === key);
|
|
803
|
-
target?.onClick?.(domEvent);
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
function DmToolbar({
|
|
808
|
-
items = [],
|
|
809
|
-
className,
|
|
810
|
-
style,
|
|
811
|
-
moreText = "More",
|
|
812
|
-
maxVisibleSecondaryItems
|
|
813
|
-
}) {
|
|
814
|
-
const { visibleSecondaryItems, overflowSecondaryItems, primaryItems } = useMemo2(() => {
|
|
815
|
-
const primaryItems2 = items.filter(isPrimary);
|
|
816
|
-
const secondaryItems = items.filter((item) => !isPrimary(item));
|
|
817
|
-
const visibleLimit = maxVisibleSecondaryItems === undefined ? secondaryItems.length : Math.max(0, maxVisibleSecondaryItems);
|
|
818
|
-
const visibleSecondaryItems2 = visibleLimit === 0 ? [] : secondaryItems.slice(-visibleLimit);
|
|
819
|
-
const overflowSecondaryItems2 = visibleLimit >= secondaryItems.length ? [] : secondaryItems.slice(0, secondaryItems.length - visibleLimit);
|
|
820
|
-
return { visibleSecondaryItems: visibleSecondaryItems2, overflowSecondaryItems: overflowSecondaryItems2, primaryItems: primaryItems2 };
|
|
821
|
-
}, [items, maxVisibleSecondaryItems]);
|
|
822
|
-
const showMore = overflowSecondaryItems.length > 0;
|
|
823
|
-
return /* @__PURE__ */ jsxs4("div", {
|
|
824
|
-
className: getDmToolbarClasses({ className }),
|
|
825
|
-
style,
|
|
826
|
-
children: [
|
|
827
|
-
visibleSecondaryItems.map((item, index) => /* @__PURE__ */ jsx5("span", {
|
|
828
|
-
className: getDmToolbarItemClasses({}),
|
|
829
|
-
children: renderToolbarItem(item, index)
|
|
830
|
-
}, item.key ?? `secondary-${index}`)),
|
|
831
|
-
showMore ? /* @__PURE__ */ jsx5(Dropdown, {
|
|
832
|
-
trigger: ["click"],
|
|
833
|
-
menu: toOverflowMenu(overflowSecondaryItems),
|
|
834
|
-
children: /* @__PURE__ */ jsx5(Button, {
|
|
835
|
-
type: "button",
|
|
836
|
-
className: dmToolbarMoreClass,
|
|
837
|
-
color: "secondary",
|
|
838
|
-
appearance: "outline",
|
|
839
|
-
children: moreText
|
|
840
|
-
})
|
|
841
|
-
}) : null,
|
|
842
|
-
primaryItems.map((item, index) => /* @__PURE__ */ jsx5("span", {
|
|
843
|
-
className: getDmToolbarItemClasses({ primary: true }),
|
|
844
|
-
children: renderToolbarItem(item, index)
|
|
845
|
-
}, item.key ?? `primary-${index}`))
|
|
846
|
-
]
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
DmToolbar.displayName = "DmToolbar";
|
|
850
|
-
// src/components/pagination/Pagination.tsx
|
|
851
|
-
import {
|
|
852
|
-
forwardRef as forwardRef3,
|
|
853
|
-
useMemo as useMemo3,
|
|
854
|
-
useState as useState3
|
|
855
|
-
} from "react";
|
|
856
|
-
|
|
857
|
-
// src/classes/pagination.ts
|
|
858
|
-
var paginationBaseClass = "pagination";
|
|
859
|
-
var paginationItemClass = "pagination-item";
|
|
860
|
-
var paginationItemActiveClass = "pagination-item-active";
|
|
861
|
-
var paginationItemDisabledClass = "pagination-item-disabled";
|
|
862
|
-
var paginationPrevClass = "pagination-prev";
|
|
863
|
-
var paginationNextClass = "pagination-next";
|
|
864
|
-
var paginationEllipsisClass = "pagination-ellipsis";
|
|
865
|
-
var paginationCompactClass = "pagination-compact";
|
|
866
|
-
var paginationInfoClass = "pagination-info";
|
|
867
|
-
var paginationInfoTextClass = "pagination-info-text";
|
|
868
|
-
var paginationInputClass = "pagination-input";
|
|
869
|
-
var paginationResponsiveClass = "pagination-responsive";
|
|
870
|
-
var paginationSizeClasses = {
|
|
871
|
-
sm: "pagination-sm",
|
|
872
|
-
md: "",
|
|
873
|
-
lg: "pagination-lg"
|
|
874
|
-
};
|
|
875
|
-
function getPaginationClasses({
|
|
876
|
-
size = "md",
|
|
877
|
-
compact,
|
|
878
|
-
className
|
|
879
|
-
}) {
|
|
880
|
-
return cn(paginationBaseClass, paginationResponsiveClass, paginationSizeClasses[size], compact && paginationCompactClass, className);
|
|
881
|
-
}
|
|
882
|
-
function getPaginationItemClasses({
|
|
883
|
-
active,
|
|
884
|
-
disabled
|
|
885
|
-
}) {
|
|
886
|
-
return cn(paginationItemClass, active && paginationItemActiveClass, disabled && paginationItemDisabledClass);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
// src/components/pagination/Pagination.tsx
|
|
890
|
-
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
891
|
-
var defaultPageSizeOptions = [10, 20, 50, 100];
|
|
892
|
-
function toPositiveInteger(value, fallback) {
|
|
893
|
-
if (!Number.isFinite(value) || value === undefined) {
|
|
894
|
-
return fallback;
|
|
895
|
-
}
|
|
896
|
-
return Math.max(1, Math.floor(value));
|
|
897
|
-
}
|
|
898
|
-
function clampPage(page, pageCount) {
|
|
899
|
-
return Math.min(pageCount, Math.max(1, Math.floor(page)));
|
|
900
|
-
}
|
|
901
|
-
function getPageCount(total, pageSize) {
|
|
902
|
-
return Math.max(1, Math.ceil(Math.max(0, total) / pageSize));
|
|
903
|
-
}
|
|
904
|
-
function getRange(current, pageSize, total) {
|
|
905
|
-
if (total <= 0) {
|
|
906
|
-
return [0, 0];
|
|
907
|
-
}
|
|
908
|
-
const start = (current - 1) * pageSize + 1;
|
|
909
|
-
const end = Math.min(total, current * pageSize);
|
|
910
|
-
return [start, end];
|
|
1371
|
+
function inputTypeForPicker(picker) {
|
|
1372
|
+
if (picker === "month")
|
|
1373
|
+
return "month";
|
|
1374
|
+
if (picker === "week")
|
|
1375
|
+
return "week";
|
|
1376
|
+
if (picker === "time")
|
|
1377
|
+
return "time";
|
|
1378
|
+
return picker === "year" || picker === "quarter" ? "text" : "date";
|
|
911
1379
|
}
|
|
912
|
-
function
|
|
913
|
-
if (
|
|
914
|
-
return
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
if (
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
return sortedPages.reduce((tokens, page) => {
|
|
925
|
-
const previous = tokens[tokens.length - 1];
|
|
926
|
-
if (typeof previous === "number") {
|
|
927
|
-
const gap = page - previous;
|
|
928
|
-
if (gap === 2) {
|
|
929
|
-
tokens.push(previous + 1);
|
|
930
|
-
} else if (gap > 2) {
|
|
931
|
-
tokens.push("ellipsis");
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
tokens.push(page);
|
|
935
|
-
return tokens;
|
|
936
|
-
}, []);
|
|
1380
|
+
function placeholderForPicker(picker) {
|
|
1381
|
+
if (picker === "month")
|
|
1382
|
+
return "Select month";
|
|
1383
|
+
if (picker === "week")
|
|
1384
|
+
return "Select week";
|
|
1385
|
+
if (picker === "quarter")
|
|
1386
|
+
return "Select quarter";
|
|
1387
|
+
if (picker === "year")
|
|
1388
|
+
return "Select year";
|
|
1389
|
+
if (picker === "time")
|
|
1390
|
+
return "Select time";
|
|
1391
|
+
return "Select date";
|
|
937
1392
|
}
|
|
938
|
-
function
|
|
939
|
-
return
|
|
1393
|
+
function normalizeDateValue(value) {
|
|
1394
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
940
1395
|
}
|
|
941
|
-
var
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
onChange,
|
|
1396
|
+
var DatePickerRoot = forwardRef4(({
|
|
1397
|
+
allowClear,
|
|
1398
|
+
className,
|
|
1399
|
+
inputProps,
|
|
1400
|
+
defaultOpen,
|
|
1401
|
+
defaultValue,
|
|
948
1402
|
disabled,
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1403
|
+
disabledDate,
|
|
1404
|
+
onBlur,
|
|
1405
|
+
onChange,
|
|
1406
|
+
onFocus,
|
|
1407
|
+
onOpenChange,
|
|
1408
|
+
open,
|
|
1409
|
+
picker = "date",
|
|
1410
|
+
placeholder,
|
|
1411
|
+
presets,
|
|
1412
|
+
showNow,
|
|
953
1413
|
size = "md",
|
|
954
|
-
|
|
1414
|
+
status,
|
|
1415
|
+
value,
|
|
955
1416
|
...props
|
|
956
1417
|
}, ref) => {
|
|
957
|
-
const
|
|
958
|
-
const
|
|
959
|
-
const [
|
|
960
|
-
const
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
}
|
|
973
|
-
if (!isPageSizeControlled) {
|
|
974
|
-
setInternalPageSize(nextPageSize);
|
|
975
|
-
}
|
|
976
|
-
onChange?.(normalizedPage, nextPageSize);
|
|
977
|
-
}
|
|
978
|
-
function handlePageSizeChange(event) {
|
|
979
|
-
const nextPageSize = toPositiveInteger(Number(event.currentTarget.value), mergedPageSize);
|
|
980
|
-
const nextPage = clampPage(mergedCurrent, getPageCount(total, nextPageSize));
|
|
981
|
-
changePage(nextPage, nextPageSize);
|
|
982
|
-
}
|
|
983
|
-
function jumpToInputPage(value) {
|
|
984
|
-
const nextPage = Number(value);
|
|
985
|
-
if (!Number.isFinite(nextPage)) {
|
|
1418
|
+
const [calendarMode, setCalendarMode] = useState5("month");
|
|
1419
|
+
const isValueControlled = value !== undefined;
|
|
1420
|
+
const [innerValue, setInnerValue] = useState5(() => normalizeDateValue(defaultValue));
|
|
1421
|
+
const dropdown = usePickerDropdown({
|
|
1422
|
+
open,
|
|
1423
|
+
defaultOpen,
|
|
1424
|
+
disabled,
|
|
1425
|
+
onOpenChange,
|
|
1426
|
+
ref
|
|
1427
|
+
});
|
|
1428
|
+
const currentValue = isValueControlled ? normalizeDateValue(value) : innerValue;
|
|
1429
|
+
const { visible, setVisible } = dropdown;
|
|
1430
|
+
const inputType = inputTypeForPicker(picker);
|
|
1431
|
+
function emitChange(nextValue) {
|
|
1432
|
+
if (nextValue && disabledDate?.(nextValue)) {
|
|
986
1433
|
return;
|
|
987
1434
|
}
|
|
988
|
-
|
|
989
|
-
|
|
1435
|
+
if (!isValueControlled) {
|
|
1436
|
+
setInnerValue(nextValue);
|
|
1437
|
+
}
|
|
1438
|
+
onChange?.(nextValue, nextValue ?? "");
|
|
990
1439
|
}
|
|
991
|
-
function
|
|
992
|
-
if (
|
|
1440
|
+
function selectValue(nextValue) {
|
|
1441
|
+
if (disabledDate?.(nextValue))
|
|
993
1442
|
return;
|
|
994
|
-
|
|
995
|
-
|
|
1443
|
+
emitChange(nextValue);
|
|
1444
|
+
dropdown.closeAndFocus();
|
|
996
1445
|
}
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
return /* @__PURE__ */ jsxs5("nav", {
|
|
1446
|
+
const presetItems = useMemo4(() => presets ?? [], [presets]);
|
|
1447
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
1000
1448
|
...props,
|
|
1001
|
-
ref,
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1449
|
+
ref: dropdown.rootRef,
|
|
1450
|
+
onBlur: dropdown.onRootBlur,
|
|
1451
|
+
className: getDatePickerClasses({
|
|
1452
|
+
size,
|
|
1453
|
+
status,
|
|
1454
|
+
picker,
|
|
1455
|
+
open: visible,
|
|
1456
|
+
disabled,
|
|
1457
|
+
className
|
|
1458
|
+
}),
|
|
1459
|
+
children: [
|
|
1460
|
+
/* @__PURE__ */ jsx6("input", {
|
|
1461
|
+
...inputProps,
|
|
1462
|
+
ref: dropdown.inputRef,
|
|
1463
|
+
"aria-haspopup": "dialog",
|
|
1464
|
+
"aria-controls": visible ? dropdown.panelId : undefined,
|
|
1465
|
+
className: datePickerInputClass,
|
|
1466
|
+
disabled,
|
|
1467
|
+
type: inputType,
|
|
1468
|
+
value: currentValue ?? "",
|
|
1469
|
+
placeholder: placeholder ?? placeholderForPicker(picker),
|
|
1470
|
+
onFocus: (event) => {
|
|
1471
|
+
onFocus?.(event);
|
|
1472
|
+
dropdown.onInputFocus();
|
|
1473
|
+
},
|
|
1474
|
+
onBlur: (event) => {
|
|
1475
|
+
onBlur?.(event);
|
|
1476
|
+
},
|
|
1477
|
+
onClick: () => setVisible(true),
|
|
1478
|
+
onChange: (event) => emitChange(event.currentTarget.value || undefined)
|
|
1479
|
+
}),
|
|
1480
|
+
allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx6("button", {
|
|
1481
|
+
type: "button",
|
|
1482
|
+
className: datePickerClearClass,
|
|
1483
|
+
"aria-label": "Clear date",
|
|
1484
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
1485
|
+
onClick: () => emitChange(undefined),
|
|
1486
|
+
children: "x"
|
|
1487
|
+
}) : null,
|
|
1011
1488
|
/* @__PURE__ */ jsx6("button", {
|
|
1012
1489
|
type: "button",
|
|
1013
|
-
className:
|
|
1014
|
-
|
|
1015
|
-
"aria-
|
|
1016
|
-
|
|
1017
|
-
|
|
1490
|
+
className: datePickerIconClass,
|
|
1491
|
+
"aria-label": "Open date picker",
|
|
1492
|
+
"aria-haspopup": "dialog",
|
|
1493
|
+
"aria-expanded": visible,
|
|
1494
|
+
"aria-controls": visible ? dropdown.panelId : undefined,
|
|
1495
|
+
disabled,
|
|
1496
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
1497
|
+
onClick: () => setVisible(!visible),
|
|
1498
|
+
children: /* @__PURE__ */ jsxs5("svg", {
|
|
1499
|
+
"aria-hidden": "true",
|
|
1500
|
+
focusable: "false",
|
|
1501
|
+
width: "18",
|
|
1502
|
+
height: "18",
|
|
1503
|
+
viewBox: "0 0 24 24",
|
|
1504
|
+
fill: "none",
|
|
1505
|
+
stroke: "currentColor",
|
|
1506
|
+
strokeWidth: "1.75",
|
|
1507
|
+
strokeLinecap: "round",
|
|
1508
|
+
strokeLinejoin: "round",
|
|
1509
|
+
children: [
|
|
1510
|
+
/* @__PURE__ */ jsx6("rect", {
|
|
1511
|
+
x: "3",
|
|
1512
|
+
y: "5",
|
|
1513
|
+
width: "18",
|
|
1514
|
+
height: "16",
|
|
1515
|
+
rx: "2"
|
|
1516
|
+
}),
|
|
1517
|
+
/* @__PURE__ */ jsx6("path", {
|
|
1518
|
+
d: "M8 3v4M16 3v4M3 10h18"
|
|
1519
|
+
})
|
|
1520
|
+
]
|
|
1521
|
+
})
|
|
1018
1522
|
}),
|
|
1019
|
-
|
|
1020
|
-
|
|
1523
|
+
visible ? /* @__PURE__ */ jsxs5("div", {
|
|
1524
|
+
id: dropdown.panelId,
|
|
1525
|
+
role: "dialog",
|
|
1526
|
+
"aria-label": "Choose date",
|
|
1527
|
+
className: getDatePickerDropdownClasses({ open: visible }),
|
|
1021
1528
|
children: [
|
|
1022
|
-
/* @__PURE__ */ jsx6(
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1529
|
+
picker === "date" || picker === "month" ? /* @__PURE__ */ jsx6(Calendar, {
|
|
1530
|
+
fullscreen: false,
|
|
1531
|
+
value: currentValue,
|
|
1532
|
+
mode: picker === "month" ? "year" : calendarMode,
|
|
1533
|
+
onPanelChange: (_, mode) => {
|
|
1534
|
+
if (picker === "date")
|
|
1535
|
+
setCalendarMode(mode);
|
|
1536
|
+
},
|
|
1537
|
+
disabledDate: (date) => {
|
|
1538
|
+
if (!disabledDate)
|
|
1539
|
+
return false;
|
|
1540
|
+
if (picker === "month")
|
|
1541
|
+
return disabledDate(date.slice(0, 7));
|
|
1542
|
+
if (calendarMode === "year") {
|
|
1543
|
+
const [year, month] = date.split("-").map(Number);
|
|
1544
|
+
const days = new Date(year, month, 0).getDate();
|
|
1545
|
+
return Array.from({ length: days }, (_, index) => `${date.slice(0, 7)}-${String(index + 1).padStart(2, "0")}`).every((day) => disabledDate(day));
|
|
1034
1546
|
}
|
|
1547
|
+
return disabledDate(date);
|
|
1548
|
+
},
|
|
1549
|
+
onSelect: (date, info) => {
|
|
1550
|
+
if (picker === "date" && info.source === "month") {
|
|
1551
|
+
setCalendarMode("month");
|
|
1552
|
+
return;
|
|
1553
|
+
}
|
|
1554
|
+
selectValue(picker === "month" ? date.slice(0, 7) : date);
|
|
1035
1555
|
}
|
|
1556
|
+
}) : /* @__PURE__ */ jsx6("input", {
|
|
1557
|
+
type: inputType,
|
|
1558
|
+
"aria-label": placeholderForPicker(picker),
|
|
1559
|
+
value: currentValue ?? "",
|
|
1560
|
+
onChange: (event) => selectValue(event.currentTarget.value)
|
|
1036
1561
|
}),
|
|
1037
|
-
/* @__PURE__ */
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1562
|
+
presetItems.map((preset, index) => /* @__PURE__ */ jsx6("button", {
|
|
1563
|
+
type: "button",
|
|
1564
|
+
className: datePickerPresetClass,
|
|
1565
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
1566
|
+
disabled: Boolean(disabledDate?.(preset.value)),
|
|
1567
|
+
onClick: () => selectValue(preset.value),
|
|
1568
|
+
children: preset.label
|
|
1569
|
+
}, index)),
|
|
1570
|
+
showNow ? /* @__PURE__ */ jsx6("div", {
|
|
1571
|
+
className: datePickerFooterClass,
|
|
1572
|
+
children: /* @__PURE__ */ jsx6("button", {
|
|
1573
|
+
type: "button",
|
|
1574
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
1575
|
+
disabled: Boolean(disabledDate?.(todayValue(picker))),
|
|
1576
|
+
onClick: () => selectValue(todayValue(picker)),
|
|
1577
|
+
children: "Now"
|
|
1578
|
+
})
|
|
1579
|
+
}) : null
|
|
1044
1580
|
]
|
|
1045
|
-
}) :
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1581
|
+
}) : null
|
|
1582
|
+
]
|
|
1583
|
+
});
|
|
1584
|
+
});
|
|
1585
|
+
DatePickerRoot.displayName = "DatePicker";
|
|
1586
|
+
var RangePicker = forwardRef4(({
|
|
1587
|
+
allowClear,
|
|
1588
|
+
className,
|
|
1589
|
+
inputProps,
|
|
1590
|
+
defaultValue,
|
|
1591
|
+
disabled,
|
|
1592
|
+
disabledDate,
|
|
1593
|
+
onChange,
|
|
1594
|
+
picker = "date",
|
|
1595
|
+
placeholder,
|
|
1596
|
+
separator = "-",
|
|
1597
|
+
size = "md",
|
|
1598
|
+
status,
|
|
1599
|
+
value,
|
|
1600
|
+
...props
|
|
1601
|
+
}, ref) => {
|
|
1602
|
+
const isControlled = value !== undefined;
|
|
1603
|
+
const [innerValue, setInnerValue] = useState5(defaultValue ?? [undefined, undefined]);
|
|
1604
|
+
const currentValue = isControlled ? value : innerValue;
|
|
1605
|
+
const inputType = inputTypeForPicker(picker);
|
|
1606
|
+
function emitChange(nextValue) {
|
|
1607
|
+
if (nextValue.some((item) => item !== undefined && Boolean(disabledDate?.(item)))) {
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
if (!isControlled) {
|
|
1611
|
+
setInnerValue(nextValue);
|
|
1612
|
+
}
|
|
1613
|
+
onChange?.(nextValue, [nextValue[0] ?? "", nextValue[1] ?? ""]);
|
|
1614
|
+
}
|
|
1615
|
+
function updateIndex(index, nextItem) {
|
|
1616
|
+
emitChange(index === 0 ? [nextItem, currentValue?.[1]] : [currentValue?.[0], nextItem]);
|
|
1617
|
+
}
|
|
1618
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
1619
|
+
...props,
|
|
1620
|
+
ref,
|
|
1621
|
+
className: getDatePickerClasses({
|
|
1622
|
+
size,
|
|
1623
|
+
status,
|
|
1624
|
+
picker,
|
|
1625
|
+
disabled,
|
|
1626
|
+
range: true,
|
|
1627
|
+
className
|
|
1628
|
+
}),
|
|
1629
|
+
children: [
|
|
1630
|
+
/* @__PURE__ */ jsx6("input", {
|
|
1631
|
+
...inputProps,
|
|
1632
|
+
className: datePickerInputClass,
|
|
1054
1633
|
disabled,
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
}, pageToken)),
|
|
1060
|
-
/* @__PURE__ */ jsx6("button", {
|
|
1061
|
-
type: "button",
|
|
1062
|
-
className: paginationNextClass,
|
|
1063
|
-
disabled: nextDisabled,
|
|
1064
|
-
"aria-label": "Next page",
|
|
1065
|
-
onClick: () => changePage(mergedCurrent + 1),
|
|
1066
|
-
children: "Next"
|
|
1634
|
+
type: inputType,
|
|
1635
|
+
value: currentValue?.[0] ?? "",
|
|
1636
|
+
placeholder: Array.isArray(placeholder) ? placeholder[0] : "Start date",
|
|
1637
|
+
onChange: (event) => updateIndex(0, event.currentTarget.value || undefined)
|
|
1067
1638
|
}),
|
|
1068
|
-
|
|
1069
|
-
className:
|
|
1070
|
-
children:
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
type: "number",
|
|
1089
|
-
min: 1,
|
|
1090
|
-
max: pageCount,
|
|
1091
|
-
value: quickJumpValue,
|
|
1092
|
-
disabled,
|
|
1093
|
-
onChange: (event) => setQuickJumpValue(event.currentTarget.value),
|
|
1094
|
-
onKeyDown: handleQuickJumpKeyDown
|
|
1095
|
-
})
|
|
1639
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1640
|
+
className: datePickerSeparatorClass,
|
|
1641
|
+
children: separator
|
|
1642
|
+
}),
|
|
1643
|
+
/* @__PURE__ */ jsx6("input", {
|
|
1644
|
+
...inputProps,
|
|
1645
|
+
id: inputProps?.id ? `${inputProps.id}-end` : undefined,
|
|
1646
|
+
className: datePickerInputClass,
|
|
1647
|
+
disabled,
|
|
1648
|
+
type: inputType,
|
|
1649
|
+
value: currentValue?.[1] ?? "",
|
|
1650
|
+
placeholder: Array.isArray(placeholder) ? placeholder[1] : "End date",
|
|
1651
|
+
onChange: (event) => updateIndex(1, event.currentTarget.value || undefined)
|
|
1652
|
+
}),
|
|
1653
|
+
allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */ jsx6("button", {
|
|
1654
|
+
type: "button",
|
|
1655
|
+
className: datePickerClearClass,
|
|
1656
|
+
"aria-label": "Clear date range",
|
|
1657
|
+
onClick: () => emitChange([undefined, undefined]),
|
|
1658
|
+
children: "x"
|
|
1096
1659
|
}) : null
|
|
1097
1660
|
]
|
|
1098
1661
|
});
|
|
1099
1662
|
});
|
|
1100
|
-
|
|
1101
|
-
|
|
1663
|
+
RangePicker.displayName = "DatePicker.RangePicker";
|
|
1664
|
+
function withPicker(picker, displayName) {
|
|
1665
|
+
const Picker = forwardRef4((props, ref) => /* @__PURE__ */ jsx6(DatePickerRoot, {
|
|
1666
|
+
...props,
|
|
1667
|
+
ref,
|
|
1668
|
+
picker
|
|
1669
|
+
}));
|
|
1670
|
+
Picker.displayName = displayName;
|
|
1671
|
+
return Picker;
|
|
1672
|
+
}
|
|
1673
|
+
var DatePicker = Object.assign(DatePickerRoot, {
|
|
1674
|
+
RangePicker,
|
|
1675
|
+
WeekPicker: withPicker("week", "DatePicker.WeekPicker"),
|
|
1676
|
+
MonthPicker: withPicker("month", "DatePicker.MonthPicker"),
|
|
1677
|
+
QuarterPicker: withPicker("quarter", "DatePicker.QuarterPicker"),
|
|
1678
|
+
YearPicker: withPicker("year", "DatePicker.YearPicker")
|
|
1679
|
+
});
|
|
1680
|
+
// src/components/input/Input.tsx
|
|
1102
1681
|
import {
|
|
1103
|
-
forwardRef as
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
useState as useState4
|
|
1682
|
+
forwardRef as forwardRef5,
|
|
1683
|
+
useImperativeHandle as useImperativeHandle2,
|
|
1684
|
+
useRef as useRef3,
|
|
1685
|
+
useState as useState6
|
|
1108
1686
|
} from "react";
|
|
1109
1687
|
|
|
1110
|
-
// src/classes/
|
|
1111
|
-
var
|
|
1112
|
-
var
|
|
1113
|
-
var
|
|
1114
|
-
var
|
|
1115
|
-
var
|
|
1116
|
-
var
|
|
1117
|
-
var
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
loading,
|
|
1131
|
-
className
|
|
1132
|
-
}) {
|
|
1133
|
-
return cn(dmPaginationRefreshClass, loading && dmPaginationRefreshLoadingClass, className);
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
// src/components/dm-pagination/DmPagination.tsx
|
|
1137
|
-
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1138
|
-
var defaultLocale = {
|
|
1139
|
-
refresh: "Refresh",
|
|
1140
|
-
showTotal: (total, range) => `${range[0]}-${range[1]} of ${total}`,
|
|
1141
|
-
showTotalSimple: (total, range) => `${range[0]}-${range[1]} / ${total}`,
|
|
1142
|
-
selected: (selectedTotal) => `, ${selectedTotal} selected`
|
|
1143
|
-
};
|
|
1144
|
-
function getResponsiveSimple({
|
|
1145
|
-
width,
|
|
1146
|
-
total,
|
|
1147
|
-
showRefresh,
|
|
1148
|
-
showSizeChanger
|
|
1149
|
-
}) {
|
|
1150
|
-
let reservedWidth = 0;
|
|
1151
|
-
if (!showRefresh)
|
|
1152
|
-
reservedWidth += 100;
|
|
1153
|
-
if (!showSizeChanger)
|
|
1154
|
-
reservedWidth += 100;
|
|
1155
|
-
if (width < 900 - reservedWidth)
|
|
1156
|
-
return total >= 100;
|
|
1157
|
-
if (width < 1100 - reservedWidth)
|
|
1158
|
-
return total >= 1000;
|
|
1159
|
-
if (width < 1220 - reservedWidth)
|
|
1160
|
-
return total >= 99999;
|
|
1161
|
-
if (width < 1300 - reservedWidth)
|
|
1162
|
-
return total >= 999999;
|
|
1163
|
-
if (width < 1450 - reservedWidth)
|
|
1164
|
-
return total >= 9999999;
|
|
1165
|
-
return false;
|
|
1166
|
-
}
|
|
1167
|
-
function useElementWidth() {
|
|
1168
|
-
const ref = useRef(null);
|
|
1169
|
-
const [width, setWidth] = useState4(1000);
|
|
1170
|
-
useEffect(() => {
|
|
1171
|
-
const element = ref.current;
|
|
1172
|
-
if (!element || typeof ResizeObserver === "undefined")
|
|
1173
|
-
return;
|
|
1174
|
-
const observer = new ResizeObserver(([entry]) => {
|
|
1175
|
-
setWidth(entry?.contentRect.width || element.getBoundingClientRect().width);
|
|
1176
|
-
});
|
|
1177
|
-
observer.observe(element);
|
|
1178
|
-
return () => observer.disconnect();
|
|
1179
|
-
}, []);
|
|
1180
|
-
return [ref, width];
|
|
1181
|
-
}
|
|
1182
|
-
function renderSelected(selectedTotal, locale) {
|
|
1183
|
-
if (!selectedTotal)
|
|
1184
|
-
return null;
|
|
1185
|
-
return /* @__PURE__ */ jsx7("span", {
|
|
1186
|
-
className: dmPaginationSelectedClass,
|
|
1187
|
-
children: locale.selected(selectedTotal)
|
|
1188
|
-
});
|
|
1189
|
-
}
|
|
1190
|
-
var DmPagination = forwardRef4(({
|
|
1191
|
-
selectedTotal = 0,
|
|
1192
|
-
loading = false,
|
|
1193
|
-
total = 0,
|
|
1194
|
-
showRefresh = true,
|
|
1195
|
-
showPagination = true,
|
|
1196
|
-
wrapperStyle,
|
|
1197
|
-
className,
|
|
1198
|
-
align = "right",
|
|
1199
|
-
showTotalFullMessage = false,
|
|
1200
|
-
showSizeChanger = true,
|
|
1201
|
-
responsiveSimple = true,
|
|
1202
|
-
refresh,
|
|
1203
|
-
simple,
|
|
1204
|
-
showQuickJumper,
|
|
1205
|
-
showTotal,
|
|
1206
|
-
locale,
|
|
1207
|
-
...props
|
|
1208
|
-
}, ref) => {
|
|
1209
|
-
const [measureRef, width] = useElementWidth();
|
|
1210
|
-
const mergedLocale = useMemo4(() => ({ ...defaultLocale, ...locale }), [locale]);
|
|
1211
|
-
const isRefreshVisible = showRefresh && Boolean(refresh);
|
|
1212
|
-
const shouldRender = showPagination || isRefreshVisible;
|
|
1213
|
-
const responsiveSimpleMode = responsiveSimple ? getResponsiveSimple({
|
|
1214
|
-
width,
|
|
1215
|
-
total,
|
|
1216
|
-
showRefresh,
|
|
1217
|
-
showSizeChanger
|
|
1218
|
-
}) : false;
|
|
1219
|
-
const mergedSimple = simple ?? responsiveSimpleMode;
|
|
1220
|
-
const mergedShowQuickJumper = showQuickJumper ?? !mergedSimple;
|
|
1221
|
-
const totalRenderer = useMemo4(() => {
|
|
1222
|
-
if (showTotal)
|
|
1223
|
-
return showTotal;
|
|
1224
|
-
return (nextTotal, range) => {
|
|
1225
|
-
if (Number(nextTotal) === 0)
|
|
1226
|
-
return "";
|
|
1227
|
-
const selected = renderSelected(selectedTotal, mergedLocale);
|
|
1228
|
-
const message = mergedSimple && !showTotalFullMessage ? mergedLocale.showTotalSimple(nextTotal, range, selectedTotal) : mergedLocale.showTotal(nextTotal, range, selectedTotal);
|
|
1229
|
-
return /* @__PURE__ */ jsxs6("span", {
|
|
1230
|
-
title: `${mergedLocale.showTotal(nextTotal, range, selectedTotal)}${selectedTotal ? mergedLocale.selected(selectedTotal) : ""}`,
|
|
1231
|
-
children: [
|
|
1232
|
-
message,
|
|
1233
|
-
selected
|
|
1234
|
-
]
|
|
1235
|
-
});
|
|
1236
|
-
};
|
|
1237
|
-
}, [
|
|
1238
|
-
mergedLocale,
|
|
1239
|
-
mergedSimple,
|
|
1240
|
-
selectedTotal,
|
|
1241
|
-
showTotal,
|
|
1242
|
-
showTotalFullMessage
|
|
1243
|
-
]);
|
|
1244
|
-
if (!shouldRender)
|
|
1245
|
-
return null;
|
|
1246
|
-
return /* @__PURE__ */ jsxs6("div", {
|
|
1247
|
-
ref: (element) => {
|
|
1248
|
-
measureRef.current = element;
|
|
1249
|
-
if (typeof ref === "function") {
|
|
1250
|
-
ref(element);
|
|
1251
|
-
} else if (ref) {
|
|
1252
|
-
ref.current = element;
|
|
1253
|
-
}
|
|
1254
|
-
},
|
|
1255
|
-
className: getDmPaginationClasses({ align, className }),
|
|
1256
|
-
style: wrapperStyle,
|
|
1257
|
-
children: [
|
|
1258
|
-
showPagination ? /* @__PURE__ */ jsx7("div", {
|
|
1259
|
-
className: dmPaginationPagerClass,
|
|
1260
|
-
children: /* @__PURE__ */ jsx7(Pagination, {
|
|
1261
|
-
...props,
|
|
1262
|
-
total,
|
|
1263
|
-
simple: mergedSimple,
|
|
1264
|
-
showQuickJumper: mergedShowQuickJumper,
|
|
1265
|
-
showSizeChanger,
|
|
1266
|
-
showTotal: totalRenderer
|
|
1267
|
-
})
|
|
1268
|
-
}) : null,
|
|
1269
|
-
isRefreshVisible ? /* @__PURE__ */ jsxs6("button", {
|
|
1270
|
-
type: "button",
|
|
1271
|
-
className: getDmPaginationRefreshClasses({ loading }),
|
|
1272
|
-
disabled: loading || props.disabled,
|
|
1273
|
-
"aria-busy": loading || undefined,
|
|
1274
|
-
onClick: refresh,
|
|
1275
|
-
children: [
|
|
1276
|
-
/* @__PURE__ */ jsx7("span", {
|
|
1277
|
-
"aria-hidden": "true",
|
|
1278
|
-
children: "Reload"
|
|
1279
|
-
}),
|
|
1280
|
-
/* @__PURE__ */ jsx7("span", {
|
|
1281
|
-
children: mergedLocale.refresh
|
|
1282
|
-
})
|
|
1283
|
-
]
|
|
1284
|
-
}) : null
|
|
1285
|
-
]
|
|
1286
|
-
});
|
|
1287
|
-
});
|
|
1288
|
-
DmPagination.displayName = "DmPagination";
|
|
1289
|
-
// src/components/input/Input.tsx
|
|
1290
|
-
import {
|
|
1291
|
-
forwardRef as forwardRef5,
|
|
1292
|
-
useImperativeHandle,
|
|
1293
|
-
useRef as useRef2,
|
|
1294
|
-
useState as useState5
|
|
1295
|
-
} from "react";
|
|
1296
|
-
|
|
1297
|
-
// src/classes/input.ts
|
|
1298
|
-
var inputBaseClass = "input";
|
|
1299
|
-
var inputWrapperClass = "input-wrapper";
|
|
1300
|
-
var inputAffixWrapperClass = "input-affix-wrapper";
|
|
1301
|
-
var inputPrefixClass = "input-prefix";
|
|
1302
|
-
var inputSuffixClass = "input-suffix";
|
|
1303
|
-
var inputClearClass = "input-clear";
|
|
1304
|
-
var inputSearchClass = "input-search";
|
|
1305
|
-
var inputSearchButtonClass = "input-search-button";
|
|
1306
|
-
var inputPasswordClass = "input-password";
|
|
1307
|
-
var inputPasswordToggleClass = "input-password-toggle";
|
|
1308
|
-
var inputGroupClass = "input-group";
|
|
1309
|
-
var textAreaBaseClass = "textarea";
|
|
1310
|
-
var textAreaWrapperClass = "textarea-wrapper";
|
|
1311
|
-
var textAreaCountClass = "textarea-counter";
|
|
1312
|
-
var textAreaCountExceededClass = "textarea-counter-exceeded";
|
|
1313
|
-
var textAreaAutoSizeClass = "textarea-auto-resize";
|
|
1314
|
-
var inputVariantClasses = {
|
|
1315
|
-
filled: "input-filled",
|
|
1316
|
-
outlined: "input-outlined"
|
|
1688
|
+
// src/classes/input.ts
|
|
1689
|
+
var inputBaseClass = "input";
|
|
1690
|
+
var inputWrapperClass = "input-wrapper";
|
|
1691
|
+
var inputAffixWrapperClass = "input-affix-wrapper";
|
|
1692
|
+
var inputPrefixClass = "input-prefix";
|
|
1693
|
+
var inputSuffixClass = "input-suffix";
|
|
1694
|
+
var inputClearClass = "input-clear";
|
|
1695
|
+
var inputSearchClass = "input-search";
|
|
1696
|
+
var inputSearchButtonClass = "input-search-button";
|
|
1697
|
+
var inputPasswordClass = "input-password";
|
|
1698
|
+
var inputPasswordToggleClass = "input-password-toggle";
|
|
1699
|
+
var inputGroupClass = "input-group";
|
|
1700
|
+
var textAreaBaseClass = "textarea";
|
|
1701
|
+
var textAreaWrapperClass = "textarea-wrapper";
|
|
1702
|
+
var textAreaCountClass = "textarea-counter";
|
|
1703
|
+
var textAreaCountExceededClass = "textarea-counter-exceeded";
|
|
1704
|
+
var textAreaAutoSizeClass = "textarea-auto-resize";
|
|
1705
|
+
var inputVariantClasses = {
|
|
1706
|
+
filled: "input-filled",
|
|
1707
|
+
outlined: "input-outlined"
|
|
1317
1708
|
};
|
|
1318
1709
|
var inputSizeClasses = {
|
|
1319
1710
|
sm: "input-sm",
|
|
@@ -1380,7 +1771,7 @@ function getTextAreaCountClasses({ exceeded }) {
|
|
|
1380
1771
|
}
|
|
1381
1772
|
|
|
1382
1773
|
// src/components/input/Input.tsx
|
|
1383
|
-
import { jsx as
|
|
1774
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1384
1775
|
function toTextValue(value) {
|
|
1385
1776
|
if (Array.isArray(value)) {
|
|
1386
1777
|
return value.join(",");
|
|
@@ -1402,12 +1793,12 @@ var InputRoot = forwardRef5(({
|
|
|
1402
1793
|
variant = "outlined",
|
|
1403
1794
|
...props
|
|
1404
1795
|
}, ref) => {
|
|
1405
|
-
const inputRef =
|
|
1406
|
-
const [internalValue, setInternalValue] =
|
|
1796
|
+
const inputRef = useRef3(null);
|
|
1797
|
+
const [internalValue, setInternalValue] = useState6(() => toTextValue(defaultValue));
|
|
1407
1798
|
const isControlled = value !== undefined;
|
|
1408
1799
|
const currentValue = isControlled ? toTextValue(value) : internalValue;
|
|
1409
1800
|
const hasAffix = prefix != null || suffix != null || allowClear;
|
|
1410
|
-
|
|
1801
|
+
useImperativeHandle2(ref, () => inputRef.current);
|
|
1411
1802
|
function handleChange(event) {
|
|
1412
1803
|
if (!isControlled) {
|
|
1413
1804
|
setInternalValue(event.currentTarget.value);
|
|
@@ -1430,7 +1821,7 @@ var InputRoot = forwardRef5(({
|
|
|
1430
1821
|
});
|
|
1431
1822
|
input.focus();
|
|
1432
1823
|
}
|
|
1433
|
-
const control = /* @__PURE__ */
|
|
1824
|
+
const control = /* @__PURE__ */ jsx7("input", {
|
|
1434
1825
|
...props,
|
|
1435
1826
|
ref: inputRef,
|
|
1436
1827
|
type,
|
|
@@ -1443,22 +1834,22 @@ var InputRoot = forwardRef5(({
|
|
|
1443
1834
|
return control;
|
|
1444
1835
|
}
|
|
1445
1836
|
const showClear = allowClear && !disabled && currentValue.length > 0;
|
|
1446
|
-
return /* @__PURE__ */
|
|
1837
|
+
return /* @__PURE__ */ jsxs6("span", {
|
|
1447
1838
|
className: getInputWrapperClasses({ affixed: hasAffix }),
|
|
1448
1839
|
children: [
|
|
1449
|
-
prefix != null ? /* @__PURE__ */
|
|
1840
|
+
prefix != null ? /* @__PURE__ */ jsx7("span", {
|
|
1450
1841
|
className: inputPrefixClass,
|
|
1451
1842
|
children: prefix
|
|
1452
1843
|
}) : null,
|
|
1453
1844
|
control,
|
|
1454
|
-
showClear ? /* @__PURE__ */
|
|
1845
|
+
showClear ? /* @__PURE__ */ jsx7("button", {
|
|
1455
1846
|
type: "button",
|
|
1456
1847
|
className: inputClearClass,
|
|
1457
1848
|
"aria-label": "Clear input",
|
|
1458
1849
|
onClick: handleClear,
|
|
1459
1850
|
children: "x"
|
|
1460
1851
|
}) : null,
|
|
1461
|
-
suffix != null ? /* @__PURE__ */
|
|
1852
|
+
suffix != null ? /* @__PURE__ */ jsx7("span", {
|
|
1462
1853
|
className: inputSuffixClass,
|
|
1463
1854
|
children: suffix
|
|
1464
1855
|
}) : null
|
|
@@ -1475,8 +1866,8 @@ var Search = forwardRef5(({
|
|
|
1475
1866
|
onSearch,
|
|
1476
1867
|
...props
|
|
1477
1868
|
}, ref) => {
|
|
1478
|
-
const inputRef =
|
|
1479
|
-
|
|
1869
|
+
const inputRef = useRef3(null);
|
|
1870
|
+
useImperativeHandle2(ref, () => inputRef.current);
|
|
1480
1871
|
function emitSearch(event) {
|
|
1481
1872
|
onSearch?.(inputRef.current?.value ?? "", event);
|
|
1482
1873
|
}
|
|
@@ -1487,16 +1878,16 @@ var Search = forwardRef5(({
|
|
|
1487
1878
|
}
|
|
1488
1879
|
}
|
|
1489
1880
|
const buttonContent = enterButton === true ? "Search" : enterButton ?? "Search";
|
|
1490
|
-
return /* @__PURE__ */
|
|
1881
|
+
return /* @__PURE__ */ jsxs6("span", {
|
|
1491
1882
|
className: getSearchWrapperClasses({ className }),
|
|
1492
1883
|
children: [
|
|
1493
|
-
/* @__PURE__ */
|
|
1884
|
+
/* @__PURE__ */ jsx7(InputRoot, {
|
|
1494
1885
|
...props,
|
|
1495
1886
|
ref: inputRef,
|
|
1496
1887
|
disabled,
|
|
1497
1888
|
onKeyDown: handleKeyDown
|
|
1498
1889
|
}),
|
|
1499
|
-
enterButton || loading ? /* @__PURE__ */
|
|
1890
|
+
enterButton || loading ? /* @__PURE__ */ jsx7("button", {
|
|
1500
1891
|
type: "button",
|
|
1501
1892
|
className: inputSearchButtonClass,
|
|
1502
1893
|
disabled: disabled || loading,
|
|
@@ -1509,9 +1900,9 @@ var Search = forwardRef5(({
|
|
|
1509
1900
|
});
|
|
1510
1901
|
Search.displayName = "Input.Search";
|
|
1511
1902
|
var Password = forwardRef5(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
|
|
1512
|
-
const [visible, setVisible] =
|
|
1903
|
+
const [visible, setVisible] = useState6(false);
|
|
1513
1904
|
const type = visible ? "text" : "password";
|
|
1514
|
-
const toggle = visibilityToggle ? /* @__PURE__ */
|
|
1905
|
+
const toggle = visibilityToggle ? /* @__PURE__ */ jsx7("button", {
|
|
1515
1906
|
type: "button",
|
|
1516
1907
|
className: inputPasswordToggleClass,
|
|
1517
1908
|
disabled,
|
|
@@ -1521,9 +1912,9 @@ var Password = forwardRef5(({ className, disabled, visibilityToggle = true, ...p
|
|
|
1521
1912
|
},
|
|
1522
1913
|
children: visible ? "Hide" : "Show"
|
|
1523
1914
|
}) : undefined;
|
|
1524
|
-
return /* @__PURE__ */
|
|
1915
|
+
return /* @__PURE__ */ jsx7("span", {
|
|
1525
1916
|
className: getPasswordWrapperClasses({ className }),
|
|
1526
|
-
children: /* @__PURE__ */
|
|
1917
|
+
children: /* @__PURE__ */ jsx7(InputRoot, {
|
|
1527
1918
|
...props,
|
|
1528
1919
|
ref,
|
|
1529
1920
|
disabled,
|
|
@@ -1547,7 +1938,7 @@ var TextArea = forwardRef5(({
|
|
|
1547
1938
|
variant = "outlined",
|
|
1548
1939
|
...props
|
|
1549
1940
|
}, ref) => {
|
|
1550
|
-
const [internalValue, setInternalValue] =
|
|
1941
|
+
const [internalValue, setInternalValue] = useState6(() => toTextValue(defaultValue));
|
|
1551
1942
|
const isControlled = value !== undefined;
|
|
1552
1943
|
const currentValue = isControlled ? toTextValue(value) : internalValue;
|
|
1553
1944
|
const count = currentValue.length;
|
|
@@ -1558,7 +1949,7 @@ var TextArea = forwardRef5(({
|
|
|
1558
1949
|
}
|
|
1559
1950
|
onChange?.(event);
|
|
1560
1951
|
}
|
|
1561
|
-
const control = /* @__PURE__ */
|
|
1952
|
+
const control = /* @__PURE__ */ jsx7("textarea", {
|
|
1562
1953
|
...props,
|
|
1563
1954
|
ref,
|
|
1564
1955
|
className: getTextAreaClasses({
|
|
@@ -1576,11 +1967,11 @@ var TextArea = forwardRef5(({
|
|
|
1576
1967
|
if (!showCount) {
|
|
1577
1968
|
return control;
|
|
1578
1969
|
}
|
|
1579
|
-
return /* @__PURE__ */
|
|
1970
|
+
return /* @__PURE__ */ jsxs6("span", {
|
|
1580
1971
|
className: textAreaWrapperClass,
|
|
1581
1972
|
children: [
|
|
1582
1973
|
control,
|
|
1583
|
-
/* @__PURE__ */
|
|
1974
|
+
/* @__PURE__ */ jsxs6("span", {
|
|
1584
1975
|
className: getTextAreaCountClasses({ exceeded }),
|
|
1585
1976
|
children: [
|
|
1586
1977
|
count,
|
|
@@ -1591,7 +1982,7 @@ var TextArea = forwardRef5(({
|
|
|
1591
1982
|
});
|
|
1592
1983
|
});
|
|
1593
1984
|
TextArea.displayName = "Input.TextArea";
|
|
1594
|
-
var Group = forwardRef5(({ className, children, ...props }, ref) => /* @__PURE__ */
|
|
1985
|
+
var Group = forwardRef5(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
|
|
1595
1986
|
...props,
|
|
1596
1987
|
ref,
|
|
1597
1988
|
className: cn(inputGroupClass, className),
|
|
@@ -1605,7 +1996,7 @@ var Input = Object.assign(InputRoot, {
|
|
|
1605
1996
|
Group
|
|
1606
1997
|
});
|
|
1607
1998
|
// src/components/select/Select.tsx
|
|
1608
|
-
import React7, { forwardRef as forwardRef6, useMemo as useMemo5, useState as
|
|
1999
|
+
import React7, { forwardRef as forwardRef6, useMemo as useMemo5, useState as useState7 } from "react";
|
|
1609
2000
|
|
|
1610
2001
|
// src/classes/select.ts
|
|
1611
2002
|
var selectContainerClass = "select-container";
|
|
@@ -1661,7 +2052,7 @@ function getSelectOptionClasses({
|
|
|
1661
2052
|
}
|
|
1662
2053
|
|
|
1663
2054
|
// src/components/select/Select.tsx
|
|
1664
|
-
import { jsx as
|
|
2055
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1665
2056
|
function isGroup(option) {
|
|
1666
2057
|
return "options" in option;
|
|
1667
2058
|
}
|
|
@@ -1737,13 +2128,13 @@ function filterOptions(options, searchValue, filterOption) {
|
|
|
1737
2128
|
function renderValue(option) {
|
|
1738
2129
|
return option ? optionLabel(option) : null;
|
|
1739
2130
|
}
|
|
1740
|
-
var Option = forwardRef6(({ children, ...props }, ref) => /* @__PURE__ */
|
|
2131
|
+
var Option = forwardRef6(({ children, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
|
|
1741
2132
|
...props,
|
|
1742
2133
|
ref,
|
|
1743
2134
|
children
|
|
1744
2135
|
}));
|
|
1745
2136
|
Option.displayName = "Select.Option";
|
|
1746
|
-
var OptGroup = forwardRef6(({ children, ...props }, ref) => /* @__PURE__ */
|
|
2137
|
+
var OptGroup = forwardRef6(({ children, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
|
|
1747
2138
|
...props,
|
|
1748
2139
|
ref,
|
|
1749
2140
|
children
|
|
@@ -1770,9 +2161,9 @@ var SelectRoot = forwardRef6(({
|
|
|
1770
2161
|
const multiple = mode === "multiple" || mode === "tags";
|
|
1771
2162
|
const sourceOptions = useMemo5(() => options ?? optionsFromChildren(children), [children, options]);
|
|
1772
2163
|
const flatOptions = useMemo5(() => flattenOptions(sourceOptions), [sourceOptions]);
|
|
1773
|
-
const [open, setOpen] =
|
|
1774
|
-
const [searchValue, setSearchValue] =
|
|
1775
|
-
const [internalValue, setInternalValue] =
|
|
2164
|
+
const [open, setOpen] = useState7(false);
|
|
2165
|
+
const [searchValue, setSearchValue] = useState7("");
|
|
2166
|
+
const [internalValue, setInternalValue] = useState7(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
|
|
1776
2167
|
const controlled = value !== undefined;
|
|
1777
2168
|
const currentValue = controlled ? value : internalValue;
|
|
1778
2169
|
const selectedValues = multiple ? normalizeMultiValue(currentValue) : normalizeSingleValue(currentValue) === undefined ? [] : [normalizeSingleValue(currentValue)];
|
|
@@ -1829,7 +2220,7 @@ var SelectRoot = forwardRef6(({
|
|
|
1829
2220
|
}
|
|
1830
2221
|
function renderOption(option) {
|
|
1831
2222
|
const selected = selectedKeys.has(valueKey(option.value));
|
|
1832
|
-
return /* @__PURE__ */
|
|
2223
|
+
return /* @__PURE__ */ jsx8("button", {
|
|
1833
2224
|
type: "button",
|
|
1834
2225
|
role: "option",
|
|
1835
2226
|
"aria-selected": selected,
|
|
@@ -1848,11 +2239,11 @@ var SelectRoot = forwardRef6(({
|
|
|
1848
2239
|
if (!isGroup(option)) {
|
|
1849
2240
|
return renderOption(option);
|
|
1850
2241
|
}
|
|
1851
|
-
return /* @__PURE__ */
|
|
2242
|
+
return /* @__PURE__ */ jsxs7("div", {
|
|
1852
2243
|
className: cn(selectGroupClass, option.className),
|
|
1853
2244
|
role: "group",
|
|
1854
2245
|
children: [
|
|
1855
|
-
/* @__PURE__ */
|
|
2246
|
+
/* @__PURE__ */ jsx8("div", {
|
|
1856
2247
|
className: selectGroupLabelClass,
|
|
1857
2248
|
children: option.label
|
|
1858
2249
|
}),
|
|
@@ -1861,11 +2252,11 @@ var SelectRoot = forwardRef6(({
|
|
|
1861
2252
|
}, `group-${index}`);
|
|
1862
2253
|
});
|
|
1863
2254
|
}
|
|
1864
|
-
const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */
|
|
2255
|
+
const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx8("span", {
|
|
1865
2256
|
className: selectTagClass,
|
|
1866
2257
|
children: renderValue(option)
|
|
1867
2258
|
}, valueKey(option.value))) : renderValue(selectedOptions[0]);
|
|
1868
|
-
return /* @__PURE__ */
|
|
2259
|
+
return /* @__PURE__ */ jsxs7("div", {
|
|
1869
2260
|
...props,
|
|
1870
2261
|
ref,
|
|
1871
2262
|
className: getSelectContainerClasses({
|
|
@@ -1876,7 +2267,7 @@ var SelectRoot = forwardRef6(({
|
|
|
1876
2267
|
className
|
|
1877
2268
|
}),
|
|
1878
2269
|
children: [
|
|
1879
|
-
/* @__PURE__ */
|
|
2270
|
+
/* @__PURE__ */ jsxs7("button", {
|
|
1880
2271
|
type: "button",
|
|
1881
2272
|
className: getSelectClasses({ size, status, disabled }),
|
|
1882
2273
|
disabled: disabled || loading,
|
|
@@ -1884,33 +2275,33 @@ var SelectRoot = forwardRef6(({
|
|
|
1884
2275
|
"aria-expanded": open,
|
|
1885
2276
|
onClick: () => setOpen((current) => !current),
|
|
1886
2277
|
children: [
|
|
1887
|
-
/* @__PURE__ */
|
|
2278
|
+
/* @__PURE__ */ jsx8("span", {
|
|
1888
2279
|
className: selectSelectionClass,
|
|
1889
|
-
children: hasValue ? selection : /* @__PURE__ */
|
|
2280
|
+
children: hasValue ? selection : /* @__PURE__ */ jsx8("span", {
|
|
1890
2281
|
className: selectPlaceholderClass,
|
|
1891
2282
|
children: placeholder
|
|
1892
2283
|
})
|
|
1893
2284
|
}),
|
|
1894
|
-
/* @__PURE__ */
|
|
2285
|
+
/* @__PURE__ */ jsx8("span", {
|
|
1895
2286
|
className: selectIconClass,
|
|
1896
2287
|
"aria-hidden": "true",
|
|
1897
2288
|
children: "v"
|
|
1898
2289
|
})
|
|
1899
2290
|
]
|
|
1900
2291
|
}),
|
|
1901
|
-
allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */
|
|
2292
|
+
allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx8("button", {
|
|
1902
2293
|
type: "button",
|
|
1903
2294
|
className: selectClearClass,
|
|
1904
2295
|
"aria-label": "Clear selection",
|
|
1905
2296
|
onClick: clearValue,
|
|
1906
2297
|
children: "x"
|
|
1907
2298
|
}) : null,
|
|
1908
|
-
open ? /* @__PURE__ */
|
|
2299
|
+
open ? /* @__PURE__ */ jsxs7("div", {
|
|
1909
2300
|
className: selectDropdownClass,
|
|
1910
2301
|
role: "listbox",
|
|
1911
2302
|
"aria-multiselectable": multiple || undefined,
|
|
1912
2303
|
children: [
|
|
1913
|
-
searchable ? /* @__PURE__ */
|
|
2304
|
+
searchable ? /* @__PURE__ */ jsx8("input", {
|
|
1914
2305
|
className: selectSearchClass,
|
|
1915
2306
|
value: searchValue,
|
|
1916
2307
|
placeholder: typeof placeholder === "string" ? placeholder : undefined,
|
|
@@ -1922,7 +2313,7 @@ var SelectRoot = forwardRef6(({
|
|
|
1922
2313
|
}
|
|
1923
2314
|
}
|
|
1924
2315
|
}) : null,
|
|
1925
|
-
visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */
|
|
2316
|
+
visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx8("div", {
|
|
1926
2317
|
className: selectEmptyClass,
|
|
1927
2318
|
children: "No data"
|
|
1928
2319
|
})
|
|
@@ -1936,32 +2327,7 @@ var Select = SelectRoot;
|
|
|
1936
2327
|
Select.Option = Option;
|
|
1937
2328
|
Select.OptGroup = OptGroup;
|
|
1938
2329
|
// src/components/dm-search/DmSearch.tsx
|
|
1939
|
-
import {
|
|
1940
|
-
forwardRef as forwardRef7,
|
|
1941
|
-
useEffect as useEffect2,
|
|
1942
|
-
useImperativeHandle as useImperativeHandle2,
|
|
1943
|
-
useMemo as useMemo6,
|
|
1944
|
-
useState as useState7
|
|
1945
|
-
} from "react";
|
|
1946
|
-
|
|
1947
|
-
// src/classes/dm-search.ts
|
|
1948
|
-
var dmSearchBaseClass = "dm-search";
|
|
1949
|
-
var dmSearchCompactClass = "dm-search-compact";
|
|
1950
|
-
var dmSearchCollapsedClass = "dm-search-collapsed";
|
|
1951
|
-
var dmSearchFieldsClass = "dm-search-fields";
|
|
1952
|
-
var dmSearchFieldClass = "dm-search-field";
|
|
1953
|
-
var dmSearchActionsClass = "dm-search-actions";
|
|
1954
|
-
var dmSearchFastFilterClass = "dm-search-fast-filter";
|
|
1955
|
-
function getDmSearchClasses({
|
|
1956
|
-
compact,
|
|
1957
|
-
collapsed,
|
|
1958
|
-
className
|
|
1959
|
-
}) {
|
|
1960
|
-
return cn(dmSearchBaseClass, compact && dmSearchCompactClass, collapsed && dmSearchCollapsedClass, className);
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
// src/components/dm-search/DmSearch.tsx
|
|
1964
|
-
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2330
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1965
2331
|
function initialValues(items, searchParams, useSearchParams = true) {
|
|
1966
2332
|
return items.reduce((acc, item) => {
|
|
1967
2333
|
const defaultValue = item.search.extraProps?.value ?? item.search.formProps?.initialValue;
|
|
@@ -1985,7 +2351,7 @@ function renderField({
|
|
|
1985
2351
|
return item.search.render?.(value, setValue, item) ?? null;
|
|
1986
2352
|
}
|
|
1987
2353
|
if (item.search.type === "select") {
|
|
1988
|
-
return /* @__PURE__ */
|
|
2354
|
+
return /* @__PURE__ */ jsx9(Select, {
|
|
1989
2355
|
...extraProps,
|
|
1990
2356
|
disabled: Boolean(loading || extraProps.disabled),
|
|
1991
2357
|
value,
|
|
@@ -1994,25 +2360,25 @@ function renderField({
|
|
|
1994
2360
|
});
|
|
1995
2361
|
}
|
|
1996
2362
|
if (item.search.type === "dateRange") {
|
|
1997
|
-
return /* @__PURE__ */
|
|
2363
|
+
return /* @__PURE__ */ jsx9(DatePicker.RangePicker, {
|
|
1998
2364
|
...extraProps,
|
|
1999
2365
|
value,
|
|
2000
2366
|
onChange: (nextValue) => setValue(nextValue)
|
|
2001
2367
|
});
|
|
2002
2368
|
}
|
|
2003
2369
|
if (item.search.type === "date") {
|
|
2004
|
-
return /* @__PURE__ */
|
|
2370
|
+
return /* @__PURE__ */ jsx9(DatePicker, {
|
|
2005
2371
|
...extraProps,
|
|
2006
2372
|
value,
|
|
2007
2373
|
onChange: (nextValue) => setValue(nextValue)
|
|
2008
2374
|
});
|
|
2009
2375
|
}
|
|
2010
2376
|
if (item.search.type === "radio" || item.search.type === "checkbox") {
|
|
2011
|
-
return /* @__PURE__ */
|
|
2377
|
+
return /* @__PURE__ */ jsx9("div", {
|
|
2012
2378
|
role: item.search.type === "radio" ? "radiogroup" : "group",
|
|
2013
|
-
children: optionList(extraProps).map((option) => /* @__PURE__ */
|
|
2379
|
+
children: optionList(extraProps).map((option) => /* @__PURE__ */ jsxs8("label", {
|
|
2014
2380
|
children: [
|
|
2015
|
-
/* @__PURE__ */
|
|
2381
|
+
/* @__PURE__ */ jsx9("input", {
|
|
2016
2382
|
type: item.search.type,
|
|
2017
2383
|
disabled: loading,
|
|
2018
2384
|
checked: item.search.type === "checkbox" ? Array.isArray(value) && value.includes(option.value) : value === option.value,
|
|
@@ -2030,7 +2396,7 @@ function renderField({
|
|
|
2030
2396
|
}, String(option.value)))
|
|
2031
2397
|
});
|
|
2032
2398
|
}
|
|
2033
|
-
return /* @__PURE__ */
|
|
2399
|
+
return /* @__PURE__ */ jsx9(Input, {
|
|
2034
2400
|
...extraProps,
|
|
2035
2401
|
type: item.search.type === "input-number" ? "number" : "text",
|
|
2036
2402
|
disabled: Boolean(loading || extraProps.disabled),
|
|
@@ -2046,6 +2412,9 @@ function renderField({
|
|
|
2046
2412
|
}
|
|
2047
2413
|
var DmSearch = forwardRef7(({
|
|
2048
2414
|
items = [],
|
|
2415
|
+
values: controlledValues,
|
|
2416
|
+
onValuesChange,
|
|
2417
|
+
onReset,
|
|
2049
2418
|
onSearch,
|
|
2050
2419
|
extra,
|
|
2051
2420
|
fastFilterItem,
|
|
@@ -2054,27 +2423,37 @@ var DmSearch = forwardRef7(({
|
|
|
2054
2423
|
compact = false,
|
|
2055
2424
|
searchParams,
|
|
2056
2425
|
loading = false,
|
|
2426
|
+
noValidate,
|
|
2057
2427
|
enableDefaultPlaceHolder = false,
|
|
2058
2428
|
className
|
|
2059
2429
|
}, ref) => {
|
|
2060
2430
|
const allItems = useMemo6(() => fastFilterItem ? [fastFilterItem, ...items] : items, [fastFilterItem, items]);
|
|
2061
|
-
const [collapsed, setCollapsed] =
|
|
2062
|
-
const [
|
|
2431
|
+
const [collapsed, setCollapsed] = useState8(defaultCollapsed);
|
|
2432
|
+
const [internalValues, setValues] = useState8(() => initialValues(allItems, searchParams));
|
|
2433
|
+
const controlled = controlledValues !== undefined;
|
|
2434
|
+
const values = controlled ? controlledValues : internalValues;
|
|
2063
2435
|
const visibleItems = collapsed ? allItems.slice(0, 1) : allItems;
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2436
|
+
useEffect3(() => {
|
|
2437
|
+
if (!controlled)
|
|
2438
|
+
setValues(initialValues(allItems, searchParams));
|
|
2439
|
+
}, [allItems, searchParams, controlled]);
|
|
2067
2440
|
function reset(useSearchParams = false) {
|
|
2068
2441
|
const nextValues = initialValues(allItems, searchParams, useSearchParams);
|
|
2069
|
-
|
|
2442
|
+
if (!controlled)
|
|
2443
|
+
setValues(nextValues);
|
|
2444
|
+
if (onReset)
|
|
2445
|
+
onReset(nextValues);
|
|
2446
|
+
else if (controlled)
|
|
2447
|
+
onValuesChange?.(nextValues);
|
|
2070
2448
|
return nextValues;
|
|
2071
2449
|
}
|
|
2072
|
-
|
|
2450
|
+
useImperativeHandle3(ref, () => ({
|
|
2073
2451
|
onReset: () => {
|
|
2074
2452
|
reset(false);
|
|
2075
2453
|
}
|
|
2076
2454
|
}));
|
|
2077
|
-
return /* @__PURE__ */
|
|
2455
|
+
return /* @__PURE__ */ jsxs8("form", {
|
|
2456
|
+
noValidate,
|
|
2078
2457
|
id: "searchForm",
|
|
2079
2458
|
className: getDmSearchClasses({ compact, collapsed, className }),
|
|
2080
2459
|
onSubmit: (event) => {
|
|
@@ -2082,53 +2461,63 @@ var DmSearch = forwardRef7(({
|
|
|
2082
2461
|
onSearch?.(values);
|
|
2083
2462
|
},
|
|
2084
2463
|
children: [
|
|
2085
|
-
fastFilterItem ? /* @__PURE__ */
|
|
2464
|
+
fastFilterItem ? /* @__PURE__ */ jsx9("div", {
|
|
2086
2465
|
className: dmSearchFastFilterClass,
|
|
2087
2466
|
children: fastFilterItem.title
|
|
2088
2467
|
}) : null,
|
|
2089
|
-
/* @__PURE__ */
|
|
2468
|
+
/* @__PURE__ */ jsx9("div", {
|
|
2090
2469
|
className: dmSearchFieldsClass,
|
|
2091
|
-
children: visibleItems.map((item) =>
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2470
|
+
children: visibleItems.map((item) => {
|
|
2471
|
+
const Field = item.search.type === "custom" ? "div" : "label";
|
|
2472
|
+
return /* @__PURE__ */ jsxs8(Field, {
|
|
2473
|
+
className: dmSearchFieldClass,
|
|
2474
|
+
children: [
|
|
2475
|
+
compact ? null : /* @__PURE__ */ jsx9("span", {
|
|
2476
|
+
children: item.title
|
|
2477
|
+
}),
|
|
2478
|
+
renderField({
|
|
2479
|
+
item,
|
|
2480
|
+
value: values[item.dataIndex],
|
|
2481
|
+
loading,
|
|
2482
|
+
enableDefaultPlaceHolder,
|
|
2483
|
+
setValue: (value) => {
|
|
2484
|
+
const nextValues = { ...values, [item.dataIndex]: value };
|
|
2485
|
+
if (!controlled)
|
|
2486
|
+
setValues(nextValues);
|
|
2487
|
+
onValuesChange?.(nextValues);
|
|
2488
|
+
}
|
|
2489
|
+
})
|
|
2490
|
+
]
|
|
2491
|
+
}, item.key);
|
|
2492
|
+
})
|
|
2109
2493
|
}),
|
|
2110
|
-
/* @__PURE__ */
|
|
2494
|
+
/* @__PURE__ */ jsxs8("div", {
|
|
2111
2495
|
className: dmSearchActionsClass,
|
|
2112
2496
|
children: [
|
|
2113
|
-
/* @__PURE__ */
|
|
2497
|
+
/* @__PURE__ */ jsx9(Button, {
|
|
2114
2498
|
type: "submit",
|
|
2115
2499
|
isLoading: loading,
|
|
2116
2500
|
children: "Search"
|
|
2117
2501
|
}),
|
|
2118
|
-
/* @__PURE__ */
|
|
2502
|
+
/* @__PURE__ */ jsx9(Button, {
|
|
2119
2503
|
type: "button",
|
|
2120
2504
|
color: "secondary",
|
|
2121
2505
|
appearance: "outline",
|
|
2122
|
-
onClick: () =>
|
|
2506
|
+
onClick: () => {
|
|
2507
|
+
const nextValues = reset(false);
|
|
2508
|
+
if (!onReset)
|
|
2509
|
+
onSearch?.(nextValues);
|
|
2510
|
+
},
|
|
2123
2511
|
children: "Reset"
|
|
2124
2512
|
}),
|
|
2125
|
-
!hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */
|
|
2513
|
+
!hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */ jsx9(Button, {
|
|
2126
2514
|
type: "button",
|
|
2127
2515
|
color: "secondary",
|
|
2128
2516
|
appearance: "text",
|
|
2129
2517
|
onClick: () => {
|
|
2130
2518
|
setCollapsed((current) => !current);
|
|
2131
|
-
|
|
2519
|
+
if (!controlled)
|
|
2520
|
+
setValues(initialValues(allItems, searchParams));
|
|
2132
2521
|
},
|
|
2133
2522
|
children: collapsed ? "Expand" : "Collapse"
|
|
2134
2523
|
}) : null,
|
|
@@ -2143,7 +2532,7 @@ DmSearch.displayName = "DmSearch";
|
|
|
2143
2532
|
import React9, {
|
|
2144
2533
|
forwardRef as forwardRef8,
|
|
2145
2534
|
useMemo as useMemo7,
|
|
2146
|
-
useState as
|
|
2535
|
+
useState as useState9
|
|
2147
2536
|
} from "react";
|
|
2148
2537
|
|
|
2149
2538
|
// src/classes/table.ts
|
|
@@ -2193,7 +2582,7 @@ function getTableSorterClasses(active) {
|
|
|
2193
2582
|
}
|
|
2194
2583
|
|
|
2195
2584
|
// src/components/table/Table.tsx
|
|
2196
|
-
import { jsx as
|
|
2585
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2197
2586
|
import { createElement } from "react";
|
|
2198
2587
|
var defaultPageSize = 10;
|
|
2199
2588
|
var defaultSortDirections = ["ascend", "descend", null];
|
|
@@ -2226,8 +2615,8 @@ function getRecordKey(record, index, rowKey) {
|
|
|
2226
2615
|
return rowKey(record, index);
|
|
2227
2616
|
}
|
|
2228
2617
|
if (rowKey) {
|
|
2229
|
-
const
|
|
2230
|
-
return typeof
|
|
2618
|
+
const key = record[rowKey];
|
|
2619
|
+
return typeof key === "string" || typeof key === "number" ? key : index;
|
|
2231
2620
|
}
|
|
2232
2621
|
const key = record.key;
|
|
2233
2622
|
return typeof key === "string" || typeof key === "number" ? key : index;
|
|
@@ -2313,20 +2702,20 @@ var Column = forwardRef8(() => null);
|
|
|
2313
2702
|
Column.displayName = "Table.Column";
|
|
2314
2703
|
var ColumnGroup = forwardRef8(() => null);
|
|
2315
2704
|
ColumnGroup.displayName = "Table.ColumnGroup";
|
|
2316
|
-
var SummaryRow = forwardRef8((props, ref) => /* @__PURE__ */
|
|
2705
|
+
var SummaryRow = forwardRef8((props, ref) => /* @__PURE__ */ jsx10("tr", {
|
|
2317
2706
|
...props,
|
|
2318
2707
|
ref
|
|
2319
2708
|
}));
|
|
2320
2709
|
SummaryRow.displayName = "Table.Summary.Row";
|
|
2321
2710
|
var SummaryCell = forwardRef8(({ index, ...props }, ref) => {
|
|
2322
|
-
return /* @__PURE__ */
|
|
2711
|
+
return /* @__PURE__ */ jsx10("td", {
|
|
2323
2712
|
...props,
|
|
2324
2713
|
ref
|
|
2325
2714
|
});
|
|
2326
2715
|
});
|
|
2327
2716
|
SummaryCell.displayName = "Table.Summary.Cell";
|
|
2328
2717
|
var Summary = Object.assign(forwardRef8(({ fixed, ...props }, ref) => {
|
|
2329
|
-
return /* @__PURE__ */
|
|
2718
|
+
return /* @__PURE__ */ jsx10("tfoot", {
|
|
2330
2719
|
...props,
|
|
2331
2720
|
ref
|
|
2332
2721
|
});
|
|
@@ -2366,9 +2755,9 @@ function renderSummary(summary, pageData, colSpan) {
|
|
|
2366
2755
|
if (React9.isValidElement(node) && node.type === Summary) {
|
|
2367
2756
|
return node;
|
|
2368
2757
|
}
|
|
2369
|
-
return /* @__PURE__ */
|
|
2370
|
-
children: /* @__PURE__ */
|
|
2371
|
-
children: /* @__PURE__ */
|
|
2758
|
+
return /* @__PURE__ */ jsx10("tfoot", {
|
|
2759
|
+
children: /* @__PURE__ */ jsx10("tr", {
|
|
2760
|
+
children: /* @__PURE__ */ jsx10("td", {
|
|
2372
2761
|
className: tableCellClass,
|
|
2373
2762
|
colSpan,
|
|
2374
2763
|
children: node
|
|
@@ -2416,12 +2805,12 @@ function TableRoot({
|
|
|
2416
2805
|
const normalizedColumns = useMemo7(() => normalizeColumns(columns ?? childColumns), [childColumns, columns]);
|
|
2417
2806
|
const leaves = useMemo7(() => leafColumns(normalizedColumns), [normalizedColumns]);
|
|
2418
2807
|
const headerRows = useMemo7(() => buildHeaderRows(normalizedColumns, getDepth(normalizedColumns)), [normalizedColumns]);
|
|
2419
|
-
const [sortStates, setSortStates] =
|
|
2420
|
-
const [filterStates, setFilterStates] =
|
|
2421
|
-
const [internalCurrent, setInternalCurrent] =
|
|
2422
|
-
const [internalPageSize, setInternalPageSize] =
|
|
2423
|
-
const [internalSelectedKeys, setInternalSelectedKeys] =
|
|
2424
|
-
const [internalExpandedKeys, setInternalExpandedKeys] =
|
|
2808
|
+
const [sortStates, setSortStates] = useState9({});
|
|
2809
|
+
const [filterStates, setFilterStates] = useState9({});
|
|
2810
|
+
const [internalCurrent, setInternalCurrent] = useState9(1);
|
|
2811
|
+
const [internalPageSize, setInternalPageSize] = useState9(defaultPageSize);
|
|
2812
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = useState9(rowSelection?.defaultSelectedRowKeys ?? []);
|
|
2813
|
+
const [internalExpandedKeys, setInternalExpandedKeys] = useState9(expandable?.defaultExpandedRowKeys ?? []);
|
|
2425
2814
|
const spinning = typeof loading === "object" ? loading.spinning : Boolean(loading);
|
|
2426
2815
|
const activeFilters = useMemo7(() => {
|
|
2427
2816
|
return leaves.reduce((result, column) => {
|
|
@@ -2596,18 +2985,18 @@ function TableRoot({
|
|
|
2596
2985
|
return null;
|
|
2597
2986
|
}
|
|
2598
2987
|
if (rowSelection.type === "radio" || rowSelection.hideSelectAll) {
|
|
2599
|
-
return /* @__PURE__ */
|
|
2988
|
+
return /* @__PURE__ */ jsx10("th", {
|
|
2600
2989
|
className: cn(tableHeaderCellClass, tableSelectionCellClass),
|
|
2601
2990
|
children: rowSelection.columnTitle
|
|
2602
2991
|
});
|
|
2603
2992
|
}
|
|
2604
2993
|
const pageKeys = pageData.map((record, index) => getRecordKey(record, index, rowKey));
|
|
2605
2994
|
const allSelected = pageKeys.length > 0 && pageKeys.every((key) => selectedKeySet.has(String(key)));
|
|
2606
|
-
return /* @__PURE__ */
|
|
2995
|
+
return /* @__PURE__ */ jsx10("th", {
|
|
2607
2996
|
className: cn(tableHeaderCellClass, tableSelectionCellClass),
|
|
2608
|
-
children: /* @__PURE__ */
|
|
2997
|
+
children: /* @__PURE__ */ jsxs9("label", {
|
|
2609
2998
|
children: [
|
|
2610
|
-
/* @__PURE__ */
|
|
2999
|
+
/* @__PURE__ */ jsx10("input", {
|
|
2611
3000
|
type: "checkbox",
|
|
2612
3001
|
"aria-label": "Select all rows",
|
|
2613
3002
|
checked: allSelected,
|
|
@@ -2618,399 +3007,825 @@ function TableRoot({
|
|
|
2618
3007
|
})
|
|
2619
3008
|
});
|
|
2620
3009
|
}
|
|
2621
|
-
function renderHeaderCell(cell, index) {
|
|
2622
|
-
const { column } = cell;
|
|
2623
|
-
const title = column.title ?? dataIndexKey(column.dataIndex) ?? index + 1;
|
|
2624
|
-
const sortOrder = sortOrderFor(column, sortStates);
|
|
2625
|
-
const headerProps = column.onHeaderCell?.(column) ?? {};
|
|
2626
|
-
return /* @__PURE__ */ createElement("th", {
|
|
2627
|
-
...headerProps,
|
|
2628
|
-
key: String(column.columnKey),
|
|
2629
|
-
className: cn(tableHeaderCellClass, column.className, headerProps.className),
|
|
2630
|
-
colSpan: cell.colSpan,
|
|
2631
|
-
rowSpan: cell.rowSpan,
|
|
2632
|
-
style: {
|
|
2633
|
-
width: column.width,
|
|
2634
|
-
textAlign: column.align,
|
|
2635
|
-
...headerProps.style
|
|
2636
|
-
}
|
|
2637
|
-
}, /* @__PURE__ */
|
|
2638
|
-
children: title
|
|
2639
|
-
}), column.sorter ? /* @__PURE__ */
|
|
3010
|
+
function renderHeaderCell(cell, index) {
|
|
3011
|
+
const { column } = cell;
|
|
3012
|
+
const title = column.title ?? dataIndexKey(column.dataIndex) ?? index + 1;
|
|
3013
|
+
const sortOrder = sortOrderFor(column, sortStates);
|
|
3014
|
+
const headerProps = column.onHeaderCell?.(column) ?? {};
|
|
3015
|
+
return /* @__PURE__ */ createElement("th", {
|
|
3016
|
+
...headerProps,
|
|
3017
|
+
key: String(column.columnKey),
|
|
3018
|
+
className: cn(tableHeaderCellClass, column.className, headerProps.className),
|
|
3019
|
+
colSpan: cell.colSpan,
|
|
3020
|
+
rowSpan: cell.rowSpan,
|
|
3021
|
+
style: {
|
|
3022
|
+
width: column.width,
|
|
3023
|
+
textAlign: column.align,
|
|
3024
|
+
...headerProps.style
|
|
3025
|
+
}
|
|
3026
|
+
}, /* @__PURE__ */ jsx10("span", {
|
|
3027
|
+
children: title
|
|
3028
|
+
}), column.sorter ? /* @__PURE__ */ jsx10("button", {
|
|
3029
|
+
type: "button",
|
|
3030
|
+
className: getTableSorterClasses(Boolean(sortOrder)),
|
|
3031
|
+
"aria-label": `Sort ${textFromNode(title, String(column.columnKey))}`,
|
|
3032
|
+
onClick: () => changeSorter(column),
|
|
3033
|
+
children: sortOrder === "ascend" ? "Asc" : sortOrder === "descend" ? "Desc" : "Sort"
|
|
3034
|
+
}) : null, column.filters?.length ? /* @__PURE__ */ jsxs9("select", {
|
|
3035
|
+
className: tableFilterClass,
|
|
3036
|
+
"aria-label": `Filter ${textFromNode(title, String(column.columnKey))}`,
|
|
3037
|
+
multiple: column.filterMultiple !== false,
|
|
3038
|
+
value: column.filterMultiple === false ? String((filterValueFor(column, filterStates) ?? [])[0] ?? "") : (filterValueFor(column, filterStates) ?? []).map(String),
|
|
3039
|
+
onChange: (event) => changeFilter(column, event),
|
|
3040
|
+
children: [
|
|
3041
|
+
column.filterMultiple === false ? /* @__PURE__ */ jsx10("option", {
|
|
3042
|
+
value: "",
|
|
3043
|
+
children: "All"
|
|
3044
|
+
}) : null,
|
|
3045
|
+
optionValues(column.filters).map((filter) => /* @__PURE__ */ jsx10("option", {
|
|
3046
|
+
value: String(filter.value),
|
|
3047
|
+
children: filter.text
|
|
3048
|
+
}, String(filter.value)))
|
|
3049
|
+
]
|
|
3050
|
+
}) : null);
|
|
3051
|
+
}
|
|
3052
|
+
function renderCell(record, recordIndex, column) {
|
|
3053
|
+
const value = getValue(record, column.dataIndex);
|
|
3054
|
+
const rendered = column.render ? column.render(value, record, recordIndex) : value;
|
|
3055
|
+
const cellProps = column.onCell?.(record, recordIndex) ?? {};
|
|
3056
|
+
return /* @__PURE__ */ createElement("td", {
|
|
3057
|
+
...cellProps,
|
|
3058
|
+
key: String(column.columnKey),
|
|
3059
|
+
className: cn(tableCellClass, column.className, cellProps.className),
|
|
3060
|
+
style: { textAlign: column.align, ...cellProps.style }
|
|
3061
|
+
}, hasNode(rendered) ? rendered : null);
|
|
3062
|
+
}
|
|
3063
|
+
function renderSelectionCell(record, index) {
|
|
3064
|
+
if (!rowSelection) {
|
|
3065
|
+
return null;
|
|
3066
|
+
}
|
|
3067
|
+
const key = getRecordKey(record, index, rowKey);
|
|
3068
|
+
const checked = selectedKeySet.has(String(key));
|
|
3069
|
+
const checkboxProps = rowSelection.getCheckboxProps?.(record) ?? {};
|
|
3070
|
+
const originNode = /* @__PURE__ */ jsx10("input", {
|
|
3071
|
+
...checkboxProps,
|
|
3072
|
+
type: rowSelection.type === "radio" ? "radio" : "checkbox",
|
|
3073
|
+
"aria-label": `Select row ${index + 1}`,
|
|
3074
|
+
checked,
|
|
3075
|
+
onChange: (event) => toggleRowSelection(record, index, event)
|
|
3076
|
+
});
|
|
3077
|
+
return /* @__PURE__ */ jsx10("td", {
|
|
3078
|
+
className: cn(tableCellClass, tableSelectionCellClass),
|
|
3079
|
+
children: rowSelection.renderCell ? rowSelection.renderCell(checked, record, index, originNode) : originNode
|
|
3080
|
+
});
|
|
3081
|
+
}
|
|
3082
|
+
function renderExpandCell(record, index) {
|
|
3083
|
+
if (!expandable?.expandedRowRender) {
|
|
3084
|
+
return null;
|
|
3085
|
+
}
|
|
3086
|
+
const key = getRecordKey(record, index, rowKey);
|
|
3087
|
+
const expanded = expandedKeySet.has(String(key));
|
|
3088
|
+
const expandableRow = expandable.rowExpandable?.(record) ?? true;
|
|
3089
|
+
return /* @__PURE__ */ jsx10("td", {
|
|
3090
|
+
className: cn(tableCellClass, tableExpandCellClass),
|
|
3091
|
+
children: expandableRow ? /* @__PURE__ */ jsx10("button", {
|
|
3092
|
+
type: "button",
|
|
3093
|
+
className: tableExpandButtonClass,
|
|
3094
|
+
"aria-label": `${expanded ? "Collapse" : "Expand"} row ${index + 1}`,
|
|
3095
|
+
onClick: () => toggleExpand(record, index),
|
|
3096
|
+
children: expanded ? "-" : "+"
|
|
3097
|
+
}) : null
|
|
3098
|
+
});
|
|
3099
|
+
}
|
|
3100
|
+
function renderRow(record, index) {
|
|
3101
|
+
const key = getRecordKey(record, index, rowKey);
|
|
3102
|
+
const expanded = expandedKeySet.has(String(key));
|
|
3103
|
+
const selected = selectedKeySet.has(String(key));
|
|
3104
|
+
const row = /* @__PURE__ */ jsxs9("tr", {
|
|
3105
|
+
className: getTableRowClasses({ selected, expanded }),
|
|
3106
|
+
onClick: () => {
|
|
3107
|
+
if (expandable?.expandRowByClick) {
|
|
3108
|
+
toggleExpand(record, index);
|
|
3109
|
+
}
|
|
3110
|
+
},
|
|
3111
|
+
children: [
|
|
3112
|
+
renderSelectionCell(record, index),
|
|
3113
|
+
renderExpandCell(record, index),
|
|
3114
|
+
leaves.map((column) => renderCell(record, index, column))
|
|
3115
|
+
]
|
|
3116
|
+
}, String(key));
|
|
3117
|
+
if (!expanded || !expandable?.expandedRowRender) {
|
|
3118
|
+
return row;
|
|
3119
|
+
}
|
|
3120
|
+
return /* @__PURE__ */ jsxs9(React9.Fragment, {
|
|
3121
|
+
children: [
|
|
3122
|
+
row,
|
|
3123
|
+
/* @__PURE__ */ jsx10("tr", {
|
|
3124
|
+
className: "table-expanded-row",
|
|
3125
|
+
children: /* @__PURE__ */ jsx10("td", {
|
|
3126
|
+
className: tableCellClass,
|
|
3127
|
+
colSpan: structuralColumnCount,
|
|
3128
|
+
children: expandable.expandedRowRender(record, index, 0, expanded)
|
|
3129
|
+
})
|
|
3130
|
+
})
|
|
3131
|
+
]
|
|
3132
|
+
}, String(key));
|
|
3133
|
+
}
|
|
3134
|
+
const tableNode = /* @__PURE__ */ jsxs9("table", {
|
|
3135
|
+
className: getTableClasses({ bordered, size }),
|
|
3136
|
+
style: { tableLayout },
|
|
3137
|
+
children: [
|
|
3138
|
+
/* @__PURE__ */ jsx10("thead", {
|
|
3139
|
+
children: headerRows.map((row, rowIndex) => /* @__PURE__ */ jsxs9("tr", {
|
|
3140
|
+
children: [
|
|
3141
|
+
rowIndex === 0 ? renderSelectionHeader() : null,
|
|
3142
|
+
rowIndex === 0 && hasExpandable ? /* @__PURE__ */ jsx10("th", {
|
|
3143
|
+
className: cn(tableHeaderCellClass, tableExpandCellClass),
|
|
3144
|
+
children: expandable?.columnTitle
|
|
3145
|
+
}) : null,
|
|
3146
|
+
row.map(renderHeaderCell)
|
|
3147
|
+
]
|
|
3148
|
+
}, rowIndex))
|
|
3149
|
+
}),
|
|
3150
|
+
/* @__PURE__ */ jsx10("tbody", {
|
|
3151
|
+
children: bodyEmpty ? /* @__PURE__ */ jsx10("tr", {
|
|
3152
|
+
children: /* @__PURE__ */ jsx10("td", {
|
|
3153
|
+
className: tableEmptyClass,
|
|
3154
|
+
colSpan: structuralColumnCount,
|
|
3155
|
+
children: locale?.emptyText ?? "No data"
|
|
3156
|
+
})
|
|
3157
|
+
}) : pageData.map(renderRow)
|
|
3158
|
+
}),
|
|
3159
|
+
renderSummary(summary, pageData, structuralColumnCount)
|
|
3160
|
+
]
|
|
3161
|
+
});
|
|
3162
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
3163
|
+
...props,
|
|
3164
|
+
ref,
|
|
3165
|
+
className: getTableWrapperClasses({ loading: spinning, className }),
|
|
3166
|
+
children: [
|
|
3167
|
+
scroll?.x || scroll?.y ? /* @__PURE__ */ jsx10("div", {
|
|
3168
|
+
style: {
|
|
3169
|
+
overflow: "auto",
|
|
3170
|
+
maxHeight: scroll.y,
|
|
3171
|
+
width: scroll.x === true ? "100%" : scroll.x
|
|
3172
|
+
},
|
|
3173
|
+
children: tableNode
|
|
3174
|
+
}) : tableNode,
|
|
3175
|
+
spinning ? /* @__PURE__ */ jsx10("div", {
|
|
3176
|
+
className: tableLoadingIndicatorClass,
|
|
3177
|
+
role: "status",
|
|
3178
|
+
children: typeof loading === "object" && loading.indicator ? loading.indicator : "Loading"
|
|
3179
|
+
}) : null,
|
|
3180
|
+
paginationConfig && !(paginationConfig.hideOnSinglePage && pageCount <= 1) ? /* @__PURE__ */ jsxs9("nav", {
|
|
3181
|
+
className: tablePaginationClass,
|
|
3182
|
+
"aria-label": "Table pagination",
|
|
3183
|
+
children: [
|
|
3184
|
+
/* @__PURE__ */ jsx10("button", {
|
|
3185
|
+
type: "button",
|
|
3186
|
+
className: tablePaginationButtonClass,
|
|
3187
|
+
disabled: paginationConfig.disabled || current <= 1,
|
|
3188
|
+
onClick: () => changePage(current - 1),
|
|
3189
|
+
children: "Previous"
|
|
3190
|
+
}),
|
|
3191
|
+
/* @__PURE__ */ jsx10("span", {
|
|
3192
|
+
className: tablePaginationInfoClass,
|
|
3193
|
+
children: paginationConfig.showTotal ? paginationConfig.showTotal(paginationConfig.total ?? sortedData.length, [
|
|
3194
|
+
bodyEmpty ? 0 : (current - 1) * pageSize + 1,
|
|
3195
|
+
Math.min(current * pageSize, sortedData.length)
|
|
3196
|
+
]) : `${current} / ${pageCount}`
|
|
3197
|
+
}),
|
|
3198
|
+
/* @__PURE__ */ jsx10("button", {
|
|
3199
|
+
type: "button",
|
|
3200
|
+
className: tablePaginationButtonClass,
|
|
3201
|
+
disabled: paginationConfig.disabled || current >= pageCount,
|
|
3202
|
+
onClick: () => changePage(current + 1),
|
|
3203
|
+
children: "Next"
|
|
3204
|
+
})
|
|
3205
|
+
]
|
|
3206
|
+
}) : null
|
|
3207
|
+
]
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
var TableWithRef = forwardRef8(TableRoot);
|
|
3211
|
+
var Table = Object.assign(TableWithRef, {
|
|
3212
|
+
Column,
|
|
3213
|
+
ColumnGroup,
|
|
3214
|
+
Summary,
|
|
3215
|
+
SELECTION_ALL: "SELECT_ALL",
|
|
3216
|
+
SELECTION_INVERT: "SELECT_INVERT",
|
|
3217
|
+
SELECTION_NONE: "SELECT_NONE",
|
|
3218
|
+
SELECTION_COLUMN: "SELECTION_COLUMN",
|
|
3219
|
+
EXPAND_COLUMN: "EXPAND_COLUMN"
|
|
3220
|
+
});
|
|
3221
|
+
Table.displayName = "Table";
|
|
3222
|
+
// src/components/dm-table/DmTable.tsx
|
|
3223
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3224
|
+
function mapAndFilter(list, mapper) {
|
|
3225
|
+
return list.map(mapper).filter((item) => item !== false && item != null);
|
|
3226
|
+
}
|
|
3227
|
+
function filterDmTableColumn(column) {
|
|
3228
|
+
if (column.onlySearch || column.hideInTable)
|
|
3229
|
+
return false;
|
|
3230
|
+
if (Array.isArray(column.children)) {
|
|
3231
|
+
const children = mapAndFilter(column.children, filterDmTableColumn);
|
|
3232
|
+
return children.length > 0 ? { ...column, children } : null;
|
|
3233
|
+
}
|
|
3234
|
+
return column;
|
|
3235
|
+
}
|
|
3236
|
+
function filterSearchColumn(column) {
|
|
3237
|
+
if (Array.isArray(column.children)) {
|
|
3238
|
+
const children = mapAndFilter(column.children, filterSearchColumn);
|
|
3239
|
+
return children.length > 0 ? { ...column, children } : null;
|
|
3240
|
+
}
|
|
3241
|
+
return column.search ? column : false;
|
|
3242
|
+
}
|
|
3243
|
+
function flattenSearchColumns(column) {
|
|
3244
|
+
return Array.isArray(column.children) ? column.children.flatMap(flattenSearchColumns) : [column];
|
|
3245
|
+
}
|
|
3246
|
+
function searchItems(columns) {
|
|
3247
|
+
return mapAndFilter(columns, filterSearchColumn).flatMap(flattenSearchColumns).map((column) => ({
|
|
3248
|
+
key: String(column.key ?? column.dataIndex),
|
|
3249
|
+
title: column.title,
|
|
3250
|
+
dataIndex: String(column.dataIndex ?? column.key),
|
|
3251
|
+
search: column.search || {
|
|
3252
|
+
type: "input",
|
|
3253
|
+
extraProps: {},
|
|
3254
|
+
formProps: {}
|
|
3255
|
+
}
|
|
3256
|
+
}));
|
|
3257
|
+
}
|
|
3258
|
+
function DmTable({
|
|
3259
|
+
name,
|
|
3260
|
+
extra,
|
|
3261
|
+
indicators,
|
|
3262
|
+
pagination,
|
|
3263
|
+
columns: inputColumns,
|
|
3264
|
+
columnSettingVisible = true,
|
|
3265
|
+
onColumnsChange,
|
|
3266
|
+
columnState,
|
|
3267
|
+
searchProps,
|
|
3268
|
+
tableExtra,
|
|
3269
|
+
className,
|
|
3270
|
+
dataSource,
|
|
3271
|
+
rowSelection,
|
|
3272
|
+
...props
|
|
3273
|
+
}) {
|
|
3274
|
+
const tableColumns = useMemo8(() => mapAndFilter(inputColumns, filterDmTableColumn), [inputColumns]);
|
|
3275
|
+
const [columns, setColumns] = useState10(tableColumns);
|
|
3276
|
+
const [columnSettingsOpen, setColumnSettingsOpen] = useState10(false);
|
|
3277
|
+
const items = searchProps?.items?.length ? searchProps.items : searchItems(inputColumns);
|
|
3278
|
+
const paginationObj = typeof pagination === "object" ? pagination : undefined;
|
|
3279
|
+
const paginationProps = paginationObj ? Object.fromEntries(Object.entries(paginationObj).filter(([key]) => key !== "ref")) : {};
|
|
3280
|
+
const total = paginationObj?.total ?? dataSource?.length ?? 0;
|
|
3281
|
+
const selectedTotal = rowSelection?.selectedRowKeys?.length ?? 0;
|
|
3282
|
+
function resetColumns() {
|
|
3283
|
+
setColumns(tableColumns);
|
|
3284
|
+
onColumnsChange?.(tableColumns);
|
|
3285
|
+
if (columnState?.persistenceKey) {
|
|
3286
|
+
globalThis.localStorage?.removeItem(columnState.persistenceKey);
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
return /* @__PURE__ */ jsxs10("div", {
|
|
3290
|
+
className: getDmTableClasses({ className }),
|
|
3291
|
+
children: [
|
|
3292
|
+
items.length > 0 || searchProps?.fastFilterItem ? /* @__PURE__ */ jsx11(Card, {
|
|
3293
|
+
className: dmTableSearchClass,
|
|
3294
|
+
padding: "md",
|
|
3295
|
+
children: /* @__PURE__ */ jsx11(DmSearch, {
|
|
3296
|
+
...searchProps,
|
|
3297
|
+
items
|
|
3298
|
+
})
|
|
3299
|
+
}) : null,
|
|
3300
|
+
indicators ? /* @__PURE__ */ jsx11("div", {
|
|
3301
|
+
className: dmTableIndicatorsClass,
|
|
3302
|
+
children: indicators
|
|
3303
|
+
}) : null,
|
|
3304
|
+
/* @__PURE__ */ jsxs10(Card, {
|
|
3305
|
+
className: dmTableCardClass,
|
|
3306
|
+
padding: "md",
|
|
3307
|
+
children: [
|
|
3308
|
+
name || extra || columnSettingVisible ? /* @__PURE__ */ jsxs10("div", {
|
|
3309
|
+
className: dmTableHeaderClass,
|
|
3310
|
+
children: [
|
|
3311
|
+
/* @__PURE__ */ jsx11("div", {
|
|
3312
|
+
className: dmTableTitleClass,
|
|
3313
|
+
children: name
|
|
3314
|
+
}),
|
|
3315
|
+
/* @__PURE__ */ jsxs10("div", {
|
|
3316
|
+
className: dmTableExtraClass,
|
|
3317
|
+
children: [
|
|
3318
|
+
extra,
|
|
3319
|
+
columnSettingVisible ? /* @__PURE__ */ jsx11(Button, {
|
|
3320
|
+
type: "button",
|
|
3321
|
+
color: "secondary",
|
|
3322
|
+
appearance: "outline",
|
|
3323
|
+
className: dmTableColumnSettingClass,
|
|
3324
|
+
onClick: () => setColumnSettingsOpen((open) => !open),
|
|
3325
|
+
children: "Columns"
|
|
3326
|
+
}) : null
|
|
3327
|
+
]
|
|
3328
|
+
})
|
|
3329
|
+
]
|
|
3330
|
+
}) : null,
|
|
3331
|
+
columnSettingsOpen ? /* @__PURE__ */ jsx11("div", {
|
|
3332
|
+
role: "dialog",
|
|
3333
|
+
"aria-label": "Column settings",
|
|
3334
|
+
children: /* @__PURE__ */ jsx11(Button, {
|
|
3335
|
+
type: "button",
|
|
3336
|
+
onClick: resetColumns,
|
|
3337
|
+
children: "Reset columns"
|
|
3338
|
+
})
|
|
3339
|
+
}) : null,
|
|
3340
|
+
tableExtra ? /* @__PURE__ */ jsx11("div", {
|
|
3341
|
+
className: dmTableTableExtraClass,
|
|
3342
|
+
children: tableExtra
|
|
3343
|
+
}) : null,
|
|
3344
|
+
/* @__PURE__ */ jsx11(Table, {
|
|
3345
|
+
...props,
|
|
3346
|
+
dataSource,
|
|
3347
|
+
rowSelection,
|
|
3348
|
+
size: props.size ?? "small",
|
|
3349
|
+
scroll: props.scroll ?? { x: 680 },
|
|
3350
|
+
columns,
|
|
3351
|
+
pagination: pagination ? {
|
|
3352
|
+
current: paginationObj?.current,
|
|
3353
|
+
defaultCurrent: paginationObj?.defaultCurrent,
|
|
3354
|
+
pageSize: paginationObj?.pageSize,
|
|
3355
|
+
defaultPageSize: paginationObj?.defaultPageSize,
|
|
3356
|
+
total,
|
|
3357
|
+
onChange: paginationObj?.onChange
|
|
3358
|
+
} : false
|
|
3359
|
+
}),
|
|
3360
|
+
pagination ? /* @__PURE__ */ jsx11(DmPagination, {
|
|
3361
|
+
...paginationProps,
|
|
3362
|
+
className: dmTablePaginationClass,
|
|
3363
|
+
total,
|
|
3364
|
+
selectedTotal,
|
|
3365
|
+
showSizeChanger: true
|
|
3366
|
+
}) : null
|
|
3367
|
+
]
|
|
3368
|
+
})
|
|
3369
|
+
]
|
|
3370
|
+
});
|
|
3371
|
+
}
|
|
3372
|
+
DmTable.displayName = "DmTable";
|
|
3373
|
+
// src/components/dm-toolbar/DmToolbar.tsx
|
|
3374
|
+
import { useMemo as useMemo9 } from "react";
|
|
3375
|
+
|
|
3376
|
+
// src/classes/dm-toolbar.ts
|
|
3377
|
+
var dmToolbarBaseClass = "dm-toolbar";
|
|
3378
|
+
var dmToolbarItemClass = "dm-toolbar-item";
|
|
3379
|
+
var dmToolbarPrimaryItemClass = "dm-toolbar-primary-item";
|
|
3380
|
+
var dmToolbarSecondaryItemClass = "dm-toolbar-secondary-item";
|
|
3381
|
+
var dmToolbarMoreClass = "dm-toolbar-more";
|
|
3382
|
+
function getDmToolbarClasses({ className }) {
|
|
3383
|
+
return cn(dmToolbarBaseClass, className);
|
|
3384
|
+
}
|
|
3385
|
+
function getDmToolbarItemClasses({
|
|
3386
|
+
primary,
|
|
3387
|
+
className
|
|
3388
|
+
}) {
|
|
3389
|
+
return cn(dmToolbarItemClass, primary ? dmToolbarPrimaryItemClass : dmToolbarSecondaryItemClass, className);
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
// src/components/dropdown/Dropdown.tsx
|
|
3393
|
+
import {
|
|
3394
|
+
cloneElement,
|
|
3395
|
+
forwardRef as forwardRef9,
|
|
3396
|
+
isValidElement,
|
|
3397
|
+
useEffect as useEffect4,
|
|
3398
|
+
useId as useId2,
|
|
3399
|
+
useRef as useRef4,
|
|
3400
|
+
useState as useState11
|
|
3401
|
+
} from "react";
|
|
3402
|
+
|
|
3403
|
+
// src/classes/dropdown.ts
|
|
3404
|
+
var dropdownWrapperClass = "dropdown";
|
|
3405
|
+
var dropdownBaseClass = "dropdown-content";
|
|
3406
|
+
var dropdownArrowClass = "dropdown-arrow";
|
|
3407
|
+
var dropdownMenuClass = "menu dropdown-menu";
|
|
3408
|
+
var dropdownButtonClass = "dropdown-button";
|
|
3409
|
+
var dropdownPlacementClasses = {
|
|
3410
|
+
top: "dropdown-block-start",
|
|
3411
|
+
bottom: "dropdown-block-end",
|
|
3412
|
+
left: "dropdown-inline-start",
|
|
3413
|
+
right: "dropdown-inline-end",
|
|
3414
|
+
topLeft: "dropdown-block-start",
|
|
3415
|
+
topRight: "dropdown-block-start",
|
|
3416
|
+
bottomLeft: "dropdown-block-end",
|
|
3417
|
+
bottomRight: "dropdown-block-end"
|
|
3418
|
+
};
|
|
3419
|
+
function getDropdownClasses({
|
|
3420
|
+
className
|
|
3421
|
+
}) {
|
|
3422
|
+
return cn(dropdownBaseClass, className);
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
// src/classes/menu.ts
|
|
3426
|
+
var menuBaseClass = "menu";
|
|
3427
|
+
var menuShowClass = "menu-show";
|
|
3428
|
+
var menuItemClass = "menu-item";
|
|
3429
|
+
var menuItemActiveClass = "menu-item-active";
|
|
3430
|
+
var menuItemDisabledClass = "menu-item-disabled";
|
|
3431
|
+
var menuItemIconClass = "menu-item-icon";
|
|
3432
|
+
var menuItemTrailingClass = "menu-item-trailing";
|
|
3433
|
+
var menuItemSubmenuClass = "menu-item-submenu";
|
|
3434
|
+
var menuDividerClass = "menu-divider";
|
|
3435
|
+
var menuLabelClass = "menu-label";
|
|
3436
|
+
var menuSubmenuClass = "menu-submenu";
|
|
3437
|
+
var menuCompactClass = "menu-compact";
|
|
3438
|
+
var menuWideClass = "menu-wide";
|
|
3439
|
+
var menuModeClasses = {
|
|
3440
|
+
vertical: "menu-vertical",
|
|
3441
|
+
horizontal: "menu-horizontal",
|
|
3442
|
+
inline: "menu-inline"
|
|
3443
|
+
};
|
|
3444
|
+
var menuThemeClasses = {
|
|
3445
|
+
light: "",
|
|
3446
|
+
dark: "menu-dark menu-surface-container-highest"
|
|
3447
|
+
};
|
|
3448
|
+
var menuSizeClasses = {
|
|
3449
|
+
sm: menuCompactClass,
|
|
3450
|
+
md: "",
|
|
3451
|
+
lg: menuWideClass
|
|
3452
|
+
};
|
|
3453
|
+
function getMenuClasses({
|
|
3454
|
+
mode = "vertical",
|
|
3455
|
+
theme = "light",
|
|
3456
|
+
size = "md",
|
|
3457
|
+
inlineCollapsed,
|
|
3458
|
+
disabled,
|
|
3459
|
+
className
|
|
3460
|
+
}) {
|
|
3461
|
+
return cn(menuBaseClass, menuShowClass, menuModeClasses[mode], menuThemeClasses[theme], menuSizeClasses[size], inlineCollapsed && "menu-inline-collapsed", disabled && menuItemDisabledClass, className);
|
|
3462
|
+
}
|
|
3463
|
+
function getMenuItemClasses({
|
|
3464
|
+
active,
|
|
3465
|
+
disabled,
|
|
3466
|
+
danger,
|
|
3467
|
+
submenu,
|
|
3468
|
+
className
|
|
3469
|
+
}) {
|
|
3470
|
+
return cn(menuItemClass, active && menuItemActiveClass, disabled && menuItemDisabledClass, danger && "menu-item-danger", submenu && menuItemSubmenuClass, className);
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3473
|
+
// src/components/dropdown/Dropdown.tsx
|
|
3474
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3475
|
+
function callHandler(handler, event) {
|
|
3476
|
+
handler?.(event);
|
|
3477
|
+
}
|
|
3478
|
+
function renderMenuItem(item, onClick, close) {
|
|
3479
|
+
if (item.type === "divider") {
|
|
3480
|
+
return /* @__PURE__ */ jsx12("li", {
|
|
3481
|
+
className: menuDividerClass
|
|
3482
|
+
}, String(item.key));
|
|
3483
|
+
}
|
|
3484
|
+
return /* @__PURE__ */ jsx12("li", {
|
|
3485
|
+
children: /* @__PURE__ */ jsxs11("button", {
|
|
2640
3486
|
type: "button",
|
|
2641
|
-
className:
|
|
2642
|
-
|
|
2643
|
-
onClick: () =>
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
"aria-label": `Filter ${textFromNode(title, String(column.columnKey))}`,
|
|
2648
|
-
multiple: column.filterMultiple !== false,
|
|
2649
|
-
value: column.filterMultiple === false ? String((filterValueFor(column, filterStates) ?? [])[0] ?? "") : (filterValueFor(column, filterStates) ?? []).map(String),
|
|
2650
|
-
onChange: (event) => changeFilter(column, event),
|
|
3487
|
+
className: cn(menuItemClass, item.danger && "menu-item-danger", item.className),
|
|
3488
|
+
disabled: item.disabled,
|
|
3489
|
+
onClick: (event) => {
|
|
3490
|
+
onClick?.({ key: String(item.key), item, domEvent: event });
|
|
3491
|
+
close();
|
|
3492
|
+
},
|
|
2651
3493
|
children: [
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
children:
|
|
3494
|
+
item.icon ? /* @__PURE__ */ jsx12("span", {
|
|
3495
|
+
className: "menu-item-icon",
|
|
3496
|
+
children: item.icon
|
|
2655
3497
|
}) : null,
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
}, String(filter.value)))
|
|
3498
|
+
/* @__PURE__ */ jsx12("span", {
|
|
3499
|
+
children: item.label
|
|
3500
|
+
})
|
|
2660
3501
|
]
|
|
2661
|
-
})
|
|
2662
|
-
}
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
3502
|
+
})
|
|
3503
|
+
}, String(item.key));
|
|
3504
|
+
}
|
|
3505
|
+
var DropdownRoot = forwardRef9(({
|
|
3506
|
+
arrow,
|
|
3507
|
+
children,
|
|
3508
|
+
className,
|
|
3509
|
+
defaultOpen,
|
|
3510
|
+
destroyPopupOnHide,
|
|
3511
|
+
disabled,
|
|
3512
|
+
dropdownRender,
|
|
3513
|
+
menu,
|
|
3514
|
+
onContextMenu,
|
|
3515
|
+
onClick,
|
|
3516
|
+
onMouseEnter,
|
|
3517
|
+
onMouseLeave,
|
|
3518
|
+
onOpenChange,
|
|
3519
|
+
open,
|
|
3520
|
+
overlay,
|
|
3521
|
+
placement = "bottomLeft",
|
|
3522
|
+
trigger = ["hover"],
|
|
3523
|
+
...props
|
|
3524
|
+
}, ref) => {
|
|
3525
|
+
const [internalOpen, setInternalOpen] = useState11(Boolean(defaultOpen));
|
|
3526
|
+
const [nativeOpen, setNativeOpen] = useState11(Boolean(open ?? defaultOpen));
|
|
3527
|
+
const visible = open ?? internalOpen;
|
|
3528
|
+
const popupRef = useRef4(null);
|
|
3529
|
+
const popupId = useId2();
|
|
3530
|
+
const anchorName = `--dm-dropdown-${popupId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
3531
|
+
const clickTrigger = trigger.includes("click") || trigger.includes("hover");
|
|
3532
|
+
useEffect4(() => {
|
|
3533
|
+
const popup = popupRef.current;
|
|
3534
|
+
if (!popup?.showPopover || !popup?.hidePopover)
|
|
3535
|
+
return;
|
|
3536
|
+
if (visible && !popup.matches(":popover-open"))
|
|
3537
|
+
popup.showPopover();
|
|
3538
|
+
if (!visible && popup.matches(":popover-open"))
|
|
3539
|
+
popup.hidePopover();
|
|
3540
|
+
}, [visible]);
|
|
3541
|
+
function setVisible(nextOpen) {
|
|
3542
|
+
if (open === undefined)
|
|
3543
|
+
setInternalOpen(nextOpen);
|
|
3544
|
+
onOpenChange?.(nextOpen);
|
|
2692
3545
|
}
|
|
2693
|
-
function
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
const expandableRow = expandable.rowExpandable?.(record) ?? true;
|
|
2700
|
-
return /* @__PURE__ */ jsx11("td", {
|
|
2701
|
-
className: cn(tableCellClass, tableExpandCellClass),
|
|
2702
|
-
children: expandableRow ? /* @__PURE__ */ jsx11("button", {
|
|
2703
|
-
type: "button",
|
|
2704
|
-
className: tableExpandButtonClass,
|
|
2705
|
-
"aria-label": `${expanded ? "Collapse" : "Expand"} row ${index + 1}`,
|
|
2706
|
-
onClick: () => toggleExpand(record, index),
|
|
2707
|
-
children: expanded ? "-" : "+"
|
|
2708
|
-
}) : null
|
|
2709
|
-
});
|
|
3546
|
+
function close() {
|
|
3547
|
+
const popup = popupRef.current;
|
|
3548
|
+
if (popup?.matches(":popover-open"))
|
|
3549
|
+
popup.hidePopover();
|
|
3550
|
+
else
|
|
3551
|
+
setVisible(false);
|
|
2710
3552
|
}
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
3553
|
+
const menuNode = overlay ?? (menu?.items ? /* @__PURE__ */ jsx12("ul", {
|
|
3554
|
+
className: dropdownMenuClass,
|
|
3555
|
+
children: menu.items.map((item) => renderMenuItem(item, menu.onClick, close))
|
|
3556
|
+
}) : null);
|
|
3557
|
+
const popup = dropdownRender ? dropdownRender(menuNode) : menuNode;
|
|
3558
|
+
const show = () => !disabled && popupRef.current?.showPopover?.();
|
|
3559
|
+
const hide = () => !disabled && popupRef.current?.hidePopover?.();
|
|
3560
|
+
const toggle = () => {
|
|
3561
|
+
if (disabled)
|
|
3562
|
+
return;
|
|
3563
|
+
if (popupRef.current?.matches(":popover-open"))
|
|
3564
|
+
hide();
|
|
3565
|
+
else
|
|
3566
|
+
show();
|
|
3567
|
+
};
|
|
3568
|
+
const childIsButton = isValidElement(children) && (children.type === "button" || children.type === Button);
|
|
3569
|
+
const triggerNode = isValidElement(children) ? cloneElement(children, {
|
|
3570
|
+
popoverTarget: childIsButton && clickTrigger && !disabled ? popupId : undefined,
|
|
3571
|
+
style: {
|
|
3572
|
+
...children.props.style,
|
|
3573
|
+
anchorName
|
|
3574
|
+
},
|
|
3575
|
+
"aria-controls": popupId,
|
|
3576
|
+
"aria-expanded": nativeOpen,
|
|
3577
|
+
disabled: disabled || children.props.disabled,
|
|
3578
|
+
onMouseEnter: (event) => {
|
|
3579
|
+
callHandler(children.props.onMouseEnter, event);
|
|
3580
|
+
if (trigger.includes("hover"))
|
|
3581
|
+
show();
|
|
3582
|
+
onMouseEnter?.(event);
|
|
3583
|
+
},
|
|
3584
|
+
onMouseLeave: (event) => {
|
|
3585
|
+
callHandler(children.props.onMouseLeave, event);
|
|
3586
|
+
onMouseLeave?.(event);
|
|
3587
|
+
},
|
|
3588
|
+
onClick: (event) => {
|
|
3589
|
+
callHandler(children.props.onClick, event);
|
|
3590
|
+
onClick?.(event);
|
|
3591
|
+
if (!childIsButton && clickTrigger && !event.defaultPrevented)
|
|
3592
|
+
toggle();
|
|
3593
|
+
},
|
|
3594
|
+
onContextMenu: (event) => {
|
|
3595
|
+
callHandler(children.props.onContextMenu, event);
|
|
3596
|
+
if (trigger.includes("contextMenu")) {
|
|
3597
|
+
event.preventDefault();
|
|
3598
|
+
toggle();
|
|
3599
|
+
}
|
|
3600
|
+
onContextMenu?.(event);
|
|
2730
3601
|
}
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
children: expandable?.columnTitle
|
|
2756
|
-
}) : null,
|
|
2757
|
-
row.map(renderHeaderCell)
|
|
2758
|
-
]
|
|
2759
|
-
}, rowIndex))
|
|
2760
|
-
}),
|
|
2761
|
-
/* @__PURE__ */ jsx11("tbody", {
|
|
2762
|
-
children: bodyEmpty ? /* @__PURE__ */ jsx11("tr", {
|
|
2763
|
-
children: /* @__PURE__ */ jsx11("td", {
|
|
2764
|
-
className: tableEmptyClass,
|
|
2765
|
-
colSpan: structuralColumnCount,
|
|
2766
|
-
children: locale?.emptyText ?? "No data"
|
|
2767
|
-
})
|
|
2768
|
-
}) : pageData.map(renderRow)
|
|
2769
|
-
}),
|
|
2770
|
-
renderSummary(summary, pageData, structuralColumnCount)
|
|
2771
|
-
]
|
|
3602
|
+
}) : /* @__PURE__ */ jsx12("button", {
|
|
3603
|
+
type: "button",
|
|
3604
|
+
disabled,
|
|
3605
|
+
popoverTarget: clickTrigger && !disabled ? popupId : undefined,
|
|
3606
|
+
style: { anchorName },
|
|
3607
|
+
"aria-controls": popupId,
|
|
3608
|
+
"aria-expanded": nativeOpen,
|
|
3609
|
+
onMouseEnter: (event) => {
|
|
3610
|
+
if (trigger.includes("hover"))
|
|
3611
|
+
show();
|
|
3612
|
+
onMouseEnter?.(event);
|
|
3613
|
+
},
|
|
3614
|
+
onMouseLeave: (event) => {
|
|
3615
|
+
onMouseLeave?.(event);
|
|
3616
|
+
},
|
|
3617
|
+
onClick,
|
|
3618
|
+
onContextMenu: (event) => {
|
|
3619
|
+
if (trigger.includes("contextMenu")) {
|
|
3620
|
+
event.preventDefault();
|
|
3621
|
+
toggle();
|
|
3622
|
+
}
|
|
3623
|
+
onContextMenu?.(event);
|
|
3624
|
+
},
|
|
3625
|
+
children
|
|
2772
3626
|
});
|
|
2773
|
-
return /* @__PURE__ */
|
|
3627
|
+
return /* @__PURE__ */ jsxs11("span", {
|
|
2774
3628
|
...props,
|
|
2775
3629
|
ref,
|
|
2776
|
-
className:
|
|
3630
|
+
className: cn(dropdownWrapperClass, dropdownPlacementClasses[placement]),
|
|
3631
|
+
onMouseLeave: trigger.includes("hover") ? hide : undefined,
|
|
2777
3632
|
children: [
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
3633
|
+
triggerNode,
|
|
3634
|
+
/* @__PURE__ */ jsxs11("span", {
|
|
3635
|
+
id: popupId,
|
|
3636
|
+
ref: popupRef,
|
|
3637
|
+
popover: "auto",
|
|
3638
|
+
style: { positionAnchor: anchorName },
|
|
3639
|
+
className: getDropdownClasses({ className, arrow }),
|
|
3640
|
+
onToggle: (event) => {
|
|
3641
|
+
if (event.target !== event.currentTarget)
|
|
3642
|
+
return;
|
|
3643
|
+
const nextOpen = event.nativeEvent.newState === "open";
|
|
3644
|
+
setNativeOpen(nextOpen);
|
|
3645
|
+
setVisible(nextOpen);
|
|
2783
3646
|
},
|
|
2784
|
-
children: tableNode
|
|
2785
|
-
}) : tableNode,
|
|
2786
|
-
spinning ? /* @__PURE__ */ jsx11("div", {
|
|
2787
|
-
className: tableLoadingIndicatorClass,
|
|
2788
|
-
role: "status",
|
|
2789
|
-
children: typeof loading === "object" && loading.indicator ? loading.indicator : "Loading"
|
|
2790
|
-
}) : null,
|
|
2791
|
-
paginationConfig && !(paginationConfig.hideOnSinglePage && pageCount <= 1) ? /* @__PURE__ */ jsxs10("nav", {
|
|
2792
|
-
className: tablePaginationClass,
|
|
2793
|
-
"aria-label": "Table pagination",
|
|
2794
3647
|
children: [
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
className:
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
3648
|
+
!destroyPopupOnHide || visible ? popup : null,
|
|
3649
|
+
arrow ? /* @__PURE__ */ jsx12("span", {
|
|
3650
|
+
className: dropdownArrowClass
|
|
3651
|
+
}) : null
|
|
3652
|
+
]
|
|
3653
|
+
})
|
|
3654
|
+
]
|
|
3655
|
+
});
|
|
3656
|
+
});
|
|
3657
|
+
DropdownRoot.displayName = "Dropdown";
|
|
3658
|
+
var DropdownButton = forwardRef9(({
|
|
3659
|
+
buttonsRender,
|
|
3660
|
+
children,
|
|
3661
|
+
disabled,
|
|
3662
|
+
menu,
|
|
3663
|
+
onClick,
|
|
3664
|
+
trigger = ["click"],
|
|
3665
|
+
color = "base",
|
|
3666
|
+
appearance = "outline",
|
|
3667
|
+
size,
|
|
3668
|
+
shape,
|
|
3669
|
+
block,
|
|
3670
|
+
isLoading,
|
|
3671
|
+
leftIcon,
|
|
3672
|
+
rightIcon,
|
|
3673
|
+
confirm,
|
|
3674
|
+
...props
|
|
3675
|
+
}, ref) => {
|
|
3676
|
+
const buttonStyle = { color, appearance, size, shape };
|
|
3677
|
+
const buttons = [
|
|
3678
|
+
/* @__PURE__ */ jsx12(Button, {
|
|
3679
|
+
...buttonStyle,
|
|
3680
|
+
disabled,
|
|
3681
|
+
isLoading,
|
|
3682
|
+
leftIcon,
|
|
3683
|
+
rightIcon,
|
|
3684
|
+
confirm,
|
|
3685
|
+
onClick,
|
|
3686
|
+
children
|
|
3687
|
+
}, "primary"),
|
|
3688
|
+
/* @__PURE__ */ jsx12(Button, {
|
|
3689
|
+
...buttonStyle,
|
|
3690
|
+
type: "button",
|
|
3691
|
+
"aria-label": "Open dropdown",
|
|
3692
|
+
disabled: disabled || isLoading,
|
|
3693
|
+
children: /* @__PURE__ */ jsxs11("svg", {
|
|
3694
|
+
"aria-hidden": "true",
|
|
3695
|
+
width: "18",
|
|
3696
|
+
height: "18",
|
|
3697
|
+
viewBox: "0 0 24 24",
|
|
3698
|
+
fill: "currentColor",
|
|
3699
|
+
children: [
|
|
3700
|
+
/* @__PURE__ */ jsx12("circle", {
|
|
3701
|
+
cx: "5",
|
|
3702
|
+
cy: "12",
|
|
3703
|
+
r: "1.75"
|
|
2801
3704
|
}),
|
|
2802
|
-
/* @__PURE__ */
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
Math.min(current * pageSize, sortedData.length)
|
|
2807
|
-
]) : `${current} / ${pageCount}`
|
|
3705
|
+
/* @__PURE__ */ jsx12("circle", {
|
|
3706
|
+
cx: "12",
|
|
3707
|
+
cy: "12",
|
|
3708
|
+
r: "1.75"
|
|
2808
3709
|
}),
|
|
2809
|
-
/* @__PURE__ */
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
onClick: () => changePage(current + 1),
|
|
2814
|
-
children: "Next"
|
|
3710
|
+
/* @__PURE__ */ jsx12("circle", {
|
|
3711
|
+
cx: "19",
|
|
3712
|
+
cy: "12",
|
|
3713
|
+
r: "1.75"
|
|
2815
3714
|
})
|
|
2816
3715
|
]
|
|
2817
|
-
})
|
|
3716
|
+
})
|
|
3717
|
+
}, "trigger")
|
|
3718
|
+
];
|
|
3719
|
+
const renderedButtons = buttonsRender ? buttonsRender(buttons) : buttons;
|
|
3720
|
+
return /* @__PURE__ */ jsxs11("span", {
|
|
3721
|
+
ref,
|
|
3722
|
+
className: cn(dropdownButtonClass, block && "dropdown-button-block"),
|
|
3723
|
+
children: [
|
|
3724
|
+
renderedButtons[0],
|
|
3725
|
+
/* @__PURE__ */ jsx12(DropdownRoot, {
|
|
3726
|
+
...props,
|
|
3727
|
+
menu,
|
|
3728
|
+
trigger,
|
|
3729
|
+
disabled: disabled || isLoading,
|
|
3730
|
+
children: renderedButtons[1]
|
|
3731
|
+
})
|
|
2818
3732
|
]
|
|
2819
3733
|
});
|
|
2820
|
-
}
|
|
2821
|
-
var TableWithRef = forwardRef8(TableRoot);
|
|
2822
|
-
var Table = Object.assign(TableWithRef, {
|
|
2823
|
-
Column,
|
|
2824
|
-
ColumnGroup,
|
|
2825
|
-
Summary,
|
|
2826
|
-
SELECTION_ALL: "SELECT_ALL",
|
|
2827
|
-
SELECTION_INVERT: "SELECT_INVERT",
|
|
2828
|
-
SELECTION_NONE: "SELECT_NONE",
|
|
2829
|
-
SELECTION_COLUMN: "SELECTION_COLUMN",
|
|
2830
|
-
EXPAND_COLUMN: "EXPAND_COLUMN"
|
|
2831
3734
|
});
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
// src/
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
var dmTableHeaderClass = "dm-table-header";
|
|
2841
|
-
var dmTableTitleClass = "dm-table-title";
|
|
2842
|
-
var dmTableExtraClass = "dm-table-extra";
|
|
2843
|
-
var dmTableIndicatorsClass = "dm-table-indicators";
|
|
2844
|
-
var dmTableTableExtraClass = "dm-table-table-extra";
|
|
2845
|
-
var dmTableColumnSettingClass = "dm-table-column-setting";
|
|
2846
|
-
var dmTablePaginationClass = "dm-table-pagination";
|
|
2847
|
-
function getDmTableClasses({ className }) {
|
|
2848
|
-
return cn(dmTableBaseClass, className);
|
|
2849
|
-
}
|
|
2850
|
-
|
|
2851
|
-
// src/components/dm-table/DmTable.tsx
|
|
2852
|
-
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2853
|
-
function mapAndFilter(list, mapper) {
|
|
2854
|
-
return list.map(mapper).filter((item) => item !== false && item != null);
|
|
2855
|
-
}
|
|
2856
|
-
function filterDmTableColumn(column) {
|
|
2857
|
-
if (column.onlySearch || column.hideInTable)
|
|
2858
|
-
return false;
|
|
2859
|
-
if (Array.isArray(column.children)) {
|
|
2860
|
-
const children = mapAndFilter(column.children, filterDmTableColumn);
|
|
2861
|
-
return children.length > 0 ? { ...column, children } : null;
|
|
2862
|
-
}
|
|
2863
|
-
return column;
|
|
2864
|
-
}
|
|
2865
|
-
function filterSearchColumn(column) {
|
|
2866
|
-
if (Array.isArray(column.children)) {
|
|
2867
|
-
const children = mapAndFilter(column.children, filterSearchColumn);
|
|
2868
|
-
return children.length > 0 ? { ...column, children } : null;
|
|
2869
|
-
}
|
|
2870
|
-
return column.search ? column : false;
|
|
3735
|
+
DropdownButton.displayName = "Dropdown.Button";
|
|
3736
|
+
var Dropdown = Object.assign(DropdownRoot, {
|
|
3737
|
+
Button: DropdownButton
|
|
3738
|
+
});
|
|
3739
|
+
// src/components/dm-toolbar/DmToolbar.tsx
|
|
3740
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3741
|
+
function isPrimary(item) {
|
|
3742
|
+
return item.type === "primary";
|
|
2871
3743
|
}
|
|
2872
|
-
function
|
|
2873
|
-
|
|
3744
|
+
function renderToolbarItem(item, index) {
|
|
3745
|
+
const {
|
|
3746
|
+
title,
|
|
3747
|
+
menu,
|
|
3748
|
+
type,
|
|
3749
|
+
htmlType = "button",
|
|
3750
|
+
color,
|
|
3751
|
+
appearance,
|
|
3752
|
+
...buttonPropsWithKey
|
|
3753
|
+
} = item;
|
|
3754
|
+
const buttonProps = { ...buttonPropsWithKey };
|
|
3755
|
+
delete buttonProps.key;
|
|
3756
|
+
const button = /* @__PURE__ */ jsx13(Button, {
|
|
3757
|
+
...buttonProps,
|
|
3758
|
+
type: htmlType,
|
|
3759
|
+
color: color ?? (type === "primary" ? "primary" : "secondary"),
|
|
3760
|
+
appearance: appearance ?? (type === "primary" ? "filled" : "outline"),
|
|
3761
|
+
children: title
|
|
3762
|
+
});
|
|
3763
|
+
if (!menu?.items?.length)
|
|
3764
|
+
return button;
|
|
3765
|
+
return /* @__PURE__ */ jsx13(Dropdown, {
|
|
3766
|
+
trigger: ["click"],
|
|
3767
|
+
menu,
|
|
3768
|
+
children: button
|
|
3769
|
+
}, `dropdown-${index}`);
|
|
2874
3770
|
}
|
|
2875
|
-
function
|
|
2876
|
-
return
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
3771
|
+
function toOverflowMenu(items) {
|
|
3772
|
+
return {
|
|
3773
|
+
items: items.map((item, index) => ({
|
|
3774
|
+
key: item.key ?? index,
|
|
3775
|
+
label: item.title,
|
|
3776
|
+
disabled: item.disabled
|
|
3777
|
+
})),
|
|
3778
|
+
onClick: ({ key, domEvent }) => {
|
|
3779
|
+
const target = items.find((item, index) => String(item.key ?? index) === key);
|
|
3780
|
+
target?.onClick?.(domEvent);
|
|
2884
3781
|
}
|
|
2885
|
-
}
|
|
3782
|
+
};
|
|
2886
3783
|
}
|
|
2887
|
-
function
|
|
2888
|
-
|
|
2889
|
-
extra,
|
|
2890
|
-
indicators,
|
|
2891
|
-
pagination,
|
|
2892
|
-
columns: inputColumns,
|
|
2893
|
-
columnSettingVisible = true,
|
|
2894
|
-
onColumnsChange,
|
|
2895
|
-
columnState,
|
|
2896
|
-
searchProps,
|
|
2897
|
-
tableExtra,
|
|
3784
|
+
function DmToolbar({
|
|
3785
|
+
items = [],
|
|
2898
3786
|
className,
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
3787
|
+
style,
|
|
3788
|
+
moreText = "More",
|
|
3789
|
+
maxVisibleSecondaryItems
|
|
2902
3790
|
}) {
|
|
2903
|
-
const
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
globalThis.localStorage?.removeItem(columnState.persistenceKey);
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
return /* @__PURE__ */ jsxs11("div", {
|
|
2919
|
-
className: getDmTableClasses({ className }),
|
|
3791
|
+
const { visibleSecondaryItems, overflowSecondaryItems, primaryItems } = useMemo9(() => {
|
|
3792
|
+
const primaryItems = items.filter(isPrimary);
|
|
3793
|
+
const secondaryItems = items.filter((item) => !isPrimary(item));
|
|
3794
|
+
const visibleLimit = maxVisibleSecondaryItems === undefined ? secondaryItems.length : Math.max(0, maxVisibleSecondaryItems);
|
|
3795
|
+
const visibleSecondaryItems = visibleLimit === 0 ? [] : secondaryItems.slice(-visibleLimit);
|
|
3796
|
+
const overflowSecondaryItems = visibleLimit >= secondaryItems.length ? [] : secondaryItems.slice(0, secondaryItems.length - visibleLimit);
|
|
3797
|
+
return { visibleSecondaryItems, overflowSecondaryItems, primaryItems };
|
|
3798
|
+
}, [items, maxVisibleSecondaryItems]);
|
|
3799
|
+
const showMore = overflowSecondaryItems.length > 0;
|
|
3800
|
+
return /* @__PURE__ */ jsxs12("div", {
|
|
3801
|
+
className: getDmToolbarClasses({ className }),
|
|
3802
|
+
style,
|
|
2920
3803
|
children: [
|
|
2921
|
-
|
|
2922
|
-
className:
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
3804
|
+
visibleSecondaryItems.map((item, index) => /* @__PURE__ */ jsx13("span", {
|
|
3805
|
+
className: getDmToolbarItemClasses({}),
|
|
3806
|
+
children: renderToolbarItem(item, index)
|
|
3807
|
+
}, item.key ?? `secondary-${index}`)),
|
|
3808
|
+
showMore ? /* @__PURE__ */ jsx13(Dropdown, {
|
|
3809
|
+
trigger: ["click"],
|
|
3810
|
+
menu: toOverflowMenu(overflowSecondaryItems),
|
|
3811
|
+
children: /* @__PURE__ */ jsx13(Button, {
|
|
3812
|
+
type: "button",
|
|
3813
|
+
className: dmToolbarMoreClass,
|
|
3814
|
+
color: "secondary",
|
|
3815
|
+
appearance: "outline",
|
|
3816
|
+
children: moreText
|
|
2927
3817
|
})
|
|
2928
3818
|
}) : null,
|
|
2929
|
-
|
|
2930
|
-
className:
|
|
2931
|
-
children:
|
|
2932
|
-
}
|
|
2933
|
-
/* @__PURE__ */ jsxs11(Card, {
|
|
2934
|
-
className: dmTableCardClass,
|
|
2935
|
-
padding: "md",
|
|
2936
|
-
children: [
|
|
2937
|
-
name || extra || columnSettingVisible ? /* @__PURE__ */ jsxs11("div", {
|
|
2938
|
-
className: dmTableHeaderClass,
|
|
2939
|
-
children: [
|
|
2940
|
-
/* @__PURE__ */ jsx12("div", {
|
|
2941
|
-
className: dmTableTitleClass,
|
|
2942
|
-
children: name
|
|
2943
|
-
}),
|
|
2944
|
-
/* @__PURE__ */ jsxs11("div", {
|
|
2945
|
-
className: dmTableExtraClass,
|
|
2946
|
-
children: [
|
|
2947
|
-
extra,
|
|
2948
|
-
columnSettingVisible ? /* @__PURE__ */ jsx12(Button, {
|
|
2949
|
-
type: "button",
|
|
2950
|
-
color: "secondary",
|
|
2951
|
-
appearance: "outline",
|
|
2952
|
-
className: dmTableColumnSettingClass,
|
|
2953
|
-
onClick: () => setColumnSettingsOpen((open) => !open),
|
|
2954
|
-
children: "Columns"
|
|
2955
|
-
}) : null
|
|
2956
|
-
]
|
|
2957
|
-
})
|
|
2958
|
-
]
|
|
2959
|
-
}) : null,
|
|
2960
|
-
columnSettingsOpen ? /* @__PURE__ */ jsx12("div", {
|
|
2961
|
-
role: "dialog",
|
|
2962
|
-
"aria-label": "Column settings",
|
|
2963
|
-
children: /* @__PURE__ */ jsx12(Button, {
|
|
2964
|
-
type: "button",
|
|
2965
|
-
onClick: resetColumns,
|
|
2966
|
-
children: "Reset columns"
|
|
2967
|
-
})
|
|
2968
|
-
}) : null,
|
|
2969
|
-
tableExtra ? /* @__PURE__ */ jsx12("div", {
|
|
2970
|
-
className: dmTableTableExtraClass,
|
|
2971
|
-
children: tableExtra
|
|
2972
|
-
}) : null,
|
|
2973
|
-
/* @__PURE__ */ jsx12(Table, {
|
|
2974
|
-
...props,
|
|
2975
|
-
dataSource,
|
|
2976
|
-
rowSelection,
|
|
2977
|
-
size: props.size ?? "small",
|
|
2978
|
-
scroll: props.scroll ?? { x: 680 },
|
|
2979
|
-
columns,
|
|
2980
|
-
pagination: pagination ? {
|
|
2981
|
-
current: paginationObj?.current,
|
|
2982
|
-
defaultCurrent: paginationObj?.defaultCurrent,
|
|
2983
|
-
pageSize: paginationObj?.pageSize,
|
|
2984
|
-
defaultPageSize: paginationObj?.defaultPageSize,
|
|
2985
|
-
total,
|
|
2986
|
-
onChange: paginationObj?.onChange
|
|
2987
|
-
} : false
|
|
2988
|
-
}),
|
|
2989
|
-
pagination ? /* @__PURE__ */ jsx12(DmPagination, {
|
|
2990
|
-
...paginationProps,
|
|
2991
|
-
className: dmTablePaginationClass,
|
|
2992
|
-
total,
|
|
2993
|
-
selectedTotal,
|
|
2994
|
-
showSizeChanger: true
|
|
2995
|
-
}) : null
|
|
2996
|
-
]
|
|
2997
|
-
})
|
|
3819
|
+
primaryItems.map((item, index) => /* @__PURE__ */ jsx13("span", {
|
|
3820
|
+
className: getDmToolbarItemClasses({ primary: true }),
|
|
3821
|
+
children: renderToolbarItem(item, index)
|
|
3822
|
+
}, item.key ?? `primary-${index}`))
|
|
2998
3823
|
]
|
|
2999
3824
|
});
|
|
3000
3825
|
}
|
|
3001
|
-
|
|
3002
|
-
// src/classes/dm-pro-table.ts
|
|
3003
|
-
var dmProTableBaseClass = "dm-pro-table";
|
|
3004
|
-
var dmProTableHeaderClass = "dm-pro-table-header";
|
|
3005
|
-
var dmProTableTitleClass = "dm-pro-table-title";
|
|
3006
|
-
var dmProTableToolbarClass = "dm-pro-table-toolbar";
|
|
3007
|
-
var dmProTableColumnSettingClass = "dm-pro-table-column-setting";
|
|
3008
|
-
function getDmProTableClasses({ className }) {
|
|
3009
|
-
return cn(dmProTableBaseClass, className);
|
|
3010
|
-
}
|
|
3011
|
-
|
|
3826
|
+
DmToolbar.displayName = "DmToolbar";
|
|
3012
3827
|
// src/components/dm-pro-table/DmProTable.tsx
|
|
3013
|
-
import { jsx as
|
|
3828
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3014
3829
|
function renderToolbar(toolBarRender) {
|
|
3015
3830
|
if (typeof toolBarRender === "function")
|
|
3016
3831
|
return toolBarRender();
|
|
@@ -3026,23 +3841,23 @@ function DmProTable({
|
|
|
3026
3841
|
rowData,
|
|
3027
3842
|
...props
|
|
3028
3843
|
}) {
|
|
3029
|
-
return /* @__PURE__ */
|
|
3844
|
+
return /* @__PURE__ */ jsxs13("div", {
|
|
3030
3845
|
className: getDmProTableClasses({ className }),
|
|
3031
3846
|
children: [
|
|
3032
|
-
showTitleBar ? /* @__PURE__ */
|
|
3847
|
+
showTitleBar ? /* @__PURE__ */ jsxs13("div", {
|
|
3033
3848
|
className: dmProTableHeaderClass,
|
|
3034
3849
|
children: [
|
|
3035
|
-
/* @__PURE__ */
|
|
3850
|
+
/* @__PURE__ */ jsx14("div", {
|
|
3036
3851
|
className: dmProTableTitleClass,
|
|
3037
3852
|
children: headerTitle
|
|
3038
3853
|
}),
|
|
3039
|
-
/* @__PURE__ */
|
|
3854
|
+
/* @__PURE__ */ jsxs13("div", {
|
|
3040
3855
|
className: dmProTableToolbarClass,
|
|
3041
3856
|
children: [
|
|
3042
|
-
toolbarItems?.length ? /* @__PURE__ */
|
|
3857
|
+
toolbarItems?.length ? /* @__PURE__ */ jsx14(DmToolbar, {
|
|
3043
3858
|
items: toolbarItems
|
|
3044
3859
|
}) : renderToolbar(toolBarRender),
|
|
3045
|
-
columnSettingVisible ? /* @__PURE__ */
|
|
3860
|
+
columnSettingVisible ? /* @__PURE__ */ jsx14(Button, {
|
|
3046
3861
|
type: "button",
|
|
3047
3862
|
color: "secondary",
|
|
3048
3863
|
appearance: "outline",
|
|
@@ -3053,7 +3868,7 @@ function DmProTable({
|
|
|
3053
3868
|
})
|
|
3054
3869
|
]
|
|
3055
3870
|
}) : null,
|
|
3056
|
-
/* @__PURE__ */
|
|
3871
|
+
/* @__PURE__ */ jsx14(DmTable, {
|
|
3057
3872
|
...props,
|
|
3058
3873
|
columnSettingVisible: showTitleBar ? false : columnSettingVisible,
|
|
3059
3874
|
dataSource: rowData
|