@faasjs/ant-design 0.0.2-beta.417 → 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,13 +145,13 @@ 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;
151
152
  };
152
153
  dataSource?: T;
153
154
  faasData?: FaasDataWrapperProps<T>;
154
- footer?: (values: T) => JSX.Element;
155
155
  } & DescriptionsProps;
156
156
  declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
157
157
 
package/dist/index.js CHANGED
@@ -258,29 +258,27 @@ function DescriptionItemContent(props) {
258
258
  }
259
259
  function Description(props) {
260
260
  if (!props.faasData)
261
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_antd3.Descriptions, {
261
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, {
262
262
  ...props,
263
- children: [
264
- props.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions.Item, {
265
- label: item.title || (0, import_lodash4.upperFirst)(item.id),
266
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DescriptionItemContent, {
267
- item,
268
- value: props.dataSource[item.id],
269
- values: props.dataSource,
270
- extendTypes: props.extendTypes
271
- })
272
- }, item.id)),
273
- props.footer && props.footer(props.dataSource)
274
- ]
263
+ children: props.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions.Item, {
264
+ label: item.title || (0, import_lodash4.upperFirst)(item.id),
265
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DescriptionItemContent, {
266
+ item,
267
+ value: props.dataSource[item.id],
268
+ values: props.dataSource,
269
+ extendTypes: props.extendTypes
270
+ })
271
+ }, item.id))
275
272
  });
276
273
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.FaasDataWrapper, {
277
274
  fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Skeleton, {
278
275
  active: true
279
276
  }),
280
- render: ({ data }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_antd3.Descriptions, {
281
- ...props,
282
- children: [
283
- props.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions.Item, {
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, {
284
282
  label: item.title || (0, import_lodash4.upperFirst)(item.id),
285
283
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DescriptionItemContent, {
286
284
  item,
@@ -288,10 +286,9 @@ function Description(props) {
288
286
  values: data,
289
287
  extendTypes: props.extendTypes
290
288
  })
291
- }, item.id)),
292
- props.footer && props.footer(data)
293
- ]
294
- }),
289
+ }, item.id))
290
+ });
291
+ },
295
292
  ...props.faasData
296
293
  });
297
294
  }
@@ -974,7 +971,11 @@ function Table(props) {
974
971
  if (!item.render)
975
972
  item.render = (value) => processValue(item, value);
976
973
  if (!item.onFilter) {
977
- 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
+ };
978
979
  }
979
980
  if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
