@faasjs/ant-design 0.0.3-beta.2 → 0.0.3-beta.4

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 CHANGED
@@ -972,7 +972,7 @@ function processValue(item, value) {
972
972
  }
973
973
  function Table(props) {
974
974
  const [columns, setColumns] = (0, import_react11.useState)();
975
- const { common: common2 } = useConfigContext();
975
+ const { common: common2, antd } = useConfigContext();
976
976
  (0, import_react11.useEffect)(() => {
977
977
  var _a;
978
978
  for (const item of props.items) {
@@ -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) => value === row[item.id];
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) => row[item.id].includes(value);
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,
@@ -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) => value === row[item.id];
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
  }
@@ -1236,7 +1254,10 @@ function Table(props) {
1236
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
  }
@@ -1245,11 +1266,14 @@ function Table(props) {
1245
1266
  if (!columns)
1246
1267
  return null;
1247
1268
  if (!props.faasData)
1248
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1249
- ...props,
1250
- rowKey: props.rowKey || "id",
1251
- columns,
1252
- dataSource: props.dataSource
1269
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1270
+ ...antd,
1271
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1272
+ ...props,
1273
+ rowKey: props.rowKey || "id",
1274
+ columns,
1275
+ dataSource: props.dataSource
1276
+ })
1253
1277
  });
1254
1278
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react12.FaasDataWrapper, {
1255
1279
  fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Skeleton, {
@@ -1261,46 +1285,55 @@ function Table(props) {
1261
1285
  reload
1262
1286
  }) => {
1263
1287
  if (!data)
1264
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1265
- ...props,
1266
- rowKey: props.rowKey || "id",
1267
- columns,
1268
- dataSource: []
1288
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1289
+ ...antd,
1290
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1291
+ ...props,
1292
+ rowKey: props.rowKey || "id",
1293
+ columns,
1294
+ dataSource: []
1295
+ })
1269
1296
  });
1270
1297
  if (Array.isArray(data))
1271
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1298
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1299
+ ...antd,
1300
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1301
+ ...props,
1302
+ rowKey: props.rowKey || "id",
1303
+ columns,
1304
+ dataSource: data
1305
+ })
1306
+ });
1307
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1308
+ ...antd,
1309
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1272
1310
  ...props,
1273
1311
  rowKey: props.rowKey || "id",
1274
1312
  columns,
1275
- dataSource: data
1276
- });
1277
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1278
- ...props,
1279
- rowKey: props.rowKey || "id",
1280
- columns,
1281
- dataSource: data.rows,
1282
- pagination: {
1283
- ...props.pagination,
1284
- ...data.pagination
1285
- },
1286
- onChange: (pagination, filters, sorter, extra) => {
1287
- if (props.onChange) {
1288
- const processed = props.onChange(pagination, filters, sorter, extra);
1313
+ dataSource: data.rows,
1314
+ pagination: {
1315
+ ...props.pagination,
1316
+ ...data.pagination
1317
+ },
1318
+ onChange: (pagination, filters, sorter, extra) => {
1319
+ if (props.onChange) {
1320
+ const processed = props.onChange(pagination, filters, sorter, extra);
1321
+ reload({
1322
+ ...params,
1323
+ pagination: processed.pagination,
1324
+ filters: processed.filters,
1325
+ sorter: processed.sorter
1326
+ });
1327
+ return;
1328
+ }
1289
1329
  reload({
1290
1330
  ...params,
1291
- pagination: processed.pagination,
1292
- filters: processed.filters,
1293
- sorter: processed.sorter
1331
+ pagination,
1332
+ filters,
1333
+ sorter
1294
1334
  });
1295
- return;
1296
1335
  }
1297
- reload({
1298
- ...params,
1299
- pagination,
1300
- filters,
1301
- sorter
1302
- });
1303
- }
1336
+ })
1304
1337
  });
1305
1338
  },
1306
1339
  ...props.faasData
package/dist/index.mjs CHANGED
@@ -938,7 +938,8 @@ import {
938
938
  Table as AntdTable,
939
939
  Radio,
940
940
  Skeleton as Skeleton3,
941
- Input as Input2
941
+ Input as Input2,
942
+ ConfigProvider as ConfigProvider2
942
943
  } from "antd";
