@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.mjs CHANGED
@@ -12,7 +12,6 @@ import {
12
12
  useEffect,
13
13
  useState
14
14
  } from "react";
15
- import { ConfigProvider as AntdConfigProvider } from "antd";
16
15
  import { defaultsDeep } from "lodash-es";
17
16
  import { jsx } from "react/jsx-runtime";
18
17
  var isZH = /^zh/i.test(navigator.language);
@@ -68,14 +67,11 @@ function ConfigProvider({
68
67
  Form: { submit: { text: zh.submit } }
69
68
  }, baseConfig));
70
69
  } else
71
- setValues(values);
70
+ setValues(defaultsDeep(config, values));
72
71
  }, []);
73
72
  return /* @__PURE__ */ jsx(ConfigContext.Provider, {
74
73
  value: values,
75
- children: /* @__PURE__ */ jsx(AntdConfigProvider, {
76
- ...config.antd,
77
- children
78
- })
74
+ children
79
75
  });
80
76
  }
81
77
  function useConfigContext() {
@@ -123,7 +119,6 @@ function transferValue(type, value) {
123
119
  import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
124
120
  import {
125
121
  Descriptions,
126
- Skeleton,
127
122
  Space
128
123
  } from "antd";
129
124
  import { isFunction, upperFirst as upperFirst2 } from "lodash-es";
@@ -132,8 +127,45 @@ import {
132
127
  useEffect as useEffect2,
133
128
  useState as useState2
134
129
  } from "react";
135
- import { FaasDataWrapper } from "@faasjs/react";
130
+
131
+ // src/FaasDataWrapper.tsx
132
+ import { FaasDataWrapper as Origin } from "@faasjs/react";
133
+
134
+ // src/Loading.tsx
135
+ import { Spin } from "antd";
136
136
  import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
137
+ function Loading(props) {
138
+ if (props.loading === false)
139
+ return /* @__PURE__ */ jsx3(Fragment, {
140
+ children: props.children
141
+ });
142
+ return /* @__PURE__ */ jsx3("div", {
143
+ style: {
144
+ ...props.style || {},
145
+ ...!props.size || props.size === "large" ? {
146
+ margin: "20vh auto",
147
+ textAlign: "center"
148
+ } : {}
149
+ },
150
+ children: /* @__PURE__ */ jsx3(Spin, {
151
+ size: props.size || "large"
152
+ })
153
+ });
154
+ }
155
+
156
+ // src/FaasDataWrapper.tsx
157
+ import { jsx as jsx4 } from "react/jsx-runtime";
158
+ function FaasDataWrapper(props) {
159
+ return /* @__PURE__ */ jsx4(Origin, {
160
+ fallback: props.loading || /* @__PURE__ */ jsx4(Loading, {
161
+ ...props.loadingProps
162
+ }),
163
+ ...props
164
+ });
165
+ }
166
+
167
+ // src/Description.tsx
168
+ import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
137
169
  function DescriptionItemContent(props) {
138
170
  var _a;
139
171
  const [computedProps, setComputedProps] = useState2();
@@ -170,69 +202,84 @@ function DescriptionItemContent(props) {
170
202
  return cloneElement(
171
203
  computedProps.extendTypes[computedProps.item.type].children,
172
204
  {
205
+ scene: "description",
173
206
  value: computedProps.value,
174
207
  values: computedProps.values
175
208
  }
176
209
  );
177
210
  else if (computedProps.extendTypes[computedProps.item.type].render)
178
- return /* @__PURE__ */ jsx3(Fragment, {
179
- children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values)
211
+ return /* @__PURE__ */ jsx5(Fragment2, {
212
+ children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
180
213
  });
181
214
  else
182
215
  throw Error(computedProps.item.type + " requires children or render");
216
+ if (computedProps.item.descriptionChildren === null)
217
+ return null;
218
+ if (computedProps.item.descriptionChildren)
219
+ return cloneElement(computedProps.item.descriptionChildren, {
220
+ scene: "description",
221
+ value: computedProps.value,
222
+ values: computedProps.values
223
+ });
224
+ if (computedProps.item.children === null)
225
+ return null;
183
226
  if (computedProps.item.children)
184
- return cloneElement(computedProps.item.children, { value: computedProps.value });
185
- if (computedProps.item.render)
186
- return /* @__PURE__ */ jsx3(Fragment, {
187
- children: computedProps.item.render(computedProps.value, computedProps.values)
227
+ return cloneElement(computedProps.item.children, {
228
+ scene: "description",
229
+ value: computedProps.value,
230
+ values: computedProps.values
188
231
  });
232
+ if (computedProps.item.descriptionRender)
233
+ return computedProps.item.descriptionRender(computedProps.value, computedProps.values, 0, "description");
234
+ if (computedProps.item.render)
235
+ return computedProps.item.render(computedProps.value, computedProps.values, 0, "description");
189
236
  if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
190
- return /* @__PURE__ */ jsx3(Blank, {});
237
+ return /* @__PURE__ */ jsx5(Blank, {});
191
238
  switch (computedProps.item.type) {
192
239
  case "string[]":
193
- return /* @__PURE__ */ jsx3(Fragment, {
240
+ return /* @__PURE__ */ jsx5(Fragment2, {
194
241
  children: computedProps.value.join(", ")
195
242
  });
196
243
  case "number":
197
244
  return computedProps.value || null;
198
245
  case "number[]":
199
- return /* @__PURE__ */ jsx3(Fragment, {
246
+ return /* @__PURE__ */ jsx5(Fragment2, {
200
247
  children: computedProps.value.join(", ")
201
248
  });
202
249
  case "boolean":
203
- return computedProps.value ? /* @__PURE__ */ jsx3(CheckOutlined, {
250
+ return computedProps.value ? /* @__PURE__ */ jsx5(CheckOutlined, {
204
251
  style: {
205
252
  marginTop: "4px",
206
253
  color: "#52c41a"
207
254
  }
208
- }) : /* @__PURE__ */ jsx3(CloseOutlined, {
255
+ }) : /* @__PURE__ */ jsx5(CloseOutlined, {
209
256
  style: {
210
257
  marginTop: "4px",
211
258
  color: "#ff4d4f"
212
259
  }
213
260
  });
214
261
  case "time":
215
- return /* @__PURE__ */ jsx3(Fragment, {
262
+ return /* @__PURE__ */ jsx5(Fragment2, {
216
263
  children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
217
264
  });
218
265
  case "date":
219
- return /* @__PURE__ */ jsx3(Fragment, {
266
+ return /* @__PURE__ */ jsx5(Fragment2, {
220
267
  children: computedProps.value.format("YYYY-MM-DD")
221
268
  });
222
269
  case "object":
223
270
  if (!computedProps.value)
224
- return /* @__PURE__ */ jsx3(Blank, {});
225
- return /* @__PURE__ */ jsx3(Description, {
271
+ return /* @__PURE__ */ jsx5(Blank, {});
272
+ return /* @__PURE__ */ jsx5(Description, {
226
273
  items: computedProps.item.object,
227
274
  dataSource: computedProps.value,
228
275
  column: 1
229
276
  });
230
277
  case "object[]":
231
278
  if (!((_a = computedProps.value) == null ? void 0 : _a.length))
232
- return /* @__PURE__ */ jsx3(Blank, {});
233
- return /* @__PURE__ */ jsx3(Space, {
279
+ return /* @__PURE__ */ jsx5(Blank, {});
280
+ return /* @__PURE__ */ jsx5(Space, {
234
281
  direction: "vertical",
235
- children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx3(Description, {
282
+ children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx5(Description, {
236
283
  items: computedProps.item.object,
237
284
  dataSource: value,
238
285
  column: 1
@@ -243,14 +290,14 @@ function DescriptionItemContent(props) {
243
290
  }
244
291
  }
245
292
  function Description(props) {
246
- if (!props.faasData)
247
- return /* @__PURE__ */ jsx3(Descriptions, {
293
+ if (props.dataSource)
294
+ return /* @__PURE__ */ jsx5(Descriptions, {
248
295
  ...props,
249
296
  title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
250
297
  children: props.items.map((item) => {
251
- return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
298
+ return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx5(Descriptions.Item, {
252
299
  label: item.title || upperFirst2(item.id),
253
- children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
300
+ children: /* @__PURE__ */ jsx5(DescriptionItemContent, {
254
301
  item,
255
302
  value: props.dataSource[item.id],
256
303
  values: props.dataSource,
@@ -259,18 +306,15 @@ function Description(props) {
259
306
  }, item.id) : null;
260
307
  }).filter(Boolean)
261
308
  });
262
- return /* @__PURE__ */ jsx3(FaasDataWrapper, {
263
- fallback: props.faasData.fallback || /* @__PURE__ */ jsx3(Skeleton, {
264
- active: true
265
- }),
309
+ return /* @__PURE__ */ jsx5(FaasDataWrapper, {
266
310
  render: ({ data }) => {
267
- return /* @__PURE__ */ jsx3(Descriptions, {
311
+ return /* @__PURE__ */ jsx5(Descriptions, {
268
312
  ...props,
269
313
  title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
270
314
  children: props.items.map((item) => {
271
- return !item.if || item.if(data) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
315
+ return !item.if || item.if(data) ? /* @__PURE__ */ jsx5(Descriptions.Item, {
272
316
  label: item.title || upperFirst2(item.id),
273
- children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
317
+ children: /* @__PURE__ */ jsx5(DescriptionItemContent, {
274
318
  item,
275
319
  value: data[item.id],
276
320
  values: data,
@@ -287,7 +331,7 @@ function Description(props) {
287
331
  // src/Drawer.tsx
288
332
  import { Drawer } from "antd";
289
333
  import { useState as useState3 } from "react";
290
- import { jsx as jsx4 } from "react/jsx-runtime";
334
+ import { jsx as jsx6 } from "react/jsx-runtime";
291
335
  function useDrawer(init) {
292
336
  const [props, setProps] = useState3({
293
337
  open: false,
@@ -298,7 +342,7 @@ function useDrawer(init) {
298
342
  ...init
299
343
  });
300
344
  return {
301
- drawer: /* @__PURE__ */ jsx4(Drawer, {
345
+ drawer: /* @__PURE__ */ jsx6(Drawer, {
302
346
  ...props
303
347
  }),
304
348
  drawerProps: props,
@@ -311,6 +355,53 @@ function useDrawer(init) {
311
355
  };
312
356
  }
313
357
 
358
+ // src/ErrorBoundary.tsx
359
+ import { Component } from "react";
360
+ import { Alert } from "antd";
361
+ import { jsx as jsx7 } from "react/jsx-runtime";
362
+ var ErrorBoundary = class extends Component {
363
+ constructor(props) {
364
+ super(props);
365
+ this.state = {
366
+ error: void 0,
367
+ info: { componentStack: "" }
368
+ };
369
+ }
370
+ componentDidCatch(error, info) {
371
+ this.setState({
372
+ error,
373
+ info
374
+ });
375
+ }
376
+ render() {
377
+ const {
378
+ message,
379
+ description,
380
+ children
381
+ } = this.props;
382
+ const { error, info } = this.state;
383
+ const componentStack = info && info.componentStack ? info.componentStack : null;
384
+ const errorMessage = typeof message === "undefined" ? (error || "").toString() : message;
385
+ const errorDescription = typeof description === "undefined" ? componentStack : description;
386
+ if (error) {
387
+ if (this.props.onError)
388
+ return this.props.onError(error, info);
389
+ return /* @__PURE__ */ jsx7(Alert, {
390
+ type: "error",
391
+ message: errorMessage,
392
+ description: /* @__PURE__ */ jsx7("pre", {
393
+ style: {
394
+ fontSize: "0.9em",
395
+ overflowX: "auto"
396
+ },
397
+ children: errorDescription
398
+ })
399
+ });
400
+ }
401
+ return children;
402
+ }
403
+ };
404
+
314
405
  // src/Form.tsx
315
406
  import { faas } from "@faasjs/react";
316
407
  import {
@@ -339,11 +430,12 @@ import {
339
430
  } from "antd";
340
431
  import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
341
432
  import {
433
+ cloneElement as cloneElement2,
342
434
  useEffect as useEffect3,
343
435
  useState as useState4
344
436
  } from "react";
345
437
  import { upperFirst as upperFirst3 } from "lodash-es";
346
- import { Fragment as Fragment2, jsx as jsx5, jsxs } from "react/jsx-runtime";
438
+ import { Fragment as Fragment3, jsx as jsx8, jsxs } from "react/jsx-runtime";
347
439
  function processProps(propsCopy, config) {
348
440
  if (!propsCopy.title)
349
441
  propsCopy.title = upperFirst3(propsCopy.id);
@@ -404,98 +496,116 @@ function FormItem(props) {
404
496
  }
405
497
  if (propsCopy.if) {
406
498
  const condition = propsCopy.if;
407
- propsCopy.shouldUpdate = (_, cur) => {
499
+ const originShouldUpdate = propsCopy.shouldUpdate;
500
+ propsCopy.shouldUpdate = (prev, cur) => {
408
501
  const show = condition(cur);
502
+ const shouldUpdate = hidden !== show;
409
503
  setHidden(!show);
410
- return show;
504
+ const origin = originShouldUpdate ? typeof originShouldUpdate === "boolean" ? originShouldUpdate : originShouldUpdate(prev, cur, {}) : true;
505
+ return shouldUpdate || origin;
411
506
  };
412
507
  delete propsCopy.if;
508
+ delete propsCopy.hidden;
413
509
  }
414
510
  setComputedProps(processProps(propsCopy, common2));
415
511
  }, [props]);
416
512
  if (!computedProps)
417
513
  return null;
418
514
  if (hidden)
419
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
515
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
420
516
  ...computedProps,
421
517
  noStyle: true,
422
518
  rules: [],
423
- children: /* @__PURE__ */ jsx5(Input, {
519
+ children: /* @__PURE__ */ jsx8(Input, {
424
520
  hidden: true
425
521
  })
426
522
  });
427
523
  if (extendTypes && extendTypes[computedProps.type])
428
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
524
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
429
525
  ...computedProps,
430
526
  children: extendTypes[computedProps.type].children
431
527
  });
528
+ if (computedProps.formChildren === null)
529
+ return null;
530
+ if (computedProps.formChildren)
531
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
532
+ ...computedProps,
533
+ children: cloneElement2(computedProps.formChildren, { scene: "form" })
534
+ });
535
+ if (computedProps.children === null)
536
+ return null;
432
537
  if (computedProps.children)
433
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
538
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
434
539
  ...computedProps,
435
- children: computedProps.children
540
+ children: cloneElement2(computedProps.children, { scene: "form" })
541
+ });
542
+ if (computedProps.formRender)
543
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
544
+ ...computedProps,
545
+ children: computedProps.formRender(null, null, 0, "form")
436
546
  });
437
547
  if (computedProps.render)
438
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
548
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
439
549
  ...computedProps,
440
- children: computedProps.render()
550
+ children: computedProps.render(null, null, 0, "form")
441
551
  });
442
552
  switch (computedProps.type) {
443
553
  case "string":
444
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
554
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
445
555
  ...computedProps,
446
- children: computedProps.options ? /* @__PURE__ */ jsx5(Select, {
556
+ children: computedProps.options ? /* @__PURE__ */ jsx8(Select, {
447
557
  ...computedProps.input
448
- }) : /* @__PURE__ */ jsx5(Input, {
558
+ }) : /* @__PURE__ */ jsx8(Input, {
449
559
  ...computedProps.input
450
560
  })
451
561
  });
452
562
  case "string[]":
453
563
  if (computedProps.options)
454
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
564
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
455
565
  ...computedProps,
456
- children: /* @__PURE__ */ jsx5(Select, {
566
+ children: /* @__PURE__ */ jsx8(Select, {
457
567
  mode: "multiple",
458
568
  ...computedProps.input
459
569
  })
460
570
  });
461
- return /* @__PURE__ */ jsx5(AntdForm.List, {
571
+ return /* @__PURE__ */ jsx8(AntdForm.List, {
462
572
  name: computedProps.name,
463
573
  rules: computedProps.rules,
464
574
  children: (fields, { add, remove }, { errors }) => {
465
575
  var _a2;
466
- return /* @__PURE__ */ jsxs(Fragment2, {
576
+ return /* @__PURE__ */ jsxs(Fragment3, {
467
577
  children: [
468
- computedProps.label && /* @__PURE__ */ jsx5("div", {
578
+ computedProps.label && /* @__PURE__ */ jsx8("div", {
469
579
  className: "ant-form-item-label",
470
- children: /* @__PURE__ */ jsx5("label", {
580
+ children: /* @__PURE__ */ jsx8("label", {
471
581
  className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
472
582
  children: computedProps.label
473
583
  })
474
584
  }),
475
585
  fields.map((field) => {
476
586
  var _a3;
477
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
587
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
478
588
  children: /* @__PURE__ */ jsxs(Row, {
479
589
  gutter: 24,
480
590
  style: { flexFlow: "row nowrap" },
481
591
  children: [
482
- /* @__PURE__ */ jsx5(Col, {
592
+ /* @__PURE__ */ jsx8(Col, {
483
593
  span: 23,
484
- children: /* @__PURE__ */ jsx5(AntdForm.Item, {
594
+ children: /* @__PURE__ */ jsx8(AntdForm.Item, {
485
595
  ...field,
486
596
  noStyle: true,
487
- children: /* @__PURE__ */ jsx5(Input, {
597
+ children: /* @__PURE__ */ jsx8(Input, {
488
598
  ...computedProps.input
489
599
  })
490
600
  })
491
601
  }),
492
- /* @__PURE__ */ jsx5(Col, {
602
+ /* @__PURE__ */ jsx8(Col, {
493
603
  span: 1,
494
- children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
604
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx8(Button, {
495
605
  danger: true,
496
606
  type: "link",
497
607
  style: { float: "right" },
498
- icon: /* @__PURE__ */ jsx5(MinusCircleOutlined, {}),
608
+ icon: /* @__PURE__ */ jsx8(MinusCircleOutlined, {}),
499
609
  onClick: () => remove(field.name)
500
610
  })
501
611
  })
@@ -505,13 +615,17 @@ function FormItem(props) {
505
615
  }),
506
616
  /* @__PURE__ */ jsxs(AntdForm.Item, {
507
617
  children: [
508
- !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx5(Button, {
618
+ !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx8(Button, {
509
619
  type: "dashed",
510
620
  block: true,
511
621
  onClick: () => add(),
512
- icon: /* @__PURE__ */ jsx5(PlusOutlined, {})
622
+ icon: /* @__PURE__ */ jsx8(PlusOutlined, {})
623
+ }),
624
+ computedProps.extra && /* @__PURE__ */ jsx8("div", {
625
+ className: "ant-form-item-extra",
626
+ children: computedProps.extra
513
627
  }),
514
- /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
628
+ /* @__PURE__ */ jsx8(AntdForm.ErrorList, {
515
629
  errors
516
630
  })
517
631
  ]
@@ -521,63 +635,63 @@ function FormItem(props) {
521
635
  }
522
636
  });
523
637
  case "number":
524
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
638
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
525
639
  ...computedProps,
526
- children: computedProps.options ? /* @__PURE__ */ jsx5(Select, {
640
+ children: computedProps.options ? /* @__PURE__ */ jsx8(Select, {
527
641
  ...computedProps.input
528
- }) : /* @__PURE__ */ jsx5(InputNumber, {
642
+ }) : /* @__PURE__ */ jsx8(InputNumber, {
529
643
  style: { width: "100%" },
530
644
  ...computedProps.input
531
645
  })
532
646
  });
533
647
  case "number[]":
534
648
  if (computedProps.options)
535
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
649
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
536
650
  ...computedProps,
537
- children: /* @__PURE__ */ jsx5(Select, {
651
+ children: /* @__PURE__ */ jsx8(Select, {
538
652
  mode: "multiple",
539
653
  ...computedProps.input
540
654
  })
541
655
  });
542
- return /* @__PURE__ */ jsx5(AntdForm.List, {
656
+ return /* @__PURE__ */ jsx8(AntdForm.List, {
543
657
  name: computedProps.name,
544
658
  rules: computedProps.rules,
545
659
  children: (fields, { add, remove }, { errors }) => {
546
660
  var _a2, _b;
547
- return /* @__PURE__ */ jsxs(Fragment2, {
661
+ return /* @__PURE__ */ jsxs(Fragment3, {
548
662
  children: [
549
- computedProps.label && /* @__PURE__ */ jsx5("div", {
663
+ computedProps.label && /* @__PURE__ */ jsx8("div", {
550
664
  className: "ant-form-item-label",
551
- children: /* @__PURE__ */ jsx5("label", {
665
+ children: /* @__PURE__ */ jsx8("label", {
552
666
  className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required",
553
667
  children: computedProps.label
554
668
  })
555
669
  }),
556
670
  fields.map((field) => {
557
671
  var _a3;
558
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
672
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
559
673
  children: /* @__PURE__ */ jsxs(Row, {
560
674
  gutter: 24,
561
675
  style: { flexFlow: "row nowrap" },
562
676
  children: [
563
- /* @__PURE__ */ jsx5(Col, {
677
+ /* @__PURE__ */ jsx8(Col, {
564
678
  span: 23,
565
- children: /* @__PURE__ */ jsx5(AntdForm.Item, {
679
+ children: /* @__PURE__ */ jsx8(AntdForm.Item, {
566
680
  ...field,
567
681
  noStyle: true,
568
- children: /* @__PURE__ */ jsx5(InputNumber, {
682
+ children: /* @__PURE__ */ jsx8(InputNumber, {
569
683
  style: { width: "100%" },
570
684
  ...computedProps.input
571
685
  })
572
686
  })
573
687
  }),
574
- /* @__PURE__ */ jsx5(Col, {
688
+ /* @__PURE__ */ jsx8(Col, {
575
689
  span: 1,
576
- children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
690
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx8(Button, {
577
691
  danger: true,
578
692
  type: "link",
579
693
  style: { float: "right" },
580
- icon: /* @__PURE__ */ jsx5(MinusCircleOutlined, {}),
694
+ icon: /* @__PURE__ */ jsx8(MinusCircleOutlined, {}),
581
695
  onClick: () => remove(field.name)
582
696
  })
583
697
  })
@@ -587,13 +701,17 @@ function FormItem(props) {
587
701
  }),
588
702
  /* @__PURE__ */ jsxs(AntdForm.Item, {
589
703
  children: [
590
- !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx5(Button, {
704
+ !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx8(Button, {
591
705
  type: "dashed",
592
706
  block: true,
593
707
  onClick: () => add(),
594
- icon: /* @__PURE__ */ jsx5(PlusOutlined, {})
708
+ icon: /* @__PURE__ */ jsx8(PlusOutlined, {})
595
709
  }),
596
- /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
710
+ computedProps.extra && /* @__PURE__ */ jsx8("div", {
711
+ className: "ant-form-item-extra",
712
+ children: computedProps.extra
713
+ }),
714
+ /* @__PURE__ */ jsx8(AntdForm.ErrorList, {
597
715
  errors
598
716
  })
599
717
  ]
@@ -603,58 +721,58 @@ function FormItem(props) {
603
721
  }
604
722
  });
605
723
  case "boolean":
606
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
724
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
607
725
  ...computedProps,
608
- children: /* @__PURE__ */ jsx5(Switch, {
726
+ children: /* @__PURE__ */ jsx8(Switch, {
609
727
  ...computedProps.input
610
728
  })
611
729
  });
612
730
  case "date":
613
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
731
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
614
732
  ...computedProps,
615
- children: /* @__PURE__ */ jsx5(DatePicker, {
733
+ children: /* @__PURE__ */ jsx8(DatePicker, {
616
734
  ...computedProps.input
617
735
  })
618
736
  });
619
737
  case "time":
620
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
738
+ return /* @__PURE__ */ jsx8(AntdForm.Item, {
621
739
  ...computedProps,
622
- children: /* @__PURE__ */ jsx5(TimePicker, {
740
+ children: /* @__PURE__ */ jsx8(TimePicker, {
623
741
  ...computedProps.input
624
742
  })
625
743
  });
626
744
  case "object":
627
- return /* @__PURE__ */ jsxs(Fragment2, {
745
+ return /* @__PURE__ */ jsxs(Fragment3, {
628
746
  children: [
629
- computedProps.label && /* @__PURE__ */ jsx5("div", {
747
+ computedProps.label && /* @__PURE__ */ jsx8("div", {
630
748
  className: "ant-form-item-label",
631
- children: /* @__PURE__ */ jsx5("label", {
749
+ children: /* @__PURE__ */ jsx8("label", {
632
750
  className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
633
751
  children: computedProps.label
634
752
  })
635
753
  }),
636
- computedProps.object.map((o) => /* @__PURE__ */ jsx5(FormItem, {
754
+ computedProps.object.map((o) => /* @__PURE__ */ jsx8(FormItem, {
637
755
  ...o
638
756
  }, o.id))
639
757
  ]
640
758
  });
641
759
  case "object[]":
642
- return /* @__PURE__ */ jsx5(AntdForm.List, {
760
+ return /* @__PURE__ */ jsx8(AntdForm.List, {
643
761
  name: computedProps.name,
644
762
  rules: computedProps.rules,
645
- children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(Fragment2, {
763
+ children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(Fragment3, {
646
764
  children: [
647
765
  fields.map((field) => /* @__PURE__ */ jsxs(AntdForm.Item, {
648
766
  style: { marginBottom: 0 },
649
767
  children: [
650
- /* @__PURE__ */ jsx5("div", {
768
+ /* @__PURE__ */ jsx8("div", {
651
769
  className: "ant-form-item-label",
652
770
  children: /* @__PURE__ */ jsxs("label", {
653
771
  children: [
654
772
  computedProps.label,
655
773
  " ",
656
774
  field.name + 1,
657
- !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
775
+ !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx8(Button, {
658
776
  danger: true,
659
777
  type: "link",
660
778
  onClick: () => remove(field.name),
@@ -663,11 +781,11 @@ function FormItem(props) {
663
781
  ]
664
782
  })
665
783
  }),
666
- /* @__PURE__ */ jsx5(Row, {
784
+ /* @__PURE__ */ jsx8(Row, {
667
785
  gutter: 24,
668
- children: computedProps.object.map((o) => /* @__PURE__ */ jsx5(Col, {
786
+ children: computedProps.object.map((o) => /* @__PURE__ */ jsx8(Col, {
669
787
  span: o.col || 24,
670
- children: /* @__PURE__ */ jsx5(FormItem, {
788
+ children: /* @__PURE__ */ jsx8(FormItem, {
671
789
  ...o,
672
790
  name: [field.name, o.id]
673
791
  })
@@ -681,14 +799,18 @@ function FormItem(props) {
681
799
  type: "dashed",
682
800
  block: true,
683
801
  onClick: () => add(),
684
- icon: /* @__PURE__ */ jsx5(PlusOutlined, {}),
802
+ icon: /* @__PURE__ */ jsx8(PlusOutlined, {}),
685
803
  children: [
686
804
  common2.add,
687
805
  " ",
688
806
  computedProps.label
689
807
  ]
690
808
  }),
691
- /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
809
+ computedProps.extra && /* @__PURE__ */ jsx8("div", {
810
+ className: "ant-form-item-extra",
811
+ children: computedProps.extra
812
+ }),
813
+ /* @__PURE__ */ jsx8(AntdForm.ErrorList, {
692
814
  errors
693
815
  })
694
816
  ]
@@ -700,9 +822,10 @@ function FormItem(props) {
700
822
  return null;
701
823
  }
702
824
  }
825
+ FormItem.useStatus = AntdForm.Item.useStatus;
703
826
 
704
827
  // src/Form.tsx
705
- import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
828
+ import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
706
829
  function Form(props) {
707
830
  var _a, _b;
708
831
  const [loading, setLoading] = useState5(false);
@@ -712,15 +835,15 @@ function Form(props) {
712
835
  const [form] = AntdForm2.useForm(props.form);
713
836
  const [initialValues, setInitialValues] = useState5(props.initialValues);
714
837
  useEffect4(() => {
715
- var _a2, _b2;
838
+ var _a2, _b2, _c;
716
839
  const propsCopy = {
717
840
  ...props,
718
841
  form
719
842
  };
720
- if (propsCopy.initialValues) {
843
+ if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
721
844
  for (const key in propsCopy.initialValues) {
722
845
  propsCopy.initialValues[key] = transferValue(
723
- (_a2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _a2.type,
846
+ (_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
724
847
  propsCopy.initialValues[key]
725
848
  );
726
849
  const item = propsCopy.items.find((item2) => item2.id === key);
@@ -751,13 +874,25 @@ function Form(props) {
751
874
  }
752
875
  setLoading(false);
753
876
  };
754
- } else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
877
+ } else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
755
878
  propsCopy.onFinish = async (values) => {
756
879
  setLoading(true);
757
880
  return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
758
881
  ...values,
759
882
  ...propsCopy.submit.to.params
760
- } : values).finally(() => setLoading(false));
883
+ } : values).then((result) => {
884
+ if (propsCopy.submit.to.then)
885
+ propsCopy.submit.to.then(result);
886
+ return result;
887
+ }).catch((error) => {
888
+ if (propsCopy.submit.to.catch)
889
+ propsCopy.submit.to.catch(error);
890
+ return Promise.reject(error);
891
+ }).finally(() => {
892
+ if (propsCopy.submit.to.finally)
893
+ propsCopy.submit.to.finally();
894
+ setLoading(false);
895
+ });
761
896
  };
762
897
  }
763
898
  if (propsCopy.extendTypes) {
@@ -793,12 +928,12 @@ function Form(props) {
793
928
  onValuesChange,
794
929
  children: [
795
930
  computedProps.beforeItems,
796
- (_a = computedProps.items) == null ? void 0 : _a.map((item) => isValidElement(item) ? item : /* @__PURE__ */ jsx6(FormItem, {
931
+ (_a = computedProps.items) == null ? void 0 : _a.map((item) => isValidElement(item) ? item : /* @__PURE__ */ jsx9(FormItem, {
797
932
  ...item,
798
933
  extendTypes
799
934
  }, item.id)),
800
935
  computedProps.children,
801
- computedProps.submit !== false && /* @__PURE__ */ jsx6(Button2, {
936
+ computedProps.submit !== false && /* @__PURE__ */ jsx9(Button2, {
802
937
  htmlType: "submit",
803
938
  type: "primary",
804
939
  loading,
@@ -809,73 +944,68 @@ function Form(props) {
809
944
  });
810
945
  }
811
946
  Form.useForm = AntdForm2.useForm;
947
+ Form.useFormInstance = AntdForm2.useFormInstance;
948
+ Form.useWatch = AntdForm2.useWatch;
949
+ Form.Item = FormItem;
950
+ Form.List = AntdForm2.List;
951
+ Form.ErrorList = AntdForm2.ErrorList;
952
+ Form.Provider = AntdForm2.Provider;
812
953
 
813
954
  // src/Link.tsx
814
955
  import { Link as RouterLink } from "react-router-dom";
815
956
  import { Button as Button3 } from "antd";
816
- import { jsx as jsx7 } from "react/jsx-runtime";
817
- function Link({
818
- href,
819
- target,
820
- text,
821
- children,
822
- style,
823
- button
824
- }) {
957
+ import { jsx as jsx10 } from "react/jsx-runtime";
958
+ function Link(props) {
959
+ var _a, _b, _c, _d;
825
960
  const { Link: Link2 } = useConfigContext();
826
- style = Object.assign({ cursor: "pointer" }, style);
827
- if (href.startsWith("http")) {
828
- if (button)
829
- return /* @__PURE__ */ jsx7(Button3, {
830
- ...button,
831
- children: /* @__PURE__ */ jsx7("a", {
832
- href,
833
- target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
834
- style: {
835
- ...Link2.style,
836
- ...style || {}
837
- },
838
- children: text || children
839
- })
961
+ let style = {
962
+ ...Link2.style || {},
963
+ cursor: "pointer",
964
+ ...props.style
965
+ };
966
+ if (props.block)
967
+ style = Object.assign({
968
+ display: "block",
969
+ width: "100%"
970
+ }, style);
971
+ if (props.href.startsWith("http")) {
972
+ if (props.button)
973
+ return /* @__PURE__ */ jsx10(Button3, {
974
+ ...props.button,
975
+ target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
976
+ style,
977
+ href: props.href,
978
+ children: (_a = props.text) != null ? _a : props.children
840
979
  });
841
- return /* @__PURE__ */ jsx7("a", {
842
- href,
843
- target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
844
- style: {
845
- ...Link2.style,
846
- ...style || {}
847
- },
848
- children: text || children
980
+ return /* @__PURE__ */ jsx10("a", {
981
+ href: props.href,
982
+ target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
983
+ style,
984
+ children: (_b = props.text) != null ? _b : props.children
849
985
  });
850
986
  }
851
- if (button)
852
- return /* @__PURE__ */ jsx7(Button3, {
853
- ...button,
854
- children: /* @__PURE__ */ jsx7(RouterLink, {
855
- to: href,
856
- target: target || (Link2 == null ? void 0 : Link2.target),
857
- style: {
858
- ...Link2.style,
859
- ...style || {}
860
- },
861
- children: text || children
987
+ if (props.button)
988
+ return /* @__PURE__ */ jsx10(RouterLink, {
989
+ to: props.href,
990
+ target: props.target || (Link2 == null ? void 0 : Link2.target),
991
+ children: /* @__PURE__ */ jsx10(Button3, {
992
+ ...props.button,
993
+ style,
994
+ children: (_c = props.text) != null ? _c : props.children
862
995
  })
863
996
  });
864
- return /* @__PURE__ */ jsx7(RouterLink, {
865
- to: href,
866
- target: target || (Link2 == null ? void 0 : Link2.target),
867
- style: {
868
- ...Link2.style,
869
- ...style || {}
870
- },
871
- children: text || children
997
+ return /* @__PURE__ */ jsx10(RouterLink, {
998
+ to: props.href,
999
+ target: props.target || (Link2 == null ? void 0 : Link2.target),
1000
+ style,
1001
+ children: (_d = props.text) != null ? _d : props.children
872
1002
  });
873
1003
  }
874
1004
 
875
1005
  // src/Modal.tsx
876
1006
  import { Modal } from "antd";
877
1007
  import { useState as useState6 } from "react";
878
- import { jsx as jsx8 } from "react/jsx-runtime";
1008
+ import { jsx as jsx11 } from "react/jsx-runtime";
879
1009
  function useModal(init) {
880
1010
  const [props, setProps] = useState6({
881
1011
  open: false,
@@ -886,7 +1016,7 @@ function useModal(init) {
886
1016
  ...init
887
1017
  });
888
1018
  return {
889
- modal: /* @__PURE__ */ jsx8(Modal, {
1019
+ modal: /* @__PURE__ */ jsx11(Modal, {
890
1020
  ...props
891
1021
  }),
892
1022
  modalProps: props,
@@ -900,7 +1030,7 @@ function useModal(init) {
900
1030
  }
901
1031
 
902
1032
  // src/Routers.tsx
903
- import { Result, Skeleton as Skeleton2 } from "antd";
1033
+ import { Result, Skeleton } from "antd";
904
1034
  import {
905
1035
  Suspense
906
1036
  } from "react";
@@ -908,10 +1038,10 @@ import {
908
1038
  Routes as OriginRoutes,
909
1039
  Route
910
1040
  } from "react-router-dom";
911
- import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
1041
+ import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
912
1042
  function PageNotFound() {
913
1043
  const config = useConfigContext();
914
- return /* @__PURE__ */ jsx9(Result, {
1044
+ return /* @__PURE__ */ jsx12(Result, {
915
1045
  status: "404",
916
1046
  title: config.common.pageNotFound
917
1047
  });
@@ -919,21 +1049,21 @@ function PageNotFound() {
919
1049
  function Routes(props) {
920
1050
  return /* @__PURE__ */ jsxs3(OriginRoutes, {
921
1051
  children: [
922
- props.routes.map((r) => /* @__PURE__ */ jsx9(Route, {
1052
+ props.routes.map((r) => /* @__PURE__ */ jsx12(Route, {
923
1053
  ...r,
924
- element: r.element || /* @__PURE__ */ jsx9(Suspense, {
925
- fallback: props.fallback || /* @__PURE__ */ jsx9("div", {
1054
+ element: r.element || /* @__PURE__ */ jsx12(Suspense, {
1055
+ fallback: props.fallback || /* @__PURE__ */ jsx12("div", {
926
1056
  style: { padding: "24px" },
927
- children: /* @__PURE__ */ jsx9(Skeleton2, {
1057
+ children: /* @__PURE__ */ jsx12(Skeleton, {
928
1058
  active: true
929
1059
  })
930
1060
  }),
931
- children: /* @__PURE__ */ jsx9(r.page, {})
1061
+ children: /* @__PURE__ */ jsx12(r.page, {})
932
1062
  })
933
1063
  }, r.path)),
934
- /* @__PURE__ */ jsx9(Route, {
1064
+ /* @__PURE__ */ jsx12(Route, {
935
1065
  path: "*",
936
- element: props.notFound || /* @__PURE__ */ jsx9(PageNotFound, {})
1066
+ element: props.notFound || /* @__PURE__ */ jsx12(PageNotFound, {})
937
1067
  }, "*")
938
1068
  ]
939
1069
  });
@@ -943,14 +1073,12 @@ function Routes(props) {
943
1073
  import {
944
1074
  useState as useState7,
945
1075
  useEffect as useEffect5,
946
- cloneElement as cloneElement2
1076
+ cloneElement as cloneElement3
947
1077
  } from "react";
948
1078
  import {
949
1079
  Table as AntdTable,
950
1080
  Radio,
951
- Skeleton as Skeleton3,
952
- Input as Input2,
953
- ConfigProvider as ConfigProvider2
1081
+ Input as Input2
954
1082
  } from "antd";
955
1083
  import dayjs2 from "dayjs";
956
1084
  import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
@@ -959,13 +1087,12 @@ import {
959
1087
  uniqBy,
960
1088
  upperFirst as upperFirst4
961
1089
  } from "lodash-es";
962
- import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
963
- import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
1090
+ import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
964
1091
  function processValue(item, value) {
965
1092
  var _a;
966
1093
  const transferred = transferValue(item.type, value);
967
1094
  if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
968
- return /* @__PURE__ */ jsx10(Blank, {});
1095
+ return /* @__PURE__ */ jsx13(Blank, {});
969
1096
  if (item.options) {
970
1097
  if (item.type.endsWith("[]"))
971
1098
  return transferred.map((v) => {
@@ -987,7 +1114,7 @@ function processValue(item, value) {
987
1114
  }
988
1115
  function Table(props) {
989
1116
  const [columns, setColumns] = useState7();
990
- const { common: common2, antd } = useConfigContext();
1117
+ const { common: common2 } = useConfigContext();
991
1118
  useEffect5(() => {
992
1119
  var _a;
993
1120
  for (const item of props.items) {
@@ -1004,15 +1131,39 @@ function Table(props) {
1004
1131
  item.filters = item.options.map((o) => ({
1005
1132
  text: o.label,
1006
1133
  value: o.value
1007
- }));
1134
+ })).concat({
1135
+ text: /* @__PURE__ */ jsx13(Blank, {}),
1136
+ value: null
1137
+ });
1008
1138
  }
1009
- if (item.children)
1010
- delete item.children;
1139
+ if (item.tableChildren === null)
1140
+ item.render = () => null;
1141
+ else if (item.tableChildren)
1142
+ item.render = (value, values) => cloneElement3(
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) => cloneElement3(
1154
+ item.children,
1155
+ {
1156
+ scene: "table",
1157
+ value,
1158
+ values
1159
+ }
1160
+ );
1011
1161
  if (props.extendTypes && props.extendTypes[item.type]) {
1012
1162
  if (props.extendTypes[item.type].children)
1013
- item.render = (value, values) => cloneElement2(
1163
+ item.render = (value, values) => cloneElement3(
1014
1164
  props.extendTypes[item.type].children,
1015
1165
  {
1166
+ scene: "table",
1016
1167
  value,
1017
1168
  values
1018
1169
  }
@@ -1040,7 +1191,7 @@ function Table(props) {
1040
1191
  setSelectedKeys,
1041
1192
  confirm,
1042
1193
  clearFilters
1043
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1194
+ }) => /* @__PURE__ */ jsx13(Input2.Search, {
1044
1195
  placeholder: `${common2.search} ${item.title}`,
1045
1196
  allowClear: true,
1046
1197
  onSearch: (v) => {
@@ -1070,7 +1221,7 @@ function Table(props) {
1070
1221
  setSelectedKeys,
1071
1222
  confirm,
1072
1223
  clearFilters
1073
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1224
+ }) => /* @__PURE__ */ jsx13(Input2.Search, {
1074
1225
  placeholder: `${common2.search} ${item.title}`,
1075
1226
  allowClear: true,
1076
1227
  onSearch: (v) => {
@@ -1093,14 +1244,14 @@ function Table(props) {
1093
1244
  item.onFilter = (value, row) => {
1094
1245
  if (value === null && isNil2(row[item.id]))
1095
1246
  return true;
1096
- return value === row[item.id];
1247
+ return value == row[item.id];
1097
1248
  };
1098
1249
  if (!item.filters && item.filterDropdown !== false)
1099
1250
  item.filterDropdown = ({
1100
1251
  setSelectedKeys,
1101
1252
  confirm,
1102
1253
  clearFilters
1103
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1254
+ }) => /* @__PURE__ */ jsx13(Input2.Search, {
1104
1255
  placeholder: `${common2.search} ${item.title}`,
1105
1256
  allowClear: true,
1106
1257
  onSearch: (v) => {
@@ -1123,14 +1274,14 @@ function Table(props) {
1123
1274
  return true;
1124
1275
  if (!row[item.id] || !row[item.id].length)
1125
1276
  return false;
1126
- return row[item.id].includes(value);
1277
+ return row[item.id].includes(Number(value));
1127
1278
  };
1128
1279
  if (!item.filters && item.filterDropdown !== false)
1129
1280
  item.filterDropdown = ({
1130
1281
  setSelectedKeys,
1131
1282
  confirm,
1132
1283
  clearFilters
1133
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1284
+ }) => /* @__PURE__ */ jsx13(Input2.Search, {
1134
1285
  placeholder: `${common2.search} ${item.title}`,
1135
1286
  allowClear: true,
1136
1287
  onSearch: (v) => {
@@ -1146,12 +1297,12 @@ function Table(props) {
1146
1297
  break;
1147
1298
  case "boolean":
1148
1299
  if (!item.render)
1149
- item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ jsx10(Blank, {}) : value ? /* @__PURE__ */ jsx10(CheckOutlined2, {
1300
+ item.render = (value) => isNil2(value) ? /* @__PURE__ */ jsx13(Blank, {}) : value ? /* @__PURE__ */ jsx13(CheckOutlined2, {
1150
1301
  style: {
1151
1302
  marginTop: "4px",
1152
1303
  color: "#52c41a"
1153
1304
  }
1154
- }) : /* @__PURE__ */ jsx10(CloseOutlined2, {
1305
+ }) : /* @__PURE__ */ jsx13(CloseOutlined2, {
1155
1306
  style: {
1156
1307
  marginTop: "4px",
1157
1308
  color: "#ff4d4f"
@@ -1171,29 +1322,29 @@ function Table(props) {
1171
1322
  confirm();
1172
1323
  },
1173
1324
  children: [
1174
- /* @__PURE__ */ jsx10(Radio.Button, {
1325
+ /* @__PURE__ */ jsx13(Radio.Button, {
1175
1326
  children: common2.all
1176
1327
  }),
1177
- /* @__PURE__ */ jsx10(Radio.Button, {
1178
- value: "true",
1179
- children: /* @__PURE__ */ jsx10(CheckOutlined2, {
1328
+ /* @__PURE__ */ jsx13(Radio.Button, {
1329
+ value: true,
1330
+ children: /* @__PURE__ */ jsx13(CheckOutlined2, {
1180
1331
  style: {
1181
1332
  color: "#52c41a",
1182
1333
  verticalAlign: "middle"
1183
1334
  }
1184
1335
  })
1185
1336
  }),
1186
- /* @__PURE__ */ jsx10(Radio.Button, {
1187
- value: "false",
1188
- children: /* @__PURE__ */ jsx10(CloseOutlined2, {
1337
+ /* @__PURE__ */ jsx13(Radio.Button, {
1338
+ value: false,
1339
+ children: /* @__PURE__ */ jsx13(CloseOutlined2, {
1189
1340
  style: {
1190
1341
  verticalAlign: "middle",
1191
1342
  color: "#ff4d4f"
1192
1343
  }
1193
1344
  })
1194
1345
  }),
1195
- /* @__PURE__ */ jsx10(Radio.Button, {
1196
- value: "empty",
1346
+ /* @__PURE__ */ jsx13(Radio.Button, {
1347
+ value: null,
1197
1348
  children: common2.blank
1198
1349
  })
1199
1350
  ]
@@ -1201,11 +1352,11 @@ function Table(props) {
1201
1352
  if (!item.onFilter)
1202
1353
  item.onFilter = (value, row) => {
1203
1354
  switch (value) {
1204
- case "true":
1355
+ case true:
1205
1356
  return !isNil2(row[item.id]) && !!row[item.id];
1206
- case "false":
1357
+ case false:
1207
1358
  return !isNil2(row[item.id]) && !row[item.id];
1208
- case "empty":
1359
+ case null:
1209
1360
  return isNil2(row[item.id]);
1210
1361
  default:
1211
1362
  return true;
@@ -1216,9 +1367,15 @@ function Table(props) {
1216
1367
  if (!item.render)
1217
1368
  item.render = (value) => processValue(item, value);
1218
1369
  if (!item.onFilter)
1219
- item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
1370
+ item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value), "date");
1220
1371
  if (!item.sorter)
1221
- item.sorter = (a, b) => dayjs2(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1372
+ item.sorter = (a, b, order) => {
1373
+ if (isNil2(a[item.id]))
1374
+ return order === "ascend" ? 1 : -1;
1375
+ if (isNil2(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
+ };
1222
1379
  break;
1223
1380
  case "time":
1224
1381
  if (!item.render)
@@ -1226,11 +1383,17 @@ function Table(props) {
1226
1383
  if (!item.onFilter)
1227
1384
  item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
1228
1385
  if (!item.sorter)
1229
- item.sorter = (a, b) => dayjs2(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1386
+ item.sorter = (a, b, order) => {
1387
+ if (isNil2(a[item.id]))
1388
+ return order === "ascend" ? 1 : -1;
1389
+ if (isNil2(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
+ };
1230
1393
  break;
1231
1394
  case "object":
1232
1395
  if (!item.render)
1233
- item.render = (value) => /* @__PURE__ */ jsx10(Description, {
1396
+ item.render = (value) => /* @__PURE__ */ jsx13(Description, {
1234
1397
  items: item.object,
1235
1398
  dataSource: value || {},
1236
1399
  column: 1
@@ -1238,11 +1401,13 @@ function Table(props) {
1238
1401
  break;
1239
1402
  case "object[]":
1240
1403
  if (!item.render)
1241
- item.render = (value) => value.map((v, i) => /* @__PURE__ */ jsx10(Description, {
1242
- items: item.object,
1243
- dataSource: v || [],
1244
- column: 1
1245
- }, i));
1404
+ item.render = (value) => /* @__PURE__ */ jsx13(Fragment4, {
1405
+ children: value.map((v, i) => /* @__PURE__ */ jsx13(Description, {
1406
+ items: item.object,
1407
+ dataSource: v || [],
1408
+ column: 1
1409
+ }, i))
1410
+ });
1246
1411
  break;
1247
1412
  default:
1248
1413
  if (!item.render)
@@ -1263,101 +1428,130 @@ function Table(props) {
1263
1428
  return;
1264
1429
  for (const column of columns) {
1265
1430
  if (column.optionsType === "auto" && !column.options && !column.filters) {
1266
- setColumns((prev) => {
1267
- const newColumns = [...prev];
1268
- const index = newColumns.findIndex((item) => item.id === column.id);
1269
- newColumns[index].filters = uniqBy(props.dataSource, column.id).map((v) => ({
1270
- text: v[column.id],
1271
- value: v[column.id]
1272
- })).concat({
1273
- text: /* @__PURE__ */ jsx10(Blank, {}),
1274
- value: null
1431
+ const filters = 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__ */ jsx13(Blank, {}),
1441
+ value: null
1442
+ });
1443
+ return newColumns;
1275
1444
  });
1276
- return newColumns;
1277
- });
1278
1445
  }
1279
1446
  }
1280
1447
  }, [props.dataSource, columns]);
1281
1448
  if (!columns)
1282
1449
  return null;
1283
- if (!props.faasData)
1284
- return /* @__PURE__ */ jsx10(ConfigProvider2, {
1285
- ...antd,
1286
- children: /* @__PURE__ */ jsx10(AntdTable, {
1287
- ...props,
1288
- rowKey: props.rowKey || "id",
1289
- columns,
1290
- dataSource: props.dataSource
1291
- })
1450
+ if (props.dataSource)
1451
+ return /* @__PURE__ */ jsx13(AntdTable, {
1452
+ ...props,
1453
+ rowKey: props.rowKey || "id",
1454
+ columns,
1455
+ dataSource: props.dataSource
1292
1456
  });
1293
- return /* @__PURE__ */ jsx10(FaasDataWrapper2, {
1294
- fallback: props.faasData.fallback || /* @__PURE__ */ jsx10(Skeleton3, {
1295
- active: true
1296
- }),
1297
- render: ({
1298
- data,
1299
- params,
1300
- reload
1301
- }) => {
1302
- if (!data)
1303
- return /* @__PURE__ */ jsx10(ConfigProvider2, {
1304
- ...antd,
1305
- children: /* @__PURE__ */ jsx10(AntdTable, {
1306
- ...props,
1307
- rowKey: props.rowKey || "id",
1308
- columns,
1309
- dataSource: []
1310
- })
1311
- });
1312
- if (Array.isArray(data))
1313
- return /* @__PURE__ */ jsx10(ConfigProvider2, {
1314
- ...antd,
1315
- children: /* @__PURE__ */ jsx10(AntdTable, {
1316
- ...props,
1317
- rowKey: props.rowKey || "id",
1318
- columns,
1319
- dataSource: data
1320
- })
1321
- });
1322
- return /* @__PURE__ */ jsx10(ConfigProvider2, {
1323
- ...antd,
1324
- children: /* @__PURE__ */ jsx10(AntdTable, {
1325
- ...props,
1326
- rowKey: props.rowKey || "id",
1327
- columns,
1328
- dataSource: data.rows,
1329
- pagination: {
1330
- ...props.pagination,
1331
- ...data.pagination
1332
- },
1333
- onChange: (pagination, filters, sorter, extra) => {
1334
- if (props.onChange) {
1335
- const processed = props.onChange(pagination, filters, sorter, extra);
1336
- reload({
1337
- ...params,
1338
- pagination: processed.pagination,
1339
- filters: processed.filters,
1340
- sorter: processed.sorter
1341
- });
1342
- return;
1343
- }
1344
- reload({
1345
- ...params,
1346
- pagination,
1347
- filters,
1348
- sorter
1457
+ return /* @__PURE__ */ jsx13(FaasDataWrapper, {
1458
+ ...props.faasData,
1459
+ children: /* @__PURE__ */ jsx13(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] = useState7(columns);
1473
+ useEffect5(() => {
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__ */ jsx13(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 = 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__ */ jsx13(Blank, {}),
1501
+ value: null
1349
1502
  });
1350
- }
1351
- })
1352
- });
1503
+ }
1504
+ }
1505
+ return newColumns;
1506
+ });
1507
+ }, [columns, data]);
1508
+ if (!data)
1509
+ return /* @__PURE__ */ jsx13(AntdTable, {
1510
+ ...props,
1511
+ rowKey: props.rowKey || "id",
1512
+ columns: currentColumns,
1513
+ dataSource: []
1514
+ });
1515
+ if (Array.isArray(data))
1516
+ return /* @__PURE__ */ jsx13(AntdTable, {
1517
+ ...props,
1518
+ rowKey: props.rowKey || "id",
1519
+ columns: currentColumns,
1520
+ dataSource: data
1521
+ });
1522
+ return /* @__PURE__ */ jsx13(AntdTable, {
1523
+ ...props,
1524
+ rowKey: props.rowKey || "id",
1525
+ columns: currentColumns,
1526
+ dataSource: data.rows,
1527
+ pagination: {
1528
+ ...props.pagination,
1529
+ ...data.pagination
1353
1530
  },
1354
- ...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
+ }
1355
1549
  });
1356
1550
  }
1357
1551
 
1358
1552
  // src/Title.tsx
1359
- import { useEffect as useEffect6, cloneElement as cloneElement3 } from "react";
1360
- import { Fragment as Fragment3, jsx as jsx11 } from "react/jsx-runtime";
1553
+ import { useEffect as useEffect6, cloneElement as cloneElement4 } from "react";
1554
+ import { Fragment as Fragment5, jsx as jsx14 } from "react/jsx-runtime";
1361
1555
  function Title(props) {
1362
1556
  const { Title: Title2 } = useConfigContext();
1363
1557
  useEffect6(() => {
@@ -1366,21 +1560,21 @@ function Title(props) {
1366
1560
  }, [props]);
1367
1561
  if (props.h1) {
1368
1562
  if (typeof props.h1 === "boolean")
1369
- return /* @__PURE__ */ jsx11("h1", {
1563
+ return /* @__PURE__ */ jsx14("h1", {
1370
1564
  children: Array.isArray(props.title) ? props.title[0] : props.title
1371
1565
  });
1372
- return /* @__PURE__ */ jsx11("h1", {
1566
+ return /* @__PURE__ */ jsx14("h1", {
1373
1567
  className: props.h1.className,
1374
1568
  style: props.h1.style,
1375
1569
  children: Array.isArray(props.title) ? props.title[0] : props.title
1376
1570
  });
1377
1571
  }
1378
1572
  if (props.plain)
1379
- return /* @__PURE__ */ jsx11(Fragment3, {
1573
+ return /* @__PURE__ */ jsx14(Fragment5, {
1380
1574
  children: Array.isArray(props.title) ? props.title[0] : props.title
1381
1575
  });
1382
1576
  if (props.children)
1383
- return cloneElement3(props.children, { title: props.title });
1577
+ return cloneElement4(props.children, { title: props.title });
1384
1578
  return null;
1385
1579
  }
1386
1580
  export {
@@ -1389,9 +1583,12 @@ export {
1389
1583
  ConfigProvider,
1390
1584
  Description,
1391
1585
  Drawer,
1586
+ ErrorBoundary,
1587
+ FaasDataWrapper,
1392
1588
  Form,
1393
1589
  FormItem,
1394
1590
  Link,
1591
+ Loading,
1395
1592
  Modal,
1396
1593
  PageNotFound,
1397
1594
  Routes,