@faasjs/ant-design 0.0.3-beta.5 → 0.0.3-beta.50

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
@@ -31,10 +31,13 @@ __export(src_exports, {
31
31
  ConfigProvider: () => ConfigProvider,
32
32
  Description: () => Description,
33
33
  Drawer: () => import_antd4.Drawer,
34
+ ErrorBoundary: () => ErrorBoundary,
35
+ FaasDataWrapper: () => FaasDataWrapper,
34
36
  Form: () => Form,
35
37
  FormItem: () => FormItem,
36
38
  Link: () => Link,
37
- Modal: () => import_antd8.Modal,
39
+ Loading: () => Loading,
40
+ Modal: () => import_antd9.Modal,
38
41
  PageNotFound: () => PageNotFound,
39
42
  Routes: () => Routes,
40
43
  Table: () => Table,
@@ -51,12 +54,11 @@ module.exports = __toCommonJS(src_exports);
51
54
  var import_react = __toESM(require("react"));
52
55
 
53
56
  // src/Blank.tsx
54
- var import_antd2 = require("antd");
57
+ var import_antd = require("antd");
55
58
  var import_lodash_es2 = require("lodash-es");
56
59
 
57
60
  // src/Config.tsx
58
61
  var import_react2 = require("react");
59
- var import_antd = require("antd");
60
62
  var import_lodash_es = require("lodash-es");
61
63
  var import_jsx_runtime = require("react/jsx-runtime");
62
64
  var isZH = /^zh/i.test(navigator.language);
@@ -112,14 +114,11 @@ function ConfigProvider({
112
114
  Form: { submit: { text: zh.submit } }
113
115
  }, baseConfig));
114
116
  } else
115
- setValues(values);
117
+ setValues((0, import_lodash_es.defaultsDeep)(config, values));
116
118
  }, []);
117
119
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, {
118
120
  value: values,
119
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, {
120
- ...config.antd,
121
- children
122
- })
121
+ children
123
122
  });
124
123
  }
125
124
  function useConfigContext() {
@@ -130,7 +129,7 @@ function useConfigContext() {
130
129
  var import_jsx_runtime = require("react/jsx-runtime");
131
130
  function Blank(options) {
132
131
  const { Blank: Blank2 } = useConfigContext();
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, {
132
+ 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_antd.Typography.Text, {
134
133
  disabled: true,
135
134
  children: (options == null ? void 0 : options.text) || Blank2.text
136
135
  }) : options.value;
@@ -167,13 +166,50 @@ function transferValue(type, value) {
167
166
  var import_icons = require("@ant-design/icons");
168
167
  var import_antd3 = require("antd");
169
168
  var import_lodash_es4 = require("lodash-es");
170
- var import_react3 = require("react");
171
- var import_react4 = require("@faasjs/react");
169
+ var import_react4 = require("react");
170
+
171
+ // src/FaasDataWrapper.tsx
172
+ var import_react3 = require("@faasjs/react");
173
+
174
+ // src/Loading.tsx
175
+ var import_antd2 = require("antd");
176
+ var import_jsx_runtime = require("react/jsx-runtime");
177
+ function Loading(props) {
178
+ if (props.loading === false)
179
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
180
+ children: props.children
181
+ });
182
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
183
+ style: {
184
+ ...props.style || {},
185
+ ...!props.size || props.size === "large" ? {
186
+ margin: "20vh auto",
187
+ textAlign: "center"
188
+ } : {}
189
+ },
190
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Spin, {
191
+ size: props.size || "large"
192
+ })
193
+ });
194
+ }
195
+
196
+ // src/FaasDataWrapper.tsx
197
+ var import_jsx_runtime = require("react/jsx-runtime");
198
+ function FaasDataWrapper(props) {
199
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.FaasDataWrapper, {
200
+ fallback: props.loading || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {
201
+ ...props.loadingProps
202
+ }),
203
+ ...props
204
+ });
205
+ }
206
+
207
+ // src/Description.tsx
172
208
  var import_jsx_runtime = require("react/jsx-runtime");
