@faasjs/ant-design 0.0.2-beta.452 → 0.0.2-beta.453

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,27 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
9
  var __getProtoOf = Object.getPrototypeOf;
7
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8
25
  var __export = (target, all) => {
9
26
  for (var name in all)
10
27
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -119,10 +136,9 @@ function ConfigProvider({
119
136
  }, []);
120
137
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, {
121
138
  value: values,
122
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, {
123
- ...config.antd,
139
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, __spreadProps(__spreadValues({}, config.antd), {
124
140
  children
125
- })
141
+ }))
126
142
  });
127
143
  }
128
144
  function useConfigContext() {
@@ -182,15 +198,40 @@ var DatePicker = (0, import_generatePicker.default)(import_dayjs3.default);
182
198
  var import_icons = require("@ant-design/icons");
183
199
  var import_antd3 = require("antd");
184
200
  var import_lodash4 = require("lodash");
201
+ var import_react4 = require("react");
202
+
203
+ // ../react/src/index.tsx
185
204
  var import_react3 = require("react");
186
- var import_react4 = require("@faasjs/react");
205
+ var clients = {};
206
+ function getClient(domain) {
207
+ const client = clients[domain || Object.keys(clients)[0]];
208
+ if (!client)
209
+ throw Error("FaasReactClient is not initialized");
210
+ return client;
211
+ }
212
+ async function faas(action, params) {
213
+ return getClient().faas(action, params);
214
+ }
215
+ function FaasDataWrapper(props) {
216
+ const [client, setClient] = (0, import_react3.useState)();
217
+ (0, import_react3.useEffect)(() => {
218
+ if (client)
219
+ return;
220
+ setClient(getClient());
221
+ }, []);
222
+ if (!client)
223
+ return props.fallback || null;
224
+ return (0, import_react3.createElement)(client.FaasDataWrapper, props);
225
+ }
226
+
227
+ // src/Description.tsx
187
228
  var import_jsx_runtime3 = require("react/jsx-runtime");
188
229
  function DescriptionItemContent(props) {
189
230
  var _a;
190
- const [computedProps, setComputedProps] = (0, import_react3.useState)();
191
- (0, import_react3.useEffect)(() => {
231
+ const [computedProps, setComputedProps] = (0, import_react4.useState)();
232
+ (0, import_react4.useEffect)(() => {
192
233
  var _a2, _b;
193
- const propsCopy = { ...props };
234
+ const propsCopy = __spreadValues({}, props);
194
235
  if (!propsCopy.item.title)
195
236
  propsCopy.item.title = (0, import_lodash4.upperFirst)(propsCopy.item.id);
196
237
  if (!propsCopy.item.type)
@@ -218,7 +259,7 @@ function DescriptionItemContent(props) {
218
259
  return null;
219
260
  if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
220
261
  if (computedProps.extendTypes[computedProps.item.type].children)
221
- return (0, import_react3.cloneElement)(
262
+ return (0, import_react4.cloneElement)(
222
263
  computedProps.extendTypes[computedProps.item.type].children,
223
264
  {
224
265
  value: computedProps.value,
@@ -232,7 +273,7 @@ function DescriptionItemContent(props) {
232
273
  else
233
274
  throw Error(computedProps.item.type + " requires children or render");
234
275
  if (computedProps.item.children)
235
- return (0, import_react3.cloneElement)(computedProps.item.children, { value: computedProps.value });
276
+ return (0, import_react4.cloneElement)(computedProps.item.children, { value: computedProps.value });
236
277
  if (computedProps.item.render)
237
278
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {
238
279
  children: computedProps.item.render(computedProps.value, computedProps.values)
@@ -293,8 +334,7 @@ function DescriptionItemContent(props) {
293
334
  }
294
335
  function Description(props) {
295
336
  if (!props.faasData)
296
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, {
297
- ...props,
337
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, __spreadProps(__spreadValues({}, props), {
298
338
  title: (0, import_lodash4.isFunction)(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
299
339
  children: props.items.map((item) => {
300
340
  return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions.Item, {
@@ -307,14 +347,13 @@ function Description(props) {
307
347
  })
308
348
  }, item.id) : null;
309
349
  }).filter(Boolean)
310
- });
311
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.FaasDataWrapper, {
350
+ }));
351
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FaasDataWrapper, __spreadValues({
312
352
  fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Skeleton, {
313
353
  active: true
314
354
  }),
315
355
  render: ({ data }) => {
316
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, {
317
- ...props,
356
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, __spreadProps(__spreadValues({}, props), {
318
357
  title: (0, import_lodash4.isFunction)(props.renderTitle) ? props.renderTitle(data) : props.title,
319
358
  children: props.items.map((item) => {
320
359
  return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions.Item, {
@@ -327,60 +366,50 @@ function Description(props) {
327
366
  })
328
367
  }, item.id) : null;
329
368
  }).filter(Boolean)
330
- });
331
- },
332
- ...props.faasData
333
- });
369
+ }));
370
+ }
371
+ }, props.faasData));
334
372
  }
335
373
 
336
374
  // src/Drawer.tsx
337
375
  var import_antd4 = require("antd");
338
- var import_react5 = require("react");
376
+ var import_react6 = require("react");
339
377
  var import_jsx_runtime4 = require("react/jsx-runtime");
340
378
  function useDrawer(init) {
341
- const [props, setProps] = (0, import_react5.useState)({
379
+ const [props, setProps] = (0, import_react6.useState)(__spreadValues({
342
380
  open: false,
343
- onClose: () => setProps((prev) => ({
344
- ...prev,
381
+ onClose: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
345
382
  open: false
346
- })),
347
- ...init
348
- });
383
+ }))
384
+ }, init));
349
385
  return {
350
- drawer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Drawer, {
351
- ...props
352
- }),
386
+ drawer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Drawer, __spreadValues({}, props)),
353
387
  drawerProps: props,
