@flowgram.ai/form-materials 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -78,10 +78,12 @@ __export(src_exports, {
78
78
  listenRefSchemaChange: () => listenRefSchemaChange,
79
79
  listenRefValueChange: () => listenRefValueChange,
80
80
  parseTypeSelectValue: () => parseTypeSelectValue,
81
+ polyfillCreateRoot: () => polyfillCreateRoot,
81
82
  provideBatchInputEffect: () => provideBatchInputEffect,
82
83
  provideBatchOutputsEffect: () => provideBatchOutputsEffect,
83
84
  provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
84
85
  syncVariableTitle: () => syncVariableTitle,
86
+ unstableSetCreateRoot: () => unstableSetCreateRoot,
85
87
  useObjectList: () => useObjectList,
86
88
  useTypeManager: () => useTypeManager,
87
89
  useVariableTree: () => useVariableTree,
@@ -337,6 +339,23 @@ var FlowValueUtils;
337
339
  FlowValueUtils2.inferJsonSchema = inferJsonSchema;
338
340
  })(FlowValueUtils || (FlowValueUtils = {}));
339
341
 
342
+ // src/shared/polyfill-create-root/index.tsx
343
+ var ReactDOM = __toESM(require("react-dom"));
344
+ var unstableCreateRoot = (dom) => ({
345
+ render(children) {
346
+ ReactDOM.render(children, dom);
347
+ },
348
+ unmount() {
349
+ ReactDOM.unmountComponentAtNode(dom);
350
+ }
351
+ });
352
+ function polyfillCreateRoot(dom) {
353
+ return unstableCreateRoot(dom);
354
+ }
355
+ function unstableSetCreateRoot(createRoot) {
356
+ unstableCreateRoot = createRoot;
357
+ }
358
+
340
359
  // src/components/variable-selector/use-variable-tree.tsx
341
360
  var import_react12 = __toESM(require("react"));
342
361
  var import_json_schema5 = require("@flowgram.ai/json-schema");
@@ -449,54 +468,55 @@ var import_preset_code4 = require("@coze-editor/editor/preset-code");
449
468
  // src/components/code-editor/theme/light.ts
450
469
  var import_preset_code2 = require("@coze-editor/editor/preset-code");
451
470
  var colors = {
452
- background: "#F7F7FC",
453
- // syntax
454
- comment: "#000A298A",
455
- key: "#00818C",
456
- string: "#D1009D",
457
- number: "#C74200",
458
- boolean: "#2B57D9",
459
- null: "#2B57D9",
460
- separator: "#0F1529D1"
471
+ background: "#FFFFFF",
472
+ comment: "#6B7280",
473
+ key: "#2563EB",
474
+ variable: "#DC2626",
475
+ string: "#059669",
476
+ number: "#EA580C",
477
+ boolean: "#7C3AED",
478
+ null: "#7C3AED",
479
+ separator: "#374151"
461
480
  };
