@flowgram.ai/form-materials 0.1.31 → 0.2.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.
Files changed (46) hide show
  1. package/bin/materials.js +21 -5
  2. package/dist/esm/index.js +570 -54
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/index.d.mts +206 -28
  5. package/dist/index.d.ts +206 -28
  6. package/dist/index.js +582 -59
  7. package/dist/index.js.map +1 -1
  8. package/package.json +4 -4
  9. package/src/components/batch-variable-selector/config.json +5 -0
  10. package/src/components/batch-variable-selector/index.tsx +19 -0
  11. package/src/components/constant-input/config.json +6 -0
  12. package/src/components/constant-input/index.tsx +81 -0
  13. package/src/components/constant-input/types.ts +18 -0
  14. package/src/components/dynamic-value-input/config.json +5 -0
  15. package/src/components/dynamic-value-input/index.tsx +77 -0
  16. package/src/components/dynamic-value-input/styles.tsx +19 -0
  17. package/src/components/index.ts +6 -3
  18. package/src/components/json-schema-editor/config.json +1 -1
  19. package/src/components/json-schema-editor/hooks.tsx +35 -24
  20. package/src/components/json-schema-editor/index.tsx +3 -3
  21. package/src/components/json-schema-editor/types.ts +3 -3
  22. package/src/components/type-selector/config.json +1 -1
  23. package/src/components/type-selector/constants.tsx +2 -2
  24. package/src/components/type-selector/index.tsx +11 -8
  25. package/src/components/variable-selector/config.json +2 -2
  26. package/src/components/variable-selector/index.tsx +76 -16
  27. package/src/components/variable-selector/styles.tsx +43 -0
  28. package/src/components/variable-selector/use-variable-tree.tsx +34 -6
  29. package/src/effects/index.ts +2 -0
  30. package/src/effects/provide-batch-input/config.json +5 -0
  31. package/src/effects/provide-batch-input/index.ts +38 -0
  32. package/src/effects/provide-batch-outputs/config.json +5 -0
  33. package/src/effects/provide-batch-outputs/index.ts +34 -0
  34. package/src/index.ts +3 -0
  35. package/src/typings/flow-value/config.json +5 -0
  36. package/src/typings/flow-value/index.ts +27 -0
  37. package/src/typings/index.ts +2 -0
  38. package/src/typings/json-schema/config.json +5 -0
  39. package/src/typings/json-schema/index.ts +31 -0
  40. package/src/utils/format-legacy-refs/config.json +5 -0
  41. package/src/utils/format-legacy-refs/index.ts +153 -0
  42. package/src/utils/format-legacy-refs/readme.md +38 -0
  43. package/src/utils/index.ts +2 -0
  44. package/src/utils/json-schema/config.json +5 -0
  45. package/src/utils/json-schema/index.ts +154 -0
  46. package/src/components/type-selector/types.ts +0 -19
package/dist/index.js CHANGED
@@ -31,20 +31,35 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
33
  ArrayIcons: () => ArrayIcons,
34
+ BatchVariableSelector: () => BatchVariableSelector,
35
+ ConstantInput: () => ConstantInput,
36
+ DynamicValueInput: () => DynamicValueInput,
34
37
  JsonSchemaEditor: () => JsonSchemaEditor,
38
+ JsonSchemaUtils: () => JsonSchemaUtils,
35
39
  TypeSelector: () => TypeSelector,
36
40
  VariableSelector: () => VariableSelector,
37
- VariableTypeIcons: () => VariableTypeIcons
41
+ VariableTypeIcons: () => VariableTypeIcons,
42
+ formatLegacyRefOnInit: () => formatLegacyRefOnInit,
43
+ formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
44
+ formatLegacyRefToNewRef: () => formatLegacyRefToNewRef,
45
+ formatNewRefToLegacyRef: () => formatNewRefToLegacyRef,
46
+ getSchemaIcon: () => getSchemaIcon,
47
+ getTypeSelectValue: () => getTypeSelectValue,
48
+ isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
49
+ isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
50
+ parseTypeSelectValue: () => parseTypeSelectValue,
51
+ provideBatchInputEffect: () => provideBatchInputEffect,
52
+ provideBatchOutputsEffect: () => provideBatchOutputsEffect
38
53
  });
39
54
  module.exports = __toCommonJS(src_exports);
40
55
 
41
56
  // src/components/variable-selector/index.tsx
42
57
  var import_react3 = __toESM(require("react"));
43
- var import_semi_ui2 = require("@douyinfe/semi-ui");
58
+ var import_semi_icons2 = require("@douyinfe/semi-icons");
44
59
 
45
60
  // src/components/variable-selector/use-variable-tree.tsx
46
61
  var import_react2 = __toESM(require("react"));
47
- var import_editor = require("@flowgram.ai/editor");
62
+ var import_editor2 = require("@flowgram.ai/editor");
48
63
  var import_semi_ui = require("@douyinfe/semi-ui");
49
64
 
50
65
  // src/components/type-selector/constants.tsx
@@ -436,18 +451,131 @@ var options = [
436
451
  }