354
388
  setDrawerProps(changes) {
355
- setProps((prev) => ({
356
- ...prev,
357
- ...changes
358
- }));
389
+ setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
359
390
  }
360
391
  };
361
392
  }
362
393
 
363
394
  // src/Form.tsx
364
- var import_react8 = require("@faasjs/react");
365
395
  var import_antd6 = require("antd");
366
- var import_react9 = require("react");
396
+ var import_react10 = require("react");
367
397
 
368
398
  // src/FormItem.tsx
369
399
  var import_antd5 = require("antd");
370
400
  var import_icons2 = require("@ant-design/icons");
371
- var import_react7 = require("react");
401
+ var import_react8 = require("react");
372
402
  var import_lodash5 = require("lodash");
373
403
 
374
404
  // src/TimePicker.tsx
375
- var import_react6 = require("react");
405
+ var import_react7 = require("react");
376
406
  var import_jsx_runtime5 = require("react/jsx-runtime");
377
- var TimePicker = (0, import_react6.forwardRef)((props, ref) => {
378
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DatePicker, {
379
- ...props,
407
+ var TimePicker = (0, import_react7.forwardRef)((props, ref) => {
408
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DatePicker, __spreadProps(__spreadValues({}, props), {
380
409
  picker: "time",
381
410
  mode: void 0,
382
411
  ref
383
- });
412
+ }));
384
413
  });
385
414
  TimePicker.displayName = "TimePicker";
386
415
 
@@ -434,53 +463,60 @@ function processProps(propsCopy, config) {
434
463
  }
435
464
  function FormItem(props) {
436
465
  var _a;
437
- const [computedProps, setComputedProps] = (0, import_react7.useState)();
438
- const [extendTypes, setExtendTypes] = (0, import_react7.useState)();
466
+ const [computedProps, setComputedProps] = (0, import_react8.useState)();
467
+ const [extendTypes, setExtendTypes] = (0, import_react8.useState)();
439
468
  const config = useConfigContext();
440
- (0, import_react7.useEffect)(() => {
441
- const propsCopy = { ...props };
469
+ const [hidden, setHidden] = (0, import_react8.useState)(false);
470
+ (0, import_react8.useEffect)(() => {
471
+ const propsCopy = __spreadValues({}, props);
442
472
  if (propsCopy.extendTypes) {
443
473
  setExtendTypes(propsCopy.extendTypes);
444
474
  delete propsCopy.extendTypes;
445
475
  }
476
+ if (propsCopy.if) {
477
+ const condition = propsCopy.if;
478
+ propsCopy.shouldUpdate = (_, cur) => {
479
+ const show = condition(cur);
480
+ setHidden(!show);
481
+ return show;
482
+ };
483
+ delete propsCopy.if;
484
+ }
446
485
  setComputedProps(processProps(propsCopy, config));
447
486
  }, [props]);
448
487
  if (!computedProps)
449
488
  return null;
489
+ if (hidden)
490
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
491
+ noStyle: true,
492
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Input, {
493
+ hidden: true
494
+ })
495
+ }));
450
496
  if (extendTypes && extendTypes[computedProps.type])
