@faasjs/ant-design 0.0.2-beta.453 → 0.0.2-beta.455
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 +337 -288
- package/dist/index.mjs +226 -184
- package/package.json +3 -5
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
1
|
// react-shim.js
|
|
22
2
|
import React from "react";
|
|
23
3
|
|
|
@@ -92,9 +72,10 @@ function ConfigProvider({
|
|
|
92
72
|
}, []);
|
|
93
73
|
return /* @__PURE__ */ jsx(ConfigContext.Provider, {
|
|
94
74
|
value: values,
|
|
95
|
-
children: /* @__PURE__ */ jsx(AntdConfigProvider,
|
|
75
|
+
children: /* @__PURE__ */ jsx(AntdConfigProvider, {
|
|
76
|
+
...config.antd,
|
|
96
77
|
children
|
|
97
|
-
})
|
|
78
|
+
})
|
|
98
79
|
});
|
|
99
80
|
}
|
|
100
81
|
function useConfigContext() {
|
|
@@ -160,46 +141,17 @@ import {
|
|
|
160
141
|
import { isFunction, upperFirst as upperFirst2 } from "lodash";
|
|
161
142
|
import {
|
|
162
143
|
cloneElement,
|
|
163
|
-
useEffect as useEffect3,
|
|
164
|
-
useState as useState3
|
|
165
|
-
} from "react";
|
|
166
|
-
|
|
167
|
-
// ../react/src/index.tsx
|
|
168
|
-
import {
|
|
169
|
-
useState as useState2,
|
|
170
144
|
useEffect as useEffect2,
|
|
171
|
-
|
|
145
|
+
useState as useState2
|
|
172
146
|
} from "react";
|
|
173
|
-
|
|
174
|
-
function getClient(domain) {
|
|
175
|
-
const client = clients[domain || Object.keys(clients)[0]];
|
|
176
|
-
if (!client)
|
|
177
|
-
throw Error("FaasReactClient is not initialized");
|
|
178
|
-
return client;
|
|
179
|
-
}
|
|
180
|
-
async function faas(action, params) {
|
|
181
|
-
return getClient().faas(action, params);
|
|
182
|
-
}
|
|
183
|
-
function FaasDataWrapper(props) {
|
|
184
|
-
const [client, setClient] = useState2();
|
|
185
|
-
useEffect2(() => {
|
|
186
|
-
if (client)
|
|
187
|
-
return;
|
|
188
|
-
setClient(getClient());
|
|
189
|
-
}, []);
|
|
190
|
-
if (!client)
|
|
191
|
-
return props.fallback || null;
|
|
192
|
-
return createElement(client.FaasDataWrapper, props);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// src/Description.tsx
|
|
147
|
+
import { FaasDataWrapper } from "@faasjs/react";
|
|
196
148
|
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
|
197
149
|
function DescriptionItemContent(props) {
|
|
198
150
|
var _a;
|
|
199
|
-
const [computedProps, setComputedProps] =
|
|
200
|
-
|
|
151
|
+
const [computedProps, setComputedProps] = useState2();
|
|
152
|
+
useEffect2(() => {
|
|
201
153
|
var _a2, _b;
|
|
202
|
-
const propsCopy =
|
|
154
|
+
const propsCopy = { ...props };
|
|
203
155
|
if (!propsCopy.item.title)
|
|
204
156
|
propsCopy.item.title = upperFirst2(propsCopy.item.id);
|
|
205
157
|
if (!propsCopy.item.type)
|
|
@@ -302,7 +254,8 @@ function DescriptionItemContent(props) {
|
|
|
302
254
|
}
|
|
303
255
|
function Description(props) {
|
|
304
256
|
if (!props.faasData)
|
|
305
|
-
return /* @__PURE__ */ jsx3(Descriptions,
|
|
257
|
+
return /* @__PURE__ */ jsx3(Descriptions, {
|
|
258
|
+
...props,
|
|
306
259
|
title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
307
260
|
children: props.items.map((item) => {
|
|
308
261
|
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
|
|
@@ -315,13 +268,14 @@ function Description(props) {
|
|
|
315
268
|
})
|
|
316
269
|
}, item.id) : null;
|
|
317
270
|
}).filter(Boolean)
|
|
318
|
-
})
|
|
319
|
-
return /* @__PURE__ */ jsx3(FaasDataWrapper,
|
|
271
|
+
});
|
|
272
|
+
return /* @__PURE__ */ jsx3(FaasDataWrapper, {
|
|
320
273
|
fallback: props.faasData.fallback || /* @__PURE__ */ jsx3(Skeleton, {
|
|
321
274
|
active: true
|
|
322
275
|
}),
|
|
323
276
|
render: ({ data }) => {
|
|
324
|
-
return /* @__PURE__ */ jsx3(Descriptions,
|
|
277
|
+
return /* @__PURE__ */ jsx3(Descriptions, {
|
|
278
|
+
...props,
|
|
325
279
|
title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
326
280
|
children: props.items.map((item) => {
|
|
327
281
|
return !item.if || item.if(data) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
|
|
@@ -334,39 +288,48 @@ function Description(props) {
|
|
|
334
288
|
})
|
|
335
289
|
}, item.id) : null;
|
|
336
290
|
}).filter(Boolean)
|
|
337
|
-
})
|
|
338
|
-
}
|
|
339
|
-
|
|
291
|
+
});
|
|
292
|
+
},
|
|
293
|
+
...props.faasData
|
|
294
|
+
});
|
|
340
295
|
}
|
|
341
296
|
|
|
342
297
|
// src/Drawer.tsx
|
|
343
298
|
import { Drawer } from "antd";
|
|
344
|
-
import { useState as
|
|
299
|
+
import { useState as useState3 } from "react";
|
|
345
300
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
346
301
|
function useDrawer(init) {
|
|
347
|
-
const [props, setProps] =
|
|
302
|
+
const [props, setProps] = useState3({
|
|
348
303
|
open: false,
|
|
349
|
-
onClose: () => setProps((prev) =>
|
|
304
|
+
onClose: () => setProps((prev) => ({
|
|
305
|
+
...prev,
|
|
350
306
|
open: false
|
|
351
|
-
}))
|
|
352
|
-
|
|
307
|
+
})),
|
|
308
|
+
...init
|
|
309
|
+
});
|
|
353
310
|
return {
|
|
354
|
-
drawer: /* @__PURE__ */ jsx4(Drawer,
|
|
311
|
+
drawer: /* @__PURE__ */ jsx4(Drawer, {
|
|
312
|
+
...props
|
|
313
|
+
}),
|
|
355
314
|
drawerProps: props,
|
|
356
315
|
setDrawerProps(changes) {
|
|
357
|
-
setProps((prev) =>
|
|
316
|
+
setProps((prev) => ({
|
|
317
|
+
...prev,
|
|
318
|
+
...changes
|
|
319
|
+
}));
|
|
358
320
|
}
|
|
359
321
|
};
|
|
360
322
|
}
|
|
361
323
|
|
|
362
324
|
// src/Form.tsx
|
|
325
|
+
import { faas } from "@faasjs/react";
|
|
363
326
|
import {
|
|
364
327
|
Button as Button2,
|
|
365
328
|
Form as AntdForm2
|
|
366
329
|
} from "antd";
|
|
367
330
|
import {
|
|
368
|
-
useEffect as
|
|
369
|
-
useState as
|
|
331
|
+
useEffect as useEffect4,
|
|
332
|
+
useState as useState5,
|
|
370
333
|
useCallback
|
|
371
334
|
} from "react";
|
|
372
335
|
|
|
@@ -383,8 +346,8 @@ import {
|
|
|
383
346
|
} from "antd";
|
|
384
347
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
385
348
|
import {
|
|
386
|
-
useEffect as
|
|
387
|
-
useState as
|
|
349
|
+
useEffect as useEffect3,
|
|
350
|
+
useState as useState4
|
|
388
351
|
} from "react";
|
|
389
352
|
import { upperFirst as upperFirst3 } from "lodash";
|
|
390
353
|
|
|
@@ -392,11 +355,12 @@ import { upperFirst as upperFirst3 } from "lodash";
|
|
|
392
355
|
import { forwardRef } from "react";
|
|
393
356
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
394
357
|
var TimePicker = forwardRef((props, ref) => {
|
|
395
|
-
return /* @__PURE__ */ jsx5(DatePicker,
|
|
358
|
+
return /* @__PURE__ */ jsx5(DatePicker, {
|
|
359
|
+
...props,
|
|
396
360
|
picker: "time",
|
|
397
361
|
mode: void 0,
|
|
398
362
|
ref
|
|
399
|
-
})
|
|
363
|
+
});
|
|
400
364
|
});
|
|
401
365
|
TimePicker.displayName = "TimePicker";
|
|
402
366
|
|
|
@@ -450,12 +414,12 @@ function processProps(propsCopy, config) {
|
|
|
450
414
|
}
|
|
451
415
|
function FormItem(props) {
|
|
452
416
|
var _a;
|
|
453
|
-
const [computedProps, setComputedProps] =
|
|
454
|
-
const [extendTypes, setExtendTypes] =
|
|
417
|
+
const [computedProps, setComputedProps] = useState4();
|
|
418
|
+
const [extendTypes, setExtendTypes] = useState4();
|
|
455
419
|
const config = useConfigContext();
|
|
456
|
-
const [hidden, setHidden] =
|
|
457
|
-
|
|
458
|
-
const propsCopy =
|
|
420
|
+
const [hidden, setHidden] = useState4(false);
|
|
421
|
+
useEffect3(() => {
|
|
422
|
+
const propsCopy = { ...props };
|
|
459
423
|
if (propsCopy.extendTypes) {
|
|
460
424
|
setExtendTypes(propsCopy.extendTypes);
|
|
461
425
|
delete propsCopy.extendTypes;
|
|
@@ -474,36 +438,48 @@ function FormItem(props) {
|
|
|
474
438
|
if (!computedProps)
|
|
475
439
|
return null;
|
|
476
440
|
if (hidden)
|
|
477
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
441
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
442
|
+
...computedProps,
|
|
478
443
|
noStyle: true,
|
|
444
|
+
rules: [],
|
|
479
445
|
children: /* @__PURE__ */ jsx6(Input, {
|
|
480
446
|
hidden: true
|
|
481
447
|
})
|
|
482
|
-
})
|
|
448
|
+
});
|
|
483
449
|
if (extendTypes && extendTypes[computedProps.type])
|
|
484
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
450
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
451
|
+
...computedProps,
|
|
485
452
|
children: extendTypes[computedProps.type].children
|
|
486
|
-
})
|
|
453
|
+
});
|
|
487
454
|
if (computedProps.children)
|
|
488
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
455
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
456
|
+
...computedProps,
|
|
489
457
|
children: computedProps.children
|
|
490
|
-
})
|
|
458
|
+
});
|
|
491
459
|
if (computedProps.render)
|
|
492
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
460
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
461
|
+
...computedProps,
|
|
493
462
|
children: computedProps.render()
|
|
494
|
-
})
|
|
463
|
+
});
|
|
495
464
|
switch (computedProps.type) {
|
|
496
465
|
case "string":
|
|
497
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
498
|
-
|
|
499
|
-
|
|
466
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
467
|
+
...computedProps,
|
|
468
|
+
children: computedProps.options ? /* @__PURE__ */ jsx6(Select, {
|
|
469
|
+
...computedProps.input
|
|
470
|
+
}) : /* @__PURE__ */ jsx6(Input, {
|
|
471
|
+
...computedProps.input
|
|
472
|
+
})
|
|
473
|
+
});
|
|
500
474
|
case "string[]":
|
|
501
475
|
if (computedProps.options)
|
|
502
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
476
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
477
|
+
...computedProps,
|
|
478
|
+
children: /* @__PURE__ */ jsx6(Select, {
|
|
479
|
+
mode: "multiple",
|
|
480
|
+
...computedProps.input
|
|
481
|
+
})
|
|
482
|
+
});
|
|
507
483
|
return /* @__PURE__ */ jsx6(AntdForm.List, {
|
|
508
484
|
name: computedProps.name,
|
|
509
485
|
rules: computedProps.rules,
|
|
@@ -527,10 +503,13 @@ function FormItem(props) {
|
|
|
527
503
|
children: [
|
|
528
504
|
/* @__PURE__ */ jsx6(Col, {
|
|
529
505
|
span: 23,
|
|
530
|
-
children: /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
506
|
+
children: /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
507
|
+
...field,
|
|
531
508
|
noStyle: true,
|
|
532
|
-
children: /* @__PURE__ */ jsx6(Input,
|
|
533
|
-
|
|
509
|
+
children: /* @__PURE__ */ jsx6(Input, {
|
|
510
|
+
...computedProps.input
|
|
511
|
+
})
|
|
512
|
+
})
|
|
534
513
|
}),
|
|
535
514
|
/* @__PURE__ */ jsx6(Col, {
|
|
536
515
|
span: 1,
|
|
@@ -564,18 +543,24 @@ function FormItem(props) {
|
|
|
564
543
|
}
|
|
565
544
|
});
|
|
566
545
|
case "number":
|
|
567
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
546
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
547
|
+
...computedProps,
|
|
548
|
+
children: computedProps.options ? /* @__PURE__ */ jsx6(Select, {
|
|
549
|
+
...computedProps.input
|
|
550
|
+
}) : /* @__PURE__ */ jsx6(InputNumber, {
|
|
551
|
+
style: { width: "100%" },
|
|
552
|
+
...computedProps.input
|
|
553
|
+
})
|
|
554
|
+
});
|
|
572
555
|
case "number[]":
|
|
573
556
|
if (computedProps.options)
|
|
574
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
557
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
558
|
+
...computedProps,
|
|
559
|
+
children: /* @__PURE__ */ jsx6(Select, {
|
|
560
|
+
mode: "multiple",
|
|
561
|
+
...computedProps.input
|
|
562
|
+
})
|
|
563
|
+
});
|
|
579
564
|
return /* @__PURE__ */ jsx6(AntdForm.List, {
|
|
580
565
|
name: computedProps.name,
|
|
581
566
|
rules: computedProps.rules,
|
|
@@ -599,12 +584,14 @@ function FormItem(props) {
|
|
|
599
584
|
children: [
|
|
600
585
|
/* @__PURE__ */ jsx6(Col, {
|
|
601
586
|
span: 23,
|
|
602
|
-
children: /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
587
|
+
children: /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
588
|
+
...field,
|
|
603
589
|
noStyle: true,
|
|
604
|
-
children: /* @__PURE__ */ jsx6(InputNumber,
|
|
605
|
-
style: { width: "100%" }
|
|
606
|
-
|
|
607
|
-
|
|
590
|
+
children: /* @__PURE__ */ jsx6(InputNumber, {
|
|
591
|
+
style: { width: "100%" },
|
|
592
|
+
...computedProps.input
|
|
593
|
+
})
|
|
594
|
+
})
|
|
608
595
|
}),
|
|
609
596
|
/* @__PURE__ */ jsx6(Col, {
|
|
610
597
|
span: 1,
|
|
@@ -638,17 +625,26 @@ function FormItem(props) {
|
|
|
638
625
|
}
|
|
639
626
|
});
|
|
640
627
|
case "boolean":
|
|
641
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
642
|
-
|
|
643
|
-
|
|
628
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
629
|
+
...computedProps,
|
|
630
|
+
children: /* @__PURE__ */ jsx6(Switch, {
|
|
631
|
+
...computedProps.input
|
|
632
|
+
})
|
|
633
|
+
});
|
|
644
634
|
case "date":
|
|
645
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
646
|
-
|
|
647
|
-
|
|
635
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
636
|
+
...computedProps,
|
|
637
|
+
children: /* @__PURE__ */ jsx6(DatePicker, {
|
|
638
|
+
...computedProps.input
|
|
639
|
+
})
|
|
640
|
+
});
|
|
648
641
|
case "time":
|
|
649
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item,
|
|
650
|
-
|
|
651
|
-
|
|
642
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
643
|
+
...computedProps,
|
|
644
|
+
children: /* @__PURE__ */ jsx6(TimePicker, {
|
|
645
|
+
...computedProps.input
|
|
646
|
+
})
|
|
647
|
+
});
|
|
652
648
|
case "object":
|
|
653
649
|
return /* @__PURE__ */ jsxs(Fragment2, {
|
|
654
650
|
children: [
|
|
@@ -659,7 +655,9 @@ function FormItem(props) {
|
|
|
659
655
|
children: computedProps.label
|
|
660
656
|
})
|
|
661
657
|
}),
|
|
662
|
-
computedProps.object.map((o) => /* @__PURE__ */ jsx6(FormItem,
|
|
658
|
+
computedProps.object.map((o) => /* @__PURE__ */ jsx6(FormItem, {
|
|
659
|
+
...o
|
|
660
|
+
}, o.id))
|
|
663
661
|
]
|
|
664
662
|
});
|
|
665
663
|
case "object[]":
|
|
@@ -691,9 +689,10 @@ function FormItem(props) {
|
|
|
691
689
|
gutter: 24,
|
|
692
690
|
children: computedProps.object.map((o) => /* @__PURE__ */ jsx6(Col, {
|
|
693
691
|
span: o.col || 24,
|
|
694
|
-
children: /* @__PURE__ */ jsx6(FormItem,
|
|
692
|
+
children: /* @__PURE__ */ jsx6(FormItem, {
|
|
693
|
+
...o,
|
|
695
694
|
name: [field.name, o.id]
|
|
696
|
-
})
|
|
695
|
+
})
|
|
697
696
|
}, o.id))
|
|
698
697
|
})
|
|
699
698
|
]
|
|
@@ -728,17 +727,18 @@ function FormItem(props) {
|
|
|
728
727
|
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
729
728
|
function Form(props) {
|
|
730
729
|
var _a, _b;
|
|
731
|
-
const [loading, setLoading] =
|
|
732
|
-
const [computedProps, setComputedProps] =
|
|
730
|
+
const [loading, setLoading] = useState5(false);
|
|
731
|
+
const [computedProps, setComputedProps] = useState5();
|
|
733
732
|
const config = useConfigContext();
|
|
734
|
-
const [extendTypes, setExtendTypes] =
|
|
733
|
+
const [extendTypes, setExtendTypes] = useState5();
|
|
735
734
|
const [form] = AntdForm2.useForm(props.form);
|
|
736
|
-
const [initialValues, setInitialValues] =
|
|
737
|
-
|
|
735
|
+
const [initialValues, setInitialValues] = useState5(props.initialValues);
|
|
736
|
+
useEffect4(() => {
|
|
738
737
|
var _a2, _b2;
|
|
739
|
-
const propsCopy =
|
|
738
|
+
const propsCopy = {
|
|
739
|
+
...props,
|
|
740
740
|
form
|
|
741
|
-
}
|
|
741
|
+
};
|
|
742
742
|
if (propsCopy.initialValues) {
|
|
743
743
|
for (const key in propsCopy.initialValues)
|
|
744
744
|
propsCopy.initialValues[key] = transferValue(
|
|
@@ -754,7 +754,10 @@ function Form(props) {
|
|
|
754
754
|
setLoading(true);
|
|
755
755
|
try {
|
|
756
756
|
if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
|
|
757
|
-
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ?
|
|
757
|
+
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
758
|
+
...values2,
|
|
759
|
+
...propsCopy.submit.to.params
|
|
760
|
+
} : values2));
|
|
758
761
|
} else
|
|
759
762
|
await props.onFinish(values);
|
|
760
763
|
} catch (error) {
|
|
@@ -765,7 +768,10 @@ function Form(props) {
|
|
|
765
768
|
} else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
|
|
766
769
|
propsCopy.onFinish = async (values) => {
|
|
767
770
|
setLoading(true);
|
|
768
|
-
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ?
|
|
771
|
+
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
772
|
+
...values,
|
|
773
|
+
...propsCopy.submit.to.params
|
|
774
|
+
} : values).finally(() => setLoading(false));
|
|
769
775
|
};
|
|
770
776
|
}
|
|
771
777
|
if (propsCopy.extendTypes) {
|
|
@@ -786,7 +792,7 @@ function Form(props) {
|
|
|
786
792
|
item.onValueChange(changedValues[key], allValues, form);
|
|
787
793
|
}
|
|
788
794
|
}, [computedProps]);
|
|
789
|
-
|
|
795
|
+
useEffect4(() => {
|
|
790
796
|
if (!initialValues)
|
|
791
797
|
return;
|
|
792
798
|
form.setFieldsValue(initialValues);
|
|
@@ -794,13 +800,15 @@ function Form(props) {
|
|
|
794
800
|
}, [computedProps]);
|
|
795
801
|
if (!computedProps)
|
|
796
802
|
return null;
|
|
797
|
-
return /* @__PURE__ */ jsxs2(AntdForm2,
|
|
803
|
+
return /* @__PURE__ */ jsxs2(AntdForm2, {
|
|
804
|
+
...computedProps,
|
|
798
805
|
onValuesChange,
|
|
799
806
|
children: [
|
|
800
807
|
computedProps.beforeItems,
|
|
801
|
-
(_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsx7(FormItem,
|
|
808
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsx7(FormItem, {
|
|
809
|
+
...item,
|
|
802
810
|
extendTypes
|
|
803
|
-
}
|
|
811
|
+
}, item.id)),
|
|
804
812
|
computedProps.children,
|
|
805
813
|
computedProps.submit !== false && /* @__PURE__ */ jsx7(Button2, {
|
|
806
814
|
htmlType: "submit",
|
|
@@ -810,7 +818,7 @@ function Form(props) {
|
|
|
810
818
|
}),
|
|
811
819
|
computedProps.footer
|
|
812
820
|
]
|
|
813
|
-
})
|
|
821
|
+
});
|
|
814
822
|
}
|
|
815
823
|
Form.useForm = AntdForm2.useForm;
|
|
816
824
|
|
|
@@ -830,54 +838,75 @@ function Link({
|
|
|
830
838
|
style = Object.assign({ cursor: "pointer" }, style);
|
|
831
839
|
if (href.startsWith("http")) {
|
|
832
840
|
if (button)
|
|
833
|
-
return /* @__PURE__ */ jsx8(Button3,
|
|
841
|
+
return /* @__PURE__ */ jsx8(Button3, {
|
|
842
|
+
...button,
|
|
834
843
|
children: /* @__PURE__ */ jsx8("a", {
|
|
835
844
|
href,
|
|
836
845
|
target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
837
|
-
style:
|
|
846
|
+
style: {
|
|
847
|
+
...Link2.style,
|
|
848
|
+
...style || {}
|
|
849
|
+
},
|
|
838
850
|
children: text || children
|
|
839
851
|
})
|
|
840
|
-
})
|
|
852
|
+
});
|
|
841
853
|
return /* @__PURE__ */ jsx8("a", {
|
|
842
854
|
href,
|
|
843
855
|
target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
844
|
-
style:
|
|
856
|
+
style: {
|
|
857
|
+
...Link2.style,
|
|
858
|
+
...style || {}
|
|
859
|
+
},
|
|
845
860
|
children: text || children
|
|
846
861
|
});
|
|
847
862
|
}
|
|
848
863
|
if (button)
|
|
849
|
-
return /* @__PURE__ */ jsx8(Button3,
|
|
864
|
+
return /* @__PURE__ */ jsx8(Button3, {
|
|
865
|
+
...button,
|
|
850
866
|
children: /* @__PURE__ */ jsx8(RouterLink, {
|
|
851
867
|
to: href,
|
|
852
868
|
target: target || (Link2 == null ? void 0 : Link2.target),
|
|
853
|
-
style:
|
|
869
|
+
style: {
|
|
870
|
+
...Link2.style,
|
|
871
|
+
...style || {}
|
|
872
|
+
},
|
|
854
873
|
children: text || children
|
|
855
874
|
})
|
|
856
|
-
})
|
|
875
|
+
});
|
|
857
876
|
return /* @__PURE__ */ jsx8(RouterLink, {
|
|
858
877
|
to: href,
|
|
859
878
|
target: target || (Link2 == null ? void 0 : Link2.target),
|
|
860
|
-
style:
|
|
879
|
+
style: {
|
|
880
|
+
...Link2.style,
|
|
881
|
+
...style || {}
|
|
882
|
+
},
|
|
861
883
|
children: text || children
|
|
862
884
|
});
|
|
863
885
|
}
|
|
864
886
|
|
|
865
887
|
// src/Modal.tsx
|
|
866
888
|
import { Modal } from "antd";
|
|
867
|
-
import { useState as
|
|
889
|
+
import { useState as useState6 } from "react";
|
|
868
890
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
869
891
|
function useModal(init) {
|
|
870
|
-
const [props, setProps] =
|
|
892
|
+
const [props, setProps] = useState6({
|
|
871
893
|
open: false,
|
|
872
|
-
onCancel: () => setProps((prev) =>
|
|
894
|
+
onCancel: () => setProps((prev) => ({
|
|
895
|
+
...prev,
|
|
873
896
|
open: false
|
|
874
|
-
}))
|
|
875
|
-
|
|
897
|
+
})),
|
|
898
|
+
...init
|
|
899
|
+
});
|
|
876
900
|
return {
|
|
877
|
-
modal: /* @__PURE__ */ jsx9(Modal,
|
|
901
|
+
modal: /* @__PURE__ */ jsx9(Modal, {
|
|
902
|
+
...props
|
|
903
|
+
}),
|
|
878
904
|
modalProps: props,
|
|
879
905
|
setModalProps(changes) {
|
|
880
|
-
setProps((prev) =>
|
|
906
|
+
setProps((prev) => ({
|
|
907
|
+
...prev,
|
|
908
|
+
...changes
|
|
909
|
+
}));
|
|
881
910
|
}
|
|
882
911
|
};
|
|
883
912
|
}
|
|
@@ -902,7 +931,8 @@ function PageNotFound() {
|
|
|
902
931
|
function Routes(props) {
|
|
903
932
|
return /* @__PURE__ */ jsxs3(OriginRoutes, {
|
|
904
933
|
children: [
|
|
905
|
-
props.routes.map((r) => /* @__PURE__ */ jsx10(Route,
|
|
934
|
+
props.routes.map((r) => /* @__PURE__ */ jsx10(Route, {
|
|
935
|
+
...r,
|
|
906
936
|
element: r.element || /* @__PURE__ */ jsx10(Suspense, {
|
|
907
937
|
fallback: props.fallback || /* @__PURE__ */ jsx10("div", {
|
|
908
938
|
style: { padding: "24px" },
|
|
@@ -912,7 +942,7 @@ function Routes(props) {
|
|
|
912
942
|
}),
|
|
913
943
|
children: /* @__PURE__ */ jsx10(r.page, {})
|
|
914
944
|
})
|
|
915
|
-
}
|
|
945
|
+
}, r.path)),
|
|
916
946
|
/* @__PURE__ */ jsx10(Route, {
|
|
917
947
|
path: "*",
|
|
918
948
|
element: props.notFound || /* @__PURE__ */ jsx10(PageNotFound, {})
|
|
@@ -923,8 +953,8 @@ function Routes(props) {
|
|
|
923
953
|
|
|
924
954
|
// src/Table.tsx
|
|
925
955
|
import {
|
|
926
|
-
useState as
|
|
927
|
-
useEffect as
|
|
956
|
+
useState as useState7,
|
|
957
|
+
useEffect as useEffect5,
|
|
928
958
|
cloneElement as cloneElement2
|
|
929
959
|
} from "react";
|
|
930
960
|
import {
|
|
@@ -940,6 +970,7 @@ import {
|
|
|
940
970
|
uniqBy,
|
|
941
971
|
upperFirst as upperFirst4
|
|
942
972
|
} from "lodash";
|
|
973
|
+
import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
943
974
|
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
944
975
|
function processValue(item, value) {
|
|
945
976
|
var _a;
|
|
@@ -966,9 +997,9 @@ function processValue(item, value) {
|
|
|
966
997
|
return value;
|
|
967
998
|
}
|
|
968
999
|
function Table(props) {
|
|
969
|
-
const [columns, setColumns] =
|
|
1000
|
+
const [columns, setColumns] = useState7();
|
|
970
1001
|
const { common: common2 } = useConfigContext();
|
|
971
|
-
|
|
1002
|
+
useEffect5(() => {
|
|
972
1003
|
var _a;
|
|
973
1004
|
for (const item of props.items) {
|
|
974
1005
|
if (!item.key)
|
|
@@ -1220,7 +1251,7 @@ function Table(props) {
|
|
|
1220
1251
|
}
|
|
1221
1252
|
setColumns(props.items);
|
|
1222
1253
|
}, [props.items]);
|
|
1223
|
-
|
|
1254
|
+
useEffect5(() => {
|
|
1224
1255
|
if (!props.dataSource || !columns)
|
|
1225
1256
|
return;
|
|
1226
1257
|
for (const column of columns) {
|
|
@@ -1240,12 +1271,13 @@ function Table(props) {
|
|
|
1240
1271
|
if (!columns)
|
|
1241
1272
|
return null;
|
|
1242
1273
|
if (!props.faasData)
|
|
1243
|
-
return /* @__PURE__ */ jsx11(AntdTable,
|
|
1274
|
+
return /* @__PURE__ */ jsx11(AntdTable, {
|
|
1275
|
+
...props,
|
|
1244
1276
|
rowKey: props.rowKey || "id",
|
|
1245
1277
|
columns,
|
|
1246
1278
|
dataSource: props.dataSource
|
|
1247
|
-
})
|
|
1248
|
-
return /* @__PURE__ */ jsx11(
|
|
1279
|
+
});
|
|
1280
|
+
return /* @__PURE__ */ jsx11(FaasDataWrapper2, {
|
|
1249
1281
|
fallback: props.faasData.fallback || /* @__PURE__ */ jsx11(Skeleton3, {
|
|
1250
1282
|
active: true
|
|
1251
1283
|
}),
|
|
@@ -1255,50 +1287,59 @@ function Table(props) {
|
|
|
1255
1287
|
reload
|
|
1256
1288
|
}) => {
|
|
1257
1289
|
if (!data)
|
|
1258
|
-
return /* @__PURE__ */ jsx11(AntdTable,
|
|
1290
|
+
return /* @__PURE__ */ jsx11(AntdTable, {
|
|
1291
|
+
...props,
|
|
1259
1292
|
rowKey: props.rowKey || "id",
|
|
1260
1293
|
columns,
|
|
1261
1294
|
dataSource: []
|
|
1262
|
-
})
|
|
1295
|
+
});
|
|
1263
1296
|
if (Array.isArray(data))
|
|
1264
|
-
return /* @__PURE__ */ jsx11(AntdTable,
|
|
1297
|
+
return /* @__PURE__ */ jsx11(AntdTable, {
|
|
1298
|
+
...props,
|
|
1265
1299
|
rowKey: props.rowKey || "id",
|
|
1266
1300
|
columns,
|
|
1267
1301
|
dataSource: data
|
|
1268
|
-
})
|
|
1269
|
-
return /* @__PURE__ */ jsx11(AntdTable,
|
|
1302
|
+
});
|
|
1303
|
+
return /* @__PURE__ */ jsx11(AntdTable, {
|
|
1304
|
+
...props,
|
|
1270
1305
|
rowKey: props.rowKey || "id",
|
|
1271
1306
|
columns,
|
|
1272
1307
|
dataSource: data.rows,
|
|
1273
|
-
pagination:
|
|
1308
|
+
pagination: {
|
|
1309
|
+
...props.pagination,
|
|
1310
|
+
...data.pagination
|
|
1311
|
+
},
|
|
1274
1312
|
onChange: (pagination, filters, sorter, extra) => {
|
|
1275
1313
|
if (props.onChange) {
|
|
1276
1314
|
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
1277
|
-
reload(
|
|
1315
|
+
reload({
|
|
1316
|
+
...params,
|
|
1278
1317
|
pagination: processed.pagination,
|
|
1279
1318
|
filters: processed.filters,
|
|
1280
1319
|
sorter: processed.sorter
|
|
1281
|
-
})
|
|
1320
|
+
});
|
|
1282
1321
|
return;
|
|
1283
1322
|
}
|
|
1284
|
-
reload(
|
|
1323
|
+
reload({
|
|
1324
|
+
...params,
|
|
1285
1325
|
pagination,
|
|
1286
1326
|
filters,
|
|
1287
1327
|
sorter
|
|
1288
|
-
})
|
|
1328
|
+
});
|
|
1289
1329
|
}
|
|
1290
|
-
})
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1330
|
+
});
|
|
1331
|
+
},
|
|
1332
|
+
...props.faasData
|
|
1333
|
+
});
|
|
1293
1334
|
}
|
|
1294
1335
|
|
|
1295
1336
|
// src/Title.tsx
|
|
1296
|
-
import { useEffect as
|
|
1337
|
+
import { useEffect as useEffect6, cloneElement as cloneElement3 } from "react";
|
|
1297
1338
|
import { PageHeader } from "antd";
|
|
1298
1339
|
import { Fragment as Fragment3, jsx as jsx12 } from "react/jsx-runtime";
|
|
1299
1340
|
function Title(props) {
|
|
1300
1341
|
const { Title: Title2 } = useConfigContext();
|
|
1301
|
-
|
|
1342
|
+
useEffect6(() => {
|
|
1302
1343
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1303
1344
|
document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
|
|
1304
1345
|
}, [props]);
|
|
@@ -1318,9 +1359,10 @@ function Title(props) {
|
|
|
1318
1359
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1319
1360
|
});
|
|
1320
1361
|
if (props.header)
|
|
1321
|
-
return /* @__PURE__ */ jsx12(PageHeader,
|
|
1322
|
-
title: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1323
|
-
|
|
1362
|
+
return /* @__PURE__ */ jsx12(PageHeader, {
|
|
1363
|
+
title: Array.isArray(props.title) ? props.title[0] : props.title,
|
|
1364
|
+
...props.header
|
|
1365
|
+
});
|
|
1324
1366
|
if (props.children)
|
|
1325
1367
|
return cloneElement3(props.children, { title: props.title });
|
|
1326
1368
|
return null;
|