@faasjs/ant-design 0.0.2-beta.416 → 0.0.2-beta.418

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 CHANGED
@@ -145,6 +145,7 @@ declare type DescriptionItemProps<T = any> = {
145
145
  render?: (value: T, values: any) => JSX.Element | string | number | boolean | null;
146
146
  } & FaasItemProps;
147
147
  declare type DescriptionProps<T = any, ExtendItemProps = any> = {
148
+ title?: ReactNode | ((values: T) => ReactNode);
148
149
  items: (DescriptionItemProps | ExtendItemProps)[];
149
150
  extendTypes?: {
150
151
  [key: string]: ExtendDescriptionTypeProps;
package/dist/index.js CHANGED
@@ -220,7 +220,7 @@ function DescriptionItemContent(props) {
220
220
  children: computedProps.item.render(computedProps.value, computedProps.values)
221
221
  });
222
222
  if (typeof computedProps.value === "undefined" || computedProps.value === null)
223
- return null;
223
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Blank, {});
224
224
  switch (computedProps.item.type) {
225
225
  case "string[]":
226
226
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {
@@ -274,18 +274,21 @@ function Description(props) {
274
274
  fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Skeleton, {
275
275
  active: true
276
276
  }),
277
- render: ({ data }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, {
278
- ...props,
279
- children: props.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions.Item, {
280
- label: item.title || (0, import_lodash4.upperFirst)(item.id),
281
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DescriptionItemContent, {
282
- item,
283
- value: data[item.id],
284
- values: data,
285
- extendTypes: props.extendTypes
286
- })
287
- }, item.id))
288
- }),
277
+ render: ({ data }) => {
278
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, {
279
+ ...props,
280
+ title: (0, import_lodash4.isFunction)(props.title) ? props.title(data) : props.title,
281
+ children: props.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions.Item, {
282
+ label: item.title || (0, import_lodash4.upperFirst)(item.id),
283
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DescriptionItemContent, {
284
+ item,
285
+ value: data[item.id],
286
+ values: data,
287
+ extendTypes: props.extendTypes
288
+ })
289
+ }, item.id))
290
+ });
291
+ },
289
292
  ...props.faasData
290
293
  });
291
294
  }
@@ -904,7 +907,7 @@ var import_jsx_runtime11 = require("react/jsx-runtime");
904
907
  function processValue(item, value) {
905
908
  var _a;
906
909
  if (typeof value === "undefined" && value === null)
907
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Empty, {});
910
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Blank, {});
908
911
  if (item.options) {
909
912
  if (item.type.endsWith("[]"))
910
913
  return value.map((v) => {
@@ -968,7 +971,11 @@ function Table(props) {
968
971
  if (!item.render)
969
972
  item.render = (value) => processValue(item, value);
970
973
  if (!item.onFilter) {
971
- item.onFilter = (value, row) => row[item.id].includes(value);
974
+ item.onFilter = (value, row) => {
975
+ if (!row[item.id])
976
+ return false;
977
+ return row[item.id].includes(value);
978
+ };
972
979
  }
973
980
  if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
974
981
  item.filterDropdown = ({
@@ -976,75 +983,49 @@ function Table(props) {
976
983
  selectedKeys,
977
984
  confirm,
978
985
  clearFilters
979
- }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", {
980
- style: { padding: 8 },
981
- children: [
982
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", {
983
- value: selectedKeys[0],
984
- onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
985
- style: {
986
- width: 188,
987
- marginBottom: 8,
988
- display: "block"
989
- }
990
- }),
991
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", {
992
- type: "button",
993
- onClick: () => confirm(),
994
- style: {
995
- width: 90,
996
- marginRight: 8
997
- },
998
- children: common2.search
999
- }),
1000
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", {
1001
- type: "button",
1002
- onClick: () => clearFilters(),
1003
- style: { width: 90 },
1004
- children: common2.reset
1005
- })
1006
- ]
986
+ }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Input.Search, {
987
+ placeholder: `${common2.search} ${item.title}`,
988
+ value: selectedKeys[0],
989
+ allowClear: true,
990
+ onSearch: (v) => {
991
+ if (v) {
992
+ setSelectedKeys([v]);
993
+ } else {
994
+ setSelectedKeys([]);
995
+ clearFilters();
996
+ }
997
+ confirm();
998
+ }
1007
999
  });
