@faasjs/ant-design 0.0.3-beta.1 → 0.0.3-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +45 -24
- package/dist/index.mjs +31 -10
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -52,12 +52,12 @@ var import_react = __toESM(require("react"));
|
|
|
52
52
|
|
|
53
53
|
// src/Blank.tsx
|
|
54
54
|
var import_antd2 = require("antd");
|
|
55
|
-
var
|
|
55
|
+
var import_lodash_es2 = require("lodash-es");
|
|
56
56
|
|
|
57
57
|
// src/Config.tsx
|
|
58
58
|
var import_react2 = require("react");
|
|
59
59
|
var import_antd = require("antd");
|
|
60
|
-
var
|
|
60
|
+
var import_lodash_es = require("lodash-es");
|
|
61
61
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
62
|
var isZH = /^zh/i.test(navigator.language);
|
|
63
63
|
var zh = {
|
|
@@ -105,7 +105,7 @@ function ConfigProvider({
|
|
|
105
105
|
const [values, setValues] = (0, import_react2.useState)(baseConfig);
|
|
106
106
|
(0, import_react2.useEffect)(() => {
|
|
107
107
|
if (config.lang === "zh") {
|
|
108
|
-
setValues((0,
|
|
108
|
+
setValues((0, import_lodash_es.defaultsDeep)(config, {
|
|
109
109
|
lang: "zh",
|
|
110
110
|
common: zh,
|
|
111
111
|
Blank: { text: zh.blank },
|
|
@@ -130,20 +130,20 @@ function useConfigContext() {
|
|
|
130
130
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
131
131
|
function Blank(options) {
|
|
132
132
|
const { Blank: Blank2 } = useConfigContext();
|
|
133
|
-
return !options || (0,
|
|
133
|
+
return !options || (0, import_lodash_es2.isNil)(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Typography.Text, {
|
|
134
134
|
disabled: true,
|
|
135
135
|
children: (options == null ? void 0 : options.text) || Blank2.text
|
|
136
136
|
}) : options.value;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
// src/data.ts
|
|
140
|
-
var
|
|
140
|
+
var import_lodash_es3 = require("lodash-es");
|
|
141
141
|
var import_dayjs = __toESM(require("dayjs"));
|
|
142
142
|
function transferOptions(options) {
|
|
143
143
|
if (!options)
|
|
144
144
|
return [];
|
|
145
145
|
return options.map((item) => typeof item === "object" ? item : {
|
|
146
|
-
label: (0,
|
|
146
|
+
label: (0, import_lodash_es3.upperFirst)(item.toString()),
|
|
147
147
|
value: item
|
|
148
148
|
});
|
|
149
149
|
}
|
|
@@ -166,7 +166,7 @@ function transferValue(type, value) {
|
|
|
166
166
|
// src/Description.tsx
|
|
167
167
|
var import_icons = require("@ant-design/icons");
|
|
168
168
|
var import_antd3 = require("antd");
|
|
169
|
-
var
|
|
169
|
+
var import_lodash_es4 = require("lodash-es");
|
|
170
170
|
var import_react3 = require("react");
|
|
171
171
|
var import_react4 = require("@faasjs/react");
|
|
172
172
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -177,7 +177,7 @@ function DescriptionItemContent(props) {
|
|
|
177
177
|
var _a2, _b;
|
|
178
178
|
const propsCopy = { ...props };
|
|
179
179
|
if (!propsCopy.item.title)
|
|
180
|
-
propsCopy.item.title = (0,
|
|
180
|
+
propsCopy.item.title = (0, import_lodash_es4.upperFirst)(propsCopy.item.id);
|
|
181
181
|
if (!propsCopy.item.type)
|
|
182
182
|
propsCopy.item.type = "string";
|
|
183
183
|
if ((_a2 = propsCopy.item.options) == null ? void 0 : _a2.length) {
|
|
@@ -282,10 +282,10 @@ function Description(props) {
|
|
|
282
282
|
if (!props.faasData)
|
|
283
283
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions, {
|
|
284
284
|
...props,
|
|
285
|
-
title: (0,
|
|
285
|
+
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
286
286
|
children: props.items.map((item) => {
|
|
287
287
|
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions.Item, {
|
|
288
|
-
label: item.title || (0,
|
|
288
|
+
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
289
289
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
290
290
|
item,
|
|
291
291
|
value: props.dataSource[item.id],
|
|
@@ -302,10 +302,10 @@ function Description(props) {
|
|
|
302
302
|
render: ({ data }) => {
|
|
303
303
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions, {
|
|
304
304
|
...props,
|
|
305
|
-
title: (0,
|
|
305
|
+
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
306
306
|
children: props.items.map((item) => {
|
|
307
307
|
return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions.Item, {
|
|
308
|
-
label: item.title || (0,
|
|
308
|
+
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
309
309
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
310
310
|
item,
|
|
311
311
|
value: data[item.id],
|
|
@@ -356,11 +356,11 @@ var import_react8 = require("react");
|
|
|
356
356
|
var import_antd5 = require("antd");
|
|
357
357
|
var import_icons2 = require("@ant-design/icons");
|
|
358
358
|
var import_react6 = require("react");
|
|
359
|
-
var
|
|
359
|
+
var import_lodash_es5 = require("lodash-es");
|
|
360
360
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
361
361
|
function processProps(propsCopy, config) {
|
|
362
362
|
if (!propsCopy.title)
|
|
363
|
-
propsCopy.title = (0,
|
|
363
|
+
propsCopy.title = (0, import_lodash_es5.upperFirst)(propsCopy.id);
|
|
364
364
|
if (!propsCopy.label && propsCopy.label !== false)
|
|
365
365
|
propsCopy.label = propsCopy.title;
|
|
366
366
|
if (!propsCopy.name)
|
|
@@ -943,7 +943,7 @@ var import_react11 = require("react");
|
|
|
943
943
|
var import_antd10 = require("antd");
|
|
944
944
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
945
945
|
var import_icons3 = require("@ant-design/icons");
|
|
946
|
-
var
|
|
946
|
+
var import_lodash_es6 = require("lodash-es");
|
|
947
947
|
var import_react12 = require("@faasjs/react");
|
|
948
948
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
949
949
|
function processValue(item, value) {
|
|
@@ -981,7 +981,7 @@ function Table(props) {
|
|
|
981
981
|
if (!item.dataIndex)
|
|
982
982
|
item.dataIndex = item.id;
|
|
983
983
|
if (!item.title)
|
|
984
|
-
item.title = (0,
|
|
984
|
+
item.title = (0, import_lodash_es6.upperFirst)(item.id);
|
|
985
985
|
if (!item.type)
|
|
986
986
|
item.type = "string";
|
|
987
987
|
if ((_a = item.options) == null ? void 0 : _a.length) {
|
|
@@ -1014,6 +1014,8 @@ function Table(props) {
|
|
|
1014
1014
|
item.render = (value) => processValue(item, value);
|
|
1015
1015
|
if (!item.onFilter)
|
|
1016
1016
|
item.onFilter = (value, row) => {
|
|
1017
|
+
if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
|
|
1018
|
+
return true;
|
|
1017
1019
|
if (!row[item.id])
|
|
1018
1020
|
return false;
|
|
1019
1021
|
return row[item.id].toLowerCase().includes(value.toLowerCase());
|
|
@@ -1042,6 +1044,8 @@ function Table(props) {
|
|
|
1042
1044
|
item.render = (value) => processValue(item, value);
|
|
1043
1045
|
if (!item.onFilter)
|
|
1044
1046
|
item.onFilter = (value, row) => {
|
|
1047
|
+
if (value === null && (!row[item.id] || !row[item.id].length))
|
|
1048
|
+
return true;
|
|
1045
1049
|
if (!row[item.id] || !row[item.id].length)
|
|
1046
1050
|
return false;
|
|
1047
1051
|
return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
|
|
@@ -1071,7 +1075,11 @@ function Table(props) {
|
|
|
1071
1075
|
if (!item.sorter)
|
|
1072
1076
|
item.sorter = (a, b) => a[item.id] - b[item.id];
|
|
1073
1077
|
if (!item.onFilter)
|
|
1074
|
-
item.onFilter = (value, row) =>
|
|
1078
|
+
item.onFilter = (value, row) => {
|
|
1079
|
+
if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
|
|
1080
|
+
return true;
|
|
1081
|
+
return value === row[item.id];
|
|
1082
|
+
};
|
|
1075
1083
|
if (!item.filters && item.filterDropdown !== false)
|
|
1076
1084
|
item.filterDropdown = ({
|
|
1077
1085
|
setSelectedKeys,
|
|
@@ -1095,7 +1103,13 @@ function Table(props) {
|
|
|
1095
1103
|
if (!item.render)
|
|
1096
1104
|
item.render = (value) => processValue(item, value).join(", ");
|
|
1097
1105
|
if (!item.onFilter)
|
|
1098
|
-
item.onFilter = (value, row) =>
|
|
1106
|
+
item.onFilter = (value, row) => {
|
|
1107
|
+
if (value === null && (!row[item.id] || !row[item.id].length))
|
|
1108
|
+
return true;
|
|
1109
|
+
if (!row[item.id] || !row[item.id].length)
|
|
1110
|
+
return false;
|
|
1111
|
+
return row[item.id].includes(value);
|
|
1112
|
+
};
|
|
1099
1113
|
if (!item.filters && item.filterDropdown !== false)
|
|
1100
1114
|
item.filterDropdown = ({
|
|
1101
1115
|
setSelectedKeys,
|
|
@@ -1173,11 +1187,11 @@ function Table(props) {
|
|
|
1173
1187
|
item.onFilter = (value, row) => {
|
|
1174
1188
|
switch (value) {
|
|
1175
1189
|
case "true":
|
|
1176
|
-
return !(0,
|
|
1190
|
+
return !(0, import_lodash_es6.isNil)(row[item.id]) && !!row[item.id];
|
|
1177
1191
|
case "false":
|
|
1178
|
-
return !(0,
|
|
1192
|
+
return !(0, import_lodash_es6.isNil)(row[item.id]) && !row[item.id];
|
|
1179
1193
|
case "empty":
|
|
1180
|
-
return (0,
|
|
1194
|
+
return (0, import_lodash_es6.isNil)(row[item.id]);
|
|
1181
1195
|
default:
|
|
1182
1196
|
return true;
|
|
1183
1197
|
}
|
|
@@ -1219,7 +1233,11 @@ function Table(props) {
|
|
|
1219
1233
|
if (!item.render)
|
|
1220
1234
|
item.render = (value) => processValue(item, value);
|
|
1221
1235
|
if (!item.onFilter)
|
|
1222
|
-
item.onFilter = (value, row) =>
|
|
1236
|
+
item.onFilter = (value, row) => {
|
|
1237
|
+
if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
|
|
1238
|
+
return true;
|
|
1239
|
+
return value === row[item.id];
|
|
1240
|
+
};
|
|
1223
1241
|
break;
|
|
1224
1242
|
}
|
|
1225
1243
|
}
|
|
@@ -1233,10 +1251,13 @@ function Table(props) {
|
|
|
1233
1251
|
setColumns((prev) => {
|
|
1234
1252
|
const newColumns = [...prev];
|
|
1235
1253
|
const index = newColumns.findIndex((item) => item.id === column.id);
|
|
1236
|
-
newColumns[index].filters = (0,
|
|
1254
|
+
newColumns[index].filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
|
|
1237
1255
|
text: v[column.id],
|
|
1238
1256
|
value: v[column.id]
|
|
1239
|
-
}))
|
|
1257
|
+
})).concat({
|
|
1258
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1259
|
+
value: null
|
|
1260
|
+
});
|
|
1240
1261
|
return newColumns;
|
|
1241
1262
|
});
|
|
1242
1263
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
|
|
4
4
|
// src/Blank.tsx
|
|
5
5
|
import { Typography } from "antd";
|
|
6
|
-
import { isNil } from "lodash";
|
|
6
|
+
import { isNil } from "lodash-es";
|
|
7
7
|
|
|
8
8
|
// src/Config.tsx
|
|
9
9
|
import {
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
useState
|
|
14
14
|
} from "react";
|
|
15
15
|
import { ConfigProvider as AntdConfigProvider } from "antd";
|
|
16
|
-
import { defaultsDeep } from "lodash";
|
|
16
|
+
import { defaultsDeep } from "lodash-es";
|
|
17
17
|
import { jsx } from "react/jsx-runtime";
|
|
18
18
|
var isZH = /^zh/i.test(navigator.language);
|
|
19
19
|
var zh = {
|
|
@@ -93,7 +93,7 @@ function Blank(options) {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// src/data.ts
|
|
96
|
-
import { upperFirst } from "lodash";
|
|
96
|
+
import { upperFirst } from "lodash-es";
|
|
97
97
|
import dayjs from "dayjs";
|
|
98
98
|
function transferOptions(options) {
|
|
99
99
|
if (!options)
|
|
@@ -126,7 +126,7 @@ import {
|
|
|
126
126
|
Skeleton,
|
|
127
127
|
Space
|
|
128
128
|
} from "antd";
|
|
129
|
-
import { isFunction, upperFirst as upperFirst2 } from "lodash";
|
|
129
|
+
import { isFunction, upperFirst as upperFirst2 } from "lodash-es";
|
|
130
130
|
import {
|
|
131
131
|
cloneElement,
|
|
132
132
|
useEffect as useEffect2,
|
|
@@ -341,7 +341,7 @@ import {
|
|
|
341
341
|
useEffect as useEffect3,
|
|
342
342
|
useState as useState4
|
|
343
343
|
} from "react";
|
|
344
|
-
import { upperFirst as upperFirst3 } from "lodash";
|
|
344
|
+
import { upperFirst as upperFirst3 } from "lodash-es";
|
|
345
345
|
import { Fragment as Fragment2, jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
346
346
|
function processProps(propsCopy, config) {
|
|
347
347
|
if (!propsCopy.title)
|
|
@@ -946,7 +946,7 @@ import {
|
|
|
946
946
|
isNil as isNil2,
|
|
947
947
|
uniqBy,
|
|
948
948
|
upperFirst as upperFirst4
|
|
949
|
-
} from "lodash";
|
|
949
|
+
} from "lodash-es";
|
|
950
950
|
import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
951
951
|
import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
952
952
|
function processValue(item, value) {
|
|
@@ -1017,6 +1017,8 @@ function Table(props) {
|
|
|
1017
1017
|
item.render = (value) => processValue(item, value);
|
|
1018
1018
|
if (!item.onFilter)
|
|
1019
1019
|
item.onFilter = (value, row) => {
|
|
1020
|
+
if (value === null && isNil2(row[item.id]))
|
|
1021
|
+
return true;
|
|
1020
1022
|
if (!row[item.id])
|
|
1021
1023
|
return false;
|
|
1022
1024
|
return row[item.id].toLowerCase().includes(value.toLowerCase());
|
|
@@ -1045,6 +1047,8 @@ function Table(props) {
|
|
|
1045
1047
|
item.render = (value) => processValue(item, value);
|
|
1046
1048
|
if (!item.onFilter)
|
|
1047
1049
|
item.onFilter = (value, row) => {
|
|
1050
|
+
if (value === null && (!row[item.id] || !row[item.id].length))
|
|
1051
|
+
return true;
|
|
1048
1052
|
if (!row[item.id] || !row[item.id].length)
|
|
1049
1053
|
return false;
|
|
1050
1054
|
return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
|
|
@@ -1074,7 +1078,11 @@ function Table(props) {
|
|
|
1074
1078
|
if (!item.sorter)
|
|
1075
1079
|
item.sorter = (a, b) => a[item.id] - b[item.id];
|
|
1076
1080
|
if (!item.onFilter)
|
|
1077
|
-
item.onFilter = (value, row) =>
|
|
1081
|
+
item.onFilter = (value, row) => {
|
|
1082
|
+
if (value === null && isNil2(row[item.id]))
|
|
1083
|
+
return true;
|
|
1084
|
+
return value === row[item.id];
|
|
1085
|
+
};
|
|
1078
1086
|
if (!item.filters && item.filterDropdown !== false)
|
|
1079
1087
|
item.filterDropdown = ({
|
|
1080
1088
|
setSelectedKeys,
|
|
@@ -1098,7 +1106,13 @@ function Table(props) {
|
|
|
1098
1106
|
if (!item.render)
|
|
1099
1107
|
item.render = (value) => processValue(item, value).join(", ");
|
|
1100
1108
|
if (!item.onFilter)
|
|
1101
|
-
item.onFilter = (value, row) =>
|
|
1109
|
+
item.onFilter = (value, row) => {
|
|
1110
|
+
if (value === null && (!row[item.id] || !row[item.id].length))
|
|
1111
|
+
return true;
|
|
1112
|
+
if (!row[item.id] || !row[item.id].length)
|
|
1113
|
+
return false;
|
|
1114
|
+
return row[item.id].includes(value);
|
|
1115
|
+
};
|
|
1102
1116
|
if (!item.filters && item.filterDropdown !== false)
|
|
1103
1117
|
item.filterDropdown = ({
|
|
1104
1118
|
setSelectedKeys,
|
|
@@ -1222,7 +1236,11 @@ function Table(props) {
|
|
|
1222
1236
|
if (!item.render)
|
|
1223
1237
|
item.render = (value) => processValue(item, value);
|
|
1224
1238
|
if (!item.onFilter)
|
|
1225
|
-
item.onFilter = (value, row) =>
|
|
1239
|
+
item.onFilter = (value, row) => {
|
|
1240
|
+
if (value === null && isNil2(row[item.id]))
|
|
1241
|
+
return true;
|
|
1242
|
+
return value === row[item.id];
|
|
1243
|
+
};
|
|
1226
1244
|
break;
|
|
1227
1245
|
}
|
|
1228
1246
|
}
|
|
@@ -1239,7 +1257,10 @@ function Table(props) {
|
|
|
1239
1257
|
newColumns[index].filters = uniqBy(props.dataSource, column.id).map((v) => ({
|
|
1240
1258
|
text: v[column.id],
|
|
1241
1259
|
value: v[column.id]
|
|
1242
|
-
}))
|
|
1260
|
+
})).concat({
|
|
1261
|
+
text: /* @__PURE__ */ jsx10(Blank, {}),
|
|
1262
|
+
value: null
|
|
1263
|
+
});
|
|
1243
1264
|
return newColumns;
|
|
1244
1265
|
});
|
|
1245
1266
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "0.0.3-beta.
|
|
3
|
+
"version": "0.0.3-beta.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@ant-design/icons": "*",
|
|
27
27
|
"antd": "*",
|
|
28
|
-
"lodash": "*",
|
|
28
|
+
"lodash-es": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.3-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.3-beta.3",
|
|
32
32
|
"react-router-dom": "*",
|
|
33
33
|
"dayjs": "*"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/lodash": "*",
|
|
36
|
+
"@types/lodash-es": "*",
|
|
37
37
|
"@testing-library/jest-dom": "*",
|
|
38
38
|
"@testing-library/react": "*",
|
|
39
39
|
"@testing-library/user-event": "*"
|