173
209
  function DescriptionItemContent(props) {
174
210
  var _a;
175
- const [computedProps, setComputedProps] = (0, import_react3.useState)();
176
- (0, import_react3.useEffect)(() => {
211
+ const [computedProps, setComputedProps] = (0, import_react4.useState)();
212
+ (0, import_react4.useEffect)(() => {
177
213
  var _a2, _b;
178
214
  const propsCopy = { ...props };
179
215
  if (!propsCopy.item.title)
@@ -203,25 +239,40 @@ function DescriptionItemContent(props) {
203
239
  return null;
204
240
  if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
205
241
  if (computedProps.extendTypes[computedProps.item.type].children)
206
- return (0, import_react3.cloneElement)(
242
+ return (0, import_react4.cloneElement)(
207
243
  computedProps.extendTypes[computedProps.item.type].children,
208
244
  {
245
+ scene: "description",
209
246
  value: computedProps.value,
210
247
  values: computedProps.values
211
248
  }
212
249
  );
213
250
  else if (computedProps.extendTypes[computedProps.item.type].render)
214
251
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
215
- children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values)
252
+ children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
216
253
  });
217
254
  else
218
255
  throw Error(computedProps.item.type + " requires children or render");
256
+ if (computedProps.item.descriptionChildren === null)
257
+ return null;
258
+ if (computedProps.item.descriptionChildren)
259
+ return (0, import_react4.cloneElement)(computedProps.item.descriptionChildren, {
260
+ scene: "description",
261
+ value: computedProps.value,
262
+ values: computedProps.values
263
+ });
264
+ if (computedProps.item.children === null)
265
+ return null;
219
266
  if (computedProps.item.children)
220
- return (0, import_react3.cloneElement)(computedProps.item.children, { value: computedProps.value });
221
- if (computedProps.item.render)
222
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
223
- children: computedProps.item.render(computedProps.value, computedProps.values)
267
+ return (0, import_react4.cloneElement)(computedProps.item.children, {
268
+ scene: "description",
269
+ value: computedProps.value,
270
+ values: computedProps.values
224
271
  });
272
+ if (computedProps.item.descriptionRender)
273
+ return computedProps.item.descriptionRender(computedProps.value, computedProps.values, 0, "description");
274
+ if (computedProps.item.render)
275
+ return computedProps.item.render(computedProps.value, computedProps.values, 0, "description");
225
276
  if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
226
277
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
227
278
  switch (computedProps.item.type) {
@@ -279,7 +330,7 @@ function DescriptionItemContent(props) {
279
330
  }
280
331
  }
281
332
  function Description(props) {
282
- if (!props.faasData)
333
+ if (props.dataSource)
283
334
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions, {
284
335
  ...props,
285
336
  title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
@@ -295,10 +346,7 @@ function Description(props) {
295
346
  }, item.id) : null;
296
347
  }).filter(Boolean)
297
348
  });
298
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react4.FaasDataWrapper, {
299
- fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Skeleton, {
300
- active: true
301
- }),
349
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
302
350
  render: ({ data }) => {
303
351
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions, {
304
352
  ...props,
@@ -347,15 +395,62 @@ function useDrawer(init) {
347
395
  };
348
396
  }
349
397
 
398
+ // src/ErrorBoundary.tsx
399
+ var import_react6 = require("react");
400
+ var import_antd5 = require("antd");
401
+ var import_jsx_runtime = require("react/jsx-runtime");
402
+ var ErrorBoundary = class extends import_react6.Component {
403
+ constructor(props) {
404
+ super(props);
405
+ this.state = {
406
+ error: void 0,
407
+ info: { componentStack: "" }
408
+ };
409
+ }
410
+ componentDidCatch(error, info) {
411
+ this.setState({
412
+ error,
413
+ info
414
+ });
415
+ }
416
+ render() {
417
+ const {
418
+ message,
419
+ description,
420
+ children
421
+ } = this.props;
422
+ const { error, info } = this.state;
423
+ const componentStack = info && info.componentStack ? info.componentStack : null;
424
+ const errorMessage = typeof message === "undefined" ? (error || "").toString() : message;
425
+ const errorDescription = typeof description === "undefined" ? componentStack : description;
426
+ if (error) {
427
+ if (this.props.onError)
428
+ return this.props.onError(error, info);
429
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Alert, {
430
+ type: "error",
431
+ message: errorMessage,
432
+ description: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
433
+ style: {
434
+ fontSize: "0.9em",
435
+ overflowX: "auto"
436
+ },
437
+ children: errorDescription
438
+ })
439
+ });
440
+ }
441
+ return children;
442
+ }
443
+ };
444
+
350
445
  // src/Form.tsx
351
- var import_react7 = require("@faasjs/react");
352
- var import_antd6 = require("antd");
353
- var import_react8 = require("react");
446
+ var import_react8 = require("@faasjs/react");
447
+ var import_antd7 = require("antd");
448
+ var import_react9 = require("react");
354
449
 
355
450
  // src/FormItem.tsx
356
- var import_antd5 = require("antd");
451
+ var import_antd6 = require("antd");
357
452
  var import_icons2 = require("@ant-design/icons");
358
- var import_react6 = require("react");
453
+ var import_react7 = require("react");
359
454
  var import_lodash_es5 = require("lodash-es");
360
455
  var import_jsx_runtime = require("react/jsx-runtime");
361
456
  function processProps(propsCopy, config) {
@@ -406,11 +501,11 @@ function processProps(propsCopy, config) {
406
501
  }
407
502
  function FormItem(props) {
408
503
  var _a;
409
- const [computedProps, setComputedProps] = (0, import_react6.useState)();
410
- const [extendTypes, setExtendTypes] = (0, import_react6.useState)();
504
+ const [computedProps, setComputedProps] = (0, import_react7.useState)();
505
+ const [extendTypes, setExtendTypes] = (0, import_react7.useState)();
411
506
  const { common: common2 } = useConfigContext();
412
- const [hidden, setHidden] = (0, import_react6.useState)(props.hidden || false);
413
- (0, import_react6.useEffect)(() => {
507
+ const [hidden, setHidden] = (0, import_react7.useState)(props.hidden || false);
508
+ (0, import_react7.useEffect)(() => {
414
509
  const propsCopy = { ...props };
415
510
  if (propsCopy.extendTypes) {
416
511
  setExtendTypes(propsCopy.extendTypes);
@@ -418,61 +513,79 @@ function FormItem(props) {
418
513
  }
419
514
  if (propsCopy.if) {
420
515
  const condition = propsCopy.if;
421
- propsCopy.shouldUpdate = (_, cur) => {
516
+ const originShouldUpdate = propsCopy.shouldUpdate;
517
+ propsCopy.shouldUpdate = (prev, cur) => {
422
518
  const show = condition(cur);
519
+ const shouldUpdate = hidden !== show;
423
520
  setHidden(!show);
424
- return show;
521
+ const origin = originShouldUpdate ? typeof originShouldUpdate === "boolean" ? originShouldUpdate : originShouldUpdate(prev, cur, {}) : true;
522
+ return shouldUpdate || origin;
425
523
  };
426
524
  delete propsCopy.if;
525
+ delete propsCopy.hidden;
427
526
  }
428
527
  setComputedProps(processProps(propsCopy, common2));
429
528
  }, [props]);
430
529
  if (!computedProps)
431
530
  return null;
432
531
  if (hidden)
433
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
532
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
434
533
  ...computedProps,
435
534
  noStyle: true,
436
535
  rules: [],
437
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Input, {
536
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Input, {
438
537
  hidden: true
439
538
  })
440
539
  });
441
540
  if (extendTypes && extendTypes[computedProps.type])
442
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
541
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
443
542
  ...computedProps,
444
543
  children: extendTypes[computedProps.type].children
445
544
  });
545
+ if (computedProps.formChildren === null)
546
+ return null;
547
+ if (computedProps.formChildren)
548
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
549
+ ...computedProps,
550
+ children: (0, import_react7.cloneElement)(computedProps.formChildren, { scene: "form" })
551
+ });
552
+ if (computedProps.children === null)
553
+ return null;
446
554
  if (computedProps.children)