1008
1000
  break;
1009
1001
  case "string[]":
1010
1002
  if (!item.render)
1011
1003
  item.render = (value) => processValue(item, value).join(", ");
1012
1004
  if (!item.onFilter)
1013
- item.onFilter = (value, row) => row[item.id].includes(value);
1005
+ item.onFilter = (value, row) => {
1006
+ if (!row[item.id] || !row[item.id].length)
1007
+ return false;
1008
+ return row[item.id].some((v) => v.includes(value));
1009
+ };
1014
1010
  if (!item.filters && item.filterDropdown !== false)
1015
1011
  item.filterDropdown = ({
1016
1012
  setSelectedKeys,
1017
1013
  selectedKeys,
1018
1014
  confirm,
1019
1015
  clearFilters
1020
- }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", {
1021
- style: { padding: 8 },
1022
- children: [
1023
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", {
1024
- value: selectedKeys[0],
1025
- onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
1026
- style: {
1027
- width: 188,
1028
- marginBottom: 8,
1029
- display: "block"
1030
- }
1031
- }),
1032
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", {
1033
- type: "button",
1034
- onClick: () => confirm(),
1035
- style: {
1036
- width: 90,
1037
- marginRight: 8
1038
- },
1039
- children: common2.search
1040
- }),
1041
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", {
1042
- type: "button",
1043
- onClick: () => clearFilters(),
1044
- style: { width: 90 },
1045
- children: common2.reset
1046
- })
1047
- ]
1016
+ }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Input.Search, {
1017
+ placeholder: `${common2.search} ${item.title}`,
1018
+ value: selectedKeys[0],
1019
+ allowClear: true,
1020
+ onSearch: (v) => {
1021
+ if (v) {
1022
+ setSelectedKeys([v]);
1023
+ } else {
1024
+ setSelectedKeys([]);
1025
+ clearFilters();
1026
+ }
1027
+ confirm();
1028
+ }
1048
1029
  });
1049
1030
  break;
1050
1031
  case "number":
@@ -1060,34 +1041,19 @@ function Table(props) {
1060
1041
  selectedKeys,
1061
1042
  confirm,
1062
1043
  clearFilters
1063
- }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", {
1064
- style: { padding: 8 },
1065
- children: [
1066
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", {
1067
- value: selectedKeys[0],
1068
- onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
1069
- style: {
1070
- width: 188,
1071
- marginBottom: 8,
1072
- display: "block"
1073
- }
1074
- }),
1075
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", {
1076
- type: "button",
1077
- onClick: () => confirm(),
1078
- style: {
1079
- width: 90,
1080
- marginRight: 8
1081
- },
1082
- children: common2.search
1083
- }),
1084
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", {
1085
- type: "button",
1086
- onClick: () => clearFilters(),
1087
- style: { width: 90 },
1088
- children: common2.reset
1089
- })
1090
- ]
1044
+ }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Input.Search, {
1045
+ placeholder: `${common2.search} ${item.title}`,
1046
+ value: selectedKeys[0],
1047
+ allowClear: true,
1048
+ onSearch: (v) => {
1049
+ if (v) {
1050
+ setSelectedKeys([Number(v)]);
1051
+ } else {
1052
+ setSelectedKeys([]);
1053
+ clearFilters();
1054
+ }
1055
+ confirm();
1056
+ }
1091
1057
  });
1092
1058
  break;
1093
1059
  case "number[]":
