@faasjs/ant-design 0.0.3-beta.7 → 0.0.3-beta.70

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