451
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
452
- ...computedProps,
497
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
453
498
  children: extendTypes[computedProps.type].children
454
- });
499
+ }));
455
500
  if (computedProps.children)
456
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
457
- ...computedProps,
501
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
458
502
  children: computedProps.children
459
- });
503
+ }));
460
504
  if (computedProps.render)
461
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
462
- ...computedProps,
505
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
463
506
  children: computedProps.render()
464
- });
507
+ }));
465
508
  switch (computedProps.type) {
466
509
  case "string":
467
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
468
- ...computedProps,
469
- children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, {
470
- ...computedProps.input
471
- }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Input, {
472
- ...computedProps.input
473
- })
474
- });
510
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
511
+ children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, __spreadValues({}, computedProps.input)) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Input, __spreadValues({}, computedProps.input))
512
+ }));
475
513
  case "string[]":
476
514
  if (computedProps.options)
477
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
478
- ...computedProps,
479
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, {
480
- mode: "multiple",
481
- ...computedProps.input
482
- })
483
- });
515
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
516
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, __spreadValues({
517
+ mode: "multiple"
518
+ }, computedProps.input))
519
+ }));
484
520
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.List, {
485
521
  name: computedProps.name,
486
522
  rules: computedProps.rules,
@@ -504,13 +540,10 @@ function FormItem(props) {
504
540
  children: [
505
541
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
506
542
  span: 23,
507
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
508
- ...field,
543
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, field), {
509
544
  noStyle: true,
510
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Input, {
511
- ...computedProps.input
512
- })
513
- })
545
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Input, __spreadValues({}, computedProps.input))
546
+ }))
514
547
  }),
515
548
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
516
549
  span: 1,
@@ -544,24 +577,18 @@ function FormItem(props) {
544
577
  }
545
578
  });
546
579
  case "number":
547
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
548
- ...computedProps,
549
- children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, {
550
- ...computedProps.input
551
- }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.InputNumber, {
552
- style: { width: "100%" },
553
- ...computedProps.input
554
- })
555
- });
580
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
581
+ children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, __spreadValues({}, computedProps.input)) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.InputNumber, __spreadValues({
582
+ style: { width: "100%" }
583
+ }, computedProps.input))
584
+ }));
556
585
  case "number[]":
557
586
  if (computedProps.options)
558
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
559
- ...computedProps,
560
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, {
561
- mode: "multiple",
562
- ...computedProps.input
563
- })
564
- });
587
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
588
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, __spreadValues({
589
+ mode: "multiple"
590
+ }, computedProps.input))
591
+ }));
565
592
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.List, {
566
593
  name: computedProps.name,
567
594
  rules: computedProps.rules,
@@ -585,14 +612,12 @@ function FormItem(props) {
585
612
  children: [
586
613
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
587
614
  span: 23,
588
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
589
- ...field,
615
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, field), {
590
616
  noStyle: true,
591
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.InputNumber, {
592
- style: { width: "100%" },
593
- ...computedProps.input
594
- })
595
- })
617
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.InputNumber, __spreadValues({
618
+ style: { width: "100%" }
619
+ }, computedProps.input))
620
+ }))
596
621
  }),
597
622
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
598
623
  span: 1,
@@ -626,26 +651,17 @@ function FormItem(props) {
626
651
  }
627
652
  });
628
653
  case "boolean":
629
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
630
- ...computedProps,
631
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Switch, {
632
- ...computedProps.input
633
- })
634
- });
654
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
655
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Switch, __spreadValues({}, computedProps.input))
656
+ }));
635
657
  case "date":
