@faasjs/ant-design 0.0.3-beta.10 → 0.0.3-beta.100

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,148 @@ 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
+ if (props.faasData && !props.dataSource)
336
+ return /* @__PURE__ */ jsxRuntime.jsx(
337
+ FaasDataWrapper,
338
+ {
339
+ render: ({ data }) => /* @__PURE__ */ jsxRuntime.jsx(
340
+ Description,
341
+ {
342
+ ...props,
343
+ dataSource: data
344
+ }
345
+ ),
346
+ ...props.faasData
347
+ }
348
+ );
349
+ return /* @__PURE__ */ jsxRuntime.jsx(
350
+ antd.Descriptions,
351
+ {
284
352
  ...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, {
353
+ title: lodashEs.isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
354
+ items: props.items.filter((item) => item && (!item.if || item.if(props.dataSource))).map((item) => ({
355
+ ...item,
356
+ key: item.id,
357
+ label: item.title || lodashEs.upperFirst(item.id),
358
+ children: /* @__PURE__ */ jsxRuntime.jsx(
359
+ DescriptionItemContent,
360
+ {
290
361
  item,
291
- value: props.dataSource[item.id],
362
+ value: props.dataSource ? props.dataSource[item.id] : null,
292
363
  values: props.dataSource,
293
364
  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,
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
- });
365
+ }
366
+ )
367
+ }))
368
+ }
369
+ );
321
370
  }
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, {
371
+ function ErrorChildren(props) {
372
+ return /* @__PURE__ */ jsxRuntime.jsx(
373
+ antd.Alert,
374
+ {
375
+ type: "error",
376
+ message: props.errorMessage,
377
+ description: /* @__PURE__ */ jsxRuntime.jsx("pre", { style: {
378
+ fontSize: "0.9em",
379
+ overflowX: "auto"
380
+ }, children: props.errorDescription })
381
+ }
382
+ );
383
+ }
384
+ function ErrorBoundary(props) {
385
+ return /* @__PURE__ */ jsxRuntime.jsx(
386
+ react.ErrorBoundary,
387
+ {
388
+ errorChildren: /* @__PURE__ */ jsxRuntime.jsx(ErrorChildren, {}),
338
389
  ...props
339
- }),
340
- drawerProps: props,
341
- setDrawerProps(changes) {
342
- setProps((prev) => ({
343
- ...prev,
344
- ...changes
345
- }));
346
390
  }
347
- };
391
+ );
348
392
  }
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");
361
393
  function processProps(propsCopy, config) {
362
394
  if (!propsCopy.title)
363
- propsCopy.title = (0, import_lodash_es5.upperFirst)(propsCopy.id);
395
+ propsCopy.title = lodashEs.upperFirst(propsCopy.id);
364
396
  if (!propsCopy.label && propsCopy.label !== false)
365
397
  propsCopy.label = propsCopy.title;
366
398
  if (!propsCopy.name)
@@ -406,11 +438,11 @@ function processProps(propsCopy, config) {
406
438
  }
407
439
  function FormItem(props) {
408
440
  var _a;
409
- const [computedProps, setComputedProps] = (0, import_react6.useState)();
410
- const [extendTypes, setExtendTypes] = (0, import_react6.useState)();
441
+ const [computedProps, setComputedProps] = react$1.useState();
442
+ const [extendTypes, setExtendTypes] = react$1.useState();
411
443
  const { common: common2 } = useConfigContext();
412
- const [hidden, setHidden] = (0, import_react6.useState)(props.hidden || false);
413
- (0, import_react6.useEffect)(() => {
444
+ const [hidden, setHidden] = react$1.useState(props.hidden || false);
445
+ react$1.useEffect(() => {
414
446
  const propsCopy = { ...props };
415
447
  if (propsCopy.extendTypes) {
416
448
  setExtendTypes(propsCopy.extendTypes);
@@ -434,311 +466,285 @@ function FormItem(props) {
434
466
  if (!computedProps)
435
467
  return null;
436
468
  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
- });
469
+ return /* @__PURE__ */ jsxRuntime.jsx(
470
+ antd.Form.Item,
471
+ {
472
+ ...computedProps,
473
+ noStyle: true,
474
+ rules: [],
475
+ children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { hidden: true })
476
+ }
477
+ );
445
478
  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
- });
479
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: extendTypes[computedProps.type].children });
480
+ if (computedProps.formChildren === null)
481
+ return null;
482
+ if (computedProps.formChildren)
483
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: react$1.cloneElement(computedProps.formChildren, { scene: "form" }) });
484
+ if (computedProps.children === null)
485
+ return null;
450
486
  if (computedProps.children)
451
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
452
- ...computedProps,
453
- children: computedProps.children
454
- });
487
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: react$1.cloneElement(computedProps.children, { scene: "form" }) });
488
+ if (computedProps.formRender)
489
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: computedProps.formRender(null, null, 0, "form") });
455
490
  if (computedProps.render)
456
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.Item, {
457
- ...computedProps,
458
- children: computedProps.render()
459
- });
491
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: computedProps.render(null, null, 0, "form") });
460
492
  switch (computedProps.type) {
461
493
  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
- });
494
+ if (computedProps.options)
495
+ 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 }) });
496
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { ...computedProps.input }) });
470
497
  case "string[]":
