@faasjs/ant-design 0.0.3-beta.99 → 0.0.4-beta.1
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/README.md +30 -20
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +379 -387
- package/dist/index.mjs +379 -387
- package/package.json +15 -9
package/dist/index.js
CHANGED
|
@@ -83,12 +83,7 @@ function App(props) {
|
|
|
83
83
|
setModalProps,
|
|
84
84
|
setDrawerProps
|
|
85
85
|
}),
|
|
86
|
-
[
|
|
87
|
-
messageApi,
|
|
88
|
-
notificationApi,
|
|
89
|
-
setModalProps,
|
|
90
|
-
setDrawerProps
|
|
91
|
-
]
|
|
86
|
+
[messageApi, notificationApi, setModalProps, setDrawerProps]
|
|
92
87
|
);
|
|
93
88
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
94
89
|
cssinjs.StyleProvider,
|
|
@@ -157,12 +152,18 @@ function ConfigProvider2({
|
|
|
157
152
|
const [values, setValues] = react$1.useState(baseConfig);
|
|
158
153
|
react$1.useEffect(() => {
|
|
159
154
|
if (config.lang === "zh") {
|
|
160
|
-
setValues(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
setValues(
|
|
156
|
+
lodashEs.defaultsDeep(
|
|
157
|
+
config,
|
|
158
|
+
{
|
|
159
|
+
lang: "zh",
|
|
160
|
+
common: zh,
|
|
161
|
+
Blank: { text: zh.blank },
|
|
162
|
+
Form: { submit: { text: zh.submit } }
|
|
163
|
+
},
|
|
164
|
+
baseConfig
|
|
165
|
+
)
|
|
166
|
+
);
|
|
166
167
|
} else
|
|
167
168
|
setValues(lodashEs.defaultsDeep(config, values));
|
|
168
169
|
}, []);
|
|
@@ -178,10 +179,12 @@ function Blank(options) {
|
|
|
178
179
|
function transferOptions(options) {
|
|
179
180
|
if (!options)
|
|
180
181
|
return [];
|
|
181
|
-
return options.map(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
return options.map(
|
|
183
|
+
(item) => typeof item === "object" ? item : {
|
|
184
|
+
label: lodashEs.upperFirst(item.toString()),
|
|
185
|
+
value: item
|
|
186
|
+
}
|
|
187
|
+
);
|
|
185
188
|
}
|
|
186
189
|
function transferValue(type, value) {
|
|
187
190
|
if (typeof value === "undefined" || value === null || value === "" || value === "null" || value === "undefined")
|
|
@@ -201,13 +204,19 @@ function transferValue(type, value) {
|
|
|
201
204
|
function Loading(props) {
|
|
202
205
|
if (props.loading === false)
|
|
203
206
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
|
|
204
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
208
|
+
"div",
|
|
209
|
+
{
|
|
210
|
+
style: {
|
|
211
|
+
...props.style || {},
|
|
212
|
+
...!props.size || props.size === "large" ? {
|
|
213
|
+
margin: "20vh auto",
|
|
214
|
+
textAlign: "center"
|
|
215
|
+
} : {}
|
|
216
|
+
},
|
|
217
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { size: props.size || "large" })
|
|
218
|
+
}
|
|
219
|
+
);
|
|
211
220
|
}
|
|
212
221
|
function FaasDataWrapper(props) {
|
|
213
222
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -219,10 +228,10 @@ function FaasDataWrapper(props) {
|
|
|
219
228
|
);
|
|
220
229
|
}
|
|
221
230
|
function DescriptionItemContent(props) {
|
|
222
|
-
var _a;
|
|
231
|
+
var _a, _b;
|
|
223
232
|
const [computedProps, setComputedProps] = react$1.useState();
|
|
224
233
|
react$1.useEffect(() => {
|
|
225
|
-
var _a2,
|
|
234
|
+
var _a2, _b2;
|
|
226
235
|
const propsCopy = { ...props };
|
|
227
236
|
if (!propsCopy.item.title)
|
|
228
237
|
propsCopy.item.title = lodashEs.upperFirst(propsCopy.item.id);
|
|
@@ -234,22 +243,20 @@ function DescriptionItemContent(props) {
|
|
|
234
243
|
propsCopy.value = transferValue(propsCopy.item.type, propsCopy.value);
|
|
235
244
|
if (propsCopy.item.options && propsCopy.value !== null) {
|
|
236
245
|
if (propsCopy.item.type.endsWith("[]"))
|
|
237
|
-
propsCopy.value = propsCopy.value.map(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
].includes(propsCopy.item.type))
|
|
246
|
-
propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
|
|
246
|
+
propsCopy.value = propsCopy.value.map(
|
|
247
|
+
(v) => {
|
|
248
|
+
var _a3;
|
|
249
|
+
return ((_a3 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
else if (["string", "number", "boolean"].includes(propsCopy.item.type))
|
|
253
|
+
propsCopy.value = ((_b2 = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b2.label) || props.value;
|
|
247
254
|
}
|
|
248
255
|
setComputedProps(propsCopy);
|
|
249
256
|
}, [props]);
|
|
250
257
|
if (!computedProps)
|
|
251
258
|
return null;
|
|
252
|
-
if (computedProps.extendTypes
|
|
259
|
+
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type])
|
|
253
260
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
254
261
|
return react$1.cloneElement(
|
|
255
262
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
@@ -260,9 +267,14 @@ function DescriptionItemContent(props) {
|
|
|
260
267
|
}
|
|
261
268
|
);
|
|
262
269
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
263
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.extendTypes[computedProps.item.type].render(
|
|
270
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.extendTypes[computedProps.item.type].render(
|
|
271
|
+
computedProps.value,
|
|
272
|
+
computedProps.values,
|
|
273
|
+
0,
|
|
274
|
+
"description"
|
|
275
|
+
) });
|
|
264
276
|
else
|
|
265
|
-
throw Error(computedProps.item.type
|
|
277
|
+
throw Error(`${computedProps.item.type} requires children or render`);
|
|
266
278
|
if (computedProps.item.descriptionChildren === null)
|
|
267
279
|
return null;
|
|
268
280
|
if (computedProps.item.descriptionChildren)
|
|
@@ -280,9 +292,19 @@ function DescriptionItemContent(props) {
|
|
|
280
292
|
values: computedProps.values
|
|
281
293
|
});
|
|
282
294
|
if (computedProps.item.descriptionRender)
|
|
283
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.item.descriptionRender(
|
|
295
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.item.descriptionRender(
|
|
296
|
+
computedProps.value,
|
|
297
|
+
computedProps.values,
|
|
298
|
+
0,
|
|
299
|
+
"description"
|
|
300
|
+
) });
|
|
284
301
|
if (computedProps.item.render)
|
|
285
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.item.render(
|
|
302
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.item.render(
|
|
303
|
+
computedProps.value,
|
|
304
|
+
computedProps.values,
|
|
305
|
+
0,
|
|
306
|
+
"description"
|
|
307
|
+
) });
|
|
286
308
|
if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
|
|
287
309
|
return /* @__PURE__ */ jsxRuntime.jsx(Blank, {});
|
|
288
310
|
switch (computedProps.item.type) {
|
|
@@ -293,13 +315,23 @@ function DescriptionItemContent(props) {
|
|
|
293
315
|
case "number[]":
|
|
294
316
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.value.join(", ") });
|
|
295
317
|
case "boolean":
|
|
296
|
-
return computedProps.value ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
318
|
+
return computedProps.value ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
319
|
+
icons.CheckOutlined,
|
|
320
|
+
{
|
|
321
|
+
style: {
|
|
322
|
+
marginTop: "4px",
|
|
323
|
+
color: "#52c41a"
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
327
|
+
icons.CloseOutlined,
|
|
328
|
+
{
|
|
329
|
+
style: {
|
|
330
|
+
marginTop: "4px",
|
|
331
|
+
color: "#ff4d4f"
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
);
|
|
303
335
|
case "time":
|
|
304
336
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.value.format("YYYY-MM-DD HH:mm:ss") });
|
|
305
337
|
case "date":
|
|
@@ -316,17 +348,19 @@ function DescriptionItemContent(props) {
|
|
|
316
348
|
}
|
|
317
349
|
);
|
|
318
350
|
case "object[]":
|
|
319
|
-
if (!((
|
|
351
|
+
if (!((_b = computedProps.value) == null ? void 0 : _b.length))
|
|
320
352
|
return /* @__PURE__ */ jsxRuntime.jsx(Blank, {});
|
|
321
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Space, { direction: "vertical", children: computedProps.value.map(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
353
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Space, { direction: "vertical", children: computedProps.value.map(
|
|
354
|
+
(value, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
355
|
+
Description,
|
|
356
|
+
{
|
|
357
|
+
items: computedProps.item.object,
|
|
358
|
+
dataSource: value,
|
|
359
|
+
column: 1
|
|
360
|
+
},
|
|
361
|
+
index
|
|
362
|
+
)
|
|
363
|
+
) });
|
|
330
364
|
default:
|
|
331
365
|
return computedProps.value || null;
|
|
332
366
|
}
|
|
@@ -336,13 +370,7 @@ function Description(props) {
|
|
|
336
370
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
337
371
|
FaasDataWrapper,
|
|
338
372
|
{
|
|
339
|
-
render: ({ data }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
340
|
-
Description,
|
|
341
|
-
{
|
|
342
|
-
...props,
|
|
343
|
-
dataSource: data
|
|
344
|
-
}
|
|
345
|
-
),
|
|
373
|
+
render: ({ data }) => /* @__PURE__ */ jsxRuntime.jsx(Description, { ...props, dataSource: data }),
|
|
346
374
|
...props.faasData
|
|
347
375
|
}
|
|
348
376
|
);
|
|
@@ -374,21 +402,21 @@ function ErrorChildren(props) {
|
|
|
374
402
|
{
|
|
375
403
|
type: "error",
|
|
376
404
|
message: props.errorMessage,
|
|
377
|
-
description: /* @__PURE__ */ jsxRuntime.jsx(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
405
|
+
description: /* @__PURE__ */ jsxRuntime.jsx(
|
|
406
|
+
"pre",
|
|
407
|
+
{
|
|
408
|
+
style: {
|
|
409
|
+
fontSize: "0.9em",
|
|
410
|
+
overflowX: "auto"
|
|
411
|
+
},
|
|
412
|
+
children: props.errorDescription
|
|
413
|
+
}
|
|
414
|
+
)
|
|
381
415
|
}
|
|
382
416
|
);
|
|
383
417
|
}
|
|
384
418
|
function ErrorBoundary(props) {
|
|
385
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
386
|
-
react.ErrorBoundary,
|
|
387
|
-
{
|
|
388
|
-
errorChildren: /* @__PURE__ */ jsxRuntime.jsx(ErrorChildren, {}),
|
|
389
|
-
...props
|
|
390
|
-
}
|
|
391
|
-
);
|
|
419
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.ErrorBoundary, { errorChildren: /* @__PURE__ */ jsxRuntime.jsx(ErrorChildren, {}), ...props });
|
|
392
420
|
}
|
|
393
421
|
function processProps(propsCopy, config) {
|
|
394
422
|
if (!propsCopy.title)
|
|
@@ -407,7 +435,9 @@ function processProps(propsCopy, config) {
|
|
|
407
435
|
required: true,
|
|
408
436
|
validator: async (_, values) => {
|
|
409
437
|
if (!values || values.length < 1)
|
|
410
|
-
return Promise.reject(
|
|
438
|
+
return Promise.reject(
|
|
439
|
+
Error(`${propsCopy.label || propsCopy.title} ${config.required}`)
|
|
440
|
+
);
|
|
411
441
|
}
|
|
412
442
|
});
|
|
413
443
|
else
|
|
@@ -419,7 +449,9 @@ function processProps(propsCopy, config) {
|
|
|
419
449
|
if (!propsCopy.input)
|
|
420
450
|
propsCopy.input = {};
|
|
421
451
|
if (propsCopy.options)
|
|
422
|
-
propsCopy.input.options = transferOptions(
|
|
452
|
+
propsCopy.input.options = transferOptions(
|
|
453
|
+
propsCopy.options
|
|
454
|
+
);
|
|
423
455
|
switch (propsCopy.type) {
|
|
424
456
|
case "boolean":
|
|
425
457
|
propsCopy.valuePropName = "checked";
|
|
@@ -466,16 +498,8 @@ function FormItem(props) {
|
|
|
466
498
|
if (!computedProps)
|
|
467
499
|
return null;
|
|
468
500
|
if (hidden)
|
|
469
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
470
|
-
|
|
471
|
-
{
|
|
472
|
-
...computedProps,
|
|
473
|
-
noStyle: true,
|
|
474
|
-
rules: [],
|
|
475
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { hidden: true })
|
|
476
|
-
}
|
|
477
|
-
);
|
|
478
|
-
if (extendTypes && extendTypes[computedProps.type])
|
|
501
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, noStyle: true, rules: [], children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { hidden: true }) });
|
|
502
|
+
if (extendTypes == null ? void 0 : extendTypes[computedProps.type])
|
|
479
503
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: extendTypes[computedProps.type].children });
|
|
480
504
|
if (computedProps.formChildren === null)
|
|
481
505
|
return null;
|
|
@@ -496,13 +520,7 @@ function FormItem(props) {
|
|
|
496
520
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { ...computedProps.input }) });
|
|
497
521
|
case "string[]":
|
|
498
522
|
if (computedProps.options)
|
|
499
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
500
|
-
antd.Select,
|
|
501
|
-
{
|
|
502
|
-
mode: "multiple",
|
|
503
|
-
...computedProps.input
|
|
504
|
-
}
|
|
505
|
-
) });
|
|
523
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Select, { mode: "multiple", ...computedProps.input }) });
|
|
506
524
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
507
525
|
antd.Form.List,
|
|
508
526
|
{
|
|
@@ -511,36 +529,28 @@ function FormItem(props) {
|
|
|
511
529
|
children: (fields, { add, remove }, { errors }) => {
|
|
512
530
|
var _a2;
|
|
513
531
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
514
|
-
computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
532
|
+
computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
533
|
+
"label",
|
|
534
|
+
{
|
|
535
|
+
className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
|
|
536
|
+
children: computedProps.label
|
|
537
|
+
}
|
|
538
|
+
) }),
|
|
515
539
|
fields.map((field) => {
|
|
516
540
|
var _a3;
|
|
517
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
518
|
-
antd.
|
|
519
|
-
{
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
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
|
-
{
|
|
534
|
-
danger: true,
|
|
535
|
-
type: "link",
|
|
536
|
-
style: { float: "right" },
|
|
537
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
|
|
538
|
-
onClick: () => remove(field.name)
|
|
539
|
-
}
|
|
540
|
-
) })
|
|
541
|
-
]
|
|
542
|
-
}
|
|
543
|
-
) }, field.key);
|
|
541
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
|
|
542
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 23, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { ...computedProps.input }) }) }),
|
|
543
|
+
/* @__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(
|
|
544
|
+
antd.Button,
|
|
545
|
+
{
|
|
546
|
+
danger: true,
|
|
547
|
+
type: "link",
|
|
548
|
+
style: { float: "right" },
|
|
549
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
|
|
550
|
+
onClick: () => remove(field.name)
|
|
551
|
+
}
|
|
552
|
+
) })
|
|
553
|
+
] }) }, field.key);
|
|
544
554
|
}),
|
|
545
555
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
|
|
546
556
|
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -571,13 +581,7 @@ function FormItem(props) {
|
|
|
571
581
|
) });
|
|
572
582
|
case "number[]":
|
|
573
583
|
if (computedProps.options)
|
|
574
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
575
|
-
antd.Select,
|
|
576
|
-
{
|
|
577
|
-
mode: "multiple",
|
|
578
|
-
...computedProps.input
|
|
579
|
-
}
|
|
580
|
-
) });
|
|
584
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Select, { mode: "multiple", ...computedProps.input }) });
|
|
581
585
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
582
586
|
antd.Form.List,
|
|
583
587
|
{
|
|
@@ -586,42 +590,36 @@ function FormItem(props) {
|
|
|
586
590
|
children: (fields, { add, remove }, { errors }) => {
|
|
587
591
|
var _a2, _b;
|
|
588
592
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
589
|
-
computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
593
|
+
computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
594
|
+
"label",
|
|
595
|
+
{
|
|
596
|
+
className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find(
|
|
597
|
+
(r) => r.required
|
|
598
|
+
)) && "ant-form-item-required",
|
|
599
|
+
children: computedProps.label
|
|
600
|
+
}
|
|
601
|
+
) }),
|
|
590
602
|
fields.map((field) => {
|
|
591
603
|
var _a3;
|
|
592
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
593
|
-
antd.
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
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
|
-
{
|
|
615
|
-
danger: true,
|
|
616
|
-
type: "link",
|
|
617
|
-
style: { float: "right" },
|
|
618
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
|
|
619
|
-
onClick: () => remove(field.name)
|
|
620
|
-
}
|
|
621
|
-
) })
|
|
622
|
-
]
|
|
623
|
-
}
|
|
624
|
-
) }, field.key);
|
|
604
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
|
|
605
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 23, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
606
|
+
antd.InputNumber,
|
|
607
|
+
{
|
|
608
|
+
style: { width: "100%" },
|
|
609
|
+
...computedProps.input
|
|
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
|
+
{
|
|
615
|
+
danger: true,
|
|
616
|
+
type: "link",
|
|
617
|
+
style: { float: "right" },
|
|
618
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
|
|
619
|
+
onClick: () => remove(field.name)
|
|
620
|
+
}
|
|
621
|
+
) })
|
|
622
|
+
] }) }, field.key);
|
|
625
623
|
}),
|
|
626
624
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
|
|
627
625
|
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -648,14 +646,14 @@ function FormItem(props) {
|
|
|
648
646
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.TimePicker, { ...computedProps.input }) });
|
|
649
647
|
case "object":
|
|
650
648
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
651
|
-
computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
652
|
-
|
|
653
|
-
FormItem,
|
|
649
|
+
computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
650
|
+
"label",
|
|
654
651
|
{
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
))
|
|
652
|
+
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
|
|
653
|
+
children: computedProps.label
|
|
654
|
+
}
|
|
655
|
+
) }),
|
|
656
|
+
computedProps.object.map((o) => /* @__PURE__ */ jsxRuntime.jsx(FormItem, { ...o }, o.id))
|
|
659
657
|
] });
|
|
660
658
|
case "object[]":
|
|
661
659
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -664,43 +662,23 @@ function FormItem(props) {
|
|
|
664
662
|
name: computedProps.name,
|
|
665
663
|
rules: computedProps.rules,
|
|
666
664
|
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
667
|
-
fields.map((field) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
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
|
-
)),
|
|
665
|
+
fields.map((field) => /* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { style: { marginBottom: 0 }, children: [
|
|
666
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
667
|
+
computedProps.label,
|
|
668
|
+
" ",
|
|
669
|
+
field.name + 1,
|
|
670
|
+
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
671
|
+
antd.Button,
|
|
672
|
+
{
|
|
673
|
+
danger: true,
|
|
674
|
+
type: "link",
|
|
675
|
+
onClick: () => remove(field.name),
|
|
676
|
+
children: common2.delete
|
|
677
|
+
}
|
|
678
|
+
)
|
|
679
|
+
] }) }),
|
|
680
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: 24, children: computedProps.object.map((o) => /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: o.col || 24, children: /* @__PURE__ */ jsxRuntime.jsx(FormItem, { ...o, name: [field.name, o.id] }) }, o.id)) })
|
|
681
|
+
] }, field.key)),
|
|
704
682
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
|
|
705
683
|
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
706
684
|
antd.Button,
|
|
@@ -734,7 +712,9 @@ function Form(props) {
|
|
|
734
712
|
const config = useConfigContext();
|
|
735
713
|
const [extendTypes, setExtendTypes] = react$1.useState();
|
|
736
714
|
const [form] = antd.Form.useForm(props.form);
|
|
737
|
-
const [initialValues, setInitialValues] = react$1.useState(
|
|
715
|
+
const [initialValues, setInitialValues] = react$1.useState(
|
|
716
|
+
props.initialValues
|
|
717
|
+
);
|
|
738
718
|
react$1.useEffect(() => {
|
|
739
719
|
var _a2, _b2, _c;
|
|
740
720
|
const propsCopy = {
|
|
@@ -760,14 +740,20 @@ function Form(props) {
|
|
|
760
740
|
}
|
|
761
741
|
if (propsCopy.onFinish) {
|
|
762
742
|
propsCopy.onFinish = async (values) => {
|
|
763
|
-
var _a3;
|
|
743
|
+
var _a3, _b3;
|
|
764
744
|
setLoading(true);
|
|
765
745
|
try {
|
|
766
|
-
if (
|
|
767
|
-
await props.onFinish(
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
746
|
+
if ((_b3 = (_a3 = propsCopy.submit) == null ? void 0 : _a3.to) == null ? void 0 : _b3.action) {
|
|
747
|
+
await props.onFinish(
|
|
748
|
+
values,
|
|
749
|
+
async (values2) => react.faas(
|
|
750
|
+
propsCopy.submit.to.action,
|
|
751
|
+
propsCopy.submit.to.params ? {
|
|
752
|
+
...values2,
|
|
753
|
+
...propsCopy.submit.to.params
|
|
754
|
+
} : values2
|
|
755
|
+
)
|
|
756
|
+
);
|
|
771
757
|
} else
|
|
772
758
|
await props.onFinish(values);
|
|
773
759
|
} catch (error) {
|
|
@@ -778,10 +764,13 @@ function Form(props) {
|
|
|
778
764
|
} else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
|
|
779
765
|
propsCopy.onFinish = async (values) => {
|
|
780
766
|
setLoading(true);
|
|
781
|
-
return react.faas(
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
767
|
+
return react.faas(
|
|
768
|
+
propsCopy.submit.to.action,
|
|
769
|
+
propsCopy.submit.to.params ? {
|
|
770
|
+
...values,
|
|
771
|
+
...propsCopy.submit.to.params
|
|
772
|
+
} : values
|
|
773
|
+
).then((result) => {
|
|
785
774
|
if (propsCopy.submit.to.then)
|
|
786
775
|
propsCopy.submit.to.then(result);
|
|
787
776
|
return result;
|
|
@@ -802,19 +791,22 @@ function Form(props) {
|
|
|
802
791
|
}
|
|
803
792
|
setComputedProps(propsCopy);
|
|
804
793
|
}, [props]);
|
|
805
|
-
const onValuesChange = react$1.useCallback(
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
props.onValuesChange
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
item.onValueChange
|
|
816
|
-
|
|
817
|
-
|
|
794
|
+
const onValuesChange = react$1.useCallback(
|
|
795
|
+
(changedValues, allValues) => {
|
|
796
|
+
console.debug("Form:onValuesChange", changedValues, allValues);
|
|
797
|
+
if (props.onValuesChange) {
|
|
798
|
+
props.onValuesChange(changedValues, allValues);
|
|
799
|
+
}
|
|
800
|
+
if (!props.items)
|
|
801
|
+
return;
|
|
802
|
+
for (const key in changedValues) {
|
|
803
|
+
const item = computedProps.items.find((i) => i.id === key);
|
|
804
|
+
if (item == null ? void 0 : item.onValueChange)
|
|
805
|
+
item.onValueChange(changedValues[key], allValues, form);
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
[computedProps]
|
|
809
|
+
);
|
|
818
810
|
react$1.useEffect(() => {
|
|
819
811
|
if (!initialValues)
|
|
820
812
|
return;
|
|
@@ -824,35 +816,22 @@ function Form(props) {
|
|
|
824
816
|
}, [computedProps]);
|
|
825
817
|
if (!computedProps)
|
|
826
818
|
return null;
|
|
827
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
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
|
-
]
|
|
854
|
-
}
|
|
855
|
-
);
|
|
819
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Form, { ...computedProps, onValuesChange, children: [
|
|
820
|
+
computedProps.beforeItems,
|
|
821
|
+
(_a = computedProps.items) == null ? void 0 : _a.map(
|
|
822
|
+
(item) => react$1.isValidElement(item) ? item : /* @__PURE__ */ jsxRuntime.jsx(
|
|
823
|
+
FormItem,
|
|
824
|
+
{
|
|
825
|
+
...item,
|
|
826
|
+
extendTypes
|
|
827
|
+
},
|
|
828
|
+
item.id
|
|
829
|
+
)
|
|
830
|
+
),
|
|
831
|
+
computedProps.children,
|
|
832
|
+
computedProps.submit !== false && /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { htmlType: "submit", type: "primary", loading, children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text }),
|
|
833
|
+
computedProps.footer
|
|
834
|
+
] });
|
|
856
835
|
}
|
|
857
836
|
Form.useForm = antd.Form.useForm;
|
|
858
837
|
Form.useFormInstance = antd.Form.useFormInstance;
|
|
@@ -865,16 +844,19 @@ function Link(props) {
|
|
|
865
844
|
var _a, _b;
|
|
866
845
|
const { Link: Config } = useConfigContext();
|
|
867
846
|
const navigate = reactRouterDom.useNavigate();
|
|
868
|
-
let
|
|
847
|
+
let computedStyle = {
|
|
869
848
|
...Config.style || {},
|
|
870
849
|
cursor: "pointer",
|
|
871
850
|
...props.style
|
|
872
851
|
};
|
|
873
852
|
if (props.block)
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
853
|
+
computedStyle = Object.assign(
|
|
854
|
+
{
|
|
855
|
+
display: "block",
|
|
856
|
+
width: "100%"
|
|
857
|
+
},
|
|
858
|
+
computedStyle
|
|
859
|
+
);
|
|
878
860
|
if (props.href.startsWith("http")) {
|
|
879
861
|
if (props.button)
|
|
880
862
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -882,28 +864,34 @@ function Link(props) {
|
|
|
882
864
|
{
|
|
883
865
|
...props.button,
|
|
884
866
|
target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
|
|
885
|
-
style,
|
|
867
|
+
style: computedStyle,
|
|
886
868
|
href: props.href,
|
|
869
|
+
onClick: props.onClick,
|
|
887
870
|
children: (_a = props.text) != null ? _a : props.children
|
|
888
871
|
}
|
|
889
872
|
);
|
|
890
873
|
if (props.children)
|
|
891
|
-
return
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
874
|
+
return (
|
|
875
|
+
// biome-ignore lint/a11y/useValidAnchor: <explanation>
|
|
876
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
877
|
+
"a",
|
|
878
|
+
{
|
|
879
|
+
href: props.href,
|
|
880
|
+
target: props.target || (Config == null ? void 0 : Config.target),
|
|
881
|
+
style: computedStyle,
|
|
882
|
+
onClick: props.onClick,
|
|
883
|
+
children: props.children
|
|
884
|
+
}
|
|
885
|
+
)
|
|
899
886
|
);
|
|
900
887
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
901
888
|
antd.Typography.Link,
|
|
902
889
|
{
|
|
903
890
|
href: props.href,
|
|
904
891
|
target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
|
|
905
|
-
style,
|
|
892
|
+
style: computedStyle,
|
|
906
893
|
copyable: props.copyable,
|
|
894
|
+
onClick: props.onClick,
|
|
907
895
|
children: props.text
|
|
908
896
|
}
|
|
909
897
|
);
|
|
@@ -913,8 +901,8 @@ function Link(props) {
|
|
|
913
901
|
antd.Button,
|
|
914
902
|
{
|
|
915
903
|
...props.button,
|
|
916
|
-
style,
|
|
917
|
-
onClick: () => (props.target || (Config == null ? void 0 : Config.target)) === "_blank" ? window.open(props.href) : navigate(props.href),
|
|
904
|
+
style: computedStyle,
|
|
905
|
+
onClick: (e) => props.onClick ? props.onClick(e) : (props.target || (Config == null ? void 0 : Config.target)) === "_blank" ? window.open(props.href) : navigate(props.href),
|
|
918
906
|
children: (_b = props.text) != null ? _b : props.children
|
|
919
907
|
}
|
|
920
908
|
);
|
|
@@ -924,7 +912,8 @@ function Link(props) {
|
|
|
924
912
|
{
|
|
925
913
|
to: props.href,
|
|
926
914
|
target: props.target || (Config == null ? void 0 : Config.target),
|
|
927
|
-
style,
|
|
915
|
+
style: computedStyle,
|
|
916
|
+
onClick: props.onClick,
|
|
928
917
|
children: props.children
|
|
929
918
|
}
|
|
930
919
|
);
|
|
@@ -933,22 +922,25 @@ function Link(props) {
|
|
|
933
922
|
{
|
|
934
923
|
href: props.href,
|
|
935
924
|
target: props.target || (Config == null ? void 0 : Config.target),
|
|
936
|
-
style,
|
|
925
|
+
style: computedStyle,
|
|
937
926
|
copyable: props.copyable,
|
|
938
|
-
onClick: () =>
|
|
927
|
+
onClick: (e) => {
|
|
928
|
+
if (props.onClick) {
|
|
929
|
+
props.onClick(e);
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
if ((props.target || (Config == null ? void 0 : Config.target)) !== "_blank") {
|
|
933
|
+
e.preventDefault();
|
|
934
|
+
navigate(props.href);
|
|
935
|
+
}
|
|
936
|
+
},
|
|
939
937
|
children: props.text
|
|
940
938
|
}
|
|
941
939
|
);
|
|
942
940
|
}
|
|
943
941
|
function PageNotFound() {
|
|
944
942
|
const config = useConfigContext();
|
|
945
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
946
|
-
antd.Result,
|
|
947
|
-
{
|
|
948
|
-
status: "404",
|
|
949
|
-
title: config.common.pageNotFound
|
|
950
|
-
}
|
|
951
|
-
);
|
|
943
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "404", title: config.common.pageNotFound });
|
|
952
944
|
}
|
|
953
945
|
function Routes(props) {
|
|
954
946
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
|
|
@@ -956,18 +948,17 @@ function Routes(props) {
|
|
|
956
948
|
reactRouterDom.Route,
|
|
957
949
|
{
|
|
958
950
|
...r,
|
|
959
|
-
element: r.element || /* @__PURE__ */ jsxRuntime.jsx(
|
|
951
|
+
element: r.element || /* @__PURE__ */ jsxRuntime.jsx(
|
|
952
|
+
react$1.Suspense,
|
|
953
|
+
{
|
|
954
|
+
fallback: props.fallback || /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "24px" }, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Skeleton, { active: true }) }),
|
|
955
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(r.page, {})
|
|
956
|
+
}
|
|
957
|
+
)
|
|
960
958
|
},
|
|
961
959
|
r.path
|
|
962
960
|
)),
|
|
963
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
964
|
-
reactRouterDom.Route,
|
|
965
|
-
{
|
|
966
|
-
path: "*",
|
|
967
|
-
element: props.notFound || /* @__PURE__ */ jsxRuntime.jsx(PageNotFound, {})
|
|
968
|
-
},
|
|
969
|
-
"*"
|
|
970
|
-
)
|
|
961
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: props.notFound || /* @__PURE__ */ jsxRuntime.jsx(PageNotFound, {}) }, "*")
|
|
971
962
|
] });
|
|
972
963
|
}
|
|
973
964
|
function processValue(item, value) {
|
|
@@ -977,21 +968,21 @@ function processValue(item, value) {
|
|
|
977
968
|
return /* @__PURE__ */ jsxRuntime.jsx(Blank, {});
|
|
978
969
|
if (item.options) {
|
|
979
970
|
if (item.type.endsWith("[]"))
|
|
980
|
-
return transferred.map(
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
"
|
|
986
|
-
|
|
987
|
-
"boolean"
|
|
988
|
-
].includes(item.type))
|
|
971
|
+
return transferred.map(
|
|
972
|
+
(v) => {
|
|
973
|
+
var _a2;
|
|
974
|
+
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
975
|
+
}
|
|
976
|
+
).join(", ");
|
|
977
|
+
if (["string", "number", "boolean"].includes(item.type))
|
|
989
978
|
return ((_a = item.options.find((option) => option.value === transferred)) == null ? void 0 : _a.label) || transferred;
|
|
990
979
|
}
|
|
991
980
|
if (item.type.endsWith("[]"))
|
|
992
981
|
return transferred.join(", ");
|
|
993
982
|
if (["date", "time"].includes(item.type))
|
|
994
|
-
return transferred.format(
|
|
983
|
+
return transferred.format(
|
|
984
|
+
item.type === "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss"
|
|
985
|
+
);
|
|
995
986
|
return value;
|
|
996
987
|
}
|
|
997
988
|
function Table(props) {
|
|
@@ -1008,11 +999,7 @@ function Table(props) {
|
|
|
1008
999
|
}));
|
|
1009
1000
|
return;
|
|
1010
1001
|
}
|
|
1011
|
-
item.filterDropdown = ({
|
|
1012
|
-
setSelectedKeys,
|
|
1013
|
-
selectedKeys,
|
|
1014
|
-
confirm
|
|
1015
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1002
|
+
item.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1016
1003
|
"div",
|
|
1017
1004
|
{
|
|
1018
1005
|
style: {
|
|
@@ -1047,7 +1034,7 @@ function Table(props) {
|
|
|
1047
1034
|
return item;
|
|
1048
1035
|
};
|
|
1049
1036
|
react$1.useEffect(() => {
|
|
1050
|
-
var _a;
|
|
1037
|
+
var _a, _b;
|
|
1051
1038
|
for (const item of props.items) {
|
|
1052
1039
|
if (!item.key)
|
|
1053
1040
|
item.key = item.id;
|
|
@@ -1071,39 +1058,30 @@ function Table(props) {
|
|
|
1071
1058
|
if (item.tableChildren === null)
|
|
1072
1059
|
item.render = () => null;
|
|
1073
1060
|
else if (item.tableChildren)
|
|
1074
|
-
item.render = (value, values) => react$1.cloneElement(
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
values
|
|
1080
|
-
}
|
|
1081
|
-
);
|
|
1061
|
+
item.render = (value, values) => react$1.cloneElement(item.tableChildren, {
|
|
1062
|
+
scene: "table",
|
|
1063
|
+
value,
|
|
1064
|
+
values
|
|
1065
|
+
});
|
|
1082
1066
|
else if (item.children === null)
|
|
1083
1067
|
item.render = () => null;
|
|
1084
1068
|
else if (item.children)
|
|
1085
|
-
item.render = (value, values) => react$1.cloneElement(
|
|
1086
|
-
|
|
1087
|
-
|
|
1069
|
+
item.render = (value, values) => react$1.cloneElement(item.children, {
|
|
1070
|
+
scene: "table",
|
|
1071
|
+
value,
|
|
1072
|
+
values
|
|
1073
|
+
});
|
|
1074
|
+
if ((_b = props.extendTypes) == null ? void 0 : _b[item.type]) {
|
|
1075
|
+
if (props.extendTypes[item.type].children)
|
|
1076
|
+
item.render = (value, values) => react$1.cloneElement(props.extendTypes[item.type].children, {
|
|
1088
1077
|
scene: "table",
|
|
1089
1078
|
value,
|
|
1090
1079
|
values
|
|
1091
|
-
}
|
|
1092
|
-
);
|
|
1093
|
-
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
1094
|
-
if (props.extendTypes[item.type].children)
|
|
1095
|
-
item.render = (value, values) => react$1.cloneElement(
|
|
1096
|
-
props.extendTypes[item.type].children,
|
|
1097
|
-
{
|
|
1098
|
-
scene: "table",
|
|
1099
|
-
value,
|
|
1100
|
-
values
|
|
1101
|
-
}
|
|
1102
|
-
);
|
|
1080
|
+
});
|
|
1103
1081
|
else if (props.extendTypes[item.type].render)
|
|
1104
1082
|
item.render = props.extendTypes[item.type].render;
|
|
1105
1083
|
else
|
|
1106
|
-
throw Error(item.type
|
|
1084
|
+
throw Error(`${item.type} requires children or render`);
|
|
1107
1085
|
continue;
|
|
1108
1086
|
}
|
|
1109
1087
|
switch (item.type) {
|
|
@@ -1151,7 +1129,9 @@ function Table(props) {
|
|
|
1151
1129
|
return true;
|
|
1152
1130
|
if (!row[item.id] || !row[item.id].length || !value)
|
|
1153
1131
|
return false;
|
|
1154
|
-
return row[item.id].some(
|
|
1132
|
+
return row[item.id].some(
|
|
1133
|
+
(v) => v.trim().toLowerCase().includes(value.trim().toLowerCase())
|
|
1134
|
+
);
|
|
1155
1135
|
};
|
|
1156
1136
|
if (item.filterDropdown === false || item.filterDropdown)
|
|
1157
1137
|
break;
|
|
@@ -1251,13 +1231,23 @@ function Table(props) {
|
|
|
1251
1231
|
break;
|
|
1252
1232
|
case "boolean":
|
|
1253
1233
|
if (!item.render)
|
|
1254
|
-
item.render = (value) => lodashEs.isNil(value) ? /* @__PURE__ */ jsxRuntime.jsx(Blank, {}) : value ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1234
|
+
item.render = (value) => lodashEs.isNil(value) ? /* @__PURE__ */ jsxRuntime.jsx(Blank, {}) : value ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1235
|
+
icons.CheckOutlined,
|
|
1236
|
+
{
|
|
1237
|
+
style: {
|
|
1238
|
+
marginTop: "4px",
|
|
1239
|
+
color: "#52c41a"
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1243
|
+
icons.CloseOutlined,
|
|
1244
|
+
{
|
|
1245
|
+
style: {
|
|
1246
|
+
marginTop: "4px",
|
|
1247
|
+
color: "#ff4d4f"
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
);
|
|
1261
1251
|
if (item.filterDropdown !== false)
|
|
1262
1252
|
item.filterDropdown = ({
|
|
1263
1253
|
setSelectedKeys,
|
|
@@ -1275,19 +1265,31 @@ function Table(props) {
|
|
|
1275
1265
|
false: false,
|
|
1276
1266
|
null: null
|
|
1277
1267
|
};
|
|
1278
|
-
setSelectedKeys(
|
|
1268
|
+
setSelectedKeys(
|
|
1269
|
+
e.target.value ? [Values[e.target.value]] : []
|
|
1270
|
+
);
|
|
1279
1271
|
confirm();
|
|
1280
1272
|
},
|
|
1281
1273
|
children: [
|
|
1282
1274
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { children: common2.all }),
|
|
1283
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "true", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1275
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "true", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1276
|
+
icons.CheckOutlined,
|
|
1277
|
+
{
|
|
1278
|
+
style: {
|
|
1279
|
+
color: "#52c41a",
|
|
1280
|
+
verticalAlign: "middle"
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
) }),
|
|
1284
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "false", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1285
|
+
icons.CloseOutlined,
|
|
1286
|
+
{
|
|
1287
|
+
style: {
|
|
1288
|
+
verticalAlign: "middle",
|
|
1289
|
+
color: "#ff4d4f"
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
) }),
|
|
1291
1293
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "null", children: common2.blank })
|
|
1292
1294
|
]
|
|
1293
1295
|
}
|
|
@@ -1316,14 +1318,18 @@ function Table(props) {
|
|
|
1316
1318
|
return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
|
|
1317
1319
|
};
|
|
1318
1320
|
if (!item.filterDropdown)
|
|
1319
|
-
item.filterDropdown = ({
|
|
1320
|
-
setSelectedKeys,
|
|
1321
|
-
confirm
|
|
1322
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1321
|
+
item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1323
1322
|
antd.DatePicker.RangePicker,
|
|
1324
1323
|
{
|
|
1325
1324
|
onChange: (dates) => {
|
|
1326
|
-
setSelectedKeys(
|
|
1325
|
+
setSelectedKeys(
|
|
1326
|
+
(dates == null ? void 0 : dates[0]) && dates[1] ? [
|
|
1327
|
+
[
|
|
1328
|
+
dates[0].startOf("day").toISOString(),
|
|
1329
|
+
dates[1].endOf("day").toISOString()
|
|
1330
|
+
]
|
|
1331
|
+
] : []
|
|
1332
|
+
);
|
|
1327
1333
|
confirm();
|
|
1328
1334
|
}
|
|
1329
1335
|
}
|
|
@@ -1349,14 +1355,18 @@ function Table(props) {
|
|
|
1349
1355
|
return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
|
|
1350
1356
|
};
|
|
1351
1357
|
if (!item.filterDropdown)
|
|
1352
|
-
item.filterDropdown = ({
|
|
1353
|
-
setSelectedKeys,
|
|
1354
|
-
confirm
|
|
1355
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1358
|
+
item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1356
1359
|
antd.DatePicker.RangePicker,
|
|
1357
1360
|
{
|
|
1358
1361
|
onChange: (dates) => {
|
|
1359
|
-
setSelectedKeys(
|
|
1362
|
+
setSelectedKeys(
|
|
1363
|
+
(dates == null ? void 0 : dates[0]) && dates[1] ? [
|
|
1364
|
+
[
|
|
1365
|
+
dates[0].startOf("day").toISOString(),
|
|
1366
|
+
dates[1].endOf("day").toISOString()
|
|
1367
|
+
]
|
|
1368
|
+
] : []
|
|
1369
|
+
);
|
|
1360
1370
|
confirm();
|
|
1361
1371
|
}
|
|
1362
1372
|
}
|
|
@@ -1439,19 +1449,7 @@ function Table(props) {
|
|
|
1439
1449
|
dataSource: props.dataSource
|
|
1440
1450
|
}
|
|
1441
1451
|
);
|
|
1442
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1443
|
-
FaasDataWrapper,
|
|
1444
|
-
{
|
|
1445
|
-
...props.faasData,
|
|
1446
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1447
|
-
FaasDataTable,
|
|
1448
|
-
{
|
|
1449
|
-
props,
|
|
1450
|
-
columns
|
|
1451
|
-
}
|
|
1452
|
-
)
|
|
1453
|
-
}
|
|
1454
|
-
);
|
|
1452
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, { ...props.faasData, children: /* @__PURE__ */ jsxRuntime.jsx(FaasDataTable, { props, columns }) });
|
|
1455
1453
|
}
|
|
1456
1454
|
function FaasDataTable({
|
|
1457
1455
|
props,
|
|
@@ -1465,11 +1463,12 @@ function FaasDataTable({
|
|
|
1465
1463
|
if (!data || Array.isArray(data))
|
|
1466
1464
|
return;
|
|
1467
1465
|
setCurrentColumns((prev) => {
|
|
1466
|
+
var _a;
|
|
1468
1467
|
const newColumns = [...prev];
|
|
1469
1468
|
for (const column of newColumns) {
|
|
1470
|
-
if (
|
|
1471
|
-
column.options = data
|
|
1472
|
-
column.filters = data
|
|
1469
|
+
if ((_a = data.options) == null ? void 0 : _a[column.id]) {
|
|
1470
|
+
column.options = data.options[column.id];
|
|
1471
|
+
column.filters = data.options[column.id].map((v) => ({
|
|
1473
1472
|
text: v.label,
|
|
1474
1473
|
value: v.value
|
|
1475
1474
|
})).concat({
|
|
@@ -1574,14 +1573,7 @@ function Title(props) {
|
|
|
1574
1573
|
if (props.h1) {
|
|
1575
1574
|
if (typeof props.h1 === "boolean")
|
|
1576
1575
|
return /* @__PURE__ */ jsxRuntime.jsx("h1", { children: Array.isArray(props.title) ? props.title[0] : props.title });
|
|
1577
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1578
|
-
"h1",
|
|
1579
|
-
{
|
|
1580
|
-
className: props.h1.className,
|
|
1581
|
-
style: props.h1.style,
|
|
1582
|
-
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1583
|
-
}
|
|
1584
|
-
);
|
|
1576
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h1", { className: props.h1.className, style: props.h1.style, children: Array.isArray(props.title) ? props.title[0] : props.title });
|
|
1585
1577
|
}
|
|
1586
1578
|
if (props.plain)
|
|
1587
1579
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: Array.isArray(props.title) ? props.title[0] : props.title });
|