636
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
637
- ...computedProps,
638
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DatePicker, {
639
- ...computedProps.input
640
- })
641
- });
658
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
659
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DatePicker, __spreadValues({}, computedProps.input))
660
+ }));
642
661
  case "time":
643
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
644
- ...computedProps,
645
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TimePicker, {
646
- ...computedProps.input
647
- })
648
- });
662
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
663
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TimePicker, __spreadValues({}, computedProps.input))
664
+ }));
649
665
  case "object":
650
666
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, {
651
667
  children: [
@@ -656,9 +672,7 @@ function FormItem(props) {
656
672
  children: computedProps.label
657
673
  })
658
674
  }),
659
- computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormItem, {
660
- ...o
661
- }, o.id))
675
+ computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormItem, __spreadValues({}, o), o.id))
662
676
  ]
663
677
  });
664
678
  case "object[]":
@@ -690,10 +704,9 @@ function FormItem(props) {
690
704
  gutter: 24,
691
705
  children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
692
706
  span: o.col || 24,
693
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormItem, {
694
- ...o,
707
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormItem, __spreadProps(__spreadValues({}, o), {
695
708
  name: [field.name, o.id]
696
- })
709
+ }))
697
710
  }, o.id))
698
711
  })
699
712
  ]
@@ -728,36 +741,33 @@ function FormItem(props) {
728
741
  var import_jsx_runtime7 = require("react/jsx-runtime");
729
742
  function Form(props) {
730
743
  var _a, _b;
731
- const [loading, setLoading] = (0, import_react9.useState)(false);
732
- const [computedProps, setComputedProps] = (0, import_react9.useState)();
744
+ const [loading, setLoading] = (0, import_react10.useState)(false);
745
+ const [computedProps, setComputedProps] = (0, import_react10.useState)();
733
746
  const config = useConfigContext();
734
- const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
747
+ const [extendTypes, setExtendTypes] = (0, import_react10.useState)();
735
748
  const [form] = import_antd6.Form.useForm(props.form);
736
- (0, import_react9.useEffect)(() => {
749
+ const [initialValues, setInitialValues] = (0, import_react10.useState)(props.initialValues);
750
+ (0, import_react10.useEffect)(() => {
737
751
  var _a2, _b2;
738
- const propsCopy = {
739
- ...props,
740
- items: (props.items || []).filter((it) => {
741
- return !it.if || it.if(props.initialValues || {});
742
- }),
752
+ const propsCopy = __spreadProps(__spreadValues({}, props), {
743
753
  form
744
- };
745
- if (propsCopy.initialValues)
754
+ });
755
+ if (propsCopy.initialValues) {
746
756
  for (const key in propsCopy.initialValues)
747
757
  propsCopy.initialValues[key] = transferValue(
748
758
  (_a2 = propsCopy.items.find((item) => item.id === key)) == null ? void 0 : _a2.type,
749
759
  propsCopy.initialValues[key]
750
760
  );
761
+ setInitialValues(propsCopy.initialValues);
762
+ delete propsCopy.initialValues;
763
+ }
751
764
  if (propsCopy.onFinish) {
752
765
  propsCopy.onFinish = async (values) => {
753
766
  var _a3;
754
767
  setLoading(true);
755
768
  try {
756
769
  if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
757
- await props.onFinish(values, async (values2) => (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
758
- ...values2,
759
- ...propsCopy.submit.to.params
760
- } : values2));
770
+ await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? __spreadValues(__spreadValues({}, values2), propsCopy.submit.to.params) : values2));
761
771
  } else
762
772
  await props.onFinish(values);
763
773
  } catch (error) {
@@ -768,10 +778,7 @@ function Form(props) {
768
778
  } else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
769
779
  propsCopy.onFinish = async (values) => {
770
780
  setLoading(true);
771
- return (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
772
- ...values,
773
- ...propsCopy.submit.to.params
774
- } : values).finally(() => setLoading(false));
781
+ return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? __spreadValues(__spreadValues({}, values), propsCopy.submit.to.params) : values).finally(() => setLoading(false));
775
782
  };
776
783
  }
777
784
  if (propsCopy.extendTypes) {
@@ -780,7 +787,7 @@ function Form(props) {
780
787
  }
781
788
  setComputedProps(propsCopy);
782
789
  }, [props]);
783
- const onValuesChange = (0, import_react9.useCallback)((changedValues, allValues) => {
790
+ const onValuesChange = (0, import_react10.useCallback)((changedValues, allValues) => {
784
791
  if (props.onValuesChange) {
785
792
  props.onValuesChange(changedValues, allValues);
786
793
  }
@@ -791,39 +798,22 @@ function Form(props) {
791
798
  if (item == null ? void 0 : item.onValueChange)
792
799
  item.onValueChange(changedValues[key], allValues, form);
793
800
  }
794
- const filterItems = props.items.filter((it) => {
795
- if (!it.if) {
796
- return true;
797
- }
798
- const show = it.if(allValues);
799
- if (show) {
800
- props.form.setFields([
801
- {
802
- name: it.id,
803
- errors: null
804
- }
805
- ]);
806
- }
807
- return show;
808
- });
809
- if (computedProps.items.length !== filterItems.length || computedProps.items.some((it, i) => it !== filterItems[i])) {
810
- setComputedProps({
811
- ...computedProps,
812
- items: filterItems
813
- });
814
- }
801
+ }, [computedProps]);
802
+ (0, import_react10.useEffect)(() => {
803
+ if (!initialValues)
804
+ return;
805
+ form.setFieldsValue(initialValues);
806
+ setInitialValues(null);
815
807
  }, [computedProps]);
816
808
  if (!computedProps)
817
809
  return null;
818
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd6.Form, {
819
- ...computedProps,
810
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd6.Form, __spreadProps(__spreadValues({}, computedProps), {
820
811
  onValuesChange,
821
812
  children: [
822
813
  computedProps.beforeItems,
823
- (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FormItem, {
824
- ...item,
814
+ (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FormItem, __spreadProps(__spreadValues({}, item), {
825
815
  extendTypes
826
- }, item.id)),
816
+ }), item.id)),
827
817
  computedProps.children,
828
818
  computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd6.Button, {
829
819
  htmlType: "submit",
@@ -833,7 +823,7 @@ function Form(props) {
833
823
  }),
834
824
  computedProps.footer
835
825
  ]
836
- });
826
+ }));
837
827
  }
