@duskmoon-dev/components 0.3.1 → 0.3.3
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 +2 -2
- package/dist/{chunk-r9wkv7xd.js → chunk-fwjzvsrx.js} +3 -3
- package/dist/classes/chat.d.ts +35 -0
- package/dist/classes/index.d.ts +1 -0
- package/dist/classes/index.js +1271 -1184
- package/dist/components/anchor/index.js +2 -2
- package/dist/components/app/index.js +85 -85
- package/dist/components/cascader/index.js +2 -2
- package/dist/components/chat/Chat.d.ts +14 -0
- package/dist/components/chat/Chat.types.d.ts +47 -0
- package/dist/components/chat/index.d.ts +2 -0
- package/dist/components/chat/index.js +220 -0
- package/dist/components/color-picker/index.js +4 -4
- package/dist/components/config-provider/index.js +2 -2
- package/dist/components/dm-breadcrumb/index.js +18 -18
- package/dist/components/dm-date-picker/index.js +94 -94
- package/dist/components/dm-drawer/index.js +16 -16
- package/dist/components/dm-layout/index.js +189 -189
- package/dist/components/dm-menu/index.js +24 -24
- package/dist/components/dm-message/index.js +18 -18
- package/dist/components/dm-page-header/index.js +158 -158
- package/dist/components/dm-pagination/index.js +39 -39
- package/dist/components/dm-pro-table/index.js +1558 -1558
- package/dist/components/dm-provider/index.js +94 -94
- package/dist/components/dm-query/index.js +33 -31
- package/dist/components/dm-search/index.js +25 -25
- 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 +595 -595
- package/dist/components/dm-tabs/index.js +34 -34
- package/dist/components/dm-toolbar/index.js +23 -23
- package/dist/components/dm-tree/index.js +92 -92
- package/dist/components/dm-truncate/index.js +33 -33
- package/dist/components/dropdown/index.js +83 -83
- package/dist/components/form/index.js +2 -2
- 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/message/index.js +5 -5
- package/dist/components/notification/index.js +2 -2
- package/dist/components/popconfirm/index.js +42 -42
- 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/table/index.js +2 -2
- package/dist/components/tabs/index.js +2 -2
- package/dist/components/tag/index.js +2 -2
- package/dist/components/tour/index.js +62 -62
- package/dist/components/typography/index.js +4 -4
- package/dist/components/upload/index.js +5 -5
- package/dist/generated/version.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1716 -1525
- package/dist/infrastructure.js +11 -11
- package/dist/styles.css +13430 -9848
- package/dist/theme/index.js +3 -3
- package/dist/utils/index.js +5 -5
- package/package.json +10 -6
|
@@ -25,6 +25,16 @@ 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
|
+
|
|
28
38
|
// src/classes/button.ts
|
|
29
39
|
var buttonBaseClass = "btn";
|
|
30
40
|
var buttonColorClasses = {
|
|
@@ -123,6 +133,24 @@ function Button({
|
|
|
123
133
|
]
|
|
124
134
|
});
|
|
125
135
|
}
|
|
136
|
+
// src/components/dm-table/DmTable.tsx
|
|
137
|
+
import { useMemo as useMemo7, useState as useState8 } from "react";
|
|
138
|
+
|
|
139
|
+
// src/classes/dm-table.ts
|
|
140
|
+
var dmTableBaseClass = "dm-table";
|
|
141
|
+
var dmTableSearchClass = "dm-table-search";
|
|
142
|
+
var dmTableCardClass = "dm-table-card";
|
|
143
|
+
var dmTableHeaderClass = "dm-table-header";
|
|
144
|
+
var dmTableTitleClass = "dm-table-title";
|
|
145
|
+
var dmTableExtraClass = "dm-table-extra";
|
|
146
|
+
var dmTableIndicatorsClass = "dm-table-indicators";
|
|
147
|
+
var dmTableTableExtraClass = "dm-table-table-extra";
|
|
148
|
+
var dmTableColumnSettingClass = "dm-table-column-setting";
|
|
149
|
+
var dmTablePaginationClass = "dm-table-pagination";
|
|
150
|
+
function getDmTableClasses({ className }) {
|
|
151
|
+
return cn(dmTableBaseClass, className);
|
|
152
|
+
}
|
|
153
|
+
|
|
126
154
|
// src/classes/card.ts
|
|
127
155
|
var cardBaseClass = "card";
|
|
128
156
|
var cardAppearanceClasses = {
|
|
@@ -166,1388 +194,1020 @@ function Card({
|
|
|
166
194
|
children
|
|
167
195
|
});
|
|
168
196
|
}
|
|
169
|
-
// src/components/
|
|
170
|
-
import {
|
|
197
|
+
// src/components/dm-pagination/DmPagination.tsx
|
|
198
|
+
import {
|
|
199
|
+
forwardRef as forwardRef2,
|
|
200
|
+
useEffect,
|
|
201
|
+
useMemo as useMemo2,
|
|
202
|
+
useRef,
|
|
203
|
+
useState as useState2
|
|
204
|
+
} from "react";
|
|
171
205
|
|
|
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"
|
|
206
|
+
// src/classes/dm-pagination.ts
|
|
207
|
+
var dmPaginationBaseClass = "dm-pagination";
|
|
208
|
+
var dmPaginationHiddenClass = "dm-pagination-hidden";
|
|
209
|
+
var dmPaginationPagerClass = "dm-pagination-pager";
|
|
210
|
+
var dmPaginationRefreshClass = "dm-pagination-refresh";
|
|
211
|
+
var dmPaginationRefreshLoadingClass = "dm-pagination-refresh-loading";
|
|
212
|
+
var dmPaginationSelectedClass = "dm-pagination-selected";
|
|
213
|
+
var dmPaginationAlignClasses = {
|
|
214
|
+
left: "dm-pagination-left",
|
|
215
|
+
center: "dm-pagination-center",
|
|
216
|
+
right: "dm-pagination-right"
|
|
191
217
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
218
|
+
function getDmPaginationClasses({
|
|
219
|
+
align = "right",
|
|
220
|
+
hidden,
|
|
221
|
+
className
|
|
222
|
+
}) {
|
|
223
|
+
return cn(dmPaginationBaseClass, dmPaginationAlignClasses[align], hidden && dmPaginationHiddenClass, className);
|
|
224
|
+
}
|
|
225
|
+
function getDmPaginationRefreshClasses({
|
|
226
|
+
loading,
|
|
227
|
+
className
|
|
228
|
+
}) {
|
|
229
|
+
return cn(dmPaginationRefreshClass, loading && dmPaginationRefreshLoadingClass, className);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/components/pagination/Pagination.tsx
|
|
233
|
+
import {
|
|
234
|
+
forwardRef,
|
|
235
|
+
useMemo,
|
|
236
|
+
useState
|
|
237
|
+
} from "react";
|
|
238
|
+
|
|
239
|
+
// src/classes/pagination.ts
|
|
240
|
+
var paginationBaseClass = "pagination";
|
|
241
|
+
var paginationItemClass = "pagination-item";
|
|
242
|
+
var paginationItemActiveClass = "pagination-item-active";
|
|
243
|
+
var paginationItemDisabledClass = "pagination-item-disabled";
|
|
244
|
+
var paginationPrevClass = "pagination-prev";
|
|
245
|
+
var paginationNextClass = "pagination-next";
|
|
246
|
+
var paginationEllipsisClass = "pagination-ellipsis";
|
|
247
|
+
var paginationCompactClass = "pagination-compact";
|
|
248
|
+
var paginationInfoClass = "pagination-info";
|
|
249
|
+
var paginationInfoTextClass = "pagination-info-text";
|
|
250
|
+
var paginationInputClass = "pagination-input";
|
|
251
|
+
var paginationResponsiveClass = "pagination-responsive";
|
|
252
|
+
var paginationSizeClasses = {
|
|
253
|
+
sm: "pagination-sm",
|
|
254
|
+
md: "",
|
|
255
|
+
lg: "pagination-lg"
|
|
199
256
|
};
|
|
200
|
-
function
|
|
257
|
+
function getPaginationClasses({
|
|
201
258
|
size = "md",
|
|
202
|
-
|
|
203
|
-
picker = "date",
|
|
204
|
-
open,
|
|
205
|
-
disabled,
|
|
206
|
-
range,
|
|
259
|
+
compact,
|
|
207
260
|
className
|
|
208
261
|
}) {
|
|
209
|
-
return cn(
|
|
262
|
+
return cn(paginationBaseClass, paginationResponsiveClass, paginationSizeClasses[size], compact && paginationCompactClass, className);
|
|
210
263
|
}
|
|
211
|
-
function
|
|
212
|
-
|
|
213
|
-
|
|
264
|
+
function getPaginationItemClasses({
|
|
265
|
+
active,
|
|
266
|
+
disabled
|
|
214
267
|
}) {
|
|
215
|
-
return cn(
|
|
268
|
+
return cn(paginationItemClass, active && paginationItemActiveClass, disabled && paginationItemDisabledClass);
|
|
216
269
|
}
|
|
217
270
|
|
|
218
|
-
// src/components/
|
|
271
|
+
// src/components/pagination/Pagination.tsx
|
|
219
272
|
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}`;
|
|
273
|
+
var defaultPageSizeOptions = [10, 20, 50, 100];
|
|
274
|
+
function toPositiveInteger(value, fallback) {
|
|
275
|
+
if (!Number.isFinite(value) || value === undefined) {
|
|
276
|
+
return fallback;
|
|
277
|
+
}
|
|
278
|
+
return Math.max(1, Math.floor(value));
|
|
232
279
|
}
|
|
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";
|
|
280
|
+
function clampPage(page, pageCount) {
|
|
281
|
+
return Math.min(pageCount, Math.max(1, Math.floor(page)));
|
|
241
282
|
}
|
|
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";
|
|
283
|
+
function getPageCount(total, pageSize) {
|
|
284
|
+
return Math.max(1, Math.ceil(Math.max(0, total) / pageSize));
|
|
254
285
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
286
|
+
function getRange(current, pageSize, total) {
|
|
287
|
+
if (total <= 0) {
|
|
288
|
+
return [0, 0];
|
|
289
|
+
}
|
|
290
|
+
const start = (current - 1) * pageSize + 1;
|
|
291
|
+
const end = Math.min(total, current * pageSize);
|
|
292
|
+
return [start, end];
|
|
257
293
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
294
|
+
function getPageTokens(current, pageCount) {
|
|
295
|
+
if (pageCount <= 7) {
|
|
296
|
+
return Array.from({ length: pageCount }, (_, index) => index + 1);
|
|
297
|
+
}
|
|
298
|
+
const pages = new Set([1, pageCount, current - 1, current, current + 1]);
|
|
299
|
+
if (current <= 4) {
|
|
300
|
+
[2, 3, 4, 5].forEach((page) => pages.add(page));
|
|
301
|
+
}
|
|
302
|
+
if (current >= pageCount - 3) {
|
|
303
|
+
[pageCount - 4, pageCount - 3, pageCount - 2, pageCount - 1].forEach((page) => pages.add(page));
|
|
304
|
+
}
|
|
305
|
+
const sortedPages = Array.from(pages).filter((page) => page >= 1 && page <= pageCount).sort((first, second) => first - second);
|
|
306
|
+
return sortedPages.reduce((tokens, page) => {
|
|
307
|
+
const previous = tokens[tokens.length - 1];
|
|
308
|
+
if (typeof previous === "number") {
|
|
309
|
+
const gap = page - previous;
|
|
310
|
+
if (gap === 2) {
|
|
311
|
+
tokens.push(previous + 1);
|
|
312
|
+
} else if (gap > 2) {
|
|
313
|
+
tokens.push("ellipsis");
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
tokens.push(page);
|
|
317
|
+
return tokens;
|
|
318
|
+
}, []);
|
|
319
|
+
}
|
|
320
|
+
function getSizeOptions(pageSize) {
|
|
321
|
+
return Array.from(new Set([...defaultPageSizeOptions, pageSize])).sort((first, second) => first - second);
|
|
322
|
+
}
|
|
323
|
+
var Pagination = forwardRef(({
|
|
324
|
+
current,
|
|
325
|
+
defaultCurrent = 1,
|
|
326
|
+
pageSize,
|
|
327
|
+
defaultPageSize = 10,
|
|
328
|
+
total = 0,
|
|
266
329
|
onChange,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
presets,
|
|
273
|
-
showNow,
|
|
330
|
+
disabled,
|
|
331
|
+
simple,
|
|
332
|
+
showSizeChanger,
|
|
333
|
+
showQuickJumper,
|
|
334
|
+
showTotal,
|
|
274
335
|
size = "md",
|
|
275
|
-
|
|
276
|
-
value,
|
|
336
|
+
className,
|
|
277
337
|
...props
|
|
278
338
|
}, ref) => {
|
|
279
|
-
const
|
|
280
|
-
const
|
|
281
|
-
const [
|
|
282
|
-
const [
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
339
|
+
const isCurrentControlled = current !== undefined;
|
|
340
|
+
const isPageSizeControlled = pageSize !== undefined;
|
|
341
|
+
const [internalCurrent, setInternalCurrent] = useState(defaultCurrent);
|
|
342
|
+
const [internalPageSize, setInternalPageSize] = useState(defaultPageSize);
|
|
343
|
+
const [quickJumpValue, setQuickJumpValue] = useState("");
|
|
344
|
+
const mergedPageSize = toPositiveInteger(pageSize ?? internalPageSize, defaultPageSize);
|
|
345
|
+
const pageCount = getPageCount(total, mergedPageSize);
|
|
346
|
+
const mergedCurrent = clampPage(toPositiveInteger(current ?? internalCurrent, defaultCurrent), pageCount);
|
|
347
|
+
const pageTokens = useMemo(() => getPageTokens(mergedCurrent, pageCount), [mergedCurrent, pageCount]);
|
|
348
|
+
const range = getRange(mergedCurrent, mergedPageSize, total);
|
|
349
|
+
function changePage(nextPage, nextPageSize = mergedPageSize) {
|
|
350
|
+
const nextPageCount = getPageCount(total, nextPageSize);
|
|
351
|
+
const normalizedPage = clampPage(nextPage, nextPageCount);
|
|
352
|
+
if (!isCurrentControlled) {
|
|
353
|
+
setInternalCurrent(normalizedPage);
|
|
289
354
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
355
|
+
if (!isPageSizeControlled) {
|
|
356
|
+
setInternalPageSize(nextPageSize);
|
|
357
|
+
}
|
|
358
|
+
onChange?.(normalizedPage, nextPageSize);
|
|
359
|
+
}
|
|
360
|
+
function handlePageSizeChange(event) {
|
|
361
|
+
const nextPageSize = toPositiveInteger(Number(event.currentTarget.value), mergedPageSize);
|
|
362
|
+
const nextPage = clampPage(mergedCurrent, getPageCount(total, nextPageSize));
|
|
363
|
+
changePage(nextPage, nextPageSize);
|
|
364
|
+
}
|
|
365
|
+
function jumpToInputPage(value) {
|
|
366
|
+
const nextPage = Number(value);
|
|
367
|
+
if (!Number.isFinite(nextPage)) {
|
|
294
368
|
return;
|
|
295
369
|
}
|
|
296
|
-
|
|
297
|
-
|
|
370
|
+
changePage(nextPage);
|
|
371
|
+
setQuickJumpValue("");
|
|
372
|
+
}
|
|
373
|
+
function handleQuickJumpKeyDown(event) {
|
|
374
|
+
if (event.key !== "Enter") {
|
|
375
|
+
return;
|
|
298
376
|
}
|
|
299
|
-
|
|
377
|
+
jumpToInputPage(event.currentTarget.value);
|
|
300
378
|
}
|
|
301
|
-
const
|
|
302
|
-
|
|
379
|
+
const previousDisabled = disabled || mergedCurrent <= 1;
|
|
380
|
+
const nextDisabled = disabled || mergedCurrent >= pageCount;
|
|
381
|
+
return /* @__PURE__ */ jsxs2("nav", {
|
|
303
382
|
...props,
|
|
304
383
|
ref,
|
|
305
|
-
className:
|
|
306
|
-
size,
|
|
307
|
-
status,
|
|
308
|
-
picker,
|
|
309
|
-
open: visible,
|
|
310
|
-
disabled,
|
|
311
|
-
className
|
|
312
|
-
}),
|
|
384
|
+
className: getPaginationClasses({ size, compact: simple, className }),
|
|
313
385
|
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"
|
|
386
|
+
showTotal ? /* @__PURE__ */ jsx3("div", {
|
|
387
|
+
className: paginationInfoClass,
|
|
388
|
+
children: /* @__PURE__ */ jsx3("span", {
|
|
389
|
+
className: paginationInfoTextClass,
|
|
390
|
+
children: showTotal(total, range)
|
|
391
|
+
})
|
|
337
392
|
}) : null,
|
|
338
|
-
/* @__PURE__ */ jsx3("
|
|
339
|
-
|
|
340
|
-
|
|
393
|
+
/* @__PURE__ */ jsx3("button", {
|
|
394
|
+
type: "button",
|
|
395
|
+
className: paginationPrevClass,
|
|
396
|
+
disabled: previousDisabled,
|
|
397
|
+
"aria-label": "Previous page",
|
|
398
|
+
onClick: () => changePage(mergedCurrent - 1),
|
|
399
|
+
children: "Prev"
|
|
341
400
|
}),
|
|
342
|
-
|
|
343
|
-
className:
|
|
401
|
+
simple ? /* @__PURE__ */ jsxs2("div", {
|
|
402
|
+
className: paginationInputClass,
|
|
344
403
|
children: [
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
404
|
+
/* @__PURE__ */ jsx3("input", {
|
|
405
|
+
"aria-label": "Current page",
|
|
406
|
+
type: "number",
|
|
407
|
+
min: 1,
|
|
408
|
+
max: pageCount,
|
|
409
|
+
value: quickJumpValue || String(mergedCurrent),
|
|
410
|
+
disabled,
|
|
411
|
+
onChange: (event) => setQuickJumpValue(event.currentTarget.value),
|
|
412
|
+
onKeyDown: handleQuickJumpKeyDown,
|
|
413
|
+
onBlur: (event) => {
|
|
414
|
+
if (event.currentTarget.value !== String(mergedCurrent)) {
|
|
415
|
+
jumpToInputPage(event.currentTarget.value);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}),
|
|
419
|
+
/* @__PURE__ */ jsxs2("span", {
|
|
420
|
+
className: paginationInfoTextClass,
|
|
421
|
+
children: [
|
|
422
|
+
"/ ",
|
|
423
|
+
pageCount
|
|
424
|
+
]
|
|
425
|
+
})
|
|
361
426
|
]
|
|
362
|
-
}) :
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
})
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
disabled,
|
|
372
|
-
disabledDate,
|
|
373
|
-
onChange,
|
|
374
|
-
picker = "date",
|
|
375
|
-
placeholder,
|
|
376
|
-
separator = "-",
|
|
377
|
-
size = "md",
|
|
378
|
-
status,
|
|
379
|
-
value,
|
|
380
|
-
...props
|
|
381
|
-
}, ref) => {
|
|
382
|
-
const isControlled = value !== undefined;
|
|
383
|
-
const [innerValue, setInnerValue] = useState(defaultValue ?? [undefined, undefined]);
|
|
384
|
-
const currentValue = isControlled ? value : innerValue;
|
|
385
|
-
const inputType = inputTypeForPicker(picker);
|
|
386
|
-
function emitChange(nextValue) {
|
|
387
|
-
if (nextValue.some((item) => item !== undefined && Boolean(disabledDate?.(item)))) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
if (!isControlled) {
|
|
391
|
-
setInnerValue(nextValue);
|
|
392
|
-
}
|
|
393
|
-
onChange?.(nextValue, [nextValue[0] ?? "", nextValue[1] ?? ""]);
|
|
394
|
-
}
|
|
395
|
-
function updateIndex(index, nextItem) {
|
|
396
|
-
emitChange(index === 0 ? [nextItem, currentValue?.[1]] : [currentValue?.[0], nextItem]);
|
|
397
|
-
}
|
|
398
|
-
return /* @__PURE__ */ jsxs2("div", {
|
|
399
|
-
...props,
|
|
400
|
-
ref,
|
|
401
|
-
className: getDatePickerClasses({
|
|
402
|
-
size,
|
|
403
|
-
status,
|
|
404
|
-
picker,
|
|
405
|
-
disabled,
|
|
406
|
-
range: true,
|
|
407
|
-
className
|
|
408
|
-
}),
|
|
409
|
-
children: [
|
|
410
|
-
/* @__PURE__ */ jsx3("input", {
|
|
411
|
-
className: datePickerInputClass,
|
|
412
|
-
disabled,
|
|
413
|
-
type: inputType,
|
|
414
|
-
value: currentValue?.[0] ?? "",
|
|
415
|
-
placeholder: Array.isArray(placeholder) ? placeholder[0] : "Start date",
|
|
416
|
-
onChange: (event) => updateIndex(0, event.currentTarget.value || undefined)
|
|
417
|
-
}),
|
|
418
|
-
/* @__PURE__ */ jsx3("span", {
|
|
419
|
-
className: datePickerSeparatorClass,
|
|
420
|
-
children: separator
|
|
421
|
-
}),
|
|
422
|
-
/* @__PURE__ */ jsx3("input", {
|
|
423
|
-
className: datePickerInputClass,
|
|
427
|
+
}) : pageTokens.map((pageToken, index) => pageToken === "ellipsis" ? /* @__PURE__ */ jsx3("span", {
|
|
428
|
+
"aria-hidden": "true",
|
|
429
|
+
className: paginationEllipsisClass
|
|
430
|
+
}, `ellipsis-${index}`) : /* @__PURE__ */ jsx3("button", {
|
|
431
|
+
type: "button",
|
|
432
|
+
className: getPaginationItemClasses({
|
|
433
|
+
active: pageToken === mergedCurrent,
|
|
434
|
+
disabled
|
|
435
|
+
}),
|
|
424
436
|
disabled,
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}),
|
|
430
|
-
|
|
437
|
+
"aria-current": pageToken === mergedCurrent ? "page" : undefined,
|
|
438
|
+
"aria-label": `Page ${pageToken}`,
|
|
439
|
+
onClick: () => changePage(pageToken),
|
|
440
|
+
children: pageToken
|
|
441
|
+
}, pageToken)),
|
|
442
|
+
/* @__PURE__ */ jsx3("button", {
|
|
431
443
|
type: "button",
|
|
432
|
-
className:
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
444
|
+
className: paginationNextClass,
|
|
445
|
+
disabled: nextDisabled,
|
|
446
|
+
"aria-label": "Next page",
|
|
447
|
+
onClick: () => changePage(mergedCurrent + 1),
|
|
448
|
+
children: "Next"
|
|
449
|
+
}),
|
|
450
|
+
showSizeChanger ? /* @__PURE__ */ jsx3("div", {
|
|
451
|
+
className: paginationInputClass,
|
|
452
|
+
children: /* @__PURE__ */ jsx3("select", {
|
|
453
|
+
"aria-label": "Page size",
|
|
454
|
+
value: mergedPageSize,
|
|
455
|
+
disabled,
|
|
456
|
+
onChange: handlePageSizeChange,
|
|
457
|
+
children: getSizeOptions(mergedPageSize).map((option) => /* @__PURE__ */ jsxs2("option", {
|
|
458
|
+
value: option,
|
|
459
|
+
children: [
|
|
460
|
+
option,
|
|
461
|
+
" / page"
|
|
462
|
+
]
|
|
463
|
+
}, option))
|
|
464
|
+
})
|
|
465
|
+
}) : null,
|
|
466
|
+
showQuickJumper && !simple ? /* @__PURE__ */ jsx3("div", {
|
|
467
|
+
className: paginationInputClass,
|
|
468
|
+
children: /* @__PURE__ */ jsx3("input", {
|
|
469
|
+
"aria-label": "Jump to page",
|
|
470
|
+
type: "number",
|
|
471
|
+
min: 1,
|
|
472
|
+
max: pageCount,
|
|
473
|
+
value: quickJumpValue,
|
|
474
|
+
disabled,
|
|
475
|
+
onChange: (event) => setQuickJumpValue(event.currentTarget.value),
|
|
476
|
+
onKeyDown: handleQuickJumpKeyDown
|
|
477
|
+
})
|
|
436
478
|
}) : null
|
|
437
479
|
]
|
|
438
480
|
});
|
|
439
481
|
});
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
482
|
+
Pagination.displayName = "Pagination";
|
|
483
|
+
// src/components/dm-pagination/DmPagination.tsx
|
|
484
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
485
|
+
var defaultLocale = {
|
|
486
|
+
refresh: "Refresh",
|
|
487
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} of ${total}`,
|
|
488
|
+
showTotalSimple: (total, range) => `${range[0]}-${range[1]} / ${total}`,
|
|
489
|
+
selected: (selectedTotal) => `, ${selectedTotal} selected`
|
|
490
|
+
};
|
|
491
|
+
function getResponsiveSimple({
|
|
492
|
+
width,
|
|
493
|
+
total,
|
|
494
|
+
showRefresh,
|
|
495
|
+
showSizeChanger
|
|
496
|
+
}) {
|
|
497
|
+
let reservedWidth = 0;
|
|
498
|
+
if (!showRefresh)
|
|
499
|
+
reservedWidth += 100;
|
|
500
|
+
if (!showSizeChanger)
|
|
501
|
+
reservedWidth += 100;
|
|
502
|
+
if (width < 900 - reservedWidth)
|
|
503
|
+
return total >= 100;
|
|
504
|
+
if (width < 1100 - reservedWidth)
|
|
505
|
+
return total >= 1000;
|
|
506
|
+
if (width < 1220 - reservedWidth)
|
|
507
|
+
return total >= 99999;
|
|
508
|
+
if (width < 1300 - reservedWidth)
|
|
509
|
+
return total >= 999999;
|
|
510
|
+
if (width < 1450 - reservedWidth)
|
|
511
|
+
return total >= 9999999;
|
|
512
|
+
return false;
|
|
449
513
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
514
|
+
function useElementWidth() {
|
|
515
|
+
const ref = useRef(null);
|
|
516
|
+
const [width, setWidth] = useState2(1000);
|
|
517
|
+
useEffect(() => {
|
|
518
|
+
const element = ref.current;
|
|
519
|
+
if (!element || typeof ResizeObserver === "undefined")
|
|
520
|
+
return;
|
|
521
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
522
|
+
setWidth(entry?.contentRect.width || element.getBoundingClientRect().width);
|
|
523
|
+
});
|
|
524
|
+
observer.observe(element);
|
|
525
|
+
return () => observer.disconnect();
|
|
526
|
+
}, []);
|
|
527
|
+
return [ref, width];
|
|
528
|
+
}
|
|
529
|
+
function renderSelected(selectedTotal, locale) {
|
|
530
|
+
if (!selectedTotal)
|
|
531
|
+
return null;
|
|
532
|
+
return /* @__PURE__ */ jsx4("span", {
|
|
533
|
+
className: dmPaginationSelectedClass,
|
|
534
|
+
children: locale.selected(selectedTotal)
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
var DmPagination = forwardRef2(({
|
|
538
|
+
selectedTotal = 0,
|
|
539
|
+
loading = false,
|
|
540
|
+
total = 0,
|
|
541
|
+
showRefresh = true,
|
|
542
|
+
showPagination = true,
|
|
543
|
+
wrapperStyle,
|
|
544
|
+
className,
|
|
545
|
+
align = "right",
|
|
546
|
+
showTotalFullMessage = false,
|
|
547
|
+
showSizeChanger = true,
|
|
548
|
+
responsiveSimple = true,
|
|
549
|
+
refresh,
|
|
550
|
+
simple,
|
|
551
|
+
showQuickJumper,
|
|
552
|
+
showTotal,
|
|
553
|
+
locale,
|
|
554
|
+
...props
|
|
555
|
+
}, ref) => {
|
|
556
|
+
const [measureRef, width] = useElementWidth();
|
|
557
|
+
const mergedLocale = useMemo2(() => ({ ...defaultLocale, ...locale }), [locale]);
|
|
558
|
+
const isRefreshVisible = showRefresh && Boolean(refresh);
|
|
559
|
+
const shouldRender = showPagination || isRefreshVisible;
|
|
560
|
+
const responsiveSimpleMode = responsiveSimple ? getResponsiveSimple({
|
|
561
|
+
width,
|
|
562
|
+
total,
|
|
563
|
+
showRefresh,
|
|
564
|
+
showSizeChanger
|
|
565
|
+
}) : false;
|
|
566
|
+
const mergedSimple = simple ?? responsiveSimpleMode;
|
|
567
|
+
const mergedShowQuickJumper = showQuickJumper ?? !mergedSimple;
|
|
568
|
+
const totalRenderer = useMemo2(() => {
|
|
569
|
+
if (showTotal)
|
|
570
|
+
return showTotal;
|
|
571
|
+
return (nextTotal, range) => {
|
|
572
|
+
if (Number(nextTotal) === 0)
|
|
573
|
+
return "";
|
|
574
|
+
const selected = renderSelected(selectedTotal, mergedLocale);
|
|
575
|
+
const message = mergedSimple && !showTotalFullMessage ? mergedLocale.showTotalSimple(nextTotal, range, selectedTotal) : mergedLocale.showTotal(nextTotal, range, selectedTotal);
|
|
576
|
+
return /* @__PURE__ */ jsxs3("span", {
|
|
577
|
+
title: `${mergedLocale.showTotal(nextTotal, range, selectedTotal)}${selectedTotal ? mergedLocale.selected(selectedTotal) : ""}`,
|
|
578
|
+
children: [
|
|
579
|
+
message,
|
|
580
|
+
selected
|
|
581
|
+
]
|
|
582
|
+
});
|
|
583
|
+
};
|
|
584
|
+
}, [
|
|
585
|
+
mergedLocale,
|
|
586
|
+
mergedSimple,
|
|
587
|
+
selectedTotal,
|
|
588
|
+
showTotal,
|
|
589
|
+
showTotalFullMessage
|
|
590
|
+
]);
|
|
591
|
+
if (!shouldRender)
|
|
592
|
+
return null;
|
|
593
|
+
return /* @__PURE__ */ jsxs3("div", {
|
|
594
|
+
ref: (element) => {
|
|
595
|
+
measureRef.current = element;
|
|
596
|
+
if (typeof ref === "function") {
|
|
597
|
+
ref(element);
|
|
598
|
+
} else if (ref) {
|
|
599
|
+
ref.current = element;
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
className: getDmPaginationClasses({ align, className }),
|
|
603
|
+
style: wrapperStyle,
|
|
604
|
+
children: [
|
|
605
|
+
showPagination ? /* @__PURE__ */ jsx4("div", {
|
|
606
|
+
className: dmPaginationPagerClass,
|
|
607
|
+
children: /* @__PURE__ */ jsx4(Pagination, {
|
|
608
|
+
...props,
|
|
609
|
+
total,
|
|
610
|
+
simple: mergedSimple,
|
|
611
|
+
showQuickJumper: mergedShowQuickJumper,
|
|
612
|
+
showSizeChanger,
|
|
613
|
+
showTotal: totalRenderer
|
|
614
|
+
})
|
|
615
|
+
}) : null,
|
|
616
|
+
isRefreshVisible ? /* @__PURE__ */ jsxs3("button", {
|
|
617
|
+
type: "button",
|
|
618
|
+
className: getDmPaginationRefreshClasses({ loading }),
|
|
619
|
+
disabled: loading || props.disabled,
|
|
620
|
+
"aria-busy": loading || undefined,
|
|
621
|
+
onClick: refresh,
|
|
622
|
+
children: [
|
|
623
|
+
/* @__PURE__ */ jsx4("span", {
|
|
624
|
+
"aria-hidden": "true",
|
|
625
|
+
children: "Reload"
|
|
626
|
+
}),
|
|
627
|
+
/* @__PURE__ */ jsx4("span", {
|
|
628
|
+
children: mergedLocale.refresh
|
|
629
|
+
})
|
|
630
|
+
]
|
|
631
|
+
}) : null
|
|
632
|
+
]
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
DmPagination.displayName = "DmPagination";
|
|
636
|
+
// src/components/dm-search/DmSearch.tsx
|
|
458
637
|
import {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
useState as
|
|
638
|
+
forwardRef as forwardRef6,
|
|
639
|
+
useEffect as useEffect2,
|
|
640
|
+
useImperativeHandle as useImperativeHandle2,
|
|
641
|
+
useMemo as useMemo5,
|
|
642
|
+
useState as useState6
|
|
464
643
|
} from "react";
|
|
465
644
|
|
|
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,
|
|
645
|
+
// src/classes/dm-search.ts
|
|
646
|
+
var dmSearchBaseClass = "dm-search";
|
|
647
|
+
var dmSearchCompactClass = "dm-search-compact";
|
|
648
|
+
var dmSearchCollapsedClass = "dm-search-collapsed";
|
|
649
|
+
var dmSearchFieldsClass = "dm-search-fields";
|
|
650
|
+
var dmSearchFieldClass = "dm-search-field";
|
|
651
|
+
var dmSearchActionsClass = "dm-search-actions";
|
|
652
|
+
var dmSearchFastFilterClass = "dm-search-fast-filter";
|
|
653
|
+
function getDmSearchClasses({
|
|
654
|
+
compact,
|
|
655
|
+
collapsed,
|
|
487
656
|
className
|
|
488
657
|
}) {
|
|
489
|
-
return cn(
|
|
658
|
+
return cn(dmSearchBaseClass, compact && dmSearchCompactClass, collapsed && dmSearchCollapsedClass, className);
|
|
490
659
|
}
|
|
491
660
|
|
|
492
|
-
// src/
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
var
|
|
497
|
-
var
|
|
498
|
-
var
|
|
499
|
-
var
|
|
500
|
-
var
|
|
501
|
-
var
|
|
502
|
-
var
|
|
503
|
-
var
|
|
504
|
-
var
|
|
505
|
-
var
|
|
506
|
-
var
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
661
|
+
// src/components/date-picker/DatePicker.tsx
|
|
662
|
+
import { forwardRef as forwardRef3, useMemo as useMemo3, useState as useState3 } from "react";
|
|
663
|
+
|
|
664
|
+
// src/classes/date-picker.ts
|
|
665
|
+
var datePickerBaseClass = "datepicker";
|
|
666
|
+
var datePickerInputClass = "datepicker-input";
|
|
667
|
+
var datePickerIconClass = "datepicker-icon";
|
|
668
|
+
var datePickerDropdownClass = "datepicker-dropdown";
|
|
669
|
+
var datePickerDropdownOpenClass = "datepicker-dropdown-open";
|
|
670
|
+
var datePickerFooterClass = "datepicker-footer";
|
|
671
|
+
var datePickerPresetClass = "datepicker-preset";
|
|
672
|
+
var datePickerRangeClass = "datepicker-range";
|
|
673
|
+
var datePickerSeparatorClass = "datepicker-range-separator";
|
|
674
|
+
var datePickerClearClass = "datepicker-clear";
|
|
675
|
+
var datePickerSizeClasses = {
|
|
676
|
+
sm: "datepicker-sm",
|
|
677
|
+
md: "",
|
|
678
|
+
lg: "datepicker-lg"
|
|
510
679
|
};
|
|
511
|
-
var
|
|
512
|
-
|
|
513
|
-
|
|
680
|
+
var datePickerStatusClasses = {
|
|
681
|
+
error: "datepicker-error",
|
|
682
|
+
success: "datepicker-success"
|
|
514
683
|
};
|
|
515
|
-
var
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
684
|
+
var datePickerPickerClasses = {
|
|
685
|
+
date: "",
|
|
686
|
+
week: "datepicker-week",
|
|
687
|
+
month: "datepicker-month-picker",
|
|
688
|
+
quarter: "datepicker-quarter-picker",
|
|
689
|
+
year: "datepicker-year-picker",
|
|
690
|
+
time: "datepicker-time-picker"
|
|
519
691
|
};
|
|
520
|
-
function
|
|
521
|
-
mode = "vertical",
|
|
522
|
-
theme = "light",
|
|
692
|
+
function getDatePickerClasses({
|
|
523
693
|
size = "md",
|
|
524
|
-
|
|
694
|
+
status,
|
|
695
|
+
picker = "date",
|
|
696
|
+
open,
|
|
525
697
|
disabled,
|
|
698
|
+
range,
|
|
526
699
|
className
|
|
527
700
|
}) {
|
|
528
|
-
return cn(
|
|
701
|
+
return cn(datePickerBaseClass, datePickerSizeClasses[size], status && datePickerStatusClasses[status], datePickerPickerClasses[picker], open && "datepicker-open", disabled && "datepicker-disabled", range && datePickerRangeClass, className);
|
|
529
702
|
}
|
|
530
|
-
function
|
|
531
|
-
|
|
532
|
-
disabled,
|
|
533
|
-
danger,
|
|
534
|
-
submenu,
|
|
703
|
+
function getDatePickerDropdownClasses({
|
|
704
|
+
open,
|
|
535
705
|
className
|
|
536
706
|
}) {
|
|
537
|
-
return cn(
|
|
707
|
+
return cn(datePickerDropdownClass, open && datePickerDropdownOpenClass, className);
|
|
538
708
|
}
|
|
539
709
|
|
|
540
|
-
// src/components/
|
|
541
|
-
import { jsx as
|
|
542
|
-
function
|
|
543
|
-
|
|
710
|
+
// src/components/date-picker/DatePicker.tsx
|
|
711
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
712
|
+
function todayValue(picker) {
|
|
713
|
+
const today = new Date;
|
|
714
|
+
const year = today.getFullYear();
|
|
715
|
+
const month = String(today.getMonth() + 1).padStart(2, "0");
|
|
716
|
+
const day = String(today.getDate()).padStart(2, "0");
|
|
717
|
+
if (picker === "month")
|
|
718
|
+
return `${year}-${month}`;
|
|
719
|
+
if (picker === "year")
|
|
720
|
+
return String(year);
|
|
721
|
+
if (picker === "time")
|
|
722
|
+
return "00:00";
|
|
723
|
+
return `${year}-${month}-${day}`;
|
|
544
724
|
}
|
|
545
|
-
function
|
|
546
|
-
|
|
725
|
+
function inputTypeForPicker(picker) {
|
|
726
|
+
if (picker === "month")
|
|
727
|
+
return "month";
|
|
728
|
+
if (picker === "week")
|
|
729
|
+
return "week";
|
|
730
|
+
if (picker === "time")
|
|
731
|
+
return "time";
|
|
732
|
+
return picker === "year" || picker === "quarter" ? "text" : "date";
|
|
547
733
|
}
|
|
548
|
-
function
|
|
549
|
-
if (
|
|
550
|
-
return
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
onClick?.({ key: String(item.key), item, domEvent: event });
|
|
561
|
-
close();
|
|
562
|
-
},
|
|
563
|
-
children: [
|
|
564
|
-
item.icon ? /* @__PURE__ */ jsx4("span", {
|
|
565
|
-
className: "menu-item-icon",
|
|
566
|
-
children: item.icon
|
|
567
|
-
}) : null,
|
|
568
|
-
/* @__PURE__ */ jsx4("span", {
|
|
569
|
-
children: item.label
|
|
570
|
-
})
|
|
571
|
-
]
|
|
572
|
-
})
|
|
573
|
-
}, String(item.key));
|
|
734
|
+
function placeholderForPicker(picker) {
|
|
735
|
+
if (picker === "month")
|
|
736
|
+
return "Select month";
|
|
737
|
+
if (picker === "week")
|
|
738
|
+
return "Select week";
|
|
739
|
+
if (picker === "quarter")
|
|
740
|
+
return "Select quarter";
|
|
741
|
+
if (picker === "year")
|
|
742
|
+
return "Select year";
|
|
743
|
+
if (picker === "time")
|
|
744
|
+
return "Select time";
|
|
745
|
+
return "Select date";
|
|
574
746
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
747
|
+
function normalizeDateValue(value) {
|
|
748
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
749
|
+
}
|
|
750
|
+
var DatePickerRoot = forwardRef3(({
|
|
751
|
+
allowClear,
|
|
578
752
|
className,
|
|
579
753
|
defaultOpen,
|
|
580
|
-
|
|
754
|
+
defaultValue,
|
|
581
755
|
disabled,
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
onMouseEnter,
|
|
587
|
-
onMouseLeave,
|
|
756
|
+
disabledDate,
|
|
757
|
+
onBlur,
|
|
758
|
+
onChange,
|
|
759
|
+
onFocus,
|
|
588
760
|
onOpenChange,
|
|
589
761
|
open,
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
762
|
+
picker = "date",
|
|
763
|
+
placeholder,
|
|
764
|
+
presets,
|
|
765
|
+
showNow,
|
|
766
|
+
size = "md",
|
|
767
|
+
status,
|
|
768
|
+
value,
|
|
593
769
|
...props
|
|
594
770
|
}, ref) => {
|
|
595
|
-
const
|
|
596
|
-
const
|
|
597
|
-
const
|
|
598
|
-
const
|
|
771
|
+
const isValueControlled = value !== undefined;
|
|
772
|
+
const isOpenControlled = open !== undefined;
|
|
773
|
+
const [innerValue, setInnerValue] = useState3(() => normalizeDateValue(defaultValue));
|
|
774
|
+
const [innerOpen, setInnerOpen] = useState3(Boolean(defaultOpen));
|
|
775
|
+
const currentValue = isValueControlled ? normalizeDateValue(value) : innerValue;
|
|
776
|
+
const visible = isOpenControlled ? Boolean(open) : innerOpen;
|
|
777
|
+
const inputType = inputTypeForPicker(picker);
|
|
599
778
|
function setVisible(nextOpen) {
|
|
600
|
-
if (
|
|
601
|
-
|
|
602
|
-
if (!isControlled) {
|
|
603
|
-
setInternalOpen(nextOpen);
|
|
779
|
+
if (!isOpenControlled) {
|
|
780
|
+
setInnerOpen(nextOpen);
|
|
604
781
|
}
|
|
605
782
|
onOpenChange?.(nextOpen);
|
|
606
783
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
className: dropdownMenuClass,
|
|
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);
|
|
784
|
+
function emitChange(nextValue) {
|
|
785
|
+
if (nextValue && disabledDate?.(nextValue)) {
|
|
786
|
+
return;
|
|
648
787
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
triggerProps.onMouseEnter?.();
|
|
657
|
-
onMouseEnter?.(event);
|
|
658
|
-
},
|
|
659
|
-
onMouseLeave: (event) => {
|
|
660
|
-
triggerProps.onMouseLeave?.();
|
|
661
|
-
onMouseLeave?.(event);
|
|
662
|
-
},
|
|
663
|
-
onClick: (event) => {
|
|
664
|
-
triggerProps.onClick?.();
|
|
665
|
-
onClick?.(event);
|
|
666
|
-
},
|
|
667
|
-
onKeyDown: (event) => {
|
|
668
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
669
|
-
event.preventDefault();
|
|
670
|
-
triggerProps.onClick?.();
|
|
671
|
-
}
|
|
672
|
-
},
|
|
673
|
-
onContextMenu: (event) => {
|
|
674
|
-
triggerProps.onContextMenu?.(event);
|
|
675
|
-
onContextMenu?.(event);
|
|
676
|
-
},
|
|
677
|
-
children
|
|
678
|
-
});
|
|
679
|
-
return /* @__PURE__ */ jsxs3("span", {
|
|
788
|
+
if (!isValueControlled) {
|
|
789
|
+
setInnerValue(nextValue);
|
|
790
|
+
}
|
|
791
|
+
onChange?.(nextValue, nextValue ?? "");
|
|
792
|
+
}
|
|
793
|
+
const presetItems = useMemo3(() => presets ?? [], [presets]);
|
|
794
|
+
return /* @__PURE__ */ jsxs4("div", {
|
|
680
795
|
...props,
|
|
681
796
|
ref,
|
|
682
|
-
className:
|
|
797
|
+
className: getDatePickerClasses({
|
|
798
|
+
size,
|
|
799
|
+
status,
|
|
800
|
+
picker,
|
|
801
|
+
open: visible,
|
|
802
|
+
disabled,
|
|
803
|
+
className
|
|
804
|
+
}),
|
|
683
805
|
children: [
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
806
|
+
/* @__PURE__ */ jsx5("input", {
|
|
807
|
+
className: datePickerInputClass,
|
|
808
|
+
disabled,
|
|
809
|
+
type: inputType,
|
|
810
|
+
value: currentValue ?? "",
|
|
811
|
+
placeholder: placeholder ?? placeholderForPicker(picker),
|
|
812
|
+
onFocus: (event) => {
|
|
813
|
+
onFocus?.(event);
|
|
814
|
+
setVisible(true);
|
|
815
|
+
},
|
|
816
|
+
onBlur: (event) => {
|
|
817
|
+
onBlur?.(event);
|
|
818
|
+
setVisible(false);
|
|
819
|
+
},
|
|
820
|
+
onChange: (event) => emitChange(event.currentTarget.value || undefined)
|
|
821
|
+
}),
|
|
822
|
+
allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx5("button", {
|
|
823
|
+
type: "button",
|
|
824
|
+
className: datePickerClearClass,
|
|
825
|
+
"aria-label": "Clear date",
|
|
826
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
827
|
+
onClick: () => emitChange(undefined),
|
|
828
|
+
children: "x"
|
|
829
|
+
}) : null,
|
|
830
|
+
/* @__PURE__ */ jsx5("span", {
|
|
831
|
+
className: datePickerIconClass,
|
|
832
|
+
"aria-hidden": "true"
|
|
833
|
+
}),
|
|
834
|
+
(presetItems.length > 0 || showNow) && visible ? /* @__PURE__ */ jsxs4("div", {
|
|
835
|
+
className: getDatePickerDropdownClasses({ open: visible }),
|
|
694
836
|
children: [
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
className:
|
|
837
|
+
presetItems.map((preset, index) => /* @__PURE__ */ jsx5("button", {
|
|
838
|
+
type: "button",
|
|
839
|
+
className: datePickerPresetClass,
|
|
840
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
841
|
+
onClick: () => emitChange(preset.value),
|
|
842
|
+
children: preset.label
|
|
843
|
+
}, index)),
|
|
844
|
+
showNow ? /* @__PURE__ */ jsx5("div", {
|
|
845
|
+
className: datePickerFooterClass,
|
|
846
|
+
children: /* @__PURE__ */ jsx5("button", {
|
|
847
|
+
type: "button",
|
|
848
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
849
|
+
onClick: () => emitChange(todayValue(picker)),
|
|
850
|
+
children: "Now"
|
|
851
|
+
})
|
|
698
852
|
}) : null
|
|
699
853
|
]
|
|
700
854
|
}) : null
|
|
701
855
|
]
|
|
702
856
|
});
|
|
703
857
|
});
|
|
704
|
-
|
|
705
|
-
var
|
|
706
|
-
|
|
707
|
-
|
|
858
|
+
DatePickerRoot.displayName = "DatePicker";
|
|
859
|
+
var RangePicker = forwardRef3(({
|
|
860
|
+
allowClear,
|
|
861
|
+
className,
|
|
862
|
+
defaultValue,
|
|
708
863
|
disabled,
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
864
|
+
disabledDate,
|
|
865
|
+
onChange,
|
|
866
|
+
picker = "date",
|
|
867
|
+
placeholder,
|
|
868
|
+
separator = "-",
|
|
869
|
+
size = "md",
|
|
870
|
+
status,
|
|
871
|
+
value,
|
|
712
872
|
...props
|
|
713
873
|
}, ref) => {
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
874
|
+
const isControlled = value !== undefined;
|
|
875
|
+
const [innerValue, setInnerValue] = useState3(defaultValue ?? [undefined, undefined]);
|
|
876
|
+
const currentValue = isControlled ? value : innerValue;
|
|
877
|
+
const inputType = inputTypeForPicker(picker);
|
|
878
|
+
function emitChange(nextValue) {
|
|
879
|
+
if (nextValue.some((item) => item !== undefined && Boolean(disabledDate?.(item)))) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
if (!isControlled) {
|
|
883
|
+
setInnerValue(nextValue);
|
|
884
|
+
}
|
|
885
|
+
onChange?.(nextValue, [nextValue[0] ?? "", nextValue[1] ?? ""]);
|
|
886
|
+
}
|
|
887
|
+
function updateIndex(index, nextItem) {
|
|
888
|
+
emitChange(index === 0 ? [nextItem, currentValue?.[1]] : [currentValue?.[0], nextItem]);
|
|
889
|
+
}
|
|
890
|
+
return /* @__PURE__ */ jsxs4("div", {
|
|
728
891
|
...props,
|
|
729
892
|
ref,
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
893
|
+
className: getDatePickerClasses({
|
|
894
|
+
size,
|
|
895
|
+
status,
|
|
896
|
+
picker,
|
|
897
|
+
disabled,
|
|
898
|
+
range: true,
|
|
899
|
+
className
|
|
900
|
+
}),
|
|
901
|
+
children: [
|
|
902
|
+
/* @__PURE__ */ jsx5("input", {
|
|
903
|
+
className: datePickerInputClass,
|
|
904
|
+
disabled,
|
|
905
|
+
type: inputType,
|
|
906
|
+
value: currentValue?.[0] ?? "",
|
|
907
|
+
placeholder: Array.isArray(placeholder) ? placeholder[0] : "Start date",
|
|
908
|
+
onChange: (event) => updateIndex(0, event.currentTarget.value || undefined)
|
|
909
|
+
}),
|
|
910
|
+
/* @__PURE__ */ jsx5("span", {
|
|
911
|
+
className: datePickerSeparatorClass,
|
|
912
|
+
children: separator
|
|
913
|
+
}),
|
|
914
|
+
/* @__PURE__ */ jsx5("input", {
|
|
915
|
+
className: datePickerInputClass,
|
|
916
|
+
disabled,
|
|
917
|
+
type: inputType,
|
|
918
|
+
value: currentValue?.[1] ?? "",
|
|
919
|
+
placeholder: Array.isArray(placeholder) ? placeholder[1] : "End date",
|
|
920
|
+
onChange: (event) => updateIndex(1, event.currentTarget.value || undefined)
|
|
921
|
+
}),
|
|
922
|
+
allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */ jsx5("button", {
|
|
923
|
+
type: "button",
|
|
924
|
+
className: datePickerClearClass,
|
|
925
|
+
"aria-label": "Clear date range",
|
|
926
|
+
onClick: () => emitChange([undefined, undefined]),
|
|
927
|
+
children: "x"
|
|
928
|
+
}) : null
|
|
929
|
+
]
|
|
737
930
|
});
|
|
738
931
|
});
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
932
|
+
RangePicker.displayName = "DatePicker.RangePicker";
|
|
933
|
+
function withPicker(picker, displayName) {
|
|
934
|
+
const Picker = forwardRef3((props, ref) => /* @__PURE__ */ jsx5(DatePickerRoot, {
|
|
935
|
+
...props,
|
|
936
|
+
ref,
|
|
937
|
+
picker
|
|
938
|
+
}));
|
|
939
|
+
Picker.displayName = displayName;
|
|
940
|
+
return Picker;
|
|
941
|
+
}
|
|
942
|
+
var DatePicker = Object.assign(DatePickerRoot, {
|
|
943
|
+
RangePicker,
|
|
944
|
+
WeekPicker: withPicker("week", "DatePicker.WeekPicker"),
|
|
945
|
+
MonthPicker: withPicker("month", "DatePicker.MonthPicker"),
|
|
946
|
+
QuarterPicker: withPicker("quarter", "DatePicker.QuarterPicker"),
|
|
947
|
+
YearPicker: withPicker("year", "DatePicker.YearPicker")
|
|
742
948
|
});
|
|
743
|
-
// src/components/
|
|
744
|
-
import {
|
|
949
|
+
// src/components/input/Input.tsx
|
|
950
|
+
import {
|
|
951
|
+
forwardRef as forwardRef4,
|
|
952
|
+
useImperativeHandle,
|
|
953
|
+
useRef as useRef2,
|
|
954
|
+
useState as useState4
|
|
955
|
+
} from "react";
|
|
745
956
|
|
|
746
|
-
// src/classes/
|
|
747
|
-
var
|
|
748
|
-
var
|
|
749
|
-
var
|
|
750
|
-
var
|
|
751
|
-
var
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
957
|
+
// src/classes/input.ts
|
|
958
|
+
var inputBaseClass = "input";
|
|
959
|
+
var inputWrapperClass = "input-wrapper";
|
|
960
|
+
var inputAffixWrapperClass = "input-affix-wrapper";
|
|
961
|
+
var inputPrefixClass = "input-prefix";
|
|
962
|
+
var inputSuffixClass = "input-suffix";
|
|
963
|
+
var inputClearClass = "input-clear";
|
|
964
|
+
var inputSearchClass = "input-search";
|
|
965
|
+
var inputSearchButtonClass = "input-search-button";
|
|
966
|
+
var inputPasswordClass = "input-password";
|
|
967
|
+
var inputPasswordToggleClass = "input-password-toggle";
|
|
968
|
+
var inputGroupClass = "input-group";
|
|
969
|
+
var textAreaBaseClass = "textarea";
|
|
970
|
+
var textAreaWrapperClass = "textarea-wrapper";
|
|
971
|
+
var textAreaCountClass = "textarea-counter";
|
|
972
|
+
var textAreaCountExceededClass = "textarea-counter-exceeded";
|
|
973
|
+
var textAreaAutoSizeClass = "textarea-auto-resize";
|
|
974
|
+
var inputVariantClasses = {
|
|
975
|
+
filled: "input-filled",
|
|
976
|
+
outlined: "input-outlined"
|
|
977
|
+
};
|
|
978
|
+
var inputSizeClasses = {
|
|
979
|
+
sm: "input-sm",
|
|
980
|
+
md: "input-md",
|
|
981
|
+
lg: "input-lg"
|
|
982
|
+
};
|
|
983
|
+
var inputStatusClasses = {
|
|
984
|
+
error: "input-error",
|
|
985
|
+
success: "input-success"
|
|
986
|
+
};
|
|
987
|
+
var textAreaVariantClasses = {
|
|
988
|
+
filled: "textarea-filled",
|
|
989
|
+
outlined: "textarea-outlined"
|
|
990
|
+
};
|
|
991
|
+
var textAreaSizeClasses = {
|
|
992
|
+
sm: "textarea-sm",
|
|
993
|
+
md: "",
|
|
994
|
+
lg: "textarea-lg"
|
|
995
|
+
};
|
|
996
|
+
var textAreaStatusClasses = {
|
|
997
|
+
error: "textarea-error",
|
|
998
|
+
success: "textarea-success"
|
|
999
|
+
};
|
|
1000
|
+
var textAreaResizeClasses = {
|
|
1001
|
+
none: "textarea-resize-none",
|
|
1002
|
+
both: "textarea-resize-both",
|
|
1003
|
+
horizontal: "textarea-resize-horizontal",
|
|
1004
|
+
vertical: "textarea-resize-vertical"
|
|
1005
|
+
};
|
|
1006
|
+
function getInputClasses({
|
|
1007
|
+
size = "md",
|
|
1008
|
+
status,
|
|
1009
|
+
variant = "outlined",
|
|
757
1010
|
className
|
|
758
1011
|
}) {
|
|
759
|
-
return cn(
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// src/components/dm-toolbar/DmToolbar.tsx
|
|
763
|
-
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
764
|
-
function isPrimary(item) {
|
|
765
|
-
return item.type === "primary";
|
|
1012
|
+
return cn(inputBaseClass, inputVariantClasses[variant], inputSizeClasses[size], status && inputStatusClasses[status], className);
|
|
766
1013
|
}
|
|
767
|
-
function
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
htmlType = "button",
|
|
773
|
-
color,
|
|
774
|
-
appearance,
|
|
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}`);
|
|
1014
|
+
function getInputWrapperClasses({
|
|
1015
|
+
affixed,
|
|
1016
|
+
className
|
|
1017
|
+
}) {
|
|
1018
|
+
return cn(inputWrapperClass, affixed && inputAffixWrapperClass, className);
|
|
793
1019
|
}
|
|
794
|
-
function
|
|
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
|
-
};
|
|
1020
|
+
function getSearchWrapperClasses({ className }) {
|
|
1021
|
+
return cn(inputSearchClass, className);
|
|
806
1022
|
}
|
|
807
|
-
function
|
|
808
|
-
|
|
809
|
-
className,
|
|
810
|
-
style,
|
|
811
|
-
moreText = "More",
|
|
812
|
-
maxVisibleSecondaryItems
|
|
1023
|
+
function getPasswordWrapperClasses({
|
|
1024
|
+
className
|
|
813
1025
|
}) {
|
|
814
|
-
|
|
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
|
-
});
|
|
1026
|
+
return cn(inputPasswordClass, className);
|
|
848
1027
|
}
|
|
849
|
-
|
|
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({
|
|
1028
|
+
function getTextAreaClasses({
|
|
876
1029
|
size = "md",
|
|
877
|
-
|
|
1030
|
+
status,
|
|
1031
|
+
variant = "outlined",
|
|
1032
|
+
resize = "vertical",
|
|
1033
|
+
autoSize,
|
|
878
1034
|
className
|
|
879
1035
|
}) {
|
|
880
|
-
return cn(
|
|
1036
|
+
return cn(textAreaBaseClass, textAreaVariantClasses[variant], textAreaSizeClasses[size], status && textAreaStatusClasses[status], textAreaResizeClasses[resize], autoSize && textAreaAutoSizeClass, className);
|
|
881
1037
|
}
|
|
882
|
-
function
|
|
883
|
-
|
|
884
|
-
disabled
|
|
885
|
-
}) {
|
|
886
|
-
return cn(paginationItemClass, active && paginationItemActiveClass, disabled && paginationItemDisabledClass);
|
|
1038
|
+
function getTextAreaCountClasses({ exceeded }) {
|
|
1039
|
+
return cn(textAreaCountClass, exceeded && textAreaCountExceededClass);
|
|
887
1040
|
}
|
|
888
1041
|
|
|
889
|
-
// src/components/
|
|
1042
|
+
// src/components/input/Input.tsx
|
|
890
1043
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
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];
|
|
911
|
-
}
|
|
912
|
-
function getPageTokens(current, pageCount) {
|
|
913
|
-
if (pageCount <= 7) {
|
|
914
|
-
return Array.from({ length: pageCount }, (_, index) => index + 1);
|
|
915
|
-
}
|
|
916
|
-
const pages = new Set([1, pageCount, current - 1, current, current + 1]);
|
|
917
|
-
if (current <= 4) {
|
|
918
|
-
[2, 3, 4, 5].forEach((page) => pages.add(page));
|
|
919
|
-
}
|
|
920
|
-
if (current >= pageCount - 3) {
|
|
921
|
-
[pageCount - 4, pageCount - 3, pageCount - 2, pageCount - 1].forEach((page) => pages.add(page));
|
|
1044
|
+
function toTextValue(value) {
|
|
1045
|
+
if (Array.isArray(value)) {
|
|
1046
|
+
return value.join(",");
|
|
922
1047
|
}
|
|
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
|
-
}, []);
|
|
937
|
-
}
|
|
938
|
-
function getSizeOptions(pageSize) {
|
|
939
|
-
return Array.from(new Set([...defaultPageSizeOptions, pageSize])).sort((first, second) => first - second);
|
|
1048
|
+
return value == null ? "" : String(value);
|
|
940
1049
|
}
|
|
941
|
-
var
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
defaultPageSize = 10,
|
|
946
|
-
total = 0,
|
|
947
|
-
onChange,
|
|
1050
|
+
var InputRoot = forwardRef4(({
|
|
1051
|
+
allowClear,
|
|
1052
|
+
className,
|
|
1053
|
+
defaultValue,
|
|
948
1054
|
disabled,
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
showQuickJumper,
|
|
952
|
-
showTotal,
|
|
1055
|
+
onChange,
|
|
1056
|
+
prefix,
|
|
953
1057
|
size = "md",
|
|
954
|
-
|
|
1058
|
+
status,
|
|
1059
|
+
suffix,
|
|
1060
|
+
type = "text",
|
|
1061
|
+
value,
|
|
1062
|
+
variant = "outlined",
|
|
955
1063
|
...props
|
|
956
1064
|
}, ref) => {
|
|
957
|
-
const
|
|
958
|
-
const
|
|
959
|
-
const
|
|
960
|
-
const
|
|
961
|
-
const
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
const range = getRange(mergedCurrent, mergedPageSize, total);
|
|
967
|
-
function changePage(nextPage, nextPageSize = mergedPageSize) {
|
|
968
|
-
const nextPageCount = getPageCount(total, nextPageSize);
|
|
969
|
-
const normalizedPage = clampPage(nextPage, nextPageCount);
|
|
970
|
-
if (!isCurrentControlled) {
|
|
971
|
-
setInternalCurrent(normalizedPage);
|
|
972
|
-
}
|
|
973
|
-
if (!isPageSizeControlled) {
|
|
974
|
-
setInternalPageSize(nextPageSize);
|
|
1065
|
+
const inputRef = useRef2(null);
|
|
1066
|
+
const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
|
|
1067
|
+
const isControlled = value !== undefined;
|
|
1068
|
+
const currentValue = isControlled ? toTextValue(value) : internalValue;
|
|
1069
|
+
const hasAffix = prefix != null || suffix != null || allowClear;
|
|
1070
|
+
useImperativeHandle(ref, () => inputRef.current);
|
|
1071
|
+
function handleChange(event) {
|
|
1072
|
+
if (!isControlled) {
|
|
1073
|
+
setInternalValue(event.currentTarget.value);
|
|
975
1074
|
}
|
|
976
|
-
onChange?.(
|
|
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);
|
|
1075
|
+
onChange?.(event);
|
|
982
1076
|
}
|
|
983
|
-
function
|
|
984
|
-
const
|
|
985
|
-
if (!
|
|
1077
|
+
function handleClear() {
|
|
1078
|
+
const input = inputRef.current;
|
|
1079
|
+
if (!input || disabled) {
|
|
986
1080
|
return;
|
|
987
1081
|
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
function handleQuickJumpKeyDown(event) {
|
|
992
|
-
if (event.key !== "Enter") {
|
|
993
|
-
return;
|
|
1082
|
+
input.value = "";
|
|
1083
|
+
if (!isControlled) {
|
|
1084
|
+
setInternalValue("");
|
|
994
1085
|
}
|
|
995
|
-
|
|
1086
|
+
onChange?.({
|
|
1087
|
+
currentTarget: input,
|
|
1088
|
+
target: input,
|
|
1089
|
+
type: "change"
|
|
1090
|
+
});
|
|
1091
|
+
input.focus();
|
|
996
1092
|
}
|
|
997
|
-
const
|
|
998
|
-
const nextDisabled = disabled || mergedCurrent >= pageCount;
|
|
999
|
-
return /* @__PURE__ */ jsxs5("nav", {
|
|
1093
|
+
const control = /* @__PURE__ */ jsx6("input", {
|
|
1000
1094
|
...props,
|
|
1001
|
-
ref,
|
|
1002
|
-
|
|
1095
|
+
ref: inputRef,
|
|
1096
|
+
type,
|
|
1097
|
+
className: getInputClasses({ size, status, variant, className }),
|
|
1098
|
+
disabled,
|
|
1099
|
+
value: currentValue,
|
|
1100
|
+
onChange: handleChange
|
|
1101
|
+
});
|
|
1102
|
+
if (!hasAffix) {
|
|
1103
|
+
return control;
|
|
1104
|
+
}
|
|
1105
|
+
const showClear = allowClear && !disabled && currentValue.length > 0;
|
|
1106
|
+
return /* @__PURE__ */ jsxs5("span", {
|
|
1107
|
+
className: getInputWrapperClasses({ affixed: hasAffix }),
|
|
1003
1108
|
children: [
|
|
1004
|
-
|
|
1005
|
-
className:
|
|
1006
|
-
children:
|
|
1007
|
-
className: paginationInfoTextClass,
|
|
1008
|
-
children: showTotal(total, range)
|
|
1009
|
-
})
|
|
1109
|
+
prefix != null ? /* @__PURE__ */ jsx6("span", {
|
|
1110
|
+
className: inputPrefixClass,
|
|
1111
|
+
children: prefix
|
|
1010
1112
|
}) : null,
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
className: paginationPrevClass,
|
|
1014
|
-
disabled: previousDisabled,
|
|
1015
|
-
"aria-label": "Previous page",
|
|
1016
|
-
onClick: () => changePage(mergedCurrent - 1),
|
|
1017
|
-
children: "Prev"
|
|
1018
|
-
}),
|
|
1019
|
-
simple ? /* @__PURE__ */ jsxs5("div", {
|
|
1020
|
-
className: paginationInputClass,
|
|
1021
|
-
children: [
|
|
1022
|
-
/* @__PURE__ */ jsx6("input", {
|
|
1023
|
-
"aria-label": "Current page",
|
|
1024
|
-
type: "number",
|
|
1025
|
-
min: 1,
|
|
1026
|
-
max: pageCount,
|
|
1027
|
-
value: quickJumpValue || String(mergedCurrent),
|
|
1028
|
-
disabled,
|
|
1029
|
-
onChange: (event) => setQuickJumpValue(event.currentTarget.value),
|
|
1030
|
-
onKeyDown: handleQuickJumpKeyDown,
|
|
1031
|
-
onBlur: (event) => {
|
|
1032
|
-
if (event.currentTarget.value !== String(mergedCurrent)) {
|
|
1033
|
-
jumpToInputPage(event.currentTarget.value);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
}),
|
|
1037
|
-
/* @__PURE__ */ jsxs5("span", {
|
|
1038
|
-
className: paginationInfoTextClass,
|
|
1039
|
-
children: [
|
|
1040
|
-
"/ ",
|
|
1041
|
-
pageCount
|
|
1042
|
-
]
|
|
1043
|
-
})
|
|
1044
|
-
]
|
|
1045
|
-
}) : pageTokens.map((pageToken, index) => pageToken === "ellipsis" ? /* @__PURE__ */ jsx6("span", {
|
|
1046
|
-
"aria-hidden": "true",
|
|
1047
|
-
className: paginationEllipsisClass
|
|
1048
|
-
}, `ellipsis-${index}`) : /* @__PURE__ */ jsx6("button", {
|
|
1049
|
-
type: "button",
|
|
1050
|
-
className: getPaginationItemClasses({
|
|
1051
|
-
active: pageToken === mergedCurrent,
|
|
1052
|
-
disabled
|
|
1053
|
-
}),
|
|
1054
|
-
disabled,
|
|
1055
|
-
"aria-current": pageToken === mergedCurrent ? "page" : undefined,
|
|
1056
|
-
"aria-label": `Page ${pageToken}`,
|
|
1057
|
-
onClick: () => changePage(pageToken),
|
|
1058
|
-
children: pageToken
|
|
1059
|
-
}, pageToken)),
|
|
1060
|
-
/* @__PURE__ */ jsx6("button", {
|
|
1113
|
+
control,
|
|
1114
|
+
showClear ? /* @__PURE__ */ jsx6("button", {
|
|
1061
1115
|
type: "button",
|
|
1062
|
-
className:
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
children: "Next"
|
|
1067
|
-
}),
|
|
1068
|
-
showSizeChanger ? /* @__PURE__ */ jsx6("div", {
|
|
1069
|
-
className: paginationInputClass,
|
|
1070
|
-
children: /* @__PURE__ */ jsx6("select", {
|
|
1071
|
-
"aria-label": "Page size",
|
|
1072
|
-
value: mergedPageSize,
|
|
1073
|
-
disabled,
|
|
1074
|
-
onChange: handlePageSizeChange,
|
|
1075
|
-
children: getSizeOptions(mergedPageSize).map((option) => /* @__PURE__ */ jsxs5("option", {
|
|
1076
|
-
value: option,
|
|
1077
|
-
children: [
|
|
1078
|
-
option,
|
|
1079
|
-
" / page"
|
|
1080
|
-
]
|
|
1081
|
-
}, option))
|
|
1082
|
-
})
|
|
1116
|
+
className: inputClearClass,
|
|
1117
|
+
"aria-label": "Clear input",
|
|
1118
|
+
onClick: handleClear,
|
|
1119
|
+
children: "x"
|
|
1083
1120
|
}) : null,
|
|
1084
|
-
|
|
1085
|
-
className:
|
|
1086
|
-
children:
|
|
1087
|
-
"aria-label": "Jump to page",
|
|
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
|
-
})
|
|
1121
|
+
suffix != null ? /* @__PURE__ */ jsx6("span", {
|
|
1122
|
+
className: inputSuffixClass,
|
|
1123
|
+
children: suffix
|
|
1096
1124
|
}) : null
|
|
1097
1125
|
]
|
|
1098
1126
|
});
|
|
1099
1127
|
});
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
useMemo as useMemo4,
|
|
1106
|
-
useRef,
|
|
1107
|
-
useState as useState4
|
|
1108
|
-
} from "react";
|
|
1109
|
-
|
|
1110
|
-
// src/classes/dm-pagination.ts
|
|
1111
|
-
var dmPaginationBaseClass = "dm-pagination";
|
|
1112
|
-
var dmPaginationHiddenClass = "dm-pagination-hidden";
|
|
1113
|
-
var dmPaginationPagerClass = "dm-pagination-pager";
|
|
1114
|
-
var dmPaginationRefreshClass = "dm-pagination-refresh";
|
|
1115
|
-
var dmPaginationRefreshLoadingClass = "dm-pagination-refresh-loading";
|
|
1116
|
-
var dmPaginationSelectedClass = "dm-pagination-selected";
|
|
1117
|
-
var dmPaginationAlignClasses = {
|
|
1118
|
-
left: "dm-pagination-left",
|
|
1119
|
-
center: "dm-pagination-center",
|
|
1120
|
-
right: "dm-pagination-right"
|
|
1121
|
-
};
|
|
1122
|
-
function getDmPaginationClasses({
|
|
1123
|
-
align = "right",
|
|
1124
|
-
hidden,
|
|
1125
|
-
className
|
|
1126
|
-
}) {
|
|
1127
|
-
return cn(dmPaginationBaseClass, dmPaginationAlignClasses[align], hidden && dmPaginationHiddenClass, className);
|
|
1128
|
-
}
|
|
1129
|
-
function getDmPaginationRefreshClasses({
|
|
1128
|
+
InputRoot.displayName = "Input";
|
|
1129
|
+
var Search = forwardRef4(({
|
|
1130
|
+
className,
|
|
1131
|
+
disabled,
|
|
1132
|
+
enterButton,
|
|
1130
1133
|
loading,
|
|
1131
|
-
|
|
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,
|
|
1134
|
+
onKeyDown,
|
|
1135
|
+
onSearch,
|
|
1207
1136
|
...props
|
|
1208
1137
|
}, ref) => {
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
const
|
|
1221
|
-
|
|
1222
|
-
|
|
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,
|
|
1138
|
+
const inputRef = useRef2(null);
|
|
1139
|
+
useImperativeHandle(ref, () => inputRef.current);
|
|
1140
|
+
function emitSearch(event) {
|
|
1141
|
+
onSearch?.(inputRef.current?.value ?? "", event);
|
|
1142
|
+
}
|
|
1143
|
+
function handleKeyDown(event) {
|
|
1144
|
+
onKeyDown?.(event);
|
|
1145
|
+
if (!event.defaultPrevented && event.key === "Enter") {
|
|
1146
|
+
emitSearch(event);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
const buttonContent = enterButton === true ? "Search" : enterButton ?? "Search";
|
|
1150
|
+
return /* @__PURE__ */ jsxs5("span", {
|
|
1151
|
+
className: getSearchWrapperClasses({ className }),
|
|
1257
1152
|
children: [
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
showSizeChanger,
|
|
1266
|
-
showTotal: totalRenderer
|
|
1267
|
-
})
|
|
1268
|
-
}) : null,
|
|
1269
|
-
isRefreshVisible ? /* @__PURE__ */ jsxs6("button", {
|
|
1153
|
+
/* @__PURE__ */ jsx6(InputRoot, {
|
|
1154
|
+
...props,
|
|
1155
|
+
ref: inputRef,
|
|
1156
|
+
disabled,
|
|
1157
|
+
onKeyDown: handleKeyDown
|
|
1158
|
+
}),
|
|
1159
|
+
enterButton || loading ? /* @__PURE__ */ jsx6("button", {
|
|
1270
1160
|
type: "button",
|
|
1271
|
-
className:
|
|
1272
|
-
disabled:
|
|
1161
|
+
className: inputSearchButtonClass,
|
|
1162
|
+
disabled: disabled || loading,
|
|
1273
1163
|
"aria-busy": loading || undefined,
|
|
1274
|
-
onClick:
|
|
1275
|
-
children:
|
|
1276
|
-
/* @__PURE__ */ jsx7("span", {
|
|
1277
|
-
"aria-hidden": "true",
|
|
1278
|
-
children: "Reload"
|
|
1279
|
-
}),
|
|
1280
|
-
/* @__PURE__ */ jsx7("span", {
|
|
1281
|
-
children: mergedLocale.refresh
|
|
1282
|
-
})
|
|
1283
|
-
]
|
|
1164
|
+
onClick: emitSearch,
|
|
1165
|
+
children: loading ? "Loading" : buttonContent
|
|
1284
1166
|
}) : null
|
|
1285
1167
|
]
|
|
1286
1168
|
});
|
|
1287
1169
|
});
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
var
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
};
|
|
1323
|
-
var inputStatusClasses = {
|
|
1324
|
-
error: "input-error",
|
|
1325
|
-
success: "input-success"
|
|
1326
|
-
};
|
|
1327
|
-
var textAreaVariantClasses = {
|
|
1328
|
-
filled: "textarea-filled",
|
|
1329
|
-
outlined: "textarea-outlined"
|
|
1330
|
-
};
|
|
1331
|
-
var textAreaSizeClasses = {
|
|
1332
|
-
sm: "textarea-sm",
|
|
1333
|
-
md: "",
|
|
1334
|
-
lg: "textarea-lg"
|
|
1335
|
-
};
|
|
1336
|
-
var textAreaStatusClasses = {
|
|
1337
|
-
error: "textarea-error",
|
|
1338
|
-
success: "textarea-success"
|
|
1339
|
-
};
|
|
1340
|
-
var textAreaResizeClasses = {
|
|
1341
|
-
none: "textarea-resize-none",
|
|
1342
|
-
both: "textarea-resize-both",
|
|
1343
|
-
horizontal: "textarea-resize-horizontal",
|
|
1344
|
-
vertical: "textarea-resize-vertical"
|
|
1345
|
-
};
|
|
1346
|
-
function getInputClasses({
|
|
1170
|
+
Search.displayName = "Input.Search";
|
|
1171
|
+
var Password = forwardRef4(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
|
|
1172
|
+
const [visible, setVisible] = useState4(false);
|
|
1173
|
+
const type = visible ? "text" : "password";
|
|
1174
|
+
const toggle = visibilityToggle ? /* @__PURE__ */ jsx6("button", {
|
|
1175
|
+
type: "button",
|
|
1176
|
+
className: inputPasswordToggleClass,
|
|
1177
|
+
disabled,
|
|
1178
|
+
"aria-label": visible ? "Hide password" : "Show password",
|
|
1179
|
+
onClick: () => {
|
|
1180
|
+
setVisible((current) => !current);
|
|
1181
|
+
},
|
|
1182
|
+
children: visible ? "Hide" : "Show"
|
|
1183
|
+
}) : undefined;
|
|
1184
|
+
return /* @__PURE__ */ jsx6("span", {
|
|
1185
|
+
className: getPasswordWrapperClasses({ className }),
|
|
1186
|
+
children: /* @__PURE__ */ jsx6(InputRoot, {
|
|
1187
|
+
...props,
|
|
1188
|
+
ref,
|
|
1189
|
+
disabled,
|
|
1190
|
+
type,
|
|
1191
|
+
suffix: toggle
|
|
1192
|
+
})
|
|
1193
|
+
});
|
|
1194
|
+
});
|
|
1195
|
+
Password.displayName = "Input.Password";
|
|
1196
|
+
var TextArea = forwardRef4(({
|
|
1197
|
+
autoSize,
|
|
1198
|
+
className,
|
|
1199
|
+
defaultValue,
|
|
1200
|
+
maxLength,
|
|
1201
|
+
onChange,
|
|
1202
|
+
resize = "vertical",
|
|
1203
|
+
showCount,
|
|
1347
1204
|
size = "md",
|
|
1348
1205
|
status,
|
|
1349
|
-
|
|
1350
|
-
className
|
|
1351
|
-
}) {
|
|
1352
|
-
return cn(inputBaseClass, inputVariantClasses[variant], inputSizeClasses[size], status && inputStatusClasses[status], className);
|
|
1353
|
-
}
|
|
1354
|
-
function getInputWrapperClasses({
|
|
1355
|
-
affixed,
|
|
1356
|
-
className
|
|
1357
|
-
}) {
|
|
1358
|
-
return cn(inputWrapperClass, affixed && inputAffixWrapperClass, className);
|
|
1359
|
-
}
|
|
1360
|
-
function getSearchWrapperClasses({ className }) {
|
|
1361
|
-
return cn(inputSearchClass, className);
|
|
1362
|
-
}
|
|
1363
|
-
function getPasswordWrapperClasses({
|
|
1364
|
-
className
|
|
1365
|
-
}) {
|
|
1366
|
-
return cn(inputPasswordClass, className);
|
|
1367
|
-
}
|
|
1368
|
-
function getTextAreaClasses({
|
|
1369
|
-
size = "md",
|
|
1370
|
-
status,
|
|
1371
|
-
variant = "outlined",
|
|
1372
|
-
resize = "vertical",
|
|
1373
|
-
autoSize,
|
|
1374
|
-
className
|
|
1375
|
-
}) {
|
|
1376
|
-
return cn(textAreaBaseClass, textAreaVariantClasses[variant], textAreaSizeClasses[size], status && textAreaStatusClasses[status], textAreaResizeClasses[resize], autoSize && textAreaAutoSizeClass, className);
|
|
1377
|
-
}
|
|
1378
|
-
function getTextAreaCountClasses({ exceeded }) {
|
|
1379
|
-
return cn(textAreaCountClass, exceeded && textAreaCountExceededClass);
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
// src/components/input/Input.tsx
|
|
1383
|
-
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1384
|
-
function toTextValue(value) {
|
|
1385
|
-
if (Array.isArray(value)) {
|
|
1386
|
-
return value.join(",");
|
|
1387
|
-
}
|
|
1388
|
-
return value == null ? "" : String(value);
|
|
1389
|
-
}
|
|
1390
|
-
var InputRoot = forwardRef5(({
|
|
1391
|
-
allowClear,
|
|
1392
|
-
className,
|
|
1393
|
-
defaultValue,
|
|
1394
|
-
disabled,
|
|
1395
|
-
onChange,
|
|
1396
|
-
prefix,
|
|
1397
|
-
size = "md",
|
|
1398
|
-
status,
|
|
1399
|
-
suffix,
|
|
1400
|
-
type = "text",
|
|
1401
|
-
value,
|
|
1402
|
-
variant = "outlined",
|
|
1403
|
-
...props
|
|
1404
|
-
}, ref) => {
|
|
1405
|
-
const inputRef = useRef2(null);
|
|
1406
|
-
const [internalValue, setInternalValue] = useState5(() => toTextValue(defaultValue));
|
|
1407
|
-
const isControlled = value !== undefined;
|
|
1408
|
-
const currentValue = isControlled ? toTextValue(value) : internalValue;
|
|
1409
|
-
const hasAffix = prefix != null || suffix != null || allowClear;
|
|
1410
|
-
useImperativeHandle(ref, () => inputRef.current);
|
|
1411
|
-
function handleChange(event) {
|
|
1412
|
-
if (!isControlled) {
|
|
1413
|
-
setInternalValue(event.currentTarget.value);
|
|
1414
|
-
}
|
|
1415
|
-
onChange?.(event);
|
|
1416
|
-
}
|
|
1417
|
-
function handleClear() {
|
|
1418
|
-
const input = inputRef.current;
|
|
1419
|
-
if (!input || disabled) {
|
|
1420
|
-
return;
|
|
1421
|
-
}
|
|
1422
|
-
input.value = "";
|
|
1423
|
-
if (!isControlled) {
|
|
1424
|
-
setInternalValue("");
|
|
1425
|
-
}
|
|
1426
|
-
onChange?.({
|
|
1427
|
-
currentTarget: input,
|
|
1428
|
-
target: input,
|
|
1429
|
-
type: "change"
|
|
1430
|
-
});
|
|
1431
|
-
input.focus();
|
|
1432
|
-
}
|
|
1433
|
-
const control = /* @__PURE__ */ jsx8("input", {
|
|
1434
|
-
...props,
|
|
1435
|
-
ref: inputRef,
|
|
1436
|
-
type,
|
|
1437
|
-
className: getInputClasses({ size, status, variant, className }),
|
|
1438
|
-
disabled,
|
|
1439
|
-
value: currentValue,
|
|
1440
|
-
onChange: handleChange
|
|
1441
|
-
});
|
|
1442
|
-
if (!hasAffix) {
|
|
1443
|
-
return control;
|
|
1444
|
-
}
|
|
1445
|
-
const showClear = allowClear && !disabled && currentValue.length > 0;
|
|
1446
|
-
return /* @__PURE__ */ jsxs7("span", {
|
|
1447
|
-
className: getInputWrapperClasses({ affixed: hasAffix }),
|
|
1448
|
-
children: [
|
|
1449
|
-
prefix != null ? /* @__PURE__ */ jsx8("span", {
|
|
1450
|
-
className: inputPrefixClass,
|
|
1451
|
-
children: prefix
|
|
1452
|
-
}) : null,
|
|
1453
|
-
control,
|
|
1454
|
-
showClear ? /* @__PURE__ */ jsx8("button", {
|
|
1455
|
-
type: "button",
|
|
1456
|
-
className: inputClearClass,
|
|
1457
|
-
"aria-label": "Clear input",
|
|
1458
|
-
onClick: handleClear,
|
|
1459
|
-
children: "x"
|
|
1460
|
-
}) : null,
|
|
1461
|
-
suffix != null ? /* @__PURE__ */ jsx8("span", {
|
|
1462
|
-
className: inputSuffixClass,
|
|
1463
|
-
children: suffix
|
|
1464
|
-
}) : null
|
|
1465
|
-
]
|
|
1466
|
-
});
|
|
1467
|
-
});
|
|
1468
|
-
InputRoot.displayName = "Input";
|
|
1469
|
-
var Search = forwardRef5(({
|
|
1470
|
-
className,
|
|
1471
|
-
disabled,
|
|
1472
|
-
enterButton,
|
|
1473
|
-
loading,
|
|
1474
|
-
onKeyDown,
|
|
1475
|
-
onSearch,
|
|
1476
|
-
...props
|
|
1477
|
-
}, ref) => {
|
|
1478
|
-
const inputRef = useRef2(null);
|
|
1479
|
-
useImperativeHandle(ref, () => inputRef.current);
|
|
1480
|
-
function emitSearch(event) {
|
|
1481
|
-
onSearch?.(inputRef.current?.value ?? "", event);
|
|
1482
|
-
}
|
|
1483
|
-
function handleKeyDown(event) {
|
|
1484
|
-
onKeyDown?.(event);
|
|
1485
|
-
if (!event.defaultPrevented && event.key === "Enter") {
|
|
1486
|
-
emitSearch(event);
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
const buttonContent = enterButton === true ? "Search" : enterButton ?? "Search";
|
|
1490
|
-
return /* @__PURE__ */ jsxs7("span", {
|
|
1491
|
-
className: getSearchWrapperClasses({ className }),
|
|
1492
|
-
children: [
|
|
1493
|
-
/* @__PURE__ */ jsx8(InputRoot, {
|
|
1494
|
-
...props,
|
|
1495
|
-
ref: inputRef,
|
|
1496
|
-
disabled,
|
|
1497
|
-
onKeyDown: handleKeyDown
|
|
1498
|
-
}),
|
|
1499
|
-
enterButton || loading ? /* @__PURE__ */ jsx8("button", {
|
|
1500
|
-
type: "button",
|
|
1501
|
-
className: inputSearchButtonClass,
|
|
1502
|
-
disabled: disabled || loading,
|
|
1503
|
-
"aria-busy": loading || undefined,
|
|
1504
|
-
onClick: emitSearch,
|
|
1505
|
-
children: loading ? "Loading" : buttonContent
|
|
1506
|
-
}) : null
|
|
1507
|
-
]
|
|
1508
|
-
});
|
|
1509
|
-
});
|
|
1510
|
-
Search.displayName = "Input.Search";
|
|
1511
|
-
var Password = forwardRef5(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
|
|
1512
|
-
const [visible, setVisible] = useState5(false);
|
|
1513
|
-
const type = visible ? "text" : "password";
|
|
1514
|
-
const toggle = visibilityToggle ? /* @__PURE__ */ jsx8("button", {
|
|
1515
|
-
type: "button",
|
|
1516
|
-
className: inputPasswordToggleClass,
|
|
1517
|
-
disabled,
|
|
1518
|
-
"aria-label": visible ? "Hide password" : "Show password",
|
|
1519
|
-
onClick: () => {
|
|
1520
|
-
setVisible((current) => !current);
|
|
1521
|
-
},
|
|
1522
|
-
children: visible ? "Hide" : "Show"
|
|
1523
|
-
}) : undefined;
|
|
1524
|
-
return /* @__PURE__ */ jsx8("span", {
|
|
1525
|
-
className: getPasswordWrapperClasses({ className }),
|
|
1526
|
-
children: /* @__PURE__ */ jsx8(InputRoot, {
|
|
1527
|
-
...props,
|
|
1528
|
-
ref,
|
|
1529
|
-
disabled,
|
|
1530
|
-
type,
|
|
1531
|
-
suffix: toggle
|
|
1532
|
-
})
|
|
1533
|
-
});
|
|
1534
|
-
});
|
|
1535
|
-
Password.displayName = "Input.Password";
|
|
1536
|
-
var TextArea = forwardRef5(({
|
|
1537
|
-
autoSize,
|
|
1538
|
-
className,
|
|
1539
|
-
defaultValue,
|
|
1540
|
-
maxLength,
|
|
1541
|
-
onChange,
|
|
1542
|
-
resize = "vertical",
|
|
1543
|
-
showCount,
|
|
1544
|
-
size = "md",
|
|
1545
|
-
status,
|
|
1546
|
-
value,
|
|
1206
|
+
value,
|
|
1547
1207
|
variant = "outlined",
|
|
1548
1208
|
...props
|
|
1549
1209
|
}, ref) => {
|
|
1550
|
-
const [internalValue, setInternalValue] =
|
|
1210
|
+
const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
|
|
1551
1211
|
const isControlled = value !== undefined;
|
|
1552
1212
|
const currentValue = isControlled ? toTextValue(value) : internalValue;
|
|
1553
1213
|
const count = currentValue.length;
|
|
@@ -1558,7 +1218,7 @@ var TextArea = forwardRef5(({
|
|
|
1558
1218
|
}
|
|
1559
1219
|
onChange?.(event);
|
|
1560
1220
|
}
|
|
1561
|
-
const control = /* @__PURE__ */
|
|
1221
|
+
const control = /* @__PURE__ */ jsx6("textarea", {
|
|
1562
1222
|
...props,
|
|
1563
1223
|
ref,
|
|
1564
1224
|
className: getTextAreaClasses({
|
|
@@ -1576,11 +1236,11 @@ var TextArea = forwardRef5(({
|
|
|
1576
1236
|
if (!showCount) {
|
|
1577
1237
|
return control;
|
|
1578
1238
|
}
|
|
1579
|
-
return /* @__PURE__ */
|
|
1239
|
+
return /* @__PURE__ */ jsxs5("span", {
|
|
1580
1240
|
className: textAreaWrapperClass,
|
|
1581
1241
|
children: [
|
|
1582
1242
|
control,
|
|
1583
|
-
/* @__PURE__ */
|
|
1243
|
+
/* @__PURE__ */ jsxs5("span", {
|
|
1584
1244
|
className: getTextAreaCountClasses({ exceeded }),
|
|
1585
1245
|
children: [
|
|
1586
1246
|
count,
|
|
@@ -1591,7 +1251,7 @@ var TextArea = forwardRef5(({
|
|
|
1591
1251
|
});
|
|
1592
1252
|
});
|
|
1593
1253
|
TextArea.displayName = "Input.TextArea";
|
|
1594
|
-
var Group =
|
|
1254
|
+
var Group = forwardRef4(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
|
|
1595
1255
|
...props,
|
|
1596
1256
|
ref,
|
|
1597
1257
|
className: cn(inputGroupClass, className),
|
|
@@ -1605,7 +1265,7 @@ var Input = Object.assign(InputRoot, {
|
|
|
1605
1265
|
Group
|
|
1606
1266
|
});
|
|
1607
1267
|
// src/components/select/Select.tsx
|
|
1608
|
-
import
|
|
1268
|
+
import React5, { forwardRef as forwardRef5, useMemo as useMemo4, useState as useState5 } from "react";
|
|
1609
1269
|
|
|
1610
1270
|
// src/classes/select.ts
|
|
1611
1271
|
var selectContainerClass = "select-container";
|
|
@@ -1661,7 +1321,7 @@ function getSelectOptionClasses({
|
|
|
1661
1321
|
}
|
|
1662
1322
|
|
|
1663
1323
|
// src/components/select/Select.tsx
|
|
1664
|
-
import { jsx as
|
|
1324
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1665
1325
|
function isGroup(option) {
|
|
1666
1326
|
return "options" in option;
|
|
1667
1327
|
}
|
|
@@ -1686,8 +1346,8 @@ function normalizeMultiValue(value) {
|
|
|
1686
1346
|
}
|
|
1687
1347
|
function optionsFromChildren(children) {
|
|
1688
1348
|
const result = [];
|
|
1689
|
-
|
|
1690
|
-
if (!
|
|
1349
|
+
React5.Children.forEach(children, (child) => {
|
|
1350
|
+
if (!React5.isValidElement(child)) {
|
|
1691
1351
|
return;
|
|
1692
1352
|
}
|
|
1693
1353
|
if (child.type === Option) {
|
|
@@ -1737,19 +1397,19 @@ function filterOptions(options, searchValue, filterOption) {
|
|
|
1737
1397
|
function renderValue(option) {
|
|
1738
1398
|
return option ? optionLabel(option) : null;
|
|
1739
1399
|
}
|
|
1740
|
-
var Option =
|
|
1400
|
+
var Option = forwardRef5(({ children, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
|
|
1741
1401
|
...props,
|
|
1742
1402
|
ref,
|
|
1743
1403
|
children
|
|
1744
1404
|
}));
|
|
1745
1405
|
Option.displayName = "Select.Option";
|
|
1746
|
-
var OptGroup =
|
|
1406
|
+
var OptGroup = forwardRef5(({ children, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
|
|
1747
1407
|
...props,
|
|
1748
1408
|
ref,
|
|
1749
1409
|
children
|
|
1750
1410
|
}));
|
|
1751
1411
|
OptGroup.displayName = "Select.OptGroup";
|
|
1752
|
-
var SelectRoot =
|
|
1412
|
+
var SelectRoot = forwardRef5(({
|
|
1753
1413
|
allowClear,
|
|
1754
1414
|
children,
|
|
1755
1415
|
className,
|
|
@@ -1768,11 +1428,11 @@ var SelectRoot = forwardRef6(({
|
|
|
1768
1428
|
...props
|
|
1769
1429
|
}, ref) => {
|
|
1770
1430
|
const multiple = mode === "multiple" || mode === "tags";
|
|
1771
|
-
const sourceOptions =
|
|
1772
|
-
const flatOptions =
|
|
1773
|
-
const [open, setOpen] =
|
|
1774
|
-
const [searchValue, setSearchValue] =
|
|
1775
|
-
const [internalValue, setInternalValue] =
|
|
1431
|
+
const sourceOptions = useMemo4(() => options ?? optionsFromChildren(children), [children, options]);
|
|
1432
|
+
const flatOptions = useMemo4(() => flattenOptions(sourceOptions), [sourceOptions]);
|
|
1433
|
+
const [open, setOpen] = useState5(false);
|
|
1434
|
+
const [searchValue, setSearchValue] = useState5("");
|
|
1435
|
+
const [internalValue, setInternalValue] = useState5(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
|
|
1776
1436
|
const controlled = value !== undefined;
|
|
1777
1437
|
const currentValue = controlled ? value : internalValue;
|
|
1778
1438
|
const selectedValues = multiple ? normalizeMultiValue(currentValue) : normalizeSingleValue(currentValue) === undefined ? [] : [normalizeSingleValue(currentValue)];
|
|
@@ -1829,7 +1489,7 @@ var SelectRoot = forwardRef6(({
|
|
|
1829
1489
|
}
|
|
1830
1490
|
function renderOption(option) {
|
|
1831
1491
|
const selected = selectedKeys.has(valueKey(option.value));
|
|
1832
|
-
return /* @__PURE__ */
|
|
1492
|
+
return /* @__PURE__ */ jsx7("button", {
|
|
1833
1493
|
type: "button",
|
|
1834
1494
|
role: "option",
|
|
1835
1495
|
"aria-selected": selected,
|
|
@@ -1848,11 +1508,11 @@ var SelectRoot = forwardRef6(({
|
|
|
1848
1508
|
if (!isGroup(option)) {
|
|
1849
1509
|
return renderOption(option);
|
|
1850
1510
|
}
|
|
1851
|
-
return /* @__PURE__ */
|
|
1511
|
+
return /* @__PURE__ */ jsxs6("div", {
|
|
1852
1512
|
className: cn(selectGroupClass, option.className),
|
|
1853
1513
|
role: "group",
|
|
1854
1514
|
children: [
|
|
1855
|
-
/* @__PURE__ */
|
|
1515
|
+
/* @__PURE__ */ jsx7("div", {
|
|
1856
1516
|
className: selectGroupLabelClass,
|
|
1857
1517
|
children: option.label
|
|
1858
1518
|
}),
|
|
@@ -1861,11 +1521,11 @@ var SelectRoot = forwardRef6(({
|
|
|
1861
1521
|
}, `group-${index}`);
|
|
1862
1522
|
});
|
|
1863
1523
|
}
|
|
1864
|
-
const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */
|
|
1524
|
+
const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx7("span", {
|
|
1865
1525
|
className: selectTagClass,
|
|
1866
1526
|
children: renderValue(option)
|
|
1867
1527
|
}, valueKey(option.value))) : renderValue(selectedOptions[0]);
|
|
1868
|
-
return /* @__PURE__ */
|
|
1528
|
+
return /* @__PURE__ */ jsxs6("div", {
|
|
1869
1529
|
...props,
|
|
1870
1530
|
ref,
|
|
1871
1531
|
className: getSelectContainerClasses({
|
|
@@ -1876,7 +1536,7 @@ var SelectRoot = forwardRef6(({
|
|
|
1876
1536
|
className
|
|
1877
1537
|
}),
|
|
1878
1538
|
children: [
|
|
1879
|
-
/* @__PURE__ */
|
|
1539
|
+
/* @__PURE__ */ jsxs6("button", {
|
|
1880
1540
|
type: "button",
|
|
1881
1541
|
className: getSelectClasses({ size, status, disabled }),
|
|
1882
1542
|
disabled: disabled || loading,
|
|
@@ -1884,33 +1544,33 @@ var SelectRoot = forwardRef6(({
|
|
|
1884
1544
|
"aria-expanded": open,
|
|
1885
1545
|
onClick: () => setOpen((current) => !current),
|
|
1886
1546
|
children: [
|
|
1887
|
-
/* @__PURE__ */
|
|
1547
|
+
/* @__PURE__ */ jsx7("span", {
|
|
1888
1548
|
className: selectSelectionClass,
|
|
1889
|
-
children: hasValue ? selection : /* @__PURE__ */
|
|
1549
|
+
children: hasValue ? selection : /* @__PURE__ */ jsx7("span", {
|
|
1890
1550
|
className: selectPlaceholderClass,
|
|
1891
1551
|
children: placeholder
|
|
1892
1552
|
})
|
|
1893
1553
|
}),
|
|
1894
|
-
/* @__PURE__ */
|
|
1554
|
+
/* @__PURE__ */ jsx7("span", {
|
|
1895
1555
|
className: selectIconClass,
|
|
1896
1556
|
"aria-hidden": "true",
|
|
1897
1557
|
children: "v"
|
|
1898
1558
|
})
|
|
1899
1559
|
]
|
|
1900
1560
|
}),
|
|
1901
|
-
allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */
|
|
1561
|
+
allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx7("button", {
|
|
1902
1562
|
type: "button",
|
|
1903
1563
|
className: selectClearClass,
|
|
1904
1564
|
"aria-label": "Clear selection",
|
|
1905
1565
|
onClick: clearValue,
|
|
1906
1566
|
children: "x"
|
|
1907
1567
|
}) : null,
|
|
1908
|
-
open ? /* @__PURE__ */
|
|
1568
|
+
open ? /* @__PURE__ */ jsxs6("div", {
|
|
1909
1569
|
className: selectDropdownClass,
|
|
1910
1570
|
role: "listbox",
|
|
1911
1571
|
"aria-multiselectable": multiple || undefined,
|
|
1912
1572
|
children: [
|
|
1913
|
-
searchable ? /* @__PURE__ */
|
|
1573
|
+
searchable ? /* @__PURE__ */ jsx7("input", {
|
|
1914
1574
|
className: selectSearchClass,
|
|
1915
1575
|
value: searchValue,
|
|
1916
1576
|
placeholder: typeof placeholder === "string" ? placeholder : undefined,
|
|
@@ -1922,7 +1582,7 @@ var SelectRoot = forwardRef6(({
|
|
|
1922
1582
|
}
|
|
1923
1583
|
}
|
|
1924
1584
|
}) : null,
|
|
1925
|
-
visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */
|
|
1585
|
+
visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx7("div", {
|
|
1926
1586
|
className: selectEmptyClass,
|
|
1927
1587
|
children: "No data"
|
|
1928
1588
|
})
|
|
@@ -1936,32 +1596,7 @@ var Select = SelectRoot;
|
|
|
1936
1596
|
Select.Option = Option;
|
|
1937
1597
|
Select.OptGroup = OptGroup;
|
|
1938
1598
|
// 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";
|
|
1599
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1965
1600
|
function initialValues(items, searchParams, useSearchParams = true) {
|
|
1966
1601
|
return items.reduce((acc, item) => {
|
|
1967
1602
|
const defaultValue = item.search.extraProps?.value ?? item.search.formProps?.initialValue;
|
|
@@ -1985,7 +1620,7 @@ function renderField({
|
|
|
1985
1620
|
return item.search.render?.(value, setValue, item) ?? null;
|
|
1986
1621
|
}
|
|
1987
1622
|
if (item.search.type === "select") {
|
|
1988
|
-
return /* @__PURE__ */
|
|
1623
|
+
return /* @__PURE__ */ jsx8(Select, {
|
|
1989
1624
|
...extraProps,
|
|
1990
1625
|
disabled: Boolean(loading || extraProps.disabled),
|
|
1991
1626
|
value,
|
|
@@ -1994,25 +1629,25 @@ function renderField({
|
|
|
1994
1629
|
});
|
|
1995
1630
|
}
|
|
1996
1631
|
if (item.search.type === "dateRange") {
|
|
1997
|
-
return /* @__PURE__ */
|
|
1632
|
+
return /* @__PURE__ */ jsx8(DatePicker.RangePicker, {
|
|
1998
1633
|
...extraProps,
|
|
1999
1634
|
value,
|
|
2000
1635
|
onChange: (nextValue) => setValue(nextValue)
|
|
2001
1636
|
});
|
|
2002
1637
|
}
|
|
2003
1638
|
if (item.search.type === "date") {
|
|
2004
|
-
return /* @__PURE__ */
|
|
1639
|
+
return /* @__PURE__ */ jsx8(DatePicker, {
|
|
2005
1640
|
...extraProps,
|
|
2006
1641
|
value,
|
|
2007
1642
|
onChange: (nextValue) => setValue(nextValue)
|
|
2008
1643
|
});
|
|
2009
1644
|
}
|
|
2010
1645
|
if (item.search.type === "radio" || item.search.type === "checkbox") {
|
|
2011
|
-
return /* @__PURE__ */
|
|
1646
|
+
return /* @__PURE__ */ jsx8("div", {
|
|
2012
1647
|
role: item.search.type === "radio" ? "radiogroup" : "group",
|
|
2013
|
-
children: optionList(extraProps).map((option) => /* @__PURE__ */
|
|
1648
|
+
children: optionList(extraProps).map((option) => /* @__PURE__ */ jsxs7("label", {
|
|
2014
1649
|
children: [
|
|
2015
|
-
/* @__PURE__ */
|
|
1650
|
+
/* @__PURE__ */ jsx8("input", {
|
|
2016
1651
|
type: item.search.type,
|
|
2017
1652
|
disabled: loading,
|
|
2018
1653
|
checked: item.search.type === "checkbox" ? Array.isArray(value) && value.includes(option.value) : value === option.value,
|
|
@@ -2030,7 +1665,7 @@ function renderField({
|
|
|
2030
1665
|
}, String(option.value)))
|
|
2031
1666
|
});
|
|
2032
1667
|
}
|
|
2033
|
-
return /* @__PURE__ */
|
|
1668
|
+
return /* @__PURE__ */ jsx8(Input, {
|
|
2034
1669
|
...extraProps,
|
|
2035
1670
|
type: item.search.type === "input-number" ? "number" : "text",
|
|
2036
1671
|
disabled: Boolean(loading || extraProps.disabled),
|
|
@@ -2044,7 +1679,7 @@ function renderField({
|
|
|
2044
1679
|
}
|
|
2045
1680
|
});
|
|
2046
1681
|
}
|
|
2047
|
-
var DmSearch =
|
|
1682
|
+
var DmSearch = forwardRef6(({
|
|
2048
1683
|
items = [],
|
|
2049
1684
|
onSearch,
|
|
2050
1685
|
extra,
|
|
@@ -2057,9 +1692,9 @@ var DmSearch = forwardRef7(({
|
|
|
2057
1692
|
enableDefaultPlaceHolder = false,
|
|
2058
1693
|
className
|
|
2059
1694
|
}, ref) => {
|
|
2060
|
-
const allItems =
|
|
2061
|
-
const [collapsed, setCollapsed] =
|
|
2062
|
-
const [values, setValues] =
|
|
1695
|
+
const allItems = useMemo5(() => fastFilterItem ? [fastFilterItem, ...items] : items, [fastFilterItem, items]);
|
|
1696
|
+
const [collapsed, setCollapsed] = useState6(defaultCollapsed);
|
|
1697
|
+
const [values, setValues] = useState6(() => initialValues(allItems, searchParams));
|
|
2063
1698
|
const visibleItems = collapsed ? allItems.slice(0, 1) : allItems;
|
|
2064
1699
|
useEffect2(() => {
|
|
2065
1700
|
setValues(initialValues(allItems, searchParams));
|
|
@@ -2074,7 +1709,7 @@ var DmSearch = forwardRef7(({
|
|
|
2074
1709
|
reset(false);
|
|
2075
1710
|
}
|
|
2076
1711
|
}));
|
|
2077
|
-
return /* @__PURE__ */
|
|
1712
|
+
return /* @__PURE__ */ jsxs7("form", {
|
|
2078
1713
|
id: "searchForm",
|
|
2079
1714
|
className: getDmSearchClasses({ compact, collapsed, className }),
|
|
2080
1715
|
onSubmit: (event) => {
|
|
@@ -2082,16 +1717,16 @@ var DmSearch = forwardRef7(({
|
|
|
2082
1717
|
onSearch?.(values);
|
|
2083
1718
|
},
|
|
2084
1719
|
children: [
|
|
2085
|
-
fastFilterItem ? /* @__PURE__ */
|
|
1720
|
+
fastFilterItem ? /* @__PURE__ */ jsx8("div", {
|
|
2086
1721
|
className: dmSearchFastFilterClass,
|
|
2087
1722
|
children: fastFilterItem.title
|
|
2088
1723
|
}) : null,
|
|
2089
|
-
/* @__PURE__ */
|
|
1724
|
+
/* @__PURE__ */ jsx8("div", {
|
|
2090
1725
|
className: dmSearchFieldsClass,
|
|
2091
|
-
children: visibleItems.map((item) => /* @__PURE__ */
|
|
1726
|
+
children: visibleItems.map((item) => /* @__PURE__ */ jsxs7("label", {
|
|
2092
1727
|
className: dmSearchFieldClass,
|
|
2093
1728
|
children: [
|
|
2094
|
-
compact ? null : /* @__PURE__ */
|
|
1729
|
+
compact ? null : /* @__PURE__ */ jsx8("span", {
|
|
2095
1730
|
children: item.title
|
|
2096
1731
|
}),
|
|
2097
1732
|
renderField({
|
|
@@ -2107,22 +1742,22 @@ var DmSearch = forwardRef7(({
|
|
|
2107
1742
|
]
|
|
2108
1743
|
}, item.key))
|
|
2109
1744
|
}),
|
|
2110
|
-
/* @__PURE__ */
|
|
1745
|
+
/* @__PURE__ */ jsxs7("div", {
|
|
2111
1746
|
className: dmSearchActionsClass,
|
|
2112
1747
|
children: [
|
|
2113
|
-
/* @__PURE__ */
|
|
1748
|
+
/* @__PURE__ */ jsx8(Button, {
|
|
2114
1749
|
type: "submit",
|
|
2115
1750
|
isLoading: loading,
|
|
2116
1751
|
children: "Search"
|
|
2117
1752
|
}),
|
|
2118
|
-
/* @__PURE__ */
|
|
1753
|
+
/* @__PURE__ */ jsx8(Button, {
|
|
2119
1754
|
type: "button",
|
|
2120
1755
|
color: "secondary",
|
|
2121
1756
|
appearance: "outline",
|
|
2122
1757
|
onClick: () => onSearch?.(reset(false)),
|
|
2123
1758
|
children: "Reset"
|
|
2124
1759
|
}),
|
|
2125
|
-
!hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */
|
|
1760
|
+
!hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */ jsx8(Button, {
|
|
2126
1761
|
type: "button",
|
|
2127
1762
|
color: "secondary",
|
|
2128
1763
|
appearance: "text",
|
|
@@ -2140,10 +1775,10 @@ var DmSearch = forwardRef7(({
|
|
|
2140
1775
|
});
|
|
2141
1776
|
DmSearch.displayName = "DmSearch";
|
|
2142
1777
|
// src/components/table/Table.tsx
|
|
2143
|
-
import
|
|
2144
|
-
forwardRef as
|
|
2145
|
-
useMemo as
|
|
2146
|
-
useState as
|
|
1778
|
+
import React7, {
|
|
1779
|
+
forwardRef as forwardRef7,
|
|
1780
|
+
useMemo as useMemo6,
|
|
1781
|
+
useState as useState7
|
|
2147
1782
|
} from "react";
|
|
2148
1783
|
|
|
2149
1784
|
// src/classes/table.ts
|
|
@@ -2193,7 +1828,7 @@ function getTableSorterClasses(active) {
|
|
|
2193
1828
|
}
|
|
2194
1829
|
|
|
2195
1830
|
// src/components/table/Table.tsx
|
|
2196
|
-
import { jsx as
|
|
1831
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2197
1832
|
import { createElement } from "react";
|
|
2198
1833
|
var defaultPageSize = 10;
|
|
2199
1834
|
var defaultSortDirections = ["ascend", "descend", null];
|
|
@@ -2226,8 +1861,8 @@ function getRecordKey(record, index, rowKey) {
|
|
|
2226
1861
|
return rowKey(record, index);
|
|
2227
1862
|
}
|
|
2228
1863
|
if (rowKey) {
|
|
2229
|
-
const
|
|
2230
|
-
return typeof
|
|
1864
|
+
const key = record[rowKey];
|
|
1865
|
+
return typeof key === "string" || typeof key === "number" ? key : index;
|
|
2231
1866
|
}
|
|
2232
1867
|
const key = record.key;
|
|
2233
1868
|
return typeof key === "string" || typeof key === "number" ? key : index;
|
|
@@ -2309,24 +1944,24 @@ function selectedRowsForKeys(data, keys, rowKey) {
|
|
|
2309
1944
|
const keySet = new Set(normalizeKeys(keys));
|
|
2310
1945
|
return data.filter((record, index) => keySet.has(String(getRecordKey(record, index, rowKey))));
|
|
2311
1946
|
}
|
|
2312
|
-
var Column =
|
|
1947
|
+
var Column = forwardRef7(() => null);
|
|
2313
1948
|
Column.displayName = "Table.Column";
|
|
2314
|
-
var ColumnGroup =
|
|
1949
|
+
var ColumnGroup = forwardRef7(() => null);
|
|
2315
1950
|
ColumnGroup.displayName = "Table.ColumnGroup";
|
|
2316
|
-
var SummaryRow =
|
|
1951
|
+
var SummaryRow = forwardRef7((props, ref) => /* @__PURE__ */ jsx9("tr", {
|
|
2317
1952
|
...props,
|
|
2318
1953
|
ref
|
|
2319
1954
|
}));
|
|
2320
1955
|
SummaryRow.displayName = "Table.Summary.Row";
|
|
2321
|
-
var SummaryCell =
|
|
2322
|
-
return /* @__PURE__ */
|
|
1956
|
+
var SummaryCell = forwardRef7(({ index, ...props }, ref) => {
|
|
1957
|
+
return /* @__PURE__ */ jsx9("td", {
|
|
2323
1958
|
...props,
|
|
2324
1959
|
ref
|
|
2325
1960
|
});
|
|
2326
1961
|
});
|
|
2327
1962
|
SummaryCell.displayName = "Table.Summary.Cell";
|
|
2328
|
-
var Summary = Object.assign(
|
|
2329
|
-
return /* @__PURE__ */
|
|
1963
|
+
var Summary = Object.assign(forwardRef7(({ fixed, ...props }, ref) => {
|
|
1964
|
+
return /* @__PURE__ */ jsx9("tfoot", {
|
|
2330
1965
|
...props,
|
|
2331
1966
|
ref
|
|
2332
1967
|
});
|
|
@@ -2336,8 +1971,8 @@ var Summary = Object.assign(forwardRef8(({ fixed, ...props }, ref) => {
|
|
|
2336
1971
|
});
|
|
2337
1972
|
Summary.displayName = "Table.Summary";
|
|
2338
1973
|
function columnsFromChildren(children) {
|
|
2339
|
-
return
|
|
2340
|
-
if (!
|
|
1974
|
+
return React7.Children.toArray(children).flatMap((child) => {
|
|
1975
|
+
if (!React7.isValidElement(child)) {
|
|
2341
1976
|
return [];
|
|
2342
1977
|
}
|
|
2343
1978
|
if (child.type === Column) {
|
|
@@ -2363,12 +1998,12 @@ function renderSummary(summary, pageData, colSpan) {
|
|
|
2363
1998
|
return null;
|
|
2364
1999
|
}
|
|
2365
2000
|
const node = summary(pageData);
|
|
2366
|
-
if (
|
|
2001
|
+
if (React7.isValidElement(node) && node.type === Summary) {
|
|
2367
2002
|
return node;
|
|
2368
2003
|
}
|
|
2369
|
-
return /* @__PURE__ */
|
|
2370
|
-
children: /* @__PURE__ */
|
|
2371
|
-
children: /* @__PURE__ */
|
|
2004
|
+
return /* @__PURE__ */ jsx9("tfoot", {
|
|
2005
|
+
children: /* @__PURE__ */ jsx9("tr", {
|
|
2006
|
+
children: /* @__PURE__ */ jsx9("td", {
|
|
2372
2007
|
className: tableCellClass,
|
|
2373
2008
|
colSpan,
|
|
2374
2009
|
children: node
|
|
@@ -2412,18 +2047,18 @@ function TableRoot({
|
|
|
2412
2047
|
className,
|
|
2413
2048
|
...props
|
|
2414
2049
|
}, ref) {
|
|
2415
|
-
const childColumns =
|
|
2416
|
-
const normalizedColumns =
|
|
2417
|
-
const leaves =
|
|
2418
|
-
const headerRows =
|
|
2419
|
-
const [sortStates, setSortStates] =
|
|
2420
|
-
const [filterStates, setFilterStates] =
|
|
2421
|
-
const [internalCurrent, setInternalCurrent] =
|
|
2422
|
-
const [internalPageSize, setInternalPageSize] =
|
|
2423
|
-
const [internalSelectedKeys, setInternalSelectedKeys] =
|
|
2424
|
-
const [internalExpandedKeys, setInternalExpandedKeys] =
|
|
2050
|
+
const childColumns = useMemo6(() => columnsFromChildren(children), [children]);
|
|
2051
|
+
const normalizedColumns = useMemo6(() => normalizeColumns(columns ?? childColumns), [childColumns, columns]);
|
|
2052
|
+
const leaves = useMemo6(() => leafColumns(normalizedColumns), [normalizedColumns]);
|
|
2053
|
+
const headerRows = useMemo6(() => buildHeaderRows(normalizedColumns, getDepth(normalizedColumns)), [normalizedColumns]);
|
|
2054
|
+
const [sortStates, setSortStates] = useState7({});
|
|
2055
|
+
const [filterStates, setFilterStates] = useState7({});
|
|
2056
|
+
const [internalCurrent, setInternalCurrent] = useState7(1);
|
|
2057
|
+
const [internalPageSize, setInternalPageSize] = useState7(defaultPageSize);
|
|
2058
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = useState7(rowSelection?.defaultSelectedRowKeys ?? []);
|
|
2059
|
+
const [internalExpandedKeys, setInternalExpandedKeys] = useState7(expandable?.defaultExpandedRowKeys ?? []);
|
|
2425
2060
|
const spinning = typeof loading === "object" ? loading.spinning : Boolean(loading);
|
|
2426
|
-
const activeFilters =
|
|
2061
|
+
const activeFilters = useMemo6(() => {
|
|
2427
2062
|
return leaves.reduce((result, column) => {
|
|
2428
2063
|
const value = filterValueFor(column, filterStates) ?? null;
|
|
2429
2064
|
if (value !== null) {
|
|
@@ -2432,7 +2067,7 @@ function TableRoot({
|
|
|
2432
2067
|
return result;
|
|
2433
2068
|
}, {});
|
|
2434
2069
|
}, [filterStates, leaves]);
|
|
2435
|
-
const activeSorter =
|
|
2070
|
+
const activeSorter = useMemo6(() => {
|
|
2436
2071
|
const column = leaves.find((item) => sortOrderFor(item, sortStates));
|
|
2437
2072
|
if (!column) {
|
|
2438
2073
|
return {};
|
|
@@ -2444,7 +2079,7 @@ function TableRoot({
|
|
|
2444
2079
|
order: sortOrderFor(column, sortStates) ?? null
|
|
2445
2080
|
};
|
|
2446
2081
|
}, [leaves, sortStates]);
|
|
2447
|
-
const filteredData =
|
|
2082
|
+
const filteredData = useMemo6(() => {
|
|
2448
2083
|
return leaves.reduce((records, column) => {
|
|
2449
2084
|
const values = filterValueFor(column, filterStates);
|
|
2450
2085
|
if (!values?.length || !column.onFilter) {
|
|
@@ -2453,7 +2088,7 @@ function TableRoot({
|
|
|
2453
2088
|
return records.filter((record) => values.some((value) => column.onFilter?.(value, record)));
|
|
2454
2089
|
}, dataSource);
|
|
2455
2090
|
}, [dataSource, filterStates, leaves]);
|
|
2456
|
-
const sortedData =
|
|
2091
|
+
const sortedData = useMemo6(() => {
|
|
2457
2092
|
const sorterColumn = leaves.find((column) => sortOrderFor(column, sortStates));
|
|
2458
2093
|
const order = sorterColumn ? sortOrderFor(sorterColumn, sortStates) : null;
|
|
2459
2094
|
const compare = sorterColumn ? sortCompare(sorterColumn.sorter) : undefined;
|
|
@@ -2596,18 +2231,18 @@ function TableRoot({
|
|
|
2596
2231
|
return null;
|
|
2597
2232
|
}
|
|
2598
2233
|
if (rowSelection.type === "radio" || rowSelection.hideSelectAll) {
|
|
2599
|
-
return /* @__PURE__ */
|
|
2234
|
+
return /* @__PURE__ */ jsx9("th", {
|
|
2600
2235
|
className: cn(tableHeaderCellClass, tableSelectionCellClass),
|
|
2601
2236
|
children: rowSelection.columnTitle
|
|
2602
2237
|
});
|
|
2603
2238
|
}
|
|
2604
2239
|
const pageKeys = pageData.map((record, index) => getRecordKey(record, index, rowKey));
|
|
2605
2240
|
const allSelected = pageKeys.length > 0 && pageKeys.every((key) => selectedKeySet.has(String(key)));
|
|
2606
|
-
return /* @__PURE__ */
|
|
2241
|
+
return /* @__PURE__ */ jsx9("th", {
|
|
2607
2242
|
className: cn(tableHeaderCellClass, tableSelectionCellClass),
|
|
2608
|
-
children: /* @__PURE__ */
|
|
2243
|
+
children: /* @__PURE__ */ jsxs8("label", {
|
|
2609
2244
|
children: [
|
|
2610
|
-
/* @__PURE__ */
|
|
2245
|
+
/* @__PURE__ */ jsx9("input", {
|
|
2611
2246
|
type: "checkbox",
|
|
2612
2247
|
"aria-label": "Select all rows",
|
|
2613
2248
|
checked: allSelected,
|
|
@@ -2634,26 +2269,26 @@ function TableRoot({
|
|
|
2634
2269
|
textAlign: column.align,
|
|
2635
2270
|
...headerProps.style
|
|
2636
2271
|
}
|
|
2637
|
-
}, /* @__PURE__ */
|
|
2272
|
+
}, /* @__PURE__ */ jsx9("span", {
|
|
2638
2273
|
children: title
|
|
2639
|
-
}), column.sorter ? /* @__PURE__ */
|
|
2274
|
+
}), column.sorter ? /* @__PURE__ */ jsx9("button", {
|
|
2640
2275
|
type: "button",
|
|
2641
2276
|
className: getTableSorterClasses(Boolean(sortOrder)),
|
|
2642
2277
|
"aria-label": `Sort ${textFromNode(title, String(column.columnKey))}`,
|
|
2643
2278
|
onClick: () => changeSorter(column),
|
|
2644
2279
|
children: sortOrder === "ascend" ? "Asc" : sortOrder === "descend" ? "Desc" : "Sort"
|
|
2645
|
-
}) : null, column.filters?.length ? /* @__PURE__ */
|
|
2280
|
+
}) : null, column.filters?.length ? /* @__PURE__ */ jsxs8("select", {
|
|
2646
2281
|
className: tableFilterClass,
|
|
2647
2282
|
"aria-label": `Filter ${textFromNode(title, String(column.columnKey))}`,
|
|
2648
2283
|
multiple: column.filterMultiple !== false,
|
|
2649
2284
|
value: column.filterMultiple === false ? String((filterValueFor(column, filterStates) ?? [])[0] ?? "") : (filterValueFor(column, filterStates) ?? []).map(String),
|
|
2650
2285
|
onChange: (event) => changeFilter(column, event),
|
|
2651
2286
|
children: [
|
|
2652
|
-
column.filterMultiple === false ? /* @__PURE__ */
|
|
2287
|
+
column.filterMultiple === false ? /* @__PURE__ */ jsx9("option", {
|
|
2653
2288
|
value: "",
|
|
2654
2289
|
children: "All"
|
|
2655
2290
|
}) : null,
|
|
2656
|
-
optionValues(column.filters).map((filter) => /* @__PURE__ */
|
|
2291
|
+
optionValues(column.filters).map((filter) => /* @__PURE__ */ jsx9("option", {
|
|
2657
2292
|
value: String(filter.value),
|
|
2658
2293
|
children: filter.text
|
|
2659
2294
|
}, String(filter.value)))
|
|
@@ -2678,14 +2313,14 @@ function TableRoot({
|
|
|
2678
2313
|
const key = getRecordKey(record, index, rowKey);
|
|
2679
2314
|
const checked = selectedKeySet.has(String(key));
|
|
2680
2315
|
const checkboxProps = rowSelection.getCheckboxProps?.(record) ?? {};
|
|
2681
|
-
const originNode = /* @__PURE__ */
|
|
2316
|
+
const originNode = /* @__PURE__ */ jsx9("input", {
|
|
2682
2317
|
...checkboxProps,
|
|
2683
2318
|
type: rowSelection.type === "radio" ? "radio" : "checkbox",
|
|
2684
2319
|
"aria-label": `Select row ${index + 1}`,
|
|
2685
2320
|
checked,
|
|
2686
2321
|
onChange: (event) => toggleRowSelection(record, index, event)
|
|
2687
2322
|
});
|
|
2688
|
-
return /* @__PURE__ */
|
|
2323
|
+
return /* @__PURE__ */ jsx9("td", {
|
|
2689
2324
|
className: cn(tableCellClass, tableSelectionCellClass),
|
|
2690
2325
|
children: rowSelection.renderCell ? rowSelection.renderCell(checked, record, index, originNode) : originNode
|
|
2691
2326
|
});
|
|
@@ -2697,9 +2332,9 @@ function TableRoot({
|
|
|
2697
2332
|
const key = getRecordKey(record, index, rowKey);
|
|
2698
2333
|
const expanded = expandedKeySet.has(String(key));
|
|
2699
2334
|
const expandableRow = expandable.rowExpandable?.(record) ?? true;
|
|
2700
|
-
return /* @__PURE__ */
|
|
2335
|
+
return /* @__PURE__ */ jsx9("td", {
|
|
2701
2336
|
className: cn(tableCellClass, tableExpandCellClass),
|
|
2702
|
-
children: expandableRow ? /* @__PURE__ */
|
|
2337
|
+
children: expandableRow ? /* @__PURE__ */ jsx9("button", {
|
|
2703
2338
|
type: "button",
|
|
2704
2339
|
className: tableExpandButtonClass,
|
|
2705
2340
|
"aria-label": `${expanded ? "Collapse" : "Expand"} row ${index + 1}`,
|
|
@@ -2712,7 +2347,7 @@ function TableRoot({
|
|
|
2712
2347
|
const key = getRecordKey(record, index, rowKey);
|
|
2713
2348
|
const expanded = expandedKeySet.has(String(key));
|
|
2714
2349
|
const selected = selectedKeySet.has(String(key));
|
|
2715
|
-
const row = /* @__PURE__ */
|
|
2350
|
+
const row = /* @__PURE__ */ jsxs8("tr", {
|
|
2716
2351
|
className: getTableRowClasses({ selected, expanded }),
|
|
2717
2352
|
onClick: () => {
|
|
2718
2353
|
if (expandable?.expandRowByClick) {
|
|
@@ -2728,12 +2363,12 @@ function TableRoot({
|
|
|
2728
2363
|
if (!expanded || !expandable?.expandedRowRender) {
|
|
2729
2364
|
return row;
|
|
2730
2365
|
}
|
|
2731
|
-
return /* @__PURE__ */
|
|
2366
|
+
return /* @__PURE__ */ jsxs8(React7.Fragment, {
|
|
2732
2367
|
children: [
|
|
2733
2368
|
row,
|
|
2734
|
-
/* @__PURE__ */
|
|
2369
|
+
/* @__PURE__ */ jsx9("tr", {
|
|
2735
2370
|
className: "table-expanded-row",
|
|
2736
|
-
children: /* @__PURE__ */
|
|
2371
|
+
children: /* @__PURE__ */ jsx9("td", {
|
|
2737
2372
|
className: tableCellClass,
|
|
2738
2373
|
colSpan: structuralColumnCount,
|
|
2739
2374
|
children: expandable.expandedRowRender(record, index, 0, expanded)
|
|
@@ -2742,15 +2377,15 @@ function TableRoot({
|
|
|
2742
2377
|
]
|
|
2743
2378
|
}, String(key));
|
|
2744
2379
|
}
|
|
2745
|
-
const tableNode = /* @__PURE__ */
|
|
2380
|
+
const tableNode = /* @__PURE__ */ jsxs8("table", {
|
|
2746
2381
|
className: getTableClasses({ bordered, size }),
|
|
2747
2382
|
style: { tableLayout },
|
|
2748
2383
|
children: [
|
|
2749
|
-
/* @__PURE__ */
|
|
2750
|
-
children: headerRows.map((row, rowIndex) => /* @__PURE__ */
|
|
2384
|
+
/* @__PURE__ */ jsx9("thead", {
|
|
2385
|
+
children: headerRows.map((row, rowIndex) => /* @__PURE__ */ jsxs8("tr", {
|
|
2751
2386
|
children: [
|
|
2752
2387
|
rowIndex === 0 ? renderSelectionHeader() : null,
|
|
2753
|
-
rowIndex === 0 && hasExpandable ? /* @__PURE__ */
|
|
2388
|
+
rowIndex === 0 && hasExpandable ? /* @__PURE__ */ jsx9("th", {
|
|
2754
2389
|
className: cn(tableHeaderCellClass, tableExpandCellClass),
|
|
2755
2390
|
children: expandable?.columnTitle
|
|
2756
2391
|
}) : null,
|
|
@@ -2758,9 +2393,9 @@ function TableRoot({
|
|
|
2758
2393
|
]
|
|
2759
2394
|
}, rowIndex))
|
|
2760
2395
|
}),
|
|
2761
|
-
/* @__PURE__ */
|
|
2762
|
-
children: bodyEmpty ? /* @__PURE__ */
|
|
2763
|
-
children: /* @__PURE__ */
|
|
2396
|
+
/* @__PURE__ */ jsx9("tbody", {
|
|
2397
|
+
children: bodyEmpty ? /* @__PURE__ */ jsx9("tr", {
|
|
2398
|
+
children: /* @__PURE__ */ jsx9("td", {
|
|
2764
2399
|
className: tableEmptyClass,
|
|
2765
2400
|
colSpan: structuralColumnCount,
|
|
2766
2401
|
children: locale?.emptyText ?? "No data"
|
|
@@ -2770,12 +2405,12 @@ function TableRoot({
|
|
|
2770
2405
|
renderSummary(summary, pageData, structuralColumnCount)
|
|
2771
2406
|
]
|
|
2772
2407
|
});
|
|
2773
|
-
return /* @__PURE__ */
|
|
2408
|
+
return /* @__PURE__ */ jsxs8("div", {
|
|
2774
2409
|
...props,
|
|
2775
2410
|
ref,
|
|
2776
2411
|
className: getTableWrapperClasses({ loading: spinning, className }),
|
|
2777
2412
|
children: [
|
|
2778
|
-
scroll?.x || scroll?.y ? /* @__PURE__ */
|
|
2413
|
+
scroll?.x || scroll?.y ? /* @__PURE__ */ jsx9("div", {
|
|
2779
2414
|
style: {
|
|
2780
2415
|
overflow: "auto",
|
|
2781
2416
|
maxHeight: scroll.y,
|
|
@@ -2783,30 +2418,30 @@ function TableRoot({
|
|
|
2783
2418
|
},
|
|
2784
2419
|
children: tableNode
|
|
2785
2420
|
}) : tableNode,
|
|
2786
|
-
spinning ? /* @__PURE__ */
|
|
2421
|
+
spinning ? /* @__PURE__ */ jsx9("div", {
|
|
2787
2422
|
className: tableLoadingIndicatorClass,
|
|
2788
2423
|
role: "status",
|
|
2789
2424
|
children: typeof loading === "object" && loading.indicator ? loading.indicator : "Loading"
|
|
2790
2425
|
}) : null,
|
|
2791
|
-
paginationConfig && !(paginationConfig.hideOnSinglePage && pageCount <= 1) ? /* @__PURE__ */
|
|
2426
|
+
paginationConfig && !(paginationConfig.hideOnSinglePage && pageCount <= 1) ? /* @__PURE__ */ jsxs8("nav", {
|
|
2792
2427
|
className: tablePaginationClass,
|
|
2793
2428
|
"aria-label": "Table pagination",
|
|
2794
2429
|
children: [
|
|
2795
|
-
/* @__PURE__ */
|
|
2430
|
+
/* @__PURE__ */ jsx9("button", {
|
|
2796
2431
|
type: "button",
|
|
2797
2432
|
className: tablePaginationButtonClass,
|
|
2798
2433
|
disabled: paginationConfig.disabled || current <= 1,
|
|
2799
2434
|
onClick: () => changePage(current - 1),
|
|
2800
2435
|
children: "Previous"
|
|
2801
2436
|
}),
|
|
2802
|
-
/* @__PURE__ */
|
|
2437
|
+
/* @__PURE__ */ jsx9("span", {
|
|
2803
2438
|
className: tablePaginationInfoClass,
|
|
2804
2439
|
children: paginationConfig.showTotal ? paginationConfig.showTotal(paginationConfig.total ?? sortedData.length, [
|
|
2805
2440
|
bodyEmpty ? 0 : (current - 1) * pageSize + 1,
|
|
2806
2441
|
Math.min(current * pageSize, sortedData.length)
|
|
2807
2442
|
]) : `${current} / ${pageCount}`
|
|
2808
2443
|
}),
|
|
2809
|
-
/* @__PURE__ */
|
|
2444
|
+
/* @__PURE__ */ jsx9("button", {
|
|
2810
2445
|
type: "button",
|
|
2811
2446
|
className: tablePaginationButtonClass,
|
|
2812
2447
|
disabled: paginationConfig.disabled || current >= pageCount,
|
|
@@ -2817,198 +2452,563 @@ function TableRoot({
|
|
|
2817
2452
|
}) : null
|
|
2818
2453
|
]
|
|
2819
2454
|
});
|
|
2820
|
-
}
|
|
2821
|
-
var TableWithRef =
|
|
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"
|
|
2455
|
+
}
|
|
2456
|
+
var TableWithRef = forwardRef7(TableRoot);
|
|
2457
|
+
var Table = Object.assign(TableWithRef, {
|
|
2458
|
+
Column,
|
|
2459
|
+
ColumnGroup,
|
|
2460
|
+
Summary,
|
|
2461
|
+
SELECTION_ALL: "SELECT_ALL",
|
|
2462
|
+
SELECTION_INVERT: "SELECT_INVERT",
|
|
2463
|
+
SELECTION_NONE: "SELECT_NONE",
|
|
2464
|
+
SELECTION_COLUMN: "SELECTION_COLUMN",
|
|
2465
|
+
EXPAND_COLUMN: "EXPAND_COLUMN"
|
|
2466
|
+
});
|
|
2467
|
+
Table.displayName = "Table";
|
|
2468
|
+
// src/components/dm-table/DmTable.tsx
|
|
2469
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2470
|
+
function mapAndFilter(list, mapper) {
|
|
2471
|
+
return list.map(mapper).filter((item) => item !== false && item != null);
|
|
2472
|
+
}
|
|
2473
|
+
function filterDmTableColumn(column) {
|
|
2474
|
+
if (column.onlySearch || column.hideInTable)
|
|
2475
|
+
return false;
|
|
2476
|
+
if (Array.isArray(column.children)) {
|
|
2477
|
+
const children = mapAndFilter(column.children, filterDmTableColumn);
|
|
2478
|
+
return children.length > 0 ? { ...column, children } : null;
|
|
2479
|
+
}
|
|
2480
|
+
return column;
|
|
2481
|
+
}
|
|
2482
|
+
function filterSearchColumn(column) {
|
|
2483
|
+
if (Array.isArray(column.children)) {
|
|
2484
|
+
const children = mapAndFilter(column.children, filterSearchColumn);
|
|
2485
|
+
return children.length > 0 ? { ...column, children } : null;
|
|
2486
|
+
}
|
|
2487
|
+
return column.search ? column : false;
|
|
2488
|
+
}
|
|
2489
|
+
function flattenSearchColumns(column) {
|
|
2490
|
+
return Array.isArray(column.children) ? column.children.flatMap(flattenSearchColumns) : [column];
|
|
2491
|
+
}
|
|
2492
|
+
function searchItems(columns) {
|
|
2493
|
+
return mapAndFilter(columns, filterSearchColumn).flatMap(flattenSearchColumns).map((column) => ({
|
|
2494
|
+
key: String(column.key ?? column.dataIndex),
|
|
2495
|
+
title: column.title,
|
|
2496
|
+
dataIndex: String(column.dataIndex ?? column.key),
|
|
2497
|
+
search: column.search || {
|
|
2498
|
+
type: "input",
|
|
2499
|
+
extraProps: {},
|
|
2500
|
+
formProps: {}
|
|
2501
|
+
}
|
|
2502
|
+
}));
|
|
2503
|
+
}
|
|
2504
|
+
function DmTable({
|
|
2505
|
+
name,
|
|
2506
|
+
extra,
|
|
2507
|
+
indicators,
|
|
2508
|
+
pagination,
|
|
2509
|
+
columns: inputColumns,
|
|
2510
|
+
columnSettingVisible = true,
|
|
2511
|
+
onColumnsChange,
|
|
2512
|
+
columnState,
|
|
2513
|
+
searchProps,
|
|
2514
|
+
tableExtra,
|
|
2515
|
+
className,
|
|
2516
|
+
dataSource,
|
|
2517
|
+
rowSelection,
|
|
2518
|
+
...props
|
|
2519
|
+
}) {
|
|
2520
|
+
const tableColumns = useMemo7(() => mapAndFilter(inputColumns, filterDmTableColumn), [inputColumns]);
|
|
2521
|
+
const [columns, setColumns] = useState8(tableColumns);
|
|
2522
|
+
const [columnSettingsOpen, setColumnSettingsOpen] = useState8(false);
|
|
2523
|
+
const items = searchProps?.items?.length ? searchProps.items : searchItems(inputColumns);
|
|
2524
|
+
const paginationObj = typeof pagination === "object" ? pagination : undefined;
|
|
2525
|
+
const paginationProps = paginationObj ? Object.fromEntries(Object.entries(paginationObj).filter(([key]) => key !== "ref")) : {};
|
|
2526
|
+
const total = paginationObj?.total ?? dataSource?.length ?? 0;
|
|
2527
|
+
const selectedTotal = rowSelection?.selectedRowKeys?.length ?? 0;
|
|
2528
|
+
function resetColumns() {
|
|
2529
|
+
setColumns(tableColumns);
|
|
2530
|
+
onColumnsChange?.(tableColumns);
|
|
2531
|
+
if (columnState?.persistenceKey) {
|
|
2532
|
+
globalThis.localStorage?.removeItem(columnState.persistenceKey);
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
2536
|
+
className: getDmTableClasses({ className }),
|
|
2537
|
+
children: [
|
|
2538
|
+
items.length > 0 || searchProps?.fastFilterItem ? /* @__PURE__ */ jsx10(Card, {
|
|
2539
|
+
className: dmTableSearchClass,
|
|
2540
|
+
padding: "md",
|
|
2541
|
+
children: /* @__PURE__ */ jsx10(DmSearch, {
|
|
2542
|
+
...searchProps,
|
|
2543
|
+
items
|
|
2544
|
+
})
|
|
2545
|
+
}) : null,
|
|
2546
|
+
indicators ? /* @__PURE__ */ jsx10("div", {
|
|
2547
|
+
className: dmTableIndicatorsClass,
|
|
2548
|
+
children: indicators
|
|
2549
|
+
}) : null,
|
|
2550
|
+
/* @__PURE__ */ jsxs9(Card, {
|
|
2551
|
+
className: dmTableCardClass,
|
|
2552
|
+
padding: "md",
|
|
2553
|
+
children: [
|
|
2554
|
+
name || extra || columnSettingVisible ? /* @__PURE__ */ jsxs9("div", {
|
|
2555
|
+
className: dmTableHeaderClass,
|
|
2556
|
+
children: [
|
|
2557
|
+
/* @__PURE__ */ jsx10("div", {
|
|
2558
|
+
className: dmTableTitleClass,
|
|
2559
|
+
children: name
|
|
2560
|
+
}),
|
|
2561
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
2562
|
+
className: dmTableExtraClass,
|
|
2563
|
+
children: [
|
|
2564
|
+
extra,
|
|
2565
|
+
columnSettingVisible ? /* @__PURE__ */ jsx10(Button, {
|
|
2566
|
+
type: "button",
|
|
2567
|
+
color: "secondary",
|
|
2568
|
+
appearance: "outline",
|
|
2569
|
+
className: dmTableColumnSettingClass,
|
|
2570
|
+
onClick: () => setColumnSettingsOpen((open) => !open),
|
|
2571
|
+
children: "Columns"
|
|
2572
|
+
}) : null
|
|
2573
|
+
]
|
|
2574
|
+
})
|
|
2575
|
+
]
|
|
2576
|
+
}) : null,
|
|
2577
|
+
columnSettingsOpen ? /* @__PURE__ */ jsx10("div", {
|
|
2578
|
+
role: "dialog",
|
|
2579
|
+
"aria-label": "Column settings",
|
|
2580
|
+
children: /* @__PURE__ */ jsx10(Button, {
|
|
2581
|
+
type: "button",
|
|
2582
|
+
onClick: resetColumns,
|
|
2583
|
+
children: "Reset columns"
|
|
2584
|
+
})
|
|
2585
|
+
}) : null,
|
|
2586
|
+
tableExtra ? /* @__PURE__ */ jsx10("div", {
|
|
2587
|
+
className: dmTableTableExtraClass,
|
|
2588
|
+
children: tableExtra
|
|
2589
|
+
}) : null,
|
|
2590
|
+
/* @__PURE__ */ jsx10(Table, {
|
|
2591
|
+
...props,
|
|
2592
|
+
dataSource,
|
|
2593
|
+
rowSelection,
|
|
2594
|
+
size: props.size ?? "small",
|
|
2595
|
+
scroll: props.scroll ?? { x: 680 },
|
|
2596
|
+
columns,
|
|
2597
|
+
pagination: pagination ? {
|
|
2598
|
+
current: paginationObj?.current,
|
|
2599
|
+
defaultCurrent: paginationObj?.defaultCurrent,
|
|
2600
|
+
pageSize: paginationObj?.pageSize,
|
|
2601
|
+
defaultPageSize: paginationObj?.defaultPageSize,
|
|
2602
|
+
total,
|
|
2603
|
+
onChange: paginationObj?.onChange
|
|
2604
|
+
} : false
|
|
2605
|
+
}),
|
|
2606
|
+
pagination ? /* @__PURE__ */ jsx10(DmPagination, {
|
|
2607
|
+
...paginationProps,
|
|
2608
|
+
className: dmTablePaginationClass,
|
|
2609
|
+
total,
|
|
2610
|
+
selectedTotal,
|
|
2611
|
+
showSizeChanger: true
|
|
2612
|
+
}) : null
|
|
2613
|
+
]
|
|
2614
|
+
})
|
|
2615
|
+
]
|
|
2616
|
+
});
|
|
2617
|
+
}
|
|
2618
|
+
DmTable.displayName = "DmTable";
|
|
2619
|
+
// src/components/dm-toolbar/DmToolbar.tsx
|
|
2620
|
+
import { useMemo as useMemo8 } from "react";
|
|
2621
|
+
|
|
2622
|
+
// src/classes/dm-toolbar.ts
|
|
2623
|
+
var dmToolbarBaseClass = "dm-toolbar";
|
|
2624
|
+
var dmToolbarItemClass = "dm-toolbar-item";
|
|
2625
|
+
var dmToolbarPrimaryItemClass = "dm-toolbar-primary-item";
|
|
2626
|
+
var dmToolbarSecondaryItemClass = "dm-toolbar-secondary-item";
|
|
2627
|
+
var dmToolbarMoreClass = "dm-toolbar-more";
|
|
2628
|
+
function getDmToolbarClasses({ className }) {
|
|
2629
|
+
return cn(dmToolbarBaseClass, className);
|
|
2630
|
+
}
|
|
2631
|
+
function getDmToolbarItemClasses({
|
|
2632
|
+
primary,
|
|
2633
|
+
className
|
|
2634
|
+
}) {
|
|
2635
|
+
return cn(dmToolbarItemClass, primary ? dmToolbarPrimaryItemClass : dmToolbarSecondaryItemClass, className);
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
// src/components/dropdown/Dropdown.tsx
|
|
2639
|
+
import {
|
|
2640
|
+
cloneElement,
|
|
2641
|
+
forwardRef as forwardRef8,
|
|
2642
|
+
isValidElement,
|
|
2643
|
+
useId,
|
|
2644
|
+
useState as useState9
|
|
2645
|
+
} from "react";
|
|
2646
|
+
|
|
2647
|
+
// src/classes/dropdown.ts
|
|
2648
|
+
var dropdownWrapperClass = "dropdown-wrapper";
|
|
2649
|
+
var dropdownBaseClass = "popover dropdown";
|
|
2650
|
+
var dropdownOpenClass = "popover-show dropdown-open";
|
|
2651
|
+
var dropdownArrowClass = "popover-arrow dropdown-arrow";
|
|
2652
|
+
var dropdownMenuClass = "menu dropdown-menu";
|
|
2653
|
+
var dropdownButtonClass = "dropdown-button";
|
|
2654
|
+
var dropdownPlacementClasses = {
|
|
2655
|
+
top: "popover-top dropdown-top",
|
|
2656
|
+
bottom: "popover-bottom dropdown-bottom",
|
|
2657
|
+
left: "popover-left dropdown-left",
|
|
2658
|
+
right: "popover-right dropdown-right",
|
|
2659
|
+
topLeft: "popover-top dropdown-top-left",
|
|
2660
|
+
topRight: "popover-top dropdown-top-right",
|
|
2661
|
+
bottomLeft: "popover-bottom dropdown-bottom-left",
|
|
2662
|
+
bottomRight: "popover-bottom dropdown-bottom-right"
|
|
2663
|
+
};
|
|
2664
|
+
function getDropdownClasses({
|
|
2665
|
+
placement = "bottomLeft",
|
|
2666
|
+
open,
|
|
2667
|
+
arrow,
|
|
2668
|
+
className
|
|
2669
|
+
}) {
|
|
2670
|
+
return cn(dropdownBaseClass, dropdownPlacementClasses[placement], open && dropdownOpenClass, !arrow && "popover-no-arrow dropdown-no-arrow", className);
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
// src/classes/menu.ts
|
|
2674
|
+
var menuBaseClass = "menu";
|
|
2675
|
+
var menuShowClass = "menu-show";
|
|
2676
|
+
var menuItemClass = "menu-item";
|
|
2677
|
+
var menuItemActiveClass = "menu-item-active";
|
|
2678
|
+
var menuItemDisabledClass = "menu-item-disabled";
|
|
2679
|
+
var menuItemIconClass = "menu-item-icon";
|
|
2680
|
+
var menuItemTrailingClass = "menu-item-trailing";
|
|
2681
|
+
var menuItemSubmenuClass = "menu-item-submenu";
|
|
2682
|
+
var menuDividerClass = "menu-divider";
|
|
2683
|
+
var menuLabelClass = "menu-label";
|
|
2684
|
+
var menuSubmenuClass = "menu-submenu";
|
|
2685
|
+
var menuCompactClass = "menu-compact";
|
|
2686
|
+
var menuWideClass = "menu-wide";
|
|
2687
|
+
var menuModeClasses = {
|
|
2688
|
+
vertical: "menu-vertical",
|
|
2689
|
+
horizontal: "menu-horizontal",
|
|
2690
|
+
inline: "menu-inline"
|
|
2691
|
+
};
|
|
2692
|
+
var menuThemeClasses = {
|
|
2693
|
+
light: "",
|
|
2694
|
+
dark: "menu-dark menu-surface-container-highest"
|
|
2695
|
+
};
|
|
2696
|
+
var menuSizeClasses = {
|
|
2697
|
+
sm: menuCompactClass,
|
|
2698
|
+
md: "",
|
|
2699
|
+
lg: menuWideClass
|
|
2700
|
+
};
|
|
2701
|
+
function getMenuClasses({
|
|
2702
|
+
mode = "vertical",
|
|
2703
|
+
theme = "light",
|
|
2704
|
+
size = "md",
|
|
2705
|
+
inlineCollapsed,
|
|
2706
|
+
disabled,
|
|
2707
|
+
className
|
|
2708
|
+
}) {
|
|
2709
|
+
return cn(menuBaseClass, menuShowClass, menuModeClasses[mode], menuThemeClasses[theme], menuSizeClasses[size], inlineCollapsed && "menu-inline-collapsed", disabled && menuItemDisabledClass, className);
|
|
2710
|
+
}
|
|
2711
|
+
function getMenuItemClasses({
|
|
2712
|
+
active,
|
|
2713
|
+
disabled,
|
|
2714
|
+
danger,
|
|
2715
|
+
submenu,
|
|
2716
|
+
className
|
|
2717
|
+
}) {
|
|
2718
|
+
return cn(menuItemClass, active && menuItemActiveClass, disabled && menuItemDisabledClass, danger && "menu-item-danger", submenu && menuItemSubmenuClass, className);
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
// src/components/dropdown/Dropdown.tsx
|
|
2722
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2723
|
+
function hasTrigger(triggers, trigger) {
|
|
2724
|
+
return (triggers ?? ["hover"]).includes(trigger);
|
|
2725
|
+
}
|
|
2726
|
+
function callHandler(handler, event) {
|
|
2727
|
+
handler?.(event);
|
|
2728
|
+
}
|
|
2729
|
+
function renderMenuItem(item, onClick, close) {
|
|
2730
|
+
if (item.type === "divider") {
|
|
2731
|
+
return /* @__PURE__ */ jsx11("li", {
|
|
2732
|
+
className: menuDividerClass
|
|
2733
|
+
}, String(item.key));
|
|
2734
|
+
}
|
|
2735
|
+
return /* @__PURE__ */ jsx11("li", {
|
|
2736
|
+
children: /* @__PURE__ */ jsxs10("button", {
|
|
2737
|
+
type: "button",
|
|
2738
|
+
className: cn(menuItemClass, item.danger && "menu-item-danger", item.className),
|
|
2739
|
+
disabled: item.disabled,
|
|
2740
|
+
onClick: (event) => {
|
|
2741
|
+
onClick?.({ key: String(item.key), item, domEvent: event });
|
|
2742
|
+
close();
|
|
2743
|
+
},
|
|
2744
|
+
children: [
|
|
2745
|
+
item.icon ? /* @__PURE__ */ jsx11("span", {
|
|
2746
|
+
className: "menu-item-icon",
|
|
2747
|
+
children: item.icon
|
|
2748
|
+
}) : null,
|
|
2749
|
+
/* @__PURE__ */ jsx11("span", {
|
|
2750
|
+
children: item.label
|
|
2751
|
+
})
|
|
2752
|
+
]
|
|
2753
|
+
})
|
|
2754
|
+
}, String(item.key));
|
|
2755
|
+
}
|
|
2756
|
+
var DropdownRoot = forwardRef8(({
|
|
2757
|
+
arrow,
|
|
2758
|
+
children,
|
|
2759
|
+
className,
|
|
2760
|
+
defaultOpen,
|
|
2761
|
+
destroyPopupOnHide,
|
|
2762
|
+
disabled,
|
|
2763
|
+
dropdownRender,
|
|
2764
|
+
menu,
|
|
2765
|
+
onContextMenu,
|
|
2766
|
+
onClick,
|
|
2767
|
+
onMouseEnter,
|
|
2768
|
+
onMouseLeave,
|
|
2769
|
+
onOpenChange,
|
|
2770
|
+
open,
|
|
2771
|
+
overlay,
|
|
2772
|
+
placement = "bottomLeft",
|
|
2773
|
+
trigger = ["hover"],
|
|
2774
|
+
...props
|
|
2775
|
+
}, ref) => {
|
|
2776
|
+
const [internalOpen, setInternalOpen] = useState9(Boolean(defaultOpen));
|
|
2777
|
+
const isControlled = open !== undefined;
|
|
2778
|
+
const visible = isControlled ? open : internalOpen;
|
|
2779
|
+
const overlayId = useId();
|
|
2780
|
+
function setVisible(nextOpen) {
|
|
2781
|
+
if (disabled)
|
|
2782
|
+
return;
|
|
2783
|
+
if (!isControlled) {
|
|
2784
|
+
setInternalOpen(nextOpen);
|
|
2785
|
+
}
|
|
2786
|
+
onOpenChange?.(nextOpen);
|
|
2787
|
+
}
|
|
2788
|
+
const close = () => setVisible(false);
|
|
2789
|
+
const toggleVisible = () => setVisible(!visible);
|
|
2790
|
+
const menuNode = overlay ?? (menu?.items ? /* @__PURE__ */ jsx11("ul", {
|
|
2791
|
+
className: dropdownMenuClass,
|
|
2792
|
+
children: menu.items.map((item) => renderMenuItem(item, menu.onClick, close))
|
|
2793
|
+
}) : null);
|
|
2794
|
+
const popup = dropdownRender ? dropdownRender(menuNode) : menuNode;
|
|
2795
|
+
const shouldRenderPopup = !destroyPopupOnHide || visible;
|
|
2796
|
+
const triggerProps = {
|
|
2797
|
+
"aria-controls": visible ? overlayId : undefined,
|
|
2798
|
+
"aria-expanded": visible || undefined,
|
|
2799
|
+
onMouseEnter: hasTrigger(trigger, "hover") ? () => setVisible(true) : undefined,
|
|
2800
|
+
onMouseLeave: hasTrigger(trigger, "hover") ? () => setVisible(false) : undefined,
|
|
2801
|
+
onClick: hasTrigger(trigger, "click") ? toggleVisible : undefined,
|
|
2802
|
+
onContextMenu: hasTrigger(trigger, "contextMenu") ? (event) => {
|
|
2803
|
+
event.preventDefault();
|
|
2804
|
+
toggleVisible();
|
|
2805
|
+
} : undefined
|
|
2806
|
+
};
|
|
2807
|
+
const triggerNode = isValidElement(children) ? cloneElement(children, {
|
|
2808
|
+
"aria-controls": triggerProps["aria-controls"] ?? children.props["aria-controls"],
|
|
2809
|
+
"aria-expanded": triggerProps["aria-expanded"] ?? children.props["aria-expanded"],
|
|
2810
|
+
onMouseEnter: (event) => {
|
|
2811
|
+
callHandler(children.props.onMouseEnter, event);
|
|
2812
|
+
triggerProps.onMouseEnter?.();
|
|
2813
|
+
onMouseEnter?.(event);
|
|
2814
|
+
},
|
|
2815
|
+
onMouseLeave: (event) => {
|
|
2816
|
+
callHandler(children.props.onMouseLeave, event);
|
|
2817
|
+
triggerProps.onMouseLeave?.();
|
|
2818
|
+
onMouseLeave?.(event);
|
|
2819
|
+
},
|
|
2820
|
+
onClick: (event) => {
|
|
2821
|
+
callHandler(children.props.onClick, event);
|
|
2822
|
+
triggerProps.onClick?.();
|
|
2823
|
+
onClick?.(event);
|
|
2824
|
+
},
|
|
2825
|
+
onContextMenu: (event) => {
|
|
2826
|
+
callHandler(children.props.onContextMenu, event);
|
|
2827
|
+
triggerProps.onContextMenu?.(event);
|
|
2828
|
+
onContextMenu?.(event);
|
|
2829
|
+
}
|
|
2830
|
+
}) : /* @__PURE__ */ jsx11("span", {
|
|
2831
|
+
role: "button",
|
|
2832
|
+
tabIndex: disabled ? -1 : 0,
|
|
2833
|
+
"aria-disabled": disabled || undefined,
|
|
2834
|
+
"aria-controls": triggerProps["aria-controls"],
|
|
2835
|
+
"aria-expanded": triggerProps["aria-expanded"],
|
|
2836
|
+
onMouseEnter: (event) => {
|
|
2837
|
+
triggerProps.onMouseEnter?.();
|
|
2838
|
+
onMouseEnter?.(event);
|
|
2839
|
+
},
|
|
2840
|
+
onMouseLeave: (event) => {
|
|
2841
|
+
triggerProps.onMouseLeave?.();
|
|
2842
|
+
onMouseLeave?.(event);
|
|
2843
|
+
},
|
|
2844
|
+
onClick: (event) => {
|
|
2845
|
+
triggerProps.onClick?.();
|
|
2846
|
+
onClick?.(event);
|
|
2847
|
+
},
|
|
2848
|
+
onKeyDown: (event) => {
|
|
2849
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
2850
|
+
event.preventDefault();
|
|
2851
|
+
triggerProps.onClick?.();
|
|
2852
|
+
}
|
|
2853
|
+
},
|
|
2854
|
+
onContextMenu: (event) => {
|
|
2855
|
+
triggerProps.onContextMenu?.(event);
|
|
2856
|
+
onContextMenu?.(event);
|
|
2857
|
+
},
|
|
2858
|
+
children
|
|
2859
|
+
});
|
|
2860
|
+
return /* @__PURE__ */ jsxs10("span", {
|
|
2861
|
+
...props,
|
|
2862
|
+
ref,
|
|
2863
|
+
className: dropdownWrapperClass,
|
|
2864
|
+
children: [
|
|
2865
|
+
triggerNode,
|
|
2866
|
+
shouldRenderPopup ? /* @__PURE__ */ jsxs10("span", {
|
|
2867
|
+
id: overlayId,
|
|
2868
|
+
role: "menu",
|
|
2869
|
+
className: getDropdownClasses({
|
|
2870
|
+
placement,
|
|
2871
|
+
open: visible,
|
|
2872
|
+
arrow,
|
|
2873
|
+
className
|
|
2874
|
+
}),
|
|
2875
|
+
children: [
|
|
2876
|
+
popup,
|
|
2877
|
+
arrow ? /* @__PURE__ */ jsx11("span", {
|
|
2878
|
+
className: dropdownArrowClass
|
|
2879
|
+
}) : null
|
|
2880
|
+
]
|
|
2881
|
+
}) : null
|
|
2882
|
+
]
|
|
2883
|
+
});
|
|
2831
2884
|
});
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2885
|
+
DropdownRoot.displayName = "Dropdown";
|
|
2886
|
+
var DropdownButton = forwardRef8(({
|
|
2887
|
+
buttonsRender,
|
|
2888
|
+
children,
|
|
2889
|
+
disabled,
|
|
2890
|
+
menu,
|
|
2891
|
+
onClick,
|
|
2892
|
+
trigger = ["click"],
|
|
2893
|
+
...props
|
|
2894
|
+
}, ref) => {
|
|
2895
|
+
const buttons = [
|
|
2896
|
+
/* @__PURE__ */ jsx11(Button, {
|
|
2897
|
+
disabled,
|
|
2898
|
+
onClick,
|
|
2899
|
+
children
|
|
2900
|
+
}, "primary"),
|
|
2901
|
+
/* @__PURE__ */ jsx11(Button, {
|
|
2902
|
+
"aria-label": "Open dropdown",
|
|
2903
|
+
disabled,
|
|
2904
|
+
children: "v"
|
|
2905
|
+
}, "trigger")
|
|
2906
|
+
];
|
|
2907
|
+
const renderedButtons = buttonsRender ? buttonsRender(buttons) : buttons;
|
|
2908
|
+
return /* @__PURE__ */ jsx11(DropdownRoot, {
|
|
2909
|
+
...props,
|
|
2910
|
+
ref,
|
|
2911
|
+
menu,
|
|
2912
|
+
trigger,
|
|
2913
|
+
disabled,
|
|
2914
|
+
children: /* @__PURE__ */ jsx11("span", {
|
|
2915
|
+
className: dropdownButtonClass,
|
|
2916
|
+
children: renderedButtons
|
|
2917
|
+
})
|
|
2918
|
+
});
|
|
2919
|
+
});
|
|
2920
|
+
DropdownButton.displayName = "Dropdown.Button";
|
|
2921
|
+
var Dropdown = Object.assign(DropdownRoot, {
|
|
2922
|
+
Button: DropdownButton
|
|
2923
|
+
});
|
|
2924
|
+
// src/components/dm-toolbar/DmToolbar.tsx
|
|
2852
2925
|
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2853
|
-
function
|
|
2854
|
-
return
|
|
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;
|
|
2926
|
+
function isPrimary(item) {
|
|
2927
|
+
return item.type === "primary";
|
|
2871
2928
|
}
|
|
2872
|
-
function
|
|
2873
|
-
|
|
2929
|
+
function renderToolbarItem(item, index) {
|
|
2930
|
+
const {
|
|
2931
|
+
title,
|
|
2932
|
+
menu,
|
|
2933
|
+
type,
|
|
2934
|
+
htmlType = "button",
|
|
2935
|
+
color,
|
|
2936
|
+
appearance,
|
|
2937
|
+
...buttonPropsWithKey
|
|
2938
|
+
} = item;
|
|
2939
|
+
const buttonProps = { ...buttonPropsWithKey };
|
|
2940
|
+
delete buttonProps.key;
|
|
2941
|
+
const button = /* @__PURE__ */ jsx12(Button, {
|
|
2942
|
+
...buttonProps,
|
|
2943
|
+
type: htmlType,
|
|
2944
|
+
color: color ?? (type === "primary" ? "primary" : "secondary"),
|
|
2945
|
+
appearance: appearance ?? (type === "primary" ? "filled" : "outline"),
|
|
2946
|
+
children: title
|
|
2947
|
+
});
|
|
2948
|
+
if (!menu?.items?.length)
|
|
2949
|
+
return button;
|
|
2950
|
+
return /* @__PURE__ */ jsx12(Dropdown, {
|
|
2951
|
+
trigger: ["click"],
|
|
2952
|
+
menu,
|
|
2953
|
+
children: button
|
|
2954
|
+
}, `dropdown-${index}`);
|
|
2874
2955
|
}
|
|
2875
|
-
function
|
|
2876
|
-
return
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2956
|
+
function toOverflowMenu(items) {
|
|
2957
|
+
return {
|
|
2958
|
+
items: items.map((item, index) => ({
|
|
2959
|
+
key: item.key ?? index,
|
|
2960
|
+
label: item.title,
|
|
2961
|
+
disabled: item.disabled
|
|
2962
|
+
})),
|
|
2963
|
+
onClick: ({ key, domEvent }) => {
|
|
2964
|
+
const target = items.find((item, index) => String(item.key ?? index) === key);
|
|
2965
|
+
target?.onClick?.(domEvent);
|
|
2884
2966
|
}
|
|
2885
|
-
}
|
|
2967
|
+
};
|
|
2886
2968
|
}
|
|
2887
|
-
function
|
|
2888
|
-
|
|
2889
|
-
extra,
|
|
2890
|
-
indicators,
|
|
2891
|
-
pagination,
|
|
2892
|
-
columns: inputColumns,
|
|
2893
|
-
columnSettingVisible = true,
|
|
2894
|
-
onColumnsChange,
|
|
2895
|
-
columnState,
|
|
2896
|
-
searchProps,
|
|
2897
|
-
tableExtra,
|
|
2969
|
+
function DmToolbar({
|
|
2970
|
+
items = [],
|
|
2898
2971
|
className,
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2972
|
+
style,
|
|
2973
|
+
moreText = "More",
|
|
2974
|
+
maxVisibleSecondaryItems
|
|
2902
2975
|
}) {
|
|
2903
|
-
const
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
setColumns(tableColumns);
|
|
2913
|
-
onColumnsChange?.(tableColumns);
|
|
2914
|
-
if (columnState?.persistenceKey) {
|
|
2915
|
-
globalThis.localStorage?.removeItem(columnState.persistenceKey);
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2976
|
+
const { visibleSecondaryItems, overflowSecondaryItems, primaryItems } = useMemo8(() => {
|
|
2977
|
+
const primaryItems = items.filter(isPrimary);
|
|
2978
|
+
const secondaryItems = items.filter((item) => !isPrimary(item));
|
|
2979
|
+
const visibleLimit = maxVisibleSecondaryItems === undefined ? secondaryItems.length : Math.max(0, maxVisibleSecondaryItems);
|
|
2980
|
+
const visibleSecondaryItems = visibleLimit === 0 ? [] : secondaryItems.slice(-visibleLimit);
|
|
2981
|
+
const overflowSecondaryItems = visibleLimit >= secondaryItems.length ? [] : secondaryItems.slice(0, secondaryItems.length - visibleLimit);
|
|
2982
|
+
return { visibleSecondaryItems, overflowSecondaryItems, primaryItems };
|
|
2983
|
+
}, [items, maxVisibleSecondaryItems]);
|
|
2984
|
+
const showMore = overflowSecondaryItems.length > 0;
|
|
2918
2985
|
return /* @__PURE__ */ jsxs11("div", {
|
|
2919
|
-
className:
|
|
2986
|
+
className: getDmToolbarClasses({ className }),
|
|
2987
|
+
style,
|
|
2920
2988
|
children: [
|
|
2921
|
-
|
|
2922
|
-
className:
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2989
|
+
visibleSecondaryItems.map((item, index) => /* @__PURE__ */ jsx12("span", {
|
|
2990
|
+
className: getDmToolbarItemClasses({}),
|
|
2991
|
+
children: renderToolbarItem(item, index)
|
|
2992
|
+
}, item.key ?? `secondary-${index}`)),
|
|
2993
|
+
showMore ? /* @__PURE__ */ jsx12(Dropdown, {
|
|
2994
|
+
trigger: ["click"],
|
|
2995
|
+
menu: toOverflowMenu(overflowSecondaryItems),
|
|
2996
|
+
children: /* @__PURE__ */ jsx12(Button, {
|
|
2997
|
+
type: "button",
|
|
2998
|
+
className: dmToolbarMoreClass,
|
|
2999
|
+
color: "secondary",
|
|
3000
|
+
appearance: "outline",
|
|
3001
|
+
children: moreText
|
|
2927
3002
|
})
|
|
2928
3003
|
}) : 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
|
-
})
|
|
3004
|
+
primaryItems.map((item, index) => /* @__PURE__ */ jsx12("span", {
|
|
3005
|
+
className: getDmToolbarItemClasses({ primary: true }),
|
|
3006
|
+
children: renderToolbarItem(item, index)
|
|
3007
|
+
}, item.key ?? `primary-${index}`))
|
|
2998
3008
|
]
|
|
2999
3009
|
});
|
|
3000
3010
|
}
|
|
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
|
-
|
|
3011
|
+
DmToolbar.displayName = "DmToolbar";
|
|
3012
3012
|
// src/components/dm-pro-table/DmProTable.tsx
|
|
3013
3013
|
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3014
3014
|
function renderToolbar(toolBarRender) {
|