@faasjs/ant-design 0.0.2-beta.451 → 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)
@@ -273,7 +314,8 @@ function DescriptionItemContent(props) {
273
314
  case "object":
274
315
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Description, {
275
316
  items: computedProps.item.object,
276
- dataSource: computedProps.value
317
+ dataSource: computedProps.value,
318
+ column: 1
277
319
  });
278
320
  case "object[]":
279
321
  if (!((_a = computedProps.value) == null ? void 0 : _a.length))
@@ -282,7 +324,8 @@ function DescriptionItemContent(props) {
282
324
  direction: "vertical",
283
325
  children: computedProps.value.map((value, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Description, {
284
326
  items: computedProps.item.object,
285
- dataSource: value
327
+ dataSource: value,
328
+ column: 1
286
329
  }, index))
287
330
  });
288
331
  default:
@@ -291,8 +334,7 @@ function DescriptionItemContent(props) {
291
334
  }
292
335
  function Description(props) {
293
336
  if (!props.faasData)
294
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, {
295
- ...props,
337
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, __spreadProps(__spreadValues({}, props), {
296
338
  title: (0, import_lodash4.isFunction)(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
297
339
  children: props.items.map((item) => {
298
340
  return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions.Item, {
@@ -305,14 +347,13 @@ function Description(props) {
305
347
  })
306
348
  }, item.id) : null;
307
349
  }).filter(Boolean)
308
- });
309
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.FaasDataWrapper, {
350
+ }));
351
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FaasDataWrapper, __spreadValues({
310
352
  fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Skeleton, {
311
353
  active: true
312
354
  }),
313
355
  render: ({ data }) => {
314
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, {
315
- ...props,
356
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions, __spreadProps(__spreadValues({}, props), {
316
357
  title: (0, import_lodash4.isFunction)(props.renderTitle) ? props.renderTitle(data) : props.title,
317
358
  children: props.items.map((item) => {
318
359
  return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd3.Descriptions.Item, {
@@ -325,60 +366,50 @@ function Description(props) {
325
366
  })
326
367
  }, item.id) : null;
327
368
  }).filter(Boolean)
328
- });
329
- },
330
- ...props.faasData
331
- });
369
+ }));
370
+ }
371
+ }, props.faasData));
332
372
  }
333
373
 
334
374
  // src/Drawer.tsx
335
375
  var import_antd4 = require("antd");
336
- var import_react5 = require("react");
376
+ var import_react6 = require("react");
337
377
  var import_jsx_runtime4 = require("react/jsx-runtime");
338
378
  function useDrawer(init) {
339
- const [props, setProps] = (0, import_react5.useState)({
379
+ const [props, setProps] = (0, import_react6.useState)(__spreadValues({
340
380
  open: false,
341
- onClose: () => setProps((prev) => ({
342
- ...prev,
381
+ onClose: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
343
382
  open: false
344
- })),
345
- ...init
346
- });
383
+ }))
384
+ }, init));
347
385
  return {
348
- drawer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Drawer, {
349
- ...props
350
- }),
386
+ drawer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd4.Drawer, __spreadValues({}, props)),
351
387
  drawerProps: props,
352
388
  setDrawerProps(changes) {
353
- setProps((prev) => ({
354
- ...prev,
355
- ...changes
356
- }));
389
+ setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
357
390
  }
358
391
  };
359
392
  }
360
393
 
361
394
  // src/Form.tsx
362
- var import_react8 = require("@faasjs/react");
363
395
  var import_antd6 = require("antd");
364
- var import_react9 = require("react");
396
+ var import_react10 = require("react");
365
397
 
366
398
  // src/FormItem.tsx
367
399
  var import_antd5 = require("antd");
368
400
  var import_icons2 = require("@ant-design/icons");
369
- var import_react7 = require("react");
401
+ var import_react8 = require("react");
370
402
  var import_lodash5 = require("lodash");
371
403
 
372
404
  // src/TimePicker.tsx
373
- var import_react6 = require("react");
405
+ var import_react7 = require("react");
374
406
  var import_jsx_runtime5 = require("react/jsx-runtime");