447
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
555
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
448
556
  ...computedProps,
449
- children: computedProps.children
557
+ children: (0, import_react7.cloneElement)(computedProps.children, { scene: "form" })
558
+ });
559
+ if (computedProps.formRender)
560
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
561
+ ...computedProps,
562
+ children: computedProps.formRender(null, null, 0, "form")
450
563
  });
451
564
  if (computedProps.render)
452
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
565
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
453
566
  ...computedProps,
454
- children: computedProps.render()
567
+ children: computedProps.render(null, null, 0, "form")
455
568
  });
456
569
  switch (computedProps.type) {
457
570
  case "string":
458
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
571
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
459
572
  ...computedProps,
460
- children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Select, {
573
+ children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
461
574
  ...computedProps.input
462
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Input, {
575
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Input, {
463
576
  ...computedProps.input
464
577
  })
465
578
  });
466
579
  case "string[]":
467
580
  if (computedProps.options)
468
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
581
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
469
582
  ...computedProps,
470
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Select, {
583
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
471
584
  mode: "multiple",
472
585
  ...computedProps.input
473
586
  })
474
587
  });
475
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.List, {
588
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
476
589
  name: computedProps.name,
477
590
  rules: computedProps.rules,
478
591
  children: (fields, { add, remove }, { errors }) => {
@@ -488,24 +601,24 @@ function FormItem(props) {
488
601
  }),
489
602
  fields.map((field) => {
490
603
  var _a3;
491
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
492
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Row, {
604
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
605
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Row, {
493
606
  gutter: 24,
494
607
  style: { flexFlow: "row nowrap" },
495
608
  children: [
496
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Col, {
609
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
497
610
  span: 23,
498
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
611
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
499
612
  ...field,
500
613
  noStyle: true,
501
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Input, {
614
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Input, {
502
615
  ...computedProps.input
503
616
  })
504
617
  })
505
618
  }),
506
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Col, {
619
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
507
620
  span: 1,
508
- children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Button, {
621
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
509
622
  danger: true,
510
623
  type: "link",
511
624
  style: { float: "right" },
@@ -517,15 +630,19 @@ function FormItem(props) {
517
630
  })
518
631
  }, field.key);
519
632
  }),
520
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Form.Item, {
633
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
521
634
  children: [
522
- !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Button, {
635
+ !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
523
636
  type: "dashed",
524
637
  block: true,
525
638
  onClick: () => add(),
526
639
  icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
527
640
  }),
528
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.ErrorList, {
641
+ computedProps.extra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
642
+ className: "ant-form-item-extra",
643
+ children: computedProps.extra
644
+ }),
645
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
529
646
  errors
530
647
  })
531
648
  ]
@@ -535,25 +652,25 @@ function FormItem(props) {
535
652
  }
536
653
  });
537
654
  case "number":
538
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
655
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
539
656
  ...computedProps,
540
- children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Select, {
657
+ children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
541
658
  ...computedProps.input
542
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.InputNumber, {
659
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.InputNumber, {
543
660
  style: { width: "100%" },
544
661
  ...computedProps.input
545
662
  })
546
663
  });
547
664
  case "number[]":
548
665
  if (computedProps.options)
549
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
666
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
550
667
  ...computedProps,
551
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Select, {
668
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
552
669
  mode: "multiple",
553
670
  ...computedProps.input
554
671
  })
555
672
  });
556
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.List, {
673
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
557
674
  name: computedProps.name,
558
675
  rules: computedProps.rules,
559
676
  children: (fields, { add, remove }, { errors }) => {
@@ -569,25 +686,25 @@ function FormItem(props) {
569
686
  }),
570
687
  fields.map((field) => {
571
688
  var _a3;
572
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
573
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Row, {
689
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
690
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Row, {
574
691
  gutter: 24,
575
692
  style: { flexFlow: "row nowrap" },
576
693
  children: [
577
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Col, {
694
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
578
695
  span: 23,
579
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
696
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
580
697
  ...field,
581
698
  noStyle: true,
582
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.InputNumber, {
699
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.InputNumber, {
583
700
  style: { width: "100%" },
584
701
  ...computedProps.input
585
702
  })
586
703
  })
587
704
  }),
588
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Col, {
705
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
589
706
  span: 1,
590
- children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Button, {
707
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
591
708
  danger: true,
592
709
  type: "link",
593
710
  style: { float: "right" },
@@ -599,15 +716,19 @@ function FormItem(props) {
599
716
  })
600
717
  }, field.key);
601
718
  }),
602
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Form.Item, {
719
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
603
720
  children: [
604
- !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Button, {
721
+ !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
605
722
  type: "dashed",
606
723
  block: true,
607
724
  onClick: () => add(),
608
725
  icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
609
726
  }),
610
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.ErrorList, {
727
+ computedProps.extra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
728
+ className: "ant-form-item-extra",
729
+ children: computedProps.extra
730
+ }),
731
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
611
732
  errors
612
733
  })
613
734
  ]
@@ -617,23 +738,23 @@ function FormItem(props) {
617
738
  }
618
739
  });
619
740
  case "boolean":
620
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
741
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
621
742
  ...computedProps,
622
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Switch, {
743
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Switch, {
623
744
  ...computedProps.input
624
745
  })
625
746
  });
626
747
  case "date":
627
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
748
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
628
749
  ...computedProps,