838
828
  Form.useForm = import_antd6.Form.useForm;
839
829
 
@@ -853,82 +843,61 @@ function Link({
853
843
  style = Object.assign({ cursor: "pointer" }, style);
854
844
  if (href.startsWith("http")) {
855
845
  if (button)
856
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd7.Button, {
857
- ...button,
846
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd7.Button, __spreadProps(__spreadValues({}, button), {
858
847
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", {
859
848
  href,
860
849
  target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
861
- style: {
862
- ...Link2.style,
863
- ...style || {}
864
- },
850
+ style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
865
851
  children: text || children
866
852
  })
867
- });
853
+ }));
868
854
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", {
869
855
  href,
870
856
  target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
871
- style: {
872
- ...Link2.style,
873
- ...style || {}
874
- },
857
+ style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
875
858
  children: text || children
876
859
  });
877
860
  }
878
861
  if (button)
879
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd7.Button, {
880
- ...button,
862
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd7.Button, __spreadProps(__spreadValues({}, button), {
881
863
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_router_dom.Link, {
882
864
  to: href,
883
865
  target: target || (Link2 == null ? void 0 : Link2.target),
884
- style: {
885
- ...Link2.style,
886
- ...style || {}
887
- },
866
+ style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
888
867
  children: text || children
889
868
  })
890
- });
869
+ }));
891
870
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_router_dom.Link, {
892
871
  to: href,
893
872
  target: target || (Link2 == null ? void 0 : Link2.target),
894
- style: {
895
- ...Link2.style,
896
- ...style || {}
897
- },
873
+ style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
898
874
  children: text || children
899
875
  });
900
876
  }
901
877
 
902
878
  // src/Modal.tsx
903
879
  var import_antd8 = require("antd");
904
- var import_react10 = require("react");
880
+ var import_react11 = require("react");
905
881
  var import_jsx_runtime9 = require("react/jsx-runtime");