375
- var TimePicker = (0, import_react6.forwardRef)((props, ref) => {
376
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DatePicker, {
377
- ...props,
407
+ var TimePicker = (0, import_react7.forwardRef)((props, ref) => {
408
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DatePicker, __spreadProps(__spreadValues({}, props), {
378
409
  picker: "time",
379
410
  mode: void 0,
380
411
  ref
381
- });
412
+ }));
382
413
  });
383
414
  TimePicker.displayName = "TimePicker";
384
415
 
@@ -432,53 +463,60 @@ function processProps(propsCopy, config) {
432
463
  }
433
464
  function FormItem(props) {
434
465
  var _a;
435
- const [computedProps, setComputedProps] = (0, import_react7.useState)();
436
- const [extendTypes, setExtendTypes] = (0, import_react7.useState)();
466
+ const [computedProps, setComputedProps] = (0, import_react8.useState)();
467
+ const [extendTypes, setExtendTypes] = (0, import_react8.useState)();
437
468
  const config = useConfigContext();
438
- (0, import_react7.useEffect)(() => {
439
- const propsCopy = { ...props };
469
+ const [hidden, setHidden] = (0, import_react8.useState)(false);
470
+ (0, import_react8.useEffect)(() => {
471
+ const propsCopy = __spreadValues({}, props);
440
472
  if (propsCopy.extendTypes) {
441
473
  setExtendTypes(propsCopy.extendTypes);
442
474
  delete propsCopy.extendTypes;
443
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
+ }
444
485
  setComputedProps(processProps(propsCopy, config));
445
486
  }, [props]);
446
487
  if (!computedProps)
447
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
+ }));
448
496
  if (extendTypes && extendTypes[computedProps.type])
449
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
450
- ...computedProps,
497
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
451
498
  children: extendTypes[computedProps.type].children
452
- });
499
+ }));
453
500
  if (computedProps.children)
454
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
455
- ...computedProps,
501
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
456
502
  children: computedProps.children
457
- });
503
+ }));
458
504
  if (computedProps.render)
459
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
460
- ...computedProps,
505
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, computedProps), {
461
506
  children: computedProps.render()
462
- });
507
+ }));
463
508
  switch (computedProps.type) {
464
509
  case "string":
465
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
466
- ...computedProps,
467
- children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, {
468
- ...computedProps.input
469
- }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Input, {
470
- ...computedProps.input
471
- })
472
- });
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
+ }));
473
513
  case "string[]":
474
514
  if (computedProps.options)
475
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
476
- ...computedProps,
477
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, {
478
- mode: "multiple",
479
- ...computedProps.input
480
- })
481
- });
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
+ }));
482
520
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.List, {
483
521
  name: computedProps.name,
484
522
  rules: computedProps.rules,
@@ -502,13 +540,10 @@ function FormItem(props) {
502
540
  children: [
503
541
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
504
542
  span: 23,
505
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
506
- ...field,
543
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, field), {
507
544
  noStyle: true,
508
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Input, {
509
- ...computedProps.input
510
- })
511
- })
545
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Input, __spreadValues({}, computedProps.input))
546
+ }))
512
547
  }),
513
548
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
514
549
  span: 1,
@@ -542,24 +577,18 @@ function FormItem(props) {
542
577
  }
543
578
  });
544
579
  case "number":
545
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
546
- ...computedProps,
547
- children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, {
548
- ...computedProps.input
549
- }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.InputNumber, {
550
- style: { width: "100%" },
551
- ...computedProps.input
552
- })
553
- });
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
+ }));
554
585
  case "number[]":
555
586
  if (computedProps.options)
556
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
557
- ...computedProps,
558
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Select, {
559
- mode: "multiple",
560
- ...computedProps.input
561
- })
562
- });
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
+ }));
563
592
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.List, {
564
593
  name: computedProps.name,
565
594
  rules: computedProps.rules,
@@ -583,14 +612,12 @@ function FormItem(props) {
583
612
  children: [
584
613
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
585
614
  span: 23,
586
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
587
- ...field,
615
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, __spreadProps(__spreadValues({}, field), {
588
616
  noStyle: true,
589
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.InputNumber, {
590
- style: { width: "100%" },
591
- ...computedProps.input
592
- })
593
- })
617
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.InputNumber, __spreadValues({
618
+ style: { width: "100%" }
619
+ }, computedProps.input))
620
+ }))
594
621
  }),