471
498
  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, {
499
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(
500
+ antd.Select,
501
+ {
475
502
  mode: "multiple",
476
503
  ...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
- }),
504
+ }
505
+ ) });
506
+ return /* @__PURE__ */ jsxRuntime.jsx(
507
+ antd.Form.List,
508
+ {
509
+ name: computedProps.name,
510
+ rules: computedProps.rules,
511
+ children: (fields, { add, remove }, { errors }) => {
512
+ var _a2;
513
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
514
+ 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
515
  fields.map((field) => {
494
516
  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, {
517
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(
518
+ antd.Row,
519
+ {
497
520
  gutter: 24,
498
521
  style: { flexFlow: "row nowrap" },
499
522
  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, {
523
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 23, children: /* @__PURE__ */ jsxRuntime.jsx(
524
+ antd.Form.Item,
525
+ {
503
526
  ...field,
504
527
  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, {
528
+ children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { ...computedProps.input })
529
+ }
530
+ ) }),
531
+ /* @__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(
532
+ antd.Button,
533
+ {
513
534
  danger: true,
514
535
  type: "link",
515
536
  style: { float: "right" },
516
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.MinusCircleOutlined, {}),
537
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
517
538
  onClick: () => remove(field.name)
518
- })
519
- })
539
+ }
540
+ ) })
520
541
  ]
521
- })
522
- }, field.key);
542
+ }
543
+ ) }, field.key);
523
544
  }),
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, {
545
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
546
+ !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsx(
547
+ antd.Button,
548
+ {
527
549
  type: "dashed",
528
550
  block: true,
529
551
  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
- });
552
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {})
553
+ }
554
+ ),
555
+ computedProps.extra && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
556
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Form.ErrorList, { errors })
557
+ ] })
558
+ ] });
559
+ }
539
560
  }
540
- });
561
+ );
541
562
  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, {
563
+ if (computedProps.options)
564
+ 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 }) });
565
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(
566
+ antd.InputNumber,
567
+ {
547
568
  style: { width: "100%" },
548
569
  ...computedProps.input
549
- })
550
- });
570
+ }
571
+ ) });
551
572
  case "number[]":
552
573
  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, {
574
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(
575
+ antd.Select,
576
+ {
556
577
  mode: "multiple",
557
578
  ...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
- }),
579
+ }
580
+ ) });
581
+ return /* @__PURE__ */ jsxRuntime.jsx(
582
+ antd.Form.List,
583
+ {
584
+ name: computedProps.name,
585
+ rules: computedProps.rules,
586
+ children: (fields, { add, remove }, { errors }) => {
587
+ var _a2, _b;
588
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
589
+ 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
590
  fields.map((field) => {
575
591
  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, {
592
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(
593
+ antd.Row,
594
+ {
578
595
  gutter: 24,
579
596
  style: { flexFlow: "row nowrap" },
580
597
  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, {
598
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 23, children: /* @__PURE__ */ jsxRuntime.jsx(
599
+ antd.Form.Item,
600
+ {
584
601
  ...field,
585
602
  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, {
603
+ children: /* @__PURE__ */ jsxRuntime.jsx(
604
+ antd.InputNumber,
605
+ {
606
+ style: { width: "100%" },
607
+ ...computedProps.input
608
+ }
609
+ )
610
+ }
611
+ ) }),
612
+ /* @__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(
613
+ antd.Button,
614
+ {
595
615
  danger: true,
596
616
  type: "link",
597
617
  style: { float: "right" },
598
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.MinusCircleOutlined, {}),
618
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
599
619
  onClick: () => remove(field.name)
600
- })
601
- })
620
+ }
621
+ ) })
602
622
  ]
603
- })
604
- }, field.key);
623
+ }
624
+ ) }, field.key);
605
625
  }),
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, {
626
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
627
+ !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsx(
628
+ antd.Button,
629
+ {
609
630
  type: "dashed",
610
631
  block: true,
611
632
  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
- });
633
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {})
634
+ }
635
+ ),
636
+ computedProps.extra && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
637
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Form.ErrorList, { errors })
638
+ ] })
639
+ ] });
640
+ }
621
641
  }
622
- });
642
+ );
623
643
  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
- });
644
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Switch, { ...computedProps.input }) });
630
645
  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
- });
646
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.DatePicker, { ...computedProps.input }) });
637
647
  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
- });
648
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.TimePicker, { ...computedProps.input }) });
644
649
  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, {
650
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
651
+ 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 }) }),
652
+ computedProps.object.map((o) => /* @__PURE__ */ jsxRuntime.jsx(
653
+ FormItem,
654
+ {
655
655
  ...o
656
- }, o.id))
657
- ]
658
- });
656
+ },
657
+ o.id
658
+ ))
659
+ ] });
659
660
  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, {
661
+ return /* @__PURE__ */ jsxRuntime.jsx(
662
+ antd.Form.List,
663
+ {
664
+ name: computedProps.name,
665
+ rules: computedProps.rules,
666
+ children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
667
+ fields.map((field) => /* @__PURE__ */ jsxRuntime.jsxs(
668
+ antd.Form.Item,
669
+ {
670
+ style: { marginBottom: 0 },
671
+ children: [
672
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
673
+ computedProps.label,
674
+ " ",
675
+ field.name + 1,
676
+ !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsxRuntime.jsx(
677
+ antd.Button,
678
+ {
676
679
  danger: true,
677
680
  type: "link",
678
681
  onClick: () => remove(field.name),
679
682
  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, {
683
+ }
684
+ )
685
+ ] }) }),
686
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: 24, children: computedProps.object.map((o) => /* @__PURE__ */ jsxRuntime.jsx(
687
+ antd.Col,
688
+ {
689
+ span: o.col || 24,
690
+ children: /* @__PURE__ */ jsxRuntime.jsx(
691
+ FormItem,
692
+ {
693
+ ...o,
694
+ name: [field.name, o.id]
695
+ }
696
+ )
697
+ },
698
+ o.id
699
+ )) })
700
+ ]
701
+ },
702
+ field.key
703
+ )),
704
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
705
+ !computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsxs(
706
+ antd.Button,
707
+ {
699
708
  type: "dashed",
700
709
  block: true,
701
710
  onClick: () => add(),
702
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {}),
711
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}),
703
712
  children: [
704
713
  common2.add,
705
714
  " ",
706
715
  computedProps.label
707
716
  ]
708
- }),
709
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Form.ErrorList, {
710
- errors
711
- })
712
- ]
713
- })
714
- ]
715
- })
716
- });
717
+ }
718
+ ),
719
+ computedProps.extra && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
720
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Form.ErrorList, { errors })
721
+ ] })
722
+ ] })
723
+ }
724
+ );
717
725
  default:
