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

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