szld-libs 0.3.49 → 0.3.51

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.
@@ -398,7 +398,7 @@ function useDynamicForm(props) {
398
398
  }
399
399
  return null;
400
400
  },
401
- [handleDealInstruction, func.handleSetFormItemInitialValue, handleSetFormItemProps, renderNestedFormList]
401
+ [handleDealInstruction, func.handleSetFormItemInitialValue, handleSetFormItemProps, renderNestedFormList, langConfig]
402
402
  );
403
403
  const handleOnRemove = async (file) => {
404
404
  var _a;
@@ -423,297 +423,300 @@ function useDynamicForm(props) {
423
423
  return false;
424
424
  }
425
425
  };
426
- const handleRenderItemInputMode = ({
427
- item,
428
- readonly = false,
429
- formItemStyle = [],
430
- radioAlign = "horizontal",
431
- relatedid,
432
- form,
433
- defaultWidth = 358,
434
- customWidth = {}
435
- }) => {
436
- var _a, _b, _c, _d, _e, _f;
437
- const mode = item.json.input || "text";
438
- const format = ((_a = item.json) == null ? void 0 : _a.format) || "";
439
- const attrid = item.attrid;
440
- const formatValue = func.handleSetFormItemInitialValue(item);
441
- const message2 = func.getTitle(langConfig, (_b = item.json) == null ? void 0 : _b["default-prompt"]) || "";
442
- const disableDateGoover = ((_c = item.json) == null ? void 0 : _c["disable-date-goover"]) || false;
443
- const placeholder = func.handleGetPlaceholder(item, langId);
444
- const params = item.json.length && {
445
- maxLength: item.json.length
446
- } || {};
447
- const itemStyle = formItemStyle.find((v) => v.type === mode);
448
- let inputWidth = (_d = item.json) == null ? void 0 : _d["input-width"];
449
- if (inputWidth) {
450
- inputWidth = formShowType === "table" ? Number(inputWidth) - 32 : inputWidth;
451
- }
452
- const width = inputWidth || defaultWidth;
453
- switch (mode) {
454
- case "label":
455
- return /* @__PURE__ */ jsxRuntime.jsx(
456
- antd.Input,
457
- {
458
- disabled: true,
459
- value: ((_e = item.json) == null ? void 0 : _e["label-value"]) || item.attrvalue || ((_f = item.json) == null ? void 0 : _f.default) || "-",
460
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
461
- }
462
- );
463
- case "text":
464
- return /* @__PURE__ */ jsxRuntime.jsx(
465
- antd.Input,
466
- {
467
- placeholder: message2 || placeholder,
468
- ...params,
469
- disabled: readonly,
470
- allowClear: true,
471
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
472
- }
473
- );
474
- case "password":
475
- return /* @__PURE__ */ jsxRuntime.jsx(
476
- antd.Input.Password,
477
- {
478
- placeholder: message2 || placeholder,
479
- ...params,
480
- disabled: readonly,
481
- allowClear: true,
482
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
483
- }
484
- );
485
- case "textarea":
486
- return /* @__PURE__ */ jsxRuntime.jsx(
487
- antd.Input.TextArea,
488
- {
489
- allowClear: true,
490
- placeholder: message2 || placeholder,
491
- rows: 5,
492
- ...params,
493
- disabled: readonly,
494
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
495
- }
496
- );
497
- case "number":
498
- return /* @__PURE__ */ jsxRuntime.jsx(
499
- antd.InputNumber,
500
- {
501
- controls: false,
502
- placeholder: message2 || placeholder,
503
- ...params,
504
- disabled: readonly,
505
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
506
- }
507
- );
508
- case "select":
509
- case "mult-select": {
510
- return /* @__PURE__ */ jsxRuntime.jsx(
511
- MySelect,
512
- {
513
- item: item.json,
514
- readonly,
515
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
516
- commonRequestWidthParams,
517
- commonRequest,
518
- value: formatValue,
519
- interfaceTypeDict,
520
- interfaceTypeSysDict,
521
- actionUrlKey,
522
- actionUrlExtraParams,
523
- langId,
524
- langConfig,
525
- onChange: (val) => {
526
- form.setFieldValue(item.attrid, val);
527
- }
528
- }
529
- );
530
- }
531
- case "modal-mult-select":
532
- case "modal-select": {
533
- return /* @__PURE__ */ jsxRuntime.jsx(
534
- SelectModel,
535
- {
536
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
537
- item: item.json,
538
- value: item.attrvalue || item.json.default || "",
539
- commonRequestWidthParams,
540
- commonRequest,
541
- onSure: async (value) => {
542
- form.setFieldValue(item.attrid, value);
543
- },
544
- disabled: readonly,
545
- langId,
546
- CustomModalComponent
547
- }
548
- );
549
- }
550
- case "mul-field-modal-select": {
551
- return /* @__PURE__ */ jsxRuntime.jsx(
552
- SelectModelBackfillFormItem,
553
- {
554
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
555
- item: item.json,
556
- form,
557
- attrid,
558
- value: item.attrvalue || item.json.default || "",
559
- commonRequestWidthParams,
560
- commonRequest,
561
- onSure: async (value) => {
562
- form.setFieldsValue(value);
563
- },
564
- disabled: readonly,
565
- CustomModalComponent,
566
- langId
567
- }
568
- );
426
+ const handleRenderItemInputMode = react.useCallback(
427
+ ({
428
+ item,
429
+ readonly = false,
430
+ formItemStyle = [],
431
+ radioAlign = "horizontal",
432
+ relatedid,
433
+ form,
434
+ defaultWidth = 358,
435
+ customWidth = {}
436
+ }) => {
437
+ var _a, _b, _c, _d, _e, _f;
438
+ const mode = item.json.input || "text";
439
+ const format = ((_a = item.json) == null ? void 0 : _a.format) || "";
440
+ const attrid = item.attrid;
441
+ const formatValue = func.handleSetFormItemInitialValue(item);
442
+ const message2 = func.getTitle(langConfig, (_b = item.json) == null ? void 0 : _b["default-prompt"]) || "";
443
+ const disableDateGoover = ((_c = item.json) == null ? void 0 : _c["disable-date-goover"]) || false;
444
+ const placeholder = func.handleGetPlaceholder(item, langId);
445
+ const params = item.json.length && {
446
+ maxLength: item.json.length
447
+ } || {};
448
+ const itemStyle = formItemStyle.find((v) => v.type === mode);
449
+ let inputWidth = (_d = item.json) == null ? void 0 : _d["input-width"];
450
+ if (inputWidth) {
451
+ inputWidth = formShowType === "table" ? Number(inputWidth) - 32 : inputWidth;
569
452
  }
570
- case "date-picker":
571
- case "time-picker":
572
- case "week-picker":
573
- case "month-picker":
574
- case "quarter-picker":
575
- case "year-picker":
576
- case "second-picker": {
577
- const pickerObj = {
578
- "date-picker": "date",
579
- "time-picker": "date",
580
- "week-picker": "week",
581
- "month-picker": "month",
582
- "quarter-picker": "quarter",
583
- "year-picker": "year",
584
- "second-picker": "time"
585
- };
586
- let disabledDateFunc = void 0;
587
- if (mode === "date-picker") {
588
- disabledDateFunc = disableDateGoover ? func.disabledDate : void 0;
453
+ const width = inputWidth || defaultWidth;
454
+ switch (mode) {
455
+ case "label":
456
+ return /* @__PURE__ */ jsxRuntime.jsx(
457
+ antd.Input,
458
+ {
459
+ disabled: true,
460
+ value: ((_e = item.json) == null ? void 0 : _e["label-value"]) || item.attrvalue || ((_f = item.json) == null ? void 0 : _f.default) || "-",
461
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
462
+ }
463
+ );
464
+ case "text":
465
+ return /* @__PURE__ */ jsxRuntime.jsx(
466
+ antd.Input,
467
+ {
468
+ placeholder: message2 || placeholder,
469
+ ...params,
470
+ disabled: readonly,
471
+ allowClear: true,
472
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
473
+ }
474
+ );
475
+ case "password":
476
+ return /* @__PURE__ */ jsxRuntime.jsx(
477
+ antd.Input.Password,
478
+ {
479
+ placeholder: message2 || placeholder,
480
+ ...params,
481
+ disabled: readonly,
482
+ allowClear: true,
483
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
484
+ }
485
+ );
486
+ case "textarea":
487
+ return /* @__PURE__ */ jsxRuntime.jsx(
488
+ antd.Input.TextArea,
489
+ {
490
+ allowClear: true,
491
+ placeholder: message2 || placeholder,
492
+ rows: 5,
493
+ ...params,
494
+ disabled: readonly,
495
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
496
+ }
497
+ );
498
+ case "number":
499
+ return /* @__PURE__ */ jsxRuntime.jsx(
500
+ antd.InputNumber,
501
+ {
502
+ controls: false,
503
+ placeholder: message2 || placeholder,
504
+ ...params,
505
+ disabled: readonly,
506
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
507
+ }
508
+ );
509
+ case "select":
510
+ case "mult-select": {
511
+ return /* @__PURE__ */ jsxRuntime.jsx(
512
+ MySelect,
513
+ {
514
+ item: item.json,
515
+ readonly,
516
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
517
+ commonRequestWidthParams,
518
+ commonRequest,
519
+ value: formatValue,
520
+ interfaceTypeDict,
521
+ interfaceTypeSysDict,
522
+ actionUrlKey,
523
+ actionUrlExtraParams,
524
+ langId,
525
+ langConfig,
526
+ onChange: (val) => {
527
+ form.setFieldValue(item.attrid, val);
528
+ }
529
+ }
530
+ );
589
531
  }
590
- return /* @__PURE__ */ jsxRuntime.jsx(
591
- antd.DatePicker,
592
- {
593
- showTime: mode === "time-picker",
594
- format: format ? format : void 0,
595
- picker: pickerObj[mode] || "date",
596
- disabled: readonly,
597
- disabledDate: disabledDateFunc,
598
- placement: "bottomLeft",
599
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
600
- }
601
- );
602
- }
603
- case "range-picker":
604
- return /* @__PURE__ */ jsxRuntime.jsx(
605
- antd.DatePicker.RangePicker,
606
- {
607
- disabledDate: disableDateGoover ? func.disabledDate : void 0,
608
- disabled: readonly,
609
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
610
- }
611
- );
612
- case "multiple-date-picker":
613
- return /* @__PURE__ */ jsxRuntime.jsx(antd.DatePicker, { multiple: true, disabled: readonly, style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth } });
614
- case "radio":
615
- return /* @__PURE__ */ jsxRuntime.jsx(
616
- MyRadio,
617
- {
618
- radioAlign,
619
- commonRequest,
620
- commonRequestWidthParams,
621
- item: item.json,
622
- readonly,
623
- options: params,
624
- handleUrlOptions: method.handleUrlOptions,
625
- value: formatValue,
626
- interfaceTypeDict,
627
- interfaceTypeSysDict,
628
- actionUrlKey,
629
- actionUrlExtraParams,
630
- langConfig,
631
- onChange: (e) => {
632
- form.setFieldValue(item.attrid, e.target.value);
532
+ case "modal-mult-select":
533
+ case "modal-select": {
534
+ return /* @__PURE__ */ jsxRuntime.jsx(
535
+ SelectModel,
536
+ {
537
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
538
+ item: item.json,
539
+ value: item.attrvalue || item.json.default || "",
540
+ commonRequestWidthParams,
541
+ commonRequest,
542
+ onSure: async (value) => {
543
+ form.setFieldValue(item.attrid, value);
544
+ },
545
+ disabled: readonly,
546
+ langId,
547
+ CustomModalComponent
633
548
  }
634
- }
635
- );
636
- case "checkbox":
637
- return /* @__PURE__ */ jsxRuntime.jsx(
638
- MyCheckbox,
639
- {
640
- radioAlign,
641
- commonRequest,
642
- commonRequestWidthParams,
643
- item: item.json,
644
- readonly,
645
- options: params,
646
- value: formatValue,
647
- handleUrlOptions: method.handleUrlOptions,
648
- interfaceTypeDict,
649
- interfaceTypeSysDict,
650
- actionUrlKey,
651
- actionUrlExtraParams,
652
- onChange: (val) => {
653
- form.setFieldValue(item.attrid, val.join(","));
549
+ );
550
+ }
551
+ case "mul-field-modal-select": {
552
+ return /* @__PURE__ */ jsxRuntime.jsx(
553
+ SelectModelBackfillFormItem,
554
+ {
555
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
556
+ item: item.json,
557
+ form,
558
+ attrid,
559
+ value: item.attrvalue || item.json.default || "",
560
+ commonRequestWidthParams,
561
+ commonRequest,
562
+ onSure: async (value) => {
563
+ form.setFieldsValue(value);
564
+ },
565
+ disabled: readonly,
566
+ CustomModalComponent,
567
+ langId
654
568
  }
569
+ );
570
+ }
571
+ case "date-picker":
572
+ case "time-picker":
573
+ case "week-picker":
574
+ case "month-picker":
575
+ case "quarter-picker":
576
+ case "year-picker":
577
+ case "second-picker": {
578
+ const pickerObj = {
579
+ "date-picker": "date",
580
+ "time-picker": "date",
581
+ "week-picker": "week",
582
+ "month-picker": "month",
583
+ "quarter-picker": "quarter",
584
+ "year-picker": "year",
585
+ "second-picker": "time"
586
+ };
587
+ let disabledDateFunc = void 0;
588
+ if (mode === "date-picker") {
589
+ disabledDateFunc = disableDateGoover ? func.disabledDate : void 0;
655
590
  }
656
- );
657
- case "audio":
658
- case "file":
659
- case "image":
660
- case "video":
661
- return /* @__PURE__ */ jsxRuntime.jsx(
662
- MyUpload,
663
- {
664
- action: uploadAction && uploadAction("initializationfile"),
665
- item: item.json,
666
- uploadType: mode,
667
- langId,
668
- list: formatValue,
669
- readonly,
670
- relatedid,
671
- relatedidKey,
672
- onRemove: (file) => handleOnRemove(file)
673
- }
674
- );
675
- case "cascader":
676
- return /* @__PURE__ */ jsxRuntime.jsx(
677
- MyCascader,
678
- {
679
- commonRequestWidthParams,
680
- commonRequest,
681
- item: item.json,
682
- value: item.attrvalue,
683
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
684
- interfaceTypeDict,
685
- interfaceTypeSysDict,
686
- actionUrlKey,
687
- actionUrlExtraParams,
688
- langId
689
- }
690
- );
691
- case "radio-card":
692
- return /* @__PURE__ */ jsxRuntime.jsx(
693
- RadioCard,
694
- {
695
- item: item.json,
696
- readonly,
697
- onChange: (value) => {
698
- form.setFieldValue(item.attrid, value);
699
- },
700
- langId,
701
- commonRequestWidthParams
702
- }
703
- );
704
- default:
705
- return /* @__PURE__ */ jsxRuntime.jsx(
706
- antd.Input,
707
- {
708
- placeholder: message2 || placeholder,
709
- ...params,
710
- showCount: true,
711
- disabled: readonly,
712
- style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
713
- }
714
- );
715
- }
716
- };
591
+ return /* @__PURE__ */ jsxRuntime.jsx(
592
+ antd.DatePicker,
593
+ {
594
+ showTime: mode === "time-picker",
595
+ format: format ? format : void 0,
596
+ picker: pickerObj[mode] || "date",
597
+ disabled: readonly,
598
+ disabledDate: disabledDateFunc,
599
+ placement: "bottomLeft",
600
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
601
+ }
602
+ );
603
+ }
604
+ case "range-picker":
605
+ return /* @__PURE__ */ jsxRuntime.jsx(
606
+ antd.DatePicker.RangePicker,
607
+ {
608
+ disabledDate: disableDateGoover ? func.disabledDate : void 0,
609
+ disabled: readonly,
610
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
611
+ }
612
+ );
613
+ case "multiple-date-picker":
614
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.DatePicker, { multiple: true, disabled: readonly, style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth } });
615
+ case "radio":
616
+ return /* @__PURE__ */ jsxRuntime.jsx(
617
+ MyRadio,
618
+ {
619
+ radioAlign,
620
+ commonRequest,
621
+ commonRequestWidthParams,
622
+ item: item.json,
623
+ readonly,
624
+ options: params,
625
+ handleUrlOptions: method.handleUrlOptions,
626
+ value: formatValue,
627
+ interfaceTypeDict,
628
+ interfaceTypeSysDict,
629
+ actionUrlKey,
630
+ actionUrlExtraParams,
631
+ langConfig,
632
+ onChange: (e) => {
633
+ form.setFieldValue(item.attrid, e.target.value);
634
+ }
635
+ }
636
+ );
637
+ case "checkbox":
638
+ return /* @__PURE__ */ jsxRuntime.jsx(
639
+ MyCheckbox,
640
+ {
641
+ radioAlign,
642
+ commonRequest,
643
+ commonRequestWidthParams,
644
+ item: item.json,
645
+ readonly,
646
+ options: params,
647
+ value: formatValue,
648
+ handleUrlOptions: method.handleUrlOptions,
649
+ interfaceTypeDict,
650
+ interfaceTypeSysDict,
651
+ actionUrlKey,
652
+ actionUrlExtraParams,
653
+ onChange: (val) => {
654
+ form.setFieldValue(item.attrid, val.join(","));
655
+ }
656
+ }
657
+ );
658
+ case "audio":
659
+ case "file":
660
+ case "image":
661
+ case "video":
662
+ return /* @__PURE__ */ jsxRuntime.jsx(
663
+ MyUpload,
664
+ {
665
+ action: uploadAction && uploadAction("initializationfile"),
666
+ item: item.json,
667
+ uploadType: mode,
668
+ langId,
669
+ list: formatValue,
670
+ readonly,
671
+ relatedid,
672
+ relatedidKey,
673
+ onRemove: (file) => handleOnRemove(file)
674
+ }
675
+ );
676
+ case "cascader":
677
+ return /* @__PURE__ */ jsxRuntime.jsx(
678
+ MyCascader,
679
+ {
680
+ commonRequestWidthParams,
681
+ commonRequest,
682
+ item: item.json,
683
+ value: item.attrvalue,
684
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
685
+ interfaceTypeDict,
686
+ interfaceTypeSysDict,
687
+ actionUrlKey,
688
+ actionUrlExtraParams,
689
+ langId
690
+ }
691
+ );
692
+ case "radio-card":
693
+ return /* @__PURE__ */ jsxRuntime.jsx(
694
+ RadioCard,
695
+ {
696
+ item: item.json,
697
+ readonly,
698
+ onChange: (value) => {
699
+ form.setFieldValue(item.attrid, value);
700
+ },
701
+ langId,
702
+ commonRequestWidthParams
703
+ }
704
+ );
705
+ default:
706
+ return /* @__PURE__ */ jsxRuntime.jsx(
707
+ antd.Input,
708
+ {
709
+ placeholder: message2 || placeholder,
710
+ ...params,
711
+ showCount: true,
712
+ disabled: readonly,
713
+ style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
714
+ }
715
+ );
716
+ }
717
+ },
718
+ [langId, langConfig]
719
+ );
717
720
  const handleRenderItem = ({
718
721
  item,
719
722
  readonly = false,
package/lib/index.js CHANGED
@@ -16,19 +16,22 @@ dayjs.locale("zh-cn");
16
16
  const Demo = () => {
17
17
  const formRef = react.useRef(null);
18
18
  const [form] = antd.Form.useForm();
19
- const [list, setList] = react.useState(method.handleAttrList(mock.attrList));
19
+ const [list, setList] = react.useState([]);
20
+ const [langList, setLangList] = react.useState([]);
21
+ const [langId, setLangId] = react.useState("");
20
22
  const onValuesChange = async (values, allValues) => {
21
- const keys = Object.keys(values);
22
- if (keys.includes("6A5984BD547449088172BD33F2A965E8")) {
23
- list.forEach((item) => {
24
- if (item.attrid === "4E507938BE7448E5883CFCD9C962707D") {
25
- item.json.data = ["1", "2", "3"];
26
- item.info = JSON.stringify(item == null ? void 0 : item.json);
27
- }
28
- });
29
- setList([...list]);
30
- }
31
23
  };
24
+ react.useEffect(() => {
25
+ setTimeout(() => {
26
+ setLangList(mock.langConfig);
27
+ }, 2e3);
28
+ setTimeout(() => {
29
+ setLangId("10001");
30
+ }, 300);
31
+ setTimeout(() => {
32
+ setList(method.handleAttrList(mock.attrList));
33
+ }, 4e3);
34
+ }, []);
32
35
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { height: "100vh", display: "flex", flexDirection: "column", gap: 20 }, children: [
33
36
  /* @__PURE__ */ jsxRuntime.jsx(main.BackHeader, { title: "页头组件", isBack: true }),
34
37
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: {}, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Form, { form, onValuesChange, children: [
@@ -46,8 +49,8 @@ const Demo = () => {
46
49
  commonRequest: services.commonRequest,
47
50
  instructionShowMode: "icon",
48
51
  ref: formRef,
49
- langId: "10001",
50
- langConfig: mock.langConfig
52
+ langId,
53
+ langConfig: langList
51
54
  }
52
55
  ),
53
56
  /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { name: "submit", style: { marginLeft: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "primary", htmlType: "submit", children: "提交" }) })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "szld-libs",
3
3
  "private": false,
4
- "version": "0.3.49",
4
+ "version": "0.3.51",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -23,7 +23,7 @@
23
23
  "react-router-dom": "^6.6.1",
24
24
  "react-vant": "^3.3.5",
25
25
  "react-window": "^1.8.9",
26
- "szld-libs": "^0.3.24"
26
+ "szld-libs": "^0.3.50"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/crypto-js": "^4.2.1",