@faasjs/ant-design 0.0.2-beta.415 → 0.0.2-beta.416
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.d.ts +3 -0
- package/dist/index.js +345 -218
- package/dist/index.mjs +218 -89
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -24,7 +24,9 @@ var zh = {
|
|
|
24
24
|
pageNotFound: "\u9875\u9762\u672A\u627E\u5230",
|
|
25
25
|
add: "\u6DFB\u52A0",
|
|
26
26
|
delete: "\u5220\u9664",
|
|
27
|
-
required: "\u5FC5\u586B"
|
|
27
|
+
required: "\u5FC5\u586B",
|
|
28
|
+
search: "\u641C\u7D22",
|
|
29
|
+
reset: "\u91CD\u7F6E"
|
|
28
30
|
};
|
|
29
31
|
var en = {
|
|
30
32
|
lang: "en",
|
|
@@ -34,7 +36,9 @@ var en = {
|
|
|
34
36
|
pageNotFound: "Page Not Found",
|
|
35
37
|
add: "Add",
|
|
36
38
|
delete: "Delete",
|
|
37
|
-
required: "is required"
|
|
39
|
+
required: "is required",
|
|
40
|
+
search: "Search",
|
|
41
|
+
reset: "Reset"
|
|
38
42
|
};
|
|
39
43
|
var common = isZH ? zh : en;
|
|
40
44
|
var baseConfig = {
|
|
@@ -879,48 +883,45 @@ import {
|
|
|
879
883
|
import {
|
|
880
884
|
Table as AntdTable,
|
|
881
885
|
Radio,
|
|
882
|
-
Skeleton as Skeleton3
|
|
886
|
+
Skeleton as Skeleton3,
|
|
887
|
+
Empty
|
|
883
888
|
} from "antd";
|
|
884
889
|
import dayjs3 from "dayjs";
|
|
890
|
+
import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
|
|
885
891
|
import {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
892
|
+
isNil as isNil2,
|
|
893
|
+
uniqBy,
|
|
894
|
+
upperFirst as upperFirst4
|
|
895
|
+
} from "lodash";
|
|
890
896
|
import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
891
897
|
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
892
898
|
function processValue(item, value) {
|
|
893
899
|
var _a;
|
|
894
|
-
if (typeof value
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
if (["date", "time"].includes(item.type)) {
|
|
914
|
-
if (typeof value === "number" && value.toString().length === 10)
|
|
915
|
-
value = value * 1e3;
|
|
916
|
-
value = dayjs3(value).format(dayjsFormat);
|
|
917
|
-
}
|
|
900
|
+
if (typeof value === "undefined" && value === null)
|
|
901
|
+
return /* @__PURE__ */ jsx11(Empty, {});
|
|
902
|
+
if (item.options) {
|
|
903
|
+
if (item.type.endsWith("[]"))
|
|
904
|
+
return value.map((v) => {
|
|
905
|
+
var _a2;
|
|
906
|
+
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
907
|
+
});
|
|
908
|
+
else if ([
|
|
909
|
+
"string",
|
|
910
|
+
"number",
|
|
911
|
+
"boolean"
|
|
912
|
+
].includes(item.type))
|
|
913
|
+
return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
|
|
914
|
+
}
|
|
915
|
+
if (["date", "time"].includes(item.type)) {
|
|
916
|
+
if (typeof value === "number" && value.toString().length === 10)
|
|
917
|
+
value = value * 1e3;
|
|
918
|
+
return dayjs3(value).format(item.type === "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss");
|
|
918
919
|
}
|
|
919
920
|
return value;
|
|
920
921
|
}
|
|
921
922
|
function Table(props) {
|
|
922
923
|
const [columns, setColumns] = useState7();
|
|
923
|
-
const
|
|
924
|
+
const { common: common2 } = useConfigContext();
|
|
924
925
|
useEffect5(() => {
|
|
925
926
|
var _a;
|
|
926
927
|
for (const item of props.items) {
|
|
@@ -939,8 +940,6 @@ function Table(props) {
|
|
|
939
940
|
value: o.value
|
|
940
941
|
}));
|
|
941
942
|
}
|
|
942
|
-
if (item.render)
|
|
943
|
-
continue;
|
|
944
943
|
if (item.children)
|
|
945
944
|
delete item.children;
|
|
946
945
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
@@ -960,75 +959,185 @@ function Table(props) {
|
|
|
960
959
|
}
|
|
961
960
|
switch (item.type) {
|
|
962
961
|
case "string":
|
|
963
|
-
item.render
|
|
962
|
+
if (!item.render)
|
|
963
|
+
item.render = (value) => processValue(item, value);
|
|
964
964
|
if (!item.onFilter) {
|
|
965
965
|
item.onFilter = (value, row) => row[item.id].includes(value);
|
|
966
|
-
if (item.filterDropdown !== false)
|
|
967
|
-
item.filterDropdown = ({
|
|
968
|
-
setSelectedKeys,
|
|
969
|
-
selectedKeys,
|
|
970
|
-
confirm,
|
|
971
|
-
clearFilters
|
|
972
|
-
}) => /* @__PURE__ */ jsxs4("div", {
|
|
973
|
-
style: { padding: 8 },
|
|
974
|
-
children: [
|
|
975
|
-
/* @__PURE__ */ jsx11("input", {
|
|
976
|
-
value: selectedKeys[0],
|
|
977
|
-
onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
|
|
978
|
-
style: {
|
|
979
|
-
width: 188,
|
|
980
|
-
marginBottom: 8,
|
|
981
|
-
display: "block"
|
|
982
|
-
}
|
|
983
|
-
}),
|
|
984
|
-
/* @__PURE__ */ jsx11("button", {
|
|
985
|
-
type: "button",
|
|
986
|
-
onClick: () => confirm(),
|
|
987
|
-
style: {
|
|
988
|
-
width: 90,
|
|
989
|
-
marginRight: 8
|
|
990
|
-
},
|
|
991
|
-
children: "Search"
|
|
992
|
-
}),
|
|
993
|
-
/* @__PURE__ */ jsx11("button", {
|
|
994
|
-
type: "button",
|
|
995
|
-
onClick: () => clearFilters(),
|
|
996
|
-
style: { width: 90 },
|
|
997
|
-
children: "Reset"
|
|
998
|
-
})
|
|
999
|
-
]
|
|
1000
|
-
});
|
|
1001
966
|
}
|
|
967
|
+
if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
|
|
968
|
+
item.filterDropdown = ({
|
|
969
|
+
setSelectedKeys,
|
|
970
|
+
selectedKeys,
|
|
971
|
+
confirm,
|
|
972
|
+
clearFilters
|
|
973
|
+
}) => /* @__PURE__ */ jsxs4("div", {
|
|
974
|
+
style: { padding: 8 },
|
|
975
|
+
children: [
|
|
976
|
+
/* @__PURE__ */ jsx11("input", {
|
|
977
|
+
value: selectedKeys[0],
|
|
978
|
+
onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
|
|
979
|
+
style: {
|
|
980
|
+
width: 188,
|
|
981
|
+
marginBottom: 8,
|
|
982
|
+
display: "block"
|
|
983
|
+
}
|
|
984
|
+
}),
|
|
985
|
+
/* @__PURE__ */ jsx11("button", {
|
|
986
|
+
type: "button",
|
|
987
|
+
onClick: () => confirm(),
|
|
988
|
+
style: {
|
|
989
|
+
width: 90,
|
|
990
|
+
marginRight: 8
|
|
991
|
+
},
|
|
992
|
+
children: common2.search
|
|
993
|
+
}),
|
|
994
|
+
/* @__PURE__ */ jsx11("button", {
|
|
995
|
+
type: "button",
|
|
996
|
+
onClick: () => clearFilters(),
|
|
997
|
+
style: { width: 90 },
|
|
998
|
+
children: common2.reset
|
|
999
|
+
})
|
|
1000
|
+
]
|
|
1001
|
+
});
|
|
1002
1002
|
break;
|
|
1003
1003
|
case "string[]":
|
|
1004
|
-
|
|
1004
|
+
if (!item.render)
|
|
1005
|
+
item.render = (value) => processValue(item, value).join(", ");
|
|
1005
1006
|
if (!item.onFilter)
|
|
1006
1007
|
item.onFilter = (value, row) => row[item.id].includes(value);
|
|
1008
|
+
if (!item.filters && item.filterDropdown !== false)
|
|
1009
|
+
item.filterDropdown = ({
|
|
1010
|
+
setSelectedKeys,
|
|
1011
|
+
selectedKeys,
|
|
1012
|
+
confirm,
|
|
1013
|
+
clearFilters
|
|
1014
|
+
}) => /* @__PURE__ */ jsxs4("div", {
|
|
1015
|
+
style: { padding: 8 },
|
|
1016
|
+
children: [
|
|
1017
|
+
/* @__PURE__ */ jsx11("input", {
|
|
1018
|
+
value: selectedKeys[0],
|
|
1019
|
+
onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
|
|
1020
|
+
style: {
|
|
1021
|
+
width: 188,
|
|
1022
|
+
marginBottom: 8,
|
|
1023
|
+
display: "block"
|
|
1024
|
+
}
|
|
1025
|
+
}),
|
|
1026
|
+
/* @__PURE__ */ jsx11("button", {
|
|
1027
|
+
type: "button",
|
|
1028
|
+
onClick: () => confirm(),
|
|
1029
|
+
style: {
|
|
1030
|
+
width: 90,
|
|
1031
|
+
marginRight: 8
|
|
1032
|
+
},
|
|
1033
|
+
children: common2.search
|
|
1034
|
+
}),
|
|
1035
|
+
/* @__PURE__ */ jsx11("button", {
|
|
1036
|
+
type: "button",
|
|
1037
|
+
onClick: () => clearFilters(),
|
|
1038
|
+
style: { width: 90 },
|
|
1039
|
+
children: common2.reset
|
|
1040
|
+
})
|
|
1041
|
+
]
|
|
1042
|
+
});
|
|
1007
1043
|
break;
|
|
1008
1044
|
case "number":
|
|
1009
|
-
item.render
|
|
1045
|
+
if (!item.render)
|
|
1046
|
+
item.render = (value) => processValue(item, value);
|
|
1010
1047
|
if (!item.sorter)
|
|
1011
1048
|
item.sorter = (a, b) => a[item.id] - b[item.id];
|
|
1012
1049
|
if (!item.onFilter)
|
|
1013
1050
|
item.onFilter = (value, row) => value === row[item.id];
|
|
1051
|
+
if (!item.filters && item.filterDropdown !== false)
|
|
1052
|
+
item.filterDropdown = ({
|
|
1053
|
+
setSelectedKeys,
|
|
1054
|
+
selectedKeys,
|
|
1055
|
+
confirm,
|
|
1056
|
+
clearFilters
|
|
1057
|
+
}) => /* @__PURE__ */ jsxs4("div", {
|
|
1058
|
+
style: { padding: 8 },
|
|
1059
|
+
children: [
|
|
1060
|
+
/* @__PURE__ */ jsx11("input", {
|
|
1061
|
+
value: selectedKeys[0],
|
|
1062
|
+
onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
|
|
1063
|
+
style: {
|
|
1064
|
+
width: 188,
|
|
1065
|
+
marginBottom: 8,
|
|
1066
|
+
display: "block"
|
|
1067
|
+
}
|
|
1068
|
+
}),
|
|
1069
|
+
/* @__PURE__ */ jsx11("button", {
|
|
1070
|
+
type: "button",
|
|
1071
|
+
onClick: () => confirm(),
|
|
1072
|
+
style: {
|
|
1073
|
+
width: 90,
|
|
1074
|
+
marginRight: 8
|
|
1075
|
+
},
|
|
1076
|
+
children: common2.search
|
|
1077
|
+
}),
|
|
1078
|
+
/* @__PURE__ */ jsx11("button", {
|
|
1079
|
+
type: "button",
|
|
1080
|
+
onClick: () => clearFilters(),
|
|
1081
|
+
style: { width: 90 },
|
|
1082
|
+
children: common2.reset
|
|
1083
|
+
})
|
|
1084
|
+
]
|
|
1085
|
+
});
|
|
1014
1086
|
break;
|
|
1015
1087
|
case "number[]":
|
|
1016
|
-
|
|
1088
|
+
if (!item.render)
|
|
1089
|
+
item.render = (value) => processValue(item, value).join(", ");
|
|
1017
1090
|
if (!item.onFilter)
|
|
1018
1091
|
item.onFilter = (value, row) => row[item.id].includes(value);
|
|
1092
|
+
if (!item.filters && item.filterDropdown !== false)
|
|
1093
|
+
item.filterDropdown = ({
|
|
1094
|
+
setSelectedKeys,
|
|
1095
|
+
selectedKeys,
|
|
1096
|
+
confirm,
|
|
1097
|
+
clearFilters
|
|
1098
|
+
}) => /* @__PURE__ */ jsxs4("div", {
|
|
1099
|
+
style: { padding: 8 },
|
|
1100
|
+
children: [
|
|
1101
|
+
/* @__PURE__ */ jsx11("input", {
|
|
1102
|
+
value: selectedKeys[0],
|
|
1103
|
+
onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
|
|
1104
|
+
style: {
|
|
1105
|
+
width: 188,
|
|
1106
|
+
marginBottom: 8,
|
|
1107
|
+
display: "block"
|
|
1108
|
+
}
|
|
1109
|
+
}),
|
|
1110
|
+
/* @__PURE__ */ jsx11("button", {
|
|
1111
|
+
type: "button",
|
|
1112
|
+
onClick: () => confirm(),
|
|
1113
|
+
style: {
|
|
1114
|
+
width: 90,
|
|
1115
|
+
marginRight: 8
|
|
1116
|
+
},
|
|
1117
|
+
children: common2.search
|
|
1118
|
+
}),
|
|
1119
|
+
/* @__PURE__ */ jsx11("button", {
|
|
1120
|
+
type: "button",
|
|
1121
|
+
onClick: () => clearFilters(),
|
|
1122
|
+
style: { width: 90 },
|
|
1123
|
+
children: common2.reset
|
|
1124
|
+
})
|
|
1125
|
+
]
|
|
1126
|
+
});
|
|
1019
1127
|
break;
|
|
1020
1128
|
case "boolean":
|
|
1021
|
-
item.render
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1129
|
+
if (!item.render)
|
|
1130
|
+
item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ jsx11(Blank, {}) : value ? /* @__PURE__ */ jsx11(CheckOutlined2, {
|
|
1131
|
+
style: {
|
|
1132
|
+
marginTop: "4px",
|
|
1133
|
+
color: "#52c41a"
|
|
1134
|
+
}
|
|
1135
|
+
}) : /* @__PURE__ */ jsx11(CloseOutlined2, {
|
|
1136
|
+
style: {
|
|
1137
|
+
marginTop: "4px",
|
|
1138
|
+
color: "#ff4d4f"
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1032
1141
|
if (item.filterDropdown !== false)
|
|
1033
1142
|
item.filterDropdown = ({
|
|
1034
1143
|
setSelectedKeys,
|
|
@@ -1044,7 +1153,7 @@ function Table(props) {
|
|
|
1044
1153
|
},
|
|
1045
1154
|
children: [
|
|
1046
1155
|
/* @__PURE__ */ jsx11(Radio.Button, {
|
|
1047
|
-
children:
|
|
1156
|
+
children: common2.all
|
|
1048
1157
|
}),
|
|
1049
1158
|
/* @__PURE__ */ jsx11(Radio.Button, {
|
|
1050
1159
|
value: "true",
|
|
@@ -1066,7 +1175,7 @@ function Table(props) {
|
|
|
1066
1175
|
}),
|
|
1067
1176
|
/* @__PURE__ */ jsx11(Radio.Button, {
|
|
1068
1177
|
value: "empty",
|
|
1069
|
-
children:
|
|
1178
|
+
children: common2.blank
|
|
1070
1179
|
})
|
|
1071
1180
|
]
|
|
1072
1181
|
});
|
|
@@ -1085,21 +1194,24 @@ function Table(props) {
|
|
|
1085
1194
|
};
|
|
1086
1195
|
break;
|
|
1087
1196
|
case "date":
|
|
1088
|
-
item.render
|
|
1197
|
+
if (!item.render)
|
|
1198
|
+
item.render = (value) => processValue(item, value);
|
|
1089
1199
|
if (!item.onFilter)
|
|
1090
1200
|
item.onFilter = (value, row) => dayjs3(row[item.id]).isSame(dayjs3(value));
|
|
1091
1201
|
if (!item.sorter)
|
|
1092
1202
|
item.sorter = (a, b) => dayjs3(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
|
|
1093
1203
|
break;
|
|
1094
1204
|
case "time":
|
|
1095
|
-
item.render
|
|
1205
|
+
if (!item.render)
|
|
1206
|
+
item.render = (value) => processValue(item, value);
|
|
1096
1207
|
if (!item.onFilter)
|
|
1097
1208
|
item.onFilter = (value, row) => dayjs3(row[item.id]).isSame(dayjs3(value));
|
|
1098
1209
|
if (!item.sorter)
|
|
1099
1210
|
item.sorter = (a, b) => dayjs3(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
|
|
1100
1211
|
break;
|
|
1101
1212
|
default:
|
|
1102
|
-
item.render
|
|
1213
|
+
if (!item.render)
|
|
1214
|
+
item.render = (value) => processValue(item, value);
|
|
1103
1215
|
if (!item.onFilter)
|
|
1104
1216
|
item.onFilter = (value, row) => value === row[item.id];
|
|
1105
1217
|
break;
|
|
@@ -1107,6 +1219,23 @@ function Table(props) {
|
|
|
1107
1219
|
}
|
|
1108
1220
|
setColumns(props.items);
|
|
1109
1221
|
}, [props.items]);
|
|
1222
|
+
useEffect5(() => {
|
|
1223
|
+
if (!props.dataSource || !columns)
|
|
1224
|
+
return;
|
|
1225
|
+
for (const column of columns) {
|
|
1226
|
+
if (column.optionsType === "auto" && !column.options && !column.filters) {
|
|
1227
|
+
setColumns((prev) => {
|
|
1228
|
+
const newColumns = [...prev];
|
|
1229
|
+
const index = newColumns.findIndex((item) => item.id === column.id);
|
|
1230
|
+
newColumns[index].filters = uniqBy(props.dataSource, column.id).map((v) => ({
|
|
1231
|
+
text: v[column.id],
|
|
1232
|
+
value: v[column.id]
|
|
1233
|
+
}));
|
|
1234
|
+
return newColumns;
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}, [props.dataSource, columns]);
|
|
1110
1239
|
if (!columns)
|
|
1111
1240
|
return null;
|
|
1112
1241
|
if (!props.faasData)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.416",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lodash": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.416",
|
|
32
32
|
"react-router-dom": "*",
|
|
33
33
|
"dayjs": "*"
|
|
34
34
|
},
|