437
452
  ];
438
453
 
454
+ // src/utils/json-schema/index.ts
455
+ var import_lodash = require("lodash");
456
+ var import_editor = require("@flowgram.ai/editor");
457
+ var JsonSchemaUtils;
458
+ ((JsonSchemaUtils2) => {
459
+ function schemaToAST(jsonSchema) {
460
+ const { type, extra } = jsonSchema || {};
461
+ const { weak = false } = extra || {};
462
+ if (!type) {
463
+ return void 0;
464
+ }
465
+ switch (type) {
466
+ case "object":
467
+ if (weak) {
468
+ return { kind: import_editor.ASTKind.Object, weak: true };
469
+ }
470
+ return import_editor.ASTFactory.createObject({
471
+ properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash.get)(a?.[1], "extra.index") || 0) - ((0, import_lodash.get)(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
472
+ key,
473
+ type: schemaToAST(_property),
474
+ meta: { description: _property.description }
475
+ }))
476
+ });
477
+ case "array":
478
+ if (weak) {
479
+ return { kind: import_editor.ASTKind.Array, weak: true };
480
+ }
481
+ return import_editor.ASTFactory.createArray({
482
+ items: schemaToAST(jsonSchema.items)
483
+ });
484
+ case "map":
485
+ if (weak) {
486
+ return { kind: import_editor.ASTKind.Map, weak: true };
487
+ }
488
+ return import_editor.ASTFactory.createMap({
489
+ valueType: schemaToAST(jsonSchema.additionalProperties)
490
+ });
491
+ case "string":
492
+ return import_editor.ASTFactory.createString();
493
+ case "number":
494
+ return import_editor.ASTFactory.createNumber();
495
+ case "boolean":
496
+ return import_editor.ASTFactory.createBoolean();
497
+ case "integer":
498
+ return import_editor.ASTFactory.createInteger();
499
+ default:
500
+ return import_editor.ASTFactory.createCustomType({ typeName: type });
501
+ }
502
+ }
503
+ JsonSchemaUtils2.schemaToAST = schemaToAST;
504
+ function astToSchema(typeAST) {
505
+ if (import_editor.ASTMatch.isString(typeAST)) {
506
+ return {
507
+ type: "string"
508
+ };
509
+ }
510
+ if (import_editor.ASTMatch.isBoolean(typeAST)) {
511
+ return {
512
+ type: "boolean"
513
+ };
514
+ }
515
+ if (import_editor.ASTMatch.isNumber(typeAST)) {
516
+ return {
517
+ type: "number"
518
+ };
519
+ }
520
+ if (import_editor.ASTMatch.isInteger(typeAST)) {
521
+ return {
522
+ type: "integer"
523
+ };
524
+ }
525
+ if (import_editor.ASTMatch.isObject(typeAST)) {
526
+ return {
527
+ type: "object",
528
+ properties: Object.fromEntries(
529
+ Object.entries(typeAST.properties).map(([key, value]) => [key, astToSchema(value)])
530
+ )
531
+ };
532
+ }
533
+ if (import_editor.ASTMatch.isArray(typeAST)) {
534
+ return {
535
+ type: "array",
536
+ items: astToSchema(typeAST.items)
537
+ };
538
+ }
539
+ if (import_editor.ASTMatch.isMap(typeAST)) {
540
+ return {
541
+ type: "map",
542
+ items: astToSchema(typeAST.valueType)
543
+ };
544
+ }
545
+ if (import_editor.ASTMatch.isCustomType(typeAST)) {
546
+ return {
547
+ type: typeAST.typeName
548
+ };
549
+ }
550
+ return void 0;
551
+ }
552
+ JsonSchemaUtils2.astToSchema = astToSchema;
553
+ function isASTMatchSchema(typeAST, schema) {
554
+ if (Array.isArray(schema)) {
555
+ return typeAST.isTypeEqual(
556
+ import_editor.ASTFactory.createUnion({
557
+ types: schema.map((_schema) => schemaToAST(_schema)).filter(Boolean)
558
+ })
559
+ );
560
+ }
561
+ return typeAST.isTypeEqual(schemaToAST(schema));
562
+ }
563
+ JsonSchemaUtils2.isASTMatchSchema = isASTMatchSchema;
564
+ })(JsonSchemaUtils || (JsonSchemaUtils = {}));
565
+
439
566
  // src/components/variable-selector/use-variable-tree.tsx
440
- function useVariableTree() {
441
- const available = (0, import_editor.useScopeAvailable)();
567
+ function useVariableTree(params) {
568
+ const { includeSchema, excludeSchema } = params;
569
+ const available = (0, import_editor2.useScopeAvailable)();
442
570
  const getVariableTypeIcon = (0, import_react2.useCallback)((variable) => {
443
- if (variable.meta.icon) {
571
+ if (variable.meta?.icon) {
444
572
  if (typeof variable.meta.icon === "string") {
445
573
  return /* @__PURE__ */ import_react2.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
446
574
  }
447
575
  return variable.meta.icon;
448
576
  }
449
577
  const _type = variable.type;
450
- if (import_editor.ASTMatch.isArray(_type)) {
578
+ if (import_editor2.ASTMatch.isArray(_type)) {
451
579
  return /* @__PURE__ */ import_react2.default.createElement(
452
580
  import_semi_ui.Icon,
453
581
  {
@@ -456,32 +584,87 @@ function useVariableTree() {
456
584
  }
457
585
  );
458
586
  }
459
- if (import_editor.ASTMatch.isCustomType(_type)) {
587
+ if (import_editor2.ASTMatch.isCustomType(_type)) {
460
588
  return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
461
589
  }
462
590
  return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
463
591
  }, []);
464
592
  const renderVariable = (variable, parentFields = []) => {
465
593
  let type = variable?.type;
594
+ if (!type) {
595
+ return null;
596
+ }
466
597
  let children;
467
- if (import_editor.ASTMatch.isObject(type)) {
598
+ if (import_editor2.ASTMatch.isObject(type)) {
468
599
  children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
469
600
  if (!children?.length) {
470
601
  return null;
471
602
  }
472
603
  }
473
- const currPath = [...parentFields.map((_field) => _field.key), variable.key].join(".");
604
+ const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
605
+ const key = keyPath.join(".");
606
+ const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
607
+ const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
608
+ const isSchemaMatch = isSchemaInclude && !isSchemaExclude;
609
+ if (!isSchemaMatch && !children?.length) {
610
+ return null;
611
+ }
474
612
  return {
475
- key: currPath,
476
- label: variable.meta.title || variable.key,
477
- value: currPath,
613
+ key,
614
+ label: variable.meta?.title || variable.key,
615
+ value: key,
616
+ keyPath,
478
617
  icon: getVariableTypeIcon(variable),
479
- children
618
+ children,
619
+ disabled: !isSchemaMatch,
620
+ rootMeta: parentFields[0]?.meta
480
621
  };
481
622
  };
482
623
  return [...available.variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
483
624
  }
484
625
 
626
+ // src/components/variable-selector/styles.tsx
627
+ var import_styled_components = __toESM(require("styled-components"));
628
+ var import_semi_ui2 = require("@douyinfe/semi-ui");
629
+ var UIRootTitle = import_styled_components.default.span`
630
+ margin-right: 4px;
631
+ color: var(--semi-color-text-2);
632
+ `;
633
+ var UITag = (0, import_styled_components.default)(import_semi_ui2.Tag)`
634
+ width: 100%;
635
+ display: flex;
636
+ align-items: center;
637
+ justify-content: flex-start;
638
+
639
+ & .semi-tag-content-center {
640
+ justify-content: flex-start;
641
+ }
642
+
643
+ &.semi-tag {
644
+ margin: 0;
645
+ }
646
+ `;
647
+ var UITreeSelect = (0, import_styled_components.default)(import_semi_ui2.TreeSelect)`
648
+ outline: ${({ $error }) => $error ? "1px solid red" : "none"};
649
+
650
+ height: 22px;
651
+ min-height: 22px;
652
+ line-height: 22px;
653
+
654
+ & .semi-tree-select-selection {
655
+ padding: 0 2px;
656
+ height: 22px;
657
+ }
658
+
659
+ & .semi-tree-select-selection-content {
660
+ width: 100%;
661
+ }
662
+
663
+ & .semi-tree-select-selection-placeholder {
664
+ padding-left: 10px;
665
+ }
666
+ `;
667
+
485
668
  // src/components/variable-selector/index.tsx
486
669
  var VariableSelector = ({
487
670
  value,
@@ -489,26 +672,70 @@ var VariableSelector = ({
489
672
  onChange,
490
673
  style,
491
674
  readonly = false,
492
- hasError
675
+ includeSchema,
676
+ excludeSchema,
677
+ hasError,
678
+ triggerRender
493
679
  }) => {
494
- const treeData = useVariableTree();
680
+ const treeData = useVariableTree({ includeSchema, excludeSchema });
681
+ const treeValue = (0, import_react3.useMemo)(() => {
682
+ if (typeof value === "string") {
683
+ console.warn(
684
+ "The Value of VariableSelector is a string, it should be an ARRAY. \n",
685
+ "Please check the value of VariableSelector \n"
686
+ );
687
+ return value;
688
+ }
689
+ return value?.join(".");
690
+ }, [value]);
691
+ const renderIcon = (icon) => {
692
+ if (typeof icon === "string") {
693
+ return /* @__PURE__ */ import_react3.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
694
+ }
695
+ return icon;
696
+ };
495
697
  return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(
496
- import_semi_ui2.TreeSelect,
698
+ UITreeSelect,
497
699
  {
498
700
  dropdownMatchSelectWidth: false,
499
701
  disabled: readonly,
500
702
  treeData,
501
703
  size: "small",
502
- value,
503
- style: {
504
- ...style,
505
- outline: hasError ? "1px solid red" : void 0
506
- },
704
+ value: treeValue,
705
+ clearIcon: null,
706
+ $error: hasError,
707
+ style,
507
708
  validateStatus: hasError ? "error" : void 0,
508
- onChange: (option) => {
509
- onChange(option);
709
+ onChange: (_, _config) => {
710
+ onChange(_config.keyPath);
711
+ },
712
+ renderSelectedItem: (_option) => {
713
+ if (!_option?.keyPath) {
714
+ return /* @__PURE__ */ import_react3.default.createElement(
715
+ UITag,
716
+ {
717
+ prefixIcon: /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconIssueStroked, null),
718
+ color: "amber",
719
+ closable: !readonly,
720
+ onClose: () => onChange(void 0)
721
+ },
722
+ config?.notFoundContent ?? "Undefined"
723
+ );
724
+ }
725
+ return /* @__PURE__ */ import_react3.default.createElement(
726
+ UITag,
727
+ {
728
+ prefixIcon: renderIcon(_option.rootMeta?.icon || _option?.icon),
729
+ closable: !readonly,
730
+ onClose: () => onChange(void 0)
731
+ },
732
+ /* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null),
733
+ _option.label
734
+ );
510
735
  },
511
- showClear: true,
736
+ showClear: false,
737
+ arrowIcon: value ? null : /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconChevronDownStroked, { size: "small" }),
738
+ triggerRender,
512
739
  placeholder: config?.placeholder ?? "Select Variable..."
513
740
  }
514
741
  ));
@@ -531,13 +758,14 @@ var parseTypeSelectValue = (value) => {
531
758
  return { type };
532
759
  };
533
760
  function TypeSelector(props) {
534
- const { value, onChange } = props;
761
+ const { value, onChange, disabled, style } = props;
535
762
  const selectValue = (0, import_react4.useMemo)(() => getTypeSelectValue(value), [value]);
536
763
  return /* @__PURE__ */ import_react4.default.createElement(
537
764
  import_semi_ui3.Cascader,
538
765
  {
766
+ disabled,
539
767
  size: "small",
540
- triggerRender: () => /* @__PURE__ */ import_react4.default.createElement(import_semi_ui3.Button, { size: "small", style: { width: 50 } }, getSchemaIcon(value)),
768
+ triggerRender: () => /* @__PURE__ */ import_react4.default.createElement(import_semi_ui3.Button, { size: "small", style }, getSchemaIcon(value)),
541
769
  treeData: options,
542
770
  value: selectValue,
543
771
  leafOnly: true,
@@ -551,52 +779,52 @@ function TypeSelector(props) {
551
779
  // src/components/json-schema-editor/index.tsx
552
780
  var import_react7 = __toESM(require("react"));
553
781
  var import_semi_ui4 = require("@douyinfe/semi-ui");
554
- var import_semi_icons3 = require("@douyinfe/semi-icons");
782
+ var import_semi_icons4 = require("@douyinfe/semi-icons");
555
783
 
556
784
  // src/components/json-schema-editor/styles.tsx
557
785
  var import_react5 = __toESM(require("react"));
558
- var import_styled_components = __toESM(require("styled-components"));
559
- var import_semi_icons2 = __toESM(require("@douyinfe/semi-icons"));
560
- var UIContainer = import_styled_components.default.div`
786
+ var import_styled_components2 = __toESM(require("styled-components"));
787
+ var import_semi_icons3 = __toESM(require("@douyinfe/semi-icons"));
788
+ var UIContainer = import_styled_components2.default.div`
561
789
  /* & .semi-input {
562
790
  background-color: #fff;
563
791
  border-radius: 6px;
564
792
  height: 24px;
565
793
  } */
566
794
  `;
567
- var UIRow = import_styled_components.default.div`
795
+ var UIRow = import_styled_components2.default.div`
568
796
  display: flex;
569
797
  align-items: center;
570
798
  gap: 6px;
571
799
  `;
572
- var UICollapseTrigger = import_styled_components.default.div`
800
+ var UICollapseTrigger = import_styled_components2.default.div`
573
801
  cursor: pointer;
574
802
  margin-right: 5px;
575
803
  `;
576
- var UIExpandDetail = import_styled_components.default.div`
804
+ var UIExpandDetail = import_styled_components2.default.div`
577
805
  display: flex;
578
806
  flex-direction: column;
579
807
  `;
580
- var UILabel = import_styled_components.default.div`
808
+ var UILabel = import_styled_components2.default.div`
581
809
  font-size: 12px;
582
810
  color: #999;
583
811
  font-weight: 400;
584
812
  margin-bottom: 2px;
585
813
  `;
586
- var UIProperties = import_styled_components.default.div`
814
+ var UIProperties = import_styled_components2.default.div`
587
815
  display: grid;
588
816
  grid-template-columns: auto 1fr;
589
817
 
590
- ${({ $shrink }) => $shrink && import_styled_components.css`
818
+ ${({ $shrink }) => $shrink && import_styled_components2.css`
591
819
  padding-left: 10px;
592
820
  margin-top: 10px;
593
821
  `}
594
822
  `;
595
- var UIPropertyLeft = import_styled_components.default.div`
823
+ var UIPropertyLeft = import_styled_components2.default.div`
596
824
  grid-column: 1;
597
825
  position: relative;
598
826
 
599
- ${({ $showLine, $isLast }) => $showLine && import_styled_components.css`
827
+ ${({ $showLine, $isLast }) => $showLine && import_styled_components2.css`
600
828
  &::before {
601
829
  /* 竖线 */
602
830
  content: '';
@@ -622,7 +850,7 @@ var UIPropertyLeft = import_styled_components.default.div`
622
850
  }
623
851
  `}
624
852
  `;
625
- var UIPropertyRight = import_styled_components.default.div`
853
+ var UIPropertyRight = import_styled_components2.default.div`
626
854
  grid-column: 2;
627
855
  margin-bottom: 10px;
628
856
 
@@ -630,30 +858,30 @@ var UIPropertyRight = import_styled_components.default.div`
630
858
  margin-bottom: 0px;
631
859
  }
632
860
  `;
633
- var UIPropertyMain = import_styled_components.default.div`
861
+ var UIPropertyMain = import_styled_components2.default.div`
634
862
  display: flex;
635
863
  flex-direction: column;
636
864
  gap: 10px;
637
865
 
638
- ${({ $expand }) => $expand && import_styled_components.css`
866
+ ${({ $expand }) => $expand && import_styled_components2.css`
639
867
  background-color: #f5f5f5;
640
868
  padding: 10px;
641
869
  border-radius: 4px;
642
870
  `}
643
871
  `;
644
- var UICollapsible = import_styled_components.default.div`
872
+ var UICollapsible = import_styled_components2.default.div`
645
873
  display: none;
646
874
 
647
- ${({ $collapse }) => $collapse && import_styled_components.css`
875
+ ${({ $collapse }) => $collapse && import_styled_components2.css`
648
876
  display: block;
649
877
  `}
650
878
  `;
651
- var UIName = import_styled_components.default.div`
879
+ var UIName = import_styled_components2.default.div`
652
880
  flex-grow: 1;
653
881
  `;
654
- var UIType = import_styled_components.default.div``;
655
- var UIRequired = import_styled_components.default.div``;
656
- var UIActions = import_styled_components.default.div`
882
+ var UIType = import_styled_components2.default.div``;
883
+ var UIRequired = import_styled_components2.default.div``;
884
+ var UIActions = import_styled_components2.default.div`
657
885
  white-space: nowrap;
658
886
  `;
659
887
  var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
@@ -676,7 +904,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
676
904
  ),
677
905
  /* @__PURE__ */ import_react5.default.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
678
906
  );
679
- var IconAddChildren = () => /* @__PURE__ */ import_react5.default.createElement(import_semi_icons2.default, { size: "small", svg: iconAddChildrenSvg });
907
+ var IconAddChildren = () => /* @__PURE__ */ import_react5.default.createElement(import_semi_icons3.default, { size: "small", svg: iconAddChildrenSvg });
680
908
 
681
909
  // src/components/json-schema-editor/hooks.tsx
682
910
  var import_react6 = require("react");
@@ -697,12 +925,16 @@ function usePropertiesEdit(value, onChange) {
697
925
  const drilldown = (0, import_react6.useMemo)(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
698
926
  const isDrilldownObject = drilldown.schema?.type === "object";
699
927
  const initPropertyList = (0, import_react6.useMemo)(
700
- () => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).map(
701
- ([name, _value]) => ({
928
+ () => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
929
+ ([name, _value], index) => ({
702
930
  key: genId(),
703
931
  name,
704
932
  isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
705
- ..._value
933
+ ..._value,
934
+ extra: {
935
+ ..._value.extra || {},
936
+ index
937
+ }
706
938
  })
707
939
  ) : [],
708
940
  [isDrilldownObject]
@@ -718,7 +950,7 @@ function usePropertiesEdit(value, onChange) {
718
950
  nameMap.set(_property.name, _property);
719
951
  }
720
952
  }
721
- return Object.entries(drilldown.schema?.properties || {}).map(([name, _value]) => {
953
+ return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
722
954
  const _property = nameMap.get(name);
723
955
  if (_property) {
724
956
  return {
@@ -764,7 +996,10 @@ function usePropertiesEdit(value, onChange) {
764
996
  });
765
997
  };
766
998
  const onAddProperty = () => {
767
- updatePropertyList((_list) => [..._list, { key: genId(), name: "", type: "string" }]);
999
+ updatePropertyList((_list) => [
1000
+ ..._list,
1001
+ { key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
1002
+ ]);
768
1003
  };
769
1004
  const onRemoveProperty = (key) => {
770
1005
  updatePropertyList((_list) => _list.filter((_property) => _property.key !== key));
@@ -808,7 +1043,7 @@ function JsonSchemaEditor(props) {
808
1043
  onRemoveProperty(_property.key);
809
1044
  }
810
1045
  }
811
- ))), /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Button, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ import_react7.default.createElement(import_semi_icons3.IconPlus, null), onClick: onAddProperty }, config?.addButtonText ?? "Add"));
1046
+ ))), /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Button, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconPlus, null), onClick: onAddProperty }, config?.addButtonText ?? "Add"));
812
1047
  }
813
1048
  function PropertyEdit(props) {
814
1049
  const { value, config, onChange: onChangeProps, onRemove, $isLast, $showLine } = props;
@@ -824,7 +1059,7 @@ function PropertyEdit(props) {
824
1059
  });
825
1060
  };
826
1061
  const showCollapse = isDrilldownObject && propertyList.length > 0;
827
- return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(UIPropertyLeft, { $isLast, $showLine }, showCollapse && /* @__PURE__ */ import_react7.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react7.default.createElement(import_semi_icons3.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react7.default.createElement(import_semi_icons3.IconChevronRight, { size: "small" }))), /* @__PURE__ */ import_react7.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react7.default.createElement(UIPropertyMain, { $expand: expand }, /* @__PURE__ */ import_react7.default.createElement(UIRow, null, /* @__PURE__ */ import_react7.default.createElement(UIName, null, /* @__PURE__ */ import_react7.default.createElement(
1062
+ return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(UIPropertyLeft, { $isLast, $showLine }, showCollapse && /* @__PURE__ */ import_react7.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconChevronRight, { size: "small" }))), /* @__PURE__ */ import_react7.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react7.default.createElement(UIPropertyMain, { $expand: expand }, /* @__PURE__ */ import_react7.default.createElement(UIRow, null, /* @__PURE__ */ import_react7.default.createElement(UIName, null, /* @__PURE__ */ import_react7.default.createElement(
828
1063
  import_semi_ui4.Input,
829
1064
  {
830
1065
  placeholder: config?.placeholder ?? "Input Variable Name",
@@ -854,7 +1089,7 @@ function PropertyEdit(props) {
854
1089
  {
855
1090
  size: "small",
856
1091
  theme: "borderless",
857
- icon: expand ? /* @__PURE__ */ import_react7.default.createElement(import_semi_icons3.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react7.default.createElement(import_semi_icons3.IconExpand, { size: "small" }),
1092
+ icon: expand ? /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconExpand, { size: "small" }),
858
1093
  onClick: () => setExpand((_expand) => !_expand)
859
1094
  }
860
1095
  ), isDrilldownObject && /* @__PURE__ */ import_react7.default.createElement(
@@ -873,7 +1108,7 @@ function PropertyEdit(props) {
873
1108
  {
874
1109
  size: "small",
875
1110
  theme: "borderless",
876
- icon: /* @__PURE__ */ import_react7.default.createElement(import_semi_icons3.IconMinus, { size: "small" }),
1111
+ icon: /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconMinus, { size: "small" }),
877
1112
  onClick: onRemove
878
1113
  }
879
1114
  ))), expand && /* @__PURE__ */ import_react7.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react7.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react7.default.createElement(
@@ -901,12 +1136,300 @@ function PropertyEdit(props) {
901
1136
  }
902
1137
  ))))));
903
1138
  }
1139
+
1140
+ // src/components/batch-variable-selector/index.tsx
1141
+ var import_react8 = __toESM(require("react"));
1142
+ var import_editor3 = require("@flowgram.ai/editor");
1143
+ var batchVariableSchema = {
1144
+ type: "array",
1145
+ extra: { weak: true }
1146
+ };
1147
+ function BatchVariableSelector(props) {
1148
+ return /* @__PURE__ */ import_react8.default.createElement(import_editor3.PrivateScopeProvider, null, /* @__PURE__ */ import_react8.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1149
+ }
1150
+
1151
+ // src/components/constant-input/index.tsx
1152
+ var import_react9 = __toESM(require("react"));
1153
+ var import_semi_ui5 = require("@douyinfe/semi-ui");
1154
+ var defaultStrategies = [
1155
+ {
1156
+ hit: (schema) => schema?.type === "string",
1157
+ Renderer: (props) => /* @__PURE__ */ import_react9.default.createElement(import_semi_ui5.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
1158
+ },
1159
+ {
1160
+ hit: (schema) => schema?.type === "number",
1161
+ Renderer: (props) => /* @__PURE__ */ import_react9.default.createElement(
1162
+ import_semi_ui5.InputNumber,
1163
+ {
1164
+ placeholder: "Please Input Number",
1165
+ size: "small",
1166
+ disabled: props.readonly,
1167
+ hideButtons: true,
1168
+ ...props
1169
+ }
1170
+ )
1171
+ },
1172
+ {
1173
+ hit: (schema) => schema?.type === "integer",
1174
+ Renderer: (props) => /* @__PURE__ */ import_react9.default.createElement(
1175
+ import_semi_ui5.InputNumber,
1176
+ {
1177
+ placeholder: "Please Input Integer",
1178
+ size: "small",
1179
+ disabled: props.readonly,
1180
+ hideButtons: true,
1181
+ precision: 0,
1182
+ ...props
1183
+ }
1184
+ )
1185
+ },
1186
+ {
1187
+ hit: (schema) => schema?.type === "boolean",
1188
+ Renderer: (props) => {
1189
+ const { value, onChange, ...rest } = props;
1190
+ return /* @__PURE__ */ import_react9.default.createElement(
1191
+ import_semi_ui5.Select,
1192
+ {
1193
+ placeholder: "Please Select Boolean",
1194
+ size: "small",
1195
+ disabled: props.readonly,
1196
+ optionList: [
1197
+ { label: "True", value: 1 },
1198
+ { label: "False", value: 0 }
1199
+ ],
1200
+ value: value ? 1 : 0,
1201
+ onChange: (value2) => onChange?.(!!value2),
1202
+ ...rest
1203
+ }
1204
+ );
1205
+ }
1206
+ }
1207
+ ];
1208
+ function ConstantInput(props) {
1209
+ const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
1210
+ const strategies = (0, import_react9.useMemo)(
1211
+ () => [...defaultStrategies, ...extraStrategies || []],
1212
+ [extraStrategies]
1213
+ );
1214
+ const Renderer = (0, import_react9.useMemo)(() => {
1215
+ const strategy = strategies.find((_strategy) => _strategy.hit(schema));
1216
+ return strategy?.Renderer;
1217
+ }, [strategies, schema]);
1218
+ if (!Renderer) {
1219
+ return /* @__PURE__ */ import_react9.default.createElement(import_semi_ui5.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
1220
+ }
1221
+ return /* @__PURE__ */ import_react9.default.createElement(Renderer, { value, onChange, readonly, ...rest });
1222
+ }
1223
+
1224
+ // src/components/dynamic-value-input/index.tsx
1225
+ var import_react10 = __toESM(require("react"));
1226
+ var import_semi_ui6 = require("@douyinfe/semi-ui");
1227
+ var import_semi_icons5 = require("@douyinfe/semi-icons");
1228
+
1229
+ // src/components/dynamic-value-input/styles.tsx
1230
+ var import_styled_components3 = __toESM(require("styled-components"));
1231
+ var UIContainer2 = import_styled_components3.default.div`
1232
+ display: flex;
1233
+ align-items: center;
1234
+ gap: 5px;
1235
+ `;
1236
+ var UIMain = import_styled_components3.default.div`
1237
+ flex-grow: 1;
1238
+
1239
+ & .semi-tree-select,
1240
+ & .semi-input-number,
1241
+ & .semi-select {
1242
+ width: 100%;
1243
+ }
1244
+ `;
1245
+ var UITrigger = import_styled_components3.default.div``;
1246
+
1247
+ // src/components/dynamic-value-input/index.tsx
1248
+ function DynamicValueInput({
1249
+ value,
1250
+ onChange,
1251
+ readonly,
1252
+ style,
1253
+ schema,
1254
+ constantProps
1255
+ }) {
1256
+ const renderMain = () => {
1257
+ if (value?.type === "ref") {
1258
+ return /* @__PURE__ */ import_react10.default.createElement(
1259
+ VariableSelector,
1260
+ {
1261
+ value: value?.content,
1262
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1263
+ includeSchema: schema,
1264
+ readonly
1265
+ }
1266
+ );
1267
+ }
1268
+ return /* @__PURE__ */ import_react10.default.createElement(
1269
+ ConstantInput,
1270
+ {
1271
+ value: value?.content,
1272
+ onChange: (_v) => onChange({ type: "constant", content: _v }),
1273
+ schema: schema || { type: "string" },
1274
+ readonly,
1275
+ ...constantProps
1276
+ }
1277
+ );
1278
+ };
1279
+ const renderTrigger = () => /* @__PURE__ */ import_react10.default.createElement(
1280
+ VariableSelector,
1281
+ {
1282
+ style: { width: "100%" },
1283
+ value: value?.type === "ref" ? value?.content : void 0,
1284
+ onChange: (_v) => onChange({ type: "ref", content: _v }),
1285
+ includeSchema: schema,
1286
+ readonly,
1287
+ triggerRender: () => /* @__PURE__ */ import_react10.default.createElement(import_semi_ui6.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconSetting, { size: "small" }) })
1288
+ }
1289
+ );
1290
+ return /* @__PURE__ */ import_react10.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react10.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react10.default.createElement(UITrigger, null, renderTrigger()));
1291
+ }
1292
+
1293
+ // src/effects/provide-batch-input/index.ts
1294
+ var import_editor4 = require("@flowgram.ai/editor");
1295
+ var provideBatchInputEffect = (0, import_editor4.createEffectFromVariableProvider)({
1296
+ private: true,
1297
+ parse: (value, ctx) => [
1298
+ import_editor4.ASTFactory.createVariableDeclaration({
1299
+ key: `${ctx.node.id}_locals`,
1300
+ meta: {
1301
+ title: (0, import_editor4.getNodeForm)(ctx.node)?.getValueIn("title"),
1302
+ icon: ctx.node.getNodeRegistry().info?.icon
1303
+ },
1304
+ type: import_editor4.ASTFactory.createObject({
1305
+ properties: [
1306
+ import_editor4.ASTFactory.createProperty({
1307
+ key: "item",
1308
+ initializer: import_editor4.ASTFactory.createEnumerateExpression({
1309
+ enumerateFor: import_editor4.ASTFactory.createKeyPathExpression({
1310
+ keyPath: value.content || []
1311
+ })
1312
+ })
1313
+ }),
1314
+ import_editor4.ASTFactory.createProperty({
1315
+ key: "index",
1316
+ type: import_editor4.ASTFactory.createNumber()
1317
+ })
1318
+ ]
1319
+ })
1320
+ })
1321
+ ]
1322
+ });
1323
+
1324
+ // src/effects/provide-batch-outputs/index.ts
1325
+ var import_editor5 = require("@flowgram.ai/editor");
1326
+ var provideBatchOutputsEffect = (0, import_editor5.createEffectFromVariableProvider)({
1327
+ private: true,
1328
+ parse: (value, ctx) => [
1329
+ import_editor5.ASTFactory.createVariableDeclaration({
1330
+ key: `${ctx.node.id}`,
1331
+ meta: {
1332
+ title: (0, import_editor5.getNodeForm)(ctx.node)?.getValueIn("title"),
1333
+ icon: ctx.node.getNodeRegistry().info?.icon
1334
+ },
1335
+ type: import_editor5.ASTFactory.createObject({
1336
+ properties: Object.entries(value).map(
1337
+ ([_key, value2]) => import_editor5.ASTFactory.createProperty({
1338
+ key: _key,
1339
+ initializer: import_editor5.ASTFactory.createWrapArrayExpression({
1340
+ wrapFor: import_editor5.ASTFactory.createKeyPathExpression({
1341
+ keyPath: value2.content || []
1342
+ })
1343
+ })
1344
+ })
1345
+ )
1346
+ })
1347
+ })
1348
+ ]
1349
+ });
1350
+
1351
+ // src/utils/format-legacy-refs/index.ts
1352
+ var import_lodash2 = require("lodash");
1353
+ function formatLegacyRefOnSubmit(value) {
1354
+ if ((0, import_lodash2.isObject)(value)) {
1355
+ if (isLegacyFlowRefValueSchema(value)) {
1356
+ return formatLegacyRefToNewRef(value);
1357
+ }
1358
+ return Object.fromEntries(
1359
+ Object.entries(value).map(([key, value2]) => [
1360
+ key,
1361
+ formatLegacyRefOnSubmit(value2)
1362
+ ])
1363
+ );
1364
+ }
1365
+ if (Array.isArray(value)) {
1366
+ return value.map(formatLegacyRefOnSubmit);
1367
+ }
1368
+ return value;
1369
+ }
1370
+ function formatLegacyRefOnInit(value) {
1371
+ if ((0, import_lodash2.isObject)(value)) {
1372
+ if (isNewFlowRefValueSchema(value)) {
1373
+ return formatNewRefToLegacyRef(value);
1374
+ }
1375
+ return Object.fromEntries(
1376
+ Object.entries(value).map(([key, value2]) => [
1377
+ key,
1378
+ formatLegacyRefOnInit(value2)
1379
+ ])
1380
+ );
1381
+ }
1382
+ if (Array.isArray(value)) {
1383
+ return value.map(formatLegacyRefOnInit);
1384
+ }
1385
+ return value;
1386
+ }
1387
+ function isLegacyFlowRefValueSchema(value) {
1388
+ return (0, import_lodash2.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
1389
+ }
1390
+ function isNewFlowRefValueSchema(value) {
1391
+ return (0, import_lodash2.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
1392
+ }
1393
+ function formatLegacyRefToNewRef(value) {
1394
+ const keyPath = value.content.split(".");
1395
+ if (keyPath[1] === "outputs") {
1396
+ return {
1397
+ type: "ref",
1398
+ content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
1399
+ };
1400
+ }
1401
+ return {
1402
+ type: "ref",
1403
+ content: keyPath
1404
+ };
1405
+ }
1406
+ function formatNewRefToLegacyRef(value) {
1407
+ return {
1408
+ type: "ref",
1409
+ content: value.content.join(".")
1410
+ };
1411
+ }
904
1412
  // Annotate the CommonJS export names for ESM import in node:
905
1413
  0 && (module.exports = {
906
1414
  ArrayIcons,
1415
+ BatchVariableSelector,
1416
+ ConstantInput,
1417
+ DynamicValueInput,
907
1418
  JsonSchemaEditor,
1419
+ JsonSchemaUtils,
908
1420
  TypeSelector,
909
1421
  VariableSelector,
910
- VariableTypeIcons
1422
+ VariableTypeIcons,
1423
+ formatLegacyRefOnInit,
1424
+ formatLegacyRefOnSubmit,
1425
+ formatLegacyRefToNewRef,
1426
+ formatNewRefToLegacyRef,
1427
+ getSchemaIcon,
1428
+ getTypeSelectValue,
1429
+ isLegacyFlowRefValueSchema,
1430
+ isNewFlowRefValueSchema,
1431
+ parseTypeSelectValue,
1432
+ provideBatchInputEffect,
1433
+ provideBatchOutputsEffect
911
1434
  });
912
1435
  //# sourceMappingURL=index.js.map