906
882
  function useModal(init) {
907
- const [props, setProps] = (0, import_react10.useState)({
883
+ const [props, setProps] = (0, import_react11.useState)(__spreadValues({
908
884
  open: false,
909
- onCancel: () => setProps((prev) => ({
910
- ...prev,
885
+ onCancel: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
911
886
  open: false
912
- })),
913
- ...init
914
- });
887
+ }))
888
+ }, init));
915
889
  return {
916
- modal: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_antd8.Modal, {
917
- ...props
918
- }),
890
+ modal: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_antd8.Modal, __spreadValues({}, props)),
919
891
  modalProps: props,
920
892
  setModalProps(changes) {
921
- setProps((prev) => ({
922
- ...prev,
923
- ...changes
924
- }));
893
+ setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
925
894
  }
926
895
  };
927
896
  }
928
897
 
929
898
  // src/Routers.tsx
930
899
  var import_antd9 = require("antd");
931
- var import_react11 = require("react");
900
+ var import_react12 = require("react");
932
901
  var import_react_router_dom2 = require("react-router-dom");
933
902
  var import_jsx_runtime10 = require("react/jsx-runtime");
934
903
  function PageNotFound() {
@@ -941,9 +910,8 @@ function PageNotFound() {
941
910
  function Routes(props) {
942
911
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_router_dom2.Routes, {
943
912
  children: [
944
- props.routes.map((r) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_router_dom2.Route, {
945
- ...r,
946
- element: r.element || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react11.Suspense, {
913
+ props.routes.map((r) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_router_dom2.Route, __spreadProps(__spreadValues({}, r), {
914
+ element: r.element || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.Suspense, {
947
915
  fallback: props.fallback || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {
948
916
  style: { padding: "24px" },
949
917
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd9.Skeleton, {
@@ -952,7 +920,7 @@ function Routes(props) {
952
920
  }),
953
921
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(r.page, {})
954
922
  })
955
- }, r.path)),
923
+ }), r.path)),
956
924
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_router_dom2.Route, {
957
925
  path: "*",
958
926
  element: props.notFound || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PageNotFound, {})
@@ -962,12 +930,11 @@ function Routes(props) {
962
930
  }
963
931
 
964
932
  // src/Table.tsx
965
- var import_react12 = require("react");
933
+ var import_react13 = require("react");
966
934
  var import_antd10 = require("antd");
967
935
  var import_dayjs4 = __toESM(require("dayjs"));
968
936
  var import_icons3 = require("@ant-design/icons");
969
937
  var import_lodash6 = require("lodash");
970
- var import_react13 = require("@faasjs/react");
971
938
  var import_jsx_runtime11 = require("react/jsx-runtime");
972
939
  function processValue(item, value) {
973
940
  var _a;
@@ -994,9 +961,9 @@ function processValue(item, value) {
994
961
  return value;
995
962
  }
996
963
  function Table(props) {
997
- const [columns, setColumns] = (0, import_react12.useState)();
964
+ const [columns, setColumns] = (0, import_react13.useState)();
998
965
  const { common: common2 } = useConfigContext();
999
- (0, import_react12.useEffect)(() => {
966
+ (0, import_react13.useEffect)(() => {
1000
967
  var _a;
1001
968
  for (const item of props.items) {
1002
969
  if (!item.key)
@@ -1018,7 +985,7 @@ function Table(props) {
1018
985
  delete item.children;
1019
986
  if (props.extendTypes && props.extendTypes[item.type]) {
1020
987
  if (props.extendTypes[item.type].children)
1021
- item.render = (value, values) => (0, import_react12.cloneElement)(
988
+ item.render = (value, values) => (0, import_react13.cloneElement)(
1022
989
  props.extendTypes[item.type].children,
1023
990
  {
1024
991
  value,
@@ -1248,7 +1215,7 @@ function Table(props) {
1248
1215
  }
1249
1216
  setColumns(props.items);
1250
1217
  }, [props.items]);
1251
- (0, import_react12.useEffect)(() => {
1218
+ (0, import_react13.useEffect)(() => {
1252
1219
  if (!props.dataSource || !columns)
1253
1220
  return;
1254
1221
  for (const column of columns) {
@@ -1268,13 +1235,12 @@ function Table(props) {
1268
1235
  if (!columns)
1269
1236
  return null;
1270
1237
  if (!props.faasData)
1271
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, {
1272
- ...props,
1238
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, __spreadProps(__spreadValues({}, props), {
1273
1239
  rowKey: props.rowKey || "id",
1274
1240
  columns,
1275
1241
  dataSource: props.dataSource
1276
- });
1277
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react13.FaasDataWrapper, {
1242
+ }));
1243
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FaasDataWrapper, __spreadValues({
1278
1244
  fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Skeleton, {
1279
1245
  active: true
1280
1246
  }),
@@ -1284,59 +1250,50 @@ function Table(props) {
1284
1250
  reload
1285
1251
  }) => {
1286
1252
  if (!data)
1287
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, {
1288
- ...props,
1253
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, __spreadProps(__spreadValues({}, props), {
1289
1254
  rowKey: props.rowKey || "id",
1290
1255
  columns,
1291
1256
  dataSource: []
1292
- });
1257
+ }));
1293
1258
  if (Array.isArray(data))
1294
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, {
1295
- ...props,
1259
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, __spreadProps(__spreadValues({}, props), {
1296
1260
  rowKey: props.rowKey || "id",
1297
1261
  columns,
1298
1262
  dataSource: data
1299
- });
1300
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, {
1301
- ...props,
1263
+ }));
1264
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, __spreadProps(__spreadValues({}, props), {
1302
1265
  rowKey: props.rowKey || "id",
1303
1266
  columns,
1304
1267
  dataSource: data.rows,
1305
- pagination: {
1306
- ...props.pagination,
1307
- ...data.pagination
1308
- },
1268
+ pagination: __spreadValues(__spreadValues({}, props.pagination), data.pagination),
1309
1269
  onChange: (pagination, filters, sorter, extra) => {
1310
1270
  if (props.onChange) {
1311
1271
  const processed = props.onChange(pagination, filters, sorter, extra);
1312
- reload({
1313
- ...params,
1272
+ reload(__spreadProps(__spreadValues({}, params), {
1314
1273
  pagination: processed.pagination,
1315
1274
  filters: processed.filters,
1316
1275
  sorter: processed.sorter
1317
- });
1276
+ }));
1318
1277
  return;
1319
1278
  }
1320
- reload({
1321
- ...params,
1279
+ reload(__spreadProps(__spreadValues({}, params), {
1322
1280
  pagination,
1323
1281
  filters,
1324
1282
  sorter
1325
- });
1283
+ }));
1326
1284
  }
1327
- });
1328
- },
1329
- ...props.faasData
1330
- });
1285
+ }));
1286
+ }
1287
+ }, props.faasData));
1331
1288
  }
1332
1289
 
1333
1290
  // src/Title.tsx
1334
- var import_react14 = require("react");
1291
+ var import_react15 = require("react");
1335
1292
  var import_antd11 = require("antd");
1336
1293
  var import_jsx_runtime12 = require("react/jsx-runtime");
1337
1294
  function Title(props) {
1338
1295
  const { Title: Title2 } = useConfigContext();
1339
- (0, import_react14.useEffect)(() => {
1296
+ (0, import_react15.useEffect)(() => {
1340
1297
  const title = Array.isArray(props.title) ? props.title : [props.title];
1341
1298
  document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
1342
1299
  }, [props]);
@@ -1356,12 +1313,11 @@ function Title(props) {
1356
1313
  children: Array.isArray(props.title) ? props.title[0] : props.title
1357
1314
  });
1358
1315
  if (props.header)
1359
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_antd11.PageHeader, {
1360
- title: Array.isArray(props.title) ? props.title[0] : props.title,
1361
- ...props.header
1362
- });
1316
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_antd11.PageHeader, __spreadValues({
1317
+ title: Array.isArray(props.title) ? props.title[0] : props.title
1318
+ }, props.header));
1363
1319
  if (props.children)
1364
- return (0, import_react14.cloneElement)(props.children, { title: props.title });
1320
+ return (0, import_react15.cloneElement)(props.children, { title: props.title });
1365
1321
  return null;
1366
1322
  }
1367
1323
  // Annotate the CommonJS export names for ESM import in node: