@faasjs/ant-design 0.0.3-beta.3 → 0.0.3-beta.30

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);
@@ -72,10 +71,7 @@ function ConfigProvider({
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() {
@@ -132,8 +128,42 @@ import {
132
128
  useEffect as useEffect2,
133
129
  useState as useState2
134
130
  } from "react";
135
- import { FaasDataWrapper } from "@faasjs/react";
136
- import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
131
+
132
+ // src/FaasDataWrapper.tsx
133
+ import { FaasDataWrapper as Origin } from "@faasjs/react";
134
+
135
+ // src/Loading.tsx
136
+ import { Spin } from "antd";
137
+ import { jsx as jsx3 } from "react/jsx-runtime";
138
+ function Loading(props) {
139
+ return /* @__PURE__ */ jsx3("div", {
140
+ style: {
141
+ ...props.style || {},
142
+ ...!props.size || props.size === "large" ? {
143
+ margin: "20vh auto",
144
+ textAlign: "center"
145
+ } : {}
146
+ },
147
+ children: /* @__PURE__ */ jsx3(Spin, {
148
+ size: props.size || "large"
149
+ })
150
+ });
151
+ }
152
+
153
+ // src/FaasDataWrapper.tsx
154
+ import { Alert } from "antd";
155
+ import { jsx as jsx4 } from "react/jsx-runtime";
156
+ function FaasDataWrapper(props) {
157
+ return /* @__PURE__ */ jsx4(Alert.ErrorBoundary, {
158
+ children: /* @__PURE__ */ jsx4(Origin, {
159
+ fallback: /* @__PURE__ */ jsx4(Loading, {}),
160
+ ...props
161
+ })
162
+ });
163
+ }
164
+
165
+ // src/Description.tsx
166
+ import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
137
167
  function DescriptionItemContent(props) {
138
168
  var _a;
139
169
  const [computedProps, setComputedProps] = useState2();
@@ -175,64 +205,67 @@ function DescriptionItemContent(props) {
175
205
  }
176
206
  );
177
207
  else if (computedProps.extendTypes[computedProps.item.type].render)
178
- return /* @__PURE__ */ jsx3(Fragment, {
208
+ return /* @__PURE__ */ jsx5(Fragment, {
179
209
  children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values)
180
210
  });
181
211
  else
182
212
  throw Error(computedProps.item.type + " requires children or render");
183
213
  if (computedProps.item.children)
184
- return cloneElement(computedProps.item.children, { value: computedProps.value });
214
+ return cloneElement(computedProps.item.children, {
215
+ value: computedProps.value,
216
+ values: computedProps.values
217
+ });
185
218
  if (computedProps.item.render)
186
- return /* @__PURE__ */ jsx3(Fragment, {
219
+ return /* @__PURE__ */ jsx5(Fragment, {
187
220
  children: computedProps.item.render(computedProps.value, computedProps.values)
188
221
  });
189
222
  if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
190
- return /* @__PURE__ */ jsx3(Blank, {});
223
+ return /* @__PURE__ */ jsx5(Blank, {});
191
224
  switch (computedProps.item.type) {
192
225
  case "string[]":
193
- return /* @__PURE__ */ jsx3(Fragment, {
226
+ return /* @__PURE__ */ jsx5(Fragment, {
194
227
  children: computedProps.value.join(", ")
195
228
  });
196
229
  case "number":
197
230
  return computedProps.value || null;
198
231
  case "number[]":
199
- return /* @__PURE__ */ jsx3(Fragment, {
232
+ return /* @__PURE__ */ jsx5(Fragment, {
200
233
  children: computedProps.value.join(", ")
201
234
  });
202
235
  case "boolean":
203
- return computedProps.value ? /* @__PURE__ */ jsx3(CheckOutlined, {
236
+ return computedProps.value ? /* @__PURE__ */ jsx5(CheckOutlined, {
204
237
  style: {
205
238
  marginTop: "4px",
206
239
  color: "#52c41a"
207
240
  }
208
- }) : /* @__PURE__ */ jsx3(CloseOutlined, {
241
+ }) : /* @__PURE__ */ jsx5(CloseOutlined, {
209
242
  style: {
210
243
  marginTop: "4px",
211
244
  color: "#ff4d4f"
212
245
  }
213
246
  });
214
247
  case "time":
215
- return /* @__PURE__ */ jsx3(Fragment, {
248
+ return /* @__PURE__ */ jsx5(Fragment, {
216
249
  children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
217
250
  });
218
251
  case "date":
219
- return /* @__PURE__ */ jsx3(Fragment, {
252
+ return /* @__PURE__ */ jsx5(Fragment, {
220
253
  children: computedProps.value.format("YYYY-MM-DD")
221
254
  });
222
255
  case "object":
223
256
  if (!computedProps.value)
224
- return /* @__PURE__ */ jsx3(Blank, {});
225
- return /* @__PURE__ */ jsx3(Description, {
257
+ return /* @__PURE__ */ jsx5(Blank, {});
258
+ return /* @__PURE__ */ jsx5(Description, {
226
259
  items: computedProps.item.object,
227
260
  dataSource: computedProps.value,
228
261
  column: 1
229
262
  });
230
263
  case "object[]":
231
264
  if (!((_a = computedProps.value) == null ? void 0 : _a.length))
232
- return /* @__PURE__ */ jsx3(Blank, {});
233
- return /* @__PURE__ */ jsx3(Space, {
265
+ return /* @__PURE__ */ jsx5(Blank, {});
266
+ return /* @__PURE__ */ jsx5(Space, {
234
267
  direction: "vertical",
235
- children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx3(Description, {
268
+ children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx5(Description, {
236
269
  items: computedProps.item.object,
237
270
  dataSource: value,
238
271
  column: 1
@@ -244,13 +277,13 @@ function DescriptionItemContent(props) {
244
277
  }
245
278
  function Description(props) {
246
279
  if (!props.faasData)
247
- return /* @__PURE__ */ jsx3(Descriptions, {
280
+ return /* @__PURE__ */ jsx5(Descriptions, {
248
281
  ...props,
249
282
  title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
250
283
  children: props.items.map((item) => {
251
- return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
284
+ return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx5(Descriptions.Item, {
252
285
  label: item.title || upperFirst2(item.id),
253
- children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
286
+ children: /* @__PURE__ */ jsx5(DescriptionItemContent, {
254
287
  item,
255
288
  value: props.dataSource[item.id],
256
289
  values: props.dataSource,
@@ -259,18 +292,18 @@ function Description(props) {
259
292
  }, item.id) : null;
260
293
  }).filter(Boolean)
261
294
  });
262
- return /* @__PURE__ */ jsx3(FaasDataWrapper, {
263
- fallback: props.faasData.fallback || /* @__PURE__ */ jsx3(Skeleton, {
295
+ return /* @__PURE__ */ jsx5(FaasDataWrapper, {
296
+ fallback: props.faasData.fallback || /* @__PURE__ */ jsx5(Skeleton, {
264
297
  active: true
265
298
  }),
266
299
  render: ({ data }) => {
267
- return /* @__PURE__ */ jsx3(Descriptions, {
300
+ return /* @__PURE__ */ jsx5(Descriptions, {
268
301
  ...props,
269
302
  title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
270
303
  children: props.items.map((item) => {
271
- return !item.if || item.if(data) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
304
+ return !item.if || item.if(data) ? /* @__PURE__ */ jsx5(Descriptions.Item, {
272
305
  label: item.title || upperFirst2(item.id),
273
- children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
306
+ children: /* @__PURE__ */ jsx5(DescriptionItemContent, {
274
307
  item,
275
308
  value: data[item.id],
276
309
  values: data,
@@ -287,7 +320,7 @@ function Description(props) {
287
320
  // src/Drawer.tsx
288
321
  import { Drawer } from "antd";
289
322
  import { useState as useState3 } from "react";
290
- import { jsx as jsx4 } from "react/jsx-runtime";
323
+ import { jsx as jsx6 } from "react/jsx-runtime";
291
324
  function useDrawer(init) {
292
325
  const [props, setProps] = useState3({
293
326
  open: false,
@@ -298,7 +331,7 @@ function useDrawer(init) {
298
331
  ...init
299
332
  });
300
333
  return {
301
- drawer: /* @__PURE__ */ jsx4(Drawer, {
334
+ drawer: /* @__PURE__ */ jsx6(Drawer, {
302
335
  ...props
303
336
  }),
304
337
  drawerProps: props,
@@ -320,7 +353,8 @@ import {
320
353
  import {
321
354
  useEffect as useEffect4,
322
355
  useState as useState5,
323
- useCallback
356
+ useCallback,
357
+ isValidElement
324
358
  } from "react";
325
359
 
326
360
  // src/FormItem.tsx
@@ -342,7 +376,7 @@ import {
342
376
  useState as useState4
343
377
  } from "react";
344
378
  import { upperFirst as upperFirst3 } from "lodash-es";
345
- import { Fragment as Fragment2, jsx as jsx5, jsxs } from "react/jsx-runtime";
379
+ import { Fragment as Fragment2, jsx as jsx7, jsxs } from "react/jsx-runtime";
346
380
  function processProps(propsCopy, config) {
347
381
  if (!propsCopy.title)
348
382
  propsCopy.title = upperFirst3(propsCopy.id);
@@ -360,13 +394,13 @@ function processProps(propsCopy, config) {
360
394
  required: true,
361
395
  validator: async (_, values) => {
362
396
  if (!values || values.length < 1)
363
- return Promise.reject(Error(`${propsCopy.label || propsCopy.title} ${config.common.required}`));
397
+ return Promise.reject(Error(`${propsCopy.label || propsCopy.title} ${config.required}`));
364
398
  }
365
399
  });
366
400
  else
367
401
  propsCopy.rules.push({
368
402
  required: true,
369
- message: `${propsCopy.label || propsCopy.title} ${config.common.required}`
403
+ message: `${propsCopy.label || propsCopy.title} ${config.required}`
370
404
  });
371
405
  }
372
406
  if (!propsCopy.input)
@@ -393,8 +427,8 @@ function FormItem(props) {
393
427
  var _a;
394
428
  const [computedProps, setComputedProps] = useState4();
395
429
  const [extendTypes, setExtendTypes] = useState4();
396
- const config = useConfigContext();
397
- const [hidden, setHidden] = useState4(false);
430
+ const { common: common2 } = useConfigContext();
431
+ const [hidden, setHidden] = useState4(props.hidden || false);
398
432
  useEffect3(() => {
399
433
  const propsCopy = { ...props };
400
434
  if (propsCopy.extendTypes) {
@@ -403,98 +437,102 @@ function FormItem(props) {
403
437
  }
404
438
  if (propsCopy.if) {
405
439
  const condition = propsCopy.if;
406
- propsCopy.shouldUpdate = (_, cur) => {
440
+ const originShouldUpdate = propsCopy.shouldUpdate;
441
+ propsCopy.shouldUpdate = (prev, cur) => {
407
442
  const show = condition(cur);
443
+ const shouldUpdate = hidden !== show;
408
444
  setHidden(!show);
409
- return show;
445
+ const origin = originShouldUpdate ? typeof originShouldUpdate === "boolean" ? originShouldUpdate : originShouldUpdate(prev, cur, {}) : true;
446
+ return shouldUpdate || origin;
410
447
  };
411
448
  delete propsCopy.if;
449
+ delete propsCopy.hidden;
412
450
  }
413
- setComputedProps(processProps(propsCopy, config));
451
+ setComputedProps(processProps(propsCopy, common2));
414
452
  }, [props]);
415
453
  if (!computedProps)
416
454
  return null;
417
455
  if (hidden)
418
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
456
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
419
457
  ...computedProps,
420
458
  noStyle: true,
421
459
  rules: [],
422
- children: /* @__PURE__ */ jsx5(Input, {
460
+ children: /* @__PURE__ */ jsx7(Input, {
423
461
  hidden: true
424
462
  })
425
463
  });
426
464
  if (extendTypes && extendTypes[computedProps.type])
427
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
465
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
428
466
  ...computedProps,
429
467
  children: extendTypes[computedProps.type].children
430
468
  });
431
469
  if (computedProps.children)
432
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
470
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
433
471
  ...computedProps,
434
472
  children: computedProps.children
435
473
  });
436
474
  if (computedProps.render)
437
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
475
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
438
476
  ...computedProps,
439
477
  children: computedProps.render()
440
478
  });
441
479
  switch (computedProps.type) {
442
480
  case "string":
443
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
481
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
444
482
  ...computedProps,
445
- children: computedProps.options ? /* @__PURE__ */ jsx5(Select, {
483
+ children: computedProps.options ? /* @__PURE__ */ jsx7(Select, {
446
484
  ...computedProps.input
447
- }) : /* @__PURE__ */ jsx5(Input, {
485
+ }) : /* @__PURE__ */ jsx7(Input, {
448
486
  ...computedProps.input
449
487
  })
450
488
  });
451
489
  case "string[]":
452
490
  if (computedProps.options)
453
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
491
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
454
492
  ...computedProps,
455
- children: /* @__PURE__ */ jsx5(Select, {
493
+ children: /* @__PURE__ */ jsx7(Select, {
456
494
  mode: "multiple",
457
495
  ...computedProps.input
458
496
  })
459
497
  });
460
- return /* @__PURE__ */ jsx5(AntdForm.List, {
498
+ return /* @__PURE__ */ jsx7(AntdForm.List, {
461
499
  name: computedProps.name,
462
500
  rules: computedProps.rules,
463
501
  children: (fields, { add, remove }, { errors }) => {
464
502
  var _a2;
465
503
  return /* @__PURE__ */ jsxs(Fragment2, {
466
504
  children: [
467
- computedProps.label && /* @__PURE__ */ jsx5("div", {
505
+ computedProps.label && /* @__PURE__ */ jsx7("div", {
468
506
  className: "ant-form-item-label",
469
- children: /* @__PURE__ */ jsx5("label", {
507
+ children: /* @__PURE__ */ jsx7("label", {
470
508
  className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
471
509
  children: computedProps.label
472
510
  })
473
511
  }),
474
512
  fields.map((field) => {
475
513
  var _a3;
476
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
514
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
477
515
  children: /* @__PURE__ */ jsxs(Row, {
478
516
  gutter: 24,
479
517
  style: { flexFlow: "row nowrap" },
480
518
  children: [
481
- /* @__PURE__ */ jsx5(Col, {
519
+ /* @__PURE__ */ jsx7(Col, {
482
520
  span: 23,
483
- children: /* @__PURE__ */ jsx5(AntdForm.Item, {
521
+ children: /* @__PURE__ */ jsx7(AntdForm.Item, {
484
522
  ...field,
485
523
  noStyle: true,
486
- children: /* @__PURE__ */ jsx5(Input, {
524
+ children: /* @__PURE__ */ jsx7(Input, {
487
525
  ...computedProps.input
488
526
  })
489
527
  })
490
528
  }),
491
- /* @__PURE__ */ jsx5(Col, {
529
+ /* @__PURE__ */ jsx7(Col, {
492
530
  span: 1,
493
- children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
531
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx7(Button, {
494
532
  danger: true,
495
533
  type: "link",
496
534
  style: { float: "right" },
497
- icon: /* @__PURE__ */ jsx5(MinusCircleOutlined, {}),
535
+ icon: /* @__PURE__ */ jsx7(MinusCircleOutlined, {}),
498
536
  onClick: () => remove(field.name)
499
537
  })
500
538
  })
@@ -504,13 +542,13 @@ function FormItem(props) {
504
542
  }),
505
543
  /* @__PURE__ */ jsxs(AntdForm.Item, {
506
544
  children: [
507
- !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx5(Button, {
545
+ !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx7(Button, {
508
546
  type: "dashed",
509
547
  block: true,
510
548
  onClick: () => add(),
511
- icon: /* @__PURE__ */ jsx5(PlusOutlined, {})
549
+ icon: /* @__PURE__ */ jsx7(PlusOutlined, {})
512
550
  }),
513
- /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
551
+ /* @__PURE__ */ jsx7(AntdForm.ErrorList, {
514
552
  errors
515
553
  })
516
554
  ]
@@ -520,63 +558,63 @@ function FormItem(props) {
520
558
  }
521
559
  });
522
560
  case "number":
523
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
561
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
524
562
  ...computedProps,
525
- children: computedProps.options ? /* @__PURE__ */ jsx5(Select, {
563
+ children: computedProps.options ? /* @__PURE__ */ jsx7(Select, {
526
564
  ...computedProps.input
527
- }) : /* @__PURE__ */ jsx5(InputNumber, {
565
+ }) : /* @__PURE__ */ jsx7(InputNumber, {
528
566
  style: { width: "100%" },
529
567
  ...computedProps.input
530
568
  })
531
569
  });
532
570
  case "number[]":
533
571
  if (computedProps.options)
534
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
572
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
535
573
  ...computedProps,
536
- children: /* @__PURE__ */ jsx5(Select, {
574
+ children: /* @__PURE__ */ jsx7(Select, {
537
575
  mode: "multiple",
538
576
  ...computedProps.input
539
577
  })
540
578
  });
541
- return /* @__PURE__ */ jsx5(AntdForm.List, {
579
+ return /* @__PURE__ */ jsx7(AntdForm.List, {
542
580
  name: computedProps.name,
543
581
  rules: computedProps.rules,
544
582
  children: (fields, { add, remove }, { errors }) => {
545
583
  var _a2, _b;
546
584
  return /* @__PURE__ */ jsxs(Fragment2, {
547
585
  children: [
548
- computedProps.label && /* @__PURE__ */ jsx5("div", {
586
+ computedProps.label && /* @__PURE__ */ jsx7("div", {
549
587
  className: "ant-form-item-label",
550
- children: /* @__PURE__ */ jsx5("label", {
588
+ children: /* @__PURE__ */ jsx7("label", {
551
589
  className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required",
552
590
  children: computedProps.label
553
591
  })
554
592
  }),
555
593
  fields.map((field) => {
556
594
  var _a3;
557
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
595
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
558
596
  children: /* @__PURE__ */ jsxs(Row, {
559
597
  gutter: 24,
560
598
  style: { flexFlow: "row nowrap" },
561
599
  children: [
562
- /* @__PURE__ */ jsx5(Col, {
600
+ /* @__PURE__ */ jsx7(Col, {
563
601
  span: 23,
564
- children: /* @__PURE__ */ jsx5(AntdForm.Item, {
602
+ children: /* @__PURE__ */ jsx7(AntdForm.Item, {
565
603
  ...field,
566
604
  noStyle: true,
567
- children: /* @__PURE__ */ jsx5(InputNumber, {
605
+ children: /* @__PURE__ */ jsx7(InputNumber, {
568
606
  style: { width: "100%" },
569
607
  ...computedProps.input
570
608
  })
571
609
  })
572
610
  }),
573
- /* @__PURE__ */ jsx5(Col, {
611
+ /* @__PURE__ */ jsx7(Col, {
574
612
  span: 1,
575
- children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
613
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx7(Button, {
576
614
  danger: true,
577
615
  type: "link",
578
616
  style: { float: "right" },
579
- icon: /* @__PURE__ */ jsx5(MinusCircleOutlined, {}),
617
+ icon: /* @__PURE__ */ jsx7(MinusCircleOutlined, {}),
580
618
  onClick: () => remove(field.name)
581
619
  })
582
620
  })
@@ -586,13 +624,13 @@ function FormItem(props) {
586
624
  }),
587
625
  /* @__PURE__ */ jsxs(AntdForm.Item, {
588
626
  children: [
589
- !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx5(Button, {
627
+ !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx7(Button, {
590
628
  type: "dashed",
591
629
  block: true,
592
630
  onClick: () => add(),
593
- icon: /* @__PURE__ */ jsx5(PlusOutlined, {})
631
+ icon: /* @__PURE__ */ jsx7(PlusOutlined, {})
594
632
  }),
595
- /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
633
+ /* @__PURE__ */ jsx7(AntdForm.ErrorList, {
596
634
  errors
597
635
  })
598
636
  ]
@@ -602,43 +640,43 @@ function FormItem(props) {
602
640
  }
603
641
  });
604
642
  case "boolean":
605
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
643
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
606
644
  ...computedProps,
607
- children: /* @__PURE__ */ jsx5(Switch, {
645
+ children: /* @__PURE__ */ jsx7(Switch, {
608
646
  ...computedProps.input
609
647
  })
610
648
  });
611
649
  case "date":
612
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
650
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
613
651
  ...computedProps,
614
- children: /* @__PURE__ */ jsx5(DatePicker, {
652
+ children: /* @__PURE__ */ jsx7(DatePicker, {
615
653
  ...computedProps.input
616
654
  })
617
655
  });
618
656
  case "time":
619
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
657
+ return /* @__PURE__ */ jsx7(AntdForm.Item, {
620
658
  ...computedProps,
621
- children: /* @__PURE__ */ jsx5(TimePicker, {
659
+ children: /* @__PURE__ */ jsx7(TimePicker, {
622
660
  ...computedProps.input
623
661
  })
624
662
  });
625
663
  case "object":
626
664
  return /* @__PURE__ */ jsxs(Fragment2, {
627
665
  children: [
628
- computedProps.label && /* @__PURE__ */ jsx5("div", {
666
+ computedProps.label && /* @__PURE__ */ jsx7("div", {
629
667
  className: "ant-form-item-label",
630
- children: /* @__PURE__ */ jsx5("label", {
668
+ children: /* @__PURE__ */ jsx7("label", {
631
669
  className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
632
670
  children: computedProps.label
633
671
  })
634
672
  }),
635
- computedProps.object.map((o) => /* @__PURE__ */ jsx5(FormItem, {
673
+ computedProps.object.map((o) => /* @__PURE__ */ jsx7(FormItem, {
636
674
  ...o
637
675
  }, o.id))
638
676
  ]
639
677
  });
640
678
  case "object[]":
641
- return /* @__PURE__ */ jsx5(AntdForm.List, {
679
+ return /* @__PURE__ */ jsx7(AntdForm.List, {
642
680
  name: computedProps.name,
643
681
  rules: computedProps.rules,
644
682
  children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(Fragment2, {
@@ -646,27 +684,27 @@ function FormItem(props) {
646
684
  fields.map((field) => /* @__PURE__ */ jsxs(AntdForm.Item, {
647
685
  style: { marginBottom: 0 },
648
686
  children: [
649
- /* @__PURE__ */ jsx5("div", {
687
+ /* @__PURE__ */ jsx7("div", {
650
688
  className: "ant-form-item-label",
651
689
  children: /* @__PURE__ */ jsxs("label", {
652
690
  children: [
653
691
  computedProps.label,
654
692
  " ",
655
693
  field.name + 1,
656
- !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
694
+ !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx7(Button, {
657
695
  danger: true,
658
696
  type: "link",
659
697
  onClick: () => remove(field.name),
660
- children: config.common.delete
698
+ children: common2.delete
661
699
  })
662
700
  ]
663
701
  })
664
702
  }),
665
- /* @__PURE__ */ jsx5(Row, {
703
+ /* @__PURE__ */ jsx7(Row, {
666
704
  gutter: 24,
667
- children: computedProps.object.map((o) => /* @__PURE__ */ jsx5(Col, {
705
+ children: computedProps.object.map((o) => /* @__PURE__ */ jsx7(Col, {
668
706
  span: o.col || 24,
669
- children: /* @__PURE__ */ jsx5(FormItem, {
707
+ children: /* @__PURE__ */ jsx7(FormItem, {
670
708
  ...o,
671
709
  name: [field.name, o.id]
672
710
  })
@@ -680,14 +718,14 @@ function FormItem(props) {
680
718
  type: "dashed",
681
719
  block: true,
682
720
  onClick: () => add(),
683
- icon: /* @__PURE__ */ jsx5(PlusOutlined, {}),
721
+ icon: /* @__PURE__ */ jsx7(PlusOutlined, {}),
684
722
  children: [
685
- config.common.add,
723
+ common2.add,
686
724
  " ",
687
725
  computedProps.label
688
726
  ]
689
727
  }),
690
- /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
728
+ /* @__PURE__ */ jsx7(AntdForm.ErrorList, {
691
729
  errors
692
730
  })
693
731
  ]
@@ -699,9 +737,10 @@ function FormItem(props) {
699
737
  return null;
700
738
  }
701
739
  }
740
+ FormItem.useStatus = AntdForm.Item.useStatus;
702
741
 
703
742
  // src/Form.tsx
704
- import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
743
+ import { jsx as jsx8, jsxs as jsxs2 } from "react/jsx-runtime";
705
744
  function Form(props) {
706
745
  var _a, _b;
707
746
  const [loading, setLoading] = useState5(false);
@@ -711,17 +750,25 @@ function Form(props) {
711
750
  const [form] = AntdForm2.useForm(props.form);
712
751
  const [initialValues, setInitialValues] = useState5(props.initialValues);
713
752
  useEffect4(() => {
714
- var _a2, _b2;
753
+ var _a2, _b2, _c;
715
754
  const propsCopy = {
716
755
  ...props,
717
756
  form
718
757
  };
719
- if (propsCopy.initialValues) {
720
- for (const key in propsCopy.initialValues)
758
+ if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
759
+ for (const key in propsCopy.initialValues) {
721
760
  propsCopy.initialValues[key] = transferValue(
722
- (_a2 = propsCopy.items.find((item) => item.id === key)) == null ? void 0 : _a2.type,
761
+ (_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
723
762
  propsCopy.initialValues[key]
724
763
  );
764
+ const item = propsCopy.items.find((item2) => item2.id === key);
765
+ if (item == null ? void 0 : item.if)
766
+ item.hidden = !item.if(propsCopy.initialValues);
767
+ }
768
+ for (const item of propsCopy.items) {
769
+ if (item.if)
770
+ item.hidden = !item.if(propsCopy.initialValues);
771
+ }
725
772
  setInitialValues(propsCopy.initialValues);
726
773
  delete propsCopy.initialValues;
727
774
  }
@@ -742,13 +789,25 @@ function Form(props) {
742
789
  }
743
790
  setLoading(false);
744
791
  };
745
- } else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
792
+ } else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
746
793
  propsCopy.onFinish = async (values) => {
747
794
  setLoading(true);
748
795
  return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
749
796
  ...values,
750
797
  ...propsCopy.submit.to.params
751
- } : values).finally(() => setLoading(false));
798
+ } : values).then((result) => {
799
+ if (propsCopy.submit.to.then)
800
+ propsCopy.submit.to.then(result);
801
+ return result;
802
+ }).catch((error) => {
803
+ if (propsCopy.submit.to.catch)
804
+ propsCopy.submit.to.catch(error);
805
+ return Promise.reject(error);
806
+ }).finally(() => {
807
+ if (propsCopy.submit.to.finally)
808
+ propsCopy.submit.to.finally();
809
+ setLoading(false);
810
+ });
752
811
  };
753
812
  }
754
813
  if (propsCopy.extendTypes) {
@@ -758,6 +817,7 @@ function Form(props) {
758
817
  setComputedProps(propsCopy);
759
818
  }, [props]);
760
819
  const onValuesChange = useCallback((changedValues, allValues) => {
820
+ console.debug("Form:onValuesChange", changedValues, allValues);
761
821
  if (props.onValuesChange) {
762
822
  props.onValuesChange(changedValues, allValues);
763
823
  }
@@ -772,6 +832,7 @@ function Form(props) {
772
832
  useEffect4(() => {
773
833
  if (!initialValues)
774
834
  return;
835
+ console.debug("Form:initialValues", initialValues);
775
836
  form.setFieldsValue(initialValues);
776
837
  setInitialValues(null);
777
838
  }, [computedProps]);
@@ -782,12 +843,12 @@ function Form(props) {
782
843
  onValuesChange,
783
844
  children: [
784
845
  computedProps.beforeItems,
785
- (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsx6(FormItem, {
846
+ (_a = computedProps.items) == null ? void 0 : _a.map((item) => isValidElement(item) ? item : /* @__PURE__ */ jsx8(FormItem, {
786
847
  ...item,
787
848
  extendTypes
788
849
  }, item.id)),
789
850
  computedProps.children,
790
- computedProps.submit !== false && /* @__PURE__ */ jsx6(Button2, {
851
+ computedProps.submit !== false && /* @__PURE__ */ jsx8(Button2, {
791
852
  htmlType: "submit",
792
853
  type: "primary",
793
854
  loading,
@@ -798,11 +859,17 @@ function Form(props) {
798
859
  });
799
860
  }
800
861
  Form.useForm = AntdForm2.useForm;
862
+ Form.useFormInstance = AntdForm2.useFormInstance;
863
+ Form.useWatch = AntdForm2.useWatch;
864
+ Form.Item = FormItem;
865
+ Form.List = AntdForm2.List;
866
+ Form.ErrorList = AntdForm2.ErrorList;
867
+ Form.Provider = AntdForm2.Provider;
801
868
 
802
869
  // src/Link.tsx
803
870
  import { Link as RouterLink } from "react-router-dom";
804
871
  import { Button as Button3 } from "antd";
805
- import { jsx as jsx7 } from "react/jsx-runtime";
872
+ import { jsx as jsx9 } from "react/jsx-runtime";
806
873
  function Link({
807
874
  href,
808
875
  target,
@@ -815,56 +882,54 @@ function Link({
815
882
  style = Object.assign({ cursor: "pointer" }, style);
816
883
  if (href.startsWith("http")) {
817
884
  if (button)
818
- return /* @__PURE__ */ jsx7(Button3, {
885
+ return /* @__PURE__ */ jsx9(Button3, {
819
886
  ...button,
820
- children: /* @__PURE__ */ jsx7("a", {
821
- href,
822
- target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
823
- style: {
824
- ...Link2.style,
825
- ...style || {}
826
- },
827
- children: text || children
828
- })
887
+ target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
888
+ style: {
889
+ ...Link2.style,
890
+ ...style || {}
891
+ },
892
+ href,
893
+ children: text != null ? text : children
829
894
  });
830
- return /* @__PURE__ */ jsx7("a", {
895
+ return /* @__PURE__ */ jsx9("a", {
831
896
  href,
832
897
  target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
833
898
  style: {
834
899
  ...Link2.style,
835
900
  ...style || {}
836
901
  },
837
- children: text || children
902
+ children: text != null ? text : children
838
903
  });
839
904
  }
840
905
  if (button)
841
- return /* @__PURE__ */ jsx7(Button3, {
842
- ...button,
843
- children: /* @__PURE__ */ jsx7(RouterLink, {
844
- to: href,
845
- target: target || (Link2 == null ? void 0 : Link2.target),
906
+ return /* @__PURE__ */ jsx9(RouterLink, {
907
+ to: href,
908
+ target: target || (Link2 == null ? void 0 : Link2.target),
909
+ children: /* @__PURE__ */ jsx9(Button3, {
910
+ ...button,
846
911
  style: {
847
912
  ...Link2.style,
848
913
  ...style || {}
849
914
  },
850
- children: text || children
915
+ children: text != null ? text : children
851
916
  })
852
917
  });
853
- return /* @__PURE__ */ jsx7(RouterLink, {
918
+ return /* @__PURE__ */ jsx9(RouterLink, {
854
919
  to: href,
855
920
  target: target || (Link2 == null ? void 0 : Link2.target),
856
921
  style: {
857
922
  ...Link2.style,
858
923
  ...style || {}
859
924
  },
860
- children: text || children
925
+ children: text != null ? text : children
861
926
  });
862
927
  }
863
928
 
864
929
  // src/Modal.tsx
865
930
  import { Modal } from "antd";
866
931
  import { useState as useState6 } from "react";
867
- import { jsx as jsx8 } from "react/jsx-runtime";
932
+ import { jsx as jsx10 } from "react/jsx-runtime";
868
933
  function useModal(init) {
869
934
  const [props, setProps] = useState6({
870
935
  open: false,
@@ -875,7 +940,7 @@ function useModal(init) {
875
940
  ...init
876
941
  });
877
942
  return {
878
- modal: /* @__PURE__ */ jsx8(Modal, {
943
+ modal: /* @__PURE__ */ jsx10(Modal, {
879
944
  ...props
880
945
  }),
881
946
  modalProps: props,
@@ -889,7 +954,11 @@ function useModal(init) {
889
954
  }
890
955
 
891
956
  // src/Routers.tsx
892
- import { Result, Skeleton as Skeleton2 } from "antd";
957
+ import {
958
+ Result,
959
+ Skeleton as Skeleton2,
960
+ Alert as Alert2
961
+ } from "antd";
893
962
  import {
894
963
  Suspense
895
964
  } from "react";
@@ -897,34 +966,36 @@ import {
897
966
  Routes as OriginRoutes,
898
967
  Route
899
968
  } from "react-router-dom";
900
- import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
969
+ import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
901
970
  function PageNotFound() {
902
971
  const config = useConfigContext();
903
- return /* @__PURE__ */ jsx9(Result, {
972
+ return /* @__PURE__ */ jsx11(Result, {
904
973
  status: "404",
905
974
  title: config.common.pageNotFound
906
975
  });
907
976
  }
908
977
  function Routes(props) {
909
- return /* @__PURE__ */ jsxs3(OriginRoutes, {
910
- children: [
911
- props.routes.map((r) => /* @__PURE__ */ jsx9(Route, {
912
- ...r,
913
- element: r.element || /* @__PURE__ */ jsx9(Suspense, {
914
- fallback: props.fallback || /* @__PURE__ */ jsx9("div", {
915
- style: { padding: "24px" },
916
- children: /* @__PURE__ */ jsx9(Skeleton2, {
917
- active: true
918
- })
919
- }),
920
- children: /* @__PURE__ */ jsx9(r.page, {})
921
- })
922
- }, r.path)),
923
- /* @__PURE__ */ jsx9(Route, {
924
- path: "*",
925
- element: props.notFound || /* @__PURE__ */ jsx9(PageNotFound, {})
926
- }, "*")
927
- ]
978
+ return /* @__PURE__ */ jsx11(Alert2.ErrorBoundary, {
979
+ children: /* @__PURE__ */ jsxs3(OriginRoutes, {
980
+ children: [
981
+ props.routes.map((r) => /* @__PURE__ */ jsx11(Route, {
982
+ ...r,
983
+ element: r.element || /* @__PURE__ */ jsx11(Suspense, {
984
+ fallback: props.fallback || /* @__PURE__ */ jsx11("div", {
985
+ style: { padding: "24px" },
986
+ children: /* @__PURE__ */ jsx11(Skeleton2, {
987
+ active: true
988
+ })
989
+ }),
990
+ children: /* @__PURE__ */ jsx11(r.page, {})
991
+ })
992
+ }, r.path)),
993
+ /* @__PURE__ */ jsx11(Route, {
994
+ path: "*",
995
+ element: props.notFound || /* @__PURE__ */ jsx11(PageNotFound, {})
996
+ }, "*")
997
+ ]
998
+ })
928
999
  });
929
1000
  }
930
1001
 
@@ -947,13 +1018,12 @@ import {
947
1018
  uniqBy,
948
1019
  upperFirst as upperFirst4
949
1020
  } from "lodash-es";
950
- import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
951
- import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
1021
+ import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
952
1022
  function processValue(item, value) {
953
1023
  var _a;
954
1024
  const transferred = transferValue(item.type, value);
955
1025
  if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
956
- return /* @__PURE__ */ jsx10(Blank, {});
1026
+ return /* @__PURE__ */ jsx12(Blank, {});
957
1027
  if (item.options) {
958
1028
  if (item.type.endsWith("[]"))
959
1029
  return transferred.map((v) => {
@@ -992,10 +1062,19 @@ function Table(props) {
992
1062
  item.filters = item.options.map((o) => ({
993
1063
  text: o.label,
994
1064
  value: o.value
995
- }));
1065
+ })).concat({
1066
+ text: /* @__PURE__ */ jsx12(Blank, {}),
1067
+ value: null
1068
+ });
996
1069
  }
997
1070
  if (item.children)
998
- delete item.children;
1071
+ item.render = (value, values) => cloneElement2(
1072
+ item.children,
1073
+ {
1074
+ value,
1075
+ values
1076
+ }
1077
+ );
999
1078
  if (props.extendTypes && props.extendTypes[item.type]) {
1000
1079
  if (props.extendTypes[item.type].children)
1001
1080
  item.render = (value, values) => cloneElement2(
@@ -1028,7 +1107,7 @@ function Table(props) {
1028
1107
  setSelectedKeys,
1029
1108
  confirm,
1030
1109
  clearFilters
1031
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1110
+ }) => /* @__PURE__ */ jsx12(Input2.Search, {
1032
1111
  placeholder: `${common2.search} ${item.title}`,
1033
1112
  allowClear: true,
1034
1113
  onSearch: (v) => {
@@ -1058,7 +1137,7 @@ function Table(props) {
1058
1137
  setSelectedKeys,
1059
1138
  confirm,
1060
1139
  clearFilters
1061
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1140
+ }) => /* @__PURE__ */ jsx12(Input2.Search, {
1062
1141
  placeholder: `${common2.search} ${item.title}`,
1063
1142
  allowClear: true,
1064
1143
  onSearch: (v) => {
@@ -1081,14 +1160,14 @@ function Table(props) {
1081
1160
  item.onFilter = (value, row) => {
1082
1161
  if (value === null && isNil2(row[item.id]))
1083
1162
  return true;
1084
- return value === row[item.id];
1163
+ return value == row[item.id];
1085
1164
  };
1086
1165
  if (!item.filters && item.filterDropdown !== false)
1087
1166
  item.filterDropdown = ({
1088
1167
  setSelectedKeys,
1089
1168
  confirm,
1090
1169
  clearFilters
1091
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1170
+ }) => /* @__PURE__ */ jsx12(Input2.Search, {
1092
1171
  placeholder: `${common2.search} ${item.title}`,
1093
1172
  allowClear: true,
1094
1173
  onSearch: (v) => {
@@ -1111,14 +1190,14 @@ function Table(props) {
1111
1190
  return true;
1112
1191
  if (!row[item.id] || !row[item.id].length)
1113
1192
  return false;
1114
- return row[item.id].includes(value);
1193
+ return row[item.id].includes(Number(value));
1115
1194
  };
1116
1195
  if (!item.filters && item.filterDropdown !== false)
1117
1196
  item.filterDropdown = ({
1118
1197
  setSelectedKeys,
1119
1198
  confirm,
1120
1199
  clearFilters
1121
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1200
+ }) => /* @__PURE__ */ jsx12(Input2.Search, {
1122
1201
  placeholder: `${common2.search} ${item.title}`,
1123
1202
  allowClear: true,
1124
1203
  onSearch: (v) => {
@@ -1134,12 +1213,12 @@ function Table(props) {
1134
1213
  break;
1135
1214
  case "boolean":
1136
1215
  if (!item.render)
1137
- item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ jsx10(Blank, {}) : value ? /* @__PURE__ */ jsx10(CheckOutlined2, {
1216
+ item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ jsx12(Blank, {}) : value ? /* @__PURE__ */ jsx12(CheckOutlined2, {
1138
1217
  style: {
1139
1218
  marginTop: "4px",
1140
1219
  color: "#52c41a"
1141
1220
  }
1142
- }) : /* @__PURE__ */ jsx10(CloseOutlined2, {
1221
+ }) : /* @__PURE__ */ jsx12(CloseOutlined2, {
1143
1222
  style: {
1144
1223
  marginTop: "4px",
1145
1224
  color: "#ff4d4f"
@@ -1159,28 +1238,28 @@ function Table(props) {
1159
1238
  confirm();
1160
1239
  },
1161
1240
  children: [
1162
- /* @__PURE__ */ jsx10(Radio.Button, {
1241
+ /* @__PURE__ */ jsx12(Radio.Button, {
1163
1242
  children: common2.all
1164
1243
  }),
1165
- /* @__PURE__ */ jsx10(Radio.Button, {
1244
+ /* @__PURE__ */ jsx12(Radio.Button, {
1166
1245
  value: "true",
1167
- children: /* @__PURE__ */ jsx10(CheckOutlined2, {
1246
+ children: /* @__PURE__ */ jsx12(CheckOutlined2, {
1168
1247
  style: {
1169
1248
  color: "#52c41a",
1170
1249
  verticalAlign: "middle"
1171
1250
  }
1172
1251
  })
1173
1252
  }),
1174
- /* @__PURE__ */ jsx10(Radio.Button, {
1253
+ /* @__PURE__ */ jsx12(Radio.Button, {
1175
1254
  value: "false",
1176
- children: /* @__PURE__ */ jsx10(CloseOutlined2, {
1255
+ children: /* @__PURE__ */ jsx12(CloseOutlined2, {
1177
1256
  style: {
1178
1257
  verticalAlign: "middle",
1179
1258
  color: "#ff4d4f"
1180
1259
  }
1181
1260
  })
1182
1261
  }),
1183
- /* @__PURE__ */ jsx10(Radio.Button, {
1262
+ /* @__PURE__ */ jsx12(Radio.Button, {
1184
1263
  value: "empty",
1185
1264
  children: common2.blank
1186
1265
  })
@@ -1218,7 +1297,7 @@ function Table(props) {
1218
1297
  break;
1219
1298
  case "object":
1220
1299
  if (!item.render)
1221
- item.render = (value) => /* @__PURE__ */ jsx10(Description, {
1300
+ item.render = (value) => /* @__PURE__ */ jsx12(Description, {
1222
1301
  items: item.object,
1223
1302
  dataSource: value || {},
1224
1303
  column: 1
@@ -1226,7 +1305,7 @@ function Table(props) {
1226
1305
  break;
1227
1306
  case "object[]":
1228
1307
  if (!item.render)
1229
- item.render = (value) => value.map((v, i) => /* @__PURE__ */ jsx10(Description, {
1308
+ item.render = (value) => value.map((v, i) => /* @__PURE__ */ jsx12(Description, {
1230
1309
  items: item.object,
1231
1310
  dataSource: v || [],
1232
1311
  column: 1
@@ -1251,89 +1330,133 @@ function Table(props) {
1251
1330
  return;
1252
1331
  for (const column of columns) {
1253
1332
  if (column.optionsType === "auto" && !column.options && !column.filters) {
1254
- setColumns((prev) => {
1255
- const newColumns = [...prev];
1256
- const index = newColumns.findIndex((item) => item.id === column.id);
1257
- newColumns[index].filters = uniqBy(props.dataSource, column.id).map((v) => ({
1258
- text: v[column.id],
1259
- value: v[column.id]
1260
- })).concat({
1261
- text: /* @__PURE__ */ jsx10(Blank, {}),
1262
- value: null
1333
+ const filters = uniqBy(props.dataSource, column.id).map((v) => ({
1334
+ text: v[column.id],
1335
+ value: v[column.id]
1336
+ }));
1337
+ if (filters.length)
1338
+ setColumns((prev) => {
1339
+ const newColumns = [...prev];
1340
+ const index = newColumns.findIndex((item) => item.id === column.id);
1341
+ newColumns[index].filters = filters.concat({
1342
+ text: /* @__PURE__ */ jsx12(Blank, {}),
1343
+ value: null
1344
+ });
1345
+ return newColumns;
1263
1346
  });
1264
- return newColumns;
1265
- });
1266
1347
  }
1267
1348
  }
1268
1349
  }, [props.dataSource, columns]);
1269
1350
  if (!columns)
1270
1351
  return null;
1271
1352
  if (!props.faasData)
1272
- return /* @__PURE__ */ jsx10(AntdTable, {
1353
+ return /* @__PURE__ */ jsx12(AntdTable, {
1273
1354
  ...props,
1274
1355
  rowKey: props.rowKey || "id",
1275
1356
  columns,
1276
1357
  dataSource: props.dataSource
1277
1358
  });
1278
- return /* @__PURE__ */ jsx10(FaasDataWrapper2, {
1279
- fallback: props.faasData.fallback || /* @__PURE__ */ jsx10(Skeleton3, {
1359
+ return /* @__PURE__ */ jsx12(FaasDataWrapper, {
1360
+ fallback: props.faasData.fallback || /* @__PURE__ */ jsx12(Skeleton3, {
1280
1361
  active: true
1281
1362
  }),
1282
- render: ({
1283
- data,
1284
- params,
1285
- reload
1286
- }) => {
1287
- if (!data)
1288
- return /* @__PURE__ */ jsx10(AntdTable, {
1289
- ...props,
1290
- rowKey: props.rowKey || "id",
1291
- columns,
1292
- dataSource: []
1293
- });
1294
- if (Array.isArray(data))
1295
- return /* @__PURE__ */ jsx10(AntdTable, {
1296
- ...props,
1297
- rowKey: props.rowKey || "id",
1298
- columns,
1299
- dataSource: data
1300
- });
1301
- return /* @__PURE__ */ jsx10(AntdTable, {
1302
- ...props,
1303
- rowKey: props.rowKey || "id",
1304
- columns,
1305
- dataSource: data.rows,
1306
- pagination: {
1307
- ...props.pagination,
1308
- ...data.pagination
1309
- },
1310
- onChange: (pagination, filters, sorter, extra) => {
1311
- if (props.onChange) {
1312
- const processed = props.onChange(pagination, filters, sorter, extra);
1313
- reload({
1314
- ...params,
1315
- pagination: processed.pagination,
1316
- filters: processed.filters,
1317
- sorter: processed.sorter
1318
- });
1319
- return;
1320
- }
1321
- reload({
1322
- ...params,
1323
- pagination,
1324
- filters,
1325
- sorter
1363
+ ...props.faasData,
1364
+ children: /* @__PURE__ */ jsx12(FaasDataTable, {
1365
+ props,
1366
+ columns
1367
+ })
1368
+ });
1369
+ }
1370
+ function FaasDataTable({
1371
+ props,
1372
+ columns,
1373
+ data,
1374
+ params,
1375
+ reload
1376
+ }) {
1377
+ const [currentColumns, setCurrentColumns] = useState7(columns);
1378
+ useEffect5(() => {
1379
+ if (!data || Array.isArray(data))
1380
+ return;
1381
+ setCurrentColumns((prev) => {
1382
+ const newColumns = [...prev];
1383
+ for (const column of newColumns) {
1384
+ if (data["options"] && data.options[column.id]) {
1385
+ column.options = data["options"][column.id];
1386
+ column.filters = data["options"][column.id].map((v) => ({
1387
+ text: v.label,
1388
+ value: v.value
1389
+ })).concat({
1390
+ text: /* @__PURE__ */ jsx12(Blank, {}),
1391
+ value: null
1326
1392
  });
1393
+ column.render = (value) => processValue(column, value);
1394
+ if (column.filterDropdown)
1395
+ delete column.filterDropdown;
1396
+ continue;
1327
1397
  }
1328
- });
1398
+ if (column.optionsType === "auto" && !column.options && !column.filters) {
1399
+ const filters = uniqBy(props.dataSource, column.id).map((v) => ({
1400
+ text: v[column.id],
1401
+ value: v[column.id]
1402
+ }));
1403
+ if (filters.length)
1404
+ column.filters = filters.concat({
1405
+ text: /* @__PURE__ */ jsx12(Blank, {}),
1406
+ value: null
1407
+ });
1408
+ }
1409
+ }
1410
+ return newColumns;
1411
+ });
1412
+ }, [columns, data]);
1413
+ if (!data)
1414
+ return /* @__PURE__ */ jsx12(AntdTable, {
1415
+ ...props,
1416
+ rowKey: props.rowKey || "id",
1417
+ columns: currentColumns,
1418
+ dataSource: []
1419
+ });
1420
+ if (Array.isArray(data))
1421
+ return /* @__PURE__ */ jsx12(AntdTable, {
1422
+ ...props,
1423
+ rowKey: props.rowKey || "id",
1424
+ columns: currentColumns,
1425
+ dataSource: data
1426
+ });
1427
+ return /* @__PURE__ */ jsx12(AntdTable, {
1428
+ ...props,
1429
+ rowKey: props.rowKey || "id",
1430
+ columns: currentColumns,
1431
+ dataSource: data.rows,
1432
+ pagination: {
1433
+ ...props.pagination,
1434
+ ...data.pagination
1329
1435
  },
1330
- ...props.faasData
1436
+ onChange: (pagination, filters, sorter, extra) => {
1437
+ if (props.onChange) {
1438
+ const processed = props.onChange(pagination, filters, sorter, extra);
1439
+ reload({
1440
+ ...params,
1441
+ pagination: processed.pagination,
1442
+ filters: processed.filters,
1443
+ sorter: processed.sorter
1444
+ });
1445
+ return;
1446
+ }
1447
+ reload({
1448
+ ...params,
1449
+ pagination,
1450
+ filters,
1451
+ sorter
1452
+ });
1453
+ }
1331
1454
  });
1332
1455
  }
1333
1456
 
1334
1457
  // src/Title.tsx
1335
1458
  import { useEffect as useEffect6, cloneElement as cloneElement3 } from "react";
1336
- import { Fragment as Fragment3, jsx as jsx11 } from "react/jsx-runtime";
1459
+ import { Fragment as Fragment3, jsx as jsx13 } from "react/jsx-runtime";
1337
1460
  function Title(props) {
1338
1461
  const { Title: Title2 } = useConfigContext();
1339
1462
  useEffect6(() => {
@@ -1342,17 +1465,17 @@ function Title(props) {
1342
1465
  }, [props]);
1343
1466
  if (props.h1) {
1344
1467
  if (typeof props.h1 === "boolean")
1345
- return /* @__PURE__ */ jsx11("h1", {
1468
+ return /* @__PURE__ */ jsx13("h1", {
1346
1469
  children: Array.isArray(props.title) ? props.title[0] : props.title
1347
1470
  });
1348
- return /* @__PURE__ */ jsx11("h1", {
1471
+ return /* @__PURE__ */ jsx13("h1", {
1349
1472
  className: props.h1.className,
1350
1473
  style: props.h1.style,
1351
1474
  children: Array.isArray(props.title) ? props.title[0] : props.title
1352
1475
  });
1353
1476
  }
1354
1477
  if (props.plain)
1355
- return /* @__PURE__ */ jsx11(Fragment3, {
1478
+ return /* @__PURE__ */ jsx13(Fragment3, {
1356
1479
  children: Array.isArray(props.title) ? props.title[0] : props.title
1357
1480
  });
1358
1481
  if (props.children)
@@ -1365,9 +1488,11 @@ export {
1365
1488
  ConfigProvider,
1366
1489
  Description,
1367
1490
  Drawer,
1491
+ FaasDataWrapper,
1368
1492
  Form,
1369
1493
  FormItem,
1370
1494
  Link,
1495
+ Loading,
1371
1496
  Modal,
1372
1497
  PageNotFound,
1373
1498
  Routes,