595
622
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
596
623
  span: 1,
@@ -624,26 +651,17 @@ function FormItem(props) {
624
651
  }
625
652
  });
626
653
  case "boolean":
627
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
628
- ...computedProps,
629
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Switch, {
630
- ...computedProps.input
631
- })
632
- });
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
+ }));
633
657
  case "date":
634
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
635
- ...computedProps,
636
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DatePicker, {
637
- ...computedProps.input
638
- })
639
- });
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
+ }));
640
661
  case "time":
641
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Form.Item, {
642
- ...computedProps,
643
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TimePicker, {
644
- ...computedProps.input
645
- })
646
- });
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
+ }));
647
665
  case "object":
648
666
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, {
649
667
  children: [
@@ -654,9 +672,7 @@ function FormItem(props) {
654
672
  children: computedProps.label
655
673
  })
656
674
  }),
657
- computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormItem, {
658
- ...o
659
- }, o.id))
675
+ computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormItem, __spreadValues({}, o), o.id))
660
676
  ]
661
677
  });
662
678
  case "object[]":
@@ -687,11 +703,10 @@ function FormItem(props) {
687
703
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Row, {
688
704
  gutter: 24,
689
705
  children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd5.Col, {
690
- span: o.col || 6,
691
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormItem, {
692
- ...o,
706
+ span: o.col || 24,
707
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormItem, __spreadProps(__spreadValues({}, o), {
693
708
  name: [field.name, o.id]
694
- })
709
+ }))
695
710
  }, o.id))
696
711
  })
697
712
  ]
