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

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) {
@@ -375,13 +470,13 @@ function processProps(propsCopy, config) {
375
470
  required: true,
376
471
  validator: async (_, values) => {
377
472
  if (!values || values.length < 1)
378
- return Promise.reject(Error(`${propsCopy.label || propsCopy.title} ${config.common.required}`));
473
+ return Promise.reject(Error(`${propsCopy.label || propsCopy.title} ${config.required}`));
379
474
  }
380
475
  });
381
476
  else
382
477
  propsCopy.rules.push({
383
478
  required: true,
384
- message: `${propsCopy.label || propsCopy.title} ${config.common.required}`
479
+ message: `${propsCopy.label || propsCopy.title} ${config.required}`
385
480
  });
386
481
  }
387
482
  if (!propsCopy.input)
@@ -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)();
411
- const config = useConfigContext();
412
- const [hidden, setHidden] = (0, import_react6.useState)(false);
413
- (0, import_react6.useEffect)(() => {
504
+ const [computedProps, setComputedProps] = (0, import_react7.useState)();
505
+ const [extendTypes, setExtendTypes] = (0, import_react7.useState)();
506
+ const { common: common2 } = useConfigContext();
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
- setComputedProps(processProps(propsCopy, config));
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,15 @@ 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
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
529
642
  errors
530
643
  })
531
644
  ]
@@ -535,25 +648,25 @@ function FormItem(props) {
535
648
  }
536
649
  });
537
650
  case "number":
538
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
651
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
539
652
  ...computedProps,
540
- children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Select, {
653
+ children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
541
654
  ...computedProps.input
542
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.InputNumber, {
655
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.InputNumber, {
543
656
  style: { width: "100%" },
544
657
  ...computedProps.input
545
658
  })
546
659
  });
547
660
  case "number[]":
548
661
  if (computedProps.options)
549
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
662
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
550
663
  ...computedProps,
551
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Select, {
664
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
552
665
  mode: "multiple",
553
666
  ...computedProps.input
554
667
  })
555
668
  });
556
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.List, {
669
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
557
670
  name: computedProps.name,
558
671
  rules: computedProps.rules,
559
672
  children: (fields, { add, remove }, { errors }) => {
@@ -569,25 +682,25 @@ function FormItem(props) {
569
682
  }),
570
683
  fields.map((field) => {
571
684
  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, {
685
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
686
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Row, {
574
687
  gutter: 24,
575
688
  style: { flexFlow: "row nowrap" },
576
689
  children: [
577
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Col, {
690
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
578
691
  span: 23,
579
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
692
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
580
693
  ...field,
581
694
  noStyle: true,
582
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.InputNumber, {
695
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.InputNumber, {
583
696
  style: { width: "100%" },
584
697
  ...computedProps.input
585
698
  })
586
699
  })
587
700
  }),
588
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Col, {
701
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
589
702
  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, {
703
+ 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
704
  danger: true,
592
705
  type: "link",
593
706
  style: { float: "right" },
@@ -599,15 +712,15 @@ function FormItem(props) {
599
712
  })
600
713
  }, field.key);
601
714
  }),
602
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Form.Item, {
715
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
603
716
  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, {
717
+ !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
605
718
  type: "dashed",
606
719
  block: true,
607
720
  onClick: () => add(),
608
721
  icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
609
722
  }),
610
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.ErrorList, {
723
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
611
724
  errors
612
725
  })
613
726
  ]
@@ -617,23 +730,23 @@ function FormItem(props) {
617
730
  }
618
731
  });
619
732
  case "boolean":
620
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
733
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
621
734
  ...computedProps,
622
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Switch, {
735
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Switch, {
623
736
  ...computedProps.input
624
737
  })
625
738
  });
626
739
  case "date":
627
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
740
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
628
741
  ...computedProps,
629
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.DatePicker, {
742
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.DatePicker, {
630
743
  ...computedProps.input
631
744
  })
632
745
  });
633
746
  case "time":
634
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
747
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
635
748
  ...computedProps,
636
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.TimePicker, {
749
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.TimePicker, {
637
750
  ...computedProps.input
638
751
  })
639
752
  });
@@ -653,12 +766,12 @@ function FormItem(props) {
653
766
  ]
654
767
  });