718
726
  return null;
719
727
  }
720
728
  }
721
-
722
- // src/Form.tsx
723
- var import_jsx_runtime = require("react/jsx-runtime");
729
+ FormItem.useStatus = antd.Form.Item.useStatus;
724
730
  function Form(props) {
725
731
  var _a, _b;
726
- const [loading, setLoading] = (0, import_react8.useState)(false);
727
- const [computedProps, setComputedProps] = (0, import_react8.useState)();
732
+ const [loading, setLoading] = react$1.useState(false);
733
+ const [computedProps, setComputedProps] = react$1.useState();
728
734
  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;
735
+ const [extendTypes, setExtendTypes] = react$1.useState();
736
+ const [form] = antd.Form.useForm(props.form);
737
+ const [initialValues, setInitialValues] = react$1.useState(props.initialValues);
738
+ react$1.useEffect(() => {
739
+ var _a2, _b2, _c;
734
740
  const propsCopy = {
735
741
  ...props,
736
742
  form
737
743
  };
738
- if (propsCopy.initialValues) {
744
+ if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
739
745
  for (const key in propsCopy.initialValues) {
740
746
  propsCopy.initialValues[key] = transferValue(
741
- (_a2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _a2.type,
747
+ (_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
742
748
  propsCopy.initialValues[key]
743
749
  );
744
750
  const item = propsCopy.items.find((item2) => item2.id === key);
@@ -758,7 +764,7 @@ function Form(props) {
758
764
  setLoading(true);
759
765
  try {
760
766
  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 ? {
767
+ await props.onFinish(values, async (values2) => react.faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
762
768
  ...values2,
763
769
  ...propsCopy.submit.to.params
764
770
  } : values2));
@@ -769,13 +775,25 @@ function Form(props) {
769
775
  }
770
776
  setLoading(false);
771
777
  };
772
- } else if (propsCopy.submit && ((_b2 = propsCopy.submit.to) == null ? void 0 : _b2.action)) {
778
+ } else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
773
779
  propsCopy.onFinish = async (values) => {
774
780
  setLoading(true);
775
- return (0, import_react7.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
781
+ return react.faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
776
782
  ...values,
777
783
  ...propsCopy.submit.to.params
778
- } : values).finally(() => setLoading(false));
784
+ } : values).then((result) => {
785
+ if (propsCopy.submit.to.then)
786
+ propsCopy.submit.to.then(result);
787
+ return result;
788
+ }).catch((error) => {
789
+ if (propsCopy.submit.to.catch)
790
+ propsCopy.submit.to.catch(error);
791
+ return Promise.reject(error);
792
+ }).finally(() => {
793
+ if (propsCopy.submit.to.finally)
794
+ propsCopy.submit.to.finally();
795
+ setLoading(false);
796
+ });
779
797
  };
780
798
  }
781
799
  if (propsCopy.extendTypes) {
@@ -784,7 +802,7 @@ function Form(props) {
784
802
  }
785
803
  setComputedProps(propsCopy);
786
804
  }, [props]);
787
- const onValuesChange = (0, import_react8.useCallback)((changedValues, allValues) => {
805
+ const onValuesChange = react$1.useCallback((changedValues, allValues) => {
788
806
  console.debug("Form:onValuesChange", changedValues, allValues);
789
807
  if (props.onValuesChange) {
790
808
  props.onValuesChange(changedValues, allValues);
@@ -797,7 +815,7 @@ function Form(props) {
797
815
  item.onValueChange(changedValues[key], allValues, form);
798
816
  }
799
817
  }, [computedProps]);
800
- (0, import_react8.useEffect)(() => {
818
+ react$1.useEffect(() => {
801
819
  if (!initialValues)
802
820
  return;
803
821
  console.debug("Form:initialValues", initialValues);
@@ -806,165 +824,163 @@ function Form(props) {
806
824
  }, [computedProps]);
807
825
  if (!computedProps)
808
826
  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
- });
828
- }
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
- }) {
843
- 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 || {}
827
+ return /* @__PURE__ */ jsxRuntime.jsxs(
828
+ antd.Form,
829
+ {
830
+ ...computedProps,
831
+ onValuesChange,
832
+ children: [
833
+ computedProps.beforeItems,
834
+ (_a = computedProps.items) == null ? void 0 : _a.map((item) => react$1.isValidElement(item) ? item : /* @__PURE__ */ jsxRuntime.jsx(
835
+ FormItem,
836
+ {
837
+ ...item,
838
+ extendTypes
855
839
  },
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
- });
868
- }
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
- }));
840
+ item.id
841
+ )),
842
+ computedProps.children,
843
+ computedProps.submit !== false && /* @__PURE__ */ jsxRuntime.jsx(
844
+ antd.Button,
845
+ {
846
+ htmlType: "submit",
847
+ type: "primary",
848
+ loading,
849
+ children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text
850
+ }
851
+ ),
852
+ computedProps.footer
853
+ ]
916
854
  }