@@ -726,36 +741,33 @@ function FormItem(props) {
726
741
  var import_jsx_runtime7 = require("react/jsx-runtime");
727
742
  function Form(props) {
728
743
  var _a, _b;
729
- const [loading, setLoading] = (0, import_react9.useState)(false);
730
- const [computedProps, setComputedProps] = (0, import_react9.useState)();
744
+ const [loading, setLoading] = (0, import_react10.useState)(false);
745
+ const [computedProps, setComputedProps] = (0, import_react10.useState)();
731
746
  const config = useConfigContext();
732
- const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
747
+ const [extendTypes, setExtendTypes] = (0, import_react10.useState)();
733
748
  const [form] = import_antd6.Form.useForm(props.form);
734
- (0, import_react9.useEffect)(() => {
749
+ const [initialValues, setInitialValues] = (0, import_react10.useState)(props.initialValues);
750
+ (0, import_react10.useEffect)(() => {
735
751
  var _a2, _b2;
736
- const propsCopy = {
737
- ...props,
738
- items: (props.items || []).filter((it) => {
739
- return !it.if || it.if(props.initialValues || {});
740
- }),
752
+ const propsCopy = __spreadProps(__spreadValues({}, props), {
741
753
  form
742
- };
743
- if (propsCopy.initialValues)
754
+ });
755
+ if (propsCopy.initialValues) {
744
756
  for (const key in propsCopy.initialValues)
745
757
  propsCopy.initialValues[key] = transferValue(
746
758
  (_a2 = propsCopy.items.find((item) => item.id === key)) == null ? void 0 : _a2.type,
747
759
  propsCopy.initialValues[key]
748
760
  );
761
+ setInitialValues(propsCopy.initialValues);
762
+ delete propsCopy.initialValues;
763
+ }
749
764
  if (propsCopy.onFinish) {
750
765
  propsCopy.onFinish = async (values) => {
751
766
  var _a3;
752
767
  setLoading(true);
753
768
  try {
754
769
  if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
755
- await props.onFinish(values, async (values2) => (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
756
- ...values2,
757
- ...propsCopy.submit.to.params
758
- } : 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));
759
771
  } else
760
772
  await props.onFinish(values);
761
773
  } catch (error) {
@@ -766,10 +778,7 @@ function Form(props) {
766
778
  } else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
767
779
  propsCopy.onFinish = async (values) => {
768
780
  setLoading(true);
769
- return (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
770
- ...values,
771
- ...propsCopy.submit.to.params
772
- } : 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));
773
782
  };
774
783
  }
775
784
  if (propsCopy.extendTypes) {
@@ -778,7 +787,7 @@ function Form(props) {
778
787
  }
779
788
  setComputedProps(propsCopy);
780
789
  }, [props]);
781
- const onValuesChange = (0, import_react9.useCallback)((changedValues, allValues) => {
790
+ const onValuesChange = (0, import_react10.useCallback)((changedValues, allValues) => {
782
791
  if (props.onValuesChange) {
783
792
  props.onValuesChange(changedValues, allValues);
784
793
  }
@@ -789,39 +798,22 @@ function Form(props) {
789
798
  if (item == null ? void 0 : item.onValueChange)
790
799
  item.onValueChange(changedValues[key], allValues, form);
791
800
  }
792
- const filterItems = props.items.filter((it) => {
793
- if (!it.if) {
794
- return true;
795
- }
796
- const show = it.if(allValues);
797
- if (show) {
798
- props.form.setFields([
799
- {
800
- name: it.id,
801
- errors: null
802
- }
803
- ]);
804
- }
805
- return show;
806
- });
807
- if (computedProps.items.length !== filterItems.length || computedProps.items.some((it, i) => it !== filterItems[i])) {
808
- setComputedProps({
809
- ...computedProps,
810
- items: filterItems
811
- });
812
- }
801
+ }, [computedProps]);
802
+ (0, import_react10.useEffect)(() => {
803
+ if (!initialValues)
804
+ return;
805
+ form.setFieldsValue(initialValues);
806
+ setInitialValues(null);
813
807
  }, [computedProps]);
814
808
  if (!computedProps)
815
809
  return null;
816
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd6.Form, {
817
- ...computedProps,
810
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd6.Form, __spreadProps(__spreadValues({}, computedProps), {
818
811
  onValuesChange,
819
812
  children: [
820
813
  computedProps.beforeItems,
821
- (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FormItem, {
822
- ...item,
814
+ (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FormItem, __spreadProps(__spreadValues({}, item), {
823
815
  extendTypes
824
- }, item.id)),
816
+ }), item.id)),
825
817
  computedProps.children,
826
818
  computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd6.Button, {
827
819
  htmlType: "submit",
@@ -831,7 +823,7 @@ function Form(props) {
831
823
  }),
832
824
  computedProps.footer
833
825
  ]
834
- });
826
+ }));
835
827
  }
836
828
  Form.useForm = import_antd6.Form.useForm;
837
829
 
@@ -851,82 +843,61 @@ function Link({
851
843
  style = Object.assign({ cursor: "pointer" }, style);
852
844
  if (href.startsWith("http")) {
853
845
  if (button)
854
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd7.Button, {
855
- ...button,
846
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd7.Button, __spreadProps(__spreadValues({}, button), {
856
847
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", {
857
848
  href,
858
849
  target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
859
- style: {
860
- ...Link2.style,
861
- ...style || {}
862
- },
850
+ style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
863
851
  children: text || children
864
852
  })
865
- });
853
+ }));
866
854
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", {
867
855
  href,
868
856
  target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
869
- style: {
870
- ...Link2.style,
871
- ...style || {}
872
- },
857
+ style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
873
858
  children: text || children
874
859
  });
875
860
  }
876
861
  if (button)
877
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd7.Button, {
878
- ...button,
862
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd7.Button, __spreadProps(__spreadValues({}, button), {
879
863
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_router_dom.Link, {
880
864
  to: href,
881
865
  target: target || (Link2 == null ? void 0 : Link2.target),
882
- style: {
883
- ...Link2.style,
884
- ...style || {}
885
- },
866
+ style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
886
867
  children: text || children
887
868
  })
888
- });
869
+ }));
889
870
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_router_dom.Link, {
890
871
  to: href,
891
872
  target: target || (Link2 == null ? void 0 : Link2.target),
892
- style: {
893
- ...Link2.style,
894
- ...style || {}
895
- },
873
+ style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
896
874
  children: text || children
897
875
  });
898
876
  }
899
877
 
900
878
  // src/Modal.tsx
