sinking-antd 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,2037 @@
1
+ import React, { createContext, useContext, useMemo, useState, useEffect, useCallback, forwardRef, useImperativeHandle, useRef } from 'react';
2
+ import * as AntdIcons from '@ant-design/icons';
3
+ import { createFromIconfontCN, MenuUnfoldOutlined, MenuFoldOutlined, DownOutlined, UpOutlined, RedoOutlined, QuestionCircleOutlined } from '@ant-design/icons';
4
+ import { createStyles, useResponsive, useTheme as useTheme$1, ThemeProvider } from 'antd-style';
5
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
6
+ import { Breadcrumb, App, Spin, Layout, Space, ConfigProvider, Menu, Drawer, Button, Form, Col, Row, Tag, Switch, Rate, Progress, Typography, Card, Affix, Pagination, Table, Modal as Modal$1, Watermark, Select, Input, InputNumber, TimePicker, DatePicker, Tooltip, theme } from 'antd';
7
+ import 'dayjs/locale/zh-cn';
8
+ import dayjs from 'dayjs';
9
+
10
+ // src/icon/index.tsx
11
+ var globalIconfontUrl = void 0;
12
+ var setIconfontUrl = (url) => {
13
+ globalIconfontUrl = url;
14
+ iconfontCache = null;
15
+ };
16
+ var getIconfontUrl = () => {
17
+ return globalIconfontUrl;
18
+ };
19
+ var IconFontContext = createContext({});
20
+ var IconFontProvider = ({ iconfontUrl, children }) => {
21
+ return /* @__PURE__ */ jsx(IconFontContext.Provider, { value: { iconfontUrl }, children });
22
+ };
23
+ var useStyles = createStyles(() => ({
24
+ iconWrapper: {
25
+ display: "inline-flex",
26
+ alignItems: "center",
27
+ justifyContent: "center"
28
+ }
29
+ }));
30
+ var Icon = React.forwardRef(
31
+ ({ type, iconfontUrl, className, style, onClick, ...rest }, ref) => {
32
+ const { styles, cx } = useStyles();
33
+ const context = useContext(IconFontContext);
34
+ const currentIconfontUrl = iconfontUrl || context.iconfontUrl || globalIconfontUrl;
35
+ const IconfontIcon = useMemo(() => {
36
+ if (!currentIconfontUrl) {
37
+ return null;
38
+ }
39
+ return createFromIconfontCN({
40
+ scriptUrl: currentIconfontUrl
41
+ });
42
+ }, [currentIconfontUrl]);
43
+ const AntdIconComponent = AntdIcons[type];
44
+ if (AntdIconComponent) {
45
+ return /* @__PURE__ */ jsx(
46
+ AntdIconComponent,
47
+ {
48
+ ref,
49
+ className: cx(styles.iconWrapper, className),
50
+ style,
51
+ onClick,
52
+ ...rest
53
+ }
54
+ );
55
+ }
56
+ if (type.startsWith("icon-")) {
57
+ if (!IconfontIcon) {
58
+ return /* @__PURE__ */ jsx("span", { ref, className: cx(styles.iconWrapper, className), style, onClick, ...rest, children: type });
59
+ }
60
+ return /* @__PURE__ */ jsx(
61
+ IconfontIcon,
62
+ {
63
+ type,
64
+ ref,
65
+ className: cx(styles.iconWrapper, className),
66
+ style,
67
+ onClick,
68
+ ...rest
69
+ }
70
+ );
71
+ }
72
+ return /* @__PURE__ */ jsx("span", { ref, className: cx(styles.iconWrapper, className), style, onClick, ...rest, children: type });
73
+ }
74
+ );
75
+ var getAntdIconNames = () => {
76
+ return Object.keys(AntdIcons).filter((key) => {
77
+ return !key.startsWith("create") && !key.startsWith("set") && !key.startsWith("get") && key !== "default";
78
+ });
79
+ };
80
+ var iconfontCache = null;
81
+ var normalizeUrl = (url) => {
82
+ if (url.startsWith("//")) {
83
+ return `https:${url}`;
84
+ }
85
+ if (url.startsWith("http://") || url.startsWith("https://")) {
86
+ return url;
87
+ }
88
+ return url.startsWith("/") ? url : `/${url}`;
89
+ };
90
+ var getIconfontIconNames = async (url) => {
91
+ const targetUrl = url || globalIconfontUrl;
92
+ if (!targetUrl) {
93
+ return [];
94
+ }
95
+ if (url && iconfontCache) {
96
+ iconfontCache = null;
97
+ }
98
+ if (iconfontCache) return iconfontCache;
99
+ try {
100
+ const urls = Array.isArray(targetUrl) ? targetUrl : [targetUrl];
101
+ const iconSets = await Promise.all(
102
+ urls.map(async (scriptUrl) => {
103
+ try {
104
+ const response = await fetch(normalizeUrl(scriptUrl));
105
+ const scriptText = await response.text();
106
+ return [...scriptText.matchAll(/id="(icon-[^"]+)"/g)].map((m) => m[1]);
107
+ } catch (_) {
108
+ return [];
109
+ }
110
+ })
111
+ );
112
+ const allIcons = [...new Set(iconSets.flat())];
113
+ iconfontCache = allIcons;
114
+ return allIcons;
115
+ } catch (_) {
116
+ return [];
117
+ }
118
+ };
119
+ var getAllIconNames = async (iconfontUrl) => {
120
+ const [antdIcons, iconfontIcons] = await Promise.all([
121
+ Promise.resolve(getAntdIconNames()),
122
+ getIconfontIconNames(iconfontUrl)
123
+ ]);
124
+ return [...antdIcons, ...iconfontIcons];
125
+ };
126
+ var useBreadCrumbStyles = createStyles(({ token }) => {
127
+ return {
128
+ bread: {
129
+ backgroundColor: token?.colorBgContainer,
130
+ padding: "5px 15px 5px 15px",
131
+ fontSize: "12px"
132
+ },
133
+ breadStyle: {
134
+ color: "rgb(156, 156, 156)",
135
+ cursor: "pointer"
136
+ }
137
+ };
138
+ });
139
+ var BreadCrumb = React.memo((props) => {
140
+ const {
141
+ style,
142
+ className,
143
+ enabled = true,
144
+ items = [],
145
+ hideBreadCrumb = false
146
+ } = props;
147
+ const { styles: { bread, breadStyle } } = useBreadCrumbStyles();
148
+ if (!enabled || hideBreadCrumb || items.length === 0) {
149
+ return null;
150
+ }
151
+ const breadCrumbData = items.map((item) => ({
152
+ title: item.title,
153
+ onClick: item.onClick,
154
+ className: breadStyle
155
+ }));
156
+ return /* @__PURE__ */ jsx(
157
+ Breadcrumb,
158
+ {
159
+ className: `${bread} ${className || ""}`,
160
+ style,
161
+ items: breadCrumbData
162
+ }
163
+ );
164
+ });
165
+ var breadcrumb_default = BreadCrumb;
166
+ var Message;
167
+ var Notification;
168
+ var Modal;
169
+ var antd_default = () => {
170
+ const staticFunction = App.useApp();
171
+ Message = staticFunction.message;
172
+ Modal = staticFunction.modal;
173
+ Notification = staticFunction.notification;
174
+ return null;
175
+ };
176
+ var getDefaultTheme = (color, radius) => {
177
+ return {
178
+ token: {
179
+ colorPrimary: color,
180
+ colorInfo: color,
181
+ borderRadius: radius
182
+ }
183
+ };
184
+ };
185
+ var getCompactTheme = (color, radius) => {
186
+ let temp = getDefaultTheme(color, radius);
187
+ temp.algorithm = [theme.compactAlgorithm];
188
+ return temp;
189
+ };
190
+ var getMode = () => {
191
+ const mode = localStorage?.getItem("theme");
192
+ if (mode == "light" || mode == "dark") {
193
+ return mode;
194
+ }
195
+ return "auto";
196
+ };
197
+ var setModeToStorage = (mode) => {
198
+ localStorage?.setItem("theme", mode);
199
+ };
200
+ var ThemeContext = createContext(void 0);
201
+ var useTheme = () => {
202
+ const context = useContext(ThemeContext);
203
+ if (!context) {
204
+ return void 0;
205
+ }
206
+ return context;
207
+ };
208
+ var Theme = ({
209
+ children,
210
+ theme: customTheme,
211
+ mode: customMode,
212
+ appearance: customAppearance,
213
+ onAppearanceChange
214
+ }) => {
215
+ const existingContext = useContext(ThemeContext);
216
+ if (existingContext && !customTheme && !customMode && !customAppearance && !onAppearanceChange) {
217
+ return children;
218
+ }
219
+ return /* @__PURE__ */ jsx(
220
+ ThemeProviderInner,
221
+ {
222
+ theme: customTheme,
223
+ mode: customMode,
224
+ appearance: customAppearance,
225
+ onAppearanceChange,
226
+ children
227
+ }
228
+ );
229
+ };
230
+ var ThemeProviderInner = ({
231
+ children,
232
+ theme: customTheme,
233
+ mode: customMode,
234
+ appearance: customAppearance,
235
+ onAppearanceChange
236
+ }) => {
237
+ const [themes, setThemes] = useState(customTheme || getDefaultTheme("#1890ff", 6));
238
+ const [mode, setMode2] = useState(customMode || getMode());
239
+ const [appearance, setAppearance] = useState(customAppearance !== void 0 ? customAppearance : null);
240
+ const lightMode = "light";
241
+ const darkMode = "dark";
242
+ const autoMode = "auto";
243
+ const setDefaultTheme = () => {
244
+ setThemes(getDefaultTheme(themes?.token?.colorPrimary, themes?.token?.borderRadius));
245
+ };
246
+ const setCompactTheme = () => {
247
+ setThemes(getCompactTheme(themes?.token?.colorPrimary, themes?.token?.borderRadius));
248
+ };
249
+ const setColor = (color) => {
250
+ let temp = { ...themes };
251
+ temp.token.colorPrimary = color;
252
+ temp.token.colorInfo = color;
253
+ setThemes(temp);
254
+ };
255
+ const setRadius = (radius) => {
256
+ let temp = { ...themes };
257
+ temp.token.borderRadius = radius;
258
+ setThemes(temp);
259
+ };
260
+ const getModeName = (modeValue) => {
261
+ if (modeValue == lightMode) {
262
+ return "\u4EAE\u8272\u98CE\u683C";
263
+ }
264
+ if (modeValue == darkMode) {
265
+ return "\u6697\u8272\u98CE\u683C";
266
+ }
267
+ return "\u8DDF\u968F\u7CFB\u7EDF";
268
+ };
269
+ const setLightMode = () => {
270
+ setModeToStorage(lightMode);
271
+ setMode2(lightMode);
272
+ setAppearance(lightMode);
273
+ };
274
+ const setDarkMode = () => {
275
+ setModeToStorage(darkMode);
276
+ setMode2(darkMode);
277
+ setAppearance(darkMode);
278
+ };
279
+ const setAutoMode = () => {
280
+ setModeToStorage(autoMode);
281
+ setMode2(autoMode);
282
+ setAppearance(null);
283
+ };
284
+ const isLightMode = () => {
285
+ return mode == lightMode;
286
+ };
287
+ const isDarkMode = () => {
288
+ return mode == darkMode;
289
+ };
290
+ const isAutoMode = () => {
291
+ return mode == autoMode;
292
+ };
293
+ const isLightTheme = () => {
294
+ return appearance == lightMode;
295
+ };
296
+ const isDarkTheme = () => {
297
+ return appearance == darkMode;
298
+ };
299
+ const isCompactTheme = () => {
300
+ return themes?.algorithm && Array.isArray(themes.algorithm) && themes.algorithm.includes(theme.compactAlgorithm);
301
+ };
302
+ const toggle = () => {
303
+ if (isAutoMode()) {
304
+ setLightMode();
305
+ } else if (isLightMode()) {
306
+ setDarkMode();
307
+ } else {
308
+ setAutoMode();
309
+ }
310
+ };
311
+ const value = {
312
+ themes,
313
+ setColor,
314
+ setRadius,
315
+ setThemes,
316
+ setDefaultTheme,
317
+ setCompactTheme,
318
+ appearance,
319
+ setAppearance,
320
+ mode,
321
+ getModeName,
322
+ lightMode,
323
+ darkMode,
324
+ autoMode,
325
+ setLightMode,
326
+ setDarkMode,
327
+ setAutoMode,
328
+ isLightMode,
329
+ isDarkMode,
330
+ isAutoMode,
331
+ isLightTheme,
332
+ isDarkTheme,
333
+ isCompactTheme,
334
+ toggle
335
+ };
336
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children: /* @__PURE__ */ jsxs(
337
+ ThemeProvider,
338
+ {
339
+ theme: themes,
340
+ themeMode: mode,
341
+ appearance,
342
+ onAppearanceChange: (newAppearance) => {
343
+ onAppearanceChange?.(newAppearance);
344
+ setAppearance(newAppearance);
345
+ },
346
+ children: [
347
+ /* @__PURE__ */ jsx(antd_default, {}),
348
+ children
349
+ ]
350
+ }
351
+ ) });
352
+ };
353
+ var theme_default = Theme;
354
+ var Animate = {
355
+ None: "",
356
+ FadeUp: "fadeInUp",
357
+ FadeDown: "fadeInDown"
358
+ };
359
+ var useStyles2 = createStyles(({ css }) => ({
360
+ fadeInUp: css`
361
+ @keyframes fadeInUp {
362
+ 0% {
363
+ opacity: 0;
364
+ transform: translateY(20px);
365
+ }
366
+ 100% {
367
+ opacity: 1;
368
+ transform: translateY(0);
369
+ }
370
+ }
371
+ animation-name: fadeInUp;
372
+ animation-duration: 0.5s;
373
+ `,
374
+ fadeInDown: css`
375
+ @keyframes fadeInDown {
376
+ 0% {
377
+ opacity: 0;
378
+ transform: translateY(-20px);
379
+ }
380
+ 100% {
381
+ opacity: 1;
382
+ transform: translateY(0);
383
+ }
384
+ }
385
+ animation-name: fadeInDown;
386
+ animation-duration: 0.5s;
387
+ `
388
+ }));
389
+ var Animation = React.memo(({ animate, style, children }) => {
390
+ const { styles } = useStyles2();
391
+ const animationClass = useMemo(() => {
392
+ return animate && animate !== Animate.None ? styles?.[animate] : null;
393
+ }, [animate, styles]);
394
+ return /* @__PURE__ */ jsx("div", { className: animationClass, style, children });
395
+ });
396
+ var animation_default = Animation;
397
+ var Title = ({ ...props }) => {
398
+ const {
399
+ placement = "left",
400
+ size = "normal",
401
+ open = true,
402
+ width = 5,
403
+ height = 0,
404
+ radius = -1,
405
+ space = 7
406
+ } = props;
407
+ const theme2 = useTheme();
408
+ const getHeight = (h, s) => {
409
+ if (h > 0) {
410
+ return h;
411
+ }
412
+ const sizeMap = {
413
+ small: 15,
414
+ normal: 20,
415
+ larger: 25
416
+ };
417
+ return sizeMap[s] || 20;
418
+ };
419
+ const useStyles7 = createStyles(({ token }) => {
420
+ const isCompact = theme2?.isCompactTheme() || false;
421
+ const barRadius = radius < 0 ? token?.borderRadius > 3 ? token?.borderRadius : 0 : radius;
422
+ const barHeight = isCompact ? getHeight(height, size) - 5 : barRadius > 0 ? getHeight(height, size) : getHeight(height, size) - 3;
423
+ const barWidth = isCompact || !isCompact && barRadius <= 0 ? width - 1 : width;
424
+ return {
425
+ center: {
426
+ display: "flex",
427
+ alignItems: "center",
428
+ justifyContent: "start"
429
+ },
430
+ leftBar: {
431
+ width: barWidth,
432
+ height: barHeight,
433
+ borderTopRightRadius: barRadius,
434
+ borderBottomRightRadius: barRadius,
435
+ marginRight: space,
436
+ backgroundColor: token?.colorPrimary
437
+ },
438
+ rightBar: {
439
+ width: barWidth,
440
+ height: barHeight,
441
+ borderTopLeftRadius: barRadius,
442
+ borderBottomLeftRadius: barRadius,
443
+ marginLeft: space,
444
+ backgroundColor: token?.colorPrimary
445
+ }
446
+ };
447
+ });
448
+ const { styles: { center, leftBar, rightBar } } = useStyles7();
449
+ const left = /* @__PURE__ */ jsxs("div", { className: center, children: [
450
+ open && /* @__PURE__ */ jsx("span", { className: leftBar }),
451
+ props?.children
452
+ ] });
453
+ const right = /* @__PURE__ */ jsxs("div", { className: center, children: [
454
+ props?.children,
455
+ open && /* @__PURE__ */ jsx("span", { className: rightBar })
456
+ ] });
457
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
458
+ placement == "left" && left,
459
+ placement == "right" && right
460
+ ] });
461
+ };
462
+ var title_default = Title;
463
+ var useStyles3 = createStyles(({ css }) => {
464
+ return {
465
+ body: css`
466
+ padding: 10px;
467
+ `,
468
+ load: {
469
+ margin: "0 auto",
470
+ width: "100%",
471
+ lineHeight: "80vh"
472
+ },
473
+ gutter: {
474
+ display: "flex"
475
+ }
476
+ };
477
+ });
478
+ var Body = React.memo((props) => {
479
+ const {
480
+ children,
481
+ loading,
482
+ style,
483
+ className,
484
+ space = true,
485
+ animation = true
486
+ } = props;
487
+ const { styles: { body, load, gutter }, cx } = useStyles3();
488
+ return /* @__PURE__ */ jsx(App, { children: loading ? /* @__PURE__ */ jsx(Spin, { spinning: true, size: "large", className: load }) : /* @__PURE__ */ jsx(Layout, { style, children: /* @__PURE__ */ jsx("div", { className: cx("ant-layout-body", className || body), children: /* @__PURE__ */ jsx(animation_default, { animate: animation ? Animate.FadeUp : Animate.None, children: space ? /* @__PURE__ */ jsx(Space, { direction: "vertical", size: "middle", className: gutter, children }) : children }) }) }) });
489
+ });
490
+ var body_default = Body;
491
+ var Footer = React.memo(({ children }) => {
492
+ return /* @__PURE__ */ jsx(Fragment, { children });
493
+ });
494
+ var footer_default = Footer;
495
+ var useStyles4 = createStyles(({ css }) => {
496
+ return {
497
+ box: {
498
+ display: "flex",
499
+ alignItems: "center",
500
+ justifyContent: "space-between"
501
+ },
502
+ right: css`
503
+ z-index: 2;
504
+ `,
505
+ left: css`
506
+ z-index: 2;
507
+ `
508
+ };
509
+ });
510
+ var Header = React.memo((props) => {
511
+ const { styles: { box, right, left } } = useStyles4();
512
+ return /* @__PURE__ */ jsxs("div", { className: box, children: [
513
+ props?.left && /* @__PURE__ */ jsx("div", { className: left, children: props.left }),
514
+ props?.right && /* @__PURE__ */ jsx("div", { className: right, children: props.right })
515
+ ] });
516
+ });
517
+ var header_default = Header;
518
+ var useStyles5 = createStyles(({ token, isDarkMode }) => {
519
+ return {
520
+ left: {
521
+ position: "relative",
522
+ background: token?.colorBgContainer,
523
+ height: "100%",
524
+ display: "flex",
525
+ flexDirection: "column"
526
+ },
527
+ content: {
528
+ flex: 1,
529
+ overflowY: "auto"
530
+ },
531
+ menu: {
532
+ zIndex: 1,
533
+ overflow: "auto",
534
+ overflowX: "hidden",
535
+ borderRight: "none !important",
536
+ fontWeight: "600",
537
+ userSelect: "none",
538
+ ":focus-visible": {
539
+ outline: "none !important"
540
+ },
541
+ "::-webkit-scrollbar": {
542
+ width: 0
543
+ },
544
+ ".ant-menu-item-selected::after": {
545
+ borderRadius: (token?.borderRadius || 0) > 3 ? `${token.borderRadius}px 0 0 ${token.borderRadius}px` : "0",
546
+ borderRightWidth: "4px !important",
547
+ ...token?.borderRadius > 3 && {
548
+ right: "5px !important",
549
+ top: "19% !important",
550
+ height: "60% !important"
551
+ }
552
+ },
553
+ ".ant-menu-item,.ant-menu-submenu-title": {
554
+ transition: "border-color 0.3s,background 0.3s !important"
555
+ }
556
+ },
557
+ menuTop: {
558
+ zIndex: 2,
559
+ userSelect: "none",
560
+ height: "100px",
561
+ lineHeight: "100px !important",
562
+ width: "100%",
563
+ padding: "10px !important",
564
+ overflow: "hidden",
565
+ cursor: "pointer",
566
+ display: "flex",
567
+ justifyContent: "center",
568
+ alignItems: "center",
569
+ background: token?.colorBgContainer + " !important"
570
+ },
571
+ menuBottom: {
572
+ background: token?.colorBgContainer,
573
+ userSelect: "none",
574
+ padding: "0px !important",
575
+ borderRadius: "0px",
576
+ height: "50px",
577
+ lineHeight: "50px !important",
578
+ borderTop: "0.5px solid " + token?.colorBorder + " !important",
579
+ borderBottom: "0.5px solid " + token?.colorBorder + " !important",
580
+ fontWeight: "bolder",
581
+ fontSize: 14,
582
+ color: isDarkMode ? "rgb(255,255,255,0.65)" : "rgba(122,122,122)",
583
+ cursor: "pointer",
584
+ overflow: "hidden",
585
+ width: "100%",
586
+ zIndex: 2,
587
+ transition: "background 0.3s !important",
588
+ display: "flex",
589
+ justifyContent: "center",
590
+ alignItems: "center"
591
+ },
592
+ logoClose: {
593
+ margin: "0px -10px"
594
+ },
595
+ menu2: {
596
+ fontWeight: "bolder",
597
+ userSelect: "none",
598
+ fontSize: "13px",
599
+ flex: "auto",
600
+ height: "55px",
601
+ borderBottom: "none !important"
602
+ },
603
+ darkColor: {
604
+ background: "#001529 !important",
605
+ backgroundColor: "#001529 !important"
606
+ },
607
+ darkBorderTop: {
608
+ borderTop: "0.5px solid #202020 !important",
609
+ color: "white"
610
+ }
611
+ };
612
+ });
613
+ var Sider = React.memo((props) => {
614
+ const {
615
+ collapsed,
616
+ pathname,
617
+ matchedRoutes = [],
618
+ onNavigate,
619
+ onMenuClick,
620
+ menus,
621
+ onLogoClick,
622
+ collapsedLogo,
623
+ unCollapsedLogo,
624
+ menuBottomBtnIcon = null,
625
+ menuBottomBtnText = null,
626
+ onMenuBottomBtnClick,
627
+ classNames,
628
+ layout = "inline",
629
+ theme: theme2 = "light"
630
+ } = props;
631
+ const { mobile } = useResponsive();
632
+ const token = useTheme$1();
633
+ const { styles: { left, content, menu, menuTop, menuBottom, menu2, darkColor, darkBorderTop }, cx } = useStyles5();
634
+ const [selectedKeys, setSelectedKeys] = useState([]);
635
+ const [stateOpenKeys, setStateOpenKeys] = useState([]);
636
+ useEffect(() => {
637
+ if (pathname) {
638
+ setSelectedKeys([pathname]);
639
+ setStateOpenKeys(matchedRoutes);
640
+ }
641
+ }, [pathname, matchedRoutes]);
642
+ const levelKeys = useMemo(() => {
643
+ const key = {};
644
+ const func = (items2, level = 1) => {
645
+ items2.forEach((item) => {
646
+ if (item?.key) {
647
+ key[item.key] = level;
648
+ }
649
+ if (item?.children) {
650
+ return func(item.children, level + 1);
651
+ }
652
+ });
653
+ };
654
+ func(menus);
655
+ return key;
656
+ }, [menus]);
657
+ const onOpenChange = useCallback((openKeys) => {
658
+ const currentOpenKey = openKeys.find((key) => stateOpenKeys.indexOf(key) === -1);
659
+ if (currentOpenKey !== void 0) {
660
+ const repeatIndex = openKeys.filter((key) => key !== currentOpenKey).findIndex((key) => levelKeys[key] === levelKeys[currentOpenKey]);
661
+ setStateOpenKeys(
662
+ openKeys.filter((_, index) => index !== repeatIndex).filter((key) => levelKeys[key] <= levelKeys[currentOpenKey])
663
+ );
664
+ } else {
665
+ setStateOpenKeys(openKeys);
666
+ }
667
+ }, [stateOpenKeys, levelKeys]);
668
+ const menuTheme = useMemo(() => {
669
+ if (token?.isDarkMode) return "light";
670
+ return theme2 === "dark" ? theme2 : "light";
671
+ }, [token?.isDarkMode, theme2]);
672
+ const getColor = useMemo(() => {
673
+ return !token?.isDarkMode && menuTheme === "dark" ? " " + darkColor : "";
674
+ }, [token?.isDarkMode, menuTheme, darkColor]);
675
+ const getBorderColor = useMemo(() => {
676
+ return !token?.isDarkMode && menuTheme === "dark" ? " " + darkBorderTop : "";
677
+ }, [token?.isDarkMode, menuTheme, darkBorderTop]);
678
+ const menuConfig = useMemo(() => ({
679
+ components: {
680
+ Menu: {
681
+ itemSelectedColor: token?.colorPrimaryText || "",
682
+ itemColor: token?.colorTextSecondary || "",
683
+ itemHoverColor: token?.colorTextSecondary || "",
684
+ fontSize: 13,
685
+ itemMarginBlock: 0,
686
+ itemMarginInline: 0,
687
+ itemBorderRadius: 0,
688
+ subMenuItemBorderRadius: 0,
689
+ activeBarWidth: 4,
690
+ itemHeight: 45,
691
+ subMenuItemBg: "rgba(255, 255, 255, 0)"
692
+ }
693
+ }
694
+ }), [token?.colorPrimaryText, token?.colorTextSecondary]);
695
+ const handleMenuClick = useCallback((item) => {
696
+ if (onNavigate) {
697
+ onNavigate(item?.key);
698
+ }
699
+ setSelectedKeys([item?.key]);
700
+ onMenuClick?.(item);
701
+ }, [onNavigate, onMenuClick]);
702
+ const handleLogoClick = useCallback(() => {
703
+ onLogoClick?.();
704
+ }, [onLogoClick]);
705
+ return /* @__PURE__ */ jsx(Fragment, { children: layout === "inline" ? /* @__PURE__ */ jsxs(Layout, { className: cx(left, getColor), children: [
706
+ /* @__PURE__ */ jsxs(Layout.Header, { className: cx(menuTop, getColor), onClick: handleLogoClick, children: [
707
+ (mobile || !mobile && !collapsed) && unCollapsedLogo?.(!token?.isDarkMode),
708
+ !mobile && collapsed && collapsedLogo?.(token?.isDarkMode)
709
+ ] }),
710
+ /* @__PURE__ */ jsx(Layout.Content, { className: cx(content, getColor), children: /* @__PURE__ */ jsx(ConfigProvider, { theme: menuConfig, children: /* @__PURE__ */ jsx(
711
+ Menu,
712
+ {
713
+ selectedKeys,
714
+ theme: menuTheme,
715
+ mode: "inline",
716
+ items: menus,
717
+ className: cx(menu, classNames),
718
+ openKeys: !collapsed ? stateOpenKeys : void 0,
719
+ onOpenChange,
720
+ onClick: handleMenuClick
721
+ }
722
+ ) }) }),
723
+ (menuBottomBtnIcon || menuBottomBtnText) && /* @__PURE__ */ jsxs(
724
+ Layout.Footer,
725
+ {
726
+ className: cx(menuBottom, getColor, getBorderColor),
727
+ onClick: onMenuBottomBtnClick,
728
+ children: [
729
+ menuBottomBtnIcon && (typeof menuBottomBtnIcon === "string" ? /* @__PURE__ */ jsx(Icon, { type: menuBottomBtnIcon }) : menuBottomBtnIcon),
730
+ (mobile || !mobile && !collapsed) && menuBottomBtnText
731
+ ]
732
+ }
733
+ )
734
+ ] }) : /* @__PURE__ */ jsx(ConfigProvider, { theme: menuConfig, children: /* @__PURE__ */ jsx(
735
+ Menu,
736
+ {
737
+ theme: menuTheme,
738
+ mode: "horizontal",
739
+ selectedKeys,
740
+ items: menus,
741
+ className: cx(menu2, classNames),
742
+ onClick: handleMenuClick
743
+ }
744
+ ) }) });
745
+ });
746
+ var sider_default = Sider;
747
+ var useLoadingStyles = createStyles(() => {
748
+ return {
749
+ body: {
750
+ width: "100%",
751
+ margin: "0 auto",
752
+ lineHeight: "80vh"
753
+ }
754
+ };
755
+ });
756
+ var Loading = () => {
757
+ const { styles: { body } } = useLoadingStyles();
758
+ return /* @__PURE__ */ jsx(Spin, { size: "large", className: body });
759
+ };
760
+ var useLayoutStyles = createStyles(({ isDarkMode, token, css, responsive }) => {
761
+ return {
762
+ container: {
763
+ display: "flex",
764
+ flexDirection: "row"
765
+ },
766
+ sider: {
767
+ zIndex: 2,
768
+ boxShadow: "2px 0 8px 0 rgba(29,35,41,.05)",
769
+ background: "none !important",
770
+ height: "100vh",
771
+ overflowY: "auto",
772
+ position: "sticky",
773
+ left: 0,
774
+ top: 0,
775
+ bottom: 0,
776
+ transition: "all 0.3s,background 0s,height 0s",
777
+ ".ant-layout-header": {
778
+ backgroundColor: token?.colorBgContainer
779
+ }
780
+ },
781
+ menuBtn: {
782
+ width: "55px !important",
783
+ height: "55px",
784
+ lineHeight: "55px",
785
+ fontSize: "15px !important",
786
+ cursor: "pointer",
787
+ float: "left",
788
+ ":hover": {
789
+ background: "none !important"
790
+ }
791
+ },
792
+ drawMenu: {
793
+ padding: "0px !important"
794
+ },
795
+ body: css`
796
+ transition: margin-left 0.3s !important;
797
+ background-color: ${isDarkMode ? "black" : "transparent"};
798
+ display: flex;
799
+ flex-direction: column;
800
+ min-height: 100vh;
801
+ `,
802
+ sticky: {
803
+ position: "sticky",
804
+ top: 0,
805
+ left: 0
806
+ },
807
+ header: css`
808
+ padding: 0;
809
+ height: 55px;
810
+ line-height: 55px;
811
+ width: 100%;
812
+ z-index: 3;
813
+ box-shadow: 0 2px 8px 0 ${isDarkMode ? "rgba(0, 0, 0, 0.25)" : "rgba(29, 35, 41, 0.05)"};
814
+ user-select: none;
815
+ background: ${token?.colorBgContainer} !important;
816
+ flex-shrink: 0;
817
+
818
+ .ant-menu-item-icon {
819
+ color: ${isDarkMode ? "rgb(255,255,255,0.85)" : ""};
820
+ }
821
+ `,
822
+ horizontalContent: css`
823
+ width: 100%;
824
+ flex: 1 0 auto;
825
+ `,
826
+ inlineContent: css`
827
+ width: 100%;
828
+ flex: 1 0 auto;
829
+ `,
830
+ flowContent: css`
831
+ .ant-layout-body {
832
+ width: 80%;
833
+ margin-left: 10%;
834
+ }
835
+
836
+ ${responsive.md} {
837
+ .ant-layout-body {
838
+ width: 100%;
839
+ margin-left: 0;
840
+ }
841
+ }
842
+ `,
843
+ footer: css`
844
+ text-align: center;
845
+ flex-shrink: 0;
846
+ `,
847
+ flow: {
848
+ display: "flex",
849
+ justifyContent: "space-between",
850
+ height: "55px"
851
+ },
852
+ logo: {
853
+ display: "inline-flex",
854
+ justifyContent: "center",
855
+ alignItems: "center",
856
+ width: "220px",
857
+ height: "55px"
858
+ },
859
+ darkColor: {
860
+ backgroundColor: "#001529 !important"
861
+ },
862
+ layoutNormal: css`
863
+ min-height: 100vh;
864
+ display: flex;
865
+ flex-direction: column;
866
+ `
867
+ };
868
+ });
869
+ var SinKing = forwardRef((props, ref) => {
870
+ let {
871
+ loading = false,
872
+ breadCrumb = true,
873
+ breadCrumbItems = [],
874
+ hideBreadCrumb = false,
875
+ menus,
876
+ menuClassNames,
877
+ pathname,
878
+ matchedRoutes,
879
+ onNavigate,
880
+ onMenuClick,
881
+ onMenuBtnClick,
882
+ onLogoClick,
883
+ collapsedLogo,
884
+ unCollapsedLogo,
885
+ headerRight,
886
+ headerLeft,
887
+ headerFixed,
888
+ headerHidden = false,
889
+ menuCollapsedWidth = 60,
890
+ menuUnCollapsedWidth = 220,
891
+ menuBottomBtnIcon = void 0,
892
+ menuBottomBtnText = void 0,
893
+ onMenuBottomBtnClick,
894
+ layout = "inline",
895
+ flowLayout = false,
896
+ menuTheme = "light",
897
+ waterMark = void 0,
898
+ children
899
+ } = props;
900
+ const systemTheme = useTheme$1();
901
+ const [collapsed, setCollapsed] = useState(false);
902
+ const [open, setOpen] = useState(false);
903
+ const {
904
+ styles: {
905
+ container,
906
+ sider,
907
+ inlineContent,
908
+ sticky,
909
+ header,
910
+ horizontalContent,
911
+ footer,
912
+ body,
913
+ drawMenu,
914
+ menuBtn,
915
+ flow,
916
+ logo,
917
+ darkColor,
918
+ flowContent,
919
+ layoutNormal
920
+ },
921
+ cx
922
+ } = useLayoutStyles();
923
+ const { mobile, md } = useResponsive();
924
+ const menuBtnOnClick = () => {
925
+ let status;
926
+ if (layout === "inline" && mobile || layout === "horizontal" && !md) {
927
+ if (collapsed) {
928
+ setCollapsed(false);
929
+ }
930
+ status = !open;
931
+ setOpen(status);
932
+ } else {
933
+ status = !collapsed;
934
+ setCollapsed(status);
935
+ }
936
+ onMenuBtnClick?.(status);
937
+ };
938
+ useImperativeHandle(ref, () => ({
939
+ collapsedMenu: () => {
940
+ setCollapsed(true);
941
+ setOpen(false);
942
+ },
943
+ unCollapsedMenu: () => {
944
+ setCollapsed(false);
945
+ setOpen(false);
946
+ },
947
+ toggleCollapsedMenu: () => {
948
+ const status = !collapsed;
949
+ setCollapsed(status);
950
+ setOpen(false);
951
+ onMenuBtnClick?.(status);
952
+ }
953
+ }));
954
+ const getColor = () => {
955
+ const mode = systemTheme?.isDarkMode ? "light" : menuTheme === "dark" ? menuTheme : "light";
956
+ return !systemTheme?.isDarkMode && mode === "dark" ? " " + darkColor : "";
957
+ };
958
+ const getWaterMaskFont = () => {
959
+ return {
960
+ color: systemTheme?.isDarkMode ? "rgba(255, 255, 255, 0.03)" : "rgba(0, 0, 0, 0.07)"
961
+ };
962
+ };
963
+ const getSider = (mode) => {
964
+ const layoutMode = mode === "horizontal" ? mode : "inline";
965
+ const theme2 = menuTheme === "dark" ? menuTheme : "light";
966
+ const routePaths = Array.isArray(matchedRoutes) ? typeof matchedRoutes[0] === "string" ? matchedRoutes : matchedRoutes.map((route) => route?.pathname || route) : [];
967
+ return /* @__PURE__ */ jsx(
968
+ sider_default,
969
+ {
970
+ classNames: menuClassNames,
971
+ layout: layoutMode,
972
+ theme: theme2,
973
+ collapsed,
974
+ pathname,
975
+ matchedRoutes: routePaths,
976
+ onNavigate,
977
+ onLogoClick,
978
+ collapsedLogo,
979
+ unCollapsedLogo,
980
+ menuBottomBtnIcon,
981
+ menuBottomBtnText,
982
+ onMenuBottomBtnClick,
983
+ menus,
984
+ onMenuClick: (item) => {
985
+ setOpen(false);
986
+ onMenuClick?.(item);
987
+ }
988
+ }
989
+ );
990
+ };
991
+ const getOutlet = () => {
992
+ return /* @__PURE__ */ jsx(Watermark, { gap: [200, 200], font: getWaterMaskFont(), content: waterMark, children });
993
+ };
994
+ const drawer = /* @__PURE__ */ jsx(
995
+ Drawer,
996
+ {
997
+ placement: "left",
998
+ closable: false,
999
+ open,
1000
+ width: menuUnCollapsedWidth,
1001
+ classNames: { body: drawMenu },
1002
+ onClose: () => {
1003
+ setOpen(false);
1004
+ },
1005
+ children: getSider("inline")
1006
+ }
1007
+ );
1008
+ const LayoutNormal = /* @__PURE__ */ jsxs(Layout, { className: container, children: [
1009
+ mobile && drawer,
1010
+ /* @__PURE__ */ jsx(
1011
+ Layout.Sider,
1012
+ {
1013
+ className: sider,
1014
+ trigger: null,
1015
+ collapsible: true,
1016
+ collapsed,
1017
+ width: menuUnCollapsedWidth,
1018
+ collapsedWidth: menuCollapsedWidth,
1019
+ hidden: mobile,
1020
+ children: getSider(layout)
1021
+ }
1022
+ ),
1023
+ /* @__PURE__ */ jsxs(Layout, { className: body, children: [
1024
+ !headerHidden && /* @__PURE__ */ jsx(Layout.Header, { className: cx(header, headerFixed && sticky), children: /* @__PURE__ */ jsx(
1025
+ header_default,
1026
+ {
1027
+ left: /* @__PURE__ */ jsxs("div", { children: [
1028
+ /* @__PURE__ */ jsx(
1029
+ Button,
1030
+ {
1031
+ type: "text",
1032
+ size: "large",
1033
+ icon: collapsed ? /* @__PURE__ */ jsx(MenuUnfoldOutlined, {}) : /* @__PURE__ */ jsx(MenuFoldOutlined, {}),
1034
+ onClick: menuBtnOnClick,
1035
+ className: menuBtn
1036
+ }
1037
+ ),
1038
+ headerLeft
1039
+ ] }),
1040
+ right: headerRight
1041
+ }
1042
+ ) }),
1043
+ /* @__PURE__ */ jsxs(Layout.Content, { className: cx(inlineContent, flowLayout && flowContent), children: [
1044
+ /* @__PURE__ */ jsx(
1045
+ breadcrumb_default,
1046
+ {
1047
+ enabled: breadCrumb,
1048
+ items: breadCrumbItems,
1049
+ hideBreadCrumb
1050
+ }
1051
+ ),
1052
+ getOutlet()
1053
+ ] }),
1054
+ props?.footer && /* @__PURE__ */ jsx(Layout.Footer, { className: footer, children: /* @__PURE__ */ jsxs(footer_default, { children: [
1055
+ " ",
1056
+ props?.footer
1057
+ ] }) })
1058
+ ] })
1059
+ ] });
1060
+ const LayoutFlow = /* @__PURE__ */ jsxs(Layout, { className: layoutNormal, children: [
1061
+ /* @__PURE__ */ jsxs(Layout.Header, { className: cx(header, headerFixed && sticky), children: [
1062
+ !md && /* @__PURE__ */ jsx(header_default, { left: /* @__PURE__ */ jsxs("div", { children: [
1063
+ /* @__PURE__ */ jsx(
1064
+ Button,
1065
+ {
1066
+ type: "text",
1067
+ size: "large",
1068
+ icon: collapsed ? /* @__PURE__ */ jsx(MenuUnfoldOutlined, {}) : /* @__PURE__ */ jsx(MenuFoldOutlined, {}),
1069
+ onClick: menuBtnOnClick,
1070
+ className: menuBtn
1071
+ }
1072
+ ),
1073
+ headerLeft
1074
+ ] }), right: headerRight }),
1075
+ !md && drawer || /* @__PURE__ */ jsxs("div", { className: cx(flow, getColor()), children: [
1076
+ /* @__PURE__ */ jsx("div", { className: logo, children: unCollapsedLogo?.(!systemTheme?.isDarkMode) }),
1077
+ getSider(layout),
1078
+ /* @__PURE__ */ jsx("div", { children: headerRight })
1079
+ ] })
1080
+ ] }),
1081
+ /* @__PURE__ */ jsxs(Layout.Content, { className: cx(horizontalContent, flowLayout && flowContent), children: [
1082
+ /* @__PURE__ */ jsx(
1083
+ breadcrumb_default,
1084
+ {
1085
+ enabled: breadCrumb,
1086
+ items: breadCrumbItems,
1087
+ hideBreadCrumb
1088
+ }
1089
+ ),
1090
+ getOutlet()
1091
+ ] }),
1092
+ props?.footer && /* @__PURE__ */ jsx(Layout.Footer, { className: footer, children: /* @__PURE__ */ jsxs(footer_default, { children: [
1093
+ " ",
1094
+ props?.footer
1095
+ ] }) })
1096
+ ] });
1097
+ return /* @__PURE__ */ jsx(App, { children: loading && /* @__PURE__ */ jsx(Loading, {}) || (layout !== "horizontal" ? LayoutNormal : LayoutFlow) });
1098
+ });
1099
+ var sinking_default = SinKing;
1100
+ var Layout4 = forwardRef((props, ref) => {
1101
+ return /* @__PURE__ */ jsx(sinking_default, { ref, ...props });
1102
+ });
1103
+ var layout_default = Layout4;
1104
+ var useStyles6 = createStyles(({ token, isDarkMode }) => {
1105
+ const fontColor = isDarkMode ? "rgba(255,255,255,0.65)" : "rgba(0,0,0,0.65)";
1106
+ const backgroundColor = isDarkMode ? "rgba(255, 255, 255, 0.1) !important" : "rgba(0, 0, 0, 0.05) !important";
1107
+ const fontSize = 12;
1108
+ const pagination = {
1109
+ color: fontColor,
1110
+ fontSize,
1111
+ ".ant-pagination-item-active": {
1112
+ backgroundColor: "transparent !important"
1113
+ },
1114
+ ".ant-pagination-item": {
1115
+ backgroundColor: "transparent !important",
1116
+ "a": {
1117
+ color: fontColor
1118
+ }
1119
+ },
1120
+ ".ant-pagination-options": {
1121
+ display: "block"
1122
+ },
1123
+ ".ant-select": {
1124
+ ".ant-select-selector": {
1125
+ fontSize,
1126
+ transition: "background-color 0.3s ease",
1127
+ color: fontColor,
1128
+ borderColor: "transparent !important",
1129
+ borderRadius: token?.borderRadius + "px !important",
1130
+ backgroundColor
1131
+ }
1132
+ },
1133
+ ".ant-pagination-options-quick-jumper": {
1134
+ "input": {
1135
+ color: fontColor,
1136
+ borderColor: "transparent",
1137
+ borderRadius: token?.borderRadius + "px !important",
1138
+ backgroundColor
1139
+ }
1140
+ }
1141
+ };
1142
+ const btn = {
1143
+ fontSize: fontSize + "px",
1144
+ height: "auto",
1145
+ padding: "5px 10px",
1146
+ borderRadius: token?.borderRadius + "px"
1147
+ };
1148
+ return {
1149
+ formItem: {
1150
+ marginBottom: "0 !important"
1151
+ },
1152
+ formItemLabel: {
1153
+ ".ant-form-item-label": {
1154
+ flex: "0 0 80px"
1155
+ }
1156
+ },
1157
+ formItemBtn: {
1158
+ ".ant-space-item>div": {
1159
+ display: "flex",
1160
+ alignItems: "center",
1161
+ gap: "8px"
1162
+ },
1163
+ ".ant-space-item>a": {
1164
+ textDecoration: "none"
1165
+ }
1166
+ },
1167
+ formButton: {
1168
+ display: "flex",
1169
+ justifyContent: "end",
1170
+ alignItems: "end"
1171
+ },
1172
+ filter: {
1173
+ boxShadow: "0 0px 10px 4px rgba(0, 0, 0, 0.05) !important",
1174
+ backgroundColor: isDarkMode ? "rgba(255, 255, 255, 0.05)" : "rgba(255, 255, 255, 0.6)",
1175
+ backdropFilter: "blur(8px)"
1176
+ },
1177
+ pageCard: {
1178
+ ".ant-card-body": {
1179
+ padding: 15
1180
+ },
1181
+ ".ant-pagination ": pagination
1182
+ },
1183
+ toolCard: {
1184
+ fontSize: token?.fontSizeSM,
1185
+ color: fontColor,
1186
+ ".ant-card-body": {
1187
+ padding: "12px 17px",
1188
+ ".ant-col": {
1189
+ fontSize,
1190
+ "a": {
1191
+ opacity: isDarkMode ? "1" : "0.8"
1192
+ }
1193
+ }
1194
+ },
1195
+ "button": btn
1196
+ },
1197
+ tableCard: {
1198
+ ".ant-card-head": {
1199
+ padding: "10px 15px 0 15px",
1200
+ minHeight: "42px",
1201
+ borderBottom: "none",
1202
+ ".ant-card-extra": {
1203
+ "button": btn
1204
+ }
1205
+ },
1206
+ ".ant-card-body": {
1207
+ padding: "10px"
1208
+ }
1209
+ },
1210
+ table: {
1211
+ ".ant-table-thead": {
1212
+ ".ant-table-cell": {
1213
+ padding: "10px !important",
1214
+ fontSize: token?.fontSize,
1215
+ color: fontColor
1216
+ }
1217
+ },
1218
+ ".ant-table-tbody": {
1219
+ ".ant-table-cell": {
1220
+ padding: "10px !important",
1221
+ fontSize: token?.fontSizeSM + 1,
1222
+ color: fontColor,
1223
+ ".ant-btn": {
1224
+ height: "25px",
1225
+ padding: "10px ",
1226
+ fontSize: token?.fontSizeSM
1227
+ }
1228
+ },
1229
+ ".ant-typography": {
1230
+ fontSize: token?.fontSizeSM + 1,
1231
+ color: fontColor
1232
+ }
1233
+ },
1234
+ ".ant-pagination ": {
1235
+ ...pagination,
1236
+ ...{
1237
+ margin: "15px 15px 5px 15px !important"
1238
+ }
1239
+ }
1240
+ }
1241
+ };
1242
+ });
1243
+ var useContainerResponsive = (containerRef) => {
1244
+ const [responsive, setResponsive] = useState({
1245
+ xs: false,
1246
+ sm: false,
1247
+ md: false,
1248
+ lg: false,
1249
+ xl: false,
1250
+ xxl: false,
1251
+ mobile: false
1252
+ });
1253
+ const debounce = useCallback((func, wait) => {
1254
+ let timeout;
1255
+ return (...args) => {
1256
+ clearTimeout(timeout);
1257
+ timeout = setTimeout(() => func.apply(null, args), wait);
1258
+ };
1259
+ }, []);
1260
+ const updateResponsive = useCallback((width) => {
1261
+ const newResponsive = {
1262
+ xs: width < 576,
1263
+ sm: width >= 576 && width < 768,
1264
+ md: width >= 768 && width < 992,
1265
+ lg: width >= 992 && width < 1200,
1266
+ xl: width >= 1200 && width < 1600,
1267
+ xxl: width >= 1600,
1268
+ mobile: width < 992
1269
+ };
1270
+ setResponsive((prev) => {
1271
+ const hasChanged = Object.keys(newResponsive).some(
1272
+ (key) => prev[key] !== newResponsive[key]
1273
+ );
1274
+ return hasChanged ? newResponsive : prev;
1275
+ });
1276
+ }, []);
1277
+ const debouncedUpdate = useMemo(
1278
+ () => debounce((width) => updateResponsive(width), 10),
1279
+ [debounce, updateResponsive]
1280
+ );
1281
+ useEffect(() => {
1282
+ const container = containerRef.current;
1283
+ if (!container) return;
1284
+ const handleResize = () => {
1285
+ const width = container.clientWidth;
1286
+ debouncedUpdate(width);
1287
+ };
1288
+ updateResponsive(container.clientWidth);
1289
+ const resizeObserver = new ResizeObserver(handleResize);
1290
+ resizeObserver.observe(container);
1291
+ return () => {
1292
+ resizeObserver.unobserve(container);
1293
+ };
1294
+ }, [containerRef, debouncedUpdate, updateResponsive]);
1295
+ return responsive;
1296
+ };
1297
+ var ProTableComponent = forwardRef((props, ref) => {
1298
+ const { styles } = useStyles6();
1299
+ const containerRef = useRef(null);
1300
+ const device = useContainerResponsive(containerRef);
1301
+ const requestRef = useRef(null);
1302
+ const {
1303
+ title = void 0,
1304
+ // 表格标题
1305
+ extra = void 0,
1306
+ // 表格额外内容
1307
+ extraRefreshBtn,
1308
+ // 是否显示刷新按钮
1309
+ rowKey = "id",
1310
+ // 行的唯一标识
1311
+ columns = [],
1312
+ // 列配置
1313
+ tableProps = {},
1314
+ // 表格属性
1315
+ pageHidden = false,
1316
+ // 是否隐藏分页
1317
+ pageInTable = false,
1318
+ // 是否在表格中显示分页
1319
+ paginationProps = {},
1320
+ // 分页属性
1321
+ defaultPage = 1,
1322
+ //默认分页
1323
+ defaultPageSize = 10,
1324
+ //默认分页容量
1325
+ search = {},
1326
+ // 搜索表单配置
1327
+ request = void 0,
1328
+ // 请求函数
1329
+ rowSelection = false,
1330
+ // 多选配置
1331
+ selectionAffix = false,
1332
+ // 是否固定多选操作栏
1333
+ paginationAffix = false,
1334
+ // 是否固定底部分页栏
1335
+ virtual = false
1336
+ // 是否启用虚拟滚动
1337
+ } = props;
1338
+ const [form] = Form.useForm();
1339
+ const [collapsed, setCollapsed] = useState(true);
1340
+ const [data, setData] = useState([]);
1341
+ const [loading, setLoading] = useState(true);
1342
+ const [params, setParams] = useState({});
1343
+ const [sort, setSort] = useState({});
1344
+ const [page, setPage] = useState(defaultPage);
1345
+ const [pageSize, setPageSize] = useState(defaultPageSize);
1346
+ const [total, setTotal] = useState(0);
1347
+ const formatValues = useCallback((values) => {
1348
+ const transformedValues = { ...values };
1349
+ Object.keys(transformedValues).forEach((key) => {
1350
+ if (!transformedValues[key]) {
1351
+ delete transformedValues[key];
1352
+ }
1353
+ });
1354
+ columns.forEach((column) => {
1355
+ const { dataIndex, transform, valueType } = column;
1356
+ const value = values[dataIndex];
1357
+ if (value !== void 0 && value !== null && value !== "") {
1358
+ if (transform) {
1359
+ const transformed = transform?.(value);
1360
+ if (typeof transformed === "object" && transformed !== null) {
1361
+ Object.assign(transformedValues, transformed);
1362
+ delete transformedValues[column?.dataIndex];
1363
+ } else {
1364
+ transformedValues[dataIndex] = transformed;
1365
+ }
1366
+ } else {
1367
+ switch (valueType) {
1368
+ case "dateRange":
1369
+ case "dateTimeRange":
1370
+ case "timeRange":
1371
+ if (Array.isArray(value) && value.length === 2) {
1372
+ const formatStr = "YYYY-MM-DD HH:mm:ss";
1373
+ transformedValues[`${dataIndex}_start`] = value[0]?.format ? value[0].format(formatStr) : value[0];
1374
+ transformedValues[`${dataIndex}_end`] = value[1]?.format ? value[1].format(formatStr) : value[1];
1375
+ }
1376
+ break;
1377
+ case "date":
1378
+ transformedValues[dataIndex] = value?.format ? value.format("YYYY-MM-DD 00:00:00") : value;
1379
+ break;
1380
+ case "dateTime":
1381
+ transformedValues[dataIndex] = value?.format ? value.format("YYYY-MM-DD HH:mm:ss") : value;
1382
+ break;
1383
+ case "time":
1384
+ if (value?.format) {
1385
+ const today = dayjs().format("YYYY-MM-DD");
1386
+ transformedValues[dataIndex] = `${today} ${value.format("HH:mm:ss")}`;
1387
+ } else {
1388
+ transformedValues[dataIndex] = value;
1389
+ }
1390
+ break;
1391
+ case "switch":
1392
+ transformedValues[dataIndex] = value;
1393
+ break;
1394
+ default:
1395
+ transformedValues[dataIndex] = value;
1396
+ }
1397
+ }
1398
+ } else if (value === false && valueType === "switch") {
1399
+ if (transform) {
1400
+ const transformed = transform(value);
1401
+ if (typeof transformed === "object" && transformed !== null) {
1402
+ Object.assign(transformedValues, transformed);
1403
+ } else {
1404
+ transformedValues[dataIndex] = transformed;
1405
+ }
1406
+ } else {
1407
+ transformedValues[dataIndex] = value;
1408
+ }
1409
+ }
1410
+ });
1411
+ return transformedValues;
1412
+ }, [columns]);
1413
+ const onFinish = useCallback((values) => {
1414
+ setPage(1);
1415
+ setParams(formatValues(values));
1416
+ }, [formatValues]);
1417
+ const onReset = useCallback(() => {
1418
+ if (params && Object.keys(params).length > 0 || page > 1) {
1419
+ form?.resetFields();
1420
+ setPage(1);
1421
+ setParams({});
1422
+ }
1423
+ }, [params, page, form]);
1424
+ const getSearchFormItem = useMemo(() => {
1425
+ let elements = [];
1426
+ let sum = 0;
1427
+ let sumAll = 0;
1428
+ let skip = 1;
1429
+ let span = 24;
1430
+ if (device.xl || device.xxl || device.lg) {
1431
+ skip = 3;
1432
+ span = 6;
1433
+ } else if (device.md) {
1434
+ skip = 2;
1435
+ span = 8;
1436
+ } else if (device.sm) {
1437
+ skip = 1;
1438
+ span = 12;
1439
+ }
1440
+ const renderFormField = (column) => {
1441
+ const { valueType, valueEnum, dataIndex, title: title2, props: props2 = {} } = column;
1442
+ const placeholder = `\u8BF7\u8F93\u5165${title2 || dataIndex}`;
1443
+ if (valueEnum) {
1444
+ return /* @__PURE__ */ jsx(Select, { placeholder: `\u8BF7\u9009\u62E9${title2 || dataIndex}`, allowClear: true, ...props2, children: Object.entries(valueEnum).map(([key, value]) => /* @__PURE__ */ jsx(Select.Option, { value: key, children: value.text }, key)) });
1445
+ }
1446
+ switch (valueType) {
1447
+ case "date":
1448
+ return /* @__PURE__ */ jsx(DatePicker, { style: { width: "100%" }, placeholder, ...props2 });
1449
+ case "dateTime":
1450
+ return /* @__PURE__ */ jsx(DatePicker, { showTime: true, style: { width: "100%" }, placeholder, ...props2 });
1451
+ case "dateRange":
1452
+ return /* @__PURE__ */ jsx(DatePicker.RangePicker, { style: { width: "100%" }, ...props2 });
1453
+ case "dateTimeRange":
1454
+ return /* @__PURE__ */ jsx(DatePicker.RangePicker, { showTime: true, style: { width: "100%" }, ...props2 });
1455
+ case "time":
1456
+ return /* @__PURE__ */ jsx(TimePicker, { style: { width: "100%" }, placeholder, ...props2 });
1457
+ case "timeRange":
1458
+ return /* @__PURE__ */ jsx(TimePicker.RangePicker, { style: { width: "100%" }, ...props2 });
1459
+ case "digit":
1460
+ return /* @__PURE__ */ jsx(InputNumber, { style: { width: "100%" }, placeholder, ...props2 });
1461
+ case "rate":
1462
+ return /* @__PURE__ */ jsx(Rate, { allowHalf: true, ...props2 });
1463
+ case "switch":
1464
+ return /* @__PURE__ */ jsx(Switch, { ...props2 });
1465
+ case "percent":
1466
+ return /* @__PURE__ */ jsx(
1467
+ InputNumber,
1468
+ {
1469
+ style: { width: "100%" },
1470
+ placeholder,
1471
+ formatter: (value) => `${value}%`,
1472
+ parser: (value) => value.replace("%", ""),
1473
+ ...props2
1474
+ }
1475
+ );
1476
+ case "progress":
1477
+ return /* @__PURE__ */ jsx(
1478
+ InputNumber,
1479
+ {
1480
+ style: { width: "100%" },
1481
+ placeholder,
1482
+ min: 0,
1483
+ max: 100,
1484
+ ...props2
1485
+ }
1486
+ );
1487
+ case "select":
1488
+ return /* @__PURE__ */ jsx(Select, { placeholder: `\u8BF7\u9009\u62E9${title2 || dataIndex}`, allowClear: true, ...props2 });
1489
+ default:
1490
+ return /* @__PURE__ */ jsx(Input, { placeholder, ...props2 });
1491
+ }
1492
+ };
1493
+ let hide = false;
1494
+ columns.forEach((column, index) => {
1495
+ if (column?.hideInSearch === true) {
1496
+ return;
1497
+ }
1498
+ if (!hide) {
1499
+ sumAll++;
1500
+ }
1501
+ if (skip > 0 && collapsed && sum >= skip) {
1502
+ hide = true;
1503
+ }
1504
+ if (!hide) {
1505
+ sum++;
1506
+ }
1507
+ const { formItemProps = {} } = column;
1508
+ elements.push(/* @__PURE__ */ jsx(
1509
+ Col,
1510
+ {
1511
+ span,
1512
+ style: { display: hide ? "none" : "block" },
1513
+ className: search?.layout && search?.layout != "vertical" ? " " + styles.formItemLabel : "",
1514
+ children: /* @__PURE__ */ jsx(
1515
+ Form.Item,
1516
+ {
1517
+ className: styles.formItem,
1518
+ label: column?.title || column?.dataIndex,
1519
+ labelAlign: "right",
1520
+ colon: true,
1521
+ tooltip: column?.tip || void 0,
1522
+ name: column?.dataIndex,
1523
+ ...formItemProps,
1524
+ children: renderFormField(column)
1525
+ }
1526
+ )
1527
+ },
1528
+ column?.dataIndex + index
1529
+ ));
1530
+ });
1531
+ let offset = 0;
1532
+ if (device.xl || device.xxl || device.lg) {
1533
+ if (sum <= 3) {
1534
+ offset = (4 - sum - 1) * 6;
1535
+ } else {
1536
+ offset = sum % 4;
1537
+ if (offset <= 0) {
1538
+ offset = 18;
1539
+ } else {
1540
+ offset = 24 - (offset + 1) * 6;
1541
+ }
1542
+ }
1543
+ } else if (device.md) {
1544
+ if (sum <= 2) {
1545
+ offset = (3 - sum - 1) * 8;
1546
+ } else {
1547
+ offset = sum % 3;
1548
+ if (offset <= 0) {
1549
+ offset = 16;
1550
+ } else {
1551
+ offset = 24 - (offset + 1) * 8;
1552
+ }
1553
+ }
1554
+ } else if (device.sm) {
1555
+ if (sum <= 1) {
1556
+ offset = (2 - sum - 1) * 12;
1557
+ } else {
1558
+ offset = sum % 2;
1559
+ if (offset <= 0) {
1560
+ offset = 12;
1561
+ } else {
1562
+ offset = 24 - (offset + 1) * 12;
1563
+ }
1564
+ }
1565
+ } else if (device.xs) {
1566
+ offset = 0;
1567
+ }
1568
+ if (offset <= 0) {
1569
+ offset = 0;
1570
+ }
1571
+ elements.push(/* @__PURE__ */ jsx(
1572
+ Col,
1573
+ {
1574
+ span,
1575
+ offset,
1576
+ className: styles.formButton,
1577
+ children: /* @__PURE__ */ jsx(Form.Item, { className: styles.formItem, children: /* @__PURE__ */ jsxs(Space, { align: "center", size: 16, className: styles.formItemBtn, children: [
1578
+ /* @__PURE__ */ jsxs("div", { children: [
1579
+ /* @__PURE__ */ jsx(Button, { htmlType: "reset", children: "\u91CD\u7F6E" }),
1580
+ /* @__PURE__ */ jsx(Button, { type: "primary", htmlType: "submit", loading, children: "\u67E5\u8BE2" })
1581
+ ] }),
1582
+ sumAll > skip && /* @__PURE__ */ jsx("a", { onClick: () => setCollapsed(!collapsed), children: collapsed ? /* @__PURE__ */ jsxs(Fragment, { children: [
1583
+ "\u5C55\u5F00 ",
1584
+ /* @__PURE__ */ jsx(DownOutlined, {})
1585
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1586
+ "\u6536\u8D77 ",
1587
+ /* @__PURE__ */ jsx(UpOutlined, {})
1588
+ ] }) })
1589
+ ] }) })
1590
+ },
1591
+ "action" + (sum + 2)
1592
+ ));
1593
+ return /* @__PURE__ */ jsx(Row, { gutter: [20, 20], children: elements });
1594
+ }, [columns, collapsed, device, loading, search, styles, form]);
1595
+ const renderTableCell = useCallback((text, record, column) => {
1596
+ const { valueType, valueEnum, copyable, props: props2 = {} } = column;
1597
+ if (valueEnum && text !== void 0 && text !== null) {
1598
+ const enumItem = valueEnum[text];
1599
+ if (enumItem) {
1600
+ const { text: label, color } = enumItem;
1601
+ if (color) {
1602
+ const colorMap = {
1603
+ success: "success",
1604
+ warning: "warning",
1605
+ error: "error",
1606
+ default: "default",
1607
+ processing: "processing"
1608
+ };
1609
+ return /* @__PURE__ */ jsx(
1610
+ Tag,
1611
+ {
1612
+ color: colorMap[color] || color || "default",
1613
+ bordered: false,
1614
+ ...props2,
1615
+ children: label
1616
+ }
1617
+ );
1618
+ }
1619
+ return label;
1620
+ }
1621
+ }
1622
+ let content;
1623
+ switch (valueType) {
1624
+ case "date":
1625
+ content = text ? dayjs(text).format("YYYY-MM-DD") : "-";
1626
+ break;
1627
+ case "dateTime":
1628
+ content = text ? dayjs(text).format("YYYY-MM-DD HH:mm:ss") : "-";
1629
+ break;
1630
+ case "time":
1631
+ content = text ? dayjs(text).format("HH:mm:ss") : "-";
1632
+ break;
1633
+ case "percent":
1634
+ content = /* @__PURE__ */ jsx(Progress, { percent: Number(text) || 0, size: "small", ...props2 });
1635
+ break;
1636
+ case "progress":
1637
+ content = /* @__PURE__ */ jsx(Progress, { percent: Number(text) || 0, size: "small", ...props2 });
1638
+ break;
1639
+ case "rate":
1640
+ content = /* @__PURE__ */ jsx(Rate, { disabled: true, value: Number(text) || 0, ...props2 });
1641
+ break;
1642
+ case "switch":
1643
+ content = /* @__PURE__ */ jsx(Switch, { checked: !!text, disabled: true, ...props2 });
1644
+ break;
1645
+ case "digit":
1646
+ content = typeof text === "number" ? text.toLocaleString() : text;
1647
+ break;
1648
+ default:
1649
+ content = text || "-";
1650
+ }
1651
+ if (copyable && text) {
1652
+ return /* @__PURE__ */ jsx(Typography.Text, { copyable: true, children: content });
1653
+ }
1654
+ return content;
1655
+ }, []);
1656
+ const getTableColumns = useMemo(() => {
1657
+ const list = [];
1658
+ columns.forEach((column) => {
1659
+ if (column?.hideInTable === true) return;
1660
+ const newColumn = {
1661
+ ...column,
1662
+ // 使用稳定的 render 函数引用
1663
+ render: column.render || ((text, record) => {
1664
+ return renderTableCell(text, record, column);
1665
+ })
1666
+ };
1667
+ if (column.tip && typeof column.title === "string") {
1668
+ const originalTitle = column.title;
1669
+ newColumn.title = () => /* @__PURE__ */ jsxs(Space, { size: "small", children: [
1670
+ originalTitle,
1671
+ /* @__PURE__ */ jsx(Tooltip, { title: column.tip, children: /* @__PURE__ */ jsx(QuestionCircleOutlined, {}) })
1672
+ ] });
1673
+ }
1674
+ list.push(newColumn);
1675
+ });
1676
+ return list;
1677
+ }, [columns, renderTableCell]);
1678
+ requestRef.current = request;
1679
+ const requestData = useCallback(() => {
1680
+ const currentRequest = requestRef.current;
1681
+ if (!currentRequest) {
1682
+ setLoading(false);
1683
+ return;
1684
+ }
1685
+ setLoading(true);
1686
+ const param = { ...params };
1687
+ param.current = page;
1688
+ param.pageSize = pageSize;
1689
+ const sorter = { ...sort };
1690
+ currentRequest(param, sorter).then((res) => {
1691
+ if (res?.success) {
1692
+ setData(res?.data || []);
1693
+ setTotal(res?.total || 0);
1694
+ }
1695
+ }).finally(() => {
1696
+ setLoading(false);
1697
+ });
1698
+ }, [params, page, pageSize, sort]);
1699
+ useEffect(() => {
1700
+ requestData();
1701
+ }, [requestData]);
1702
+ const getTableExtra = useMemo(() => {
1703
+ if (!extraRefreshBtn && !extra) {
1704
+ return false;
1705
+ }
1706
+ return /* @__PURE__ */ jsxs(Space, { children: [
1707
+ extra,
1708
+ extraRefreshBtn && /* @__PURE__ */ jsx(
1709
+ Button,
1710
+ {
1711
+ color: "default",
1712
+ style: {
1713
+ fontSize: "15px",
1714
+ opacity: "0.7"
1715
+ },
1716
+ variant: "link",
1717
+ icon: /* @__PURE__ */ jsx(RedoOutlined, { rotate: 260 }),
1718
+ onClick: requestData
1719
+ }
1720
+ )
1721
+ ] });
1722
+ }, [extraRefreshBtn, extra, requestData]);
1723
+ const [selectedRowKeys, setSelectedRowKeys] = useState([]);
1724
+ const [selectedRows, setSelectedRows] = useState([]);
1725
+ const clearSelectedRow = useCallback(() => {
1726
+ setSelectedRowKeys([]);
1727
+ setSelectedRows([]);
1728
+ if (rowSelection && typeof rowSelection === "object" && rowSelection.onChange) {
1729
+ rowSelection.onChange([], []);
1730
+ }
1731
+ }, [rowSelection]);
1732
+ const invertSelectedRow = useCallback(() => {
1733
+ const allKeys = data.map((item) => item[rowKey]);
1734
+ const newSelectedKeys = allKeys.filter((key) => !selectedRowKeys.includes(key));
1735
+ setSelectedRowKeys(newSelectedKeys);
1736
+ const newSelectedRows = data.filter((item) => newSelectedKeys.includes(item[rowKey]));
1737
+ setSelectedRows(newSelectedRows);
1738
+ if (rowSelection && typeof rowSelection === "object" && rowSelection.onChange) {
1739
+ rowSelection.onChange(newSelectedKeys, newSelectedRows);
1740
+ }
1741
+ }, [data, rowKey, selectedRowKeys, rowSelection]);
1742
+ const allSelectedRow = useCallback(() => {
1743
+ const allKeys = data.map((item) => item[rowKey]);
1744
+ setSelectedRowKeys(allKeys);
1745
+ setSelectedRows(data);
1746
+ if (rowSelection && typeof rowSelection === "object" && rowSelection.onChange) {
1747
+ rowSelection.onChange(allKeys, data);
1748
+ }
1749
+ }, [data, rowKey, rowSelection]);
1750
+ const handleSelectChange = useCallback((newSelectedRowKeys, newSelectedRows) => {
1751
+ setSelectedRowKeys(newSelectedRowKeys);
1752
+ setSelectedRows(newSelectedRows);
1753
+ if (rowSelection && typeof rowSelection === "object" && rowSelection?.onChange) {
1754
+ rowSelection?.onChange(newSelectedRowKeys, newSelectedRows);
1755
+ }
1756
+ }, [rowSelection]);
1757
+ const handleSelect = useCallback((record, selected, selectedRows2) => {
1758
+ if (rowSelection && typeof rowSelection === "object" && rowSelection?.onSelect) {
1759
+ rowSelection?.onSelect(record, selected, selectedRows2);
1760
+ }
1761
+ }, [rowSelection]);
1762
+ const handleSelectAll = useCallback((selected, selectedRows2, changeRows) => {
1763
+ if (rowSelection && typeof rowSelection === "object" && rowSelection?.onSelectAll) {
1764
+ rowSelection?.onSelectAll(selected, selectedRows2, changeRows);
1765
+ }
1766
+ }, [rowSelection]);
1767
+ const handleSelectInvert = useCallback((selectedRowKeys2) => {
1768
+ if (rowSelection && typeof rowSelection === "object" && rowSelection?.onSelectInvert) {
1769
+ rowSelection?.onSelectInvert(selectedRowKeys2);
1770
+ }
1771
+ }, [rowSelection]);
1772
+ const getRowSelection = useMemo(() => {
1773
+ if (rowSelection === false) {
1774
+ return void 0;
1775
+ }
1776
+ const select = {
1777
+ selectedRowKeys: rowSelection?.selectedRowKeys || selectedRowKeys,
1778
+ onChange: handleSelectChange,
1779
+ onSelect: handleSelect,
1780
+ onSelectAll: handleSelectAll,
1781
+ onSelectInvert: handleSelectInvert
1782
+ };
1783
+ return {
1784
+ ...{
1785
+ align: rowSelection?.align || "center",
1786
+ columnWidth: rowSelection?.columnWidth || 50,
1787
+ fixed: rowSelection?.fixed || false,
1788
+ selections: [
1789
+ {
1790
+ key: "all",
1791
+ text: "\u5168\u90E8\u9009\u4E2D",
1792
+ onSelect: allSelectedRow
1793
+ },
1794
+ {
1795
+ key: "invert",
1796
+ text: "\u53CD\u5411\u9009\u4E2D",
1797
+ onSelect: invertSelectedRow
1798
+ },
1799
+ {
1800
+ key: "clear",
1801
+ text: "\u6E05\u7A7A\u9009\u4E2D",
1802
+ onSelect: clearSelectedRow
1803
+ }
1804
+ ]
1805
+ },
1806
+ ...rowSelection,
1807
+ ...select
1808
+ };
1809
+ }, [rowSelection, selectedRowKeys, handleSelectChange, handleSelect, handleSelectAll, handleSelectInvert, allSelectedRow, invertSelectedRow, clearSelectedRow]);
1810
+ const setSelectedRowKey = useCallback((keys) => {
1811
+ setSelectedRowKeys(keys);
1812
+ const rows = data.filter((item) => keys.includes(item[rowKey]));
1813
+ setSelectedRows(rows);
1814
+ if (rowSelection && typeof rowSelection === "object" && rowSelection.onChange) {
1815
+ rowSelection.onChange(keys, rows);
1816
+ }
1817
+ }, [data, rowKey, rowSelection]);
1818
+ useImperativeHandle(ref, () => ({
1819
+ searchForm: form,
1820
+ refreshTableData: requestData,
1821
+ resetTableData: onReset,
1822
+ getTableData: () => {
1823
+ return {
1824
+ data,
1825
+ page,
1826
+ pageSize,
1827
+ sort,
1828
+ total
1829
+ };
1830
+ },
1831
+ getSelectedRowKeys: () => selectedRowKeys,
1832
+ getSelectedRows: () => selectedRows,
1833
+ setSelectedRowKeys: setSelectedRowKey,
1834
+ clearSelectedRows: clearSelectedRow,
1835
+ invertSelectedRow,
1836
+ allSelectedRow
1837
+ }));
1838
+ const [selectionBarAffix, setSelectionBarAffix] = useState(false);
1839
+ const renderSelectionBar = useCallback(() => {
1840
+ if ((selectedRowKeys?.length || 0) <= 0) return null;
1841
+ const content = /* @__PURE__ */ jsx(
1842
+ Card,
1843
+ {
1844
+ className: styles.toolCard + (selectionBarAffix ? " " + styles.filter : ""),
1845
+ variant: "borderless",
1846
+ children: /* @__PURE__ */ jsxs(Row, { justify: "space-between", align: "middle", children: [
1847
+ /* @__PURE__ */ jsx(Col, { children: typeof rowSelection?.leftExtra === "function" && rowSelection?.leftExtra?.(selectedRowKeys, selectedRows) || rowSelection?.leftExtra || /* @__PURE__ */ jsxs(Fragment, { children: [
1848
+ "\u5DF2\u9009\u62E9 ",
1849
+ selectedRowKeys?.length,
1850
+ " \u9879 ",
1851
+ /* @__PURE__ */ jsx(
1852
+ "a",
1853
+ {
1854
+ onClick: clearSelectedRow,
1855
+ children: "\u53D6\u6D88\u9009\u62E9"
1856
+ }
1857
+ )
1858
+ ] }) }),
1859
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(Space, { children: typeof rowSelection?.rightExtra === "function" && rowSelection?.rightExtra?.(selectedRowKeys, selectedRows) || rowSelection?.rightExtra }) })
1860
+ ] })
1861
+ }
1862
+ );
1863
+ if (rowSelection?.hideExtra === true) {
1864
+ return false;
1865
+ }
1866
+ return /* @__PURE__ */ jsx(Col, { span: (selectedRowKeys?.length || 0) <= 0 ? 0 : 24, children: selectionAffix ? /* @__PURE__ */ jsx(Affix, { offsetTop: 5, onChange: (affixed) => setSelectionBarAffix(affixed || false), children: content }) : content });
1867
+ }, [selectedRowKeys, selectedRows, rowSelection, selectionAffix, selectionBarAffix, styles, clearSelectedRow]);
1868
+ const [pageAffix, setPageAffix] = useState(false);
1869
+ const renderPagination = useCallback(() => {
1870
+ if (pageHidden || pageInTable || total <= 0) return null;
1871
+ const content = /* @__PURE__ */ jsx(
1872
+ Card,
1873
+ {
1874
+ className: styles.pageCard + (pageAffix ? " " + styles.filter : ""),
1875
+ variant: "borderless",
1876
+ children: /* @__PURE__ */ jsx(
1877
+ Pagination,
1878
+ {
1879
+ align: "center",
1880
+ showTotal: (total2, range) => device?.xs || device?.sm ? false : `\u7B2C ${range[0]}-${range[1]} \u6761 / \u5171 ${total2} \u6761`,
1881
+ showQuickJumper: !(device?.xs || device?.sm),
1882
+ pageSizeOptions: [10, 20, 50, 100],
1883
+ ...paginationProps,
1884
+ showSizeChanger: {
1885
+ showSearch: false,
1886
+ variant: "filled",
1887
+ size: "small"
1888
+ },
1889
+ showLessItems: true,
1890
+ size: "small",
1891
+ current: page,
1892
+ pageSize,
1893
+ total,
1894
+ onChange: (page2, pageSize2) => {
1895
+ setPage(page2);
1896
+ setPageSize(pageSize2);
1897
+ }
1898
+ }
1899
+ )
1900
+ }
1901
+ );
1902
+ return paginationAffix ? /* @__PURE__ */ jsx(Affix, { offsetBottom: 5, onChange: (affixed) => setPageAffix(affixed || false), children: content }) : content;
1903
+ }, [pageHidden, pageInTable, total, page, pageSize, paginationProps, device, pageAffix, paginationAffix, styles]);
1904
+ return /* @__PURE__ */ jsxs(Row, { gutter: [15, 15], ref: containerRef, children: [
1905
+ /* @__PURE__ */ jsx(Col, { span: !search ? 0 : 24, children: /* @__PURE__ */ jsx(Card, { variant: "borderless", children: /* @__PURE__ */ jsx(
1906
+ Form,
1907
+ {
1908
+ layout: search?.layout || "vertical",
1909
+ form,
1910
+ onReset,
1911
+ onFinish,
1912
+ children: getSearchFormItem
1913
+ }
1914
+ ) }) }),
1915
+ renderSelectionBar(),
1916
+ /* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsx(Card, { title, extra: getTableExtra, className: styles.tableCard, variant: "borderless", children: /* @__PURE__ */ jsx(
1917
+ Table,
1918
+ {
1919
+ rowKey,
1920
+ className: styles.table,
1921
+ style: { overflowX: "auto", whiteSpace: "nowrap" },
1922
+ scroll: { x: true, y: virtual ? 500 : void 0 },
1923
+ virtual,
1924
+ ...tableProps,
1925
+ rowSelection: getRowSelection,
1926
+ pagination: !pageHidden && pageInTable ? {
1927
+ ...{
1928
+ pageSizeOptions: [10, 20, 50, 100]
1929
+ },
1930
+ ...paginationProps,
1931
+ ...{
1932
+ current: page,
1933
+ pageSize,
1934
+ total,
1935
+ size: "small",
1936
+ showSizeChanger: {
1937
+ showSearch: false,
1938
+ variant: "filled",
1939
+ size: "small"
1940
+ },
1941
+ showQuickJumper: !(device?.xs || device?.sm),
1942
+ showLessItems: true,
1943
+ showTotal: (total2, range) => device?.xs || device?.sm ? false : `\u7B2C ${range[0]}-${range[1]} \u6761 / \u5171 ${total2} \u6761`,
1944
+ onChange: (page2, pageSize2) => {
1945
+ setPage(page2);
1946
+ setPageSize(pageSize2);
1947
+ }
1948
+ }
1949
+ } : false,
1950
+ size: "small",
1951
+ columns: getTableColumns,
1952
+ dataSource: data,
1953
+ loading,
1954
+ onChange: useCallback((_, filters, sorter) => {
1955
+ if (Object.keys(filters).length > 0) {
1956
+ setParams((prev) => ({ ...prev, ...filters }));
1957
+ }
1958
+ if (Object.keys(sorter).length > 0 && sorter?.field) {
1959
+ let temp = {};
1960
+ temp[sorter?.field] = sorter?.order;
1961
+ setSort(temp);
1962
+ }
1963
+ }, [])
1964
+ }
1965
+ ) }) }),
1966
+ !pageHidden && !pageInTable && total > 0 && /* @__PURE__ */ jsx(Col, { span: 24, children: renderPagination() })
1967
+ ] });
1968
+ });
1969
+ var pro_table_default = ProTableComponent;
1970
+ var ProModal = forwardRef((props, ref) => {
1971
+ const {
1972
+ modalProps = {},
1973
+ title,
1974
+ onOk,
1975
+ onCancel,
1976
+ afterClose,
1977
+ okText,
1978
+ okType,
1979
+ width = 520,
1980
+ afterOpenChange,
1981
+ children
1982
+ } = props;
1983
+ const theme2 = useTheme();
1984
+ const [internalOpen, setInternalOpen] = useState(false);
1985
+ const isControlled = modalProps?.open !== void 0;
1986
+ const open = isControlled ? modalProps?.open : internalOpen;
1987
+ const adjustedWidth = theme2?.isCompactTheme?.() ? typeof width === "number" ? Math.floor(width * 0.87) : width : width;
1988
+ const handleOk = async () => {
1989
+ await onOk?.();
1990
+ };
1991
+ const handleCancel = () => {
1992
+ if (onCancel) {
1993
+ onCancel();
1994
+ } else if (!isControlled) {
1995
+ setInternalOpen(false);
1996
+ afterOpenChange?.(false);
1997
+ }
1998
+ };
1999
+ const handleAfterClose = () => {
2000
+ afterClose?.();
2001
+ };
2002
+ useImperativeHandle(ref, () => ({
2003
+ show: () => {
2004
+ if (!isControlled) {
2005
+ setInternalOpen(true);
2006
+ }
2007
+ afterOpenChange?.(true);
2008
+ },
2009
+ hide: () => {
2010
+ if (!isControlled) {
2011
+ setInternalOpen(false);
2012
+ }
2013
+ afterOpenChange?.(false);
2014
+ }
2015
+ }));
2016
+ return /* @__PURE__ */ jsx(
2017
+ Modal$1,
2018
+ {
2019
+ title,
2020
+ open,
2021
+ onOk: handleOk,
2022
+ onCancel: handleCancel,
2023
+ afterClose: handleAfterClose,
2024
+ okText,
2025
+ okType,
2026
+ width: adjustedWidth,
2027
+ maskClosable: false,
2028
+ ...modalProps,
2029
+ children
2030
+ }
2031
+ );
2032
+ });
2033
+ var pro_modal_default = ProModal;
2034
+
2035
+ export { Animate, animation_default as Animation, antd_default as Antd, body_default as Body, breadcrumb_default as Breadcrumb, footer_default as Footer, header_default as Header, Icon, IconFontProvider, layout_default as Layout, Message, Modal, Notification, pro_modal_default as ProModal, pro_table_default as ProTable, sider_default as Sider, theme_default as Theme, title_default as Title, getAllIconNames, getAntdIconNames, getIconfontIconNames, getIconfontUrl, setIconfontUrl, useTheme };
2036
+ //# sourceMappingURL=index.mjs.map
2037
+ //# sourceMappingURL=index.mjs.map