@@ -1101,34 +1067,19 @@ function Table(props) {
1101
1067
  selectedKeys,
1102
1068
  confirm,
1103
1069
  clearFilters
1104
- }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", {
1105
- style: { padding: 8 },
1106
- children: [
1107
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", {
1108
- value: selectedKeys[0],
1109
- onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
1110
- style: {
1111
- width: 188,
1112
- marginBottom: 8,
1113
- display: "block"
1114
- }
1115
- }),
1116
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", {
1117
- type: "button",
1118
- onClick: () => confirm(),
1119
- style: {
1120
- width: 90,
1121
- marginRight: 8
1122
- },
1123
- children: common2.search
1124
- }),
1125
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", {
1126
- type: "button",
1127
- onClick: () => clearFilters(),
1128
- style: { width: 90 },
1129
- children: common2.reset
1130
- })
1131
- ]
1070
+ }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Input.Search, {
1071
+ placeholder: `${common2.search} ${item.title}`,
1072
+ value: selectedKeys[0],
1073
+ allowClear: true,
1074
+ onSearch: (v) => {
1075
+ if (v) {
1076
+ setSelectedKeys([Number(v)]);
1077
+ } else {
1078
+ setSelectedKeys([]);
1079
+ clearFilters();
1080
+ }
1081
+ confirm();
1082
+ }
1132
1083
  });
1133
1084
  break;
1134
1085
  case "boolean":
package/dist/index.mjs CHANGED
@@ -121,7 +121,7 @@ import {
121
121
  Descriptions,
122
122
  Skeleton
123
123
  } from "antd";
124
- import { upperFirst as upperFirst2 } from "lodash";
124
+ import { isFunction, upperFirst as upperFirst2 } from "lodash";
125
125
  import {
126
126
  cloneElement,
127
127
  useEffect as useEffect2,
@@ -181,7 +181,7 @@ function DescriptionItemContent(props) {
181
181
  children: computedProps.item.render(computedProps.value, computedProps.values)
182
182
  });
183
183
  if (typeof computedProps.value === "undefined" || computedProps.value === null)
184
- return null;
184
+ return /* @__PURE__ */ jsx3(Blank, {});
185
185
  switch (computedProps.item.type) {
186
186
  case "string[]":
187
187
  return /* @__PURE__ */ jsx3(Fragment, {
@@ -235,18 +235,21 @@ function Description(props) {
235
235
  fallback: props.faasData.fallback || /* @__PURE__ */ jsx3(Skeleton, {
236
236
  active: true
237
237
  }),
238
- render: ({ data }) => /* @__PURE__ */ jsx3(Descriptions, {
239
- ...props,
240
- children: props.items.map((item) => /* @__PURE__ */ jsx3(Descriptions.Item, {
241
- label: item.title || upperFirst2(item.id),
242
- children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
243
- item,
244
- value: data[item.id],
245
- values: data,
246
- extendTypes: props.extendTypes
247
- })
248
- }, item.id))
249
- }),
238
+ render: ({ data }) => {
239
+ return /* @__PURE__ */ jsx3(Descriptions, {
240
+ ...props,
241
+ title: isFunction(props.title) ? props.title(data) : props.title,
242
+ children: props.items.map((item) => /* @__PURE__ */ jsx3(Descriptions.Item, {
243
+ label: item.title || upperFirst2(item.id),
244
+ children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
245
+ item,
246
+ value: data[item.id],
247
+ values: data,
248
+ extendTypes: props.extendTypes
249
+ })
250
+ }, item.id))
251
+ });
252
+ },
250
253
  ...props.faasData
251
254
  });
252
255
  }
@@ -884,7 +887,7 @@ import {
884
887
  Table as AntdTable,
885
888
  Radio,
886
889
  Skeleton as Skeleton3,
887
- Empty
890
+ Input as Input2
888
891
  } from "antd";
889
892
  import dayjs3 from "dayjs";
890
893
  import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