901
879
  var import_antd8 = require("antd");
902
- var import_react10 = require("react");
880
+ var import_react11 = require("react");
903
881
  var import_jsx_runtime9 = require("react/jsx-runtime");
904
882
  function useModal(init) {
905
- const [props, setProps] = (0, import_react10.useState)({
883
+ const [props, setProps] = (0, import_react11.useState)(__spreadValues({
906
884
  open: false,
907
- onCancel: () => setProps((prev) => ({
908
- ...prev,
885
+ onCancel: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
909
886
  open: false
910
- })),
911
- ...init
912
- });
887
+ }))
888
+ }, init));
913
889
  return {
914
- modal: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_antd8.Modal, {
915
- ...props
916
- }),
890
+ modal: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_antd8.Modal, __spreadValues({}, props)),
917
891
  modalProps: props,
918
892
  setModalProps(changes) {
919
- setProps((prev) => ({
920
- ...prev,
921
- ...changes
922
- }));
893
+ setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
923
894
  }
924
895
  };
925
896
  }
926
897
 
927
898
  // src/Routers.tsx
928
899
  var import_antd9 = require("antd");
929
- var import_react11 = require("react");
900
+ var import_react12 = require("react");
930
901
  var import_react_router_dom2 = require("react-router-dom");
931
902
  var import_jsx_runtime10 = require("react/jsx-runtime");
932
903
  function PageNotFound() {
@@ -939,9 +910,8 @@ function PageNotFound() {
939
910
  function Routes(props) {
940
911
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_router_dom2.Routes, {
941
912
  children: [
942
- props.routes.map((r) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_router_dom2.Route, {
943
- ...r,
944
- 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, {
945
915
  fallback: props.fallback || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {
946
916
  style: { padding: "24px" },
947
917
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd9.Skeleton, {
@@ -950,7 +920,7 @@ function Routes(props) {
950
920
  }),
951
921
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(r.page, {})
952
922
  })
953
- }, r.path)),
923
+ }), r.path)),
954
924
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_router_dom2.Route, {
955
925
  path: "*",
956
926
  element: props.notFound || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PageNotFound, {})
@@ -960,12 +930,11 @@ function Routes(props) {
960
930
  }
961
931
 
962
932
  // src/Table.tsx
963
- var import_react12 = require("react");
933
+ var import_react13 = require("react");
964
934
  var import_antd10 = require("antd");
965
935
  var import_dayjs4 = __toESM(require("dayjs"));
966
936
  var import_icons3 = require("@ant-design/icons");
967
937
  var import_lodash6 = require("lodash");
968
- var import_react13 = require("@faasjs/react");
969
938
  var import_jsx_runtime11 = require("react/jsx-runtime");
