@faasjs/ant-design 8.0.0-beta.13 → 8.0.0-beta.15
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 +0 -35
- package/dist/index.cjs +72 -66
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +61 -50
- package/package.json +3 -6
package/README.md
CHANGED
|
@@ -1,40 +1,5 @@
|
|
|
1
1
|
# @faasjs/ant-design
|
|
2
2
|
|
|
3
|
-
UI components based on [FaasJS](https://faasjs.com), [Ant Design](https://ant.design) and [React Router](https://reactrouter.com).
|
|
4
|
-
|
|
5
|
-
[](https://github.com/faasjs/faasjs/blob/main/packages/ant-design/LICENSE)
|
|
6
|
-
[](https://www.npmjs.com/package/@faasjs/ant-design)
|
|
7
|
-
|
|
8
|
-
## Features
|
|
9
|
-
|
|
10
|
-
- [App](https://faasjs.com/doc/ant-design/functions/App.html) component with Ant Design & FaasJS.
|
|
11
|
-
- [UnionFaasItemElement](https://faasjs.com/doc/ant-design/type-aliases/UnionFaasItemElement.html) and [UnionFaasItemRender](https://faasjs.com/doc/ant-design/type-aliases/UnionFaasItemRender.html) for custom union rendering.
|
|
12
|
-
|
|
13
|
-
## Install
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
npm install @faasjs/ant-design
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
In `@faasjs/ant-design`, we use `FaasItemProps` to provide data structures for components.
|
|
22
|
-
|
|
23
|
-
```ts
|
|
24
|
-
type FaasItemType =
|
|
25
|
-
'string' | 'string[]' |
|
|
26
|
-
'number' | 'number[]' |
|
|
27
|
-
'boolean' |
|
|
28
|
-
'date' | 'time' |
|
|
29
|
-
'object' | 'object[]'
|
|
30
|
-
|
|
31
|
-
type FaasItemProps = {
|
|
32
|
-
type: FaasItemTypes
|
|
33
|
-
id: string
|
|
34
|
-
title?: string
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
3
|
## Functions
|
|
39
4
|
|
|
40
5
|
- [App](functions/App.md)
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -7,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
20
16
|
}
|
|
21
17
|
return to;
|
|
22
18
|
};
|
|
@@ -24,7 +20,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
20
|
value: mod,
|
|
25
21
|
enumerable: true
|
|
26
22
|
}) : target, mod));
|
|
27
|
-
|
|
28
23
|
//#endregion
|
|
29
24
|
let _faasjs_react = require("@faasjs/react");
|
|
30
25
|
let antd = require("antd");
|
|
@@ -35,7 +30,6 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
35
30
|
let _ant_design_icons = require("@ant-design/icons");
|
|
36
31
|
let dayjs = require("dayjs");
|
|
37
32
|
dayjs = __toESM(dayjs);
|
|
38
|
-
|
|
39
33
|
//#region src/Loading.tsx
|
|
40
34
|
/**
|
|
41
35
|
* Loading component based on Spin
|
|
@@ -53,7 +47,7 @@ function Loading(props) {
|
|
|
53
47
|
if (props.loading === false) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: props.children });
|
|
54
48
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
55
49
|
style: {
|
|
56
|
-
...props.style
|
|
50
|
+
...props.style,
|
|
57
51
|
...!props.size || props.size === "large" ? {
|
|
58
52
|
margin: "20vh auto",
|
|
59
53
|
textAlign: "center"
|
|
@@ -62,7 +56,6 @@ function Loading(props) {
|
|
|
62
56
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Spin, { size: props.size || "large" })
|
|
63
57
|
});
|
|
64
58
|
}
|
|
65
|
-
|
|
66
59
|
//#endregion
|
|
67
60
|
//#region src/FaasDataWrapper.tsx
|
|
68
61
|
/**
|
|
@@ -101,7 +94,6 @@ function withFaasData(Component, faasProps) {
|
|
|
101
94
|
...faasProps
|
|
102
95
|
});
|
|
103
96
|
}
|
|
104
|
-
|
|
105
97
|
//#endregion
|
|
106
98
|
//#region src/Config.tsx
|
|
107
99
|
const zh = {
|
|
@@ -173,7 +165,6 @@ function ConfigProvider(props) {
|
|
|
173
165
|
function useConfigContext() {
|
|
174
166
|
return (0, react.useContext)(ConfigContext);
|
|
175
167
|
}
|
|
176
|
-
|
|
177
168
|
//#endregion
|
|
178
169
|
//#region src/Drawer.tsx
|
|
179
170
|
/**
|
|
@@ -216,7 +207,6 @@ function useDrawer(init) {
|
|
|
216
207
|
setDrawerProps
|
|
217
208
|
};
|
|
218
209
|
}
|
|
219
|
-
|
|
220
210
|
//#endregion
|
|
221
211
|
//#region src/ErrorBoundary.tsx
|
|
222
212
|
function ErrorChildren(props) {
|
|
@@ -241,7 +231,6 @@ function ErrorBoundary(props) {
|
|
|
241
231
|
...props
|
|
242
232
|
});
|
|
243
233
|
}
|
|
244
|
-
|
|
245
234
|
//#endregion
|
|
246
235
|
//#region src/Modal.tsx
|
|
247
236
|
/**
|
|
@@ -282,7 +271,6 @@ function useModal(init) {
|
|
|
282
271
|
setModalProps
|
|
283
272
|
};
|
|
284
273
|
}
|
|
285
|
-
|
|
286
274
|
//#endregion
|
|
287
275
|
//#region src/App.tsx
|
|
288
276
|
const AppContext = (0, _faasjs_react.createSplittingContext)([
|
|
@@ -388,7 +376,6 @@ function App(props) {
|
|
|
388
376
|
*/
|
|
389
377
|
const useApp = AppContext.use;
|
|
390
378
|
App.useApp = useApp;
|
|
391
|
-
|
|
392
379
|
//#endregion
|
|
393
380
|
//#region src/Blank.tsx
|
|
394
381
|
/**
|
|
@@ -410,7 +397,6 @@ function Blank(options) {
|
|
|
410
397
|
children: options?.text || theme.Blank.text
|
|
411
398
|
}) : options.value;
|
|
412
399
|
}
|
|
413
|
-
|
|
414
400
|
//#endregion
|
|
415
401
|
//#region src/data.ts
|
|
416
402
|
/**
|
|
@@ -480,12 +466,11 @@ function transferValue(type, value) {
|
|
|
480
466
|
function cloneUnionFaasItemElement(element, props) {
|
|
481
467
|
return (0, react.cloneElement)((0, react.isValidElement)(element) ? element : (0, react.createElement)(element), props);
|
|
482
468
|
}
|
|
483
|
-
|
|
484
469
|
//#endregion
|
|
485
470
|
//#region src/Description.tsx
|
|
486
471
|
function DescriptionItemContent(props) {
|
|
487
472
|
const [computedProps, setComputedProps] = (0, react.useState)();
|
|
488
|
-
(0,
|
|
473
|
+
(0, _faasjs_react.useEqualEffect)(() => {
|
|
489
474
|
const propsCopy = { ...props };
|
|
490
475
|
propsCopy.item.title = propsCopy.item.title ?? idToTitle(propsCopy.item.id);
|
|
491
476
|
if (!propsCopy.item.type) propsCopy.item.type = "string";
|
|
@@ -607,7 +592,6 @@ function Description({ faasData, dataSource, renderTitle, extendTypes, ...props
|
|
|
607
592
|
});
|
|
608
593
|
}
|
|
609
594
|
Description.displayName = "Description";
|
|
610
|
-
|
|
611
595
|
//#endregion
|
|
612
596
|
//#region src/FormItem.tsx
|
|
613
597
|
function isOptionsProps(item) {
|
|
@@ -667,7 +651,7 @@ function FormItem(props) {
|
|
|
667
651
|
const [extendTypes, setExtendTypes] = (0, react.useState)();
|
|
668
652
|
const { theme } = useConfigContext();
|
|
669
653
|
const [hidden, setHidden] = (0, react.useState)(props.hidden || false);
|
|
670
|
-
(0,
|
|
654
|
+
(0, _faasjs_react.useEqualEffect)(() => {
|
|
671
655
|
const { extendTypes, ...propsCopy } = { ...props };
|
|
672
656
|
if (extendTypes) setExtendTypes(extendTypes);
|
|
673
657
|
if (propsCopy.if) {
|
|
@@ -684,7 +668,11 @@ function FormItem(props) {
|
|
|
684
668
|
delete propsCopy.hidden;
|
|
685
669
|
}
|
|
686
670
|
setComputedProps(processProps(propsCopy, theme.common));
|
|
687
|
-
}, [
|
|
671
|
+
}, [
|
|
672
|
+
hidden,
|
|
673
|
+
props,
|
|
674
|
+
theme.common
|
|
675
|
+
]);
|
|
688
676
|
if (!computedProps) return null;
|
|
689
677
|
const itemType = computedProps.type ?? "string";
|
|
690
678
|
if (hidden) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Form.Item, {
|
|
@@ -898,7 +886,6 @@ function FormItem(props) {
|
|
|
898
886
|
}
|
|
899
887
|
}
|
|
900
888
|
FormItem.useStatus = antd.Form.Item.useStatus;
|
|
901
|
-
|
|
902
889
|
//#endregion
|
|
903
890
|
//#region src/Form.tsx
|
|
904
891
|
function isFormItemProps(item) {
|
|
@@ -917,19 +904,21 @@ function Form(props) {
|
|
|
917
904
|
const [extendTypes, setExtendTypes] = (0, react.useState)();
|
|
918
905
|
const [form] = antd.Form.useForm(props.form);
|
|
919
906
|
const [initialValues, setInitialValues] = (0, react.useState)(props.initialValues || Object.create(null));
|
|
920
|
-
(0,
|
|
907
|
+
(0, _faasjs_react.useEqualEffect)(() => {
|
|
921
908
|
const { submit, ...propsCopy } = {
|
|
922
909
|
...props,
|
|
923
910
|
form
|
|
924
911
|
};
|
|
912
|
+
let nextInitialValues = propsCopy.initialValues;
|
|
925
913
|
if (typeof submit !== "undefined") setSubmit(submit);
|
|
926
914
|
if (propsCopy.initialValues && propsCopy.items?.length) {
|
|
927
915
|
for (const key in propsCopy.initialValues) propsCopy.initialValues[key] = transferValue(propsCopy.items.find((item) => isFormItemProps(item) && item.id === key)?.type, propsCopy.initialValues[key]);
|
|
916
|
+
nextInitialValues = propsCopy.initialValues;
|
|
928
917
|
setInitialValues(propsCopy.initialValues);
|
|
929
918
|
delete propsCopy.initialValues;
|
|
930
919
|
}
|
|
931
920
|
if (propsCopy.items?.length) {
|
|
932
|
-
for (const item of propsCopy.items) if (isFormItemProps(item) && item.if) item.hidden = !item.if(
|
|
921
|
+
for (const item of propsCopy.items) if (isFormItemProps(item) && item.if) item.hidden = !item.if(nextInitialValues || Object.create(null));
|
|
933
922
|
}
|
|
934
923
|
const submitTo = typeof submit === "object" ? submit.to : void 0;
|
|
935
924
|
if (propsCopy.onFinish) {
|
|
@@ -968,7 +957,7 @@ function Form(props) {
|
|
|
968
957
|
delete propsCopy.extendTypes;
|
|
969
958
|
}
|
|
970
959
|
setComputedProps(propsCopy);
|
|
971
|
-
}, [props]);
|
|
960
|
+
}, [form, props]);
|
|
972
961
|
const onValuesChange = (0, _faasjs_react.useEqualCallback)((changedValues, allValues) => {
|
|
973
962
|
console.debug("Form:onValuesChange", changedValues, allValues);
|
|
974
963
|
if (props.onValuesChange) props.onValuesChange(changedValues, allValues);
|
|
@@ -978,12 +967,12 @@ function Form(props) {
|
|
|
978
967
|
if (item?.onValueChange) item.onValueChange(changedValues[key], allValues, form);
|
|
979
968
|
}
|
|
980
969
|
}, [computedProps]);
|
|
981
|
-
(0,
|
|
970
|
+
(0, _faasjs_react.useEqualEffect)(() => {
|
|
982
971
|
if (!initialValues) return;
|
|
983
972
|
console.debug("Form:initialValues", initialValues);
|
|
984
973
|
form.setFieldsValue(initialValues);
|
|
985
974
|
setInitialValues(null);
|
|
986
|
-
}, [
|
|
975
|
+
}, [form, initialValues]);
|
|
987
976
|
if (!computedProps) return null;
|
|
988
977
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Form, {
|
|
989
978
|
...computedProps,
|
|
@@ -1015,7 +1004,6 @@ Form.Item = FormItem;
|
|
|
1015
1004
|
Form.List = antd.Form.List;
|
|
1016
1005
|
Form.ErrorList = antd.Form.ErrorList;
|
|
1017
1006
|
Form.Provider = antd.Form.Provider;
|
|
1018
|
-
|
|
1019
1007
|
//#endregion
|
|
1020
1008
|
//#region src/Link.tsx
|
|
1021
1009
|
/**
|
|
@@ -1035,7 +1023,7 @@ function Link(props) {
|
|
|
1035
1023
|
const navigate = (0, react_router_dom.useNavigate)();
|
|
1036
1024
|
const target = props.target || theme.Link?.target || (props.href.startsWith("http") ? "_blank" : void 0);
|
|
1037
1025
|
let computedStyle = {
|
|
1038
|
-
...theme.Link.style
|
|
1026
|
+
...theme.Link.style,
|
|
1039
1027
|
cursor: "pointer",
|
|
1040
1028
|
...props.style
|
|
1041
1029
|
};
|
|
@@ -1049,8 +1037,16 @@ function Link(props) {
|
|
|
1049
1037
|
...buttonProps,
|
|
1050
1038
|
style: computedStyle,
|
|
1051
1039
|
onClick: (e) => {
|
|
1052
|
-
props.onClick ? props.onClick(e) : target === "_blank" ? window.open(props.href) : navigate(props.href);
|
|
1053
1040
|
e.preventDefault();
|
|
1041
|
+
if (props.onClick) {
|
|
1042
|
+
props.onClick(e);
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
if (target === "_blank") {
|
|
1046
|
+
window.open(props.href);
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
navigate(props.href);
|
|
1054
1050
|
},
|
|
1055
1051
|
children: props.children ?? props.text
|
|
1056
1052
|
});
|
|
@@ -1074,7 +1070,6 @@ function Link(props) {
|
|
|
1074
1070
|
children: props.children ?? props.text
|
|
1075
1071
|
});
|
|
1076
1072
|
}
|
|
1077
|
-
|
|
1078
1073
|
//#endregion
|
|
1079
1074
|
//#region src/Routers.tsx
|
|
1080
1075
|
function PageNotFound() {
|
|
@@ -1122,7 +1117,6 @@ function Routes(props) {
|
|
|
1122
1117
|
element: props.notFound || /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageNotFound, {})
|
|
1123
1118
|
}, "*")] });
|
|
1124
1119
|
}
|
|
1125
|
-
|
|
1126
1120
|
//#endregion
|
|
1127
1121
|
//#region src/Table.tsx
|
|
1128
1122
|
function processValue(item, value) {
|
|
@@ -1152,7 +1146,8 @@ function processValue(item, value) {
|
|
|
1152
1146
|
function Table(props) {
|
|
1153
1147
|
const [columns, setColumns] = (0, react.useState)();
|
|
1154
1148
|
const { theme } = useConfigContext();
|
|
1155
|
-
const
|
|
1149
|
+
const { all, blank, search } = theme.common;
|
|
1150
|
+
const generateFilterDropdown = (0, react.useCallback)((item) => {
|
|
1156
1151
|
if (item.filterDropdown && item.filterDropdown !== true) return;
|
|
1157
1152
|
if (!item.options?.length) return;
|
|
1158
1153
|
if (item.options.length < 11) {
|
|
@@ -1173,7 +1168,7 @@ function Table(props) {
|
|
|
1173
1168
|
allowClear: true,
|
|
1174
1169
|
showSearch: true,
|
|
1175
1170
|
style: { width: "100%" },
|
|
1176
|
-
placeholder: `${
|
|
1171
|
+
placeholder: `${search} ${item.title}`,
|
|
1177
1172
|
value: selectedKeys,
|
|
1178
1173
|
onChange: (v) => {
|
|
1179
1174
|
setSelectedKeys(v?.length ? v : []);
|
|
@@ -1181,18 +1176,19 @@ function Table(props) {
|
|
|
1181
1176
|
},
|
|
1182
1177
|
mode: "multiple",
|
|
1183
1178
|
filterOption: (input, option) => {
|
|
1184
|
-
if (!input || !option
|
|
1179
|
+
if (!input || !option) return true;
|
|
1180
|
+
if (typeof option.label !== "string") return option.value === input;
|
|
1185
1181
|
input = input.trim();
|
|
1186
|
-
return option.value === input || option.label.
|
|
1182
|
+
return option.value === input || option.label.toLowerCase().includes(input.toLowerCase());
|
|
1187
1183
|
}
|
|
1188
1184
|
})
|
|
1189
1185
|
});
|
|
1190
1186
|
return item;
|
|
1191
|
-
};
|
|
1192
|
-
(0,
|
|
1187
|
+
}, [search]);
|
|
1188
|
+
(0, _faasjs_react.useEqualEffect)(() => {
|
|
1193
1189
|
const items = (0, lodash_es.cloneDeep)(props.items).filter((item) => !(item.tableChildren === null || item.children === null || item.tableRender === null || item.render === null));
|
|
1194
1190
|
const createTextSearchFilterDropdown = (item, transformValue) => ({ setSelectedKeys, confirm, clearFilters }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Input.Search, {
|
|
1195
|
-
placeholder: `${
|
|
1191
|
+
placeholder: `${search} ${item.title}`,
|
|
1196
1192
|
allowClear: true,
|
|
1197
1193
|
onSearch: (v) => {
|
|
1198
1194
|
if (v) setSelectedKeys(transformValue ? [transformValue(v)] : [v]);
|
|
@@ -1290,7 +1286,7 @@ function Table(props) {
|
|
|
1290
1286
|
}
|
|
1291
1287
|
break;
|
|
1292
1288
|
case "number[]":
|
|
1293
|
-
if (!item.render) item.render = (value) => processValue(item, value)
|
|
1289
|
+
if (!item.render) item.render = (value) => processValue(item, value);
|
|
1294
1290
|
if (item.filterDropdown !== false) {
|
|
1295
1291
|
if (!item.onFilter && !props.faasData) item.onFilter = (value, row) => {
|
|
1296
1292
|
if (value === null && (!row[item.id] || !row[item.id].length)) return true;
|
|
@@ -1309,7 +1305,7 @@ function Table(props) {
|
|
|
1309
1305
|
color: "#ff4d4f"
|
|
1310
1306
|
} });
|
|
1311
1307
|
if (item.filterDropdown !== false) {
|
|
1312
|
-
if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Radio.Group, {
|
|
1308
|
+
if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm: confirmFilter }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Radio.Group, {
|
|
1313
1309
|
style: { padding: 8 },
|
|
1314
1310
|
buttonStyle: "solid",
|
|
1315
1311
|
value: JSON.stringify(selectedKeys[0]),
|
|
@@ -1319,10 +1315,10 @@ function Table(props) {
|
|
|
1319
1315
|
false: false,
|
|
1320
1316
|
null: null
|
|
1321
1317
|
}[e.target.value]] : []);
|
|
1322
|
-
|
|
1318
|
+
confirmFilter();
|
|
1323
1319
|
},
|
|
1324
1320
|
children: [
|
|
1325
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Radio.Button, { children:
|
|
1321
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Radio.Button, { children: all }),
|
|
1326
1322
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Radio.Button, {
|
|
1327
1323
|
value: "true",
|
|
1328
1324
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ant_design_icons.CheckOutlined, { style: {
|
|
@@ -1339,7 +1335,7 @@ function Table(props) {
|
|
|
1339
1335
|
}),
|
|
1340
1336
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Radio.Button, {
|
|
1341
1337
|
value: "null",
|
|
1342
|
-
children:
|
|
1338
|
+
children: blank
|
|
1343
1339
|
})
|
|
1344
1340
|
]
|
|
1345
1341
|
});
|
|
@@ -1363,7 +1359,9 @@ function Table(props) {
|
|
|
1363
1359
|
};
|
|
1364
1360
|
if (item.filterDropdown !== false) {
|
|
1365
1361
|
if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.DatePicker.RangePicker, { onChange: (dates) => {
|
|
1366
|
-
|
|
1362
|
+
const start = dates?.[0];
|
|
1363
|
+
const end = dates?.[1];
|
|
1364
|
+
setSelectedKeys(start && end ? [[start.startOf("day").toISOString(), end.endOf("day").toISOString()]] : []);
|
|
1367
1365
|
confirm();
|
|
1368
1366
|
} });
|
|
1369
1367
|
if (!item.onFilter && !props.faasData) item.onFilter = (value, row) => {
|
|
@@ -1397,8 +1395,16 @@ function Table(props) {
|
|
|
1397
1395
|
}
|
|
1398
1396
|
}
|
|
1399
1397
|
setColumns(items);
|
|
1400
|
-
}, [
|
|
1401
|
-
|
|
1398
|
+
}, [
|
|
1399
|
+
all,
|
|
1400
|
+
blank,
|
|
1401
|
+
generateFilterDropdown,
|
|
1402
|
+
props.extendTypes,
|
|
1403
|
+
props.faasData,
|
|
1404
|
+
props.items,
|
|
1405
|
+
search
|
|
1406
|
+
]);
|
|
1407
|
+
(0, _faasjs_react.useEqualEffect)(() => {
|
|
1402
1408
|
if (!props.dataSource || !columns) return;
|
|
1403
1409
|
for (const column of columns) if (column.optionsType === "auto" && !column.options && !column.filters) {
|
|
1404
1410
|
const options = (0, lodash_es.uniqBy)(props.dataSource, column.id).map((v) => ({
|
|
@@ -1414,7 +1420,11 @@ function Table(props) {
|
|
|
1414
1420
|
return newColumns;
|
|
1415
1421
|
});
|
|
1416
1422
|
}
|
|
1417
|
-
}, [
|
|
1423
|
+
}, [
|
|
1424
|
+
props.dataSource,
|
|
1425
|
+
columns,
|
|
1426
|
+
generateFilterDropdown
|
|
1427
|
+
]);
|
|
1418
1428
|
if (!columns) return null;
|
|
1419
1429
|
if (props.dataSource) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Table, {
|
|
1420
1430
|
...props,
|
|
@@ -1436,7 +1446,7 @@ function Table(props) {
|
|
|
1436
1446
|
}
|
|
1437
1447
|
function FaasDataTable({ props, columns, data, params, reload, loading }) {
|
|
1438
1448
|
const [currentColumns, setCurrentColumns] = (0, react.useState)(columns);
|
|
1439
|
-
(0,
|
|
1449
|
+
(0, _faasjs_react.useEqualEffect)(() => {
|
|
1440
1450
|
if (!data || Array.isArray(data)) return;
|
|
1441
1451
|
setCurrentColumns((prev) => {
|
|
1442
1452
|
const newColumns = [...prev];
|
|
@@ -1514,7 +1524,6 @@ function FaasDataTable({ props, columns, data, params, reload, loading }) {
|
|
|
1514
1524
|
}
|
|
1515
1525
|
});
|
|
1516
1526
|
}
|
|
1517
|
-
|
|
1518
1527
|
//#endregion
|
|
1519
1528
|
//#region src/Tabs.tsx
|
|
1520
1529
|
/**
|
|
@@ -1552,7 +1561,6 @@ function Tabs(props) {
|
|
|
1552
1561
|
}))
|
|
1553
1562
|
});
|
|
1554
1563
|
}
|
|
1555
|
-
|
|
1556
1564
|
//#endregion
|
|
1557
1565
|
//#region src/Title.tsx
|
|
1558
1566
|
/**
|
|
@@ -1575,7 +1583,7 @@ function Tabs(props) {
|
|
|
1575
1583
|
*/
|
|
1576
1584
|
function Title(props) {
|
|
1577
1585
|
const { theme } = useConfigContext();
|
|
1578
|
-
(0,
|
|
1586
|
+
(0, _faasjs_react.useEqualEffect)(() => {
|
|
1579
1587
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1580
1588
|
document.title = title.concat(props.suffix || theme.Title.suffix).filter((t) => !!t).join(props.separator || theme.Title.separator);
|
|
1581
1589
|
}, [props, theme.Title]);
|
|
@@ -1591,7 +1599,6 @@ function Title(props) {
|
|
|
1591
1599
|
if (props.children) return (0, react.cloneElement)(props.children, { title: props.title });
|
|
1592
1600
|
return null;
|
|
1593
1601
|
}
|
|
1594
|
-
|
|
1595
1602
|
//#endregion
|
|
1596
1603
|
//#region src/useThemeToken.ts
|
|
1597
1604
|
/**
|
|
@@ -1605,7 +1612,6 @@ function Title(props) {
|
|
|
1605
1612
|
function useThemeToken() {
|
|
1606
1613
|
return antd.theme.useToken().token;
|
|
1607
1614
|
}
|
|
1608
|
-
|
|
1609
1615
|
//#endregion
|
|
1610
1616
|
exports.App = App;
|
|
1611
1617
|
exports.Blank = Blank;
|
|
@@ -1629,11 +1635,11 @@ exports.Title = Title;
|
|
|
1629
1635
|
exports.cloneUnionFaasItemElement = cloneUnionFaasItemElement;
|
|
1630
1636
|
exports.faas = _faasjs_react.faas;
|
|
1631
1637
|
exports.idToTitle = idToTitle;
|
|
1632
|
-
Object.defineProperty(exports,
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1638
|
+
Object.defineProperty(exports, "lazy", {
|
|
1639
|
+
enumerable: true,
|
|
1640
|
+
get: function() {
|
|
1641
|
+
return react.lazy;
|
|
1642
|
+
}
|
|
1637
1643
|
});
|
|
1638
1644
|
exports.transferOptions = transferOptions;
|
|
1639
1645
|
exports.transferValue = transferValue;
|
|
@@ -1643,4 +1649,4 @@ exports.useDrawer = useDrawer;
|
|
|
1643
1649
|
exports.useFaas = _faasjs_react.useFaas;
|
|
1644
1650
|
exports.useModal = useModal;
|
|
1645
1651
|
exports.useThemeToken = useThemeToken;
|
|
1646
|
-
exports.withFaasData = withFaasData;
|
|
1652
|
+
exports.withFaasData = withFaasData;
|
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ type FaasActionPaths = Exclude<Extract<keyof FaasActions, string>, 'faasjsAction
|
|
|
53
53
|
/**
|
|
54
54
|
* Union type accepted by action helpers.
|
|
55
55
|
*/
|
|
56
|
-
type FaasActionUnionType =
|
|
56
|
+
type FaasActionUnionType = Record<string, any> | string;
|
|
57
57
|
/**
|
|
58
58
|
* Infer the action path type.
|
|
59
59
|
*
|
|
@@ -319,7 +319,7 @@ interface useAppProps {
|
|
|
319
319
|
*/
|
|
320
320
|
declare function App(props: AppProps): react_jsx_runtime0.JSX.Element;
|
|
321
321
|
declare namespace App {
|
|
322
|
-
var useApp:
|
|
322
|
+
var useApp: any;
|
|
323
323
|
}
|
|
324
324
|
/**
|
|
325
325
|
* Get app context.
|
|
@@ -330,7 +330,7 @@ declare namespace App {
|
|
|
330
330
|
* const { message, notification, setModalProps, setDrawerProps } = useApp()
|
|
331
331
|
* ```
|
|
332
332
|
*/
|
|
333
|
-
declare const useApp:
|
|
333
|
+
declare const useApp: any;
|
|
334
334
|
//#endregion
|
|
335
335
|
//#region src/Blank.d.ts
|
|
336
336
|
interface BlankProps {
|
|
@@ -747,7 +747,7 @@ interface DescriptionItemProps<T = any> extends FaasItemProps {
|
|
|
747
747
|
object?: DescriptionItemProps<T>[];
|
|
748
748
|
}
|
|
749
749
|
interface DescriptionProps<T = any, ExtendItemProps = any> extends Omit<DescriptionsProps, 'items'> {
|
|
750
|
-
renderTitle?(values: T): ReactNode;
|
|
750
|
+
renderTitle?(this: void, values: T): ReactNode;
|
|
751
751
|
items: (DescriptionItemProps | ExtendItemProps)[];
|
|
752
752
|
extendTypes?: {
|
|
753
753
|
[key: string]: ExtendDescriptionTypeProps;
|
|
@@ -825,7 +825,7 @@ type FormSubmitProps = {
|
|
|
825
825
|
* ```
|
|
826
826
|
*/
|
|
827
827
|
to?: {
|
|
828
|
-
action: FaasAction
|
|
828
|
+
action: FaasAction; /** params will overwrite form values before submit */
|
|
829
829
|
params?: Record<string, any>;
|
|
830
830
|
then?: (result: any) => void;
|
|
831
831
|
catch?: (error: any) => void;
|
package/dist/index.mjs
CHANGED
|
@@ -2,11 +2,10 @@ import { ErrorBoundary as ErrorBoundary$1, FaasDataWrapper as FaasDataWrapper$1,
|
|
|
2
2
|
import { Alert, Button, Col, ConfigProvider as ConfigProvider$1, DatePicker, Descriptions, Drawer, Form as Form$1, Input, InputNumber, Modal, Radio, Result, Row, Select, Skeleton, Space, Spin, Switch, Table as Table$1, Tabs as Tabs$1, Typography, message, notification, theme } from "antd";
|
|
3
3
|
import { BrowserRouter, Route, Routes as Routes$1, useLocation, useNavigate } from "react-router-dom";
|
|
4
4
|
import { cloneDeep, defaultsDeep, isNil, uniqBy } from "lodash-es";
|
|
5
|
-
import { Suspense, cloneElement, createContext, createElement, isValidElement, lazy,
|
|
5
|
+
import { Suspense, cloneElement, createContext, createElement, isValidElement, lazy, useCallback, useContext, useState } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { CheckOutlined, CloseOutlined, MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
8
8
|
import dayjs from "dayjs";
|
|
9
|
-
|
|
10
9
|
//#region src/Loading.tsx
|
|
11
10
|
/**
|
|
12
11
|
* Loading component based on Spin
|
|
@@ -24,7 +23,7 @@ function Loading(props) {
|
|
|
24
23
|
if (props.loading === false) return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
25
24
|
return /* @__PURE__ */ jsx("div", {
|
|
26
25
|
style: {
|
|
27
|
-
...props.style
|
|
26
|
+
...props.style,
|
|
28
27
|
...!props.size || props.size === "large" ? {
|
|
29
28
|
margin: "20vh auto",
|
|
30
29
|
textAlign: "center"
|
|
@@ -33,7 +32,6 @@ function Loading(props) {
|
|
|
33
32
|
children: /* @__PURE__ */ jsx(Spin, { size: props.size || "large" })
|
|
34
33
|
});
|
|
35
34
|
}
|
|
36
|
-
|
|
37
35
|
//#endregion
|
|
38
36
|
//#region src/FaasDataWrapper.tsx
|
|
39
37
|
/**
|
|
@@ -72,7 +70,6 @@ function withFaasData(Component, faasProps) {
|
|
|
72
70
|
...faasProps
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
|
-
|
|
76
73
|
//#endregion
|
|
77
74
|
//#region src/Config.tsx
|
|
78
75
|
const zh = {
|
|
@@ -144,7 +141,6 @@ function ConfigProvider(props) {
|
|
|
144
141
|
function useConfigContext() {
|
|
145
142
|
return useContext(ConfigContext);
|
|
146
143
|
}
|
|
147
|
-
|
|
148
144
|
//#endregion
|
|
149
145
|
//#region src/Drawer.tsx
|
|
150
146
|
/**
|
|
@@ -187,7 +183,6 @@ function useDrawer(init) {
|
|
|
187
183
|
setDrawerProps
|
|
188
184
|
};
|
|
189
185
|
}
|
|
190
|
-
|
|
191
186
|
//#endregion
|
|
192
187
|
//#region src/ErrorBoundary.tsx
|
|
193
188
|
function ErrorChildren(props) {
|
|
@@ -212,7 +207,6 @@ function ErrorBoundary(props) {
|
|
|
212
207
|
...props
|
|
213
208
|
});
|
|
214
209
|
}
|
|
215
|
-
|
|
216
210
|
//#endregion
|
|
217
211
|
//#region src/Modal.tsx
|
|
218
212
|
/**
|
|
@@ -253,7 +247,6 @@ function useModal(init) {
|
|
|
253
247
|
setModalProps
|
|
254
248
|
};
|
|
255
249
|
}
|
|
256
|
-
|
|
257
250
|
//#endregion
|
|
258
251
|
//#region src/App.tsx
|
|
259
252
|
const AppContext = createSplittingContext([
|
|
@@ -359,7 +352,6 @@ function App(props) {
|
|
|
359
352
|
*/
|
|
360
353
|
const useApp = AppContext.use;
|
|
361
354
|
App.useApp = useApp;
|
|
362
|
-
|
|
363
355
|
//#endregion
|
|
364
356
|
//#region src/Blank.tsx
|
|
365
357
|
/**
|
|
@@ -381,7 +373,6 @@ function Blank(options) {
|
|
|
381
373
|
children: options?.text || theme.Blank.text
|
|
382
374
|
}) : options.value;
|
|
383
375
|
}
|
|
384
|
-
|
|
385
376
|
//#endregion
|
|
386
377
|
//#region src/data.ts
|
|
387
378
|
/**
|
|
@@ -451,12 +442,11 @@ function transferValue(type, value) {
|
|
|
451
442
|
function cloneUnionFaasItemElement(element, props) {
|
|
452
443
|
return cloneElement(isValidElement(element) ? element : createElement(element), props);
|
|
453
444
|
}
|
|
454
|
-
|
|
455
445
|
//#endregion
|
|
456
446
|
//#region src/Description.tsx
|
|
457
447
|
function DescriptionItemContent(props) {
|
|
458
448
|
const [computedProps, setComputedProps] = useState();
|
|
459
|
-
|
|
449
|
+
useEqualEffect(() => {
|
|
460
450
|
const propsCopy = { ...props };
|
|
461
451
|
propsCopy.item.title = propsCopy.item.title ?? idToTitle(propsCopy.item.id);
|
|
462
452
|
if (!propsCopy.item.type) propsCopy.item.type = "string";
|
|
@@ -578,7 +568,6 @@ function Description({ faasData, dataSource, renderTitle, extendTypes, ...props
|
|
|
578
568
|
});
|
|
579
569
|
}
|
|
580
570
|
Description.displayName = "Description";
|
|
581
|
-
|
|
582
571
|
//#endregion
|
|
583
572
|
//#region src/FormItem.tsx
|
|
584
573
|
function isOptionsProps(item) {
|
|
@@ -638,7 +627,7 @@ function FormItem(props) {
|
|
|
638
627
|
const [extendTypes, setExtendTypes] = useState();
|
|
639
628
|
const { theme } = useConfigContext();
|
|
640
629
|
const [hidden, setHidden] = useState(props.hidden || false);
|
|
641
|
-
|
|
630
|
+
useEqualEffect(() => {
|
|
642
631
|
const { extendTypes, ...propsCopy } = { ...props };
|
|
643
632
|
if (extendTypes) setExtendTypes(extendTypes);
|
|
644
633
|
if (propsCopy.if) {
|
|
@@ -655,7 +644,11 @@ function FormItem(props) {
|
|
|
655
644
|
delete propsCopy.hidden;
|
|
656
645
|
}
|
|
657
646
|
setComputedProps(processProps(propsCopy, theme.common));
|
|
658
|
-
}, [
|
|
647
|
+
}, [
|
|
648
|
+
hidden,
|
|
649
|
+
props,
|
|
650
|
+
theme.common
|
|
651
|
+
]);
|
|
659
652
|
if (!computedProps) return null;
|
|
660
653
|
const itemType = computedProps.type ?? "string";
|
|
661
654
|
if (hidden) return /* @__PURE__ */ jsx(Form$1.Item, {
|
|
@@ -869,7 +862,6 @@ function FormItem(props) {
|
|
|
869
862
|
}
|
|
870
863
|
}
|
|
871
864
|
FormItem.useStatus = Form$1.Item.useStatus;
|
|
872
|
-
|
|
873
865
|
//#endregion
|
|
874
866
|
//#region src/Form.tsx
|
|
875
867
|
function isFormItemProps(item) {
|
|
@@ -888,19 +880,21 @@ function Form(props) {
|
|
|
888
880
|
const [extendTypes, setExtendTypes] = useState();
|
|
889
881
|
const [form] = Form$1.useForm(props.form);
|
|
890
882
|
const [initialValues, setInitialValues] = useState(props.initialValues || Object.create(null));
|
|
891
|
-
|
|
883
|
+
useEqualEffect(() => {
|
|
892
884
|
const { submit, ...propsCopy } = {
|
|
893
885
|
...props,
|
|
894
886
|
form
|
|
895
887
|
};
|
|
888
|
+
let nextInitialValues = propsCopy.initialValues;
|
|
896
889
|
if (typeof submit !== "undefined") setSubmit(submit);
|
|
897
890
|
if (propsCopy.initialValues && propsCopy.items?.length) {
|
|
898
891
|
for (const key in propsCopy.initialValues) propsCopy.initialValues[key] = transferValue(propsCopy.items.find((item) => isFormItemProps(item) && item.id === key)?.type, propsCopy.initialValues[key]);
|
|
892
|
+
nextInitialValues = propsCopy.initialValues;
|
|
899
893
|
setInitialValues(propsCopy.initialValues);
|
|
900
894
|
delete propsCopy.initialValues;
|
|
901
895
|
}
|
|
902
896
|
if (propsCopy.items?.length) {
|
|
903
|
-
for (const item of propsCopy.items) if (isFormItemProps(item) && item.if) item.hidden = !item.if(
|
|
897
|
+
for (const item of propsCopy.items) if (isFormItemProps(item) && item.if) item.hidden = !item.if(nextInitialValues || Object.create(null));
|
|
904
898
|
}
|
|
905
899
|
const submitTo = typeof submit === "object" ? submit.to : void 0;
|
|
906
900
|
if (propsCopy.onFinish) {
|
|
@@ -939,7 +933,7 @@ function Form(props) {
|
|
|
939
933
|
delete propsCopy.extendTypes;
|
|
940
934
|
}
|
|
941
935
|
setComputedProps(propsCopy);
|
|
942
|
-
}, [props]);
|
|
936
|
+
}, [form, props]);
|
|
943
937
|
const onValuesChange = useEqualCallback((changedValues, allValues) => {
|
|
944
938
|
console.debug("Form:onValuesChange", changedValues, allValues);
|
|
945
939
|
if (props.onValuesChange) props.onValuesChange(changedValues, allValues);
|
|
@@ -949,12 +943,12 @@ function Form(props) {
|
|
|
949
943
|
if (item?.onValueChange) item.onValueChange(changedValues[key], allValues, form);
|
|
950
944
|
}
|
|
951
945
|
}, [computedProps]);
|
|
952
|
-
|
|
946
|
+
useEqualEffect(() => {
|
|
953
947
|
if (!initialValues) return;
|
|
954
948
|
console.debug("Form:initialValues", initialValues);
|
|
955
949
|
form.setFieldsValue(initialValues);
|
|
956
950
|
setInitialValues(null);
|
|
957
|
-
}, [
|
|
951
|
+
}, [form, initialValues]);
|
|
958
952
|
if (!computedProps) return null;
|
|
959
953
|
return /* @__PURE__ */ jsxs(Form$1, {
|
|
960
954
|
...computedProps,
|
|
@@ -986,7 +980,6 @@ Form.Item = FormItem;
|
|
|
986
980
|
Form.List = Form$1.List;
|
|
987
981
|
Form.ErrorList = Form$1.ErrorList;
|
|
988
982
|
Form.Provider = Form$1.Provider;
|
|
989
|
-
|
|
990
983
|
//#endregion
|
|
991
984
|
//#region src/Link.tsx
|
|
992
985
|
/**
|
|
@@ -1006,7 +999,7 @@ function Link(props) {
|
|
|
1006
999
|
const navigate = useNavigate();
|
|
1007
1000
|
const target = props.target || theme.Link?.target || (props.href.startsWith("http") ? "_blank" : void 0);
|
|
1008
1001
|
let computedStyle = {
|
|
1009
|
-
...theme.Link.style
|
|
1002
|
+
...theme.Link.style,
|
|
1010
1003
|
cursor: "pointer",
|
|
1011
1004
|
...props.style
|
|
1012
1005
|
};
|
|
@@ -1020,8 +1013,16 @@ function Link(props) {
|
|
|
1020
1013
|
...buttonProps,
|
|
1021
1014
|
style: computedStyle,
|
|
1022
1015
|
onClick: (e) => {
|
|
1023
|
-
props.onClick ? props.onClick(e) : target === "_blank" ? window.open(props.href) : navigate(props.href);
|
|
1024
1016
|
e.preventDefault();
|
|
1017
|
+
if (props.onClick) {
|
|
1018
|
+
props.onClick(e);
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
if (target === "_blank") {
|
|
1022
|
+
window.open(props.href);
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
navigate(props.href);
|
|
1025
1026
|
},
|
|
1026
1027
|
children: props.children ?? props.text
|
|
1027
1028
|
});
|
|
@@ -1045,7 +1046,6 @@ function Link(props) {
|
|
|
1045
1046
|
children: props.children ?? props.text
|
|
1046
1047
|
});
|
|
1047
1048
|
}
|
|
1048
|
-
|
|
1049
1049
|
//#endregion
|
|
1050
1050
|
//#region src/Routers.tsx
|
|
1051
1051
|
function PageNotFound() {
|
|
@@ -1093,7 +1093,6 @@ function Routes(props) {
|
|
|
1093
1093
|
element: props.notFound || /* @__PURE__ */ jsx(PageNotFound, {})
|
|
1094
1094
|
}, "*")] });
|
|
1095
1095
|
}
|
|
1096
|
-
|
|
1097
1096
|
//#endregion
|
|
1098
1097
|
//#region src/Table.tsx
|
|
1099
1098
|
function processValue(item, value) {
|
|
@@ -1123,7 +1122,8 @@ function processValue(item, value) {
|
|
|
1123
1122
|
function Table(props) {
|
|
1124
1123
|
const [columns, setColumns] = useState();
|
|
1125
1124
|
const { theme } = useConfigContext();
|
|
1126
|
-
const
|
|
1125
|
+
const { all, blank, search } = theme.common;
|
|
1126
|
+
const generateFilterDropdown = useCallback((item) => {
|
|
1127
1127
|
if (item.filterDropdown && item.filterDropdown !== true) return;
|
|
1128
1128
|
if (!item.options?.length) return;
|
|
1129
1129
|
if (item.options.length < 11) {
|
|
@@ -1144,7 +1144,7 @@ function Table(props) {
|
|
|
1144
1144
|
allowClear: true,
|
|
1145
1145
|
showSearch: true,
|
|
1146
1146
|
style: { width: "100%" },
|
|
1147
|
-
placeholder: `${
|
|
1147
|
+
placeholder: `${search} ${item.title}`,
|
|
1148
1148
|
value: selectedKeys,
|
|
1149
1149
|
onChange: (v) => {
|
|
1150
1150
|
setSelectedKeys(v?.length ? v : []);
|
|
@@ -1152,18 +1152,19 @@ function Table(props) {
|
|
|
1152
1152
|
},
|
|
1153
1153
|
mode: "multiple",
|
|
1154
1154
|
filterOption: (input, option) => {
|
|
1155
|
-
if (!input || !option
|
|
1155
|
+
if (!input || !option) return true;
|
|
1156
|
+
if (typeof option.label !== "string") return option.value === input;
|
|
1156
1157
|
input = input.trim();
|
|
1157
|
-
return option.value === input || option.label.
|
|
1158
|
+
return option.value === input || option.label.toLowerCase().includes(input.toLowerCase());
|
|
1158
1159
|
}
|
|
1159
1160
|
})
|
|
1160
1161
|
});
|
|
1161
1162
|
return item;
|
|
1162
|
-
};
|
|
1163
|
-
|
|
1163
|
+
}, [search]);
|
|
1164
|
+
useEqualEffect(() => {
|
|
1164
1165
|
const items = cloneDeep(props.items).filter((item) => !(item.tableChildren === null || item.children === null || item.tableRender === null || item.render === null));
|
|
1165
1166
|
const createTextSearchFilterDropdown = (item, transformValue) => ({ setSelectedKeys, confirm, clearFilters }) => /* @__PURE__ */ jsx(Input.Search, {
|
|
1166
|
-
placeholder: `${
|
|
1167
|
+
placeholder: `${search} ${item.title}`,
|
|
1167
1168
|
allowClear: true,
|
|
1168
1169
|
onSearch: (v) => {
|
|
1169
1170
|
if (v) setSelectedKeys(transformValue ? [transformValue(v)] : [v]);
|
|
@@ -1261,7 +1262,7 @@ function Table(props) {
|
|
|
1261
1262
|
}
|
|
1262
1263
|
break;
|
|
1263
1264
|
case "number[]":
|
|
1264
|
-
if (!item.render) item.render = (value) => processValue(item, value)
|
|
1265
|
+
if (!item.render) item.render = (value) => processValue(item, value);
|
|
1265
1266
|
if (item.filterDropdown !== false) {
|
|
1266
1267
|
if (!item.onFilter && !props.faasData) item.onFilter = (value, row) => {
|
|
1267
1268
|
if (value === null && (!row[item.id] || !row[item.id].length)) return true;
|
|
@@ -1280,7 +1281,7 @@ function Table(props) {
|
|
|
1280
1281
|
color: "#ff4d4f"
|
|
1281
1282
|
} });
|
|
1282
1283
|
if (item.filterDropdown !== false) {
|
|
1283
|
-
if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm }) => /* @__PURE__ */ jsxs(Radio.Group, {
|
|
1284
|
+
if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm: confirmFilter }) => /* @__PURE__ */ jsxs(Radio.Group, {
|
|
1284
1285
|
style: { padding: 8 },
|
|
1285
1286
|
buttonStyle: "solid",
|
|
1286
1287
|
value: JSON.stringify(selectedKeys[0]),
|
|
@@ -1290,10 +1291,10 @@ function Table(props) {
|
|
|
1290
1291
|
false: false,
|
|
1291
1292
|
null: null
|
|
1292
1293
|
}[e.target.value]] : []);
|
|
1293
|
-
|
|
1294
|
+
confirmFilter();
|
|
1294
1295
|
},
|
|
1295
1296
|
children: [
|
|
1296
|
-
/* @__PURE__ */ jsx(Radio.Button, { children:
|
|
1297
|
+
/* @__PURE__ */ jsx(Radio.Button, { children: all }),
|
|
1297
1298
|
/* @__PURE__ */ jsx(Radio.Button, {
|
|
1298
1299
|
value: "true",
|
|
1299
1300
|
children: /* @__PURE__ */ jsx(CheckOutlined, { style: {
|
|
@@ -1310,7 +1311,7 @@ function Table(props) {
|
|
|
1310
1311
|
}),
|
|
1311
1312
|
/* @__PURE__ */ jsx(Radio.Button, {
|
|
1312
1313
|
value: "null",
|
|
1313
|
-
children:
|
|
1314
|
+
children: blank
|
|
1314
1315
|
})
|
|
1315
1316
|
]
|
|
1316
1317
|
});
|
|
@@ -1334,7 +1335,9 @@ function Table(props) {
|
|
|
1334
1335
|
};
|
|
1335
1336
|
if (item.filterDropdown !== false) {
|
|
1336
1337
|
if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsx(DatePicker.RangePicker, { onChange: (dates) => {
|
|
1337
|
-
|
|
1338
|
+
const start = dates?.[0];
|
|
1339
|
+
const end = dates?.[1];
|
|
1340
|
+
setSelectedKeys(start && end ? [[start.startOf("day").toISOString(), end.endOf("day").toISOString()]] : []);
|
|
1338
1341
|
confirm();
|
|
1339
1342
|
} });
|
|
1340
1343
|
if (!item.onFilter && !props.faasData) item.onFilter = (value, row) => {
|
|
@@ -1368,8 +1371,16 @@ function Table(props) {
|
|
|
1368
1371
|
}
|
|
1369
1372
|
}
|
|
1370
1373
|
setColumns(items);
|
|
1371
|
-
}, [
|
|
1372
|
-
|
|
1374
|
+
}, [
|
|
1375
|
+
all,
|
|
1376
|
+
blank,
|
|
1377
|
+
generateFilterDropdown,
|
|
1378
|
+
props.extendTypes,
|
|
1379
|
+
props.faasData,
|
|
1380
|
+
props.items,
|
|
1381
|
+
search
|
|
1382
|
+
]);
|
|
1383
|
+
useEqualEffect(() => {
|
|
1373
1384
|
if (!props.dataSource || !columns) return;
|
|
1374
1385
|
for (const column of columns) if (column.optionsType === "auto" && !column.options && !column.filters) {
|
|
1375
1386
|
const options = uniqBy(props.dataSource, column.id).map((v) => ({
|
|
@@ -1385,7 +1396,11 @@ function Table(props) {
|
|
|
1385
1396
|
return newColumns;
|
|
1386
1397
|
});
|
|
1387
1398
|
}
|
|
1388
|
-
}, [
|
|
1399
|
+
}, [
|
|
1400
|
+
props.dataSource,
|
|
1401
|
+
columns,
|
|
1402
|
+
generateFilterDropdown
|
|
1403
|
+
]);
|
|
1389
1404
|
if (!columns) return null;
|
|
1390
1405
|
if (props.dataSource) return /* @__PURE__ */ jsx(Table$1, {
|
|
1391
1406
|
...props,
|
|
@@ -1407,7 +1422,7 @@ function Table(props) {
|
|
|
1407
1422
|
}
|
|
1408
1423
|
function FaasDataTable({ props, columns, data, params, reload, loading }) {
|
|
1409
1424
|
const [currentColumns, setCurrentColumns] = useState(columns);
|
|
1410
|
-
|
|
1425
|
+
useEqualEffect(() => {
|
|
1411
1426
|
if (!data || Array.isArray(data)) return;
|
|
1412
1427
|
setCurrentColumns((prev) => {
|
|
1413
1428
|
const newColumns = [...prev];
|
|
@@ -1485,7 +1500,6 @@ function FaasDataTable({ props, columns, data, params, reload, loading }) {
|
|
|
1485
1500
|
}
|
|
1486
1501
|
});
|
|
1487
1502
|
}
|
|
1488
|
-
|
|
1489
1503
|
//#endregion
|
|
1490
1504
|
//#region src/Tabs.tsx
|
|
1491
1505
|
/**
|
|
@@ -1523,7 +1537,6 @@ function Tabs(props) {
|
|
|
1523
1537
|
}))
|
|
1524
1538
|
});
|
|
1525
1539
|
}
|
|
1526
|
-
|
|
1527
1540
|
//#endregion
|
|
1528
1541
|
//#region src/Title.tsx
|
|
1529
1542
|
/**
|
|
@@ -1546,7 +1559,7 @@ function Tabs(props) {
|
|
|
1546
1559
|
*/
|
|
1547
1560
|
function Title(props) {
|
|
1548
1561
|
const { theme } = useConfigContext();
|
|
1549
|
-
|
|
1562
|
+
useEqualEffect(() => {
|
|
1550
1563
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1551
1564
|
document.title = title.concat(props.suffix || theme.Title.suffix).filter((t) => !!t).join(props.separator || theme.Title.separator);
|
|
1552
1565
|
}, [props, theme.Title]);
|
|
@@ -1562,7 +1575,6 @@ function Title(props) {
|
|
|
1562
1575
|
if (props.children) return cloneElement(props.children, { title: props.title });
|
|
1563
1576
|
return null;
|
|
1564
1577
|
}
|
|
1565
|
-
|
|
1566
1578
|
//#endregion
|
|
1567
1579
|
//#region src/useThemeToken.ts
|
|
1568
1580
|
/**
|
|
@@ -1576,6 +1588,5 @@ function Title(props) {
|
|
|
1576
1588
|
function useThemeToken() {
|
|
1577
1589
|
return theme.useToken().token;
|
|
1578
1590
|
}
|
|
1579
|
-
|
|
1580
1591
|
//#endregion
|
|
1581
|
-
export { App, Blank, ConfigContext, ConfigProvider, Description, Drawer, ErrorBoundary, FaasDataWrapper, FaasReactClient, Form, FormItem, Link, Loading, Modal, PageNotFound, Routes, Table, Tabs, Title, cloneUnionFaasItemElement, faas, idToTitle, lazy, transferOptions, transferValue, useApp, useConfigContext, useDrawer, useFaas, useModal, useThemeToken, withFaasData };
|
|
1592
|
+
export { App, Blank, ConfigContext, ConfigProvider, Description, Drawer, ErrorBoundary, FaasDataWrapper, FaasReactClient, Form, FormItem, Link, Loading, Modal, PageNotFound, Routes, Table, Tabs, Title, cloneUnionFaasItemElement, faas, idToTitle, lazy, transferOptions, transferValue, useApp, useConfigContext, useDrawer, useFaas, useModal, useThemeToken, withFaasData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.15",
|
|
4
4
|
"homepage": "https://faasjs.com/doc/ant-design",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/faasjs/faasjs/issues"
|
|
@@ -26,12 +26,9 @@
|
|
|
26
26
|
"require": "./dist/index.cjs"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
"scripts": {
|
|
30
|
-
"build": "tsdown src/index.ts --config ../../tsdown.config.ts --dts.eager --no-sourcemap --no-dts.sourcemap"
|
|
31
|
-
},
|
|
32
29
|
"devDependencies": {
|
|
33
30
|
"@ant-design/icons": "*",
|
|
34
|
-
"@faasjs/react": ">=8.0.0-beta.
|
|
31
|
+
"@faasjs/react": ">=8.0.0-beta.15",
|
|
35
32
|
"@types/lodash-es": "*",
|
|
36
33
|
"@types/react": "^19.0.0",
|
|
37
34
|
"@types/react-dom": "^19.0.0",
|
|
@@ -43,7 +40,7 @@
|
|
|
43
40
|
},
|
|
44
41
|
"peerDependencies": {
|
|
45
42
|
"@ant-design/icons": "*",
|
|
46
|
-
"@faasjs/react": ">=8.0.0-beta.
|
|
43
|
+
"@faasjs/react": ">=8.0.0-beta.15",
|
|
47
44
|
"antd": "^6.0.0",
|
|
48
45
|
"lodash-es": "*",
|
|
49
46
|
"react": "^19.0.0",
|