szld-libs 0.2.74 → 0.2.76
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/szld-components.es.js +8220 -8207
- package/dist/szld-components.umd.js +42 -42
- package/es/components/DynamicForm/func.d.ts +9 -0
- package/es/components/DynamicForm/func.js +104 -0
- package/es/components/DynamicForm/index.d.ts +2 -1
- package/es/components/DynamicForm/useDynamicForm.js +83 -157
- package/lib/components/DynamicForm/func.d.ts +9 -0
- package/lib/components/DynamicForm/func.js +104 -0
- package/lib/components/DynamicForm/index.d.ts +2 -1
- package/lib/components/DynamicForm/useDynamicForm.js +87 -161
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const
|
|
4
|
-
const react = require("react");
|
|
3
|
+
const func = require("./func");
|
|
5
4
|
const method = require("../../utils/method");
|
|
5
|
+
const react = require("react");
|
|
6
6
|
const isoWeek = require("dayjs/plugin/isoWeek");
|
|
7
7
|
const SelectModel = require("./selectModel");
|
|
8
8
|
const MyCheckbox = require("./myCheckbox");
|
|
@@ -13,6 +13,7 @@ const MySelect = require("./mySelect");
|
|
|
13
13
|
const MyUpload = require("./myUpload");
|
|
14
14
|
const MyRadio = require("./myRadio");
|
|
15
15
|
const _ = require("lodash");
|
|
16
|
+
const icons = require("@ant-design/icons");
|
|
16
17
|
const antd = require("antd");
|
|
17
18
|
dayjs.extend(isoWeek);
|
|
18
19
|
function useDynamicForm(props) {
|
|
@@ -138,75 +139,6 @@ function useDynamicForm(props) {
|
|
|
138
139
|
},
|
|
139
140
|
[handleNormFile]
|
|
140
141
|
);
|
|
141
|
-
const handleSetFormItemInitialValue = react.useCallback((itemWithJson) => {
|
|
142
|
-
var _a, _b, _c, _d, _e;
|
|
143
|
-
const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
|
|
144
|
-
const isFormList = (_b = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _b["properties-multiple"];
|
|
145
|
-
let initialValue = itemWithJson.attrvalue ?? ((_c = itemWithJson.json) == null ? void 0 : _c.default);
|
|
146
|
-
if (inputType === "label" && initialValue) {
|
|
147
|
-
initialValue = ((_d = itemWithJson.json) == null ? void 0 : _d["label-value"]) ?? initialValue ?? "-";
|
|
148
|
-
}
|
|
149
|
-
if ((inputType === "date-picker" || inputType === "time-picker") && initialValue) {
|
|
150
|
-
try {
|
|
151
|
-
const date = dayjs(initialValue);
|
|
152
|
-
initialValue = date.isValid() ? date : void 0;
|
|
153
|
-
} catch (error) {
|
|
154
|
-
initialValue = void 0;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (inputType === "range-picker" && initialValue) {
|
|
158
|
-
try {
|
|
159
|
-
initialValue = initialValue == null ? void 0 : initialValue.split("~");
|
|
160
|
-
initialValue = initialValue.map((v) => dayjs(v));
|
|
161
|
-
} catch (error) {
|
|
162
|
-
initialValue = void 0;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (inputType === "multiple-date-picker" && initialValue) {
|
|
166
|
-
try {
|
|
167
|
-
initialValue = initialValue == null ? void 0 : initialValue.split(",");
|
|
168
|
-
initialValue = initialValue.map((v) => dayjs(v));
|
|
169
|
-
} catch (error) {
|
|
170
|
-
initialValue = void 0;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (inputType === "cascader" && initialValue && typeof initialValue === "string") {
|
|
174
|
-
const delimiter = (_e = itemWithJson.json) == null ? void 0 : _e["cascader-delimiter"];
|
|
175
|
-
if (delimiter) {
|
|
176
|
-
initialValue = initialValue.split(delimiter).filter(Boolean);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (["mult-select", "checkbox"].includes(inputType) && initialValue && typeof initialValue === "string") {
|
|
180
|
-
initialValue = initialValue.split(",").filter(Boolean);
|
|
181
|
-
}
|
|
182
|
-
if (["image", "video", "audio", "file"].includes(inputType) && initialValue) {
|
|
183
|
-
try {
|
|
184
|
-
const fileList = Array.isArray(initialValue) ? initialValue : JSON.parse(initialValue);
|
|
185
|
-
initialValue = fileList.map((file) => ({
|
|
186
|
-
...file,
|
|
187
|
-
url: file.FilePath,
|
|
188
|
-
name: file.FileName,
|
|
189
|
-
uid: file.FileId
|
|
190
|
-
}));
|
|
191
|
-
} catch (error) {
|
|
192
|
-
initialValue = [];
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (isFormList && itemWithJson.attrtype === 1) {
|
|
196
|
-
const children = itemWithJson.children || [];
|
|
197
|
-
if (Array.isArray(children)) {
|
|
198
|
-
initialValue = [
|
|
199
|
-
Object.assign(
|
|
200
|
-
{},
|
|
201
|
-
...children == null ? void 0 : children.map((child) => ({
|
|
202
|
-
[child.attrid]: handleSetFormItemInitialValue(child)
|
|
203
|
-
}))
|
|
204
|
-
)
|
|
205
|
-
];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return initialValue || null;
|
|
209
|
-
}, []);
|
|
210
142
|
const handleCollapseIcon = react.useCallback(
|
|
211
143
|
({ isActive }) => isActive ? /* @__PURE__ */ jsxRuntime.jsx(icons.MinusSquareOutlined, { style: { fontSize: 18, color: "#999" } }) : /* @__PURE__ */ jsxRuntime.jsx(icons.PlusSquareOutlined, { style: { fontSize: 18, color: "#999" } }),
|
|
212
144
|
[]
|
|
@@ -242,11 +174,11 @@ function useDynamicForm(props) {
|
|
|
242
174
|
formListField,
|
|
243
175
|
isShowLabel = true
|
|
244
176
|
}) => {
|
|
245
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
177
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
246
178
|
const isFormList = (_a = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a["properties-multiple"];
|
|
247
179
|
let formListInitValue = [];
|
|
248
180
|
if (isFormList) {
|
|
249
|
-
formListInitValue = handleSetFormItemInitialValue(itemWithJson);
|
|
181
|
+
formListInitValue = func.handleSetFormItemInitialValue(itemWithJson);
|
|
250
182
|
}
|
|
251
183
|
if (((_b = itemWithJson.json) == null ? void 0 : _b.hide) === true || (hideAttrList == null ? void 0 : hideAttrList.includes(itemWithJson.attrid))) {
|
|
252
184
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
@@ -354,85 +286,72 @@ function useDynamicForm(props) {
|
|
|
354
286
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "实例信息" });
|
|
355
287
|
}
|
|
356
288
|
if (itemWithJson.attrtype === 0) {
|
|
357
|
-
let initialValue = handleSetFormItemInitialValue(itemWithJson);
|
|
358
|
-
const message2 = (_c = itemWithJson.json) == null ? void 0 : _c["
|
|
359
|
-
|
|
360
|
-
const { input = "" } = itemWithJson.json || {};
|
|
361
|
-
if ([
|
|
362
|
-
"radio",
|
|
363
|
-
"checkbox",
|
|
364
|
-
"select",
|
|
365
|
-
"mult-select",
|
|
366
|
-
"modal-select",
|
|
367
|
-
"date-picker",
|
|
368
|
-
"range-picker",
|
|
369
|
-
"multiple-date-picker",
|
|
370
|
-
"time-picker",
|
|
371
|
-
"week-picker",
|
|
372
|
-
"month-picker",
|
|
373
|
-
"quarter-picker",
|
|
374
|
-
"year-picker",
|
|
375
|
-
"second-picker"
|
|
376
|
-
].includes(input)) {
|
|
377
|
-
placeholder = "请选择";
|
|
378
|
-
}
|
|
379
|
-
if (["image", "file", "video", "audio"].includes(input)) {
|
|
380
|
-
placeholder = "请上传";
|
|
381
|
-
}
|
|
289
|
+
let initialValue = func.handleSetFormItemInitialValue(itemWithJson);
|
|
290
|
+
const message2 = (_c = itemWithJson.json) == null ? void 0 : _c["default-prompt"];
|
|
291
|
+
const placeholder = func.handleGetPlaceholder(itemWithJson);
|
|
382
292
|
const { combinations = [] } = itemWithJson.json || {};
|
|
383
293
|
if (combinations == null ? void 0 : combinations.length) {
|
|
384
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
294
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
295
|
+
antd.Form.Item,
|
|
296
|
+
{
|
|
297
|
+
label: (_d = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _d["combination-name"],
|
|
298
|
+
required: (_e = itemWithJson.json) == null ? void 0 : _e.must,
|
|
299
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Space.Compact, { children: combinations.map((item, index) => {
|
|
300
|
+
var _a2, _b2, _c2, _d2;
|
|
301
|
+
let initValue = func.handleSetFormItemInitialValue(item);
|
|
302
|
+
let width = defaultWidth;
|
|
303
|
+
const customWidth = {};
|
|
304
|
+
const mode = item.json.input || "text";
|
|
305
|
+
const itemStyle = formItemStyle == null ? void 0 : formItemStyle.find((v) => v.type === mode);
|
|
306
|
+
if (itemStyle) {
|
|
307
|
+
const { width: width2 } = (itemStyle == null ? void 0 : itemStyle.style) || {};
|
|
308
|
+
if (width2) {
|
|
309
|
+
customWidth["width"] = width2;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const widthRatio = (_a2 = item == null ? void 0 : item.json) == null ? void 0 : _a2["combination-width-ratio"];
|
|
313
|
+
const placeholder2 = func.handleGetPlaceholder(item);
|
|
314
|
+
if (widthRatio) {
|
|
315
|
+
width = defaultWidth * widthRatio;
|
|
316
|
+
}
|
|
317
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
318
|
+
antd.Form.Item,
|
|
319
|
+
{
|
|
320
|
+
name: item.attrid,
|
|
321
|
+
noStyle: true,
|
|
322
|
+
initialValue: initValue,
|
|
323
|
+
rules: [
|
|
324
|
+
...((_b2 = item.json) == null ? void 0 : _b2.must) ? [
|
|
325
|
+
{
|
|
326
|
+
required: true,
|
|
327
|
+
message: message2 || `${placeholder2}${item.attrname}`
|
|
328
|
+
}
|
|
329
|
+
] : [],
|
|
330
|
+
...((_c2 = itemWithJson.json) == null ? void 0 : _c2.regexp) ? [
|
|
331
|
+
{
|
|
332
|
+
pattern: new RegExp(itemWithJson.json.regexp),
|
|
333
|
+
message: ((_d2 = itemWithJson.json) == null ? void 0 : _d2["regexp-message"]) || `${itemWithJson.attrname}格式不正确`
|
|
334
|
+
}
|
|
335
|
+
] : []
|
|
336
|
+
],
|
|
337
|
+
...handleSetFormItemProps(item),
|
|
338
|
+
children: handleRenderItemInputMode({
|
|
339
|
+
item,
|
|
340
|
+
readonly,
|
|
341
|
+
formItemStyle,
|
|
342
|
+
radioAlign,
|
|
343
|
+
relatedid,
|
|
344
|
+
form,
|
|
345
|
+
defaultWidth: width,
|
|
346
|
+
customWidth
|
|
347
|
+
})
|
|
348
|
+
},
|
|
349
|
+
index
|
|
350
|
+
);
|
|
351
|
+
}) })
|
|
352
|
+
},
|
|
353
|
+
`${itemWithJson.attrid}+1`
|
|
354
|
+
) });
|
|
436
355
|
}
|
|
437
356
|
if (isFormListItem && formListField) {
|
|
438
357
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -442,16 +361,16 @@ function useDynamicForm(props) {
|
|
|
442
361
|
label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
|
|
443
362
|
initialValue,
|
|
444
363
|
rules: [
|
|
445
|
-
...((
|
|
364
|
+
...((_f = itemWithJson.json) == null ? void 0 : _f.must) ? [
|
|
446
365
|
{
|
|
447
366
|
required: true,
|
|
448
367
|
message: `${placeholder}${itemWithJson.attrname}`
|
|
449
368
|
}
|
|
450
369
|
] : [],
|
|
451
|
-
...((
|
|
370
|
+
...((_g = itemWithJson.json) == null ? void 0 : _g.regexp) ? [
|
|
452
371
|
{
|
|
453
372
|
pattern: new RegExp(itemWithJson.json.regexp),
|
|
454
|
-
message: ((
|
|
373
|
+
message: ((_h = itemWithJson.json) == null ? void 0 : _h["regexp-message"]) || `${itemWithJson.attrname}格式不正确`
|
|
455
374
|
}
|
|
456
375
|
] : []
|
|
457
376
|
],
|
|
@@ -476,16 +395,16 @@ function useDynamicForm(props) {
|
|
|
476
395
|
label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
|
|
477
396
|
initialValue,
|
|
478
397
|
rules: [
|
|
479
|
-
...((
|
|
398
|
+
...((_i = itemWithJson.json) == null ? void 0 : _i.must) ? [
|
|
480
399
|
{
|
|
481
400
|
required: true,
|
|
482
401
|
message: `${placeholder}${itemWithJson.attrname}`
|
|
483
402
|
}
|
|
484
403
|
] : [],
|
|
485
|
-
...((
|
|
404
|
+
...((_j = itemWithJson.json) == null ? void 0 : _j.regexp) ? [
|
|
486
405
|
{
|
|
487
406
|
pattern: new RegExp(itemWithJson.json.regexp),
|
|
488
|
-
message: ((
|
|
407
|
+
message: ((_k = itemWithJson.json) == null ? void 0 : _k["regexp-message"]) || `${itemWithJson.attrname}格式不正确`
|
|
489
408
|
}
|
|
490
409
|
] : []
|
|
491
410
|
],
|
|
@@ -541,10 +460,11 @@ function useDynamicForm(props) {
|
|
|
541
460
|
defaultWidth = 358,
|
|
542
461
|
customWidth = {}
|
|
543
462
|
}) => {
|
|
544
|
-
var _a, _b, _c;
|
|
463
|
+
var _a, _b, _c, _d;
|
|
545
464
|
const mode = item.json.input || "text";
|
|
546
|
-
const formatValue = handleSetFormItemInitialValue(item);
|
|
547
|
-
const message2 = ((_a = item.json) == null ? void 0 : _a
|
|
465
|
+
const formatValue = func.handleSetFormItemInitialValue(item);
|
|
466
|
+
const message2 = ((_a = item.json) == null ? void 0 : _a["default-prompt"]) || "";
|
|
467
|
+
const disableDateGoover = ((_b = item.json) == null ? void 0 : _b["disable-date-goover"]) || false;
|
|
548
468
|
const params = item.json.length && {
|
|
549
469
|
maxLength: item.json.length
|
|
550
470
|
} || {};
|
|
@@ -555,7 +475,7 @@ function useDynamicForm(props) {
|
|
|
555
475
|
antd.Input,
|
|
556
476
|
{
|
|
557
477
|
disabled: true,
|
|
558
|
-
value: ((
|
|
478
|
+
value: ((_c = item.json) == null ? void 0 : _c["label-value"]) || item.attrvalue || ((_d = item.json) == null ? void 0 : _d.default) || "-",
|
|
559
479
|
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
560
480
|
}
|
|
561
481
|
);
|
|
@@ -660,12 +580,17 @@ function useDynamicForm(props) {
|
|
|
660
580
|
"year-picker": "year",
|
|
661
581
|
"second-picker": "time"
|
|
662
582
|
};
|
|
583
|
+
let disabledDateFunc = void 0;
|
|
584
|
+
if (mode === "date-picker") {
|
|
585
|
+
disabledDateFunc = disableDateGoover ? func.disabledDate : void 0;
|
|
586
|
+
}
|
|
663
587
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
664
588
|
antd.DatePicker,
|
|
665
589
|
{
|
|
666
590
|
showTime: mode === "time-picker",
|
|
667
591
|
picker: pickerObj[mode] || "date",
|
|
668
592
|
disabled: readonly,
|
|
593
|
+
disabledDate: disabledDateFunc,
|
|
669
594
|
placement: "bottomLeft",
|
|
670
595
|
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
671
596
|
}
|
|
@@ -675,6 +600,7 @@ function useDynamicForm(props) {
|
|
|
675
600
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
676
601
|
antd.DatePicker.RangePicker,
|
|
677
602
|
{
|
|
603
|
+
disabledDate: disableDateGoover ? func.disabledDate : void 0,
|
|
678
604
|
disabled: readonly,
|
|
679
605
|
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
680
606
|
}
|
|
@@ -830,7 +756,7 @@ function useDynamicForm(props) {
|
|
|
830
756
|
};
|
|
831
757
|
return {
|
|
832
758
|
handleRenderItem,
|
|
833
|
-
handleSetFormItemInitialValue
|
|
759
|
+
handleSetFormItemInitialValue: func.handleSetFormItemInitialValue
|
|
834
760
|
};
|
|
835
761
|
}
|
|
836
762
|
module.exports = useDynamicForm;
|