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