655
768
  case "object[]":
656
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.List, {
769
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
657
770
  name: computedProps.name,
658
771
  rules: computedProps.rules,
659
772
  children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
660
773
  children: [
661
- fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Form.Item, {
774
+ fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
662
775
  style: { marginBottom: 0 },
663
776
  children: [
664
777
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
@@ -668,18 +781,18 @@ function FormItem(props) {
668
781
  computedProps.label,
669
782
  " ",
670
783
  field.name + 1,
671
- !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Button, {
784
+ !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
672
785
  danger: true,
673
786
  type: "link",
674
787
  onClick: () => remove(field.name),
675
- children: config.common.delete
788
+ children: common2.delete
676
789
  })
677
790
  ]
678
791
  })
679
792
  }),
680
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Row, {
793
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Row, {
681
794
  gutter: 24,
682
- children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Col, {
795
+ children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
683
796
  span: o.col || 24,
684
797
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
685
798
  ...o,
@@ -689,20 +802,20 @@ function FormItem(props) {
689
802
  })
690
803
  ]
691
804
  }, field.key)),
692
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Form.Item, {
805
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
693
806
  children: [
694
- !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Button, {
807
+ !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Button, {
695
808
  type: "dashed",
696
809
  block: true,
697
810
  onClick: () => add(),
698
811
  icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {}),
699
812
  children: [
700
- config.common.add,
813
+ common2.add,
701
814
  " ",
702
815
  computedProps.label
703
816
  ]
704
817
  }),
705
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.ErrorList, {
818
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
706
819
  errors
707
820
  })
708
821
  ]
@@ -714,29 +827,38 @@ function FormItem(props) {
714
827
  return null;
715
828
  }
716
829
  }
830
+ FormItem.useStatus = import_antd6.Form.Item.useStatus;
717
831
 
718
832
  // src/Form.tsx
719
833
  var import_jsx_runtime = require("react/jsx-runtime");
720
834
  function Form(props) {
721
835
  var _a, _b;
722
- const [loading, setLoading] = (0, import_react8.useState)(false);
723
- const [computedProps, setComputedProps] = (0, import_react8.useState)();
836
+ const [loading, setLoading] = (0, import_react9.useState)(false);
837
+ const [computedProps, setComputedProps] = (0, import_react9.useState)();
724
838
  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;
839
+ const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
840
+ const [form] = import_antd7.Form.useForm(props.form);
841
+ const [initialValues, setInitialValues] = (0, import_react9.useState)(props.initialValues);
842
+ (0, import_react9.useEffect)(() => {
843
+ var _a2, _b2, _c;
730
844
  const propsCopy = {
731
845
  ...props,
732
846
  form
733
847
  };
734
- if (propsCopy.initialValues) {
735
- for (const key in propsCopy.initialValues)
848
+ if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
849
+ for (const key in propsCopy.initialValues) {
736
850
  propsCopy.initialValues[key] = transferValue(
737
- (_a2 = propsCopy.items.find((item) => item.id === key)) == null ? void 0 : _a2.type,
851
+ (_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
738
852
  propsCopy.initialValues[key]
739
853
  );
854
+ const item = propsCopy.items.find((item2) => item2.id === key);
855
+ if (item == null ? void 0 : item.if)
856
+ item.hidden = !item.if(propsCopy.initialValues);
857
+ }
858
+ for (const item of propsCopy.items) {
859
+ if (item.if)
860
+ item.hidden = !item.if(propsCopy.initialValues);
861
+ }
740
862
  setInitialValues(propsCopy.initialValues);
741
863
  delete propsCopy.initialValues;
742
864
  }
@@ -746,7 +868,7 @@ function Form(props) {
746
868
  setLoading(true);
747
869
  try {
748
870
  if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
749
- await props.onFinish(values, async (values2) => (0, import_react7.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
871
+ await props.onFinish(values, async (values2) => (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
750
872
  ...values2,
751
873
  ...propsCopy.submit.to.params
752
874
  } : values2));
@@ -757,13 +879,25 @@ function Form(props) {
757
879
  }
758
880
  setLoading(false);
759
881
  };
760
- } else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
882
+ } else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
761
883
  propsCopy.onFinish = async (values) => {
762
884
  setLoading(true);
763
- return (0, import_react7.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
885
+ return (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
764
886
  ...values,
765
887
  ...propsCopy.submit.to.params
766
- } : values).finally(() => setLoading(false));
888
+ } : values).then((result) => {
889
+ if (propsCopy.submit.to.then)
890
+ propsCopy.submit.to.then(result);
891
+ return result;
892
+ }).catch((error) => {
893
+ if (propsCopy.submit.to.catch)
894
+ propsCopy.submit.to.catch(error);
895
+ return Promise.reject(error);
896
+ }).finally(() => {
897
+ if (propsCopy.submit.to.finally)
898
+ propsCopy.submit.to.finally();
899
+ setLoading(false);
900
+ });
767
901
  };
768
902
  }
769
903
  if (propsCopy.extendTypes) {
@@ -772,7 +906,8 @@ function Form(props) {
772
906
  }
773
907
  setComputedProps(propsCopy);
774
908
  }, [props]);