855
+ );
856
+ }
857
+ Form.useForm = antd.Form.useForm;
858
+ Form.useFormInstance = antd.Form.useFormInstance;
859
+ Form.useWatch = antd.Form.useWatch;
860
+ Form.Item = FormItem;
861
+ Form.List = antd.Form.List;
862
+ Form.ErrorList = antd.Form.ErrorList;
863
+ Form.Provider = antd.Form.Provider;
864
+ function Link(props) {
865
+ var _a, _b;
866
+ const { Link: Config } = useConfigContext();
867
+ const navigate = reactRouterDom.useNavigate();
868
+ let style = {
869
+ ...Config.style || {},
870
+ cursor: "pointer",
871
+ ...props.style
917
872
  };
873
+ if (props.block)
874
+ style = Object.assign({
875
+ display: "block",
876
+ width: "100%"
877
+ }, style);
878
+ if (props.href.startsWith("http")) {
879
+ if (props.button)
880
+ return /* @__PURE__ */ jsxRuntime.jsx(
881
+ antd.Button,
882
+ {
883
+ ...props.button,
884
+ target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
885
+ style,
886
+ href: props.href,
887
+ children: (_a = props.text) != null ? _a : props.children
888
+ }
889
+ );
890
+ if (props.children)
891
+ return /* @__PURE__ */ jsxRuntime.jsx(
892
+ "a",
893
+ {
894
+ href: props.href,
895
+ target: props.target || (Config == null ? void 0 : Config.target),
896
+ style,
897
+ children: props.children
898
+ }
899
+ );
900
+ return /* @__PURE__ */ jsxRuntime.jsx(
901
+ antd.Typography.Link,
902
+ {
903
+ href: props.href,
904
+ target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
905
+ style,
906
+ copyable: props.copyable,
907
+ children: props.text
908
+ }
909
+ );
910
+ }
911
+ if (props.button)
912
+ return /* @__PURE__ */ jsxRuntime.jsx(
913
+ antd.Button,
914
+ {
915
+ ...props.button,
916
+ style,
917
+ onClick: () => (props.target || (Config == null ? void 0 : Config.target)) === "_blank" ? window.open(props.href) : navigate(props.href),
918
+ children: (_b = props.text) != null ? _b : props.children
919
+ }
920
+ );
921
+ if (props.children)
922
+ return /* @__PURE__ */ jsxRuntime.jsx(
923
+ reactRouterDom.Link,
924
+ {
925
+ to: props.href,
926
+ target: props.target || (Config == null ? void 0 : Config.target),
927
+ style,
928
+ children: props.children
929
+ }
930
+ );
931
+ return /* @__PURE__ */ jsxRuntime.jsx(
932
+ antd.Typography.Link,
933
+ {
934
+ href: props.href,
935
+ target: props.target || (Config == null ? void 0 : Config.target),
936
+ style,
937
+ copyable: props.copyable,
938
+ onClick: (e) => {
939
+ e.preventDefault();
940
+ if ((props.target || (Config == null ? void 0 : Config.target)) === "_blank")
941
+ window.open(props.href);
942
+ else
943
+ navigate(props.href);
944
+ },
945
+ children: props.text
946
+ }
947
+ );
918
948
  }
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
949
  function PageNotFound() {
926
950
  const config = useConfigContext();
927
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Result, {
928
- status: "404",
929
- title: config.common.pageNotFound
930
- });
951
+ return /* @__PURE__ */ jsxRuntime.jsx(
952
+ antd.Result,
953
+ {
954
+ status: "404",
955
+ title: config.common.pageNotFound
956
+ }
957
+ );
931
958
  }
932
959
  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, {
960
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
961
+ props.routes.map((r) => /* @__PURE__ */ jsxRuntime.jsx(
962
+ reactRouterDom.Route,
963
+ {
936
964
  ...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, {
965
+ 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, {}) })
966
+ },
967
+ r.path
968
+ )),
969
+ /* @__PURE__ */ jsxRuntime.jsx(
970
+ reactRouterDom.Route,
971
+ {
948
972
  path: "*",
949
- element: props.notFound || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageNotFound, {})
950
- }, "*")
951
- ]
952
- });
973
+ element: props.notFound || /* @__PURE__ */ jsxRuntime.jsx(PageNotFound, {})
974
+ },
975
+ "*"
976
+ )
977
+ ] });
953
978
  }
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
979
  function processValue(item, value) {
964
980
  var _a;
965
981
  const transferred = transferValue(item.type, value);
966
982
  if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
967
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
983
+ return /* @__PURE__ */ jsxRuntime.jsx(Blank, {});
968
984
  if (item.options) {
969
985
  if (item.type.endsWith("[]"))
970
986
  return transferred.map((v) => {
@@ -985,9 +1001,58 @@ function processValue(item, value) {
985
1001
  return value;
986
1002
  }
987
1003
  function Table(props) {
988
- const [columns, setColumns] = (0, import_react11.useState)();
989
- const { common: common2, antd } = useConfigContext();
990
- (0, import_react11.useEffect)(() => {
1004
+ const [columns, setColumns] = react$1.useState();
1005
+ const { common: common2 } = useConfigContext();
1006
+ const generateFilterDropdown = (item) => {
1007
+ if (typeof item.filterDropdown !== "undefined")
1008
+ return;
1009
+ if (item.options.length < 11) {
1010
+ if (!item.filters)
1011
+ item.filters = item.options.map((o) => ({
1012
+ text: o.label,
1013
+ value: o.value
1014
+ }));
1015
+ return;
1016
+ }
1017
+ item.filterDropdown = ({
1018
+ setSelectedKeys,
1019
+ selectedKeys,
1020
+ confirm
1021
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1022
+ "div",
1023
+ {
1024
+ style: {
1025
+ padding: 8,
1026
+ width: "200px"
1027
+ },
1028
+ onKeyDown: (e) => e.stopPropagation(),
1029
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1030
+ antd.Select,
1031
+ {
1032
+ options: item.options,
1033
+ allowClear: true,
1034
+ showSearch: true,
1035
+ style: { width: "100%" },
1036
+ placeholder: `${common2.search} ${item.title}`,
1037
+ value: selectedKeys,
1038
+ onChange: (v) => {
1039
+ setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
1040
+ confirm();
1041
+ },
1042
+ mode: "multiple",
1043
+ filterOption: (input, option) => {
1044
+ if (!input || !option || !option.label)
1045
+ return true;
1046
+ input = input.trim();
1047
+ return option.value === input || option.label.toString().toLowerCase().includes(input.toLowerCase());
1048
+ }
1049
+ }
1050
+ )
1051
+ }
1052
+ );
1053
+ return item;
1054
+ };
1055
+ react$1.useEffect(() => {
991
1056
  var _a;
992
1057
  for (const item of props.items) {
993
1058
  if (!item.key)
@@ -995,7 +1060,7 @@ function Table(props) {
995
1060
  if (!item.dataIndex)
996
1061
  item.dataIndex = item.id;
997
1062
  if (!item.title)
998
- item.title = (0, import_lodash_es6.upperFirst)(item.id);
1063
+ item.title = lodashEs.upperFirst(item.id);
999
1064
  if (!item.type)
1000
1065
  item.type = "string";
1001
1066
  if ((_a = item.options) == null ? void 0 : _a.length) {
@@ -1003,15 +1068,40 @@ function Table(props) {
1003
1068
  item.filters = item.options.map((o) => ({
1004
1069
  text: o.label,
1005
1070
  value: o.value
1006
- }));
1071
+ })).concat({
1072
+ text: /* @__PURE__ */ jsxRuntime.jsx(Blank, {}),
1073
+ value: null
1074
+ });
1075
+ generateFilterDropdown(item);
1007
1076
  }
1008
- if (item.children)
1009
- delete item.children;
1077
+ if (item.tableChildren === null)
1078
+ item.render = () => null;
1079
+ else if (item.tableChildren)
1080
+ item.render = (value, values) => react$1.cloneElement(
1081
+ item.tableChildren,
1082
+ {
1083
+ scene: "table",
1084
+ value,
1085
+ values
1086
+ }
1087
+ );
1088
+ else if (item.children === null)
1089
+ item.render = () => null;
1090
+ else if (item.children)
1091
+ item.render = (value, values) => react$1.cloneElement(
1092
+ item.children,
1093
+ {
1094
+ scene: "table",
1095
+ value,
1096
+ values
1097
+ }
1098
+ );
1010
1099
  if (props.extendTypes && props.extendTypes[item.type]) {
1011
1100
  if (props.extendTypes[item.type].children)
1012
- item.render = (value, values) => (0, import_react11.cloneElement)(
1101
+ item.render = (value, values) => react$1.cloneElement(
1013
1102
  props.extendTypes[item.type].children,
1014
1103
  {
1104
+ scene: "table",
1015
1105
  value,
1016
1106
  values
1017
1107
  }
@@ -1028,30 +1118,35 @@ function Table(props) {
1028
1118
  item.render = (value) => processValue(item, value);
1029
1119
  if (!item.onFilter)
1030
1120
  item.onFilter = (value, row) => {
1031
- if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
1121
+ if (!value || lodashEs.isNil(value))
1032
1122
  return true;
1033
- if (!row[item.id])
1123
+ if (lodashEs.isNil(row[item.id]))
1034
1124
  return false;
1035
- return row[item.id].toLowerCase().includes(value.toLowerCase());
1125
+ return row[item.id].trim().toLowerCase().includes(value.trim().toLowerCase());
1036
1126
  };
1037
- if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
1127
+ if (item.filterDropdown === false || item.filterDropdown)
1128
+ break;
1129
+ if (!item.filters && item.optionsType !== "auto")
1038
1130
  item.filterDropdown = ({
1039
1131
  setSelectedKeys,
1040
1132
  confirm,
1041
1133
  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();
1134
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1135
+ antd.Input.Search,
1136
+ {
1137
+ placeholder: `${common2.search} ${item.title}`,
1138
+ allowClear: true,
1139
+ onSearch: (v) => {
1140
+ if (v) {
1141
+ setSelectedKeys([v]);
1142
+ } else {
1143
+ setSelectedKeys([]);
1144
+ clearFilters();
1145
+ }
1146
+ confirm();
1051
1147
  }
1052
- confirm();
1053
1148
  }
1054
- });
1149
+ );
1055
1150
  break;
1056
1151
  case "string[]":
1057
1152
  if (!item.render)
@@ -1060,28 +1155,33 @@ function Table(props) {
1060
1155
  item.onFilter = (value, row) => {
1061
1156
  if (value === null && (!row[item.id] || !row[item.id].length))
1062
1157
  return true;
1063
- if (!row[item.id] || !row[item.id].length)
1158
+ if (!row[item.id] || !row[item.id].length || !value)
1064
1159
  return false;
1065
- return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
1160
+ return row[item.id].some((v) => v.trim().toLowerCase().includes(value.trim().toLowerCase()));
1066
1161
  };
1067
- if (!item.filters && item.filterDropdown !== false)
1162
+ if (item.filterDropdown === false || item.filterDropdown)
1163
+ break;
1164
+ if (!item.filters && item.optionsType !== "auto")
1068
1165
  item.filterDropdown = ({
1069
1166
  setSelectedKeys,
1070
1167
  confirm,
1071
1168
  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();
1169
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1170
+ antd.Input.Search,
1171
+ {
1172
+ placeholder: `${common2.search} ${item.title}`,
1173
+ allowClear: true,
1174
+ onSearch: (v) => {
1175
+ if (v) {
1176
+ setSelectedKeys([v]);
1177
+ } else {
1178
+ setSelectedKeys([]);
1179
+ clearFilters();
1180
+ }
1181
+ confirm();
1081
1182
  }
1082
- confirm();
1083
1183
  }
1084
- });
1184
+ );
1085
1185
  break;
1086
1186
  case "number":
1087
1187
  if (!item.render)
@@ -1090,28 +1190,35 @@ function Table(props) {
1090
1190
  item.sorter = (a, b) => a[item.id] - b[item.id];
1091
1191
  if (!item.onFilter)
1092
1192
  item.onFilter = (value, row) => {
1093
- if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
1193
+ if (value === null)
1094
1194
  return true;
1095
- return value === row[item.id];
1195
+ if (lodashEs.isNil(row[item.id]))
1196
+ return false;
1197
+ return value == row[item.id];
1096
1198
  };
1097
- if (!item.filters && item.filterDropdown !== false)
1199
+ if (item.filterDropdown === false || item.filterDropdown)
1200
+ break;
1201
+ if (!item.filters)
1098
1202
  item.filterDropdown = ({
1099
1203
  setSelectedKeys,
1100
1204
  confirm,
1101
1205
  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();
1206
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1207
+ antd.Input.Search,
1208
+ {
1209
+ placeholder: `${common2.search} ${item.title}`,
1210
+ allowClear: true,
1211
+ onSearch: (v) => {
1212
+ if (v) {
1213
+ setSelectedKeys([Number(v)]);
1214
+ } else {
1215
+ setSelectedKeys([]);
1216
+ clearFilters();
1217
+ }
1218
+ confirm();
1111
1219
  }
1112
- confirm();
1113
1220
  }
1114
- });
1221
+ );
1115
1222
  break;
1116
1223
  case "number[]":
1117
1224
  if (!item.render)
@@ -1122,133 +1229,182 @@ function Table(props) {
1122
1229
  return true;
1123
1230
  if (!row[item.id] || !row[item.id].length)
1124
1231
  return false;
1125
- return row[item.id].includes(value);
1232
+ return row[item.id].includes(Number(value));
1126
1233
  };
1127
- if (!item.filters && item.filterDropdown !== false)
1234
+ if (item.filterDropdown === false || item.filterDropdown)
1235
+ break;
1236
+ if (!item.filters)
1128
1237
  item.filterDropdown = ({
1129
1238
  setSelectedKeys,
1130
1239
  confirm,
1131
1240
  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();
1241
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1242
+ antd.Input.Search,
1243
+ {
1244
+ placeholder: `${common2.search} ${item.title}`,
1245
+ allowClear: true,
1246
+ onSearch: (v) => {
1247
+ if (v) {
1248
+ setSelectedKeys([Number(v)]);
1249
+ } else {
1250
+ setSelectedKeys([]);
1251
+ clearFilters();
1252
+ }
1253
+ confirm();
1141
1254
  }
1142
- confirm();
1143
1255
  }
1144
- });
1256
+ );
1145
1257
  break;
1146
1258
  case "boolean":
1147
1259
  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
- });
1260
+ item.render = (value) => lodashEs.isNil(value) ? /* @__PURE__ */ jsxRuntime.jsx(Blank, {}) : value ? /* @__PURE__ */ jsxRuntime.jsx(icons.CheckOutlined, { style: {
1261
+ marginTop: "4px",
1262
+ color: "#52c41a"
1263
+ } }) : /* @__PURE__ */ jsxRuntime.jsx(icons.CloseOutlined, { style: {
1264
+ marginTop: "4px",
1265
+ color: "#ff4d4f"
1266
+ } });
1159
1267
  if (item.filterDropdown !== false)
1160
1268
  item.filterDropdown = ({
1161
1269
  setSelectedKeys,
1162
1270
  selectedKeys,
1163
1271
  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
- });
1272
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(
1273
+ antd.Radio.Group,
1274
+ {
1275
+ style: { padding: 8 },
1276
+ buttonStyle: "solid",
1277
+ value: JSON.stringify(selectedKeys[0]),
1278
+ onChange: (e) => {
1279
+ const Values = {
1280
+ true: true,
1281
+ false: false,
1282
+ null: null
1283
+ };
1284
+ setSelectedKeys(e.target.value ? [Values[e.target.value]] : []);
1285
+ confirm();
1286
+ },
1287
+ children: [
1288
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { children: common2.all }),
1289
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "true", children: /* @__PURE__ */ jsxRuntime.jsx(icons.CheckOutlined, { style: {
1290
+ color: "#52c41a",
1291
+ verticalAlign: "middle"
1292
+ } }) }),
1293
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "false", children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseOutlined, { style: {
1294
+ verticalAlign: "middle",
1295
+ color: "#ff4d4f"
1296
+ } }) }),
1297
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "null", children: common2.blank })
1298
+ ]
1299
+ }
1300
+ );
1200
1301
  if (!item.onFilter)
1201
1302
  item.onFilter = (value, row) => {
1202
1303
  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]);
1304
+ case true:
1305
+ return !lodashEs.isNil(row[item.id]) && row[item.id] !== false;
1306
+ case false:
1307
+ return !lodashEs.isNil(row[item.id]) && !row[item.id];
1209
1308
  default:
1210
- return true;
1309
+ return lodashEs.isNil(row[item.id]);
1211
1310
  }
1212
1311
  };
1213
1312
  break;
1214
1313
  case "date":
1215
1314
  if (!item.render)
1216
1315
  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
1316
  if (!item.sorter)
1220
- item.sorter = (a, b) => (0, import_dayjs2.default)(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1317
+ item.sorter = (a, b, order) => {
1318
+ if (lodashEs.isNil(a[item.id]))
1319
+ return order === "ascend" ? 1 : -1;
1320
+ if (lodashEs.isNil(b[item.id]))
1321
+ return order === "ascend" ? -1 : 1;
1322
+ return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
1323
+ };
1324
+ if (!item.filterDropdown)
1325
+ item.filterDropdown = ({
1326
+ setSelectedKeys,
1327
+ confirm
1328
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1329
+ antd.DatePicker.RangePicker,
1330
+ {
1331
+ onChange: (dates) => {
1332
+ setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
1333
+ confirm();
1334
+ }
1335
+ }
1336
+ );
1337
+ if (!item.onFilter)
1338
+ item.onFilter = (value, row) => {
1339
+ if (lodashEs.isNil(value[0]))
1340
+ return true;
1341
+ if (lodashEs.isNil(row[item.id]))
1342
+ return false;
1343
+ return dayjs2__default.default(row[item.id]) >= dayjs2__default.default(value[0]) && dayjs2__default.default(row[item.id]) <= dayjs2__default.default(value[1]);
1344
+ };
1221
1345
  break;
1222
1346
  case "time":
1223
1347
  if (!item.render)
1224
1348
  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
1349
  if (!item.sorter)
1228
- item.sorter = (a, b) => (0, import_dayjs2.default)(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
1350
+ item.sorter = (a, b, order) => {
1351
+ if (lodashEs.isNil(a[item.id]))
1352
+ return order === "ascend" ? 1 : -1;
1353
+ if (lodashEs.isNil(b[item.id]))
1354
+ return order === "ascend" ? -1 : 1;
1355
+ return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
1356
+ };
1357
+ if (!item.filterDropdown)
1358
+ item.filterDropdown = ({
1359
+ setSelectedKeys,
1360
+ confirm
1361
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
1362
+ antd.DatePicker.RangePicker,
1363
+ {
1364
+ onChange: (dates) => {
1365
+ setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
1366
+ confirm();
1367
+ }
1368
+ }
1369
+ );
1370
+ if (!item.onFilter)
1371
+ item.onFilter = (value, row) => {
1372
+ if (lodashEs.isNil(value[0]))
1373
+ return true;
1374
+ if (lodashEs.isNil(row[item.id]))
1375
+ return false;
1376
+ return dayjs2__default.default(row[item.id]) >= dayjs2__default.default(value[0]) && dayjs2__default.default(row[item.id]) <= dayjs2__default.default(value[1]);
1377
+ };
1229
1378
  break;
1230
1379
  case "object":
1231
1380
  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
- });
1381
+ item.render = (value) => /* @__PURE__ */ jsxRuntime.jsx(
1382
+ Description,
1383
+ {
1384
+ items: item.object,
1385
+ dataSource: value || {},
1386
+ column: 1
1387
+ }
1388
+ );
1237
1389
  break;
1238
1390
  case "object[]":
1239
1391
  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));
