@faasjs/ant-design 0.0.3-beta.6 → 0.0.3-beta.60

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 CHANGED
@@ -1,20 +1,157 @@
1
1
  // react-shim.js
2
2
  import React from "react";
3
3
 
4
+ // src/App.tsx
5
+ import {
6
+ ConfigProvider,
7
+ message,
8
+ notification
9
+ } from "antd";
10
+ import { StyleProvider, legacyLogicalPropertiesTransformer } from "@ant-design/cssinjs";
11
+ import {
12
+ createContext,
13
+ useContext,
14
+ useEffect,
15
+ useMemo
16
+ } from "react";
17
+
18
+ // src/Modal.tsx
19
+ import { Modal } from "antd";
20
+ import { useState } from "react";
21
+ import { jsx } from "react/jsx-runtime";
22
+ function useModal(init) {
23
+ const [props, setProps] = useState({
24
+ open: false,
25
+ onCancel: () => setProps((prev) => ({
26
+ ...prev,
27
+ open: false
28
+ })),
29
+ ...init
30
+ });
31
+ return {
32
+ modal: /* @__PURE__ */ jsx(Modal, {
33
+ ...props
34
+ }),
35
+ modalProps: props,
36
+ setModalProps(changes) {
37
+ setProps((prev) => ({
38
+ ...prev,
39
+ ...changes
40
+ }));
41
+ }
42
+ };
43
+ }
44
+
45
+ // src/Drawer.tsx
46
+ import { Drawer } from "antd";
47
+ import { useState as useState2 } from "react";
48
+ import { jsx as jsx2 } from "react/jsx-runtime";
49
+ function useDrawer(init) {
50
+ const [props, setProps] = useState2({
51
+ open: false,
52
+ onClose: () => setProps((prev) => ({
53
+ ...prev,
54
+ open: false
55
+ })),
56
+ ...init
57
+ });
58
+ return {
59
+ drawer: /* @__PURE__ */ jsx2(Drawer, {
60
+ ...props
61
+ }),
62
+ drawerProps: props,
63
+ setDrawerProps(changes) {
64
+ setProps((prev) => ({
65
+ ...prev,
66
+ ...changes
67
+ }));
68
+ }
69
+ };
70
+ }
71
+
72
+ // src/App.tsx
73
+ import { BrowserRouter, useLocation } from "react-router-dom";
74
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
75
+ var AppContext = createContext({
76
+ message: {},
77
+ notification: {},
78
+ setModalProps: () => void 0,
79
+ setDrawerProps: () => void 0
80
+ });
81
+ function RoutesApp(props) {
82
+ const location = useLocation();
83
+ const { setDrawerProps, setModalProps } = useApp();
84
+ useEffect(() => {
85
+ console.debug("location", location);
86
+ setDrawerProps({ open: false });
87
+ setModalProps({ open: false });
88
+ }, [location]);
89
+ return /* @__PURE__ */ jsx3(Fragment, {
90
+ children: props.children
91
+ });
92
+ }
93
+ function App(props) {
94
+ const [messageApi, messageContextHolder] = message.useMessage();
95
+ const [notificationApi, notificationContextHolder] = notification.useNotification();
96
+ const { modal, setModalProps } = useModal();
97
+ const { drawer, setDrawerProps } = useDrawer();
98
+ const memoizedContextValue = useMemo(
99
+ () => ({
100
+ message: messageApi,
101
+ notification: notificationApi,
102
+ setModalProps,
103
+ setDrawerProps
104
+ }),
105
+ [
106
+ messageApi,
107
+ notificationApi,
108
+ setModalProps,
109
+ setDrawerProps
110
+ ]
111
+ );
112
+ return /* @__PURE__ */ jsx3(StyleProvider, {
113
+ ...Object.assign(props.styleProviderProps || {}, {
114
+ hashPriority: "high",
115
+ transformers: [legacyLogicalPropertiesTransformer]
116
+ }),
117
+ children: /* @__PURE__ */ jsx3(ConfigProvider, {
118
+ ...props.configProviderProps,
119
+ children: /* @__PURE__ */ jsx3(AppContext.Provider, {
120
+ value: memoizedContextValue,
121
+ children: /* @__PURE__ */ jsxs(BrowserRouter, {
122
+ ...props.browserRouterProps,
123
+ children: [
124
+ messageContextHolder,
125
+ notificationContextHolder,
126
+ modal,
127
+ drawer,
128
+ /* @__PURE__ */ jsx3(RoutesApp, {
129
+ children: props.children
130
+ })
131
+ ]
132
+ })
133
+ })
134
+ })
135
+ });
136
+ }
137
+ function useApp() {
138
+ return useContext(AppContext);
139
+ }
140
+ App.useApp = useApp;
141
+
4
142
  // src/Blank.tsx
5
143
  import { Typography } from "antd";
6
144
  import { isNil } from "lodash-es";
7
145
 
8
146
  // src/Config.tsx
9
147
  import {
10
- createContext,
11
- useContext,
12
- useEffect,
13
- useState
148
+ createContext as createContext2,
149
+ useContext as useContext2,
150
+ useEffect as useEffect2,
151
+ useState as useState3
14
152
  } from "react";
15
- import { ConfigProvider as AntdConfigProvider } from "antd";
16
153
  import { defaultsDeep } from "lodash-es";
17
- import { jsx } from "react/jsx-runtime";
154
+ import { jsx as jsx4 } from "react/jsx-runtime";
18
155
  var isZH = /^zh/i.test(navigator.language);
19
156
  var zh = {
20
157
  lang: "zh",
@@ -53,13 +190,13 @@ var baseConfig = {
53
190
  },
54
191
  Link: { style: {} }
55
192
  };