943
944
  import dayjs2 from "dayjs";
944
945
  import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
@@ -975,7 +976,7 @@ function processValue(item, value) {
975
976
  }
976
977
  function Table(props) {
977
978
  const [columns, setColumns] = useState7();
978
- const { common: common2 } = useConfigContext();
979
+ const { common: common2, antd } = useConfigContext();
979
980
  useEffect5(() => {
980
981
  var _a;
981
982
  for (const item of props.items) {
@@ -1017,6 +1018,8 @@ function Table(props) {
1017
1018
  item.render = (value) => processValue(item, value);
1018
1019
  if (!item.onFilter)
1019
1020
  item.onFilter = (value, row) => {
1021
+ if (value === null && isNil2(row[item.id]))
1022
+ return true;
1020
1023
  if (!row[item.id])
1021
1024
  return false;
1022
1025
  return row[item.id].toLowerCase().includes(value.toLowerCase());
@@ -1045,6 +1048,8 @@ function Table(props) {
1045
1048
  item.render = (value) => processValue(item, value);
1046
1049
  if (!item.onFilter)
1047
1050
  item.onFilter = (value, row) => {
1051
+ if (value === null && (!row[item.id] || !row[item.id].length))
1052
+ return true;
1048
1053
  if (!row[item.id] || !row[item.id].length)
1049
1054
  return false;
1050
1055
  return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
@@ -1074,7 +1079,11 @@ function Table(props) {
1074
1079
  if (!item.sorter)
1075
1080
  item.sorter = (a, b) => a[item.id] - b[item.id];
1076
1081
  if (!item.onFilter)
1077
- item.onFilter = (value, row) => value === row[item.id];
1082
+ item.onFilter = (value, row) => {
1083
+ if (value === null && isNil2(row[item.id]))
1084
+ return true;
1085
+ return value === row[item.id];
1086
+ };
1078
1087
  if (!item.filters && item.filterDropdown !== false)
1079
1088
  item.filterDropdown = ({
1080
1089
  setSelectedKeys,
@@ -1098,7 +1107,13 @@ function Table(props) {
1098
1107
  if (!item.render)
1099
1108
  item.render = (value) => processValue(item, value).join(", ");
1100
1109
  if (!item.onFilter)
1101
- item.onFilter = (value, row) => row[item.id].includes(value);
1110
+ item.onFilter = (value, row) => {
1111
+ if (value === null && (!row[item.id] || !row[item.id].length))
1112
+ return true;
1113
+ if (!row[item.id] || !row[item.id].length)
1114
+ return false;
1115
+ return row[item.id].includes(value);
1116
+ };
1102
1117
  if (!item.filters && item.filterDropdown !== false)
1103
1118
  item.filterDropdown = ({
1104
1119
  setSelectedKeys,
@@ -1222,7 +1237,11 @@ function Table(props) {
1222
1237
  if (!item.render)
1223
1238
  item.render = (value) => processValue(item, value);
1224
1239
  if (!item.onFilter)
1225
- item.onFilter = (value, row) => value === row[item.id];
1240
+ item.onFilter = (value, row) => {
1241
+ if (value === null && isNil2(row[item.id]))
1242
+ return true;
1243
+ return value === row[item.id];
1244
+ };
1226
1245
  break;
1227
1246
  }
1228
1247
  }
@@ -1239,7 +1258,10 @@ function Table(props) {
1239
1258
  newColumns[index].filters = uniqBy(props.dataSource, column.id).map((v) => ({
1240
1259
  text: v[column.id],
1241
1260
  value: v[column.id]
1242
- }));
1261
+ })).concat({
1262
+ text: /* @__PURE__ */ jsx10(Blank, {}),
1263
+ value: null
1264
+ });
1243
1265
  return newColumns;
1244
1266
  });
1245
1267
  }
@@ -1248,11 +1270,14 @@ function Table(props) {
1248
1270
  if (!columns)
1249
1271
  return null;
1250
1272
  if (!props.faasData)
1251
- return /* @__PURE__ */ jsx10(AntdTable, {
1252
- ...props,
1253
- rowKey: props.rowKey || "id",
1254
- columns,
1255
- dataSource: props.dataSource
1273
+ return /* @__PURE__ */ jsx10(ConfigProvider2, {
1274
+ ...antd,
1275
+ children: /* @__PURE__ */ jsx10(AntdTable, {
1276
+ ...props,
1277
+ rowKey: props.rowKey || "id",
1278
+ columns,
1279
+ dataSource: props.dataSource
1280
+ })
1256
1281
  });
1257
1282
  return /* @__PURE__ */ jsx10(FaasDataWrapper2, {
1258
1283
  fallback: props.faasData.fallback || /* @__PURE__ */ jsx10(Skeleton3, {
@@ -1264,46 +1289,55 @@ function Table(props) {
1264
1289
  reload
1265
1290
  }) => {
1266
1291
  if (!data)
1267
- return /* @__PURE__ */ jsx10(AntdTable, {
1268
- ...props,
1269
- rowKey: props.rowKey || "id",
1270
- columns,
1271
- dataSource: []
1292
+ return /* @__PURE__ */ jsx10(ConfigProvider2, {
1293
+ ...antd,
1294
+ children: /* @__PURE__ */ jsx10(AntdTable, {
1295
+ ...props,
1296
+ rowKey: props.rowKey || "id",
1297
+ columns,
1298
+ dataSource: []
1299
+ })
1272
1300
  });
1273
1301
  if (Array.isArray(data))
1274
- return /* @__PURE__ */ jsx10(AntdTable, {
1302
+ return /* @__PURE__ */ jsx10(ConfigProvider2, {
1303
+ ...antd,
1304
+ children: /* @__PURE__ */ jsx10(AntdTable, {
1305
+ ...props,
1306
+ rowKey: props.rowKey || "id",
1307
+ columns,
1308
+ dataSource: data
1309
+ })
1310
+ });
1311
+ return /* @__PURE__ */ jsx10(ConfigProvider2, {
1312
+ ...antd,
1313
+ children: /* @__PURE__ */ jsx10(AntdTable, {
1275
1314
  ...props,
1276
1315
  rowKey: props.rowKey || "id",
1277
1316
  columns,
1278
- dataSource: data
1279
- });
1280
- return /* @__PURE__ */ jsx10(AntdTable, {
1281
- ...props,
1282
- rowKey: props.rowKey || "id",
1283
- columns,
1284
- dataSource: data.rows,
1285
- pagination: {
1286
- ...props.pagination,
1287
- ...data.pagination
1288
- },
1289
- onChange: (pagination, filters, sorter, extra) => {
1290
- if (props.onChange) {
1291
- const processed = props.onChange(pagination, filters, sorter, extra);
1317
+ dataSource: data.rows,
1318
+ pagination: {
1319
+ ...props.pagination,
1320
+ ...data.pagination
1321
+ },
1322
+ onChange: (pagination, filters, sorter, extra) => {
1323
+ if (props.onChange) {
1324
+ const processed = props.onChange(pagination, filters, sorter, extra);
1325
+ reload({
1326
+ ...params,
1327
+ pagination: processed.pagination,
1328
+ filters: processed.filters,
1329
+ sorter: processed.sorter
1330
+ });
1331
+ return;
1332
+ }
1292
1333
  reload({
1293
1334
  ...params,
1294
- pagination: processed.pagination,
1295
- filters: processed.filters,
1296
- sorter: processed.sorter
1335
+ pagination,
1336
+ filters,
1337
+ sorter
1297
1338
  });
1298
- return;
1299
1339
  }
1300
- reload({
1301
- ...params,
1302
- pagination,
1303
- filters,
1304
- sorter
1305
- });
1306
- }
1340
+ })
1307
1341
  });
1308
1342
  },
1309
1343
  ...props.faasData
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.3-beta.2",
3
+ "version": "0.0.3-beta.4",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,7 +28,7 @@
28
28
  "lodash-es": "*",
29
29
  "react": "*",
30
30
  "react-dom": "*",
31
- "@faasjs/react": "^0.0.3-beta.2",
31
+ "@faasjs/react": "^0.0.3-beta.4",
32
32
  "react-router-dom": "*",
33
33
  "dayjs": "*"
34
34
  },