@faasjs/ant-design 0.0.3-beta.9 → 0.0.3-beta.90

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