@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.d.ts +84 -47
- package/dist/index.js +205 -249
- package/dist/index.mjs +207 -244
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
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
|
+
|
|
1
21
|
// react-shim.js
|
|
2
22
|
import React from "react";
|
|
3
23
|
|
|
@@ -72,10 +92,9 @@ function ConfigProvider({
|
|
|
72
92
|
}, []);
|
|
73
93
|
return /* @__PURE__ */ jsx(ConfigContext.Provider, {
|
|
74
94
|
value: values,
|
|
75
|
-
children: /* @__PURE__ */ jsx(AntdConfigProvider, {
|
|
76
|
-
...config.antd,
|
|
95
|
+
children: /* @__PURE__ */ jsx(AntdConfigProvider, __spreadProps(__spreadValues({}, config.antd), {
|
|
77
96
|
children
|
|
78
|
-
})
|
|
97
|
+
}))
|
|
79
98
|
});
|
|
80
99
|
}
|
|
81
100
|
function useConfigContext() {
|
|
@@ -141,17 +160,46 @@ import {
|
|
|
141
160
|
import { isFunction, upperFirst as upperFirst2 } from "lodash";
|
|
142
161
|
import {
|
|
143
162
|
cloneElement,
|
|
163
|
+
useEffect as useEffect3,
|
|
164
|
+
useState as useState3
|
|
165
|
+
} from "react";
|
|
166
|
+
|
|
167
|
+
// ../react/src/index.tsx
|
|
168
|
+
import {
|
|
169
|
+
useState as useState2,
|
|
144
170
|
useEffect as useEffect2,
|
|
145
|
-
|
|
171
|
+
createElement
|
|
146
172
|
} from "react";
|
|
147
|
-
|
|
173
|
+
var clients = {};
|
|
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
|
|
148
196
|
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
|
149
197
|
function DescriptionItemContent(props) {
|
|
150
198
|
var _a;
|
|
151
|
-
const [computedProps, setComputedProps] =
|
|
152
|
-
|
|
199
|
+
const [computedProps, setComputedProps] = useState3();
|
|
200
|
+
useEffect3(() => {
|
|
153
201
|
var _a2, _b;
|
|
154
|
-
const propsCopy = {
|
|
202
|
+
const propsCopy = __spreadValues({}, props);
|
|
155
203
|
if (!propsCopy.item.title)
|
|
156
204
|
propsCopy.item.title = upperFirst2(propsCopy.item.id);
|
|
157
205
|
if (!propsCopy.item.type)
|
|
@@ -254,8 +302,7 @@ function DescriptionItemContent(props) {
|
|
|
254
302
|
}
|
|
255
303
|
function Description(props) {
|
|
256
304
|
if (!props.faasData)
|
|
257
|
-
return /* @__PURE__ */ jsx3(Descriptions, {
|
|
258
|
-
...props,
|
|
305
|
+
return /* @__PURE__ */ jsx3(Descriptions, __spreadProps(__spreadValues({}, props), {
|
|
259
306
|
title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
260
307
|
children: props.items.map((item) => {
|
|
261
308
|
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
|
|
@@ -268,14 +315,13 @@ function Description(props) {
|
|
|
268
315
|
})
|
|
269
316
|
}, item.id) : null;
|
|
270
317
|
}).filter(Boolean)
|
|
271
|
-
});
|
|
272
|
-
return /* @__PURE__ */ jsx3(FaasDataWrapper, {
|
|
318
|
+
}));
|
|
319
|
+
return /* @__PURE__ */ jsx3(FaasDataWrapper, __spreadValues({
|
|
273
320
|
fallback: props.faasData.fallback || /* @__PURE__ */ jsx3(Skeleton, {
|
|
274
321
|
active: true
|
|
275
322
|
}),
|
|
276
323
|
render: ({ data }) => {
|
|
277
|
-
return /* @__PURE__ */ jsx3(Descriptions, {
|
|
278
|
-
...props,
|
|
324
|
+
return /* @__PURE__ */ jsx3(Descriptions, __spreadProps(__spreadValues({}, props), {
|
|
279
325
|
title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
280
326
|
children: props.items.map((item) => {
|
|
281
327
|
return !item.if || item.if(data) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
|
|
@@ -288,48 +334,39 @@ function Description(props) {
|
|
|
288
334
|
})
|
|
289
335
|
}, item.id) : null;
|
|
290
336
|
}).filter(Boolean)
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
});
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
}, props.faasData));
|
|
295
340
|
}
|
|
296
341
|
|
|
297
342
|
// src/Drawer.tsx
|
|
298
343
|
import { Drawer } from "antd";
|
|
299
|
-
import { useState as
|
|
344
|
+
import { useState as useState4 } from "react";
|
|
300
345
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
301
346
|
function useDrawer(init) {
|
|
302
|
-
const [props, setProps] =
|
|
347
|
+
const [props, setProps] = useState4(__spreadValues({
|
|
303
348
|
open: false,
|
|
304
|
-
onClose: () => setProps((prev) => ({
|
|
305
|
-
...prev,
|
|
349
|
+
onClose: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
306
350
|
open: false
|
|
307
|
-
}))
|
|
308
|
-
|
|
309
|
-
});
|
|
351
|
+
}))
|
|
352
|
+
}, init));
|
|
310
353
|
return {
|
|
311
|
-
drawer: /* @__PURE__ */ jsx4(Drawer, {
|
|
312
|
-
...props
|
|
313
|
-
}),
|
|
354
|
+
drawer: /* @__PURE__ */ jsx4(Drawer, __spreadValues({}, props)),
|
|
314
355
|
drawerProps: props,
|
|
315
356
|
setDrawerProps(changes) {
|
|
316
|
-
setProps((prev) => ({
|
|
317
|
-
...prev,
|
|
318
|
-
...changes
|
|
319
|
-
}));
|
|
357
|
+
setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
|
|
320
358
|
}
|
|
321
359
|
};
|
|
322
360
|
}
|
|
323
361
|
|
|
324
362
|
// src/Form.tsx
|
|
325
|
-
import { faas } from "@faasjs/react";
|
|
326
363
|
import {
|
|
327
364
|
Button as Button2,
|
|
328
365
|
Form as AntdForm2
|
|
329
366
|
} from "antd";
|
|
330
367
|
import {
|
|
331
|
-
useEffect as
|
|
332
|
-
useState as
|
|
368
|
+
useEffect as useEffect5,
|
|
369
|
+
useState as useState6,
|
|
333
370
|
useCallback
|
|
334
371
|
} from "react";
|
|
335
372
|
|
|
@@ -346,8 +383,8 @@ import {
|
|
|
346
383
|
} from "antd";
|
|
347
384
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
348
385
|
import {
|
|
349
|
-
useEffect as
|
|
350
|
-
useState as
|
|
386
|
+
useEffect as useEffect4,
|
|
387
|
+
useState as useState5
|
|
351
388
|
} from "react";
|
|
352
389
|
import { upperFirst as upperFirst3 } from "lodash";
|
|
353
390
|
|
|
@@ -355,12 +392,11 @@ import { upperFirst as upperFirst3 } from "lodash";
|
|
|
355
392
|
import { forwardRef } from "react";
|
|
356
393
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
357
394
|
var TimePicker = forwardRef((props, ref) => {
|
|
358
|
-
return /* @__PURE__ */ jsx5(DatePicker, {
|
|
359
|
-
...props,
|
|
395
|
+
return /* @__PURE__ */ jsx5(DatePicker, __spreadProps(__spreadValues({}, props), {
|
|
360
396
|
picker: "time",
|
|
361
397
|
mode: void 0,
|
|
362
398
|
ref
|
|
363
|
-
});
|
|
399
|
+
}));
|
|
364
400
|
});
|
|
365
401
|
TimePicker.displayName = "TimePicker";
|
|
366
402
|
|
|
@@ -414,53 +450,60 @@ function processProps(propsCopy, config) {
|
|
|
414
450
|
}
|
|
415
451
|
function FormItem(props) {
|
|
416
452
|
var _a;
|
|
417
|
-
const [computedProps, setComputedProps] =
|
|
418
|
-
const [extendTypes, setExtendTypes] =
|
|
453
|
+
const [computedProps, setComputedProps] = useState5();
|
|
454
|
+
const [extendTypes, setExtendTypes] = useState5();
|
|
419
455
|
const config = useConfigContext();
|
|
420
|
-
|
|
421
|
-
|
|
456
|
+
const [hidden, setHidden] = useState5(false);
|
|
457
|
+
useEffect4(() => {
|
|
458
|
+
const propsCopy = __spreadValues({}, props);
|
|
422
459
|
if (propsCopy.extendTypes) {
|
|
423
460
|
setExtendTypes(propsCopy.extendTypes);
|
|
424
461
|
delete propsCopy.extendTypes;
|
|
425
462
|
}
|
|
463
|
+
if (propsCopy.if) {
|
|
464
|
+
const condition = propsCopy.if;
|
|
465
|
+
propsCopy.shouldUpdate = (_, cur) => {
|
|
466
|
+
const show = condition(cur);
|
|
467
|
+
setHidden(!show);
|
|
468
|
+
return show;
|
|
469
|
+
};
|
|
470
|
+
delete propsCopy.if;
|
|
471
|
+
}
|
|
426
472
|
setComputedProps(processProps(propsCopy, config));
|
|
427
473
|
}, [props]);
|
|
428
474
|
if (!computedProps)
|
|
429
475
|
return null;
|
|
476
|
+
if (hidden)
|
|
477
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
478
|
+
noStyle: true,
|
|
479
|
+
children: /* @__PURE__ */ jsx6(Input, {
|
|
480
|
+
hidden: true
|
|
481
|
+
})
|
|
482
|
+
}));
|
|
430
483
|
if (extendTypes && extendTypes[computedProps.type])
|
|
431
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
432
|
-
...computedProps,
|
|
484
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
433
485
|
children: extendTypes[computedProps.type].children
|
|
434
|
-
});
|
|
486
|
+
}));
|
|
435
487
|
if (computedProps.children)
|
|
436
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
437
|
-
...computedProps,
|
|
488
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
438
489
|
children: computedProps.children
|
|
439
|
-
});
|
|
490
|
+
}));
|
|
440
491
|
if (computedProps.render)
|
|
441
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
442
|
-
...computedProps,
|
|
492
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
443
493
|
children: computedProps.render()
|
|
444
|
-
});
|
|
494
|
+
}));
|
|
445
495
|
switch (computedProps.type) {
|
|
446
496
|
case "string":
|
|
447
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
...computedProps.input
|
|
451
|
-
}) : /* @__PURE__ */ jsx6(Input, {
|
|
452
|
-
...computedProps.input
|
|
453
|
-
})
|
|
454
|
-
});
|
|
497
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
498
|
+
children: computedProps.options ? /* @__PURE__ */ jsx6(Select, __spreadValues({}, computedProps.input)) : /* @__PURE__ */ jsx6(Input, __spreadValues({}, computedProps.input))
|
|
499
|
+
}));
|
|
455
500
|
case "string[]":
|
|
456
501
|
if (computedProps.options)
|
|
457
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
})
|
|
463
|
-
});
|
|
502
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
503
|
+
children: /* @__PURE__ */ jsx6(Select, __spreadValues({
|
|
504
|
+
mode: "multiple"
|
|
505
|
+
}, computedProps.input))
|
|
506
|
+
}));
|
|
464
507
|
return /* @__PURE__ */ jsx6(AntdForm.List, {
|
|
465
508
|
name: computedProps.name,
|
|
466
509
|
rules: computedProps.rules,
|
|
@@ -484,13 +527,10 @@ function FormItem(props) {
|
|
|
484
527
|
children: [
|
|
485
528
|
/* @__PURE__ */ jsx6(Col, {
|
|
486
529
|
span: 23,
|
|
487
|
-
children: /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
488
|
-
...field,
|
|
530
|
+
children: /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, field), {
|
|
489
531
|
noStyle: true,
|
|
490
|
-
children: /* @__PURE__ */ jsx6(Input, {
|
|
491
|
-
|
|
492
|
-
})
|
|
493
|
-
})
|
|
532
|
+
children: /* @__PURE__ */ jsx6(Input, __spreadValues({}, computedProps.input))
|
|
533
|
+
}))
|
|
494
534
|
}),
|
|
495
535
|
/* @__PURE__ */ jsx6(Col, {
|
|
496
536
|
span: 1,
|
|
@@ -524,24 +564,18 @@ function FormItem(props) {
|
|
|
524
564
|
}
|
|
525
565
|
});
|
|
526
566
|
case "number":
|
|
527
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
style: { width: "100%" },
|
|
533
|
-
...computedProps.input
|
|
534
|
-
})
|
|
535
|
-
});
|
|
567
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
568
|
+
children: computedProps.options ? /* @__PURE__ */ jsx6(Select, __spreadValues({}, computedProps.input)) : /* @__PURE__ */ jsx6(InputNumber, __spreadValues({
|
|
569
|
+
style: { width: "100%" }
|
|
570
|
+
}, computedProps.input))
|
|
571
|
+
}));
|
|
536
572
|
case "number[]":
|
|
537
573
|
if (computedProps.options)
|
|
538
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
})
|
|
544
|
-
});
|
|
574
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
575
|
+
children: /* @__PURE__ */ jsx6(Select, __spreadValues({
|
|
576
|
+
mode: "multiple"
|
|
577
|
+
}, computedProps.input))
|
|
578
|
+
}));
|
|
545
579
|
return /* @__PURE__ */ jsx6(AntdForm.List, {
|
|
546
580
|
name: computedProps.name,
|
|
547
581
|
rules: computedProps.rules,
|
|
@@ -565,14 +599,12 @@ function FormItem(props) {
|
|
|
565
599
|
children: [
|
|
566
600
|
/* @__PURE__ */ jsx6(Col, {
|
|
567
601
|
span: 23,
|
|
568
|
-
children: /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
569
|
-
...field,
|
|
602
|
+
children: /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, field), {
|
|
570
603
|
noStyle: true,
|
|
571
|
-
children: /* @__PURE__ */ jsx6(InputNumber, {
|
|
572
|
-
style: { width: "100%" }
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
})
|
|
604
|
+
children: /* @__PURE__ */ jsx6(InputNumber, __spreadValues({
|
|
605
|
+
style: { width: "100%" }
|
|
606
|
+
}, computedProps.input))
|
|
607
|
+
}))
|
|
576
608
|
}),
|
|
577
609
|
/* @__PURE__ */ jsx6(Col, {
|
|
578
610
|
span: 1,
|
|
@@ -606,26 +638,17 @@ function FormItem(props) {
|
|
|
606
638
|
}
|
|
607
639
|
});
|
|
608
640
|
case "boolean":
|
|
609
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
...computedProps.input
|
|
613
|
-
})
|
|
614
|
-
});
|
|
641
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
642
|
+
children: /* @__PURE__ */ jsx6(Switch, __spreadValues({}, computedProps.input))
|
|
643
|
+
}));
|
|
615
644
|
case "date":
|
|
616
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
...computedProps.input
|
|
620
|
-
})
|
|
621
|
-
});
|
|
645
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
646
|
+
children: /* @__PURE__ */ jsx6(DatePicker, __spreadValues({}, computedProps.input))
|
|
647
|
+
}));
|
|
622
648
|
case "time":
|
|
623
|
-
return /* @__PURE__ */ jsx6(AntdForm.Item, {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
...computedProps.input
|
|
627
|
-
})
|
|
628
|
-
});
|
|
649
|
+
return /* @__PURE__ */ jsx6(AntdForm.Item, __spreadProps(__spreadValues({}, computedProps), {
|
|
650
|
+
children: /* @__PURE__ */ jsx6(TimePicker, __spreadValues({}, computedProps.input))
|
|
651
|
+
}));
|
|
629
652
|
case "object":
|
|
630
653
|
return /* @__PURE__ */ jsxs(Fragment2, {
|
|
631
654
|
children: [
|
|
@@ -636,9 +659,7 @@ function FormItem(props) {
|
|
|
636
659
|
children: computedProps.label
|
|
637
660
|
})
|
|
638
661
|
}),
|
|
639
|
-
computedProps.object.map((o) => /* @__PURE__ */ jsx6(FormItem, {
|
|
640
|
-
...o
|
|
641
|
-
}, o.id))
|
|
662
|
+
computedProps.object.map((o) => /* @__PURE__ */ jsx6(FormItem, __spreadValues({}, o), o.id))
|
|
642
663
|
]
|
|
643
664
|
});
|
|
644
665
|
case "object[]":
|
|
@@ -670,10 +691,9 @@ function FormItem(props) {
|
|
|
670
691
|
gutter: 24,
|
|
671
692
|
children: computedProps.object.map((o) => /* @__PURE__ */ jsx6(Col, {
|
|
672
693
|
span: o.col || 24,
|
|
673
|
-
children: /* @__PURE__ */ jsx6(FormItem, {
|
|
674
|
-
...o,
|
|
694
|
+
children: /* @__PURE__ */ jsx6(FormItem, __spreadProps(__spreadValues({}, o), {
|
|
675
695
|
name: [field.name, o.id]
|
|
676
|
-
})
|
|
696
|
+
}))
|
|
677
697
|
}, o.id))
|
|
678
698
|
})
|
|
679
699
|
]
|
|
@@ -708,36 +728,33 @@ function FormItem(props) {
|
|
|
708
728
|
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
709
729
|
function Form(props) {
|
|
710
730
|
var _a, _b;
|
|
711
|
-
const [loading, setLoading] =
|
|
712
|
-
const [computedProps, setComputedProps] =
|
|
731
|
+
const [loading, setLoading] = useState6(false);
|
|
732
|
+
const [computedProps, setComputedProps] = useState6();
|
|
713
733
|
const config = useConfigContext();
|
|
714
|
-
const [extendTypes, setExtendTypes] =
|
|
734
|
+
const [extendTypes, setExtendTypes] = useState6();
|
|
715
735
|
const [form] = AntdForm2.useForm(props.form);
|
|
716
|
-
|
|
736
|
+
const [initialValues, setInitialValues] = useState6(props.initialValues);
|
|
737
|
+
useEffect5(() => {
|
|
717
738
|
var _a2, _b2;
|
|
718
|
-
const propsCopy = {
|
|
719
|
-
...props,
|
|
720
|
-
items: (props.items || []).filter((it) => {
|
|
721
|
-
return !it.if || it.if(props.initialValues || {});
|
|
722
|
-
}),
|
|
739
|
+
const propsCopy = __spreadProps(__spreadValues({}, props), {
|
|
723
740
|
form
|
|
724
|
-
};
|
|
725
|
-
if (propsCopy.initialValues)
|
|
741
|
+
});
|
|
742
|
+
if (propsCopy.initialValues) {
|
|
726
743
|
for (const key in propsCopy.initialValues)
|
|
727
744
|
propsCopy.initialValues[key] = transferValue(
|
|
728
745
|
(_a2 = propsCopy.items.find((item) => item.id === key)) == null ? void 0 : _a2.type,
|
|
729
746
|
propsCopy.initialValues[key]
|
|
730
747
|
);
|
|
748
|
+
setInitialValues(propsCopy.initialValues);
|
|
749
|
+
delete propsCopy.initialValues;
|
|
750
|
+
}
|
|
731
751
|
if (propsCopy.onFinish) {
|
|
732
752
|
propsCopy.onFinish = async (values) => {
|
|
733
753
|
var _a3;
|
|
734
754
|
setLoading(true);
|
|
735
755
|
try {
|
|
736
756
|
if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
|
|
737
|
-
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
738
|
-
...values2,
|
|
739
|
-
...propsCopy.submit.to.params
|
|
740
|
-
} : values2));
|
|
757
|
+
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? __spreadValues(__spreadValues({}, values2), propsCopy.submit.to.params) : values2));
|
|
741
758
|
} else
|
|
742
759
|
await props.onFinish(values);
|
|
743
760
|
} catch (error) {
|
|
@@ -748,10 +765,7 @@ function Form(props) {
|
|
|
748
765
|
} else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
|
|
749
766
|
propsCopy.onFinish = async (values) => {
|
|
750
767
|
setLoading(true);
|
|
751
|
-
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
752
|
-
...values,
|
|
753
|
-
...propsCopy.submit.to.params
|
|
754
|
-
} : values).finally(() => setLoading(false));
|
|
768
|
+
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? __spreadValues(__spreadValues({}, values), propsCopy.submit.to.params) : values).finally(() => setLoading(false));
|
|
755
769
|
};
|
|
756
770
|
}
|
|
757
771
|
if (propsCopy.extendTypes) {
|
|
@@ -771,39 +785,22 @@ function Form(props) {
|
|
|
771
785
|
if (item == null ? void 0 : item.onValueChange)
|
|
772
786
|
item.onValueChange(changedValues[key], allValues, form);
|
|
773
787
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
props.form.setFields([
|
|
781
|
-
{
|
|
782
|
-
name: it.id,
|
|
783
|
-
errors: null
|
|
784
|
-
}
|
|
785
|
-
]);
|
|
786
|
-
}
|
|
787
|
-
return show;
|
|
788
|
-
});
|
|
789
|
-
if (computedProps.items.length !== filterItems.length || computedProps.items.some((it, i) => it !== filterItems[i])) {
|
|
790
|
-
setComputedProps({
|
|
791
|
-
...computedProps,
|
|
792
|
-
items: filterItems
|
|
793
|
-
});
|
|
794
|
-
}
|
|
788
|
+
}, [computedProps]);
|
|
789
|
+
useEffect5(() => {
|
|
790
|
+
if (!initialValues)
|
|
791
|
+
return;
|
|
792
|
+
form.setFieldsValue(initialValues);
|
|
793
|
+
setInitialValues(null);
|
|
795
794
|
}, [computedProps]);
|
|
796
795
|
if (!computedProps)
|
|
797
796
|
return null;
|
|
798
|
-
return /* @__PURE__ */ jsxs2(AntdForm2, {
|
|
799
|
-
...computedProps,
|
|
797
|
+
return /* @__PURE__ */ jsxs2(AntdForm2, __spreadProps(__spreadValues({}, computedProps), {
|
|
800
798
|
onValuesChange,
|
|
801
799
|
children: [
|
|
802
800
|
computedProps.beforeItems,
|
|
803
|
-
(_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsx7(FormItem, {
|
|
804
|
-
...item,
|
|
801
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsx7(FormItem, __spreadProps(__spreadValues({}, item), {
|
|
805
802
|
extendTypes
|
|
806
|
-
}, item.id)),
|
|
803
|
+
}), item.id)),
|
|
807
804
|
computedProps.children,
|
|
808
805
|
computedProps.submit !== false && /* @__PURE__ */ jsx7(Button2, {
|
|
809
806
|
htmlType: "submit",
|
|
@@ -813,7 +810,7 @@ function Form(props) {
|
|
|
813
810
|
}),
|
|
814
811
|
computedProps.footer
|
|
815
812
|
]
|
|
816
|
-
});
|
|
813
|
+
}));
|
|
817
814
|
}
|
|
818
815
|
Form.useForm = AntdForm2.useForm;
|
|
819
816
|
|
|
@@ -833,75 +830,54 @@ function Link({
|
|
|
833
830
|
style = Object.assign({ cursor: "pointer" }, style);
|
|
834
831
|
if (href.startsWith("http")) {
|
|
835
832
|
if (button)
|
|
836
|
-
return /* @__PURE__ */ jsx8(Button3, {
|
|
837
|
-
...button,
|
|
833
|
+
return /* @__PURE__ */ jsx8(Button3, __spreadProps(__spreadValues({}, button), {
|
|
838
834
|
children: /* @__PURE__ */ jsx8("a", {
|
|
839
835
|
href,
|
|
840
836
|
target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
841
|
-
style: {
|
|
842
|
-
...Link2.style,
|
|
843
|
-
...style || {}
|
|
844
|
-
},
|
|
837
|
+
style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
|
|
845
838
|
children: text || children
|
|
846
839
|
})
|
|
847
|
-
});
|
|
840
|
+
}));
|
|
848
841
|
return /* @__PURE__ */ jsx8("a", {
|
|
849
842
|
href,
|
|
850
843
|
target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
851
|
-
style: {
|
|
852
|
-
...Link2.style,
|
|
853
|
-
...style || {}
|
|
854
|
-
},
|
|
844
|
+
style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
|
|
855
845
|
children: text || children
|
|
856
846
|
});
|
|
857
847
|
}
|
|
858
848
|
if (button)
|
|
859
|
-
return /* @__PURE__ */ jsx8(Button3, {
|
|
860
|
-
...button,
|
|
849
|
+
return /* @__PURE__ */ jsx8(Button3, __spreadProps(__spreadValues({}, button), {
|
|
861
850
|
children: /* @__PURE__ */ jsx8(RouterLink, {
|
|
862
851
|
to: href,
|
|
863
852
|
target: target || (Link2 == null ? void 0 : Link2.target),
|
|
864
|
-
style: {
|
|
865
|
-
...Link2.style,
|
|
866
|
-
...style || {}
|
|
867
|
-
},
|
|
853
|
+
style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
|
|
868
854
|
children: text || children
|
|
869
855
|
})
|
|
870
|
-
});
|
|
856
|
+
}));
|
|
871
857
|
return /* @__PURE__ */ jsx8(RouterLink, {
|
|
872
858
|
to: href,
|
|
873
859
|
target: target || (Link2 == null ? void 0 : Link2.target),
|
|
874
|
-
style: {
|
|
875
|
-
...Link2.style,
|
|
876
|
-
...style || {}
|
|
877
|
-
},
|
|
860
|
+
style: __spreadValues(__spreadValues({}, Link2.style), style || {}),
|
|
878
861
|
children: text || children
|
|
879
862
|
});
|
|
880
863
|
}
|
|
881
864
|
|
|
882
865
|
// src/Modal.tsx
|
|
883
866
|
import { Modal } from "antd";
|
|
884
|
-
import { useState as
|
|
867
|
+
import { useState as useState7 } from "react";
|
|
885
868
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
886
869
|
function useModal(init) {
|
|
887
|
-
const [props, setProps] =
|
|
870
|
+
const [props, setProps] = useState7(__spreadValues({
|
|
888
871
|
open: false,
|
|
889
|
-
onCancel: () => setProps((prev) => ({
|
|
890
|
-
...prev,
|
|
872
|
+
onCancel: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
891
873
|
open: false
|
|
892
|
-
}))
|
|
893
|
-
|
|
894
|
-
});
|
|
874
|
+
}))
|
|
875
|
+
}, init));
|
|
895
876
|
return {
|
|
896
|
-
modal: /* @__PURE__ */ jsx9(Modal, {
|
|
897
|
-
...props
|
|
898
|
-
}),
|
|
877
|
+
modal: /* @__PURE__ */ jsx9(Modal, __spreadValues({}, props)),
|
|
899
878
|
modalProps: props,
|
|
900
879
|
setModalProps(changes) {
|
|
901
|
-
setProps((prev) => ({
|
|
902
|
-
...prev,
|
|
903
|
-
...changes
|
|
904
|
-
}));
|
|
880
|
+
setProps((prev) => __spreadValues(__spreadValues({}, prev), changes));
|
|
905
881
|
}
|
|
906
882
|
};
|
|
907
883
|
}
|
|
@@ -926,8 +902,7 @@ function PageNotFound() {
|
|
|
926
902
|
function Routes(props) {
|
|
927
903
|
return /* @__PURE__ */ jsxs3(OriginRoutes, {
|
|
928
904
|
children: [
|
|
929
|
-
props.routes.map((r) => /* @__PURE__ */ jsx10(Route, {
|
|
930
|
-
...r,
|
|
905
|
+
props.routes.map((r) => /* @__PURE__ */ jsx10(Route, __spreadProps(__spreadValues({}, r), {
|
|
931
906
|
element: r.element || /* @__PURE__ */ jsx10(Suspense, {
|
|
932
907
|
fallback: props.fallback || /* @__PURE__ */ jsx10("div", {
|
|
933
908
|
style: { padding: "24px" },
|
|
@@ -937,7 +912,7 @@ function Routes(props) {
|
|
|
937
912
|
}),
|
|
938
913
|
children: /* @__PURE__ */ jsx10(r.page, {})
|
|
939
914
|
})
|
|
940
|
-
}, r.path)),
|
|
915
|
+
}), r.path)),
|
|
941
916
|
/* @__PURE__ */ jsx10(Route, {
|
|
942
917
|
path: "*",
|
|
943
918
|
element: props.notFound || /* @__PURE__ */ jsx10(PageNotFound, {})
|
|
@@ -948,8 +923,8 @@ function Routes(props) {
|
|
|
948
923
|
|
|
949
924
|
// src/Table.tsx
|
|
950
925
|
import {
|
|
951
|
-
useState as
|
|
952
|
-
useEffect as
|
|
926
|
+
useState as useState8,
|
|
927
|
+
useEffect as useEffect6,
|
|
953
928
|
cloneElement as cloneElement2
|
|
954
929
|
} from "react";
|
|
955
930
|
import {
|
|
@@ -965,7 +940,6 @@ import {
|
|
|
965
940
|
uniqBy,
|
|
966
941
|
upperFirst as upperFirst4
|
|
967
942
|
} from "lodash";
|
|
968
|
-
import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
969
943
|
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
970
944
|
function processValue(item, value) {
|
|
971
945
|
var _a;
|
|
@@ -992,9 +966,9 @@ function processValue(item, value) {
|
|
|
992
966
|
return value;
|
|
993
967
|
}
|
|
994
968
|
function Table(props) {
|
|
995
|
-
const [columns, setColumns] =
|
|
969
|
+
const [columns, setColumns] = useState8();
|
|
996
970
|
const { common: common2 } = useConfigContext();
|
|
997
|
-
|
|
971
|
+
useEffect6(() => {
|
|
998
972
|
var _a;
|
|
999
973
|
for (const item of props.items) {
|
|
1000
974
|
if (!item.key)
|
|
@@ -1246,7 +1220,7 @@ function Table(props) {
|
|
|
1246
1220
|
}
|
|
1247
1221
|
setColumns(props.items);
|
|
1248
1222
|
}, [props.items]);
|
|
1249
|
-
|
|
1223
|
+
useEffect6(() => {
|
|
1250
1224
|
if (!props.dataSource || !columns)
|
|
1251
1225
|
return;
|
|
1252
1226
|
for (const column of columns) {
|
|
@@ -1266,13 +1240,12 @@ function Table(props) {
|
|
|
1266
1240
|
if (!columns)
|
|
1267
1241
|
return null;
|
|
1268
1242
|
if (!props.faasData)
|
|
1269
|
-
return /* @__PURE__ */ jsx11(AntdTable, {
|
|
1270
|
-
...props,
|
|
1243
|
+
return /* @__PURE__ */ jsx11(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
1271
1244
|
rowKey: props.rowKey || "id",
|
|
1272
1245
|
columns,
|
|
1273
1246
|
dataSource: props.dataSource
|
|
1274
|
-
});
|
|
1275
|
-
return /* @__PURE__ */ jsx11(
|
|
1247
|
+
}));
|
|
1248
|
+
return /* @__PURE__ */ jsx11(FaasDataWrapper, __spreadValues({
|
|
1276
1249
|
fallback: props.faasData.fallback || /* @__PURE__ */ jsx11(Skeleton3, {
|
|
1277
1250
|
active: true
|
|
1278
1251
|
}),
|
|
@@ -1282,59 +1255,50 @@ function Table(props) {
|
|
|
1282
1255
|
reload
|
|
1283
1256
|
}) => {
|
|
1284
1257
|
if (!data)
|
|
1285
|
-
return /* @__PURE__ */ jsx11(AntdTable, {
|
|
1286
|
-
...props,
|
|
1258
|
+
return /* @__PURE__ */ jsx11(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
1287
1259
|
rowKey: props.rowKey || "id",
|
|
1288
1260
|
columns,
|
|
1289
1261
|
dataSource: []
|
|
1290
|
-
});
|
|
1262
|
+
}));
|
|
1291
1263
|
if (Array.isArray(data))
|
|
1292
|
-
return /* @__PURE__ */ jsx11(AntdTable, {
|
|
1293
|
-
...props,
|
|
1264
|
+
return /* @__PURE__ */ jsx11(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
1294
1265
|
rowKey: props.rowKey || "id",
|
|
1295
1266
|
columns,
|
|
1296
1267
|
dataSource: data
|
|
1297
|
-
});
|
|
1298
|
-
return /* @__PURE__ */ jsx11(AntdTable, {
|
|
1299
|
-
...props,
|
|
1268
|
+
}));
|
|
1269
|
+
return /* @__PURE__ */ jsx11(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
1300
1270
|
rowKey: props.rowKey || "id",
|
|
1301
1271
|
columns,
|
|
1302
1272
|
dataSource: data.rows,
|
|
1303
|
-
pagination: {
|
|
1304
|
-
...props.pagination,
|
|
1305
|
-
...data.pagination
|
|
1306
|
-
},
|
|
1273
|
+
pagination: __spreadValues(__spreadValues({}, props.pagination), data.pagination),
|
|
1307
1274
|
onChange: (pagination, filters, sorter, extra) => {
|
|
1308
1275
|
if (props.onChange) {
|
|
1309
1276
|
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
1310
|
-
reload({
|
|
1311
|
-
...params,
|
|
1277
|
+
reload(__spreadProps(__spreadValues({}, params), {
|
|
1312
1278
|
pagination: processed.pagination,
|
|
1313
1279
|
filters: processed.filters,
|
|
1314
1280
|
sorter: processed.sorter
|
|
1315
|
-
});
|
|
1281
|
+
}));
|
|
1316
1282
|
return;
|
|
1317
1283
|
}
|
|
1318
|
-
reload({
|
|
1319
|
-
...params,
|
|
1284
|
+
reload(__spreadProps(__spreadValues({}, params), {
|
|
1320
1285
|
pagination,
|
|
1321
1286
|
filters,
|
|
1322
1287
|
sorter
|
|
1323
|
-
});
|
|
1288
|
+
}));
|
|
1324
1289
|
}
|
|
1325
|
-
});
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
});
|
|
1290
|
+
}));
|
|
1291
|
+
}
|
|
1292
|
+
}, props.faasData));
|
|
1329
1293
|
}
|
|
1330
1294
|
|
|
1331
1295
|
// src/Title.tsx
|
|
1332
|
-
import { useEffect as
|
|
1296
|
+
import { useEffect as useEffect7, cloneElement as cloneElement3 } from "react";
|
|
1333
1297
|
import { PageHeader } from "antd";
|
|
1334
1298
|
import { Fragment as Fragment3, jsx as jsx12 } from "react/jsx-runtime";
|
|
1335
1299
|
function Title(props) {
|
|
1336
1300
|
const { Title: Title2 } = useConfigContext();
|
|
1337
|
-
|
|
1301
|
+
useEffect7(() => {
|
|
1338
1302
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1339
1303
|
document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
|
|
1340
1304
|
}, [props]);
|
|
@@ -1354,10 +1318,9 @@ function Title(props) {
|
|
|
1354
1318
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1355
1319
|
});
|
|
1356
1320
|
if (props.header)
|
|
1357
|
-
return /* @__PURE__ */ jsx12(PageHeader, {
|
|
1358
|
-
title: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1359
|
-
|
|
1360
|
-
});
|
|
1321
|
+
return /* @__PURE__ */ jsx12(PageHeader, __spreadValues({
|
|
1322
|
+
title: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1323
|
+
}, props.header));
|
|
1361
1324
|
if (props.children)
|
|
1362
1325
|
return cloneElement3(props.children, { title: props.title });
|
|
1363
1326
|
return null;
|