@@ -898,7 +901,7 @@ import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
898
901
  function processValue(item, value) {
899
902
  var _a;
900
903
  if (typeof value === "undefined" && value === null)
901
- return /* @__PURE__ */ jsx11(Empty, {});
904
+ return /* @__PURE__ */ jsx11(Blank, {});
902
905
  if (item.options) {
903
906
  if (item.type.endsWith("[]"))
904
907
  return value.map((v) => {
@@ -962,7 +965,11 @@ function Table(props) {
962
965
  if (!item.render)
963
966
  item.render = (value) => processValue(item, value);
964
967
  if (!item.onFilter) {
965
- item.onFilter = (value, row) => row[item.id].includes(value);
968
+ item.onFilter = (value, row) => {
969
+ if (!row[item.id])
970
+ return false;
971
+ return row[item.id].includes(value);
972
+ };
966
973
  }
967
974
  if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
968
975
  item.filterDropdown = ({
@@ -970,75 +977,49 @@ function Table(props) {
970
977
  selectedKeys,
971
978
  confirm,
972
979
  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
- ]
980
+ }) => /* @__PURE__ */ jsx11(Input2.Search, {
981
+ placeholder: `${common2.search} ${item.title}`,
982
+ value: selectedKeys[0],
983
+ allowClear: true,
984
+ onSearch: (v) => {
985
+ if (v) {
986
+ setSelectedKeys([v]);
987
+ } else {
988
+ setSelectedKeys([]);
989
+ clearFilters();
990
+ }
991
+ confirm();
992
+ }
1001
993
  });
1002
994
  break;
1003
995
  case "string[]":
1004
996
  if (!item.render)
1005
997
  item.render = (value) => processValue(item, value).join(", ");
1006
998
  if (!item.onFilter)
1007
- item.onFilter = (value, row) => row[item.id].includes(value);
999
+ item.onFilter = (value, row) => {
1000
+ if (!row[item.id] || !row[item.id].length)
1001
+ return false;
1002
+ return row[item.id].some((v) => v.includes(value));
1003
+ };
1008
1004
  if (!item.filters && item.filterDropdown !== false)
1009
1005
  item.filterDropdown = ({
1010
1006
  setSelectedKeys,
1011
1007
  selectedKeys,
1012
1008
  confirm,
1013
1009
  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
- ]
1010
+ }) => /* @__PURE__ */ jsx11(Input2.Search, {
1011
+ placeholder: `${common2.search} ${item.title}`,
1012
+ value: selectedKeys[0],
1013
+ allowClear: true,
1014
+ onSearch: (v) => {
1015
+ if (v) {
1016
+ setSelectedKeys([v]);
1017
+ } else {
1018
+ setSelectedKeys([]);
1019
+ clearFilters();
1020
+ }
1021
+ confirm();
1022
+ }
1042
1023
  });
1043
1024
  break;
1044
1025
  case "number":
@@ -1054,34 +1035,19 @@ function Table(props) {
1054
1035
  selectedKeys,
1055
1036
  confirm,
1056
1037
  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
- ]
1038
+ }) => /* @__PURE__ */ jsx11(Input2.Search, {
1039
+ placeholder: `${common2.search} ${item.title}`,
1040
+ value: selectedKeys[0],
1041
+ allowClear: true,
1042
+ onSearch: (v) => {
1043
+ if (v) {
1044
+ setSelectedKeys([Number(v)]);
1045
+ } else {
1046
+ setSelectedKeys([]);
1047
+ clearFilters();
1048
+ }
1049
+ confirm();
1050
+ }
1085
1051
  });
1086
1052
  break;
1087
1053
  case "number[]":
@@ -1095,34 +1061,19 @@ function Table(props) {
1095
1061
  selectedKeys,
1096
1062
  confirm,
1097
1063
  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
- ]
1064
+ }) => /* @__PURE__ */ jsx11(Input2.Search, {
1065
+ placeholder: `${common2.search} ${item.title}`,
1066
+ value: selectedKeys[0],
1067
+ allowClear: true,
1068
+ onSearch: (v) => {
1069
+ if (v) {
1070
+ setSelectedKeys([Number(v)]);
1071
+ } else {
1072
+ setSelectedKeys([]);
1073
+ clearFilters();
1074
+ }
1075
+ confirm();
1076
+ }
1126
1077
  });
1127
1078
  break;
1128
1079
  case "boolean":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.2-beta.416",
3
+ "version": "0.0.2-beta.418",
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.416",
31
+ "@faasjs/react": "^0.0.2-beta.418",
32
32
  "react-router-dom": "*",
33
33
  "dayjs": "*"
34
34
  },