@faasjs/ant-design 0.0.4-beta.8 → 0.0.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -54
- package/dist/index.d.mts +70 -57
- package/dist/index.d.ts +70 -57
- package/dist/index.js +353 -340
- package/dist/index.mjs +356 -343
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ErrorBoundary as ErrorBoundary$1, FaasReactClient, FaasDataWrapper as FaasDataWrapper$1, faas } from '@faasjs/react';
|
|
2
2
|
export { faas, useFaas } from '@faasjs/react';
|
|
3
|
-
import { Form as Form$1, Modal, Drawer, message, notification, ConfigProvider, Typography, Spin, Descriptions, Input, Button, Row, Col, TimePicker, DatePicker, Switch, Select, InputNumber, Radio, Result, Skeleton, Table as Table$1, Tabs as Tabs$1,
|
|
3
|
+
import { Form as Form$1, Modal, Drawer, message, notification, ConfigProvider as ConfigProvider$1, Typography, Spin, Descriptions, Input, Button, Row, Col, TimePicker, DatePicker, Switch, Select, InputNumber, Radio, Result, Skeleton, Table as Table$1, Tabs as Tabs$1, Alert, Space } from 'antd';
|
|
4
4
|
export { Drawer, Modal } from 'antd';
|
|
5
5
|
import { StyleProvider, legacyLogicalPropertiesTransformer } from '@ant-design/cssinjs';
|
|
6
|
-
import { createContext, useState,
|
|
6
|
+
import { createContext, useState, useEffect, useContext, useMemo, cloneElement, useCallback, isValidElement, Suspense } from 'react';
|
|
7
7
|
export { lazy } from 'react';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
import { BrowserRouter, useNavigate, Link as Link$1, Routes as Routes$1, Route, useLocation } from 'react-router-dom';
|
|
@@ -52,57 +52,28 @@ function useDrawer(init) {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
message: {},
|
|
57
|
-
notification: {},
|
|
58
|
-
setModalProps: () => void 0,
|
|
59
|
-
setDrawerProps: () => void 0
|
|
60
|
-
});
|
|
61
|
-
function RoutesApp(props) {
|
|
62
|
-
const location = useLocation();
|
|
63
|
-
const { setDrawerProps, setModalProps } = useApp();
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
console.debug("location", location);
|
|
66
|
-
setDrawerProps({ open: false });
|
|
67
|
-
setModalProps({ open: false });
|
|
68
|
-
}, [location]);
|
|
69
|
-
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
70
|
-
}
|
|
71
|
-
function App(props) {
|
|
72
|
-
const [messageApi, messageContextHolder] = message.useMessage();
|
|
73
|
-
const [notificationApi, notificationContextHolder] = notification.useNotification();
|
|
74
|
-
const { modal, setModalProps } = useModal();
|
|
75
|
-
const { drawer, setDrawerProps } = useDrawer();
|
|
76
|
-
const memoizedContextValue = useMemo(
|
|
77
|
-
() => ({
|
|
78
|
-
message: messageApi,
|
|
79
|
-
notification: notificationApi,
|
|
80
|
-
setModalProps,
|
|
81
|
-
setDrawerProps
|
|
82
|
-
}),
|
|
83
|
-
[messageApi, notificationApi, setModalProps, setDrawerProps]
|
|
84
|
-
);
|
|
55
|
+
function ErrorChildren(props) {
|
|
85
56
|
return /* @__PURE__ */ jsx(
|
|
86
|
-
|
|
57
|
+
Alert,
|
|
87
58
|
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
59
|
+
type: "error",
|
|
60
|
+
message: props.errorMessage,
|
|
61
|
+
description: /* @__PURE__ */ jsx(
|
|
62
|
+
"pre",
|
|
63
|
+
{
|
|
64
|
+
style: {
|
|
65
|
+
fontSize: "0.9em",
|
|
66
|
+
overflowX: "auto"
|
|
67
|
+
},
|
|
68
|
+
children: props.errorDescription
|
|
69
|
+
}
|
|
70
|
+
)
|
|
99
71
|
}
|
|
100
72
|
);
|
|
101
73
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
74
|
+
function ErrorBoundary(props) {
|
|
75
|
+
return /* @__PURE__ */ jsx(ErrorBoundary$1, { errorChildren: /* @__PURE__ */ jsx(ErrorChildren, {}), ...props });
|
|
104
76
|
}
|
|
105
|
-
App.useApp = useApp;
|
|
106
77
|
var isZH = /^zh/i.test(navigator.language);
|
|
107
78
|
var zh = {
|
|
108
79
|
lang: "zh",
|
|
@@ -129,8 +100,7 @@ var en = {
|
|
|
129
100
|
reset: "Reset"
|
|
130
101
|
};
|
|
131
102
|
var common = isZH ? zh : en;
|
|
132
|
-
var
|
|
133
|
-
antd: {},
|
|
103
|
+
var baseTheme = {
|
|
134
104
|
lang: "en",
|
|
135
105
|
common,
|
|
136
106
|
Blank: { text: common.blank },
|
|
@@ -141,37 +111,92 @@ var baseConfig = {
|
|
|
141
111
|
},
|
|
142
112
|
Link: { style: {} }
|
|
143
113
|
};
|
|
144
|
-
var ConfigContext = createContext(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const [values, setValues] = useState(baseConfig);
|
|
114
|
+
var ConfigContext = createContext({
|
|
115
|
+
theme: baseTheme
|
|
116
|
+
});
|
|
117
|
+
function ConfigProvider(props) {
|
|
118
|
+
const [theme, setTheme] = useState();
|
|
150
119
|
useEffect(() => {
|
|
151
|
-
|
|
152
|
-
|
|
120
|
+
var _a;
|
|
121
|
+
if (((_a = props.theme) == null ? void 0 : _a.lang) === "zh") {
|
|
122
|
+
setTheme(
|
|
153
123
|
defaultsDeep(
|
|
154
|
-
|
|
124
|
+
props.theme,
|
|
155
125
|
{
|
|
156
126
|
lang: "zh",
|
|
157
127
|
common: zh,
|
|
158
128
|
Blank: { text: zh.blank },
|
|
159
129
|
Form: { submit: { text: zh.submit } }
|
|
160
130
|
},
|
|
161
|
-
|
|
131
|
+
baseTheme
|
|
162
132
|
)
|
|
163
133
|
);
|
|
164
134
|
} else
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
135
|
+
setTheme(defaultsDeep(props.theme, baseTheme));
|
|
136
|
+
if (props.faasClientOptions)
|
|
137
|
+
FaasReactClient(props.faasClientOptions);
|
|
138
|
+
}, [JSON.stringify(props.theme)]);
|
|
139
|
+
if (!theme)
|
|
140
|
+
return null;
|
|
141
|
+
return /* @__PURE__ */ jsx(ConfigContext.Provider, { value: { theme }, children: props.children });
|
|
168
142
|
}
|
|
169
143
|
function useConfigContext() {
|
|
170
144
|
return useContext(ConfigContext);
|
|
171
145
|
}
|
|
146
|
+
var AppContext = createContext({
|
|
147
|
+
message: {},
|
|
148
|
+
notification: {},
|
|
149
|
+
setModalProps: () => void 0,
|
|
150
|
+
setDrawerProps: () => void 0
|
|
151
|
+
});
|
|
152
|
+
function RoutesApp(props) {
|
|
153
|
+
const location = useLocation();
|
|
154
|
+
const { setDrawerProps, setModalProps } = useApp();
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
console.debug("location", location);
|
|
157
|
+
setDrawerProps({ open: false });
|
|
158
|
+
setModalProps({ open: false });
|
|
159
|
+
}, [location]);
|
|
160
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
161
|
+
}
|
|
162
|
+
function App(props) {
|
|
163
|
+
const [messageApi, messageContextHolder] = message.useMessage();
|
|
164
|
+
const [notificationApi, notificationContextHolder] = notification.useNotification();
|
|
165
|
+
const { modal, setModalProps } = useModal();
|
|
166
|
+
const { drawer, setDrawerProps } = useDrawer();
|
|
167
|
+
const memoizedContextValue = useMemo(
|
|
168
|
+
() => ({
|
|
169
|
+
message: messageApi,
|
|
170
|
+
notification: notificationApi,
|
|
171
|
+
setModalProps,
|
|
172
|
+
setDrawerProps
|
|
173
|
+
}),
|
|
174
|
+
[messageApi, notificationApi, setModalProps, setDrawerProps]
|
|
175
|
+
);
|
|
176
|
+
return /* @__PURE__ */ jsx(
|
|
177
|
+
StyleProvider,
|
|
178
|
+
{
|
|
179
|
+
...Object.assign(props.styleProviderProps || {}, {
|
|
180
|
+
hashPriority: "high",
|
|
181
|
+
transformers: [legacyLogicalPropertiesTransformer]
|
|
182
|
+
}),
|
|
183
|
+
children: /* @__PURE__ */ jsx(ConfigProvider$1, { ...props.configProviderProps, children: /* @__PURE__ */ jsx(AppContext.Provider, { value: memoizedContextValue, children: /* @__PURE__ */ jsx(ConfigProvider, { ...props.faasConfigProviderProps, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxs(BrowserRouter, { ...props.browserRouterProps, children: [
|
|
184
|
+
messageContextHolder,
|
|
185
|
+
notificationContextHolder,
|
|
186
|
+
modal,
|
|
187
|
+
drawer,
|
|
188
|
+
/* @__PURE__ */ jsx(RoutesApp, { children: props.children })
|
|
189
|
+
] }) }) }) }) })
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
function useApp() {
|
|
194
|
+
return useContext(AppContext);
|
|
195
|
+
}
|
|
196
|
+
App.useApp = useApp;
|
|
172
197
|
function Blank(options) {
|
|
173
|
-
const {
|
|
174
|
-
return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) ||
|
|
198
|
+
const { theme } = useConfigContext();
|
|
199
|
+
return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) || theme.Blank.text }) : options.value;
|
|
175
200
|
}
|
|
176
201
|
function transferOptions(options) {
|
|
177
202
|
if (!options)
|
|
@@ -253,7 +278,7 @@ function DescriptionItemContent(props) {
|
|
|
253
278
|
}, [props]);
|
|
254
279
|
if (!computedProps)
|
|
255
280
|
return null;
|
|
256
|
-
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type])
|
|
281
|
+
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type]) {
|
|
257
282
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
258
283
|
return cloneElement(
|
|
259
284
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
@@ -263,15 +288,15 @@ function DescriptionItemContent(props) {
|
|
|
263
288
|
values: computedProps.values
|
|
264
289
|
}
|
|
265
290
|
);
|
|
266
|
-
|
|
291
|
+
if (computedProps.extendTypes[computedProps.item.type].render)
|
|
267
292
|
return /* @__PURE__ */ jsx(Fragment, { children: computedProps.extendTypes[computedProps.item.type].render(
|
|
268
293
|
computedProps.value,
|
|
269
294
|
computedProps.values,
|
|
270
295
|
0,
|
|
271
296
|
"description"
|
|
272
297
|
) });
|
|
273
|
-
|
|
274
|
-
|
|
298
|
+
throw Error(`${computedProps.item.type} requires children or render`);
|
|
299
|
+
}
|
|
275
300
|
if (computedProps.item.descriptionChildren === null)
|
|
276
301
|
return null;
|
|
277
302
|
if (computedProps.item.descriptionChildren)
|
|
@@ -393,28 +418,6 @@ function Description(props) {
|
|
|
393
418
|
}
|
|
394
419
|
);
|
|
395
420
|
}
|
|
396
|
-
function ErrorChildren(props) {
|
|
397
|
-
return /* @__PURE__ */ jsx(
|
|
398
|
-
Alert,
|
|
399
|
-
{
|
|
400
|
-
type: "error",
|
|
401
|
-
message: props.errorMessage,
|
|
402
|
-
description: /* @__PURE__ */ jsx(
|
|
403
|
-
"pre",
|
|
404
|
-
{
|
|
405
|
-
style: {
|
|
406
|
-
fontSize: "0.9em",
|
|
407
|
-
overflowX: "auto"
|
|
408
|
-
},
|
|
409
|
-
children: props.errorDescription
|
|
410
|
-
}
|
|
411
|
-
)
|
|
412
|
-
}
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
function ErrorBoundary(props) {
|
|
416
|
-
return /* @__PURE__ */ jsx(ErrorBoundary$1, { errorChildren: /* @__PURE__ */ jsx(ErrorChildren, {}), ...props });
|
|
417
|
-
}
|
|
418
421
|
function processProps(propsCopy, config) {
|
|
419
422
|
if (!propsCopy.title)
|
|
420
423
|
propsCopy.title = upperFirst(propsCopy.id);
|
|
@@ -469,7 +472,7 @@ function FormItem(props) {
|
|
|
469
472
|
var _a;
|
|
470
473
|
const [computedProps, setComputedProps] = useState();
|
|
471
474
|
const [extendTypes, setExtendTypes] = useState();
|
|
472
|
-
const {
|
|
475
|
+
const { theme } = useConfigContext();
|
|
473
476
|
const [hidden, setHidden] = useState(props.hidden || false);
|
|
474
477
|
useEffect(() => {
|
|
475
478
|
const propsCopy = { ...props };
|
|
@@ -490,7 +493,7 @@ function FormItem(props) {
|
|
|
490
493
|
delete propsCopy.if;
|
|
491
494
|
delete propsCopy.hidden;
|
|
492
495
|
}
|
|
493
|
-
setComputedProps(processProps(propsCopy,
|
|
496
|
+
setComputedProps(processProps(propsCopy, theme.common));
|
|
494
497
|
}, [props]);
|
|
495
498
|
if (!computedProps)
|
|
496
499
|
return null;
|
|
@@ -670,7 +673,7 @@ function FormItem(props) {
|
|
|
670
673
|
danger: true,
|
|
671
674
|
type: "link",
|
|
672
675
|
onClick: () => remove(field.name),
|
|
673
|
-
children:
|
|
676
|
+
children: theme.common.delete
|
|
674
677
|
}
|
|
675
678
|
)
|
|
676
679
|
] }) }),
|
|
@@ -685,7 +688,7 @@ function FormItem(props) {
|
|
|
685
688
|
onClick: () => add(),
|
|
686
689
|
icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
|
|
687
690
|
children: [
|
|
688
|
-
|
|
691
|
+
theme.common.add,
|
|
689
692
|
" ",
|
|
690
693
|
computedProps.label
|
|
691
694
|
]
|
|
@@ -826,7 +829,7 @@ function Form(props) {
|
|
|
826
829
|
)
|
|
827
830
|
),
|
|
828
831
|
computedProps.children,
|
|
829
|
-
computedProps.submit !== false && /* @__PURE__ */ jsx(Button, { htmlType: "submit", type: "primary", loading, children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text }),
|
|
832
|
+
computedProps.submit !== false && /* @__PURE__ */ jsx(Button, { htmlType: "submit", type: "primary", loading, children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.theme.Form.submit.text }),
|
|
830
833
|
computedProps.footer
|
|
831
834
|
] });
|
|
832
835
|
}
|
|
@@ -838,11 +841,11 @@ Form.List = Form$1.List;
|
|
|
838
841
|
Form.ErrorList = Form$1.ErrorList;
|
|
839
842
|
Form.Provider = Form$1.Provider;
|
|
840
843
|
function Link(props) {
|
|
841
|
-
var _a, _b;
|
|
842
|
-
const {
|
|
844
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
845
|
+
const { theme } = useConfigContext();
|
|
843
846
|
const navigate = useNavigate();
|
|
844
847
|
let computedStyle = {
|
|
845
|
-
...
|
|
848
|
+
...theme.Link.style || {},
|
|
846
849
|
cursor: "pointer",
|
|
847
850
|
...props.style
|
|
848
851
|
};
|
|
@@ -860,11 +863,11 @@ function Link(props) {
|
|
|
860
863
|
Button,
|
|
861
864
|
{
|
|
862
865
|
...props.button,
|
|
863
|
-
target: props.target || (
|
|
866
|
+
target: props.target || ((_a = theme.Link) == null ? void 0 : _a.target) || "_blank",
|
|
864
867
|
style: computedStyle,
|
|
865
868
|
href: props.href,
|
|
866
869
|
onClick: props.onClick,
|
|
867
|
-
children: (
|
|
870
|
+
children: (_b = props.text) != null ? _b : props.children
|
|
868
871
|
}
|
|
869
872
|
);
|
|
870
873
|
if (props.children)
|
|
@@ -874,7 +877,7 @@ function Link(props) {
|
|
|
874
877
|
"a",
|
|
875
878
|
{
|
|
876
879
|
href: props.href,
|
|
877
|
-
target: props.target || (
|
|
880
|
+
target: props.target || ((_c = theme.Link) == null ? void 0 : _c.target),
|
|
878
881
|
style: computedStyle,
|
|
879
882
|
onClick: props.onClick,
|
|
880
883
|
children: props.children
|
|
@@ -885,7 +888,7 @@ function Link(props) {
|
|
|
885
888
|
Typography.Link,
|
|
886
889
|
{
|
|
887
890
|
href: props.href,
|
|
888
|
-
target: props.target || (
|
|
891
|
+
target: props.target || ((_d = theme.Link) == null ? void 0 : _d.target) || "_blank",
|
|
889
892
|
style: computedStyle,
|
|
890
893
|
copyable: props.copyable,
|
|
891
894
|
onClick: props.onClick,
|
|
@@ -899,8 +902,11 @@ function Link(props) {
|
|
|
899
902
|
{
|
|
900
903
|
...props.button,
|
|
901
904
|
style: computedStyle,
|
|
902
|
-
onClick: (e) =>
|
|
903
|
-
|
|
905
|
+
onClick: (e) => {
|
|
906
|
+
var _a2;
|
|
907
|
+
return props.onClick ? props.onClick(e) : (props.target || ((_a2 = theme.Link) == null ? void 0 : _a2.target)) === "_blank" ? window.open(props.href) : navigate(props.href);
|
|
908
|
+
},
|
|
909
|
+
children: (_e = props.text) != null ? _e : props.children
|
|
904
910
|
}
|
|
905
911
|
);
|
|
906
912
|
if (props.children)
|
|
@@ -908,7 +914,7 @@ function Link(props) {
|
|
|
908
914
|
Link$1,
|
|
909
915
|
{
|
|
910
916
|
to: props.href,
|
|
911
|
-
target: props.target || (
|
|
917
|
+
target: props.target || ((_f = theme.Link) == null ? void 0 : _f.target),
|
|
912
918
|
style: computedStyle,
|
|
913
919
|
onClick: props.onClick,
|
|
914
920
|
children: props.children
|
|
@@ -918,15 +924,16 @@ function Link(props) {
|
|
|
918
924
|
Typography.Link,
|
|
919
925
|
{
|
|
920
926
|
href: props.href,
|
|
921
|
-
target: props.target || (
|
|
927
|
+
target: props.target || ((_g = theme.Link) == null ? void 0 : _g.target),
|
|
922
928
|
style: computedStyle,
|
|
923
929
|
copyable: props.copyable,
|
|
924
930
|
onClick: (e) => {
|
|
931
|
+
var _a2;
|
|
925
932
|
if (props.onClick) {
|
|
926
933
|
props.onClick(e);
|
|
927
934
|
return;
|
|
928
935
|
}
|
|
929
|
-
if ((props.target || (
|
|
936
|
+
if ((props.target || ((_a2 = theme.Link) == null ? void 0 : _a2.target)) !== "_blank") {
|
|
930
937
|
e.preventDefault();
|
|
931
938
|
navigate(props.href);
|
|
932
939
|
}
|
|
@@ -936,8 +943,8 @@ function Link(props) {
|
|
|
936
943
|
);
|
|
937
944
|
}
|
|
938
945
|
function PageNotFound() {
|
|
939
|
-
const
|
|
940
|
-
return /* @__PURE__ */ jsx(Result, { status: "404", title:
|
|
946
|
+
const { theme } = useConfigContext();
|
|
947
|
+
return /* @__PURE__ */ jsx(Result, { status: "404", title: theme.common.pageNotFound });
|
|
941
948
|
}
|
|
942
949
|
function Routes(props) {
|
|
943
950
|
return /* @__PURE__ */ jsxs(Routes$1, { children: [
|
|
@@ -984,9 +991,9 @@ function processValue(item, value) {
|
|
|
984
991
|
}
|
|
985
992
|
function Table(props) {
|
|
986
993
|
const [columns, setColumns] = useState();
|
|
987
|
-
const {
|
|
994
|
+
const { theme } = useConfigContext();
|
|
988
995
|
const generateFilterDropdown = (item) => {
|
|
989
|
-
if (
|
|
996
|
+
if (item.filterDropdown && item.filterDropdown !== true)
|
|
990
997
|
return;
|
|
991
998
|
if (item.options.length < 11) {
|
|
992
999
|
if (!item.filters)
|
|
@@ -1011,7 +1018,7 @@ function Table(props) {
|
|
|
1011
1018
|
allowClear: true,
|
|
1012
1019
|
showSearch: true,
|
|
1013
1020
|
style: { width: "100%" },
|
|
1014
|
-
placeholder: `${
|
|
1021
|
+
placeholder: `${theme.common.search} ${item.title}`,
|
|
1015
1022
|
value: selectedKeys,
|
|
1016
1023
|
onChange: (v) => {
|
|
1017
1024
|
setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
|
|
@@ -1085,146 +1092,146 @@ function Table(props) {
|
|
|
1085
1092
|
case "string":
|
|
1086
1093
|
if (!item.render)
|
|
1087
1094
|
item.render = (value) => processValue(item, value);
|
|
1088
|
-
if (
|
|
1089
|
-
item.onFilter
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1095
|
+
if (item.filterDropdown !== false) {
|
|
1096
|
+
if (!item.onFilter)
|
|
1097
|
+
item.onFilter = (value, row) => {
|
|
1098
|
+
if (!value || isNil(value))
|
|
1099
|
+
return true;
|
|
1100
|
+
if (isNil(row[item.id]))
|
|
1101
|
+
return false;
|
|
1102
|
+
return row[item.id].trim().toLowerCase().includes(value.trim().toLowerCase());
|
|
1103
|
+
};
|
|
1104
|
+
if (typeof item.filterDropdown === "undefined" && !item.filters && item.optionsType !== "auto")
|
|
1105
|
+
item.filterDropdown = ({
|
|
1106
|
+
setSelectedKeys,
|
|
1107
|
+
confirm,
|
|
1108
|
+
clearFilters
|
|
1109
|
+
}) => /* @__PURE__ */ jsx(
|
|
1110
|
+
Input.Search,
|
|
1111
|
+
{
|
|
1112
|
+
placeholder: `${theme.common.search} ${item.title}`,
|
|
1113
|
+
allowClear: true,
|
|
1114
|
+
onSearch: (v) => {
|
|
1115
|
+
if (v) {
|
|
1116
|
+
setSelectedKeys([v]);
|
|
1117
|
+
} else {
|
|
1118
|
+
setSelectedKeys([]);
|
|
1119
|
+
clearFilters();
|
|
1120
|
+
}
|
|
1121
|
+
confirm();
|
|
1114
1122
|
}
|
|
1115
|
-
confirm();
|
|
1116
1123
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1119
1126
|
break;
|
|
1120
1127
|
case "string[]":
|
|
1121
1128
|
if (!item.render)
|
|
1122
1129
|
item.render = (value) => processValue(item, value);
|
|
1123
|
-
if (
|
|
1124
|
-
item.onFilter
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1130
|
+
if (item.filterDropdown !== false) {
|
|
1131
|
+
if (!item.onFilter)
|
|
1132
|
+
item.onFilter = (value, row) => {
|
|
1133
|
+
if (value === null && (!row[item.id] || !row[item.id].length))
|
|
1134
|
+
return true;
|
|
1135
|
+
if (!row[item.id] || !row[item.id].length || !value)
|
|
1136
|
+
return false;
|
|
1137
|
+
return row[item.id].some(
|
|
1138
|
+
(v) => v.trim().toLowerCase().includes(value.trim().toLowerCase())
|
|
1139
|
+
);
|
|
1140
|
+
};
|
|
1141
|
+
if (typeof item.filterDropdown === "undefined" && !item.filters && item.optionsType !== "auto")
|
|
1142
|
+
item.filterDropdown = ({
|
|
1143
|
+
setSelectedKeys,
|
|
1144
|
+
confirm,
|
|
1145
|
+
clearFilters
|
|
1146
|
+
}) => /* @__PURE__ */ jsx(
|
|
1147
|
+
Input.Search,
|
|
1148
|
+
{
|
|
1149
|
+
placeholder: `${theme.common.search} ${item.title}`,
|
|
1150
|
+
allowClear: true,
|
|
1151
|
+
onSearch: (v) => {
|
|
1152
|
+
if (v) {
|
|
1153
|
+
setSelectedKeys([v]);
|
|
1154
|
+
} else {
|
|
1155
|
+
setSelectedKeys([]);
|
|
1156
|
+
clearFilters();
|
|
1157
|
+
}
|
|
1158
|
+
confirm();
|
|
1151
1159
|
}
|
|
1152
|
-
confirm();
|
|
1153
1160
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1156
1163
|
break;
|
|
1157
1164
|
case "number":
|
|
1158
1165
|
if (!item.render)
|
|
1159
1166
|
item.render = (value) => processValue(item, value);
|
|
1160
|
-
if (
|
|
1167
|
+
if (typeof item.sorter === "undefined")
|
|
1161
1168
|
item.sorter = (a, b) => a[item.id] - b[item.id];
|
|
1162
|
-
if (
|
|
1163
|
-
item.onFilter
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1169
|
+
if (item.filterDropdown !== false) {
|
|
1170
|
+
if (!item.onFilter)
|
|
1171
|
+
item.onFilter = (value, row) => {
|
|
1172
|
+
if (value === null)
|
|
1173
|
+
return true;
|
|
1174
|
+
if (isNil(row[item.id]))
|
|
1175
|
+
return false;
|
|
1176
|
+
return value == row[item.id];
|
|
1177
|
+
};
|
|
1178
|
+
if (typeof item.filterDropdown === "undefined" && !item.filters)
|
|
1179
|
+
item.filterDropdown = ({
|
|
1180
|
+
setSelectedKeys,
|
|
1181
|
+
confirm,
|
|
1182
|
+
clearFilters
|
|
1183
|
+
}) => /* @__PURE__ */ jsx(
|
|
1184
|
+
Input.Search,
|
|
1185
|
+
{
|
|
1186
|
+
placeholder: `${theme.common.search} ${item.title}`,
|
|
1187
|
+
allowClear: true,
|
|
1188
|
+
onSearch: (v) => {
|
|
1189
|
+
if (v) {
|
|
1190
|
+
setSelectedKeys([Number(v)]);
|
|
1191
|
+
} else {
|
|
1192
|
+
setSelectedKeys([]);
|
|
1193
|
+
clearFilters();
|
|
1194
|
+
}
|
|
1195
|
+
confirm();
|
|
1188
1196
|
}
|
|
1189
|
-
confirm();
|
|
1190
1197
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1198
|
+
);
|
|
1199
|
+
}
|
|
1193
1200
|
break;
|
|
1194
1201
|
case "number[]":
|
|
1195
1202
|
if (!item.render)
|
|
1196
1203
|
item.render = (value) => processValue(item, value).join(", ");
|
|
1197
|
-
if (
|
|
1198
|
-
item.onFilter
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1204
|
+
if (item.filterDropdown !== false) {
|
|
1205
|
+
if (!item.onFilter)
|
|
1206
|
+
item.onFilter = (value, row) => {
|
|
1207
|
+
if (value === null && (!row[item.id] || !row[item.id].length))
|
|
1208
|
+
return true;
|
|
1209
|
+
if (!row[item.id] || !row[item.id].length)
|
|
1210
|
+
return false;
|
|
1211
|
+
return row[item.id].includes(Number(value));
|
|
1212
|
+
};
|
|
1213
|
+
if (typeof item.filterDropdown === "undefined" && !item.filters)
|
|
1214
|
+
item.filterDropdown = ({
|
|
1215
|
+
setSelectedKeys,
|
|
1216
|
+
confirm,
|
|
1217
|
+
clearFilters
|
|
1218
|
+
}) => /* @__PURE__ */ jsx(
|
|
1219
|
+
Input.Search,
|
|
1220
|
+
{
|
|
1221
|
+
placeholder: `${theme.common.search} ${item.title}`,
|
|
1222
|
+
allowClear: true,
|
|
1223
|
+
onSearch: (v) => {
|
|
1224
|
+
if (v) {
|
|
1225
|
+
setSelectedKeys([Number(v)]);
|
|
1226
|
+
} else {
|
|
1227
|
+
setSelectedKeys([]);
|
|
1228
|
+
clearFilters();
|
|
1229
|
+
}
|
|
1230
|
+
confirm();
|
|
1223
1231
|
}
|
|
1224
|
-
confirm();
|
|
1225
1232
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1233
|
+
);
|
|
1234
|
+
}
|
|
1228
1235
|
break;
|
|
1229
1236
|
case "boolean":
|
|
1230
1237
|
if (!item.render)
|
|
@@ -1245,68 +1252,70 @@ function Table(props) {
|
|
|
1245
1252
|
}
|
|
1246
1253
|
}
|
|
1247
1254
|
);
|
|
1248
|
-
if (item.filterDropdown !== false)
|
|
1249
|
-
item.filterDropdown
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1255
|
+
if (item.filterDropdown !== false) {
|
|
1256
|
+
if (typeof item.filterDropdown === "undefined")
|
|
1257
|
+
item.filterDropdown = ({
|
|
1258
|
+
setSelectedKeys,
|
|
1259
|
+
selectedKeys,
|
|
1260
|
+
confirm
|
|
1261
|
+
}) => /* @__PURE__ */ jsxs(
|
|
1262
|
+
Radio.Group,
|
|
1263
|
+
{
|
|
1264
|
+
style: { padding: 8 },
|
|
1265
|
+
buttonStyle: "solid",
|
|
1266
|
+
value: JSON.stringify(selectedKeys[0]),
|
|
1267
|
+
onChange: (e) => {
|
|
1268
|
+
const Values = {
|
|
1269
|
+
true: true,
|
|
1270
|
+
false: false,
|
|
1271
|
+
null: null
|
|
1272
|
+
};
|
|
1273
|
+
setSelectedKeys(
|
|
1274
|
+
e.target.value ? [Values[e.target.value]] : []
|
|
1275
|
+
);
|
|
1276
|
+
confirm();
|
|
1277
|
+
},
|
|
1278
|
+
children: [
|
|
1279
|
+
/* @__PURE__ */ jsx(Radio.Button, { children: theme.common.all }),
|
|
1280
|
+
/* @__PURE__ */ jsx(Radio.Button, { value: "true", children: /* @__PURE__ */ jsx(
|
|
1281
|
+
CheckOutlined,
|
|
1282
|
+
{
|
|
1283
|
+
style: {
|
|
1284
|
+
color: "#52c41a",
|
|
1285
|
+
verticalAlign: "middle"
|
|
1286
|
+
}
|
|
1278
1287
|
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1288
|
+
) }),
|
|
1289
|
+
/* @__PURE__ */ jsx(Radio.Button, { value: "false", children: /* @__PURE__ */ jsx(
|
|
1290
|
+
CloseOutlined,
|
|
1291
|
+
{
|
|
1292
|
+
style: {
|
|
1293
|
+
verticalAlign: "middle",
|
|
1294
|
+
color: "#ff4d4f"
|
|
1295
|
+
}
|
|
1287
1296
|
}
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
)
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1297
|
+
) }),
|
|
1298
|
+
/* @__PURE__ */ jsx(Radio.Button, { value: "null", children: theme.common.blank })
|
|
1299
|
+
]
|
|
1300
|
+
}
|
|
1301
|
+
);
|
|
1302
|
+
if (!item.onFilter)
|
|
1303
|
+
item.onFilter = (value, row) => {
|
|
1304
|
+
switch (value) {
|
|
1305
|
+
case true:
|
|
1306
|
+
return !isNil(row[item.id]) && row[item.id] !== false;
|
|
1307
|
+
case false:
|
|
1308
|
+
return !isNil(row[item.id]) && !row[item.id];
|
|
1309
|
+
default:
|
|
1310
|
+
return isNil(row[item.id]);
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1305
1314
|
break;
|
|
1306
1315
|
case "date":
|
|
1307
1316
|
if (!item.render)
|
|
1308
1317
|
item.render = (value) => processValue(item, value);
|
|
1309
|
-
if (
|
|
1318
|
+
if (typeof item.sorter === "undefined")
|
|
1310
1319
|
item.sorter = (a, b, order) => {
|
|
1311
1320
|
if (isNil(a[item.id]))
|
|
1312
1321
|
return order === "ascend" ? 1 : -1;
|
|
@@ -1314,36 +1323,38 @@ function Table(props) {
|
|
|
1314
1323
|
return order === "ascend" ? -1 : 1;
|
|
1315
1324
|
return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
|
|
1316
1325
|
};
|
|
1317
|
-
if (
|
|
1318
|
-
item.filterDropdown
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
(
|
|
1324
|
-
[
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1326
|
+
if (item.filterDropdown !== false) {
|
|
1327
|
+
if (typeof item.filterDropdown === "undefined")
|
|
1328
|
+
item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsx(
|
|
1329
|
+
DatePicker.RangePicker,
|
|
1330
|
+
{
|
|
1331
|
+
onChange: (dates) => {
|
|
1332
|
+
setSelectedKeys(
|
|
1333
|
+
(dates == null ? void 0 : dates[0]) && dates[1] ? [
|
|
1334
|
+
[
|
|
1335
|
+
dates[0].startOf("day").toISOString(),
|
|
1336
|
+
dates[1].endOf("day").toISOString()
|
|
1337
|
+
]
|
|
1338
|
+
] : []
|
|
1339
|
+
);
|
|
1340
|
+
confirm();
|
|
1341
|
+
}
|
|
1331
1342
|
}
|
|
1332
|
-
|
|
1333
|
-
)
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
return
|
|
1340
|
-
|
|
1341
|
-
|
|
1343
|
+
);
|
|
1344
|
+
if (!item.onFilter)
|
|
1345
|
+
item.onFilter = (value, row) => {
|
|
1346
|
+
if (isNil(value[0]))
|
|
1347
|
+
return true;
|
|
1348
|
+
if (isNil(row[item.id]))
|
|
1349
|
+
return false;
|
|
1350
|
+
return dayjs2(row[item.id]) >= dayjs2(value[0]) && dayjs2(row[item.id]) <= dayjs2(value[1]);
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1342
1353
|
break;
|
|
1343
1354
|
case "time":
|
|
1344
1355
|
if (!item.render)
|
|
1345
1356
|
item.render = (value) => processValue(item, value);
|
|
1346
|
-
if (
|
|
1357
|
+
if (typeof item.sorter === "undefined")
|
|
1347
1358
|
item.sorter = (a, b, order) => {
|
|
1348
1359
|
if (isNil(a[item.id]))
|
|
1349
1360
|
return order === "ascend" ? 1 : -1;
|
|
@@ -1351,31 +1362,33 @@ function Table(props) {
|
|
|
1351
1362
|
return order === "ascend" ? -1 : 1;
|
|
1352
1363
|
return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
|
|
1353
1364
|
};
|
|
1354
|
-
if (
|
|
1355
|
-
item.filterDropdown
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
(
|
|
1361
|
-
[
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1365
|
+
if (item.filterDropdown !== false) {
|
|
1366
|
+
if (typeof item.filterDropdown === "undefined")
|
|
1367
|
+
item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsx(
|
|
1368
|
+
DatePicker.RangePicker,
|
|
1369
|
+
{
|
|
1370
|
+
onChange: (dates) => {
|
|
1371
|
+
setSelectedKeys(
|
|
1372
|
+
(dates == null ? void 0 : dates[0]) && dates[1] ? [
|
|
1373
|
+
[
|
|
1374
|
+
dates[0].startOf("day").toISOString(),
|
|
1375
|
+
dates[1].endOf("day").toISOString()
|
|
1376
|
+
]
|
|
1377
|
+
] : []
|
|
1378
|
+
);
|
|
1379
|
+
confirm();
|
|
1380
|
+
}
|
|
1368
1381
|
}
|
|
1369
|
-
|
|
1370
|
-
)
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
return
|
|
1377
|
-
|
|
1378
|
-
|
|
1382
|
+
);
|
|
1383
|
+
if (!item.onFilter)
|
|
1384
|
+
item.onFilter = (value, row) => {
|
|
1385
|
+
if (isNil(value[0]))
|
|
1386
|
+
return true;
|
|
1387
|
+
if (isNil(row[item.id]))
|
|
1388
|
+
return false;
|
|
1389
|
+
return dayjs2(row[item.id]) >= dayjs2(value[0]) && dayjs2(row[item.id]) <= dayjs2(value[1]);
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1379
1392
|
break;
|
|
1380
1393
|
case "object":
|
|
1381
1394
|
if (!item.render)
|
|
@@ -1403,7 +1416,7 @@ function Table(props) {
|
|
|
1403
1416
|
default:
|
|
1404
1417
|
if (!item.render)
|
|
1405
1418
|
item.render = (value) => processValue(item, value);
|
|
1406
|
-
if (!item.onFilter)
|
|
1419
|
+
if (item.filterDropdown !== false && !item.onFilter)
|
|
1407
1420
|
item.onFilter = (value, row) => {
|
|
1408
1421
|
if (value === null && isNil(row[item.id]))
|
|
1409
1422
|
return true;
|
|
@@ -1464,8 +1477,8 @@ function FaasDataTable({
|
|
|
1464
1477
|
const newColumns = [...prev];
|
|
1465
1478
|
for (const column of newColumns) {
|
|
1466
1479
|
if ((_a = data.options) == null ? void 0 : _a[column.id]) {
|
|
1467
|
-
column.options = data.options[column.id];
|
|
1468
|
-
column.filters =
|
|
1480
|
+
column.options = transferOptions(data.options[column.id]);
|
|
1481
|
+
column.filters = column.options.map((v) => ({
|
|
1469
1482
|
text: v.label,
|
|
1470
1483
|
value: v.value
|
|
1471
1484
|
})).concat({
|
|
@@ -1562,10 +1575,10 @@ function Tabs(props) {
|
|
|
1562
1575
|
);
|
|
1563
1576
|
}
|
|
1564
1577
|
function Title(props) {
|
|
1565
|
-
const {
|
|
1578
|
+
const { theme } = useConfigContext();
|
|
1566
1579
|
useEffect(() => {
|
|
1567
1580
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1568
|
-
document.title = title.concat(props.suffix ||
|
|
1581
|
+
document.title = title.concat(props.suffix || theme.Title.suffix).filter((t) => !!t).join(props.separator || theme.Title.separator);
|
|
1569
1582
|
}, [props]);
|
|
1570
1583
|
if (props.h1) {
|
|
1571
1584
|
if (typeof props.h1 === "boolean")
|
|
@@ -1579,4 +1592,4 @@ function Title(props) {
|
|
|
1579
1592
|
return null;
|
|
1580
1593
|
}
|
|
1581
1594
|
|
|
1582
|
-
export { App, Blank, ConfigContext,
|
|
1595
|
+
export { App, Blank, ConfigContext, ConfigProvider, Description, ErrorBoundary, FaasDataWrapper, Form, FormItem, Link, Loading, PageNotFound, Routes, Table, Tabs, Title, transferOptions, transferValue, useApp, useConfigContext, useDrawer, useModal };
|