462
481
  var lightTheme = (0, import_preset_code2.createTheme)({
463
482
  variant: "light",
464
483
  settings: {
465
- background: "#fff",
466
- foreground: "#000",
467
- caret: "#000",
468
- selection: "#d9d9d9",
469
- gutterBackground: "#f0f0f0",
470
- gutterForeground: "#666",
484
+ background: "#FFFFFF",
485
+ foreground: "#1F2937",
486
+ caret: "#2563EB",
487
+ selection: "#E5E7EB",
488
+ gutterBackground: "#F9FAFB",
489
+ gutterForeground: "#6B7280",
471
490
  gutterBorderColor: "transparent",
472
491
  gutterBorderWidth: 0,
473
- lineHighlight: "#e1e1e180",
474
- bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
492
+ lineHighlight: "#F3F4F680",
493
+ bracketColors: ["#F59E0B", "#8B5CF6", "#06B6D4"],
475
494
  tooltip: {
476
- backgroundColor: "#f0f0f0",
477
- color: "#000",
478
- border: "1px solid #ccc"
495
+ backgroundColor: "#FFFFFF",
496
+ color: "#1F2937",
497
+ border: "1px solid #E5E7EB",
498
+ boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"
479
499
  },
480
500
  link: {
481
- color: "#007bff"
501
+ color: "#2563EB"
482
502
  },
483
503
  completionItemHover: {
484
- backgroundColor: "#f0f0f0"
504
+ backgroundColor: "#F3F4F6"
485
505
  },
486
506
  completionItemSelected: {
487
- backgroundColor: "#e0e0e0"
507
+ backgroundColor: "#E5E7EB"
488
508
  },
489
509
  completionItemIcon: {
490
- color: "#333"
510
+ color: "#4B5563"
491
511
  },
492
512
  completionItemLabel: {
493
- color: "#333"
513
+ color: "#1F2937"
494
514
  },
495
515
  completionItemInfo: {
496
- color: "#333"
516
+ color: "#4B5563"
497
517
  },
498
518
  completionItemDetail: {
499
- color: "#666"
519
+ color: "#6B7280"
500
520
  }
501
521
  },
502
522
  styles: [
@@ -509,6 +529,10 @@ var lightTheme = (0, import_preset_code2.createTheme)({
509
529
  tag: [import_preset_code2.tags.propertyName],
510
530
  color: colors.key
511
531
  },
532
+ {
533
+ tag: [import_preset_code2.tags.variableName],
534
+ color: colors.variable
535
+ },
512
536
  {
513
537
  tag: [import_preset_code2.tags.string],
514
538
  color: colors.string
@@ -532,27 +556,44 @@ var lightTheme = (0, import_preset_code2.createTheme)({
532
556
  // markdown
533
557
  {
534
558
  tag: [import_preset_code2.tags.heading],
535
- color: "#3e76ef"
559
+ color: "#2563EB"
536
560
  },
537
561
  {
538
562
  tag: [import_preset_code2.tags.processingInstruction],
539
- color: "#3e76ef"
563
+ color: "#2563EB"
564
+ },
565
+ // js
566
+ {
567
+ tag: [import_preset_code2.tags.definitionKeyword],
568
+ color: "#9333EA"
569
+ },
570
+ {
571
+ tag: [import_preset_code2.tags.modifier],
572
+ color: "#9333EA"
573
+ },
574
+ {
575
+ tag: [import_preset_code2.tags.controlKeyword],
576
+ color: "#9333EA"
577
+ },
578
+ {
579
+ tag: [import_preset_code2.tags.operatorKeyword],
580
+ color: "#9333EA"
540
581
  },
541
582
  // shell
542
583
  // curl
543
584
  {
544
585
  tag: [import_preset_code2.tags.standard(import_preset_code2.tags.variableName)],
545
- color: "#00804A"
586
+ color: "#059669"
546
587
  },
547
588
  // -X
548
589
  {
549
590
  tag: [import_preset_code2.tags.attributeName],
550
- color: "#C74200"
591
+ color: "#EA580C"
551
592
  },
552
593
  // url in string (includes quotes), e.g. "https://..."
553
594
  {
554
595
  tag: [import_preset_code2.tags.special(import_preset_code2.tags.string)],
555
- color: "#2B57D9"
596
+ color: "#2563EB"
556
597
  }
557
598
  ]
558
599
  });
@@ -560,54 +601,55 @@ var lightTheme = (0, import_preset_code2.createTheme)({
560
601
  // src/components/code-editor/theme/dark.ts
561
602
  var import_preset_code3 = require("@coze-editor/editor/preset-code");
562
603
  var colors2 = {
563
- background: "#151B27",
564
- // syntax
565
- comment: "#FFFFFF63",
566
- key: "#39E5D7",
567
- string: "#FF94D2",
568
- number: "#FF9933",
569
- boolean: "#78B0FF",
570
- null: "#78B0FF",
571
- separator: "#FFFFFFC9"
604
+ background: "#0D1117",
605
+ // syntax - 现代化暗色主题配色
606
+ comment: "#8B949E",
607
+ key: "#7DD3FC",
608
+ variable: "#F472B6",
609
+ string: "#34D399",
610
+ number: "#FBBF24",
611
+ boolean: "#A78BFA",
612
+ null: "#A78BFA",
613
+ separator: "#E6EDF3"
572
614
  };
573
615
  var darkTheme = (0, import_preset_code3.createTheme)({
574
616
  variant: "dark",
575
617
  settings: {
576
618
  background: colors2.background,
577
- foreground: "#fff",
578
- caret: "#AEAFAD",
579
- selection: "#d9d9d942",
619
+ foreground: "#E6EDF3",
620
+ caret: "#7DD3FC",
621
+ selection: "#264F7833",
580
622
  gutterBackground: colors2.background,
581
- gutterForeground: "#FFFFFF63",
623
+ gutterForeground: "#6E7681",
582
624
  gutterBorderColor: "transparent",
583
625
  gutterBorderWidth: 0,
584
- lineHighlight: "#272e3d36",
585
- bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
626
+ lineHighlight: "#21262D",
627
+ bracketColors: ["#FBBF24", "#A78BFA", "#7DD3FC"],
586
628
  tooltip: {
587
- backgroundColor: "#363D4D",
588
- color: "#fff",
589
- border: "none"
629
+ backgroundColor: "#21262D",
630
+ color: "#E6EDF3",
631
+ border: "1px solid #30363D"
590
632
  },
591
633
  link: {
592
- color: "#4daafc"
634
+ color: "#58A6FF"
593
635
  },
594
636
  completionItemHover: {
595
- backgroundColor: "#FFFFFF0F"
637
+ backgroundColor: "#21262D"
596
638
  },
597
639
  completionItemSelected: {
598
- backgroundColor: "#FFFFFF17"
640
+ backgroundColor: "#1F6EEB"
599
641
  },
600
642
  completionItemIcon: {
601
- color: "#FFFFFFC9"
643
+ color: "#8B949E"
602
644
  },
603
645
  completionItemLabel: {
604
- color: "#FFFFFFC9"
646
+ color: "#E6EDF3"
605
647
  },
606
648
  completionItemInfo: {
607
- color: "#FFFFFFC9"
649
+ color: "#8B949E"
608
650
  },
609
651
  completionItemDetail: {
610
- color: "#FFFFFF63"
652
+ color: "#6E7681"
611
653
  }
612
654
  },
613
655
  styles: [
@@ -640,30 +682,47 @@ var darkTheme = (0, import_preset_code3.createTheme)({
640
682
  tag: [import_preset_code3.tags.separator],
641
683
  color: colors2.separator
642
684
  },
685
+ // js
686
+ {
687
+ tag: [import_preset_code3.tags.definitionKeyword],
688
+ color: "#C084FC"
689
+ },
690
+ {
691
+ tag: [import_preset_code3.tags.modifier],
692
+ color: "#C084FC"
693
+ },
694
+ {
695
+ tag: [import_preset_code3.tags.controlKeyword],
696
+ color: "#C084FC"
697
+ },
698
+ {
699
+ tag: [import_preset_code3.tags.operatorKeyword],
700
+ color: "#C084FC"
701
+ },
643
702
  // markdown
644
703
  {
645
704
  tag: [import_preset_code3.tags.heading],
646
- color: "#6b6bff"
705
+ color: "#7DD3FC"
647
706
  },
648
707
  {
649
708
  tag: [import_preset_code3.tags.processingInstruction],
650
- color: "#6b6bff"
709
+ color: "#7DD3FC"
651
710
  },
652
711
  // shell
653
712
  // curl
654
713
  {
655
714
  tag: [import_preset_code3.tags.standard(import_preset_code3.tags.variableName)],
656
- color: "#3BEB84"
715
+ color: "#34D399"
657
716
  },
658
717
  // -X
659
718
  {
660
719
  tag: [import_preset_code3.tags.attributeName],
661
- color: "#FF9933"
720
+ color: "#FBBF24"
662
721
  },
663
722
  // url in string (includes quotes), e.g. "https://..."
664
723
  {
665
724
  tag: [import_preset_code3.tags.special(import_preset_code3.tags.string)],
666
- color: "#78B0FF"
725
+ color: "#7DD3FC"
667
726
  }
668
727
  ]
669
728
  });
@@ -1518,7 +1577,7 @@ function PropertyEdit(props) {
1518
1577
  BlurInput,
1519
1578
  {
1520
1579
  disabled: readonly,
1521
- placeholder: config?.placeholder ?? "Input Variable Name",
1580
+ placeholder: config?.placeholder ?? import_editor14.I18n.t("Input Variable Name"),
1522
1581
  size: "small",
1523
1582
  value: name,
1524
1583
  onChange: (value2) => onChange("name", value2)
@@ -2500,7 +2559,6 @@ function VariableTree() {
2500
2559
  }
2501
2560
 
2502
2561
  // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2503
- var import_react_dom = __toESM(require("react-dom"));
2504
2562
  var import_react39 = __toESM(require("react"));
2505
2563
  var import_lodash5 = require("lodash");
2506
2564
  var import_editor23 = require("@flowgram.ai/editor");
@@ -2560,36 +2618,32 @@ var VariableTagWidget = class extends import_view4.WidgetType {
2560
2618
  this.keyPath = keyPath;
2561
2619
  this.scope = scope;
2562
2620
  }
2563
- renderReact(jsx) {
2564
- import_react_dom.default.render(jsx, this.rootDOM);
2565
- }
2566
2621
  renderVariable(v) {
2567
2622
  if (!v) {
2568
- this.renderReact(
2623
+ this.root.render(
2569
2624
  /* @__PURE__ */ import_react39.default.createElement(UITag2, { prefixIcon: /* @__PURE__ */ import_react39.default.createElement(import_semi_icons7.IconIssueStroked, null), color: "amber" }, "Unknown")
2570
2625
  );
2571
2626
  return;
2572
2627
  }
2573
- const rootField = (0, import_lodash5.last)(v.parentFields) || v;
2574
- const isRoot = v.parentFields.length === 0;
2575
- const rootTitle = /* @__PURE__ */ import_react39.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
2628
+ const rootField = (0, import_lodash5.last)(v.parentFields);
2629
+ const rootTitle = /* @__PURE__ */ import_react39.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2576
2630
  const rootIcon = this.renderIcon(rootField?.meta.icon);
2577
- this.renderReact(
2631
+ this.root.render(
2578
2632
  /* @__PURE__ */ import_react39.default.createElement(
2579
2633
  import_semi_ui17.Popover,
2580
2634
  {
2581
2635
  content: /* @__PURE__ */ import_react39.default.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2582
2636
  },
2583
- /* @__PURE__ */ import_react39.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ import_react39.default.createElement(UIVarName2, null, v?.key))
2637
+ /* @__PURE__ */ import_react39.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName2, null, v?.key))
2584
2638
  )
2585
2639
  );
2586
2640
  }
2587
2641
  toDOM(view) {
2588
2642
  const dom = document.createElement("span");
2589
- this.rootDOM = dom;
2643
+ this.root = polyfillCreateRoot(dom);
2590
2644
  this.toDispose.push(
2591
2645
  import_editor23.Disposable.create(() => {
2592
- import_react_dom.default.unmountComponentAtNode(this.rootDOM);
2646
+ this.root.unmount();
2593
2647
  })
2594
2648
  );
2595
2649
  this.toDispose.push(
@@ -2866,7 +2920,6 @@ function VariableTree2() {
2866
2920
 
2867
2921
  // src/components/json-editor-with-variables/extensions/variable-tag.tsx
2868
2922
  var import_react48 = __toESM(require("react"));
2869
- var import_client = require("react-dom/client");
2870
2923
  var import_lodash7 = require("lodash");
2871
2924
  var import_editor25 = require("@flowgram.ai/editor");
2872
2925
  var import_semi_ui22 = require("@douyinfe/semi-ui");
@@ -2947,7 +3000,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
2947
3000
  }
2948
3001
  toDOM(view) {
2949
3002
  const dom = document.createElement("span");
2950
- this.root = (0, import_client.createRoot)(dom);
3003
+ this.root = polyfillCreateRoot(dom);
2951
3004
  this.toDispose.push(
2952
3005
  import_editor25.Disposable.create(() => {
2953
3006
  this.root.unmount();
@@ -3014,6 +3067,7 @@ function VariableTagInject2() {
3014
3067
  }
3015
3068
 
3016
3069
  // src/components/json-editor-with-variables/index.tsx
3070
+ var import_editor26 = require("@flowgram.ai/editor");
3017
3071
  function findAllMatches(inputString, regex) {
3018
3072
  const globalRegex = new RegExp(
3019
3073
  regex,
@@ -3047,7 +3101,7 @@ function JsonEditorWithVariables(props) {
3047
3101
  CodeEditor,
3048
3102
  {
3049
3103
  languageId: "json",
3050
- activeLinePlaceholder: "Press '@' to Select variable",
3104
+ activeLinePlaceholder: import_editor26.I18n.t("Press '@' to Select variable"),
3051
3105
  ...props,
3052
3106
  options: {
3053
3107
  transformer,
@@ -3061,7 +3115,7 @@ function JsonEditorWithVariables(props) {
3061
3115
 
3062
3116
  // src/components/inputs-values/index.tsx
3063
3117
  var import_react51 = __toESM(require("react"));
3064
- var import_editor26 = require("@flowgram.ai/editor");
3118
+ var import_editor27 = require("@flowgram.ai/editor");
3065
3119
  var import_semi_ui23 = require("@douyinfe/semi-ui");
3066
3120
  var import_semi_icons9 = require("@douyinfe/semi-icons");
3067
3121
 
@@ -3102,7 +3156,7 @@ function InputsValues({
3102
3156
  size: "small",
3103
3157
  value: item.key,
3104
3158
  onChange: (v) => updateKey(item.id, v),
3105
- placeholder: import_editor26.I18n.t("Input Key")
3159
+ placeholder: import_editor27.I18n.t("Input Key")
3106
3160
  }
3107
3161
  ), /* @__PURE__ */ import_react51.default.createElement(
3108
3162
  InjectDynamicValueInput,
@@ -3139,7 +3193,7 @@ function InputsValues({
3139
3193
  schema: { type: "string" }
3140
3194
  })
3141
3195
  },
3142
- import_editor26.I18n.t("Add")
3196
+ import_editor27.I18n.t("Add")
3143
3197
  ));
3144
3198
  }
3145
3199
 
@@ -3252,7 +3306,7 @@ function SchemaTree(props) {
3252
3306
  // src/components/display-outputs/index.tsx
3253
3307
  var import_react54 = __toESM(require("react"));
3254
3308
  var import_json_schema9 = require("@flowgram.ai/json-schema");
3255
- var import_editor27 = require("@flowgram.ai/editor");
3309
+ var import_editor28 = require("@flowgram.ai/editor");
3256
3310
 
3257
3311
  // src/components/display-schema-tag/index.tsx
3258
3312
  var import_react53 = __toESM(require("react"));
@@ -3305,8 +3359,8 @@ var DisplayOutputsWrapper = import_styled_components13.default.div`
3305
3359
 
3306
3360
  // src/components/display-outputs/index.tsx
3307
3361
  function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3308
- const scope = (0, import_editor27.useCurrentScope)();
3309
- const refresh = (0, import_editor27.useRefresh)();
3362
+ const scope = (0, import_editor28.useCurrentScope)();
3363
+ const refresh = (0, import_editor28.useRefresh)();
3310
3364
  (0, import_react54.useEffect)(() => {
3311
3365
  if (!displayFromScope) {
3312
3366
  return () => null;
@@ -3341,9 +3395,9 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3341
3395
  // src/components/display-flow-value/index.tsx
3342
3396
  var import_react55 = __toESM(require("react"));
3343
3397
  var import_json_schema10 = require("@flowgram.ai/json-schema");
3344
- var import_editor28 = require("@flowgram.ai/editor");
3398
+ var import_editor29 = require("@flowgram.ai/editor");
3345
3399
  function DisplayFlowValue({ value, title, showIconInTree }) {
3346
- const available = (0, import_editor28.useScopeAvailable)();
3400
+ const available = (0, import_editor29.useScopeAvailable)();
3347
3401
  const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
3348
3402
  const schema = (0, import_react55.useMemo)(() => {
3349
3403
  if (value?.type === "ref") {
@@ -3371,7 +3425,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
3371
3425
  // src/components/display-inputs-values/index.tsx
3372
3426
  var import_react56 = __toESM(require("react"));
3373
3427
  var import_lodash8 = require("lodash");
3374
- var import_editor29 = require("@flowgram.ai/editor");
3428
+ var import_editor30 = require("@flowgram.ai/editor");
3375
3429
 
3376
3430
  // src/components/display-inputs-values/styles.ts
3377
3431
  var import_styled_components14 = __toESM(require("styled-components"));
@@ -3407,7 +3461,7 @@ function DisplayInputsValueAllInTag({
3407
3461
  title,
3408
3462
  showIconInTree
3409
3463
  }) {
3410
- const available = (0, import_editor29.useScopeAvailable)();
3464
+ const available = (0, import_editor30.useScopeAvailable)();
3411
3465
  const schema = (0, import_react56.useMemo)(
3412
3466
  () => FlowValueUtils.inferJsonSchema(value, available.scope),
3413
3467
  [available.version, value]
@@ -3417,7 +3471,7 @@ function DisplayInputsValueAllInTag({
3417
3471
 
3418
3472
  // src/components/assign-rows/index.tsx
3419
3473
  var import_react59 = __toESM(require("react"));
3420
- var import_editor30 = require("@flowgram.ai/editor");
3474
+ var import_editor31 = require("@flowgram.ai/editor");
3421
3475
  var import_semi_ui27 = require("@douyinfe/semi-ui");
3422
3476
  var import_semi_icons11 = require("@douyinfe/semi-icons");
3423
3477
 
@@ -3504,7 +3558,7 @@ function AssignRow(props) {
3504
3558
  // src/components/assign-rows/index.tsx
3505
3559
  function AssignRows(props) {
3506
3560
  const { name, readonly } = props;
3507
- return /* @__PURE__ */ import_react59.default.createElement(import_editor30.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react59.default.createElement(
3561
+ return /* @__PURE__ */ import_react59.default.createElement(import_editor31.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react59.default.createElement(
3508
3562
  AssignRow,
3509
3563
  {
3510
3564
  key: childField.key,
@@ -3538,7 +3592,7 @@ function AssignRows(props) {
3538
3592
 
3539
3593
  // src/components/inputs-values-tree/index.tsx
3540
3594
  var import_react63 = __toESM(require("react"));
3541
- var import_editor32 = require("@flowgram.ai/editor");
3595
+ var import_editor33 = require("@flowgram.ai/editor");
3542
3596
  var import_semi_ui29 = require("@douyinfe/semi-ui");
3543
3597
  var import_semi_icons14 = require("@douyinfe/semi-icons");
3544
3598
 
@@ -3648,7 +3702,7 @@ var IconAddChildren2 = () => /* @__PURE__ */ import_react60.default.createElemen
3648
3702
 
3649
3703
  // src/components/inputs-values-tree/row.tsx
3650
3704
  var import_react62 = __toESM(require("react"));
3651
- var import_editor31 = require("@flowgram.ai/editor");
3705
+ var import_editor32 = require("@flowgram.ai/editor");
3652
3706
  var import_semi_ui28 = require("@douyinfe/semi-ui");
3653
3707
  var import_semi_icons13 = require("@douyinfe/semi-icons");
3654
3708
 
@@ -3705,7 +3759,7 @@ var AddObjectChildStrategy = {
3705
3759
  size: "small",
3706
3760
  disabled: true,
3707
3761
  style: { pointerEvents: "none" },
3708
- value: import_editor31.I18n.t("Configure via child fields")
3762
+ value: import_editor32.I18n.t("Configure via child fields")
3709
3763
  }
3710
3764
  )
3711
3765
  };
@@ -3746,7 +3800,7 @@ function InputValueRow(props) {
3746
3800
  size: "small",
3747
3801
  value: keyName,
3748
3802
  onChange: (v) => onUpdateKey?.(v),
3749
- placeholder: import_editor31.I18n.t("Input Key")
3803
+ placeholder: import_editor32.I18n.t("Input Key")
3750
3804
  }
3751
3805
  ), /* @__PURE__ */ import_react62.default.createElement(
3752
3806
  InjectDynamicValueInput,
@@ -3846,34 +3900,34 @@ function InputsValuesTree(props) {
3846
3900
  });
3847
3901
  }
3848
3902
  },
3849
- import_editor32.I18n.t("Add")
3903
+ import_editor33.I18n.t("Add")
3850
3904
  ));
3851
3905
  }
3852
3906
 
3853
3907
  // src/effects/provide-batch-input/index.ts
3854
- var import_editor33 = require("@flowgram.ai/editor");
3855
- var provideBatchInputEffect = (0, import_editor33.createEffectFromVariableProvider)({
3908
+ var import_editor34 = require("@flowgram.ai/editor");
3909
+ var provideBatchInputEffect = (0, import_editor34.createEffectFromVariableProvider)({
3856
3910
  private: true,
3857
3911
  parse: (value, ctx) => [
3858
- import_editor33.ASTFactory.createVariableDeclaration({
3912
+ import_editor34.ASTFactory.createVariableDeclaration({
3859
3913
  key: `${ctx.node.id}_locals`,
3860
3914
  meta: {
3861
- title: (0, import_editor33.getNodeForm)(ctx.node)?.getValueIn("title"),
3915
+ title: (0, import_editor34.getNodeForm)(ctx.node)?.getValueIn("title"),
3862
3916
  icon: ctx.node.getNodeRegistry().info?.icon
3863
3917
  },
3864
- type: import_editor33.ASTFactory.createObject({
3918
+ type: import_editor34.ASTFactory.createObject({
3865
3919
  properties: [
3866
- import_editor33.ASTFactory.createProperty({
3920
+ import_editor34.ASTFactory.createProperty({
3867
3921
  key: "item",
3868
- initializer: import_editor33.ASTFactory.createEnumerateExpression({
3869
- enumerateFor: import_editor33.ASTFactory.createKeyPathExpression({
3922
+ initializer: import_editor34.ASTFactory.createEnumerateExpression({
3923
+ enumerateFor: import_editor34.ASTFactory.createKeyPathExpression({
3870
3924
  keyPath: value.content || []
3871
3925
  })
3872
3926
  })
3873
3927
  }),
3874
- import_editor33.ASTFactory.createProperty({
3928
+ import_editor34.ASTFactory.createProperty({
3875
3929
  key: "index",
3876
- type: import_editor33.ASTFactory.createNumber()
3930
+ type: import_editor34.ASTFactory.createNumber()
3877
3931
  })
3878
3932
  ]
3879
3933
  })
@@ -3882,13 +3936,13 @@ var provideBatchInputEffect = (0, import_editor33.createEffectFromVariableProvid
3882
3936
  });
3883
3937
 
3884
3938
  // src/effects/auto-rename-ref/index.ts
3885
- var import_editor34 = require("@flowgram.ai/editor");
3939
+ var import_editor35 = require("@flowgram.ai/editor");
3886
3940
  var autoRenameRefEffect = [
3887
3941
  {
3888
- event: import_editor34.DataEvent.onValueInit,
3942
+ event: import_editor35.DataEvent.onValueInit,
3889
3943
  effect: (params) => {
3890
3944
  const { context, form, name } = params;
3891
- const renameService = context.node.getService(import_editor34.VariableFieldKeyRenameService);
3945
+ const renameService = context.node.getService(import_editor35.VariableFieldKeyRenameService);
3892
3946
  const disposable = renameService.onRename(({ before, after }) => {
3893
3947
  const beforeKeyPath = [
3894
3948
  ...before.parentFields.map((_field) => _field.key).reverse(),
@@ -3946,13 +4000,13 @@ function traverseRef(name, value, cb) {
3946
4000
 
3947
4001
  // src/effects/provide-json-schema-outputs/index.ts
3948
4002
  var import_json_schema11 = require("@flowgram.ai/json-schema");
3949
- var import_editor35 = require("@flowgram.ai/editor");
3950
- var provideJsonSchemaOutputs = (0, import_editor35.createEffectFromVariableProvider)({
4003
+ var import_editor36 = require("@flowgram.ai/editor");
4004
+ var provideJsonSchemaOutputs = (0, import_editor36.createEffectFromVariableProvider)({
3951
4005
  parse: (value, ctx) => [
3952
- import_editor35.ASTFactory.createVariableDeclaration({
4006
+ import_editor36.ASTFactory.createVariableDeclaration({
3953
4007
  key: `${ctx.node.id}`,
3954
4008
  meta: {
3955
- title: (0, import_editor35.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
4009
+ title: (0, import_editor36.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
3956
4010
  icon: ctx.node.getNodeRegistry().info?.icon
3957
4011
  },
3958
4012
  type: import_json_schema11.JsonSchemaUtils.schemaToAST(value)
@@ -3961,12 +4015,12 @@ var provideJsonSchemaOutputs = (0, import_editor35.createEffectFromVariableProvi
3961
4015
  });
3962
4016
 
3963
4017
  // src/effects/sync-variable-title/index.ts
3964
- var import_editor36 = require("@flowgram.ai/editor");
4018
+ var import_editor37 = require("@flowgram.ai/editor");
3965
4019
  var syncVariableTitle = [
3966
4020
  {
3967
- event: import_editor36.DataEvent.onValueChange,
4021
+ event: import_editor37.DataEvent.onValueChange,
3968
4022
  effect: ({ value, context }) => {
3969
- context.node.getData(import_editor36.FlowNodeVariableData).allScopes.forEach((_scope) => {
4023
+ context.node.getData(import_editor37.FlowNodeVariableData).allScopes.forEach((_scope) => {
3970
4024
  _scope.output.variables.forEach((_var) => {
3971
4025
  _var.updateMeta({
3972
4026
  ..._var.meta || {},
@@ -3981,14 +4035,14 @@ var syncVariableTitle = [
3981
4035
 
3982
4036
  // src/effects/validate-when-variable-sync/index.ts
3983
4037
  var import_lodash10 = require("lodash");
3984
- var import_editor37 = require("@flowgram.ai/editor");
4038
+ var import_editor38 = require("@flowgram.ai/editor");
3985
4039
  var validateWhenVariableSync = ({
3986
4040
  scope
3987
4041
  } = {}) => [
3988
4042
  {
3989
- event: import_editor37.DataEvent.onValueInit,
4043
+ event: import_editor38.DataEvent.onValueInit,
3990
4044
  effect: ({ context, form }) => {
3991
- const nodeScope = scope === "private" ? (0, import_editor37.getNodePrivateScope)(context.node) : (0, import_editor37.getNodeScope)(context.node);
4045
+ const nodeScope = scope === "private" ? (0, import_editor38.getNodePrivateScope)(context.node) : (0, import_editor38.getNodeScope)(context.node);
3992
4046
  const disposable = nodeScope.available.onListOrAnyVarChange(() => {
3993
4047
  if (!(0, import_lodash10.isEmpty)(form.state.errors)) {
3994
4048
  form.validate();
@@ -4000,16 +4054,16 @@ var validateWhenVariableSync = ({
4000
4054
  ];
4001
4055
 
4002
4056
  // src/effects/listen-ref-value-change/index.ts
4003
- var import_editor38 = require("@flowgram.ai/editor");
4057
+ var import_editor39 = require("@flowgram.ai/editor");
4004
4058
  var listenRefValueChange = (cb) => [
4005
4059
  {
4006
- event: import_editor38.DataEvent.onValueInitOrChange,
4060
+ event: import_editor39.DataEvent.onValueInitOrChange,
4007
4061
  effect: (params) => {
4008
4062
  const { context, value } = params;
4009
4063
  if (value?.type !== "ref") {
4010
4064
  return () => null;
4011
4065
  }
4012
- const disposable = (0, import_editor38.getNodeScope)(context.node).available.trackByKeyPath(
4066
+ const disposable = (0, import_editor39.getNodeScope)(context.node).available.trackByKeyPath(
4013
4067
  value?.content || [],
4014
4068
  (v) => {
4015
4069
  cb({ ...params, variable: v });
@@ -4024,16 +4078,16 @@ var listenRefValueChange = (cb) => [
4024
4078
 
4025
4079
  // src/effects/listen-ref-schema-change/index.ts
4026
4080
  var import_json_schema12 = require("@flowgram.ai/json-schema");
4027
- var import_editor39 = require("@flowgram.ai/editor");
4081
+ var import_editor40 = require("@flowgram.ai/editor");
4028
4082
  var listenRefSchemaChange = (cb) => [
4029
4083
  {
4030
- event: import_editor39.DataEvent.onValueInitOrChange,
4084
+ event: import_editor40.DataEvent.onValueInitOrChange,
4031
4085
  effect: (params) => {
4032
4086
  const { context, value } = params;
4033
4087
  if (value?.type !== "ref") {
4034
4088
  return () => null;
4035
4089
  }
4036
- const disposable = (0, import_editor39.getNodeScope)(context.node).available.trackByKeyPath(
4090
+ const disposable = (0, import_editor40.getNodeScope)(context.node).available.trackByKeyPath(
4037
4091
  value?.content || [],
4038
4092
  (_type) => {
4039
4093
  cb({ ...params, schema: import_json_schema12.JsonSchemaUtils.astToSchema(_type) });
@@ -4050,21 +4104,21 @@ var listenRefSchemaChange = (cb) => [
4050
4104
  ];
4051
4105
 
4052
4106
  // src/form-plugins/batch-outputs-plugin/index.ts
4053
- var import_editor40 = require("@flowgram.ai/editor");
4054
- var provideBatchOutputsEffect = (0, import_editor40.createEffectFromVariableProvider)({
4107
+ var import_editor41 = require("@flowgram.ai/editor");
4108
+ var provideBatchOutputsEffect = (0, import_editor41.createEffectFromVariableProvider)({
4055
4109
  parse: (value, ctx) => [
4056
- import_editor40.ASTFactory.createVariableDeclaration({
4110
+ import_editor41.ASTFactory.createVariableDeclaration({
4057
4111
  key: `${ctx.node.id}`,
4058
4112
  meta: {
4059
- title: (0, import_editor40.getNodeForm)(ctx.node)?.getValueIn("title"),
4113
+ title: (0, import_editor41.getNodeForm)(ctx.node)?.getValueIn("title"),
4060
4114
  icon: ctx.node.getNodeRegistry().info?.icon
4061
4115
  },
4062
- type: import_editor40.ASTFactory.createObject({
4116
+ type: import_editor41.ASTFactory.createObject({
4063
4117
  properties: Object.entries(value).map(
4064
- ([_key, value2]) => import_editor40.ASTFactory.createProperty({
4118
+ ([_key, value2]) => import_editor41.ASTFactory.createProperty({
4065
4119
  key: _key,
4066
- initializer: import_editor40.ASTFactory.createWrapArrayExpression({
4067
- wrapFor: import_editor40.ASTFactory.createKeyPathExpression({
4120
+ initializer: import_editor41.ASTFactory.createWrapArrayExpression({
4121
+ wrapFor: import_editor41.ASTFactory.createKeyPathExpression({
4068
4122
  keyPath: value2?.content || []
4069
4123
  })
4070
4124
  })
@@ -4074,7 +4128,7 @@ var provideBatchOutputsEffect = (0, import_editor40.createEffectFromVariableProv
4074
4128
  })
4075
4129
  ]
4076
4130
  });
4077
- var createBatchOutputsFormPlugin = (0, import_editor40.defineFormPluginCreator)({
4131
+ var createBatchOutputsFormPlugin = (0, import_editor41.defineFormPluginCreator)({
4078
4132
  name: "batch-outputs-plugin",
4079
4133
  onSetupFormMeta({ mergeEffect }, { outputKey }) {
4080
4134
  mergeEffect({
@@ -4082,7 +4136,7 @@ var createBatchOutputsFormPlugin = (0, import_editor40.defineFormPluginCreator)(
4082
4136
  });
4083
4137
  },
4084
4138
  onInit(ctx, { outputKey }) {
4085
- const chainTransformService = ctx.node.getService(import_editor40.ScopeChainTransformService);
4139
+ const chainTransformService = ctx.node.getService(import_editor41.ScopeChainTransformService);
4086
4140
  const batchNodeType = ctx.node.flowNodeType;
4087
4141
  const transformerId = `${batchNodeType}-outputs`;
4088
4142
  if (chainTransformService.hasTransformer(transformerId)) {
@@ -4092,21 +4146,21 @@ var createBatchOutputsFormPlugin = (0, import_editor40.defineFormPluginCreator)(
4092
4146
  transformCovers: (covers, ctx2) => {
4093
4147
  const node = ctx2.scope.meta?.node;
4094
4148
  if (node?.parent?.flowNodeType === batchNodeType) {
4095
- return [...covers, (0, import_editor40.getNodeScope)(node.parent)];
4149
+ return [...covers, (0, import_editor41.getNodeScope)(node.parent)];
4096
4150
  }
4097
4151
  return covers;
4098
4152
  },
4099
4153
  transformDeps(scopes, ctx2) {
4100
4154
  const scopeMeta = ctx2.scope.meta;
4101
- if (scopeMeta?.type === import_editor40.FlowNodeScopeType.private) {
4155
+ if (scopeMeta?.type === import_editor41.FlowNodeScopeType.private) {
4102
4156
  return scopes;
4103
4157
  }
4104
4158
  const node = scopeMeta?.node;
4105
4159
  if (node?.flowNodeType === batchNodeType) {
4106
4160
  const childBlocks = node.blocks;
4107
4161
  return [
4108
- (0, import_editor40.getNodePrivateScope)(node),
4109
- ...childBlocks.map((_childBlock) => (0, import_editor40.getNodeScope)(_childBlock))
4162
+ (0, import_editor41.getNodePrivateScope)(node),
4163
+ ...childBlocks.map((_childBlock) => (0, import_editor41.getNodeScope)(_childBlock))
4110
4164
  ];
4111
4165
  }
4112
4166
  return scopes;
@@ -4117,8 +4171,8 @@ var createBatchOutputsFormPlugin = (0, import_editor40.defineFormPluginCreator)(
4117
4171
 
4118
4172
  // src/form-plugins/infer-inputs-plugin/index.ts
4119
4173
  var import_lodash11 = require("lodash");
4120
- var import_editor41 = require("@flowgram.ai/editor");
4121
- var createInferInputsPlugin = (0, import_editor41.defineFormPluginCreator)({
4174
+ var import_editor42 = require("@flowgram.ai/editor");
4175
+ var createInferInputsPlugin = (0, import_editor42.defineFormPluginCreator)({
4122
4176
  onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
4123
4177
  if (!sourceKey || !targetKey) {
4124
4178
  return;
@@ -4129,7 +4183,7 @@ var createInferInputsPlugin = (0, import_editor41.defineFormPluginCreator)({
4129
4183
  targetKey,
4130
4184
  FlowValueUtils.inferJsonSchema(
4131
4185
  (0, import_lodash11.get)(formData, sourceKey),
4132
- scope === "private" ? (0, import_editor41.getNodePrivateScope)(ctx.node) : (0, import_editor41.getNodeScope)(ctx.node)
4186
+ scope === "private" ? (0, import_editor42.getNodePrivateScope)(ctx.node) : (0, import_editor42.getNodeScope)(ctx.node)
4133
4187
  )
4134
4188
  );
4135
4189
  return formData;
@@ -4140,32 +4194,32 @@ var createInferInputsPlugin = (0, import_editor41.defineFormPluginCreator)({
4140
4194
  // src/form-plugins/infer-assign-plugin/index.ts
4141
4195
  var import_lodash12 = require("lodash");
4142
4196
  var import_json_schema13 = require("@flowgram.ai/json-schema");
4143
- var import_editor42 = require("@flowgram.ai/editor");
4144
- var createInferAssignPlugin = (0, import_editor42.defineFormPluginCreator)({
4197
+ var import_editor43 = require("@flowgram.ai/editor");
4198
+ var createInferAssignPlugin = (0, import_editor43.defineFormPluginCreator)({
4145
4199
  onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
4146
4200
  if (!assignKey || !outputKey) {
4147
4201
  return;
4148
4202
  }
4149
4203
  mergeEffect({
4150
- [assignKey]: (0, import_editor42.createEffectFromVariableProvider)({
4204
+ [assignKey]: (0, import_editor43.createEffectFromVariableProvider)({
4151
4205
  parse: (value, ctx) => {
4152
4206
  const declareRows = (0, import_lodash12.uniqBy)(
4153
4207
  value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
4154
4208
  "left"
4155
4209
  );
4156
4210
  return [
4157
- import_editor42.ASTFactory.createVariableDeclaration({
4211
+ import_editor43.ASTFactory.createVariableDeclaration({
4158
4212
  key: `${ctx.node.id}`,
4159
4213
  meta: {
4160
- title: (0, import_editor42.getNodeForm)(ctx.node)?.getValueIn("title"),
4214
+ title: (0, import_editor43.getNodeForm)(ctx.node)?.getValueIn("title"),
4161
4215
  icon: ctx.node.getNodeRegistry().info?.icon
4162
4216
  },
4163
- type: import_editor42.ASTFactory.createObject({
4217
+ type: import_editor43.ASTFactory.createObject({
4164
4218
  properties: declareRows.map(
4165
- (_v) => import_editor42.ASTFactory.createProperty({
4219
+ (_v) => import_editor43.ASTFactory.createProperty({
4166
4220
  key: _v.left,
4167
4221
  type: _v.right?.type === "constant" ? import_json_schema13.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
4168
- initializer: _v.right?.type === "ref" ? import_editor42.ASTFactory.createKeyPathExpression({
4222
+ initializer: _v.right?.type === "ref" ? import_editor43.ASTFactory.createKeyPathExpression({
4169
4223
  keyPath: _v.right?.content || []
4170
4224
  }) : {}
4171
4225
  })
@@ -4180,7 +4234,7 @@ var createInferAssignPlugin = (0, import_editor42.defineFormPluginCreator)({
4180
4234
  (0, import_lodash12.set)(
4181
4235
  formData,
4182
4236
  outputKey,
4183
- import_json_schema13.JsonSchemaUtils.astToSchema((0, import_editor42.getNodeScope)(ctx.node).output.variables?.[0]?.type)
4237
+ import_json_schema13.JsonSchemaUtils.astToSchema((0, import_editor43.getNodeScope)(ctx.node).output.variables?.[0]?.type)
4184
4238
  );
4185
4239
  return formData;
4186
4240
  });
@@ -4189,7 +4243,7 @@ var createInferAssignPlugin = (0, import_editor42.defineFormPluginCreator)({
4189
4243
 
4190
4244
  // src/validate/validate-flow-value/index.tsx
4191
4245
  var import_lodash13 = require("lodash");
4192
- var import_editor43 = require("@flowgram.ai/editor");
4246
+ var import_editor44 = require("@flowgram.ai/editor");
4193
4247
  function validateFlowValue(value, ctx) {
4194
4248
  const { node, required, errorMessages } = ctx;
4195
4249
  const {
@@ -4198,15 +4252,15 @@ function validateFlowValue(value, ctx) {
4198
4252
  } = errorMessages || {};
4199
4253
  if (required && ((0, import_lodash13.isNil)(value) || (0, import_lodash13.isNil)(value?.content) || value?.content === "")) {
4200
4254
  return {
4201
- level: import_editor43.FeedbackLevel.Error,
4255
+ level: import_editor44.FeedbackLevel.Error,
4202
4256
  message: requiredMessage
4203
4257
  };
4204
4258
  }
4205
4259
  if (value?.type === "ref") {
4206
- const variable = (0, import_editor43.getNodeScope)(node).available.getByKeyPath(value?.content || []);
4260
+ const variable = (0, import_editor44.getNodeScope)(node).available.getByKeyPath(value?.content || []);
4207
4261
  if (!variable) {
4208
4262
  return {
4209
- level: import_editor43.FeedbackLevel.Error,
4263
+ level: import_editor44.FeedbackLevel.Error,
4210
4264
  message: unknownVariableMessage
4211
4265
  };
4212
4266
  }
@@ -4214,10 +4268,10 @@ function validateFlowValue(value, ctx) {
4214
4268
  if (value?.type === "template") {
4215
4269
  const allRefs = FlowValueUtils.getTemplateKeyPaths(value);
4216
4270
  for (const ref of allRefs) {
4217
- const variable = (0, import_editor43.getNodeScope)(node).available.getByKeyPath(ref);
4271
+ const variable = (0, import_editor44.getNodeScope)(node).available.getByKeyPath(ref);
4218
4272
  if (!variable) {
4219
4273
  return {
4220
- level: import_editor43.FeedbackLevel.Error,
4274
+ level: import_editor44.FeedbackLevel.Error,
4221
4275
  message: unknownVariableMessage
4222
4276
  };
4223
4277
  }
@@ -4275,10 +4329,12 @@ function validateFlowValue(value, ctx) {
4275
4329
  listenRefSchemaChange,
4276
4330
  listenRefValueChange,
4277
4331
  parseTypeSelectValue,
4332
+ polyfillCreateRoot,
4278
4333
  provideBatchInputEffect,
4279
4334
  provideBatchOutputsEffect,
4280
4335
  provideJsonSchemaOutputs,
4281
4336
  syncVariableTitle,
4337
+ unstableSetCreateRoot,
4282
4338
  useObjectList,
4283
4339
  useTypeManager,
4284
4340
  useVariableTree,