56
- var ConfigContext = createContext(baseConfig);
57
- function ConfigProvider({
193
+ var ConfigContext = createContext2(baseConfig);
194
+ function ConfigProvider2({
58
195
  config,
59
196
  children
60
197
  }) {
61
- const [values, setValues] = useState(baseConfig);
62
- useEffect(() => {
198
+ const [values, setValues] = useState3(baseConfig);
199
+ useEffect2(() => {
63
200
  if (config.lang === "zh") {
64
201
  setValues(defaultsDeep(config, {
65
202
  lang: "zh",
@@ -68,25 +205,22 @@ function ConfigProvider({
68
205
  Form: { submit: { text: zh.submit } }
69
206
  }, baseConfig));
70
207
  } else
71
- setValues(values);
208
+ setValues(defaultsDeep(config, values));
72
209
  }, []);
73
- return /* @__PURE__ */ jsx(ConfigContext.Provider, {
210
+ return /* @__PURE__ */ jsx4(ConfigContext.Provider, {
74
211
  value: values,
75
- children: /* @__PURE__ */ jsx(AntdConfigProvider, {
76
- ...config.antd,
77
- children
78
- })
212
+ children
79
213
  });
80
214
  }
81
215
  function useConfigContext() {
82
- return useContext(ConfigContext);
216
+ return useContext2(ConfigContext);
83
217
  }
84
218
 
85
219
  // src/Blank.tsx
86
- import { jsx as jsx2 } from "react/jsx-runtime";
220
+ import { jsx as jsx5 } from "react/jsx-runtime";
87
221
  function Blank(options) {
88
222
  const { Blank: Blank2 } = useConfigContext();
89
- return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx2(Typography.Text, {
223
+ return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx5(Typography.Text, {
90
224
  disabled: true,
91
225
  children: (options == null ? void 0 : options.text) || Blank2.text
92
226
  }) : options.value;
@@ -123,21 +257,57 @@ function transferValue(type, value) {
123
257
  import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
124
258
  import {
125
259
  Descriptions,
126
- Skeleton,
127
260
  Space
128
261
  } from "antd";
129
262
  import { isFunction, upperFirst as upperFirst2 } from "lodash-es";
130
263
  import {
131
264
  cloneElement,
132
- useEffect as useEffect2,
133
- useState as useState2
265
+ useEffect as useEffect3,
266
+ useState as useState4
134
267
  } from "react";
135
- import { FaasDataWrapper } from "@faasjs/react";
136
- import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
268
+
269
+ // src/FaasDataWrapper.tsx
270
+ import { FaasDataWrapper as Origin } from "@faasjs/react";
271
+
272
+ // src/Loading.tsx
273
+ import { Spin } from "antd";
274
+ import { Fragment as Fragment2, jsx as jsx6 } from "react/jsx-runtime";
275
+ function Loading(props) {
276
+ if (props.loading === false)
277
+ return /* @__PURE__ */ jsx6(Fragment2, {
278
+ children: props.children
279
+ });
280
+ return /* @__PURE__ */ jsx6("div", {
281
+ style: {
282
+ ...props.style || {},
283
+ ...!props.size || props.size === "large" ? {
284
+ margin: "20vh auto",
285
+ textAlign: "center"
286
+ } : {}
287
+ },
288
+ children: /* @__PURE__ */ jsx6(Spin, {
289
+ size: props.size || "large"
290
+ })
291
+ });
292
+ }
293
+
294
+ // src/FaasDataWrapper.tsx
295
+ import { jsx as jsx7 } from "react/jsx-runtime";
296
+ function FaasDataWrapper(props) {
297
+ return /* @__PURE__ */ jsx7(Origin, {
298
+ fallback: props.loading || /* @__PURE__ */ jsx7(Loading, {
299
+ ...props.loadingProps
300
+ }),
301
+ ...props
302
+ });
303
+ }
304
+
305
+ // src/Description.tsx
306
+ import { Fragment as Fragment3, jsx as jsx8 } from "react/jsx-runtime";
137
307
  function DescriptionItemContent(props) {
138
308
  var _a;
139
- const [computedProps, setComputedProps] = useState2();
140
- useEffect2(() => {
309
+ const [computedProps, setComputedProps] = useState4();
310
+ useEffect3(() => {
141
311
  var _a2, _b;
142
312
  const propsCopy = { ...props };
143
313
  if (!propsCopy.item.title)
@@ -170,69 +340,84 @@ function DescriptionItemContent(props) {
170
340
  return cloneElement(
171
341
  computedProps.extendTypes[computedProps.item.type].children,
172
342
  {
343
+ scene: "description",
173
344
  value: computedProps.value,
174
345
  values: computedProps.values
175
346
  }
176
347
  );
177
348
  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)
349
+ return /* @__PURE__ */ jsx8(Fragment3, {
350
+ children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
180
351
  });
181
352
  else
182
353
  throw Error(computedProps.item.type + " requires children or render");
354
+ if (computedProps.item.descriptionChildren === null)
355
+ return null;
356
+ if (computedProps.item.descriptionChildren)
357
+ return cloneElement(computedProps.item.descriptionChildren, {
358
+ scene: "description",
359
+ value: computedProps.value,
360
+ values: computedProps.values
361
+ });
362
+ if (computedProps.item.children === null)
363
+ return null;
183
364
  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)
365
+ return cloneElement(computedProps.item.children, {
366
+ scene: "description",
367
+ value: computedProps.value,
368
+ values: computedProps.values
188
369
  });
370
+ if (computedProps.item.descriptionRender)
371
+ return computedProps.item.descriptionRender(computedProps.value, computedProps.values, 0, "description");
372
+ if (computedProps.item.render)
373
+ return computedProps.item.render(computedProps.value, computedProps.values, 0, "description");
189
374
  if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
190
- return /* @__PURE__ */ jsx3(Blank, {});
375
+ return /* @__PURE__ */ jsx8(Blank, {});
191
376
  switch (computedProps.item.type) {
192
377
  case "string[]":
193
- return /* @__PURE__ */ jsx3(Fragment, {
378
+ return /* @__PURE__ */ jsx8(Fragment3, {
194
379
  children: computedProps.value.join(", ")
195
380
  });
196
381
  case "number":
197
382
  return computedProps.value || null;
198
383
  case "number[]":
199
- return /* @__PURE__ */ jsx3(Fragment, {
384
+ return /* @__PURE__ */ jsx8(Fragment3, {
200
385
  children: computedProps.value.join(", ")
201
386
  });
202
387
  case "boolean":
203
- return computedProps.value ? /* @__PURE__ */ jsx3(CheckOutlined, {
388
+ return computedProps.value ? /* @__PURE__ */ jsx8(CheckOutlined, {
204
389
  style: {
205
390
  marginTop: "4px",
206
391
  color: "#52c41a"
207
392
  }
208
- }) : /* @__PURE__ */ jsx3(CloseOutlined, {
393
+ }) : /* @__PURE__ */ jsx8(CloseOutlined, {
209
394
  style: {
210
395
  marginTop: "4px",
211
396
  color: "#ff4d4f"
212
397
  }
213
398
  });
214
399
  case "time":
215
- return /* @__PURE__ */ jsx3(Fragment, {
400
+ return /* @__PURE__ */ jsx8(Fragment3, {
216
401
  children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
217
402
  });
218
403
  case "date":
219
- return /* @__PURE__ */ jsx3(Fragment, {
404
+ return /* @__PURE__ */ jsx8(Fragment3, {
220
405
  children: computedProps.value.format("YYYY-MM-DD")
221
406
  });
222
407
  case "object":
223
408
  if (!computedProps.value)
224
- return /* @__PURE__ */ jsx3(Blank, {});
225
- return /* @__PURE__ */ jsx3(Description, {
409
+ return /* @__PURE__ */ jsx8(Blank, {});
410
+ return /* @__PURE__ */ jsx8(Description, {
226
411
  items: computedProps.item.object,
227
412
  dataSource: computedProps.value,
228
413
  column: 1
229
414
  });
230
415
  case "object[]":
231
416
  if (!((_a = computedProps.value) == null ? void 0 : _a.length))
232
- return /* @__PURE__ */ jsx3(Blank, {});
233
- return /* @__PURE__ */ jsx3(Space, {
417
+ return /* @__PURE__ */ jsx8(Blank, {});
418
+ return /* @__PURE__ */ jsx8(Space, {
234
419
  direction: "vertical",
235
- children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx3(Description, {
420
+ children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx8(Description, {
236
421
  items: computedProps.item.object,
237
422
  dataSource: value,
238
423
  column: 1
@@ -243,14 +428,14 @@ function DescriptionItemContent(props) {
243
428
  }
244
429
  }
245
430
  function Description(props) {
246
- if (!props.faasData)
247
- return /* @__PURE__ */ jsx3(Descriptions, {
431
+ if (props.dataSource)
432
+ return /* @__PURE__ */ jsx8(Descriptions, {
248
433
  ...props,
249
434
  title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
250
435
  children: props.items.map((item) => {
251
- return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
436
+ return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx8(Descriptions.Item, {
252
437
  label: item.title || upperFirst2(item.id),
253
- children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
438
+ children: /* @__PURE__ */ jsx8(DescriptionItemContent, {
254
439
  item,
255
440
  value: props.dataSource[item.id],
256
441
  values: props.dataSource,
@@ -259,18 +444,15 @@ function Description(props) {
259
444
  }, item.id) : null;
260
445
  }).filter(Boolean)
261
446
  });
262
- return /* @__PURE__ */ jsx3(FaasDataWrapper, {
263
- fallback: props.faasData.fallback || /* @__PURE__ */ jsx3(Skeleton, {
264
- active: true
265
- }),
447
+ return /* @__PURE__ */ jsx8(FaasDataWrapper, {
266
448
  render: ({ data }) => {
267
- return /* @__PURE__ */ jsx3(Descriptions, {
449
+ return /* @__PURE__ */ jsx8(Descriptions, {
268
450
  ...props,
269
451
  title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
270
452
  children: props.items.map((item) => {
271
- return !item.if || item.if(data) ? /* @__PURE__ */ jsx3(Descriptions.Item, {
453
+ return !item.if || item.if(data) ? /* @__PURE__ */ jsx8(Descriptions.Item, {
272
454
  label: item.title || upperFirst2(item.id),
273
- children: /* @__PURE__ */ jsx3(DescriptionItemContent, {
455
+ children: /* @__PURE__ */ jsx8(DescriptionItemContent, {
274
456
  item,
275
457
  value: data[item.id],
276
458
  values: data,
@@ -284,32 +466,52 @@ function Description(props) {
284
466
  });
285
467
  }
286
468
 
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
- }));
469
+ // src/ErrorBoundary.tsx
470
+ import { Component } from "react";
471
+ import { Alert } from "antd";
472
+ import { jsx as jsx9 } from "react/jsx-runtime";
473
+ var ErrorBoundary = class extends Component {
474
+ constructor(props) {
475
+ super(props);
476
+ this.state = {
477
+ error: void 0,
478
+ info: { componentStack: "" }
479
+ };
480
+ }
481
+ componentDidCatch(error, info) {
482
+ this.setState({
483
+ error,
484
+ info
485
+ });
486
+ }
487
+ render() {
488
+ const {
489
+ message: message2,
490
+ description,
491
+ children
492
+ } = this.props;
493
+ const { error, info } = this.state;
494
+ const componentStack = info && info.componentStack ? info.componentStack : null;
495
+ const errorMessage = typeof message2 === "undefined" ? (error || "").toString() : message2;
496
+ const errorDescription = typeof description === "undefined" ? componentStack : description;
497
+ if (error) {
498
+ if (this.props.onError)
499
+ return this.props.onError(error, info);
500
+ return /* @__PURE__ */ jsx9(Alert, {
501
+ type: "error",
502
+ message: errorMessage,
503
+ description: /* @__PURE__ */ jsx9("pre", {
504
+ style: {
505
+ fontSize: "0.9em",
506
+ overflowX: "auto"
507
+ },
508
+ children: errorDescription
509
+ })
510
+ });
310
511
  }
311
- };
312
- }
512
+ return children;
513
+ }
514
+ };
313
515
 
314
516
  // src/Form.tsx
315
517
  import { faas } from "@faasjs/react";
@@ -318,8 +520,8 @@ import {
318
520
  Form as AntdForm2
319
521
  } from "antd";
320
522
  import {
321
- useEffect as useEffect4,
322
- useState as useState5,
523
+ useEffect as useEffect5,
524
+ useState as useState6,
323
525
  useCallback,
324
526
  isValidElement
325
527
  } from "react";
@@ -339,11 +541,12 @@ import {
339
541
  } from "antd";
340
542
  import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
341
543
  import {
342
- useEffect as useEffect3,
343
- useState as useState4
544
+ cloneElement as cloneElement2,
545
+ useEffect as useEffect4,
546
+ useState as useState5
344
547
  } from "react";
345
548
  import { upperFirst as upperFirst3 } from "lodash-es";
346
- import { Fragment as Fragment2, jsx as jsx5, jsxs } from "react/jsx-runtime";
549
+ import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
347
550
  function processProps(propsCopy, config) {
348
551
  if (!propsCopy.title)
349
552
  propsCopy.title = upperFirst3(propsCopy.id);
@@ -392,11 +595,11 @@ function processProps(propsCopy, config) {
392
595
  }
393
596
  function FormItem(props) {
394
597
  var _a;
395
- const [computedProps, setComputedProps] = useState4();
396
- const [extendTypes, setExtendTypes] = useState4();
598
+ const [computedProps, setComputedProps] = useState5();
599
+ const [extendTypes, setExtendTypes] = useState5();
397
600
  const { common: common2 } = useConfigContext();
398
- const [hidden, setHidden] = useState4(props.hidden || false);
399
- useEffect3(() => {
601
+ const [hidden, setHidden] = useState5(props.hidden || false);
602
+ useEffect4(() => {
400
603
  const propsCopy = { ...props };
401
604
  if (propsCopy.extendTypes) {
402
605
  setExtendTypes(propsCopy.extendTypes);
@@ -404,98 +607,116 @@ function FormItem(props) {
404
607
  }
405
608
  if (propsCopy.if) {
406
609
  const condition = propsCopy.if;
407
- propsCopy.shouldUpdate = (_, cur) => {
610
+ const originShouldUpdate = propsCopy.shouldUpdate;
611
+ propsCopy.shouldUpdate = (prev, cur) => {
408
612
  const show = condition(cur);
613
+ const shouldUpdate = hidden !== show;
409
614
  setHidden(!show);
410
- return show;
615
+ const origin = originShouldUpdate ? typeof originShouldUpdate === "boolean" ? originShouldUpdate : originShouldUpdate(prev, cur, {}) : true;
616
+ return shouldUpdate || origin;
411
617
  };
412
618
  delete propsCopy.if;
619
+ delete propsCopy.hidden;
413
620
  }
414
621
  setComputedProps(processProps(propsCopy, common2));
415
622
  }, [props]);
416
623
  if (!computedProps)
417
624
  return null;
418
625
  if (hidden)
419
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
626
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
420
627
  ...computedProps,
421
628
  noStyle: true,
422
629
  rules: [],
423
- children: /* @__PURE__ */ jsx5(Input, {
630
+ children: /* @__PURE__ */ jsx10(Input, {
424
631
  hidden: true
425
632
  })
426
633
  });
427
634
  if (extendTypes && extendTypes[computedProps.type])
428
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
635
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
429
636
  ...computedProps,
430
637
  children: extendTypes[computedProps.type].children
431
638
  });
639
+ if (computedProps.formChildren === null)
640
+ return null;
641
+ if (computedProps.formChildren)
642
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
643
+ ...computedProps,
644
+ children: cloneElement2(computedProps.formChildren, { scene: "form" })
645
+ });
646
+ if (computedProps.children === null)
647
+ return null;
432
648
  if (computedProps.children)
433
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
649
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
650
+ ...computedProps,
651
+ children: cloneElement2(computedProps.children, { scene: "form" })
652
+ });
653
+ if (computedProps.formRender)
654
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
434
655
  ...computedProps,
435
- children: computedProps.children
656
+ children: computedProps.formRender(null, null, 0, "form")
436
657
  });
437
658
  if (computedProps.render)
438
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
659
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
439
660
  ...computedProps,
440
- children: computedProps.render()
661
+ children: computedProps.render(null, null, 0, "form")
441
662
  });
442
663
  switch (computedProps.type) {
443
664
  case "string":
444
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
665
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
445
666
  ...computedProps,
446
- children: computedProps.options ? /* @__PURE__ */ jsx5(Select, {
667
+ children: computedProps.options ? /* @__PURE__ */ jsx10(Select, {
447
668
  ...computedProps.input
448
- }) : /* @__PURE__ */ jsx5(Input, {
669
+ }) : /* @__PURE__ */ jsx10(Input, {
449
670
  ...computedProps.input
450
671
  })
451
672
  });
452
673
  case "string[]":
453
674
  if (computedProps.options)
454
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
675
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
455
676
  ...computedProps,
456
- children: /* @__PURE__ */ jsx5(Select, {
677
+ children: /* @__PURE__ */ jsx10(Select, {
457
678
  mode: "multiple",
458
679
  ...computedProps.input
459
680
  })
460
681
  });
461
- return /* @__PURE__ */ jsx5(AntdForm.List, {
682
+ return /* @__PURE__ */ jsx10(AntdForm.List, {
462
683
  name: computedProps.name,
463
684
  rules: computedProps.rules,
464
685
  children: (fields, { add, remove }, { errors }) => {
465
686
  var _a2;
466
- return /* @__PURE__ */ jsxs(Fragment2, {
687
+ return /* @__PURE__ */ jsxs2(Fragment4, {
467
688
  children: [
468
- computedProps.label && /* @__PURE__ */ jsx5("div", {
689
+ computedProps.label && /* @__PURE__ */ jsx10("div", {
469
690
  className: "ant-form-item-label",
470
- children: /* @__PURE__ */ jsx5("label", {
691
+ children: /* @__PURE__ */ jsx10("label", {
471
692
  className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
472
693
  children: computedProps.label
473
694
  })
474
695
  }),
475
696
  fields.map((field) => {
476
697
  var _a3;
477
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
478
- children: /* @__PURE__ */ jsxs(Row, {
698
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
699
+ children: /* @__PURE__ */ jsxs2(Row, {
479
700
  gutter: 24,
480
701
  style: { flexFlow: "row nowrap" },
481
702
  children: [
482
- /* @__PURE__ */ jsx5(Col, {
703
+ /* @__PURE__ */ jsx10(Col, {
483
704
  span: 23,
484
- children: /* @__PURE__ */ jsx5(AntdForm.Item, {
705
+ children: /* @__PURE__ */ jsx10(AntdForm.Item, {
485
706
  ...field,
486
707
  noStyle: true,
487
- children: /* @__PURE__ */ jsx5(Input, {
708
+ children: /* @__PURE__ */ jsx10(Input, {
488
709
  ...computedProps.input
489
710
  })
490
711
  })
491
712
  }),
492
- /* @__PURE__ */ jsx5(Col, {
713
+ /* @__PURE__ */ jsx10(Col, {
493
714
  span: 1,
494
- children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
715
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
495
716
  danger: true,
496
717
  type: "link",
497
718
  style: { float: "right" },
498
- icon: /* @__PURE__ */ jsx5(MinusCircleOutlined, {}),
719
+ icon: /* @__PURE__ */ jsx10(MinusCircleOutlined, {}),
499
720
  onClick: () => remove(field.name)
500
721
  })
501
722
  })
@@ -503,15 +724,19 @@ function FormItem(props) {
503
724
  })
504
725
  }, field.key);
505
726
  }),
506
- /* @__PURE__ */ jsxs(AntdForm.Item, {
727
+ /* @__PURE__ */ jsxs2(AntdForm.Item, {
507
728
  children: [
508
- !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx5(Button, {
729
+ !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx10(Button, {
509
730
  type: "dashed",
510
731
  block: true,
511
732
  onClick: () => add(),
512
- icon: /* @__PURE__ */ jsx5(PlusOutlined, {})
733
+ icon: /* @__PURE__ */ jsx10(PlusOutlined, {})
734
+ }),
735
+ computedProps.extra && /* @__PURE__ */ jsx10("div", {
736
+ className: "ant-form-item-extra",
737
+ children: computedProps.extra
513
738
  }),
514
- /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
739
+ /* @__PURE__ */ jsx10(AntdForm.ErrorList, {
515
740
  errors
516
741
  })
517
742
  ]
@@ -521,63 +746,63 @@ function FormItem(props) {
521
746
  }
522
747
  });
523
748
  case "number":
524
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
749
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
525
750
  ...computedProps,
526
- children: computedProps.options ? /* @__PURE__ */ jsx5(Select, {
751
+ children: computedProps.options ? /* @__PURE__ */ jsx10(Select, {
527
752
  ...computedProps.input
528
- }) : /* @__PURE__ */ jsx5(InputNumber, {
753
+ }) : /* @__PURE__ */ jsx10(InputNumber, {
529
754
  style: { width: "100%" },
530
755
  ...computedProps.input
531
756
  })
532
757
  });
533
758
  case "number[]":
534
759
  if (computedProps.options)
535
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
760
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
536
761
  ...computedProps,
537
- children: /* @__PURE__ */ jsx5(Select, {
762
+ children: /* @__PURE__ */ jsx10(Select, {
538
763
  mode: "multiple",
539
764
  ...computedProps.input
540
765
  })
541
766
  });
542
- return /* @__PURE__ */ jsx5(AntdForm.List, {
767
+ return /* @__PURE__ */ jsx10(AntdForm.List, {
543
768
  name: computedProps.name,
544
769
  rules: computedProps.rules,
545
770
  children: (fields, { add, remove }, { errors }) => {
546
771
  var _a2, _b;
547
- return /* @__PURE__ */ jsxs(Fragment2, {
772
+ return /* @__PURE__ */ jsxs2(Fragment4, {
548
773
  children: [
549
- computedProps.label && /* @__PURE__ */ jsx5("div", {
774
+ computedProps.label && /* @__PURE__ */ jsx10("div", {
550
775
  className: "ant-form-item-label",
551
- children: /* @__PURE__ */ jsx5("label", {
776
+ children: /* @__PURE__ */ jsx10("label", {
552
777
  className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required",
553
778
  children: computedProps.label
554
779
  })
555
780
  }),
556
781
  fields.map((field) => {
557
782
  var _a3;
558
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
559
- children: /* @__PURE__ */ jsxs(Row, {
783
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
784
+ children: /* @__PURE__ */ jsxs2(Row, {
560
785
  gutter: 24,
561
786
  style: { flexFlow: "row nowrap" },
562
787
  children: [
563
- /* @__PURE__ */ jsx5(Col, {
788
+ /* @__PURE__ */ jsx10(Col, {
564
789
  span: 23,
565
- children: /* @__PURE__ */ jsx5(AntdForm.Item, {
790
+ children: /* @__PURE__ */ jsx10(AntdForm.Item, {
566
791
  ...field,
567
792
  noStyle: true,
568
- children: /* @__PURE__ */ jsx5(InputNumber, {
793
+ children: /* @__PURE__ */ jsx10(InputNumber, {
569
794
  style: { width: "100%" },
570
795
  ...computedProps.input
571
796
  })
572
797
  })
573
798
  }),
574
- /* @__PURE__ */ jsx5(Col, {
799
+ /* @__PURE__ */ jsx10(Col, {
575
800
  span: 1,
576
- children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
801
+ children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
577
802
  danger: true,
578
803
  type: "link",
579
804
  style: { float: "right" },
580
- icon: /* @__PURE__ */ jsx5(MinusCircleOutlined, {}),
805
+ icon: /* @__PURE__ */ jsx10(MinusCircleOutlined, {}),
581
806
  onClick: () => remove(field.name)
582
807
  })
583
808
  })
@@ -585,15 +810,19 @@ function FormItem(props) {
585
810
  })
586
811
  }, field.key);
587
812
  }),
588
- /* @__PURE__ */ jsxs(AntdForm.Item, {
813
+ /* @__PURE__ */ jsxs2(AntdForm.Item, {
589
814
  children: [
590
- !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx5(Button, {
815
+ !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx10(Button, {
591
816
  type: "dashed",
592
817
  block: true,
593
818
  onClick: () => add(),
594
- icon: /* @__PURE__ */ jsx5(PlusOutlined, {})
819
+ icon: /* @__PURE__ */ jsx10(PlusOutlined, {})
595
820
  }),
596
- /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
821
+ computedProps.extra && /* @__PURE__ */ jsx10("div", {
822
+ className: "ant-form-item-extra",
823
+ children: computedProps.extra
824
+ }),
825
+ /* @__PURE__ */ jsx10(AntdForm.ErrorList, {
597
826
  errors
598
827
  })
599
828
  ]
@@ -603,58 +832,58 @@ function FormItem(props) {
603
832
  }
604
833
  });
605
834
  case "boolean":
606
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
835
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
607
836
  ...computedProps,
608
- children: /* @__PURE__ */ jsx5(Switch, {
837
+ children: /* @__PURE__ */ jsx10(Switch, {
609
838
  ...computedProps.input
610
839
  })
611
840
  });
612
841
  case "date":
613
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
842
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
614
843
  ...computedProps,
615
- children: /* @__PURE__ */ jsx5(DatePicker, {
844
+ children: /* @__PURE__ */ jsx10(DatePicker, {
616
845
  ...computedProps.input
617
846
  })
618
847
  });
619
848
  case "time":
620
- return /* @__PURE__ */ jsx5(AntdForm.Item, {
849
+ return /* @__PURE__ */ jsx10(AntdForm.Item, {
621
850
  ...computedProps,
622
- children: /* @__PURE__ */ jsx5(TimePicker, {
851
+ children: /* @__PURE__ */ jsx10(TimePicker, {
623
852
  ...computedProps.input
624
853
  })
625
854
  });
626
855
  case "object":
627
- return /* @__PURE__ */ jsxs(Fragment2, {
856
+ return /* @__PURE__ */ jsxs2(Fragment4, {
628
857
  children: [
629
- computedProps.label && /* @__PURE__ */ jsx5("div", {
858
+ computedProps.label && /* @__PURE__ */ jsx10("div", {
630
859
  className: "ant-form-item-label",
631
- children: /* @__PURE__ */ jsx5("label", {
860
+ children: /* @__PURE__ */ jsx10("label", {
632
861
  className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
633
862
  children: computedProps.label
634
863
  })
635
864
  }),
636
- computedProps.object.map((o) => /* @__PURE__ */ jsx5(FormItem, {
865
+ computedProps.object.map((o) => /* @__PURE__ */ jsx10(FormItem, {
637
866
  ...o
638
867
  }, o.id))
639
868
  ]
640
869
  });
641
870
  case "object[]":
642
- return /* @__PURE__ */ jsx5(AntdForm.List, {
871
+ return /* @__PURE__ */ jsx10(AntdForm.List, {
643
872
  name: computedProps.name,
644
873
  rules: computedProps.rules,
645
- children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(Fragment2, {
874
+ children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs2(Fragment4, {
646
875
  children: [
647
- fields.map((field) => /* @__PURE__ */ jsxs(AntdForm.Item, {
876
+ fields.map((field) => /* @__PURE__ */ jsxs2(AntdForm.Item, {
648
877
  style: { marginBottom: 0 },
649
878
  children: [
650
- /* @__PURE__ */ jsx5("div", {
879
+ /* @__PURE__ */ jsx10("div", {
651
880
  className: "ant-form-item-label",
652
- children: /* @__PURE__ */ jsxs("label", {
881
+ children: /* @__PURE__ */ jsxs2("label", {
653
882
  children: [
654
883
  computedProps.label,
655
884
  " ",
656
885
  field.name + 1,
657
- !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx5(Button, {
886
+ !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
658
887
  danger: true,
659
888
  type: "link",
660
889
  onClick: () => remove(field.name),
@@ -663,11 +892,11 @@ function FormItem(props) {
663
892
  ]
664
893
  })
665
894
  }),
666
- /* @__PURE__ */ jsx5(Row, {
895
+ /* @__PURE__ */ jsx10(Row, {
667
896
  gutter: 24,
668
- children: computedProps.object.map((o) => /* @__PURE__ */ jsx5(Col, {
897
+ children: computedProps.object.map((o) => /* @__PURE__ */ jsx10(Col, {
669
898
  span: o.col || 24,
670
- children: /* @__PURE__ */ jsx5(FormItem, {
899
+ children: /* @__PURE__ */ jsx10(FormItem, {
671
900
  ...o,
672
901
  name: [field.name, o.id]
673
902
  })
@@ -675,20 +904,24 @@ function FormItem(props) {
675
904
  })
676
905
  ]
677
906
  }, field.key)),
678
- /* @__PURE__ */ jsxs(AntdForm.Item, {
907
+ /* @__PURE__ */ jsxs2(AntdForm.Item, {
679
908
  children: [
680
- !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxs(Button, {
909
+ !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxs2(Button, {
681
910
  type: "dashed",
682
911
  block: true,
683
912
  onClick: () => add(),
684
- icon: /* @__PURE__ */ jsx5(PlusOutlined, {}),
913
+ icon: /* @__PURE__ */ jsx10(PlusOutlined, {}),
685
914
  children: [
686
915
  common2.add,
687
916
  " ",
688
917
  computedProps.label
689
918
  ]
690
919
  }),
691
- /* @__PURE__ */ jsx5(AntdForm.ErrorList, {
920
+ computedProps.extra && /* @__PURE__ */ jsx10("div", {
921
+ className: "ant-form-item-extra",
922
+ children: computedProps.extra
923
+ }),
924
+ /* @__PURE__ */ jsx10(AntdForm.ErrorList, {
692
925
  errors
693
926
  })
694
927
  ]
@@ -700,27 +933,28 @@ function FormItem(props) {
700
933
  return null;
701
934
  }
702
935
  }
936
+ FormItem.useStatus = AntdForm.Item.useStatus;
703
937
 
704
938
  // src/Form.tsx
705
- import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
939
+ import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
706
940
  function Form(props) {
707
941
  var _a, _b;
708
- const [loading, setLoading] = useState5(false);
709
- const [computedProps, setComputedProps] = useState5();
942
+ const [loading, setLoading] = useState6(false);
943
+ const [computedProps, setComputedProps] = useState6();
710
944
  const config = useConfigContext();
711
- const [extendTypes, setExtendTypes] = useState5();
945
+ const [extendTypes, setExtendTypes] = useState6();
712
946
  const [form] = AntdForm2.useForm(props.form);
713
- const [initialValues, setInitialValues] = useState5(props.initialValues);
714
- useEffect4(() => {
715
- var _a2, _b2;
947
+ const [initialValues, setInitialValues] = useState6(props.initialValues);
948
+ useEffect5(() => {
949
+ var _a2, _b2, _c;
716
950
  const propsCopy = {
717
951
  ...props,
718
952
  form
719
953
  };
720
- if (propsCopy.initialValues) {
954
+ if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
721
955
  for (const key in propsCopy.initialValues) {
722
956
  propsCopy.initialValues[key] = transferValue(
723
- (_a2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _a2.type,
957
+ (_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
724
958
  propsCopy.initialValues[key]
725
959
  );
726
960
  const item = propsCopy.items.find((item2) => item2.id === key);
@@ -751,13 +985,25 @@ function Form(props) {
751
985
  }
752
986
  setLoading(false);
753
987
  };
754
- } else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
988
+ } else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
755
989
  propsCopy.onFinish = async (values) => {
756
990
  setLoading(true);
757
991
  return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
758
992
  ...values,
759
993
  ...propsCopy.submit.to.params
760
- } : values).finally(() => setLoading(false));
994
+ } : values).then((result) => {
995
+ if (propsCopy.submit.to.then)
996
+ propsCopy.submit.to.then(result);
997
+ return result;
998
+ }).catch((error) => {
999
+ if (propsCopy.submit.to.catch)
1000
+ propsCopy.submit.to.catch(error);
1001
+ return Promise.reject(error);
1002
+ }).finally(() => {
1003
+ if (propsCopy.submit.to.finally)
1004
+ propsCopy.submit.to.finally();
1005
+ setLoading(false);
1006
+ });
761
1007
  };
762
1008
  }
763
1009
  if (propsCopy.extendTypes) {
@@ -779,7 +1025,7 @@ function Form(props) {
779
1025
  item.onValueChange(changedValues[key], allValues, form);
780
1026
  }
781
1027
  }, [computedProps]);
782
- useEffect4(() => {
1028
+ useEffect5(() => {
783
1029
  if (!initialValues)
784
1030
  return;
785
1031
  console.debug("Form:initialValues", initialValues);
@@ -788,17 +1034,17 @@ function Form(props) {
788
1034
  }, [computedProps]);
789
1035
  if (!computedProps)
790
1036
  return null;
791
- return /* @__PURE__ */ jsxs2(AntdForm2, {
1037
+ return /* @__PURE__ */ jsxs3(AntdForm2, {
792
1038
  ...computedProps,
793
1039
  onValuesChange,
794
1040
  children: [
795
1041
  computedProps.beforeItems,
796
- (_a = computedProps.items) == null ? void 0 : _a.map((item) => isValidElement(item) ? item : /* @__PURE__ */ jsx6(FormItem, {
1042
+ (_a = computedProps.items) == null ? void 0 : _a.map((item) => isValidElement(item) ? item : /* @__PURE__ */ jsx11(FormItem, {
797
1043
  ...item,
798
1044
  extendTypes
799
1045
  }, item.id)),
800
1046
  computedProps.children,
801
- computedProps.submit !== false && /* @__PURE__ */ jsx6(Button2, {
1047
+ computedProps.submit !== false && /* @__PURE__ */ jsx11(Button2, {
802
1048
  htmlType: "submit",
803
1049
  type: "primary",
804
1050
  loading,
@@ -809,98 +1055,66 @@ function Form(props) {
809
1055
  });
810
1056
  }
811
1057
  Form.useForm = AntdForm2.useForm;
1058
+ Form.useFormInstance = AntdForm2.useFormInstance;
1059
+ Form.useWatch = AntdForm2.useWatch;
1060
+ Form.Item = FormItem;
1061
+ Form.List = AntdForm2.List;
1062
+ Form.ErrorList = AntdForm2.ErrorList;
1063
+ Form.Provider = AntdForm2.Provider;
812
1064
 
813
1065
  // src/Link.tsx
814
1066
  import { Link as RouterLink } from "react-router-dom";
815
1067
  import { Button as Button3 } from "antd";
816
- import { jsx as jsx7 } from "react/jsx-runtime";
817
- function Link({
818
- href,
819
- target,
820
- text,
821
- children,
822
- style,
823
- button
824
- }) {
1068
+ import { jsx as jsx12 } from "react/jsx-runtime";
1069
+ function Link(props) {
1070
+ var _a, _b, _c, _d;
825
1071
  const { Link: Link2 } = useConfigContext();
826
- style = Object.assign({ cursor: "pointer" }, style);
827
- if (href.startsWith("http")) {
828
- if (button)
829
- return /* @__PURE__ */ jsx7(Button3, {
830
- ...button,
831
- children: /* @__PURE__ */ jsx7("a", {
832
- href,
833
- target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
834
- style: {
835
- ...Link2.style,
836
- ...style || {}
837
- },
838
- children: text || children
839
- })
1072
+ let style = {
1073
+ ...Link2.style || {},
1074
+ cursor: "pointer",
1075
+ ...props.style
1076
+ };
1077
+ if (props.block)
1078
+ style = Object.assign({
1079
+ display: "block",
1080
+ width: "100%"
1081
+ }, style);
1082
+ if (props.href.startsWith("http")) {
1083
+ if (props.button)
1084
+ return /* @__PURE__ */ jsx12(Button3, {
1085
+ ...props.button,
1086
+ target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
1087
+ style,
1088
+ href: props.href,
1089
+ children: (_a = props.text) != null ? _a : props.children
840
1090
  });
841
- return /* @__PURE__ */ jsx7("a", {
842
- href,
843
- target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
844
- style: {
845
- ...Link2.style,
846
- ...style || {}
847
- },
848
- children: text || children
1091
+ return /* @__PURE__ */ jsx12("a", {
1092
+ href: props.href,
1093
+ target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
1094
+ style,
1095
+ children: (_b = props.text) != null ? _b : props.children
849
1096
  });
850
1097
  }
851
- if (button)
852
- return /* @__PURE__ */ jsx7(Button3, {
853
- ...button,
854
- children: /* @__PURE__ */ jsx7(RouterLink, {
855
- to: href,
856
- target: target || (Link2 == null ? void 0 : Link2.target),
857
- style: {
858
- ...Link2.style,
859
- ...style || {}
860
- },
861
- children: text || children
1098
+ if (props.button)
1099
+ return /* @__PURE__ */ jsx12(RouterLink, {
1100
+ to: props.href,
1101
+ target: props.target || (Link2 == null ? void 0 : Link2.target),
1102
+ children: /* @__PURE__ */ jsx12(Button3, {
1103
+ ...props.button,
1104
+ style,
1105
+ children: (_c = props.text) != null ? _c : props.children
862
1106
  })
863
1107
  });
864
- return /* @__PURE__ */ jsx7(RouterLink, {
865
- to: href,
866
- target: target || (Link2 == null ? void 0 : Link2.target),
867
- style: {
868
- ...Link2.style,
869
- ...style || {}
870
- },
871
- children: text || children
872
- });
873
- }
874
-
875
- // src/Modal.tsx
876
- import { Modal } from "antd";
877
- import { useState as useState6 } from "react";
878
- import { jsx as jsx8 } from "react/jsx-runtime";
879
- function useModal(init) {
880
- const [props, setProps] = useState6({
881
- open: false,
882
- onCancel: () => setProps((prev) => ({
883
- ...prev,
884
- open: false
885
- })),
886
- ...init
1108
+ return /* @__PURE__ */ jsx12(RouterLink, {
1109
+ to: props.href,
1110
+ target: props.target || (Link2 == null ? void 0 : Link2.target),
1111
+ style,
1112
+ children: (_d = props.text) != null ? _d : props.children
887
1113
  });
888
- return {
889
- modal: /* @__PURE__ */ jsx8(Modal, {
890
- ...props
891
- }),
892
- modalProps: props,
893
- setModalProps(changes) {
894
- setProps((prev) => ({
895
- ...prev,
896
- ...changes
897
- }));
898
- }
899
- };
900
1114
  }
901
1115
 
902
1116
  // src/Routers.tsx
903
- import { Result, Skeleton as Skeleton2 } from "antd";
1117
+ import { Result, Skeleton } from "antd";
904
1118
  import {
905
1119
  Suspense
906
1120
  } from "react";
@@ -908,32 +1122,33 @@ import {
908
1122
  Routes as OriginRoutes,
909
1123
  Route
910
1124
  } from "react-router-dom";
911
- import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
1125
+ import { lazy } from "react";
1126
+ import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
912
1127
  function PageNotFound() {
913
1128
  const config = useConfigContext();
914
- return /* @__PURE__ */ jsx9(Result, {
1129
+ return /* @__PURE__ */ jsx13(Result, {
915
1130
  status: "404",
916
1131
  title: config.common.pageNotFound
917
1132
  });
918
1133
  }
919
1134
  function Routes(props) {
920
- return /* @__PURE__ */ jsxs3(OriginRoutes, {
1135
+ return /* @__PURE__ */ jsxs4(OriginRoutes, {
921
1136
  children: [
922
- props.routes.map((r) => /* @__PURE__ */ jsx9(Route, {
1137
+ props.routes.map((r) => /* @__PURE__ */ jsx13(Route, {
923
1138
  ...r,
924
- element: r.element || /* @__PURE__ */ jsx9(Suspense, {
925
- fallback: props.fallback || /* @__PURE__ */ jsx9("div", {
1139
+ element: r.element || /* @__PURE__ */ jsx13(Suspense, {
1140
+ fallback: props.fallback || /* @__PURE__ */ jsx13("div", {
926
1141
  style: { padding: "24px" },
927
- children: /* @__PURE__ */ jsx9(Skeleton2, {
1142
+ children: /* @__PURE__ */ jsx13(Skeleton, {
928
1143
  active: true
929
1144
  })
930
1145
  }),
931
- children: /* @__PURE__ */ jsx9(r.page, {})
1146
+ children: /* @__PURE__ */ jsx13(r.page, {})
932
1147
  })
933
1148
  }, r.path)),
934
- /* @__PURE__ */ jsx9(Route, {
1149
+ /* @__PURE__ */ jsx13(Route, {
935
1150
  path: "*",
936
- element: props.notFound || /* @__PURE__ */ jsx9(PageNotFound, {})
1151
+ element: props.notFound || /* @__PURE__ */ jsx13(PageNotFound, {})
937
1152
  }, "*")
938
1153
  ]
939
1154
  });
@@ -942,15 +1157,13 @@ function Routes(props) {
942
1157
  // src/Table.tsx
943
1158
  import {
944
1159
  useState as useState7,
945
- useEffect as useEffect5,
946
- cloneElement as cloneElement2
1160
+ useEffect as useEffect6,
1161
+ cloneElement as cloneElement3
947
1162
  } from "react";
948
1163
  import {
949
1164
  Table as AntdTable,
950
1165
  Radio,
951
- Skeleton as Skeleton3,
952
- Input as Input2,
953
- ConfigProvider as ConfigProvider2
1166
+ Input as Input2
954
1167
  } from "antd";
955
1168
  import dayjs2 from "dayjs";
956
1169
  import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
@@ -959,13 +1172,12 @@ import {
959
1172
  uniqBy,
960
1173
  upperFirst as upperFirst4
961
1174
  } from "lodash-es";
962
- import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
963
- import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
1175
+ import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
964
1176
  function processValue(item, value) {
965
1177
  var _a;
966
1178
  const transferred = transferValue(item.type, value);
967
1179
  if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
968
- return /* @__PURE__ */ jsx10(Blank, {});
1180
+ return /* @__PURE__ */ jsx14(Blank, {});
969
1181
  if (item.options) {
970
1182
  if (item.type.endsWith("[]"))
971
1183
  return transferred.map((v) => {
@@ -987,8 +1199,8 @@ function processValue(item, value) {
987
1199
  }
988
1200
  function Table(props) {
989
1201
  const [columns, setColumns] = useState7();
990
- const { common: common2, antd } = useConfigContext();
991
- useEffect5(() => {
1202
+ const { common: common2 } = useConfigContext();
1203
+ useEffect6(() => {
992
1204
  var _a;
993
1205
  for (const item of props.items) {
994
1206
  if (!item.key)
@@ -1004,15 +1216,39 @@ function Table(props) {
1004
1216
  item.filters = item.options.map((o) => ({
1005
1217
  text: o.label,
1006
1218
  value: o.value
1007
- }));
1219
+ })).concat({
1220
+ text: /* @__PURE__ */ jsx14(Blank, {}),
1221
+ value: null
1222
+ });
1008
1223
  }
1009
- if (item.children)
1010
- delete item.children;
1224
+ if (item.tableChildren === null)
1225
+ item.render = () => null;
1226
+ else if (item.tableChildren)
1227
+ item.render = (value, values) => cloneElement3(
1228
+ item.tableChildren,
1229
+ {
1230
+ scene: "table",
1231
+ value,
1232
+ values
1233
+ }
1234
+ );
1235
+ else if (item.children === null)
1236
+ item.render = () => null;
1237
+ else if (item.children)
1238
+ item.render = (value, values) => cloneElement3(
1239
+ item.children,
1240
+ {
1241
+ scene: "table",
1242
+ value,
1243
+ values
1244
+ }
1245
+ );
1011
1246
  if (props.extendTypes && props.extendTypes[item.type]) {
1012
1247
  if (props.extendTypes[item.type].children)
1013
- item.render = (value, values) => cloneElement2(
1248
+ item.render = (value, values) => cloneElement3(
1014
1249
  props.extendTypes[item.type].children,
1015
1250
  {
1251
+ scene: "table",
1016
1252
  value,
1017
1253
  values
1018
1254
  }
@@ -1031,16 +1267,18 @@ function Table(props) {
1031
1267
  item.onFilter = (value, row) => {
1032
1268
  if (value === null && isNil2(row[item.id]))
1033
1269
  return true;
1034
- if (!row[item.id])
1270
+ if (!row[item.id] || !value)
1035
1271
  return false;
1036
1272
  return row[item.id].toLowerCase().includes(value.toLowerCase());
1037
1273
  };
1038
- if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
1274
+ if (item.filterDropdown === false || item.filterDropdown)
1275
+ break;
1276
+ if (!item.filters && item.optionsType !== "auto")
1039
1277
  item.filterDropdown = ({
1040
1278
  setSelectedKeys,
1041
1279
  confirm,
1042
1280
  clearFilters
1043
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1281
+ }) => /* @__PURE__ */ jsx14(Input2.Search, {
1044
1282
  placeholder: `${common2.search} ${item.title}`,
1045
1283
  allowClear: true,
1046
1284
  onSearch: (v) => {
@@ -1061,16 +1299,18 @@ function Table(props) {
1061
1299
  item.onFilter = (value, row) => {
1062
1300
  if (value === null && (!row[item.id] || !row[item.id].length))
1063
1301
  return true;
1064
- if (!row[item.id] || !row[item.id].length)
1302
+ if (!row[item.id] || !row[item.id].length || !value)
1065
1303
  return false;
1066
1304
  return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
1067
1305
  };
1068
- if (!item.filters && item.filterDropdown !== false)
1306
+ if (item.filterDropdown === false || item.filterDropdown)
1307
+ break;
1308
+ if (!item.filters && item.optionsType !== "auto")
1069
1309
  item.filterDropdown = ({
1070
1310
  setSelectedKeys,
1071
1311
  confirm,
1072
1312
  clearFilters
1073
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1313
+ }) => /* @__PURE__ */ jsx14(Input2.Search, {
1074
1314
  placeholder: `${common2.search} ${item.title}`,
1075
1315
  allowClear: true,
1076
1316
  onSearch: (v) => {
@@ -1093,14 +1333,16 @@ function Table(props) {
1093
1333
  item.onFilter = (value, row) => {
1094
1334
  if (value === null && isNil2(row[item.id]))
1095
1335
  return true;
1096
- return value === row[item.id];
1336
+ return value == row[item.id];
1097
1337
  };
1098
- if (!item.filters && item.filterDropdown !== false)
1338
+ if (item.filterDropdown === false || item.filterDropdown)
1339
+ break;
1340
+ if (!item.filters)
1099
1341
  item.filterDropdown = ({
1100
1342
  setSelectedKeys,
1101
1343
  confirm,
1102
1344
  clearFilters
1103
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1345
+ }) => /* @__PURE__ */ jsx14(Input2.Search, {
1104
1346
  placeholder: `${common2.search} ${item.title}`,
1105
1347
  allowClear: true,
1106
1348
  onSearch: (v) => {
@@ -1123,14 +1365,16 @@ function Table(props) {
1123
1365
  return true;
1124
1366
  if (!row[item.id] || !row[item.id].length)
1125
1367
  return false;
1126
- return row[item.id].includes(value);
1368
+ return row[item.id].includes(Number(value));
1127
1369
  };
1128
- if (!item.filters && item.filterDropdown !== false)
1370
+ if (item.filterDropdown === false || item.filterDropdown)
1371
+ break;
1372
+ if (!item.filters)
1129
1373
  item.filterDropdown = ({
1130
1374
  setSelectedKeys,
1131
1375
  confirm,
1132
1376
  clearFilters
1133
- }) => /* @__PURE__ */ jsx10(Input2.Search, {
1377
+ }) => /* @__PURE__ */ jsx14(Input2.Search, {
1134
1378
  placeholder: `${common2.search} ${item.title}`,
1135
1379
  allowClear: true,
1136
1380
  onSearch: (v) => {
@@ -1146,12 +1390,12 @@ function Table(props) {
1146
1390
  break;
1147
1391
  case "boolean":
1148
1392
  if (!item.render)
1149
- item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ jsx10(Blank, {}) : value ? /* @__PURE__ */ jsx10(CheckOutlined2, {
1393
+ item.render = (value) => isNil2(value) ? /* @__PURE__ */ jsx14(Blank, {}) : value ? /* @__PURE__ */ jsx14(CheckOutlined2, {
1150
1394
  style: {
1151
1395
  marginTop: "4px",
1152
1396
  color: "#52c41a"
1153
1397
  }
1154
- }) : /* @__PURE__ */ jsx10(CloseOutlined2, {
1398
+ }) : /* @__PURE__ */ jsx14(CloseOutlined2, {
1155
1399
  style: {
1156
1400
  marginTop: "4px",
1157
1401
  color: "#ff4d4f"
@@ -1162,38 +1406,43 @@ function Table(props) {
1162
1406
  setSelectedKeys,
1163
1407
  selectedKeys,
1164
1408
  confirm
1165
- }) => /* @__PURE__ */ jsxs4(Radio.Group, {
1409
+ }) => /* @__PURE__ */ jsxs5(Radio.Group, {
1166
1410
  style: { padding: 8 },
1167
1411
  buttonStyle: "solid",
1168
1412
  value: selectedKeys[0],
1169
1413
  onChange: (e) => {
1170
- setSelectedKeys(e.target.value ? [e.target.value] : []);
1414
+ const Values = {
1415
+ true: true,
1416
+ false: false,
1417
+ null: null
1418
+ };
1419
+ setSelectedKeys(e.target.value ? [Values[e.target.value]] : []);
1171
1420
  confirm();
1172
1421
  },
1173
1422
  children: [
1174
- /* @__PURE__ */ jsx10(Radio.Button, {
1423
+ /* @__PURE__ */ jsx14(Radio.Button, {
1175
1424
  children: common2.all
1176
1425
  }),
1177
- /* @__PURE__ */ jsx10(Radio.Button, {
1426
+ /* @__PURE__ */ jsx14(Radio.Button, {
1178
1427
  value: "true",
1179
- children: /* @__PURE__ */ jsx10(CheckOutlined2, {
1428
+ children: /* @__PURE__ */ jsx14(CheckOutlined2, {
1180
1429
  style: {
1181
1430
  color: "#52c41a",
1182
1431
  verticalAlign: "middle"
1183
1432
  }
1184
1433
  })
1185
1434
  }),
1186
- /* @__PURE__ */ jsx10(Radio.Button, {
1435
+ /* @__PURE__ */ jsx14(Radio.Button, {
1187
1436
  value: "false",
1188
- children: /* @__PURE__ */ jsx10(CloseOutlined2, {
1437
+ children: /* @__PURE__ */ jsx14(CloseOutlined2, {
1189
1438
  style: {
1190
1439
  verticalAlign: "middle",
1191
1440
  color: "#ff4d4f"
1192
1441
  }
1193
1442
  })
1194
1443
  }),
1195
- /* @__PURE__ */ jsx10(Radio.Button, {
1196
- value: "empty",
1444
+ /* @__PURE__ */ jsx14(Radio.Button, {
1445
+ value: "null",
1197
1446
  children: common2.blank
1198
1447
  })
1199
1448
  ]
@@ -1201,14 +1450,12 @@ function Table(props) {
1201
1450
  if (!item.onFilter)
1202
1451
  item.onFilter = (value, row) => {
1203
1452
  switch (value) {
1204
- case "true":
1205
- return !isNil2(row[item.id]) && !!row[item.id];
1206
- case "false":
1453
+ case true:
1454
+ return !isNil2(row[item.id]) && row[item.id] !== false;
1455
+ case false:
1207
1456
  return !isNil2(row[item.id]) && !row[item.id];
1208
- case "empty":
1209
- return isNil2(row[item.id]);
1210
1457
  default:
1211
- return true;
1458
+ return isNil2(row[item.id]);
1212
1459
  }
1213
1460
  };
1214
1461
  break;
@@ -1216,9 +1463,15 @@ function Table(props) {
1216
1463
  if (!item.render)
1217
1464
  item.render = (value) => processValue(item, value);
1218
1465
  if (!item.onFilter)
1219
- item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
1466
+ item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value), "date");
1220
1467
  if (!item.sorter)
1221
- item.sorter = (a, b) => dayjs2(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1468
+ item.sorter = (a, b, order) => {
1469
+ if (isNil2(a[item.id]))
1470
+ return order === "ascend" ? 1 : -1;
1471
+ if (isNil2(b[item.id]))
1472
+ return order === "ascend" ? -1 : 1;
1473
+ return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
1474
+ };
1222
1475
  break;
1223
1476
  case "time":
1224
1477
  if (!item.render)
@@ -1226,11 +1479,17 @@ function Table(props) {
1226
1479
  if (!item.onFilter)
1227
1480
  item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
1228
1481
  if (!item.sorter)
1229
- item.sorter = (a, b) => dayjs2(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1482
+ item.sorter = (a, b, order) => {
1483
+ if (isNil2(a[item.id]))
1484
+ return order === "ascend" ? 1 : -1;
1485
+ if (isNil2(b[item.id]))
1486
+ return order === "ascend" ? -1 : 1;
1487
+ return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
1488
+ };
1230
1489
  break;
1231
1490
  case "object":
1232
1491
  if (!item.render)
1233
- item.render = (value) => /* @__PURE__ */ jsx10(Description, {
1492
+ item.render = (value) => /* @__PURE__ */ jsx14(Description, {
1234
1493
  items: item.object,
1235
1494
  dataSource: value || {},
1236
1495
  column: 1
@@ -1238,11 +1497,13 @@ function Table(props) {
1238
1497
  break;
1239
1498
  case "object[]":
1240
1499
  if (!item.render)
1241
- item.render = (value) => value.map((v, i) => /* @__PURE__ */ jsx10(Description, {
1242
- items: item.object,
1243
- dataSource: v || [],
1244
- column: 1
1245
- }, i));
1500
+ item.render = (value) => /* @__PURE__ */ jsx14(Fragment5, {
1501
+ children: value.map((v, i) => /* @__PURE__ */ jsx14(Description, {
1502
+ items: item.object,
1503
+ dataSource: v || [],
1504
+ column: 1
1505
+ }, i))
1506
+ });
1246
1507
  break;
1247
1508
  default:
1248
1509
  if (!item.render)
@@ -1258,147 +1519,182 @@ function Table(props) {
1258
1519
  }
1259
1520
  setColumns(props.items);
1260
1521
  }, [props.items]);
1261
- useEffect5(() => {
1522
+ useEffect6(() => {
1262
1523
  if (!props.dataSource || !columns)
1263
1524
  return;
1264
1525
  for (const column of columns) {
1265
1526
  if (column.optionsType === "auto" && !column.options && !column.filters) {
1266
- setColumns((prev) => {
1267
- const newColumns = [...prev];
1268
- const index = newColumns.findIndex((item) => item.id === column.id);
1269
- newColumns[index].filters = uniqBy(props.dataSource, column.id).map((v) => ({
1270
- text: v[column.id],
1271
- value: v[column.id]
1272
- })).concat({
1273
- text: /* @__PURE__ */ jsx10(Blank, {}),
1274
- value: null
1527
+ const filters = uniqBy(props.dataSource, column.id).map((v) => ({
1528
+ text: v[column.id],
1529
+ value: v[column.id]
1530
+ }));
1531
+ if (filters.length)
1532
+ setColumns((prev) => {
1533
+ const newColumns = [...prev];
1534
+ const index = newColumns.findIndex((item) => item.id === column.id);
1535
+ newColumns[index].filters = filters.concat({
1536
+ text: /* @__PURE__ */ jsx14(Blank, {}),
1537
+ value: null
1538
+ });
1539
+ return newColumns;
1275
1540
  });
1276
- return newColumns;
1277
- });
1278
1541
  }
1279
1542
  }
1280
1543
  }, [props.dataSource, columns]);
1281
1544
  if (!columns)
1282
1545
  return null;
1283
- if (!props.faasData)
1284
- return /* @__PURE__ */ jsx10(ConfigProvider2, {
1285
- ...antd,
1286
- children: /* @__PURE__ */ jsx10(AntdTable, {
1287
- ...props,
1288
- rowKey: props.rowKey || "id",
1289
- columns,
1290
- dataSource: props.dataSource
1291
- })
1546
+ if (props.dataSource)
1547
+ return /* @__PURE__ */ jsx14(AntdTable, {
1548
+ ...props,
1549
+ rowKey: props.rowKey || "id",
1550
+ columns,
1551
+ dataSource: props.dataSource
1292
1552
  });
1293
- return /* @__PURE__ */ jsx10(FaasDataWrapper2, {
1294
- fallback: props.faasData.fallback || /* @__PURE__ */ jsx10(Skeleton3, {
1295
- active: true
1296
- }),
1297
- render: ({
1298
- data,
1299
- params,
1300
- reload
1301
- }) => {
1302
- if (!data)
1303
- return /* @__PURE__ */ jsx10(ConfigProvider2, {
1304
- ...antd,
1305
- children: /* @__PURE__ */ jsx10(AntdTable, {
1306
- ...props,
1307
- rowKey: props.rowKey || "id",
1308
- columns,
1309
- dataSource: []
1310
- })
1311
- });
1312
- if (Array.isArray(data))
1313
- return /* @__PURE__ */ jsx10(ConfigProvider2, {
1314
- ...antd,
1315
- children: /* @__PURE__ */ jsx10(AntdTable, {
1316
- ...props,
1317
- rowKey: props.rowKey || "id",
1318
- columns,
1319
- dataSource: data
1320
- })
1321
- });
1322
- return /* @__PURE__ */ jsx10(ConfigProvider2, {
1323
- ...antd,
1324
- children: /* @__PURE__ */ jsx10(AntdTable, {
1325
- ...props,
1326
- rowKey: props.rowKey || "id",
1327
- columns,
1328
- dataSource: data.rows,
1329
- pagination: {
1330
- ...props.pagination,
1331
- ...data.pagination
1332
- },
1333
- onChange: (pagination, filters, sorter, extra) => {
1334
- if (props.onChange) {
1335
- const processed = props.onChange(pagination, filters, sorter, extra);
1336
- reload({
1337
- ...params,
1338
- pagination: processed.pagination,
1339
- filters: processed.filters,
1340
- sorter: processed.sorter
1341
- });
1342
- return;
1343
- }
1344
- reload({
1345
- ...params,
1346
- pagination,
1347
- filters,
1348
- sorter
1553
+ return /* @__PURE__ */ jsx14(FaasDataWrapper, {
1554
+ ...props.faasData,
1555
+ children: /* @__PURE__ */ jsx14(FaasDataTable, {
1556
+ props,
1557
+ columns
1558
+ })
1559
+ });
1560
+ }
1561
+ function FaasDataTable({
1562
+ props,
1563
+ columns,
1564
+ data,
1565
+ params,
1566
+ reload
1567
+ }) {
1568
+ const [currentColumns, setCurrentColumns] = useState7(columns);
1569
+ useEffect6(() => {
1570
+ if (!data || Array.isArray(data))
1571
+ return;
1572
+ setCurrentColumns((prev) => {
1573
+ const newColumns = [...prev];
1574
+ for (const column of newColumns) {
1575
+ if (data["options"] && data.options[column.id]) {
1576
+ column.options = data["options"][column.id];
1577
+ column.filters = data["options"][column.id].map((v) => ({
1578
+ text: v.label,
1579
+ value: v.value
1580
+ })).concat({
1581
+ text: /* @__PURE__ */ jsx14(Blank, {}),
1582
+ value: null
1583
+ });
1584
+ column.render = (value) => processValue(column, value);
1585
+ if (column.filterDropdown)
1586
+ delete column.filterDropdown;
1587
+ continue;
1588
+ }
1589
+ if (column.optionsType === "auto" && !column.options && !column.filters) {
1590
+ const filters = uniqBy(props.dataSource, column.id).map((v) => ({
1591
+ text: v[column.id],
1592
+ value: v[column.id]
1593
+ }));
1594
+ if (filters.length)
1595
+ column.filters = filters.concat({
1596
+ text: /* @__PURE__ */ jsx14(Blank, {}),
1597
+ value: null
1349
1598
  });
1350
- }
1351
- })
1352
- });
1599
+ }
1600
+ }
1601
+ return newColumns;
1602
+ });
1603
+ }, [columns, data]);
1604
+ if (!data)
1605
+ return /* @__PURE__ */ jsx14(AntdTable, {
1606
+ ...props,
1607
+ rowKey: props.rowKey || "id",
1608
+ columns: currentColumns,
1609
+ dataSource: []
1610
+ });
1611
+ if (Array.isArray(data))
1612
+ return /* @__PURE__ */ jsx14(AntdTable, {
1613
+ ...props,
1614
+ rowKey: props.rowKey || "id",
1615
+ columns: currentColumns,
1616
+ dataSource: data
1617
+ });
1618
+ return /* @__PURE__ */ jsx14(AntdTable, {
1619
+ ...props,
1620
+ rowKey: props.rowKey || "id",
1621
+ columns: currentColumns,
1622
+ dataSource: data.rows,
1623
+ pagination: {
1624
+ ...props.pagination,
1625
+ ...data.pagination
1353
1626
  },
1354
- ...props.faasData
1627
+ onChange: (pagination, filters, sorter, extra) => {
1628
+ if (props.onChange) {
1629
+ const processed = props.onChange(pagination, filters, sorter, extra);
1630
+ reload({
1631
+ ...params,
1632
+ pagination: processed.pagination,
1633
+ filters: processed.filters,
1634
+ sorter: processed.sorter
1635
+ });
1636
+ return;
1637
+ }
1638
+ reload({
1639
+ ...params,
1640
+ pagination,
1641
+ filters,
1642
+ sorter
1643
+ });
1644
+ }
1355
1645
  });
1356
1646
  }
1357
1647
 
1358
1648
  // src/Title.tsx
1359
- import { useEffect as useEffect6, cloneElement as cloneElement3 } from "react";
1360
- import { Fragment as Fragment3, jsx as jsx11 } from "react/jsx-runtime";
1649
+ import { useEffect as useEffect7, cloneElement as cloneElement4 } from "react";
1650
+ import { Fragment as Fragment6, jsx as jsx15 } from "react/jsx-runtime";
1361
1651
  function Title(props) {
1362
1652
  const { Title: Title2 } = useConfigContext();
1363
- useEffect6(() => {
1653
+ useEffect7(() => {
1364
1654
  const title = Array.isArray(props.title) ? props.title : [props.title];
1365
1655
  document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
1366
1656
  }, [props]);
1367
1657
  if (props.h1) {
1368
1658
  if (typeof props.h1 === "boolean")
1369
- return /* @__PURE__ */ jsx11("h1", {
1659
+ return /* @__PURE__ */ jsx15("h1", {
1370
1660
  children: Array.isArray(props.title) ? props.title[0] : props.title
1371
1661
  });
1372
- return /* @__PURE__ */ jsx11("h1", {
1662
+ return /* @__PURE__ */ jsx15("h1", {
1373
1663
  className: props.h1.className,
1374
1664
  style: props.h1.style,
1375
1665
  children: Array.isArray(props.title) ? props.title[0] : props.title
1376
1666
  });
1377
1667
  }
1378
1668
  if (props.plain)
1379
- return /* @__PURE__ */ jsx11(Fragment3, {
1669
+ return /* @__PURE__ */ jsx15(Fragment6, {
1380
1670
  children: Array.isArray(props.title) ? props.title[0] : props.title
1381
1671
  });
1382
1672
  if (props.children)
1383
- return cloneElement3(props.children, { title: props.title });
1673
+ return cloneElement4(props.children, { title: props.title });
1384
1674
  return null;
1385
1675
  }
1386
1676
  export {
1677
+ App,
1387
1678
  Blank,
1388
1679
  ConfigContext,
1389
- ConfigProvider,
1680
+ ConfigProvider2 as ConfigProvider,
1390
1681
  Description,
1391
1682
  Drawer,
1683
+ ErrorBoundary,
1684
+ FaasDataWrapper,
1392
1685
  Form,
1393
1686
  FormItem,
1394
1687
  Link,
1688
+ Loading,
1395
1689
  Modal,
1396
1690
  PageNotFound,
1397
1691
  Routes,
1398
1692
  Table,
1399
1693
  Title,
1694
+ lazy,
1400
1695
  transferOptions,
1401
1696
  transferValue,
1697
+ useApp,
1402
1698
  useConfigContext,
1403
1699
  useDrawer,
1404
1700
  useModal