629
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.DatePicker, {
750
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.DatePicker, {
630
751
  ...computedProps.input
631
752
  })
632
753
  });
633
754
  case "time":
634
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
755
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
635
756
  ...computedProps,
636
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.TimePicker, {
757
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.TimePicker, {
637
758
  ...computedProps.input
638
759
  })
639
760
  });
@@ -653,12 +774,12 @@ function FormItem(props) {
653
774
  ]
654
775
  });
655
776
  case "object[]":
656
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.List, {
777
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
657
778
  name: computedProps.name,
658
779
  rules: computedProps.rules,
659
780
  children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
660
781
  children: [
661
- fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Form.Item, {
782
+ fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
662
783
  style: { marginBottom: 0 },
663
784
  children: [
664
785
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
@@ -668,7 +789,7 @@ function FormItem(props) {
668
789
  computedProps.label,
669
790
  " ",
670
791
  field.name + 1,
671
- !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Button, {
792
+ !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
672
793
  danger: true,
673
794
  type: "link",
674
795
  onClick: () => remove(field.name),
@@ -677,9 +798,9 @@ function FormItem(props) {
677
798
  ]
678
799
  })
679
800
  }),
680
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Row, {
801
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Row, {
681
802
  gutter: 24,
682
- children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Col, {
803
+ children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
683
804
  span: o.col || 24,
684
805
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
685
806
  ...o,
@@ -689,9 +810,9 @@ function FormItem(props) {
689
810
  })
690
811
  ]
691
812
  }, field.key)),
692
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Form.Item, {
813
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
693
814
  children: [
694
- !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Button, {
815
+ !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Button, {
695
816
  type: "dashed",
696
817
  block: true,
697
818
  onClick: () => add(),
@@ -702,7 +823,11 @@ function FormItem(props) {
702
823
  computedProps.label
703
824
  ]
704
825
  }),
705
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.ErrorList, {
826
+ computedProps.extra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
827
+ className: "ant-form-item-extra",
828
+ children: computedProps.extra
829
+ }),
830
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
706
831
  errors
707
832
  })
708
833
  ]
@@ -714,27 +839,28 @@ function FormItem(props) {
714
839
  return null;
715
840
  }
716
841
  }
842
+ FormItem.useStatus = import_antd6.Form.Item.useStatus;
717
843
 
718
844
  // src/Form.tsx
719
845
  var import_jsx_runtime = require("react/jsx-runtime");