970
939
  function processValue(item, value) {
971
940
  var _a;
@@ -992,9 +961,9 @@ function processValue(item, value) {
992
961
  return value;
993
962
  }
994
963
  function Table(props) {
995
- const [columns, setColumns] = (0, import_react12.useState)();
964
+ const [columns, setColumns] = (0, import_react13.useState)();
996
965
  const { common: common2 } = useConfigContext();
997
- (0, import_react12.useEffect)(() => {
966
+ (0, import_react13.useEffect)(() => {
998
967
  var _a;
999
968
  for (const item of props.items) {
1000
969
  if (!item.key)
@@ -1016,7 +985,7 @@ function Table(props) {
1016
985
  delete item.children;
1017
986
  if (props.extendTypes && props.extendTypes[item.type]) {
1018
987
  if (props.extendTypes[item.type].children)
1019
- item.render = (value, values) => (0, import_react12.cloneElement)(
988
+ item.render = (value, values) => (0, import_react13.cloneElement)(
1020
989
  props.extendTypes[item.type].children,
1021
990
  {
1022
991
  value,
@@ -1246,7 +1215,7 @@ function Table(props) {
1246
1215
  }
1247
1216
  setColumns(props.items);
1248
1217
  }, [props.items]);
1249
- (0, import_react12.useEffect)(() => {
1218
+ (0, import_react13.useEffect)(() => {
1250
1219
  if (!props.dataSource || !columns)
1251
1220
  return;
1252
1221
  for (const column of columns) {
@@ -1266,13 +1235,12 @@ function Table(props) {
1266
1235
  if (!columns)
1267
1236
  return null;
1268
1237
  if (!props.faasData)
1269
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, {
1270
- ...props,
1238
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, __spreadProps(__spreadValues({}, props), {
1271
1239
  rowKey: props.rowKey || "id",
1272
1240
  columns,
1273
1241
  dataSource: props.dataSource
1274
- });
1275
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react13.FaasDataWrapper, {
1242
+ }));
1243
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FaasDataWrapper, __spreadValues({
1276
1244
  fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Skeleton, {
1277
1245
  active: true
1278
1246
  }),
@@ -1282,59 +1250,50 @@ function Table(props) {
1282
1250
  reload
1283
1251
  }) => {
1284
1252
  if (!data)
1285
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, {
1286
- ...props,
1253
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, __spreadProps(__spreadValues({}, props), {
1287
1254
  rowKey: props.rowKey || "id",
1288
1255
  columns,
1289
1256
  dataSource: []
1290
- });
1257
+ }));
1291
1258
  if (Array.isArray(data))
1292
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, {
1293
- ...props,
1259
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, __spreadProps(__spreadValues({}, props), {
1294
1260
  rowKey: props.rowKey || "id",
1295
1261
  columns,
1296
1262
  dataSource: data
1297
- });
1298
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, {
1299
- ...props,
1263
+ }));
1264
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd10.Table, __spreadProps(__spreadValues({}, props), {
1300
1265
  rowKey: props.rowKey || "id",
1301
1266
  columns,
1302
1267
  dataSource: data.rows,
1303
- pagination: {
1304
- ...props.pagination,
1305
- ...data.pagination
1306
- },
1268
+ pagination: __spreadValues(__spreadValues({}, props.pagination), data.pagination),
1307
1269
  onChange: (pagination, filters, sorter, extra) => {
1308
1270
  if (props.onChange) {
1309
1271
  const processed = props.onChange(pagination, filters, sorter, extra);
1310
- reload({
1311
- ...params,
1272
+ reload(__spreadProps(__spreadValues({}, params), {
1312
1273
  pagination: processed.pagination,
1313
1274
  filters: processed.filters,
1314
1275
  sorter: processed.sorter
1315
- });
1276
+ }));
1316
1277
  return;
1317
1278
  }
1318
- reload({
1319
- ...params,
1279
+ reload(__spreadProps(__spreadValues({}, params), {
1320
1280
  pagination,
1321
1281
  filters,
1322
1282
  sorter
1323
- });
1283
+ }));
1324
1284
  }
1325
- });
1326
- },
1327
- ...props.faasData
1328
- });
1285
+ }));
1286
+ }
1287
+ }, props.faasData));
1329
1288
  }
1330
1289
 
1331
1290
  // src/Title.tsx
1332
- var import_react14 = require("react");
1291
+ var import_react15 = require("react");
1333
1292
  var import_antd11 = require("antd");
1334
1293
  var import_jsx_runtime12 = require("react/jsx-runtime");
1335
1294
  function Title(props) {
1336
1295
  const { Title: Title2 } = useConfigContext();
1337
- (0, import_react14.useEffect)(() => {
1296
+ (0, import_react15.useEffect)(() => {
1338
1297
  const title = Array.isArray(props.title) ? props.title : [props.title];
1339
1298
  document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
1340
1299
  }, [props]);
@@ -1354,12 +1313,11 @@ function Title(props) {
1354
1313
  children: Array.isArray(props.title) ? props.title[0] : props.title
1355
1314
  });
1356
1315
  if (props.header)
1357
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_antd11.PageHeader, {
1358
- title: Array.isArray(props.title) ? props.title[0] : props.title,
1359
- ...props.header
1360
- });
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));
1361
1319
  if (props.children)
1362
- return (0, import_react14.cloneElement)(props.children, { title: props.title });
1320
+ return (0, import_react15.cloneElement)(props.children, { title: props.title });
1363
1321
  return null;
1364
1322
  }
1365
1323
  // Annotate the CommonJS export names for ESM import in node: