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