1392
+ item.render = (value) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: value.map((v, i) => /* @__PURE__ */ jsxRuntime.jsx(
1393
+ Description,
1394
+ {
1395
+ items: item.object,
1396
+ dataSource: v || [],
1397
+ column: 1
1398
+ },
1399
+ i
1400
+ )) });
1245
1401
  break;
1246
1402
  default:
1247
1403
  if (!item.render)
1248
1404
  item.render = (value) => processValue(item, value);
1249
1405
  if (!item.onFilter)
1250
1406
  item.onFilter = (value, row) => {
1251
- if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
1407
+ if (value === null && lodashEs.isNil(row[item.id]))
1252
1408
  return true;
1253
1409
  return value === row[item.id];
1254
1410
  };
@@ -1256,150 +1412,229 @@ function Table(props) {
1256
1412
  }
1257
1413
  }
1258
1414
  setColumns(props.items);
1259
- }, [props.items]);
1260
- (0, import_react11.useEffect)(() => {
1415
+ }, [JSON.stringify(props.items)]);
1416
+ react$1.useEffect(() => {
1261
1417
  if (!props.dataSource || !columns)
1262
1418
  return;
1263
1419
  for (const column of columns) {
1264
1420
  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
1421
+ const options = lodashEs.uniqBy(props.dataSource, column.id).map((v) => ({
1422
+ label: v[column.id],
1423
+ value: v[column.id]
1424
+ }));
1425
+ if (options.length)
1426
+ setColumns((prev) => {
1427
+ const newColumns = [...prev];
1428
+ const index = newColumns.findIndex((item) => item.id === column.id);
1429
+ newColumns[index].options = options;
1430
+ generateFilterDropdown(newColumns[index]);
1431
+ return newColumns;
1274
1432
  });
1275
- return newColumns;
1276
- });
1277
1433
  }
1278
1434
  }
1279
1435
  }, [props.dataSource, columns]);
1280
1436
  if (!columns)