720
846
  function Form(props) {
721
847
  var _a, _b;
722
- const [loading, setLoading] = (0, import_react8.useState)(false);
723
- const [computedProps, setComputedProps] = (0, import_react8.useState)();
848
+ const [loading, setLoading] = (0, import_react9.useState)(false);
849
+ const [computedProps, setComputedProps] = (0, import_react9.useState)();
724
850
  const config = useConfigContext();
725
- const [extendTypes, setExtendTypes] = (0, import_react8.useState)();
726
- const [form] = import_antd6.Form.useForm(props.form);
727
- const [initialValues, setInitialValues] = (0, import_react8.useState)(props.initialValues);
728
- (0, import_react8.useEffect)(() => {
729
- var _a2, _b2;
851
+ const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
852
+ const [form] = import_antd7.Form.useForm(props.form);
853
+ const [initialValues, setInitialValues] = (0, import_react9.useState)(props.initialValues);
854
+ (0, import_react9.useEffect)(() => {
855
+ var _a2, _b2, _c;
730
856
  const propsCopy = {
731
857
  ...props,
732
858
  form
733
859
  };
734
- if (propsCopy.initialValues) {
860
+ if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
735
861
  for (const key in propsCopy.initialValues) {
736
862
  propsCopy.initialValues[key] = transferValue(
737
- (_a2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _a2.type,
863
+ (_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
738
864
  propsCopy.initialValues[key]
739
865
  );
740
866
  const item = propsCopy.items.find((item2) => item2.id === key);
@@ -754,7 +880,7 @@ function Form(props) {
754
880
  setLoading(true);
755
881
  try {
756
882
  if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
757
- await props.onFinish(values, async (values2) => (0, import_react7.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
883
+ await props.onFinish(values, async (values2) => (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
758
884
  ...values2,
759
885
  ...propsCopy.submit.to.params
760
886
  } : values2));
@@ -765,13 +891,25 @@ function Form(props) {
765
891
  }
766
892
  setLoading(false);
767
893
  };
768
- } else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
894
+ } else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
769
895
  propsCopy.onFinish = async (values) => {
770
896
  setLoading(true);
771
- return (0, import_react7.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
897
+ return (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
772
898
  ...values,
773
899
  ...propsCopy.submit.to.params
774
- } : values).finally(() => setLoading(false));
900
+ } : values).then((result) => {
901
+ if (propsCopy.submit.to.then)
902
+ propsCopy.submit.to.then(result);
903
+ return result;
904
+ }).catch((error) => {
905
+ if (propsCopy.submit.to.catch)
906
+ propsCopy.submit.to.catch(error);
907
+ return Promise.reject(error);
908
+ }).finally(() => {
909
+ if (propsCopy.submit.to.finally)
910
+ propsCopy.submit.to.finally();
911
+ setLoading(false);
912
+ });
775
913
  };
776
914
  }
777
915
  if (propsCopy.extendTypes) {
@@ -780,7 +918,7 @@ function Form(props) {
780
918
  }
781
919
  setComputedProps(propsCopy);
782
920
  }, [props]);
783
- const onValuesChange = (0, import_react8.useCallback)((changedValues, allValues) => {
921
+ const onValuesChange = (0, import_react9.useCallback)((changedValues, allValues) => {
784
922
  console.debug("Form:onValuesChange", changedValues, allValues);
785
923
  if (props.onValuesChange) {
786
924
  props.onValuesChange(changedValues, allValues);
@@ -793,7 +931,7 @@ function Form(props) {
793
931
  item.onValueChange(changedValues[key], allValues, form);
794
932
  }
795
933
  }, [computedProps]);
796
- (0, import_react8.useEffect)(() => {
934
+ (0, import_react9.useEffect)(() => {
797
935
  if (!initialValues)
798
936
  return;
799
937
  console.debug("Form:initialValues", initialValues);
@@ -802,17 +940,17 @@ function Form(props) {
802
940
  }, [computedProps]);
803
941
  if (!computedProps)
804
942
  return null;
805
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form, {
943
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd7.Form, {
806
944
  ...computedProps,
807
945
  onValuesChange,
808
946
  children: [
809
947
  computedProps.beforeItems,
810
- (_a = computedProps.items) == null ? void 0 : _a.map((item) => (0, import_react8.isValidElement)(item) ? item : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
948
+ (_a = computedProps.items) == null ? void 0 : _a.map((item) => (0, import_react9.isValidElement)(item) ? item : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
811
949
  ...item,
812
950
  extendTypes
813
951
  }, item.id)),
814
952
  computedProps.children,
815
- computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
953
+ computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Button, {
816
954
  htmlType: "submit",
817
955
  type: "primary",
818
956
  loading,
@@ -822,76 +960,71 @@ function Form(props) {
822
960
  ]
823
961
  });
824
962
  }
825
- Form.useForm = import_antd6.Form.useForm;
963
+ Form.useForm = import_antd7.Form.useForm;
964
+ Form.useFormInstance = import_antd7.Form.useFormInstance;
965
+ Form.useWatch = import_antd7.Form.useWatch;
966
+ Form.Item = FormItem;
967
+ Form.List = import_antd7.Form.List;
968
+ Form.ErrorList = import_antd7.Form.ErrorList;
969
+ Form.Provider = import_antd7.Form.Provider;
826
970
 
827
971
  // src/Link.tsx
828
972
  var import_react_router_dom = require("react-router-dom");
829
- var import_antd7 = require("antd");
973
+ var import_antd8 = require("antd");
830
974
  var import_jsx_runtime = require("react/jsx-runtime");
831
- function Link({
832
- href,
833
- target,
834
- text,
835
- children,
836
- style,
837
- button
838
- }) {
975
+ function Link(props) {
976
+ var _a, _b, _c, _d;
839
977
  const { Link: Link2 } = useConfigContext();
840
- style = Object.assign({ cursor: "pointer" }, style);
841
- if (href.startsWith("http")) {
842
- if (button)
843
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Button, {
844
- ...button,
845
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
846
- href,
847
- target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
848
- style: {
849
- ...Link2.style,
850
- ...style || {}
851
- },
852
- children: text || children
853
- })
978
+ let style = {
979
+ ...Link2.style || {},
980
+ cursor: "pointer",
981
+ ...props.style
982
+ };
983
+ if (props.block)
984
+ style = Object.assign({
985
+ display: "block",
986
+ width: "100%"
987
+ }, style);
988
+ if (props.href.startsWith("http")) {
989
+ if (props.button)
990
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
991
+ ...props.button,
992
+ target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
993
+ style,
994
+ href: props.href,
995
+ children: (_a = props.text) != null ? _a : props.children
854
996
  });
855
997
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
856
- href,
857
- target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
858
- style: {
859
- ...Link2.style,
860
- ...style || {}
861
- },
862
- children: text || children
998
+ href: props.href,
999
+ target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
1000
+ style,
1001
+ children: (_b = props.text) != null ? _b : props.children
863
1002
  });
864
1003
  }
865
- if (button)
866
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Button, {
867
- ...button,
868
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
869
- to: href,
870
- target: target || (Link2 == null ? void 0 : Link2.target),
871
- style: {
872
- ...Link2.style,
873
- ...style || {}
874
- },
875
- children: text || children
1004
+ if (props.button)
1005
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
1006
+ to: props.href,
1007
+ target: props.target || (Link2 == null ? void 0 : Link2.target),
1008
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
1009
+ ...props.button,
1010
+ style,
1011
+ children: (_c = props.text) != null ? _c : props.children
876
1012
  })
877
1013
  });
878
1014
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
879
- to: href,
880
- target: target || (Link2 == null ? void 0 : Link2.target),
881
- style: {
882
- ...Link2.style,
883
- ...style || {}
884
- },
885
- children: text || children
1015
+ to: props.href,
1016
+ target: props.target || (Link2 == null ? void 0 : Link2.target),
1017
+ style,
1018
+ children: (_d = props.text) != null ? _d : props.children
886
1019
  });
887
1020
  }
888
1021
 
889
1022
  // src/Modal.tsx
890
- var import_antd8 = require("antd");
891
- var import_react9 = require("react");
1023
+ var import_antd9 = require("antd");
1024
+ var import_react10 = require("react");
892
1025
  var import_jsx_runtime = require("react/jsx-runtime");
893
1026
  function useModal(init) {
894
- const [props, setProps] = (0, import_react9.useState)({
1027
+ const [props, setProps] = (0, import_react10.useState)({
895
1028
  open: false,
896
1029
  onCancel: () => setProps((prev) => ({
897
1030
  ...prev,
@@ -900,7 +1033,7 @@ function useModal(init) {
900
1033
  ...init
901
1034
  });
902
1035
  return {
903
- modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Modal, {
1036
+ modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Modal, {
904
1037
  ...props
905
1038
  }),
906
1039
  modalProps: props,
@@ -914,13 +1047,13 @@ function useModal(init) {
914
1047
  }
915
1048
 
916
1049
  // src/Routers.tsx
917
- var import_antd9 = require("antd");
918
- var import_react10 = require("react");
1050
+ var import_antd10 = require("antd");
1051
+ var import_react11 = require("react");
919
1052
  var import_react_router_dom2 = require("react-router-dom");
920
1053
  var import_jsx_runtime = require("react/jsx-runtime");
921
1054
  function PageNotFound() {
922
1055
  const config = useConfigContext();
923
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Result, {
1056
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Result, {
924
1057
  status: "404",
925
1058
  title: config.common.pageNotFound
926
1059
  });
@@ -930,10 +1063,10 @@ function Routes(props) {
930
1063
  children: [
931
1064
  props.routes.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom2.Route, {
932
1065
  ...r,
933
- element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react10.Suspense, {
1066
+ element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react11.Suspense, {
934
1067
  fallback: props.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
935
1068
  style: { padding: "24px" },
936
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Skeleton, {
1069
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Skeleton, {
937
1070
  active: true
938
1071
  })
939
1072
  }),
@@ -949,12 +1082,11 @@ function Routes(props) {
949
1082
  }
950
1083
 
951
1084
  // src/Table.tsx
952
- var import_react11 = require("react");
953
- var import_antd10 = require("antd");
1085
+ var import_react12 = require("react");
1086
+ var import_antd11 = require("antd");
954
1087
  var import_dayjs2 = __toESM(require("dayjs"));
955
1088
  var import_icons3 = require("@ant-design/icons");
956
1089
  var import_lodash_es6 = require("lodash-es");
957
- var import_react12 = require("@faasjs/react");
958
1090
  var import_jsx_runtime = require("react/jsx-runtime");
959
1091
  function processValue(item, value) {
960
1092
  var _a;
@@ -981,9 +1113,9 @@ function processValue(item, value) {
981
1113
  return value;
982
1114
  }
983
1115
  function Table(props) {
984
- const [columns, setColumns] = (0, import_react11.useState)();
985
- const { common: common2, antd } = useConfigContext();
986
- (0, import_react11.useEffect)(() => {
1116
+ const [columns, setColumns] = (0, import_react12.useState)();
1117
+ const { common: common2 } = useConfigContext();
1118
+ (0, import_react12.useEffect)(() => {
987
1119
  var _a;
988
1120
  for (const item of props.items) {
989
1121
  if (!item.key)
@@ -999,15 +1131,39 @@ function Table(props) {
999
1131
  item.filters = item.options.map((o) => ({
1000
1132
  text: o.label,
1001
1133
  value: o.value
1002
- }));
1134
+ })).concat({
1135
+ text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1136
+ value: null
1137
+ });
1003
1138
  }
1004
- if (item.children)
1005
- delete item.children;
1139
+ if (item.tableChildren === null)
1140
+ item.render = () => null;
1141
+ else if (item.tableChildren)
1142
+ item.render = (value, values) => (0, import_react12.cloneElement)(
1143
+ item.tableChildren,
1144
+ {
1145
+ scene: "table",
1146
+ value,
1147
+ values
1148
+ }
1149
+ );
1150
+ else if (item.children === null)
1151
+ item.render = () => null;
1152
+ else if (item.children)
1153
+ item.render = (value, values) => (0, import_react12.cloneElement)(
1154
+ item.children,
1155
+ {
1156
+ scene: "table",
1157
+ value,
1158
+ values
1159
+ }
1160
+ );
1006
1161
  if (props.extendTypes && props.extendTypes[item.type]) {
1007
1162
  if (props.extendTypes[item.type].children)
1008
- item.render = (value, values) => (0, import_react11.cloneElement)(
1163
+ item.render = (value, values) => (0, import_react12.cloneElement)(
1009
1164
  props.extendTypes[item.type].children,
1010
1165
  {
1166
+ scene: "table",
1011
1167
  value,
1012
1168
  values
1013
1169
  }
@@ -1035,7 +1191,7 @@ function Table(props) {
1035
1191
  setSelectedKeys,
1036
1192
  confirm,
1037
1193
  clearFilters
1038
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Input.Search, {
1194
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
1039
1195
  placeholder: `${common2.search} ${item.title}`,
1040
1196
  allowClear: true,
1041
1197
  onSearch: (v) => {
@@ -1065,7 +1221,7 @@ function Table(props) {
1065
1221
  setSelectedKeys,
1066
1222
  confirm,
1067
1223
  clearFilters
1068
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Input.Search, {
1224
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
1069
1225
  placeholder: `${common2.search} ${item.title}`,
1070
1226
  allowClear: true,
1071
1227
  onSearch: (v) => {
@@ -1088,14 +1244,14 @@ function Table(props) {
1088
1244
  item.onFilter = (value, row) => {
1089
1245
  if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
1090
1246
  return true;
1091
- return value === row[item.id];
1247
+ return value == row[item.id];
1092
1248
  };
1093
1249
  if (!item.filters && item.filterDropdown !== false)
1094
1250
  item.filterDropdown = ({
1095
1251
  setSelectedKeys,
1096
1252
  confirm,
1097
1253
  clearFilters
1098
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Input.Search, {
1254
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
1099
1255
  placeholder: `${common2.search} ${item.title}`,
1100
1256
  allowClear: true,
1101
1257
  onSearch: (v) => {
@@ -1118,14 +1274,14 @@ function Table(props) {
1118
1274
  return true;
1119
1275
  if (!row[item.id] || !row[item.id].length)
1120
1276
  return false;
1121
- return row[item.id].includes(value);
1277
+ return row[item.id].includes(Number(value));
1122
1278
  };
1123
1279
  if (!item.filters && item.filterDropdown !== false)
1124
1280
  item.filterDropdown = ({
1125
1281
  setSelectedKeys,
1126
1282
  confirm,
1127
1283
  clearFilters
1128
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Input.Search, {
1284
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
1129
1285
  placeholder: `${common2.search} ${item.title}`,
1130
1286
  allowClear: true,
1131
1287
  onSearch: (v) => {
@@ -1141,7 +1297,7 @@ function Table(props) {
1141
1297
  break;
1142
1298
  case "boolean":
1143
1299
  if (!item.render)
1144
- item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}) : value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
1300
+ item.render = (value) => (0, import_lodash_es6.isNil)(value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}) : value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
1145
1301
  style: {
1146
1302
  marginTop: "4px",
1147
1303
  color: "#52c41a"
@@ -1157,7 +1313,7 @@ function Table(props) {
1157
1313
  setSelectedKeys,
1158
1314
  selectedKeys,
1159
1315
  confirm
1160
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd10.Radio.Group, {
1316
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd11.Radio.Group, {
1161
1317
  style: { padding: 8 },
1162
1318
  buttonStyle: "solid",
1163
1319
  value: selectedKeys[0],
@@ -1166,11 +1322,11 @@ function Table(props) {
1166
1322
  confirm();
1167
1323
  },
1168
1324
  children: [
1169
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Radio.Button, {
1325
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
1170
1326
  children: common2.all
1171
1327
  }),
1172
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Radio.Button, {
1173
- value: "true",
1328
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
1329
+ value: true,
1174
1330
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
1175
1331
  style: {
1176
1332
  color: "#52c41a",
@@ -1178,8 +1334,8 @@ function Table(props) {
1178
1334
  }
1179
1335
  })
1180
1336
  }),
1181
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Radio.Button, {
1182
- value: "false",
1337
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
1338
+ value: false,
1183
1339
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CloseOutlined, {
1184
1340
  style: {
1185
1341
  verticalAlign: "middle",
@@ -1187,8 +1343,8 @@ function Table(props) {
1187
1343
  }
1188
1344
  })
1189
1345
  }),
1190
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Radio.Button, {
1191
- value: "empty",
1346
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
1347
+ value: null,
1192
1348
  children: common2.blank
1193
1349
  })
1194
1350
  ]
@@ -1196,11 +1352,11 @@ function Table(props) {
1196
1352
  if (!item.onFilter)
1197
1353
  item.onFilter = (value, row) => {
1198
1354
  switch (value) {
1199
- case "true":
1355
+ case true:
1200
1356
  return !(0, import_lodash_es6.isNil)(row[item.id]) && !!row[item.id];
1201
- case "false":
1357
+ case false:
1202
1358
  return !(0, import_lodash_es6.isNil)(row[item.id]) && !row[item.id];
1203
- case "empty":
1359
+ case null:
1204
1360
  return (0, import_lodash_es6.isNil)(row[item.id]);
1205
1361
  default:
1206
1362
  return true;
@@ -1211,9 +1367,15 @@ function Table(props) {
1211
1367
  if (!item.render)
1212
1368
  item.render = (value) => processValue(item, value);
1213
1369
  if (!item.onFilter)
1214
- item.onFilter = (value, row) => (0, import_dayjs2.default)(row[item.id]).isSame((0, import_dayjs2.default)(value));
1370
+ item.onFilter = (value, row) => (0, import_dayjs2.default)(row[item.id]).isSame((0, import_dayjs2.default)(value), "date");
1215
1371
  if (!item.sorter)
1216
- item.sorter = (a, b) => (0, import_dayjs2.default)(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1372
+ item.sorter = (a, b, order) => {
1373
+ if ((0, import_lodash_es6.isNil)(a[item.id]))
1374
+ return order === "ascend" ? 1 : -1;
1375
+ if ((0, import_lodash_es6.isNil)(b[item.id]))
1376
+ return order === "ascend" ? -1 : 1;
1377
+ return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
1378
+ };
1217
1379
  break;
1218
1380
  case "time":
1219
1381
  if (!item.render)
@@ -1221,7 +1383,13 @@ function Table(props) {
1221
1383
  if (!item.onFilter)
1222
1384
  item.onFilter = (value, row) => (0, import_dayjs2.default)(row[item.id]).isSame((0, import_dayjs2.default)(value));
1223
1385
  if (!item.sorter)
1224
- item.sorter = (a, b) => (0, import_dayjs2.default)(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1386
+ item.sorter = (a, b, order) => {
1387
+ if ((0, import_lodash_es6.isNil)(a[item.id]))
1388
+ return order === "ascend" ? 1 : -1;
1389
+ if ((0, import_lodash_es6.isNil)(b[item.id]))
1390
+ return order === "ascend" ? -1 : 1;
1391
+ return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
1392
+ };
1225
1393
  break;
1226
1394
  case "object":
1227
1395
  if (!item.render)
@@ -1233,11 +1401,13 @@ function Table(props) {
1233
1401
  break;
1234
1402
  case "object[]":
1235
1403
  if (!item.render)
1236
- item.render = (value) => value.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
1237
- items: item.object,
1238
- dataSource: v || [],
1239
- column: 1
1240
- }, i));
1404
+ item.render = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
1405
+ children: value.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
1406
+ items: item.object,
1407
+ dataSource: v || [],
1408
+ column: 1
1409
+ }, i))
1410
+ });
1241
1411
  break;
1242
1412
  default:
1243
1413
  if (!item.render)
@@ -1253,100 +1423,129 @@ function Table(props) {
1253
1423
  }
1254
1424
  setColumns(props.items);
1255
1425
  }, [props.items]);
1256
- (0, import_react11.useEffect)(() => {
1426
+ (0, import_react12.useEffect)(() => {
1257
1427
  if (!props.dataSource || !columns)
1258
1428
  return;
1259
1429
  for (const column of columns) {
1260
1430
  if (column.optionsType === "auto" && !column.options && !column.filters) {
1261
- setColumns((prev) => {
1262
- const newColumns = [...prev];
1263
- const index = newColumns.findIndex((item) => item.id === column.id);
1264
- newColumns[index].filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
1265
- text: v[column.id],
1266
- value: v[column.id]
1267
- })).concat({
1268
- text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1269
- value: null
1431
+ const filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
1432
+ text: v[column.id],
1433
+ value: v[column.id]
1434
+ }));
1435
+ if (filters.length)
1436
+ setColumns((prev) => {
1437
+ const newColumns = [...prev];
1438
+ const index = newColumns.findIndex((item) => item.id === column.id);
1439
+ newColumns[index].filters = filters.concat({
1440
+ text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1441
+ value: null
1442
+ });
1443
+ return newColumns;
1270
1444
  });
1271
- return newColumns;
1272
- });
1273
1445
  }
1274
1446
  }
1275
1447
  }, [props.dataSource, columns]);
1276
1448
  if (!columns)
1277
1449
  return null;
1278
- if (!props.faasData)
1279
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1280
- ...antd,
1281
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1282
- ...props,
1283
- rowKey: props.rowKey || "id",
1284
- columns,
1285
- dataSource: props.dataSource
1286
- })
1450
+ if (props.dataSource)
1451
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
1452
+ ...props,
1453
+ rowKey: props.rowKey || "id",
1454
+ columns,
1455
+ dataSource: props.dataSource
1287
1456
  });
1288
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react12.FaasDataWrapper, {
1289
- fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Skeleton, {
1290
- active: true
1291
- }),
1292
- render: ({
1293
- data,
1294
- params,
1295
- reload
1296
- }) => {
1297
- if (!data)
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: []
1305
- })
1306
- });
1307
- if (Array.isArray(data))
1308
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1309
- ...antd,
1310
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1311
- ...props,
1312
- rowKey: props.rowKey || "id",
1313
- columns,
1314
- dataSource: data
1315
- })
1316
- });
1317
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1318
- ...antd,
1319
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1320
- ...props,
1321
- rowKey: props.rowKey || "id",
1322
- columns,
1323
- dataSource: data.rows,
1324
- pagination: {
1325
- ...props.pagination,
1326
- ...data.pagination
1327
- },
1328
- onChange: (pagination, filters, sorter, extra) => {
1329
- if (props.onChange) {
1330
- const processed = props.onChange(pagination, filters, sorter, extra);
1331
- reload({
1332
- ...params,
1333
- pagination: processed.pagination,
1334
- filters: processed.filters,
1335
- sorter: processed.sorter
1336
- });
1337
- return;
1338
- }
1339
- reload({
1340
- ...params,
1341
- pagination,
1342
- filters,
1343
- sorter
1457
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
1458
+ ...props.faasData,
1459
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataTable, {
1460
+ props,
1461
+ columns
1462
+ })
1463
+ });
1464
+ }
1465
+ function FaasDataTable({
1466
+ props,
1467
+ columns,
1468
+ data,
1469
+ params,
1470
+ reload
1471
+ }) {
1472
+ const [currentColumns, setCurrentColumns] = (0, import_react12.useState)(columns);
1473
+ (0, import_react12.useEffect)(() => {
1474
+ if (!data || Array.isArray(data))
1475
+ return;
1476
+ setCurrentColumns((prev) => {
1477
+ const newColumns = [...prev];
1478
+ for (const column of newColumns) {
1479
+ if (data["options"] && data.options[column.id]) {
1480
+ column.options = data["options"][column.id];
1481
+ column.filters = data["options"][column.id].map((v) => ({
1482
+ text: v.label,
1483
+ value: v.value
1484
+ })).concat({
1485
+ text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1486
+ value: null
1487
+ });
1488
+ column.render = (value) => processValue(column, value);
1489
+ if (column.filterDropdown)
1490
+ delete column.filterDropdown;
1491
+ continue;
1492
+ }
1493
+ if (column.optionsType === "auto" && !column.options && !column.filters) {
1494
+ const filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
1495
+ text: v[column.id],
1496
+ value: v[column.id]
1497
+ }));
1498
+ if (filters.length)
1499
+ column.filters = filters.concat({
1500
+ text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1501
+ value: null
1344
1502
  });
1345
- }
1346
- })
1347
- });
1503
+ }
1504
+ }
1505
+ return newColumns;
1506
+ });
1507
+ }, [columns, data]);
1508
+ if (!data)
1509
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
1510
+ ...props,
1511
+ rowKey: props.rowKey || "id",
1512
+ columns: currentColumns,
1513
+ dataSource: []
1514
+ });
1515
+ if (Array.isArray(data))
1516
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
1517
+ ...props,
1518
+ rowKey: props.rowKey || "id",
1519
+ columns: currentColumns,
1520
+ dataSource: data
1521
+ });
1522
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
1523
+ ...props,
1524
+ rowKey: props.rowKey || "id",
1525
+ columns: currentColumns,
1526
+ dataSource: data.rows,
1527
+ pagination: {
1528
+ ...props.pagination,
1529
+ ...data.pagination
1348
1530
  },
1349
- ...props.faasData
1531
+ onChange: (pagination, filters, sorter, extra) => {
1532
+ if (props.onChange) {
1533
+ const processed = props.onChange(pagination, filters, sorter, extra);
1534
+ reload({
1535
+ ...params,
1536
+ pagination: processed.pagination,
1537
+ filters: processed.filters,
1538
+ sorter: processed.sorter
1539
+ });
1540
+ return;
1541
+ }
1542
+ reload({
1543
+ ...params,
1544
+ pagination,
1545
+ filters,
1546
+ sorter
1547
+ });
1548
+ }
1350
1549
  });
1351
1550
  }
1352
1551
 
@@ -1385,9 +1584,12 @@ function Title(props) {
1385
1584
  ConfigProvider,
1386
1585
  Description,
1387
1586
  Drawer,
1587
+ ErrorBoundary,
1588
+ FaasDataWrapper,
1388
1589
  Form,
1389
1590
  FormItem,
1390
1591
  Link,
1592
+ Loading,
1391
1593
  Modal,
1392
1594
  PageNotFound,
1393
1595
  Routes,