@faasjs/ant-design 0.0.2-development → 0.0.3-beta.2

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.mjs ADDED
@@ -0,0 +1,1360 @@
1
+ // react-shim.js
2
+ import React from "react";
3
+
4
+ // src/Blank.tsx
5
+ import { Typography } from "antd";
6
+ import { isNil } from "lodash-es";
7
+
8
+ // src/Config.tsx
9
+ import {
10
+ createContext,
11
+ useContext,
12
+ useEffect,
13
+ useState
14
+ } from "react";
15
+ import { ConfigProvider as AntdConfigProvider } from "antd";
16
+ import { defaultsDeep } from "lodash-es";
17
+ import { jsx } from "react/jsx-runtime";
18
+ var isZH = /^zh/i.test(navigator.language);
19
+ var zh = {
20
+ lang: "zh",
21
+ blank: "\u7A7A",
22
+ all: "\u5168\u90E8",
23
+ submit: "\u63D0\u4EA4",
24
+ pageNotFound: "\u9875\u9762\u672A\u627E\u5230",
25
+ add: "\u6DFB\u52A0",
26
+ delete: "\u5220\u9664",
27
+ required: "\u5FC5\u586B",
28
+ search: "\u641C\u7D22",
29
+ reset: "\u91CD\u7F6E"
30
+ };
31
+ var en = {
32
+ lang: "en",
33
+ blank: "Empty",
34
+ all: "All",
35
+ submit: "Submit",
36
+ pageNotFound: "Page Not Found",
37
+ add: "Add",
38
+ delete: "Delete",
39
+ required: "is required",
40
+ search: "Search",
41
+ reset: "Reset"
42
+ };
43
+ var common = isZH ? zh : en;
44
+ var baseConfig = {
45
+ antd: {},
46
+ lang: "en",
47
+ common,
48
+ Blank: { text: common.blank },
49
+ Form: { submit: { text: common.submit } },
50
+ Title: {
51
+ separator: " - ",
52
+ suffix: ""
53
+ },
54
+ Link: { style: {} }
55
+ };
56
+ var ConfigContext = createContext(baseConfig);
57
+ function ConfigProvider({
58
+ config,
59
+ children
60
+ }) {
61
+ const [values, setValues] = useState(baseConfig);
62
+ useEffect(() => {
63
+ if (config.lang === "zh") {
64
+ setValues(defaultsDeep(config, {
65
+ lang: "zh",
66
+ common: zh,
67
+ Blank: { text: zh.blank },
68
+ Form: { submit: { text: zh.submit } }
69
+ }, baseConfig));
70
+ } else
71
+ setValues(values);
72
+ }, []);
73
+ return /* @__PURE__ */ jsx(ConfigContext.Provider, {
74
+ value: values,
75
+ children: /* @__PURE__ */ jsx(AntdConfigProvider, {
76
+ ...config.antd,
77
+ children
78
+ })
79
+ });
80
+ }
81
+ function useConfigContext() {
82
+ return useContext(ConfigContext);
83
+ }
84
+
85
+ // src/Blank.tsx
86
+ import { jsx as jsx2 } from "react/jsx-runtime";
87
+ function Blank(options) {
88
+ const { Blank: Blank2 } = useConfigContext();
89
+ return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx2(Typography.Text, {
90
+ disabled: true,
91
+ children: (options == null ? void 0 : options.text) || Blank2.text
92
+ }) : options.value;
93
+ }
94
+
95
+ // src/data.ts
96
+ import { upperFirst } from "lodash-es";
97
+ import dayjs from "dayjs";
98
+ function transferOptions(options) {
99
+ if (!options)
100
+ return [];
101
+ return options.map((item) => typeof item === "object" ? item : {
102
+ label: upperFirst(item.toString()),
103
+ value: item
104
+ });
105
+ }
106
+ function transferValue(type, value) {
107
+ if (typeof value === "undefined" || value === null || value === "" || value === "null" || value === "undefined")
108
+ return null;
109
+ if (!type)
110
+ type = "string";
111
+ if (type.endsWith("[]") && typeof value === "string")
112
+ value = value.split(",").filter(Boolean);
113
+ if (["date", "time"].includes(type)) {
114
+ if (typeof value === "number" && value.toString().length === 10)
115
+ value = value * 1e3;
116
+ if (!dayjs.isDayjs(value))
117
+ value = dayjs(value);
118
+ }
119
+ return value;
120
+ }
121
+
122
+ // src/Description.tsx
123
+ import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
124
+ import {
125
+ Descriptions,
126
+ Skeleton,
127
+ Space
128
+ } from "antd";
129
+ import { isFunction, upperFirst as upperFirst2 } from "lodash-es";
130
+ import {
131
+ cloneElement,
132
+ useEffect as useEffect2,
133
+ useState as useState2
134
+ } from "react";
135
+ import { FaasDataWrapper } from "@faasjs/react";
136
+ import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
137
+ function DescriptionItemContent(props) {
138
+ var _a;
139
+ const [computedProps, setComputedProps] = useState2();
140
+ useEffect2(() => {
141
+ var _a2, _b;
142
+ const propsCopy = { ...props };
143
+ if (!propsCopy.item.title)
144
+ propsCopy.item.title = upperFirst2(propsCopy.item.id);
145
+ if (!propsCopy.item.type)
146
+ propsCopy.item.type = "string";
147
+ if ((_a2 = propsCopy.item.options) == null ? void 0 : _a2.length) {
148
+ propsCopy.item.options = transferOptions(propsCopy.item.options);
149
+ }
150
+ propsCopy.value = transferValue(propsCopy.item.type, propsCopy.value);
151
+ if (propsCopy.item.options && propsCopy.value !== null) {
152
+ if (propsCopy.item.type.endsWith("[]"))
153
+ propsCopy.value = propsCopy.value.map((v) => {
154
+ var _a3;
155
+ return ((_a3 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
156
+ });
157
+ else if ([
158
+ "string",
159
+ "number",
160
+ "boolean"
161
+ ].includes(propsCopy.item.type))
162
+ propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
163
+ }
164
+ setComputedProps(propsCopy);
165
+ }, [props]);
166
+ if (!computedProps)
167
+ return null;
168
+ if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
169
+ if (computedProps.extendTypes[computedProps.item.type].children)
170
+ return cloneElement(
171
+ computedProps.extendTypes[computedProps.item.type].children,
172
+ {
173
+ value: computedProps.value,
174
+ values: computedProps.values
175
+ }
176
+ );
177
+ else if (computedProps.extendTypes[computedProps.item.type].render)
178
+ return /* @__PURE__ */ jsx3(Fragment, {
179
+ children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values)
180
+ });
181
+ else
182
+ throw Error(computedProps.item.type + " requires children or render");
183
+ if (computedProps.item.children)
184
+ return cloneElement(computedProps.item.children, { value: computedProps.value });
185
+ if (computedProps.item.render)
186
+ return /* @__PURE__ */ jsx3(Fragment, {
187
+ children: computedProps.item.render(computedProps.value, computedProps.values)
188
+ });
189
+ if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
190
+ return /* @__PURE__ */ jsx3(Blank, {});
191
+ switch (computedProps.item.type) {
192
+ case "string[]":
193
+ return /* @__PURE__ */ jsx3(Fragment, {
194
+ children: computedProps.value.join(", ")
195
+ });
196
+ case "number":
197
+ return computedProps.value || null;
198
+ case "number[]":
199
+ return /* @__PURE__ */ jsx3(Fragment, {
200
+ children: computedProps.value.join(", ")
201
+ });
202
+ case "boolean":
203
+ return computedProps.value ? /* @__PURE__ */ jsx3(CheckOutlined, {
204
+ style: {
205
+ marginTop: "4px",
206
+ color: "#52c41a"
207
+ }
208
+ }) : /* @__PURE__ */ jsx3(CloseOutlined, {
209
+ style: {
210
+ marginTop: "4px",
211
+ color: "#ff4d4f"
212
+ }
213
+ });
214
+ case "time":
215
+ return /* @__PURE__ */ jsx3(Fragment, {
216
+ children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
217
+ });
218
+ case "date":
219
+ return /* @__PURE__ */ jsx3(Fragment, {
220
+ children: computedProps.value.format("YYYY-MM-DD")
221
+ });
222
+ case "object":
223
+ if (!computedProps.value)
224
+ return /* @__PURE__ */ jsx3(Blank, {});
225
+ return /* @__PURE__ */ jsx3(Description, {
226
+ items: computedProps.item.object,
227
+ dataSource: computedProps.value,
228
+ column: 1
229
+ });
230
+ case "object[]":
231
+ if (!((_a = computedProps.value) == null ? void 0 : _a.length))
232
+ return /* @__PURE__ */ jsx3(Blank, {});
233
+ return /* @__PURE__ */ jsx3(Space, {
234
+ direction: "vertical",
235
+ children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx3(Description, {
236
+ items: computedProps.item.object,
237
+ dataSource: value,
238
+ column: 1
239
+ }, index))
240
+ });
241
+ default:
242
+ return computedProps.value || null;
243
+ }
244
+ }
245
+ function Description(props) {
246
+ if (!props.faasData)
247
+ return /* @__PURE__ */ jsx3(Descriptions, {
248
+ ...props,
249
+ title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
250
+ children: props.items.map((item) => {
251
+ return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
252
+ label: item.title || upperFirst2(item.id),
253
+ children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
254
+ item,
255
+ value: props.dataSource[item.id],
256
+ values: props.dataSource,
257
+ extendTypes: props.extendTypes
258
+ })
259
+ }, item.id) : null;
260
+ }).filter(Boolean)
261
+ });
262
+ return /* @__PURE__ */ jsx3(FaasDataWrapper, {
263
+ fallback: props.faasData.fallback || /* @__PURE__ */ jsx3(Skeleton, {
264
+ active: true
265
+ }),
266
+ render: ({ data }) => {
267
+ return /* @__PURE__ */ jsx3(Descriptions, {
268
+ ...props,
269
+ title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
270
+ children: props.items.map((item) => {
271
+ return !item.if || item.if(data) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
272
+ label: item.title || upperFirst2(item.id),
273
+ children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
274
+ item,
275
+ value: data[item.id],
276
+ values: data,
277
+ extendTypes: props.extendTypes
278
+ })
279
+ }, item.id) : null;
280
+ }).filter(Boolean)
281
+ });
282
+ },
283
+ ...props.faasData
284
+ });
285
+ }
286
+
287
+ // src/Drawer.tsx
288
+ import { Drawer } from "antd";
289
+ import { useState as useState3 } from "react";
290
+ import { jsx as jsx4 } from "react/jsx-runtime";
291
+ function useDrawer(init) {
292
+ const [props, setProps] = useState3({
293
+ open: false,
294
+ onClose: () => setProps((prev) => ({
295
+ ...prev,
296
+ open: false
297
+ })),
298
+ ...init
299
+ });
300
+ return {
301
+ drawer: /* @__PURE__ */ jsx4(Drawer, {
302
+ ...props
303
+ }),
304
+ drawerProps: props,
305
+ setDrawerProps(changes) {
306
+ setProps((prev) => ({
307
+ ...prev,
308
+ ...changes
309
+ }));
310
+ }
311
+ };
312
+ }
313
+
314
+ // src/Form.tsx
315
+ import { faas } from "@faasjs/react";
316
+ import {
317
+ Button as Button2,
318
+ Form as AntdForm2
319
+ } from "antd";
320
+ import {
321
+ useEffect as useEffect4,
322
+ useState as useState5,
323
+ useCallback
324
+ } from "react";
325
+
326
+ // src/FormItem.tsx
327
+ import {
328
+ Button,
329
+ Row,
330
+ Col,
331
+ Form as AntdForm,
332
+ Input,
333
+ InputNumber,
334
+ Switch,
335
+ Select,
336
+ DatePicker,
337
+ TimePicker
338
+ } from "antd";
339
+ import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
340
+ import {
341
+ useEffect as useEffect3,
342
+ useState as useState4
343
+ } from "react";
344
+ import { upperFirst as upperFirst3 } from "lodash-es";
345
+ import { Fragment as Fragment2, jsx as jsx5, jsxs } from "react/jsx-runtime";
346
+ function processProps(propsCopy, config) {
347
+ if (!propsCopy.title)
348
+ propsCopy.title = upperFirst3(propsCopy.id);
349
+ if (!propsCopy.label && propsCopy.label !== false)
350
+ propsCopy.label = propsCopy.title;
351
+ if (!propsCopy.name)
352
+ propsCopy.name = propsCopy.id;
353
+ if (!propsCopy.type)
354
+ propsCopy.type = "string";
355
+ if (!propsCopy.rules)
356
+ propsCopy.rules = [];
357
+ if (propsCopy.required) {
358
+ if (propsCopy.type.endsWith("[]"))
359
+ propsCopy.rules.push({
360
+ required: true,
361
+ validator: async (_, values) => {
362
+ if (!values || values.length < 1)
363
+ return Promise.reject(Error(`${propsCopy.label || propsCopy.title} ${config.common.required}`));
364
+ }
365
+ });
366
+ else
367
+ propsCopy.rules.push({
368
+ required: true,
369
+ message: `${propsCopy.label || propsCopy.title} ${config.common.required}`
370
+ });
371
+ }
372
+ if (!propsCopy.input)
373
+ propsCopy.input = {};
374
+ if (propsCopy.options)
375
+ propsCopy.input.options = transferOptions(propsCopy.options);
376
+ switch (propsCopy.type) {
377
+ case "boolean":
378
+ propsCopy.valuePropName = "checked";
379
+ break;
380
+ case "object":
381
+ if (!Array.isArray(propsCopy.name))
382
+ propsCopy.name = [propsCopy.name];
383
+ for (const sub of propsCopy.object) {
384
+ if (!sub.name)
385
+ sub.name = propsCopy.name.concat(sub.id);
386
+ processProps(sub, config);
387
+ }
388
+ break;
389
+ }
390
+ return propsCopy;
391
+ }
392
+ function FormItem(props) {
393
+ var _a;
394
+ const [computedProps, setComputedProps] = useState4();
395
+ const [extendTypes, setExtendTypes] = useState4();
396
+ const config = useConfigContext();
397
+ const [hidden, setHidden] = useState4(false);
398
+ useEffect3(() => {
399
+ const propsCopy = { ...props };
400
+ if (propsCopy.extendTypes) {
401
+ setExtendTypes(propsCopy.extendTypes);
402
+ delete propsCopy.extendTypes;
403
+ }
404
+ if (propsCopy.if) {
405
+ const condition = propsCopy.if;
406
+ propsCopy.shouldUpdate = (_, cur) => {
407
+ const show = condition(cur);
408
+ setHidden(!show);
409
+ return show;
410
+ };
411
+ delete propsCopy.if;
412
+ }
413
+ setComputedProps(processProps(propsCopy, config));
414
+ }, [props]);
415
+ if (!computedProps)
416
+ return null;
417
+ if (hidden)
418
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
419
+ ...computedProps,
420
+ noStyle: true,
421
+ rules: [],
422
+ children: /* @__PURE__ */ jsx5(Input, {
423
+ hidden: true
424
+ })
425
+ });
426
+ if (extendTypes && extendTypes[computedProps.type])
427
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
428
+ ...computedProps,
429
+ children: extendTypes[computedProps.type].children
430
+ });
431
+ if (computedProps.children)
432
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
433
+ ...computedProps,
434
+ children: computedProps.children
435
+ });
436
+ if (computedProps.render)
437
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
438
+ ...computedProps,
439
+ children: computedProps.render()
440
+ });
441
+ switch (computedProps.type) {
442
+ case "string":
443
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
444
+ ...computedProps,
445
+ children: computedProps.options ? /* @__PURE__ */ jsx5(Select, {
446
+ ...computedProps.input
447
+ }) : /* @__PURE__ */ jsx5(Input, {
448
+ ...computedProps.input
449
+ })
450
+ });
451
+ case "string[]":
452
+ if (computedProps.options)
453
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
454
+ ...computedProps,
455
+ children: /* @__PURE__ */ jsx5(Select, {
456
+ mode: "multiple",
457
+ ...computedProps.input
458
+ })
459
+ });
460
+ return /* @__PURE__ */ jsx5(AntdForm.List, {
461
+ name: computedProps.name,
462
+ rules: computedProps.rules,
463
+ children: (fields, { add, remove }, { errors }) => {
464
+ var _a2;
465
+ return /* @__PURE__ */ jsxs(Fragment2, {
466
+ children: [
467
+ computedProps.label && /* @__PURE__ */ jsx5("div", {
468
+ className: "ant-form-item-label",
469
+ children: /* @__PURE__ */ jsx5("label", {
470
+ className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
471
+ children: computedProps.label
472
+ })
473
+ }),
474
+ fields.map((field) => {
475
+ var _a3;
476
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
477
+ children: /* @__PURE__ */ jsxs(Row, {
478
+ gutter: 24,
479
+ style: { flexFlow: "row nowrap" },
480
+ children: [
481
+ /* @__PURE__ */ jsx5(Col, {
482
+ span: 23,
483
+ children: /* @__PURE__ */ jsx5(AntdForm.Item, {
484
+ ...field,
485
+ noStyle: true,
486
+ children: /* @__PURE__ */ jsx5(Input, {
487
+ ...computedProps.input
488
+ })
489
+ })
490
+ }),
491
+ /* @__PURE__ */ jsx5(Col, {
492
+ span: 1,
493
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
494
+ danger: true,
495
+ type: "link",
496
+ style: { float: "right" },
497
+ icon: /* @__PURE__ */ jsx5(MinusCircleOutlined, {}),
498
+ onClick: () => remove(field.name)
499
+ })
500
+ })
501
+ ]
502
+ })
503
+ }, field.key);
504
+ }),
505
+ /* @__PURE__ */ jsxs(AntdForm.Item, {
506
+ children: [
507
+ !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx5(Button, {
508
+ type: "dashed",
509
+ block: true,
510
+ onClick: () => add(),
511
+ icon: /* @__PURE__ */ jsx5(PlusOutlined, {})
512
+ }),
513
+ /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
514
+ errors
515
+ })
516
+ ]
517
+ })
518
+ ]
519
+ });
520
+ }
521
+ });
522
+ case "number":
523
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
524
+ ...computedProps,
525
+ children: computedProps.options ? /* @__PURE__ */ jsx5(Select, {
526
+ ...computedProps.input
527
+ }) : /* @__PURE__ */ jsx5(InputNumber, {
528
+ style: { width: "100%" },
529
+ ...computedProps.input
530
+ })
531
+ });
532
+ case "number[]":
533
+ if (computedProps.options)
534
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
535
+ ...computedProps,
536
+ children: /* @__PURE__ */ jsx5(Select, {
537
+ mode: "multiple",
538
+ ...computedProps.input
539
+ })
540
+ });
541
+ return /* @__PURE__ */ jsx5(AntdForm.List, {
542
+ name: computedProps.name,
543
+ rules: computedProps.rules,
544
+ children: (fields, { add, remove }, { errors }) => {
545
+ var _a2, _b;
546
+ return /* @__PURE__ */ jsxs(Fragment2, {
547
+ children: [
548
+ computedProps.label && /* @__PURE__ */ jsx5("div", {
549
+ className: "ant-form-item-label",
550
+ children: /* @__PURE__ */ jsx5("label", {
551
+ className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required",
552
+ children: computedProps.label
553
+ })
554
+ }),
555
+ fields.map((field) => {
556
+ var _a3;
557
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
558
+ children: /* @__PURE__ */ jsxs(Row, {
559
+ gutter: 24,
560
+ style: { flexFlow: "row nowrap" },
561
+ children: [
562
+ /* @__PURE__ */ jsx5(Col, {
563
+ span: 23,
564
+ children: /* @__PURE__ */ jsx5(AntdForm.Item, {
565
+ ...field,
566
+ noStyle: true,
567
+ children: /* @__PURE__ */ jsx5(InputNumber, {
568
+ style: { width: "100%" },
569
+ ...computedProps.input
570
+ })
571
+ })
572
+ }),
573
+ /* @__PURE__ */ jsx5(Col, {
574
+ span: 1,
575
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
576
+ danger: true,
577
+ type: "link",
578
+ style: { float: "right" },
579
+ icon: /* @__PURE__ */ jsx5(MinusCircleOutlined, {}),
580
+ onClick: () => remove(field.name)
581
+ })
582
+ })
583
+ ]
584
+ })
585
+ }, field.key);
586
+ }),
587
+ /* @__PURE__ */ jsxs(AntdForm.Item, {
588
+ children: [
589
+ !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx5(Button, {
590
+ type: "dashed",
591
+ block: true,
592
+ onClick: () => add(),
593
+ icon: /* @__PURE__ */ jsx5(PlusOutlined, {})
594
+ }),
595
+ /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
596
+ errors
597
+ })
598
+ ]
599
+ })
600
+ ]
601
+ });
602
+ }
603
+ });
604
+ case "boolean":
605
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
606
+ ...computedProps,
607
+ children: /* @__PURE__ */ jsx5(Switch, {
608
+ ...computedProps.input
609
+ })
610
+ });
611
+ case "date":
612
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
613
+ ...computedProps,
614
+ children: /* @__PURE__ */ jsx5(DatePicker, {
615
+ ...computedProps.input
616
+ })
617
+ });
618
+ case "time":
619
+ return /* @__PURE__ */ jsx5(AntdForm.Item, {
620
+ ...computedProps,
621
+ children: /* @__PURE__ */ jsx5(TimePicker, {
622
+ ...computedProps.input
623
+ })
624
+ });
625
+ case "object":
626
+ return /* @__PURE__ */ jsxs(Fragment2, {
627
+ children: [
628
+ computedProps.label && /* @__PURE__ */ jsx5("div", {
629
+ className: "ant-form-item-label",
630
+ children: /* @__PURE__ */ jsx5("label", {
631
+ className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
632
+ children: computedProps.label
633
+ })
634
+ }),
635
+ computedProps.object.map((o) => /* @__PURE__ */ jsx5(FormItem, {
636
+ ...o
637
+ }, o.id))
638
+ ]
639
+ });
640
+ case "object[]":
641
+ return /* @__PURE__ */ jsx5(AntdForm.List, {
642
+ name: computedProps.name,
643
+ rules: computedProps.rules,
644
+ children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(Fragment2, {
645
+ children: [
646
+ fields.map((field) => /* @__PURE__ */ jsxs(AntdForm.Item, {
647
+ style: { marginBottom: 0 },
648
+ children: [
649
+ /* @__PURE__ */ jsx5("div", {
650
+ className: "ant-form-item-label",
651
+ children: /* @__PURE__ */ jsxs("label", {
652
+ children: [
653
+ computedProps.label,
654
+ " ",
655
+ field.name + 1,
656
+ !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
657
+ danger: true,
658
+ type: "link",
659
+ onClick: () => remove(field.name),
660
+ children: config.common.delete
661
+ })
662
+ ]
663
+ })
664
+ }),
665
+ /* @__PURE__ */ jsx5(Row, {
666
+ gutter: 24,
667
+ children: computedProps.object.map((o) => /* @__PURE__ */ jsx5(Col, {
668
+ span: o.col || 24,
669
+ children: /* @__PURE__ */ jsx5(FormItem, {
670
+ ...o,
671
+ name: [field.name, o.id]
672
+ })
673
+ }, o.id))
674
+ })
675
+ ]
676
+ }, field.key)),
677
+ /* @__PURE__ */ jsxs(AntdForm.Item, {
678
+ children: [
679
+ !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxs(Button, {
680
+ type: "dashed",
681
+ block: true,
682
+ onClick: () => add(),
683
+ icon: /* @__PURE__ */ jsx5(PlusOutlined, {}),
684
+ children: [
685
+ config.common.add,
686
+ " ",
687
+ computedProps.label
688
+ ]
689
+ }),
690
+ /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
691
+ errors
692
+ })
693
+ ]
694
+ })
695
+ ]
696
+ })
697
+ });
698
+ default:
699
+ return null;
700
+ }
701
+ }
702
+
703
+ // src/Form.tsx
704
+ import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
705
+ function Form(props) {
706
+ var _a, _b;
707
+ const [loading, setLoading] = useState5(false);
708
+ const [computedProps, setComputedProps] = useState5();
709
+ const config = useConfigContext();
710
+ const [extendTypes, setExtendTypes] = useState5();
711
+ const [form] = AntdForm2.useForm(props.form);
712
+ const [initialValues, setInitialValues] = useState5(props.initialValues);
713
+ useEffect4(() => {
714
+ var _a2, _b2;
715
+ const propsCopy = {
716
+ ...props,
717
+ form
718
+ };
719
+ if (propsCopy.initialValues) {
720
+ for (const key in propsCopy.initialValues)
721
+ propsCopy.initialValues[key] = transferValue(
722
+ (_a2 = propsCopy.items.find((item) => item.id === key)) == null ? void 0 : _a2.type,
723
+ propsCopy.initialValues[key]
724
+ );
725
+ setInitialValues(propsCopy.initialValues);
726
+ delete propsCopy.initialValues;
727
+ }
728
+ if (propsCopy.onFinish) {
729
+ propsCopy.onFinish = async (values) => {
730
+ var _a3;
731
+ setLoading(true);
732
+ try {
733
+ if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
734
+ await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
735
+ ...values2,
736
+ ...propsCopy.submit.to.params
737
+ } : values2));
738
+ } else
739
+ await props.onFinish(values);
740
+ } catch (error) {
741
+ console.error(error);
742
+ }
743
+ setLoading(false);
744
+ };
745
+ } else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
746
+ propsCopy.onFinish = async (values) => {
747
+ setLoading(true);
748
+ return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
749
+ ...values,
750
+ ...propsCopy.submit.to.params
751
+ } : values).finally(() => setLoading(false));
752
+ };
753
+ }
754
+ if (propsCopy.extendTypes) {
755
+ setExtendTypes(propsCopy.extendTypes);
756
+ delete propsCopy.extendTypes;
757
+ }
758
+ setComputedProps(propsCopy);
759
+ }, [props]);
760
+ const onValuesChange = useCallback((changedValues, allValues) => {
761
+ if (props.onValuesChange) {
762
+ props.onValuesChange(changedValues, allValues);
763
+ }
764
+ if (!props.items)
765
+ return;
766
+ for (const key in changedValues) {
767
+ const item = computedProps.items.find((i) => i.id === key);
768
+ if (item == null ? void 0 : item.onValueChange)
769
+ item.onValueChange(changedValues[key], allValues, form);
770
+ }
771
+ }, [computedProps]);
772
+ useEffect4(() => {
773
+ if (!initialValues)
774
+ return;
775
+ form.setFieldsValue(initialValues);
776
+ setInitialValues(null);
777
+ }, [computedProps]);
778
+ if (!computedProps)
779
+ return null;
780
+ return /* @__PURE__ */ jsxs2(AntdForm2, {
781
+ ...computedProps,
782
+ onValuesChange,
783
+ children: [
784
+ computedProps.beforeItems,
785
+ (_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsx6(FormItem, {
786
+ ...item,
787
+ extendTypes
788
+ }, item.id)),
789
+ computedProps.children,
790
+ computedProps.submit !== false && /* @__PURE__ */ jsx6(Button2, {
791
+ htmlType: "submit",
792
+ type: "primary",
793
+ loading,
794
+ children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text
795
+ }),
796
+ computedProps.footer
797
+ ]
798
+ });
799
+ }
800
+ Form.useForm = AntdForm2.useForm;
801
+
802
+ // src/Link.tsx
803
+ import { Link as RouterLink } from "react-router-dom";
804
+ import { Button as Button3 } from "antd";
805
+ import { jsx as jsx7 } from "react/jsx-runtime";
806
+ function Link({
807
+ href,
808
+ target,
809
+ text,
810
+ children,
811
+ style,
812
+ button
813
+ }) {
814
+ const { Link: Link2 } = useConfigContext();
815
+ style = Object.assign({ cursor: "pointer" }, style);
816
+ if (href.startsWith("http")) {
817
+ if (button)
818
+ return /* @__PURE__ */ jsx7(Button3, {
819
+ ...button,
820
+ children: /* @__PURE__ */ jsx7("a", {
821
+ href,
822
+ target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
823
+ style: {
824
+ ...Link2.style,
825
+ ...style || {}
826
+ },
827
+ children: text || children
828
+ })
829
+ });
830
+ return /* @__PURE__ */ jsx7("a", {
831
+ href,
832
+ target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
833
+ style: {
834
+ ...Link2.style,
835
+ ...style || {}
836
+ },
837
+ children: text || children
838
+ });
839
+ }
840
+ if (button)
841
+ return /* @__PURE__ */ jsx7(Button3, {
842
+ ...button,
843
+ children: /* @__PURE__ */ jsx7(RouterLink, {
844
+ to: href,
845
+ target: target || (Link2 == null ? void 0 : Link2.target),
846
+ style: {
847
+ ...Link2.style,
848
+ ...style || {}
849
+ },
850
+ children: text || children
851
+ })
852
+ });
853
+ return /* @__PURE__ */ jsx7(RouterLink, {
854
+ to: href,
855
+ target: target || (Link2 == null ? void 0 : Link2.target),
856
+ style: {
857
+ ...Link2.style,
858
+ ...style || {}
859
+ },
860
+ children: text || children
861
+ });
862
+ }
863
+
864
+ // src/Modal.tsx
865
+ import { Modal } from "antd";
866
+ import { useState as useState6 } from "react";
867
+ import { jsx as jsx8 } from "react/jsx-runtime";
868
+ function useModal(init) {
869
+ const [props, setProps] = useState6({
870
+ open: false,
871
+ onCancel: () => setProps((prev) => ({
872
+ ...prev,
873
+ open: false
874
+ })),
875
+ ...init
876
+ });
877
+ return {
878
+ modal: /* @__PURE__ */ jsx8(Modal, {
879
+ ...props
880
+ }),
881
+ modalProps: props,
882
+ setModalProps(changes) {
883
+ setProps((prev) => ({
884
+ ...prev,
885
+ ...changes
886
+ }));
887
+ }
888
+ };
889
+ }
890
+
891
+ // src/Routers.tsx
892
+ import { Result, Skeleton as Skeleton2 } from "antd";
893
+ import {
894
+ Suspense
895
+ } from "react";
896
+ import {
897
+ Routes as OriginRoutes,
898
+ Route
899
+ } from "react-router-dom";
900
+ import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
901
+ function PageNotFound() {
902
+ const config = useConfigContext();
903
+ return /* @__PURE__ */ jsx9(Result, {
904
+ status: "404",
905
+ title: config.common.pageNotFound
906
+ });
907
+ }
908
+ function Routes(props) {
909
+ return /* @__PURE__ */ jsxs3(OriginRoutes, {
910
+ children: [
911
+ props.routes.map((r) => /* @__PURE__ */ jsx9(Route, {
912
+ ...r,
913
+ element: r.element || /* @__PURE__ */ jsx9(Suspense, {
914
+ fallback: props.fallback || /* @__PURE__ */ jsx9("div", {
915
+ style: { padding: "24px" },
916
+ children: /* @__PURE__ */ jsx9(Skeleton2, {
917
+ active: true
918
+ })
919
+ }),
920
+ children: /* @__PURE__ */ jsx9(r.page, {})
921
+ })
922
+ }, r.path)),
923
+ /* @__PURE__ */ jsx9(Route, {
924
+ path: "*",
925
+ element: props.notFound || /* @__PURE__ */ jsx9(PageNotFound, {})
926
+ }, "*")
927
+ ]
928
+ });
929
+ }
930
+
931
+ // src/Table.tsx
932
+ import {
933
+ useState as useState7,
934
+ useEffect as useEffect5,
935
+ cloneElement as cloneElement2
936
+ } from "react";
937
+ import {
938
+ Table as AntdTable,
939
+ Radio,
940
+ Skeleton as Skeleton3,
941
+ Input as Input2
942
+ } from "antd";
943
+ import dayjs2 from "dayjs";
944
+ import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
945
+ import {
946
+ isNil as isNil2,
947
+ uniqBy,
948
+ upperFirst as upperFirst4
949
+ } from "lodash-es";
950
+ import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
951
+ import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
952
+ function processValue(item, value) {
953
+ var _a;
954
+ const transferred = transferValue(item.type, value);
955
+ if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
956
+ return /* @__PURE__ */ jsx10(Blank, {});
957
+ if (item.options) {
958
+ if (item.type.endsWith("[]"))
959
+ return transferred.map((v) => {
960
+ var _a2;
961
+ return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
962
+ }).join(", ");
963
+ if ([
964
+ "string",
965
+ "number",
966
+ "boolean"
967
+ ].includes(item.type))
968
+ return ((_a = item.options.find((option) => option.value === transferred)) == null ? void 0 : _a.label) || transferred;
969
+ }
970
+ if (item.type.endsWith("[]"))
971
+ return transferred.join(", ");
972
+ if (["date", "time"].includes(item.type))
973
+ return transferred.format(item.type === "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss");
974
+ return value;
975
+ }
976
+ function Table(props) {
977
+ const [columns, setColumns] = useState7();
978
+ const { common: common2 } = useConfigContext();
979
+ useEffect5(() => {
980
+ var _a;
981
+ for (const item of props.items) {
982
+ if (!item.key)
983
+ item.key = item.id;
984
+ if (!item.dataIndex)
985
+ item.dataIndex = item.id;
986
+ if (!item.title)
987
+ item.title = upperFirst4(item.id);
988
+ if (!item.type)
989
+ item.type = "string";
990
+ if ((_a = item.options) == null ? void 0 : _a.length) {
991
+ item.options = transferOptions(item.options);
992
+ item.filters = item.options.map((o) => ({
993
+ text: o.label,
994
+ value: o.value
995
+ }));
996
+ }
997
+ if (item.children)
998
+ delete item.children;
999
+ if (props.extendTypes && props.extendTypes[item.type]) {
1000
+ if (props.extendTypes[item.type].children)
1001
+ item.render = (value, values) => cloneElement2(
1002
+ props.extendTypes[item.type].children,
1003
+ {
1004
+ value,
1005
+ values
1006
+ }
1007
+ );
1008
+ else if (props.extendTypes[item.type].render)
1009
+ item.render = props.extendTypes[item.type].render;
1010
+ else
1011
+ throw Error(item.type + " requires children or render");
1012
+ continue;
1013
+ }
1014
+ switch (item.type) {
1015
+ case "string":
1016
+ if (!item.render)
1017
+ item.render = (value) => processValue(item, value);
1018
+ if (!item.onFilter)
1019
+ item.onFilter = (value, row) => {
1020
+ if (!row[item.id])
1021
+ return false;
1022
+ return row[item.id].toLowerCase().includes(value.toLowerCase());
1023
+ };
1024
+ if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
1025
+ item.filterDropdown = ({
1026
+ setSelectedKeys,
1027
+ confirm,
1028
+ clearFilters
1029
+ }) => /* @__PURE__ */ jsx10(Input2.Search, {
1030
+ placeholder: `${common2.search} ${item.title}`,
1031
+ allowClear: true,
1032
+ onSearch: (v) => {
1033
+ if (v) {
1034
+ setSelectedKeys([v]);
1035
+ } else {
1036
+ setSelectedKeys([]);
1037
+ clearFilters();
1038
+ }
1039
+ confirm();
1040
+ }
1041
+ });
1042
+ break;
1043
+ case "string[]":
1044
+ if (!item.render)
1045
+ item.render = (value) => processValue(item, value);
1046
+ if (!item.onFilter)
1047
+ item.onFilter = (value, row) => {
1048
+ if (!row[item.id] || !row[item.id].length)
1049
+ return false;
1050
+ return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
1051
+ };
1052
+ if (!item.filters && item.filterDropdown !== false)
1053
+ item.filterDropdown = ({
1054
+ setSelectedKeys,
1055
+ confirm,
1056
+ clearFilters
1057
+ }) => /* @__PURE__ */ jsx10(Input2.Search, {
1058
+ placeholder: `${common2.search} ${item.title}`,
1059
+ allowClear: true,
1060
+ onSearch: (v) => {
1061
+ if (v) {
1062
+ setSelectedKeys([v]);
1063
+ } else {
1064
+ setSelectedKeys([]);
1065
+ clearFilters();
1066
+ }
1067
+ confirm();
1068
+ }
1069
+ });
1070
+ break;
1071
+ case "number":
1072
+ if (!item.render)
1073
+ item.render = (value) => processValue(item, value);
1074
+ if (!item.sorter)
1075
+ item.sorter = (a, b) => a[item.id] - b[item.id];
1076
+ if (!item.onFilter)
1077
+ item.onFilter = (value, row) => value === row[item.id];
1078
+ if (!item.filters && item.filterDropdown !== false)
1079
+ item.filterDropdown = ({
1080
+ setSelectedKeys,
1081
+ confirm,
1082
+ clearFilters
1083
+ }) => /* @__PURE__ */ jsx10(Input2.Search, {
1084
+ placeholder: `${common2.search} ${item.title}`,
1085
+ allowClear: true,
1086
+ onSearch: (v) => {
1087
+ if (v) {
1088
+ setSelectedKeys([Number(v)]);
1089
+ } else {
1090
+ setSelectedKeys([]);
1091
+ clearFilters();
1092
+ }
1093
+ confirm();
1094
+ }
1095
+ });
1096
+ break;
1097
+ case "number[]":
1098
+ if (!item.render)
1099
+ item.render = (value) => processValue(item, value).join(", ");
1100
+ if (!item.onFilter)
1101
+ item.onFilter = (value, row) => row[item.id].includes(value);
1102
+ if (!item.filters && item.filterDropdown !== false)
1103
+ item.filterDropdown = ({
1104
+ setSelectedKeys,
1105
+ confirm,
1106
+ clearFilters
1107
+ }) => /* @__PURE__ */ jsx10(Input2.Search, {
1108
+ placeholder: `${common2.search} ${item.title}`,
1109
+ allowClear: true,
1110
+ onSearch: (v) => {
1111
+ if (v) {
1112
+ setSelectedKeys([Number(v)]);
1113
+ } else {
1114
+ setSelectedKeys([]);
1115
+ clearFilters();
1116
+ }
1117
+ confirm();
1118
+ }
1119
+ });
1120
+ break;
1121
+ case "boolean":
1122
+ if (!item.render)
1123
+ item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ jsx10(Blank, {}) : value ? /* @__PURE__ */ jsx10(CheckOutlined2, {
1124
+ style: {
1125
+ marginTop: "4px",
1126
+ color: "#52c41a"
1127
+ }
1128
+ }) : /* @__PURE__ */ jsx10(CloseOutlined2, {
1129
+ style: {
1130
+ marginTop: "4px",
1131
+ color: "#ff4d4f"
1132
+ }
1133
+ });
1134
+ if (item.filterDropdown !== false)
1135
+ item.filterDropdown = ({
1136
+ setSelectedKeys,
1137
+ selectedKeys,
1138
+ confirm
1139
+ }) => /* @__PURE__ */ jsxs4(Radio.Group, {
1140
+ style: { padding: 8 },
1141
+ buttonStyle: "solid",
1142
+ value: selectedKeys[0],
1143
+ onChange: (e) => {
1144
+ setSelectedKeys(e.target.value ? [e.target.value] : []);
1145
+ confirm();
1146
+ },
1147
+ children: [
1148
+ /* @__PURE__ */ jsx10(Radio.Button, {
1149
+ children: common2.all
1150
+ }),
1151
+ /* @__PURE__ */ jsx10(Radio.Button, {
1152
+ value: "true",
1153
+ children: /* @__PURE__ */ jsx10(CheckOutlined2, {
1154
+ style: {
1155
+ color: "#52c41a",
1156
+ verticalAlign: "middle"
1157
+ }
1158
+ })
1159
+ }),
1160
+ /* @__PURE__ */ jsx10(Radio.Button, {
1161
+ value: "false",
1162
+ children: /* @__PURE__ */ jsx10(CloseOutlined2, {
1163
+ style: {
1164
+ verticalAlign: "middle",
1165
+ color: "#ff4d4f"
1166
+ }
1167
+ })
1168
+ }),
1169
+ /* @__PURE__ */ jsx10(Radio.Button, {
1170
+ value: "empty",
1171
+ children: common2.blank
1172
+ })
1173
+ ]
1174
+ });
1175
+ if (!item.onFilter)
1176
+ item.onFilter = (value, row) => {
1177
+ switch (value) {
1178
+ case "true":
1179
+ return !isNil2(row[item.id]) && !!row[item.id];
1180
+ case "false":
1181
+ return !isNil2(row[item.id]) && !row[item.id];
1182
+ case "empty":
1183
+ return isNil2(row[item.id]);
1184
+ default:
1185
+ return true;
1186
+ }
1187
+ };
1188
+ break;
1189
+ case "date":
1190
+ if (!item.render)
1191
+ item.render = (value) => processValue(item, value);
1192
+ if (!item.onFilter)
1193
+ item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
1194
+ if (!item.sorter)
1195
+ item.sorter = (a, b) => dayjs2(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1196
+ break;
1197
+ case "time":
1198
+ if (!item.render)
1199
+ item.render = (value) => processValue(item, value);
1200
+ if (!item.onFilter)
1201
+ item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
1202
+ if (!item.sorter)
1203
+ item.sorter = (a, b) => dayjs2(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1204
+ break;
1205
+ case "object":
1206
+ if (!item.render)
1207
+ item.render = (value) => /* @__PURE__ */ jsx10(Description, {
1208
+ items: item.object,
1209
+ dataSource: value || {},
1210
+ column: 1
1211
+ });
1212
+ break;
1213
+ case "object[]":
1214
+ if (!item.render)
1215
+ item.render = (value) => value.map((v, i) => /* @__PURE__ */ jsx10(Description, {
1216
+ items: item.object,
1217
+ dataSource: v || [],
1218
+ column: 1
1219
+ }, i));
1220
+ break;
1221
+ default:
1222
+ if (!item.render)
1223
+ item.render = (value) => processValue(item, value);
1224
+ if (!item.onFilter)
1225
+ item.onFilter = (value, row) => value === row[item.id];
1226
+ break;
1227
+ }
1228
+ }
1229
+ setColumns(props.items);
1230
+ }, [props.items]);
1231
+ useEffect5(() => {
1232
+ if (!props.dataSource || !columns)
1233
+ return;
1234
+ for (const column of columns) {
1235
+ if (column.optionsType === "auto" && !column.options && !column.filters) {
1236
+ setColumns((prev) => {
1237
+ const newColumns = [...prev];
1238
+ const index = newColumns.findIndex((item) => item.id === column.id);
1239
+ newColumns[index].filters = uniqBy(props.dataSource, column.id).map((v) => ({
1240
+ text: v[column.id],
1241
+ value: v[column.id]
1242
+ }));
1243
+ return newColumns;
1244
+ });
1245
+ }
1246
+ }
1247
+ }, [props.dataSource, columns]);
1248
+ if (!columns)
1249
+ return null;
1250
+ if (!props.faasData)
1251
+ return /* @__PURE__ */ jsx10(AntdTable, {
1252
+ ...props,
1253
+ rowKey: props.rowKey || "id",
1254
+ columns,
1255
+ dataSource: props.dataSource
1256
+ });
1257
+ return /* @__PURE__ */ jsx10(FaasDataWrapper2, {
1258
+ fallback: props.faasData.fallback || /* @__PURE__ */ jsx10(Skeleton3, {
1259
+ active: true
1260
+ }),
1261
+ render: ({
1262
+ data,
1263
+ params,
1264
+ reload
1265
+ }) => {
1266
+ if (!data)
1267
+ return /* @__PURE__ */ jsx10(AntdTable, {
1268
+ ...props,
1269
+ rowKey: props.rowKey || "id",
1270
+ columns,
1271
+ dataSource: []
1272
+ });
1273
+ if (Array.isArray(data))
1274
+ return /* @__PURE__ */ jsx10(AntdTable, {
1275
+ ...props,
1276
+ rowKey: props.rowKey || "id",
1277
+ columns,
1278
+ dataSource: data
1279
+ });
1280
+ return /* @__PURE__ */ jsx10(AntdTable, {
1281
+ ...props,
1282
+ rowKey: props.rowKey || "id",
1283
+ columns,
1284
+ dataSource: data.rows,
1285
+ pagination: {
1286
+ ...props.pagination,
1287
+ ...data.pagination
1288
+ },
1289
+ onChange: (pagination, filters, sorter, extra) => {
1290
+ if (props.onChange) {
1291
+ const processed = props.onChange(pagination, filters, sorter, extra);
1292
+ reload({
1293
+ ...params,
1294
+ pagination: processed.pagination,
1295
+ filters: processed.filters,
1296
+ sorter: processed.sorter
1297
+ });
1298
+ return;
1299
+ }
1300
+ reload({
1301
+ ...params,
1302
+ pagination,
1303
+ filters,
1304
+ sorter
1305
+ });
1306
+ }
1307
+ });
1308
+ },
1309
+ ...props.faasData
1310
+ });
1311
+ }
1312
+
1313
+ // src/Title.tsx
1314
+ import { useEffect as useEffect6, cloneElement as cloneElement3 } from "react";
1315
+ import { Fragment as Fragment3, jsx as jsx11 } from "react/jsx-runtime";
1316
+ function Title(props) {
1317
+ const { Title: Title2 } = useConfigContext();
1318
+ useEffect6(() => {
1319
+ const title = Array.isArray(props.title) ? props.title : [props.title];
1320
+ document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
1321
+ }, [props]);
1322
+ if (props.h1) {
1323
+ if (typeof props.h1 === "boolean")
1324
+ return /* @__PURE__ */ jsx11("h1", {
1325
+ children: Array.isArray(props.title) ? props.title[0] : props.title
1326
+ });
1327
+ return /* @__PURE__ */ jsx11("h1", {
1328
+ className: props.h1.className,
1329
+ style: props.h1.style,
1330
+ children: Array.isArray(props.title) ? props.title[0] : props.title
1331
+ });
1332
+ }
1333
+ if (props.plain)
1334
+ return /* @__PURE__ */ jsx11(Fragment3, {
1335
+ children: Array.isArray(props.title) ? props.title[0] : props.title
1336
+ });
1337
+ if (props.children)
1338
+ return cloneElement3(props.children, { title: props.title });
1339
+ return null;
1340
+ }
1341
+ export {
1342
+ Blank,
1343
+ ConfigContext,
1344
+ ConfigProvider,
1345
+ Description,
1346
+ Drawer,
1347
+ Form,
1348
+ FormItem,
1349
+ Link,
1350
+ Modal,
1351
+ PageNotFound,
1352
+ Routes,
1353
+ Table,
1354
+ Title,
1355
+ transferOptions,
1356
+ transferValue,
1357
+ useConfigContext,
1358
+ useDrawer,
1359
+ useModal
1360
+ };