980
981
  item.filterDropdown = ({
@@ -1001,7 +1002,11 @@ function Table(props) {
1001
1002
  if (!item.render)
1002
1003
  item.render = (value) => processValue(item, value).join(", ");
1003
1004
  if (!item.onFilter)
1004
- 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
+ };
1005
1010
  if (!item.filters && item.filterDropdown !== false)
1006
1011
  item.filterDropdown = ({
1007
1012
  setSelectedKeys,
@@ -1042,7 +1047,7 @@ function Table(props) {
1042
1047
  allowClear: true,
1043
1048
  onSearch: (v) => {
1044
1049
  if (v) {
1045
- setSelectedKeys([v]);
1050
+ setSelectedKeys([Number(v)]);
1046
1051
  } else {
1047
1052
  setSelectedKeys([]);
1048
1053
  clearFilters();
@@ -1068,7 +1073,7 @@ function Table(props) {
1068
1073
  allowClear: true,
1069
1074
  onSearch: (v) => {
1070
1075
  if (v) {
1071
- setSelectedKeys([v]);
1076
+ setSelectedKeys([Number(v)]);
1072
1077
  } else {
1073
1078
  setSelectedKeys([]);
1074
1079
  clearFilters();
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,
@@ -129,7 +129,7 @@ import {
129
129
  } from "react";
130
130
  import dayjs from "dayjs";
131
131
  import { FaasDataWrapper } from "@faasjs/react";
132
- import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
132
+ import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
133
133
  function DescriptionItemContent(props) {
134
134
  const [computedProps, setComputedProps] = useState2();
135
135
  useEffect2(() => {
@@ -219,29 +219,27 @@ function DescriptionItemContent(props) {
219
219
  }
220
220
  function Description(props) {
221
221
  if (!props.faasData)
222
- return /* @__PURE__ */ jsxs(Descriptions, {
222
+ return /* @__PURE__ */ jsx3(Descriptions, {
223
223
  ...props,
224
- children: [
225
- props.items.map((item) => /* @__PURE__ */ jsx3(Descriptions.Item, {
226
- label: item.title || upperFirst2(item.id),
227
- children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
228
- item,
229
- value: props.dataSource[item.id],
230
- values: props.dataSource,
231
- extendTypes: props.extendTypes
232
- })
233
- }, item.id)),
234
- props.footer && props.footer(props.dataSource)
235
- ]
224
+ children: props.items.map((item) => /* @__PURE__ */ jsx3(Descriptions.Item, {
225
+ label: item.title || upperFirst2(item.id),
226
+ children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
227
+ item,
228
+ value: props.dataSource[item.id],
229
+ values: props.dataSource,
230
+ extendTypes: props.extendTypes
231
+ })
232
+ }, item.id))
236
233
  });
237
234
  return /* @__PURE__ */ jsx3(FaasDataWrapper, {
238
235
  fallback: props.faasData.fallback || /* @__PURE__ */ jsx3(Skeleton, {
239
236
  active: true
240
237
  }),
241
- render: ({ data }) => /* @__PURE__ */ jsxs(Descriptions, {
242
- ...props,
243
- children: [
244
- props.items.map((item) => /* @__PURE__ */ jsx3(Descriptions.Item, {
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, {
245
243
  label: item.title || upperFirst2(item.id),
246
244
  children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
247
245
  item,
@@ -249,10 +247,9 @@ function Description(props) {
249
247
  values: data,
250
248
  extendTypes: props.extendTypes
251
249
  })
252
- }, item.id)),
253
- props.footer && props.footer(data)
254
- ]
255
- }),
250
+ }, item.id))
251
+ });
252
+ },
256
253
  ...props.faasData
257
254
  });
258
255
  }
@@ -325,7 +322,7 @@ TimePicker.displayName = "TimePicker";
325
322
 
326
323
  // src/FormItem.tsx
327
324
  import dayjs2, { isDayjs } from "dayjs";
328
- import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
325
+ import { Fragment as Fragment2, jsx as jsx6, jsxs } from "react/jsx-runtime";
329
326
  function processProps(propsCopy, config) {
330
327
  if (!propsCopy.title)
331
328
  propsCopy.title = upperFirst3(propsCopy.id);
@@ -446,7 +443,7 @@ function FormItem(props) {
446
443
  rules: computedProps.rules,
447
444
  children: (fields, { add, remove }, { errors }) => {
448
445
  var _a2;
449
- return /* @__PURE__ */ jsxs2(Fragment2, {
446
+ return /* @__PURE__ */ jsxs(Fragment2, {
450
447
  children: [
451
448
  computedProps.label && /* @__PURE__ */ jsx6("div", {
452
449
  className: "ant-form-item-label",
@@ -458,7 +455,7 @@ function FormItem(props) {
458
455
  fields.map((field) => {
459
456
  var _a3;
460
457
  return /* @__PURE__ */ jsx6(AntdForm.Item, {
461
- children: /* @__PURE__ */ jsxs2(Row, {
458
+ children: /* @__PURE__ */ jsxs(Row, {
462
459
  gutter: 24,
463
460
  style: { flexFlow: "row nowrap" },
464
461
  children: [
@@ -486,7 +483,7 @@ function FormItem(props) {
486
483
  })
487
484
  }, field.key);
488
485
  }),
489
- /* @__PURE__ */ jsxs2(AntdForm.Item, {
486
+ /* @__PURE__ */ jsxs(AntdForm.Item, {
490
487
  children: [
491
488
  !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx6(Button, {
492
489
  type: "dashed",
@@ -527,7 +524,7 @@ function FormItem(props) {
527
524
  rules: computedProps.rules,
528
525
  children: (fields, { add, remove }, { errors }) => {
529
526
  var _a2, _b;
530
- return /* @__PURE__ */ jsxs2(Fragment2, {
527
+ return /* @__PURE__ */ jsxs(Fragment2, {
531
528
  children: [
532
529
  computedProps.label && /* @__PURE__ */ jsx6("div", {
533
530
  className: "ant-form-item-label",
@@ -539,7 +536,7 @@ function FormItem(props) {
539
536
  fields.map((field) => {
540
537
  var _a3;
541
538
  return /* @__PURE__ */ jsx6(AntdForm.Item, {
542
- children: /* @__PURE__ */ jsxs2(Row, {
539
+ children: /* @__PURE__ */ jsxs(Row, {
543
540
  gutter: 24,
544
541
  style: { flexFlow: "row nowrap" },
545
542
  children: [
@@ -568,7 +565,7 @@ function FormItem(props) {
568
565
  })
569
566
  }, field.key);
570
567
  }),
571
- /* @__PURE__ */ jsxs2(AntdForm.Item, {
568
+ /* @__PURE__ */ jsxs(AntdForm.Item, {
572
569
  children: [
573
570
  !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx6(Button, {
574
571
  type: "dashed",
@@ -607,7 +604,7 @@ function FormItem(props) {
607
604
  })
608
605
  });
609
606
  case "object":
610
- return /* @__PURE__ */ jsxs2(Fragment2, {
607
+ return /* @__PURE__ */ jsxs(Fragment2, {
611
608
  children: [
612
609
  computedProps.label && /* @__PURE__ */ jsx6("div", {
613
610
  className: "ant-form-item-label",
@@ -625,14 +622,14 @@ function FormItem(props) {
625
622
  return /* @__PURE__ */ jsx6(AntdForm.List, {
626
623
  name: computedProps.name,
627
624
  rules: computedProps.rules,
628
- children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs2(Fragment2, {
625
+ children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(Fragment2, {
629
626
  children: [
630
- fields.map((field) => /* @__PURE__ */ jsxs2(AntdForm.Item, {
627
+ fields.map((field) => /* @__PURE__ */ jsxs(AntdForm.Item, {
631
628
  style: { marginBottom: 0 },
632
629
  children: [
633
630
  /* @__PURE__ */ jsx6("div", {
634
631
  className: "ant-form-item-label",
635
- children: /* @__PURE__ */ jsxs2("label", {
632
+ children: /* @__PURE__ */ jsxs("label", {
636
633
  children: [
637
634
  computedProps.label,
638
635
  " ",
@@ -658,9 +655,9 @@ function FormItem(props) {
658
655
  })
659
656
  ]
660
657
  }, field.key)),
661
- /* @__PURE__ */ jsxs2(AntdForm.Item, {
658
+ /* @__PURE__ */ jsxs(AntdForm.Item, {
662
659
  children: [
663
- !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxs2(Button, {
660
+ !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxs(Button, {
664
661
  type: "dashed",
665
662
  block: true,
666
663
  onClick: () => add(),
@@ -685,7 +682,7 @@ function FormItem(props) {
685
682
  }
686
683
 
687
684
  // src/Form.tsx
688
- import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
685
+ import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
689
686
  function Form(props) {
690
687
  var _a, _b;
691
688
  const [loading, setLoading] = useState5(false);
@@ -729,7 +726,7 @@ function Form(props) {
729
726
  }, []);
730
727
  if (!computedProps)
731
728
  return null;
732
- return /* @__PURE__ */ jsxs3(AntdForm2, {
729
+ return /* @__PURE__ */ jsxs2(AntdForm2, {
733
730
  ...computedProps,
734
731
  children: [
735
732
  computedProps.beforeItems,
@@ -849,7 +846,7 @@ import {
849
846
  Routes as OriginRoutes,
850
847
  Route
851
848
  } from "react-router-dom";
852
- import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
849
+ import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
853
850
  function PageNotFound() {
854
851
  const config = useConfigContext();
855
852
  return /* @__PURE__ */ jsx10(Result, {
@@ -858,7 +855,7 @@ function PageNotFound() {
858
855
  });
859
856
  }
860
857
  function Routes(props) {
861
- return /* @__PURE__ */ jsxs4(OriginRoutes, {
858
+ return /* @__PURE__ */ jsxs3(OriginRoutes, {
862
859
  children: [
863
860
  props.routes.map((r) => /* @__PURE__ */ jsx10(Route, {
864
861
  ...r,
@@ -900,7 +897,7 @@ import {
900
897
  upperFirst as upperFirst4
901
898
  } from "lodash";
902
899
  import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
903
- import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
900
+ import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
904
901
  function processValue(item, value) {
905
902
  var _a;
906
903
  if (typeof value === "undefined" && value === null)
@@ -968,7 +965,11 @@ function Table(props) {
968
965
  if (!item.render)
969
966
  item.render = (value) => processValue(item, value);
970
967
  if (!item.onFilter) {
971
- 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
+ };
972
973
  }
973
974
  if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
974
975
  item.filterDropdown = ({
@@ -995,7 +996,11 @@ function Table(props) {
995
996
  if (!item.render)
996
997
  item.render = (value) => processValue(item, value).join(", ");
997
998
  if (!item.onFilter)
998
- 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
+ };
999
1004
  if (!item.filters && item.filterDropdown !== false)
1000
1005
  item.filterDropdown = ({
1001
1006
  setSelectedKeys,
@@ -1036,7 +1041,7 @@ function Table(props) {
1036
1041
  allowClear: true,
1037
1042
  onSearch: (v) => {
1038
1043
  if (v) {
1039
- setSelectedKeys([v]);
1044
+ setSelectedKeys([Number(v)]);
1040
1045
  } else {
1041
1046
  setSelectedKeys([]);
1042
1047
  clearFilters();
@@ -1062,7 +1067,7 @@ function Table(props) {
1062
1067
  allowClear: true,
1063
1068
  onSearch: (v) => {
1064
1069
  if (v) {
1065
- setSelectedKeys([v]);
1070
+ setSelectedKeys([Number(v)]);
1066
1071
  } else {
1067
1072
  setSelectedKeys([]);
1068
1073
  clearFilters();
@@ -1089,7 +1094,7 @@ function Table(props) {
1089
1094
  setSelectedKeys,
1090
1095
  selectedKeys,
1091
1096
  confirm
1092
- }) => /* @__PURE__ */ jsxs5(Radio.Group, {
1097
+ }) => /* @__PURE__ */ jsxs4(Radio.Group, {
1093
1098
  style: { padding: 8 },
1094
1099
  buttonStyle: "solid",
1095
1100
  value: selectedKeys[0],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.2-beta.417",
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.417",
31
+ "@faasjs/react": "^0.0.2-beta.418",
32
32
  "react-router-dom": "*",
33
33
  "dayjs": "*"
34
34
  },