1281
1437
  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, {
1438
+ if (props.dataSource)
1439
+ return /* @__PURE__ */ jsxRuntime.jsx(
1440
+ antd.Table,
1441
+ {
1286
1442
  ...props,
1287
1443
  rowKey: props.rowKey || "id",
1288
1444
  columns,
1289
1445
  dataSource: props.dataSource
1290
- })
1446
+ }
1447
+ );
1448
+ return /* @__PURE__ */ jsxRuntime.jsx(
1449
+ FaasDataWrapper,
1450
+ {
1451
+ ...props.faasData,
1452
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1453
+ FaasDataTable,
1454
+ {
1455
+ props,
1456
+ columns
1457
+ }
1458
+ )
1459
+ }
1460
+ );
1461
+ }
1462
+ function FaasDataTable({
1463
+ props,
1464
+ columns,
1465
+ data,
1466
+ params,
1467
+ reload
1468
+ }) {
1469
+ const [currentColumns, setCurrentColumns] = react$1.useState(columns);
1470
+ react$1.useEffect(() => {
1471
+ if (!data || Array.isArray(data))
1472
+ return;
1473
+ setCurrentColumns((prev) => {
1474
+ const newColumns = [...prev];
1475
+ for (const column of newColumns) {
1476
+ if (data["options"] && data.options[column.id]) {
1477
+ column.options = data["options"][column.id];
1478
+ column.filters = data["options"][column.id].map((v) => ({
1479
+ text: v.label,
1480
+ value: v.value
1481
+ })).concat({
1482
+ text: /* @__PURE__ */ jsxRuntime.jsx(Blank, {}),
1483
+ value: null
1484
+ });
1485
+ column.render = (value) => processValue(column, value);
1486
+ if (column.filterDropdown)
1487
+ delete column.filterDropdown;
1488
+ continue;
1489
+ }
1490
+ if (column.optionsType === "auto" && !column.options && !column.filters) {
1491
+ const filters = lodashEs.uniqBy(props.dataSource, column.id).map((v) => ({
1492
+ text: v[column.id],
1493
+ value: v[column.id]
1494
+ }));
1495
+ if (filters.length)
1496
+ column.filters = filters.concat({
1497
+ text: /* @__PURE__ */ jsxRuntime.jsx(Blank, {}),
1498
+ value: null
1499
+ });
1500
+ }
1501
+ }
1502
+ return newColumns;
1291
1503
  });
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
- })
1504
+ }, [columns, data]);
1505
+ if (!data)
1506
+ return /* @__PURE__ */ jsxRuntime.jsx(
1507
+ antd.Table,
1508
+ {
1509
+ ...props,
1510
+ loading: props.loading,
1511
+ rowKey: props.rowKey || "id",
1512
+ columns: currentColumns,
1513
+ dataSource: []
1514
+ }
1515
+ );
1516
+ if (Array.isArray(data))
1517
+ return /* @__PURE__ */ jsxRuntime.jsx(
1518
+ antd.Table,
1519
+ {
1520
+ ...props,
1521
+ loading: props.loading,
1522
+ rowKey: props.rowKey || "id",
1523
+ columns: currentColumns,
1524
+ dataSource: data
1525
+ }
1526
+ );
1527
+ return /* @__PURE__ */ jsxRuntime.jsx(
1528
+ antd.Table,
1529
+ {
1530
+ ...props,
1531
+ loading: props.loading,
1532
+ rowKey: props.rowKey || "id",
1533
+ columns: currentColumns,
1534
+ dataSource: data.rows,
1535
+ pagination: {
1536
+ ...props.pagination,
1537
+ ...data.pagination
1538
+ },
1539
+ onChange: (pagination, filters, sorter, extra) => {
1540
+ if (props.onChange) {
1541
+ const processed = props.onChange(pagination, filters, sorter, extra);
1542
+ reload({
1543
+ ...params,
1544
+ pagination: processed.pagination,
1545
+ filters: processed.filters,
1546
+ sorter: processed.sorter,
1547
+ extra: processed.extra
1548
+ });
1549
+ return;
1550
+ }
1551
+ reload({
1552
+ ...params,
1553
+ pagination,
1554
+ filters,
1555
+ sorter
1320
1556
  });
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
- });
1557
+ }
1558
+ }
1559
+ );
1560
+ }
1561
+ function Tabs(props) {
1562
+ return /* @__PURE__ */ jsxRuntime.jsx(
1563
+ antd.Tabs,
1564
+ {
1565
+ ...props,
1566
+ items: props.items.filter(Boolean).map((i) => ({
1567
+ ...i,
1568
+ key: i.key || i.id,
1569
+ label: i.label || i.title || i.id
1570
+ }))
1571
+ }
1572
+ );
1355
1573
  }
1356
-
1357
- // src/Title.tsx
1358
- var import_react13 = require("react");
1359
- var import_jsx_runtime = require("react/jsx-runtime");
1360
1574
  function Title(props) {
1361
1575
  const { Title: Title2 } = useConfigContext();
1362
- (0, import_react13.useEffect)(() => {
1576
+ react$1.useEffect(() => {
1363
1577
  const title = Array.isArray(props.title) ? props.title : [props.title];
1364
1578
  document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
1365
1579
  }, [props]);
1366
1580
  if (props.h1) {
1367
1581
  if (typeof props.h1 === "boolean")
1368
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
1582
+ return /* @__PURE__ */ jsxRuntime.jsx("h1", { children: Array.isArray(props.title) ? props.title[0] : props.title });
1583
+ return /* @__PURE__ */ jsxRuntime.jsx(
1584
+ "h1",
1585
+ {
1586
+ className: props.h1.className,
1587
+ style: props.h1.style,
1369
1588
  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
- });
1589
+ }
1590
+ );
1376
1591
  }
1377
1592
  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
- });
1593
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: Array.isArray(props.title) ? props.title[0] : props.title });
1381
1594
  if (props.children)
1382
- return (0, import_react13.cloneElement)(props.children, { title: props.title });
1595
+ return react$1.cloneElement(props.children, { title: props.title });
1383
1596
  return null;
1384
1597
  }
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
1598
+
1599
+ Object.defineProperty(exports, 'faas', {
1600
+ enumerable: true,
1601
+ get: function () { return react.faas; }
1602
+ });
1603
+ Object.defineProperty(exports, 'useFaas', {
1604
+ enumerable: true,
1605
+ get: function () { return react.useFaas; }
1606
+ });
1607
+ Object.defineProperty(exports, 'Drawer', {
1608
+ enumerable: true,
1609
+ get: function () { return antd.Drawer; }
1610
+ });
1611
+ Object.defineProperty(exports, 'Modal', {
1612
+ enumerable: true,
1613
+ get: function () { return antd.Modal; }
1614
+ });
1615
+ Object.defineProperty(exports, 'lazy', {
1616
+ enumerable: true,
1617
+ get: function () { return react$1.lazy; }
1405
1618
  });
1619
+ exports.App = App;
1620
+ exports.Blank = Blank;
1621
+ exports.ConfigContext = ConfigContext;
1622
+ exports.ConfigProvider = ConfigProvider2;
1623
+ exports.Description = Description;
1624
+ exports.ErrorBoundary = ErrorBoundary;
1625
+ exports.FaasDataWrapper = FaasDataWrapper;
1626
+ exports.Form = Form;
1627
+ exports.FormItem = FormItem;
1628
+ exports.Link = Link;
1629
+ exports.Loading = Loading;
1630
+ exports.PageNotFound = PageNotFound;
1631
+ exports.Routes = Routes;
1632
+ exports.Table = Table;
1633
+ exports.Tabs = Tabs;
1634
+ exports.Title = Title;
1635
+ exports.transferOptions = transferOptions;
1636
+ exports.transferValue = transferValue;
1637
+ exports.useApp = useApp;
1638
+ exports.useConfigContext = useConfigContext;
1639
+ exports.useDrawer = useDrawer;
1640
+ exports.useModal = useModal;