775
- const onValuesChange = (0, import_react8.useCallback)((changedValues, allValues) => {
909
+ const onValuesChange = (0, import_react9.useCallback)((changedValues, allValues) => {
910
+ console.debug("Form:onValuesChange", changedValues, allValues);
776
911
  if (props.onValuesChange) {
777
912
  props.onValuesChange(changedValues, allValues);
778
913
  }
@@ -784,25 +919,26 @@ function Form(props) {
784
919
  item.onValueChange(changedValues[key], allValues, form);
785
920
  }
786
921
  }, [computedProps]);
787
- (0, import_react8.useEffect)(() => {
922
+ (0, import_react9.useEffect)(() => {
788
923
  if (!initialValues)
789
924
  return;
925
+ console.debug("Form:initialValues", initialValues);
790
926
  form.setFieldsValue(initialValues);
791
927
  setInitialValues(null);
792
928
  }, [computedProps]);
793
929
  if (!computedProps)
794
930
  return null;
795
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form, {
931
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd7.Form, {
796
932
  ...computedProps,
797
933
  onValuesChange,
798
934
  children: [
799
935
  computedProps.beforeItems,
800
- (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
936
+ (_a = computedProps.items) == null ? void 0 : _a.map((item) => (0, import_react9.isValidElement)(item) ? item : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
801
937
  ...item,
802
938
  extendTypes
803
939
  }, item.id)),
804
940
  computedProps.children,
805
- computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
941
+ computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Button, {
806
942
  htmlType: "submit",
807
943
  type: "primary",
808
944
  loading,
@@ -812,76 +948,71 @@ function Form(props) {
812
948
  ]
813
949
  });
814
950
  }
815
- Form.useForm = import_antd6.Form.useForm;
951
+ Form.useForm = import_antd7.Form.useForm;
952
+ Form.useFormInstance = import_antd7.Form.useFormInstance;
953
+ Form.useWatch = import_antd7.Form.useWatch;
954
+ Form.Item = FormItem;
955
+ Form.List = import_antd7.Form.List;
956
+ Form.ErrorList = import_antd7.Form.ErrorList;
957
+ Form.Provider = import_antd7.Form.Provider;
816
958
 
817
959
  // src/Link.tsx
818
960
  var import_react_router_dom = require("react-router-dom");
819
- var import_antd7 = require("antd");
961
+ var import_antd8 = require("antd");
820
962
  var import_jsx_runtime = require("react/jsx-runtime");
821
- function Link({
822
- href,
823
- target,
824
- text,
825
- children,
826
- style,
827
- button
828
- }) {
963
+ function Link(props) {
964
+ var _a, _b, _c, _d;
829
965
  const { Link: Link2 } = useConfigContext();
830
- style = Object.assign({ cursor: "pointer" }, style);
831
- if (href.startsWith("http")) {
832
- if (button)
833
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Button, {
834
- ...button,
835
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
836
- href,
837
- target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
838
- style: {
839
- ...Link2.style,
840
- ...style || {}
841
- },
842
- children: text || children
843
- })
966
+ let style = {
967
+ ...Link2.style || {},
968
+ cursor: "pointer",
969
+ ...props.style
970
+ };
971
+ if (props.block)
972
+ style = Object.assign({
973
+ display: "block",
974
+ width: "100%"
975
+ }, style);
976
+ if (props.href.startsWith("http")) {
977
+ if (props.button)
978
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
979
+ ...props.button,
980
+ target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
981
+ style,
982
+ href: props.href,
983
+ children: (_a = props.text) != null ? _a : props.children
844
984
  });
845
985
  return /* @__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
986
+ href: props.href,
987
+ target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
988
+ style,
989
+ children: (_b = props.text) != null ? _b : props.children
853
990
  });
854
991
  }
855
- if (button)
856
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Button, {
857
- ...button,
858
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
859
- to: href,
860
- target: target || (Link2 == null ? void 0 : Link2.target),
861
- style: {
862
- ...Link2.style,
863
- ...style || {}
864
- },
865
- children: text || children
992
+ if (props.button)
993
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
994
+ to: props.href,
995
+ target: props.target || (Link2 == null ? void 0 : Link2.target),
996
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
997
+ ...props.button,
998
+ style,
999
+ children: (_c = props.text) != null ? _c : props.children
866
1000
  })
867
1001
  });
868
1002
  return /* @__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
1003
+ to: props.href,
1004
+ target: props.target || (Link2 == null ? void 0 : Link2.target),
1005
+ style,
1006
+ children: (_d = props.text) != null ? _d : props.children
876
1007
  });
877
1008
  }
878
1009
 
879
1010
  // src/Modal.tsx
880
- var import_antd8 = require("antd");
881
- var import_react9 = require("react");
1011
+ var import_antd9 = require("antd");
1012
+ var import_react10 = require("react");
882
1013
  var import_jsx_runtime = require("react/jsx-runtime");
883
1014
  function useModal(init) {
884
- const [props, setProps] = (0, import_react9.useState)({
1015
+ const [props, setProps] = (0, import_react10.useState)({
885
1016
  open: false,
886
1017
  onCancel: () => setProps((prev) => ({
887
1018
  ...prev,
@@ -890,7 +1021,7 @@ function useModal(init) {
890
1021
  ...init
891
1022
  });
892
1023
  return {
893
- modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Modal, {
1024
+ modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Modal, {
894
1025
  ...props
895
1026
  }),
896
1027
  modalProps: props,
@@ -904,13 +1035,13 @@ function useModal(init) {
904
1035
  }
905
1036
 
906
1037
  // src/Routers.tsx
907
- var import_antd9 = require("antd");
908
- var import_react10 = require("react");
1038
+ var import_antd10 = require("antd");
1039
+ var import_react11 = require("react");
909
1040
  var import_react_router_dom2 = require("react-router-dom");
910
1041
  var import_jsx_runtime = require("react/jsx-runtime");
911
1042
  function PageNotFound() {
912
1043
  const config = useConfigContext();
913
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Result, {
1044
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Result, {
914
1045
  status: "404",
915
1046
  title: config.common.pageNotFound
916
1047
  });
@@ -920,10 +1051,10 @@ function Routes(props) {
920
1051
  children: [
921
1052
  props.routes.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom2.Route, {
922
1053
  ...r,
923
- element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react10.Suspense, {
1054
+ element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react11.Suspense, {
924
1055
  fallback: props.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
925
1056
  style: { padding: "24px" },
926
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Skeleton, {
1057
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Skeleton, {
927
1058
  active: true
928
1059
  })
929
1060
  }),
@@ -939,12 +1070,11 @@ function Routes(props) {
939
1070
  }
940
1071
 
941
1072
  // src/Table.tsx
942
- var import_react11 = require("react");
943
- var import_antd10 = require("antd");
1073
+ var import_react12 = require("react");
1074
+ var import_antd11 = require("antd");
944
1075
  var import_dayjs2 = __toESM(require("dayjs"));
945
1076
  var import_icons3 = require("@ant-design/icons");
946
1077
  var import_lodash_es6 = require("lodash-es");
947
- var import_react12 = require("@faasjs/react");
948
1078
  var import_jsx_runtime = require("react/jsx-runtime");
949
1079
  function processValue(item, value) {
950
1080
  var _a;
@@ -971,9 +1101,9 @@ function processValue(item, value) {
971
1101
  return value;
972
1102
  }
973
1103
  function Table(props) {
974
- const [columns, setColumns] = (0, import_react11.useState)();
975
- const { common: common2, antd } = useConfigContext();
976
- (0, import_react11.useEffect)(() => {
1104
+ const [columns, setColumns] = (0, import_react12.useState)();
1105
+ const { common: common2 } = useConfigContext();
1106
+ (0, import_react12.useEffect)(() => {
977
1107
  var _a;
978
1108
  for (const item of props.items) {
979
1109
  if (!item.key)
@@ -989,15 +1119,39 @@ function Table(props) {
989
1119
  item.filters = item.options.map((o) => ({
990
1120
  text: o.label,
991
1121
  value: o.value
992
- }));
1122
+ })).concat({
1123
+ text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1124
+ value: null
1125
+ });
993
1126
  }
994
- if (item.children)
995
- delete item.children;
1127
+ if (item.tableChildren === null)
1128
+ item.render = () => null;
1129
+ else if (item.tableChildren)
1130
+ item.render = (value, values) => (0, import_react12.cloneElement)(
1131
+ item.tableChildren,
1132
+ {
1133
+ scene: "table",
1134
+ value,
1135
+ values
1136
+ }
1137
+ );
1138
+ else if (item.children === null)
1139
+ item.render = () => null;
1140
+ else if (item.children)
1141
+ item.render = (value, values) => (0, import_react12.cloneElement)(
1142
+ item.children,
1143
+ {
1144
+ scene: "table",
1145
+ value,
1146
+ values
1147
+ }
1148
+ );
996
1149
  if (props.extendTypes && props.extendTypes[item.type]) {
997
1150
  if (props.extendTypes[item.type].children)
998
- item.render = (value, values) => (0, import_react11.cloneElement)(
1151
+ item.render = (value, values) => (0, import_react12.cloneElement)(
999
1152
  props.extendTypes[item.type].children,
1000
1153
  {
1154
+ scene: "table",
1001
1155
  value,
1002
1156
  values
1003
1157
  }
@@ -1025,7 +1179,7 @@ function Table(props) {
1025
1179
  setSelectedKeys,
1026
1180
  confirm,
1027
1181
  clearFilters
1028
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Input.Search, {
1182
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
1029
1183
  placeholder: `${common2.search} ${item.title}`,
1030
1184
  allowClear: true,
1031
1185
  onSearch: (v) => {
@@ -1055,7 +1209,7 @@ function Table(props) {
1055
1209
  setSelectedKeys,
1056
1210
  confirm,
1057
1211
  clearFilters
1058
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Input.Search, {
1212
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
1059
1213
  placeholder: `${common2.search} ${item.title}`,
1060
1214
  allowClear: true,
1061
1215
  onSearch: (v) => {
@@ -1078,14 +1232,14 @@ function Table(props) {
1078
1232
  item.onFilter = (value, row) => {
1079
1233
  if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
1080
1234
  return true;
1081
- return value === row[item.id];
1235
+ return value == row[item.id];
1082
1236
  };
1083
1237
  if (!item.filters && item.filterDropdown !== false)
1084
1238
  item.filterDropdown = ({
1085
1239
  setSelectedKeys,
1086
1240
  confirm,
1087
1241
  clearFilters
1088
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Input.Search, {
1242
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
1089
1243
  placeholder: `${common2.search} ${item.title}`,
1090
1244
  allowClear: true,
1091
1245
  onSearch: (v) => {
@@ -1108,14 +1262,14 @@ function Table(props) {
1108
1262
  return true;
1109
1263
  if (!row[item.id] || !row[item.id].length)
1110
1264
  return false;
1111
- return row[item.id].includes(value);
1265
+ return row[item.id].includes(Number(value));
1112
1266
  };
1113
1267
  if (!item.filters && item.filterDropdown !== false)
1114
1268
  item.filterDropdown = ({
1115
1269
  setSelectedKeys,
1116
1270
  confirm,
1117
1271
  clearFilters
1118
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Input.Search, {
1272
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
1119
1273
  placeholder: `${common2.search} ${item.title}`,
1120
1274
  allowClear: true,
1121
1275
  onSearch: (v) => {
@@ -1147,7 +1301,7 @@ function Table(props) {
1147
1301
  setSelectedKeys,
1148
1302
  selectedKeys,
1149
1303
  confirm
1150
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd10.Radio.Group, {
1304
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd11.Radio.Group, {
1151
1305
  style: { padding: 8 },
1152
1306
  buttonStyle: "solid",
1153
1307
  value: selectedKeys[0],
@@ -1156,10 +1310,10 @@ function Table(props) {
1156
1310
  confirm();
1157
1311
  },
1158
1312
  children: [
1159
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Radio.Button, {
1313
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
1160
1314
  children: common2.all
1161
1315
  }),
1162
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Radio.Button, {
1316
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
1163
1317
  value: "true",
1164
1318
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
1165
1319
  style: {
@@ -1168,7 +1322,7 @@ function Table(props) {
1168
1322
  }
1169
1323
  })
1170
1324
  }),
1171
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Radio.Button, {
1325
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
1172
1326
  value: "false",
1173
1327
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CloseOutlined, {
1174
1328
  style: {
@@ -1177,7 +1331,7 @@ function Table(props) {
1177
1331
  }
1178
1332
  })
1179
1333
  }),
1180
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Radio.Button, {
1334
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
1181
1335
  value: "empty",
1182
1336
  children: common2.blank
1183
1337
  })
@@ -1223,11 +1377,13 @@ function Table(props) {
1223
1377
  break;
1224
1378
  case "object[]":
1225
1379
  if (!item.render)
1226
- item.render = (value) => value.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
1227
- items: item.object,
1228
- dataSource: v || [],
1229
- column: 1
1230
- }, i));
1380
+ item.render = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
1381
+ children: value.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
1382
+ items: item.object,
1383
+ dataSource: v || [],
1384
+ column: 1
1385
+ }, i))
1386
+ });
1231
1387
  break;
1232
1388
  default:
1233
1389
  if (!item.render)
@@ -1243,100 +1399,129 @@ function Table(props) {
1243
1399
  }
1244
1400
  setColumns(props.items);
1245
1401
  }, [props.items]);
1246
- (0, import_react11.useEffect)(() => {
1402
+ (0, import_react12.useEffect)(() => {
1247
1403
  if (!props.dataSource || !columns)
1248
1404
  return;
1249
1405
  for (const column of columns) {
1250
1406
  if (column.optionsType === "auto" && !column.options && !column.filters) {
1251
- setColumns((prev) => {
1252
- const newColumns = [...prev];
1253
- const index = newColumns.findIndex((item) => item.id === column.id);
1254
- newColumns[index].filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
1255
- text: v[column.id],
1256
- value: v[column.id]
1257
- })).concat({
1258
- text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1259
- value: null
1407
+ const filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
1408
+ text: v[column.id],
1409
+ value: v[column.id]
1410
+ }));
1411
+ if (filters.length)
1412
+ setColumns((prev) => {
1413
+ const newColumns = [...prev];
1414
+ const index = newColumns.findIndex((item) => item.id === column.id);
1415
+ newColumns[index].filters = filters.concat({
1416
+ text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1417
+ value: null
1418
+ });
1419
+ return newColumns;
1260
1420
  });
1261
- return newColumns;
1262
- });
1263
1421
  }
1264
1422
  }
1265
1423
  }, [props.dataSource, columns]);
1266
1424
  if (!columns)
1267
1425
  return null;
1268
- if (!props.faasData)
1269
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1270
- ...antd,
1271
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1272
- ...props,
1273
- rowKey: props.rowKey || "id",
1274
- columns,
1275
- dataSource: props.dataSource
1276
- })
1426
+ if (props.dataSource)
1427
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
1428
+ ...props,
1429
+ rowKey: props.rowKey || "id",
1430
+ columns,
1431
+ dataSource: props.dataSource
1277
1432
  });
1278
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react12.FaasDataWrapper, {
1279
- fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Skeleton, {
1280
- active: true
1281
- }),
1282
- render: ({
1283
- data,
1284
- params,
1285
- reload
1286
- }) => {
1287
- if (!data)
1288
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1289
- ...antd,
1290
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1291
- ...props,
1292
- rowKey: props.rowKey || "id",
1293
- columns,
1294
- dataSource: []
1295
- })
1296
- });
1297
- if (Array.isArray(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: data
1305
- })
1306
- });
1307
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.ConfigProvider, {
1308
- ...antd,
1309
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Table, {
1310
- ...props,
1311
- rowKey: props.rowKey || "id",
1312
- columns,
1313
- dataSource: data.rows,
1314
- pagination: {
1315
- ...props.pagination,
1316
- ...data.pagination
1317
- },
1318
- onChange: (pagination, filters, sorter, extra) => {
1319
- if (props.onChange) {
1320
- const processed = props.onChange(pagination, filters, sorter, extra);
1321
- reload({
1322
- ...params,
1323
- pagination: processed.pagination,
1324
- filters: processed.filters,
1325
- sorter: processed.sorter
1326
- });
1327
- return;
1328
- }
1329
- reload({
1330
- ...params,
1331
- pagination,
1332
- filters,
1333
- sorter
1433
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
1434
+ ...props.faasData,
1435
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataTable, {
1436
+ props,
1437
+ columns
1438
+ })
1439
+ });
1440
+ }
1441
+ function FaasDataTable({
1442
+ props,
1443
+ columns,
1444
+ data,
1445
+ params,
1446
+ reload
1447
+ }) {
1448
+ const [currentColumns, setCurrentColumns] = (0, import_react12.useState)(columns);
1449
+ (0, import_react12.useEffect)(() => {
1450
+ if (!data || Array.isArray(data))
1451
+ return;
1452
+ setCurrentColumns((prev) => {
1453
+ const newColumns = [...prev];
1454
+ for (const column of newColumns) {
1455
+ if (data["options"] && data.options[column.id]) {
1456
+ column.options = data["options"][column.id];
1457
+ column.filters = data["options"][column.id].map((v) => ({
1458
+ text: v.label,
1459
+ value: v.value
1460
+ })).concat({
1461
+ text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1462
+ value: null
1463
+ });
1464
+ column.render = (value) => processValue(column, value);
1465
+ if (column.filterDropdown)
1466
+ delete column.filterDropdown;
1467
+ continue;
1468
+ }
1469
+ if (column.optionsType === "auto" && !column.options && !column.filters) {
1470
+ const filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
1471
+ text: v[column.id],
1472
+ value: v[column.id]
1473
+ }));
1474
+ if (filters.length)
1475
+ column.filters = filters.concat({
1476
+ text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
1477
+ value: null
1334
1478
  });
1335
- }
1336
- })
1337
- });
1479
+ }
1480
+ }
1481
+ return newColumns;
1482
+ });
1483
+ }, [columns, data]);
1484
+ if (!data)
1485
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
1486
+ ...props,
1487
+ rowKey: props.rowKey || "id",
1488
+ columns: currentColumns,
1489
+ dataSource: []
1490
+ });
1491
+ if (Array.isArray(data))
1492
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
1493
+ ...props,
1494
+ rowKey: props.rowKey || "id",
1495
+ columns: currentColumns,
1496
+ dataSource: data
1497
+ });
1498
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
1499
+ ...props,
1500
+ rowKey: props.rowKey || "id",
1501
+ columns: currentColumns,
1502
+ dataSource: data.rows,
1503
+ pagination: {
1504
+ ...props.pagination,
1505
+ ...data.pagination
1338
1506
  },
1339
- ...props.faasData
1507
+ onChange: (pagination, filters, sorter, extra) => {
1508
+ if (props.onChange) {
1509
+ const processed = props.onChange(pagination, filters, sorter, extra);
1510
+ reload({
1511
+ ...params,
1512
+ pagination: processed.pagination,
1513
+ filters: processed.filters,
1514
+ sorter: processed.sorter
1515
+ });
1516
+ return;
1517
+ }
1518
+ reload({
1519
+ ...params,
1520
+ pagination,
1521
+ filters,
1522
+ sorter
1523
+ });
1524
+ }
1340
1525
  });
1341
1526
  }
1342
1527
 
@@ -1375,9 +1560,12 @@ function Title(props) {
1375
1560
  ConfigProvider,
1376
1561
  Description,
1377
1562
  Drawer,
1563
+ ErrorBoundary,
1564
+ FaasDataWrapper,
1378
1565
  Form,
1379
1566
  FormItem,
1380
1567
  Link,
1568
+ Loading,
1381
1569
  Modal,
1382
1570
  PageNotFound,
1383
1571
  Routes,