@faasjs/ant-design 0.0.3-beta.8 → 0.0.3-beta.81

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