@flowgram.ai/form-materials 0.4.2 → 0.4.4

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
@@ -82,6 +82,7 @@ __export(src_exports, {
82
82
  provideBatchOutputsEffect: () => provideBatchOutputsEffect,
83
83
  provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
84
84
  syncVariableTitle: () => syncVariableTitle,
85
+ useObjectList: () => useObjectList,
85
86
  useTypeManager: () => useTypeManager,
86
87
  useVariableTree: () => useVariableTree,
87
88
  validateFlowValue: () => validateFlowValue,
@@ -274,13 +275,13 @@ var FlowValueUtils;
274
275
  return;
275
276
  }
276
277
  FlowValueUtils2.traverse = traverse;
277
- function getTemplateKeyPaths2(value) {
278
- const keyPathReg = /{{(.*?)}}/g;
278
+ function getTemplateKeyPaths(value) {
279
+ const keyPathReg = /\{\{([^\}\{]+)\}\}/g;
279
280
  return (0, import_lodash2.uniq)(value.content?.match(keyPathReg) || []).map(
280
281
  (_keyPath) => _keyPath.slice(2, -2).split(".")
281
282
  );
282
283
  }
283
- FlowValueUtils2.getTemplateKeyPaths = getTemplateKeyPaths2;
284
+ FlowValueUtils2.getTemplateKeyPaths = getTemplateKeyPaths;
284
285
  function inferConstantJsonSchema(value) {
285
286
  if (value?.schema) {
286
287
  return value.schema;
@@ -1128,12 +1129,24 @@ function TypeSelector(props) {
1128
1129
  }),
1129
1130
  []
1130
1131
  );
1132
+ const isDisabled = readonly || disabled;
1131
1133
  return /* @__PURE__ */ import_react14.default.createElement(
1132
1134
  import_semi_ui8.Cascader,
1133
1135
  {
1134
- disabled: readonly || disabled,
1136
+ disabled: isDisabled,
1135
1137
  size: "small",
1136
- triggerRender: () => /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
1138
+ triggerRender: () => /* @__PURE__ */ import_react14.default.createElement(
1139
+ import_semi_ui8.IconButton,
1140
+ {
1141
+ size: "small",
1142
+ style: {
1143
+ ...isDisabled ? { pointerEvents: "none" } : {},
1144
+ ...style || {}
1145
+ },
1146
+ disabled: isDisabled,
1147
+ icon
1148
+ }
1149
+ ),
1137
1150
  treeData: options,
1138
1151
  value: selectValue,
1139
1152
  leafOnly: true,
@@ -1505,7 +1518,7 @@ function PropertyEdit(props) {
1505
1518
  BlurInput,
1506
1519
  {
1507
1520
  disabled: readonly,
1508
- placeholder: config?.placeholder ?? "Input Variable Name",
1521
+ placeholder: config?.placeholder ?? import_editor14.I18n.t("Input Variable Name"),
1509
1522
  size: "small",
1510
1523
  value: name,
1511
1524
  onChange: (value2) => onChange("name", value2)
@@ -1720,6 +1733,11 @@ function useIncludeSchema(schemaFromProps) {
1720
1733
  }
1721
1734
 
1722
1735
  // src/components/dynamic-value-input/index.tsx
1736
+ var DEFAULT_VALUE = {
1737
+ type: "constant",
1738
+ content: "",
1739
+ schema: { type: "string" }
1740
+ };
1723
1741
  function DynamicValueInput({
1724
1742
  value,
1725
1743
  onChange,
@@ -1731,6 +1749,7 @@ function DynamicValueInput({
1731
1749
  const refVariable = useRefVariable(value);
1732
1750
  const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
1733
1751
  const includeSchema = useIncludeSchema(schemaFromProps);
1752
+ const typeManager = (0, import_json_schema7.useTypeManager)();
1734
1753
  const renderTypeSelector = () => {
1735
1754
  if (schemaFromProps) {
1736
1755
  return /* @__PURE__ */ import_react23.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
@@ -1745,20 +1764,18 @@ function DynamicValueInput({
1745
1764
  value: selectSchema,
1746
1765
  onChange: (_v) => {
1747
1766
  setSelectSchema(_v || { type: "string" });
1748
- let content;
1767
+ const schema = _v || { type: "string" };
1768
+ let content = typeManager.getDefaultValue(schema);
1749
1769
  if (_v?.type === "object") {
1750
1770
  content = "{}";
1751
1771
  }
1752
1772
  if (_v?.type === "array") {
1753
1773
  content = "[]";
1754
1774
  }
1755
- if (_v?.type === "boolean") {
1756
- content = false;
1757
- }
1758
1775
  onChange({
1759
1776
  type: "constant",
1760
1777
  content,
1761
- schema: _v || { type: "string" }
1778
+ schema
1762
1779
  });
1763
1780
  },
1764
1781
  readonly
@@ -1772,7 +1789,7 @@ function DynamicValueInput({
1772
1789
  {
1773
1790
  style: { width: "100%" },
1774
1791
  value: value?.content,
1775
- onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1792
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
1776
1793
  includeSchema,
1777
1794
  readonly
1778
1795
  }
@@ -1790,7 +1807,7 @@ function DynamicValueInput({
1790
1807
  InjectVariableSelector,
1791
1808
  {
1792
1809
  style: { width: "100%" },
1793
- onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1810
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
1794
1811
  includeSchema,
1795
1812
  readonly
1796
1813
  }
@@ -2431,8 +2448,16 @@ function VariableTree() {
2431
2448
  if (!range) {
2432
2449
  return;
2433
2450
  }
2451
+ let { from, to } = range;
2452
+ while (editor.$view.state.doc.sliceString(from - 1, from) === "{") {
2453
+ from--;
2454
+ }
2455
+ while (editor.$view.state.doc.sliceString(to, to + 1) === "}") {
2456
+ to++;
2457
+ }
2434
2458
  editor.replaceText({
2435
- ...range,
2459
+ from,
2460
+ to,
2436
2461
  text: "{{" + variablePath + "}}"
2437
2462
  });
2438
2463
  setVisible(false);
@@ -2594,7 +2619,7 @@ function VariableTagInject() {
2594
2619
  const scope = (0, import_editor23.useCurrentScope)();
2595
2620
  (0, import_react39.useLayoutEffect)(() => {
2596
2621
  const atMatcher = new import_view4.MatchDecorator({
2597
- regexp: /\{\{([^\}]+)\}\}/g,
2622
+ regexp: /\{\{([^\}\{]+)\}\}/g,
2598
2623
  decoration: (match) => import_view4.Decoration.replace({
2599
2624
  widget: new VariableTagWidget({
2600
2625
  keyPath: match[1]?.split(".") ?? [],
@@ -2682,20 +2707,32 @@ function InputsPicker({
2682
2707
  children
2683
2708
  };
2684
2709
  };
2685
- const treeData = (0, import_react42.useMemo)(
2686
- () => Object.entries(inputsValues).map(([key, value]) => {
2687
- if (value?.type === "ref") {
2710
+ const getTreeData = (value, keyPath) => {
2711
+ const currKey = keyPath.join(".");
2712
+ if (FlowValueUtils.isFlowValue(value)) {
2713
+ if (FlowValueUtils.isRef(value)) {
2688
2714
  const variable = available.getByKeyPath(value.content || []);
2689
2715
  if (variable) {
2690
- return renderVariable(variable, [key]);
2716
+ return renderVariable(variable, keyPath);
2691
2717
  }
2692
2718
  }
2693
2719
  return {
2694
- key,
2695
- value: key,
2696
- label: key
2720
+ key: currKey,
2721
+ value: currKey,
2722
+ label: (0, import_lodash6.last)(keyPath)
2697
2723
  };
2698
- }),
2724
+ }
2725
+ if ((0, import_lodash6.isPlainObject)(value)) {
2726
+ return {
2727
+ key: currKey,
2728
+ value: currKey,
2729
+ label: (0, import_lodash6.last)(keyPath),
2730
+ children: Object.entries(value).map(([key, value2]) => getTreeData(value2, [...keyPath, key])).filter(Boolean)
2731
+ };
2732
+ }
2733
+ };
2734
+ const treeData = (0, import_react42.useMemo)(
2735
+ () => Object.entries(inputsValues).map(([key, value]) => getTreeData(value, [key])).filter(Boolean),
2699
2736
  []
2700
2737
  );
2701
2738
  return /* @__PURE__ */ import_react42.default.createElement(import_semi_ui18.Tree, { treeData, onSelect: (v) => onSelect(v) });
@@ -2712,6 +2749,13 @@ function InputsTree({ inputsValues }) {
2712
2749
  if (!range) {
2713
2750
  return;
2714
2751
  }
2752
+ let { from, to } = range;
2753
+ while (editor.$view.state.doc.sliceString(from - 1, from) === "{") {
2754
+ from--;
2755
+ }
2756
+ while (editor.$view.state.doc.sliceString(to, to + 1) === "}") {
2757
+ to++;
2758
+ }
2715
2759
  editor.replaceText({
2716
2760
  ...range,
2717
2761
  text: "{{" + variablePath + "}}"
@@ -2936,7 +2980,7 @@ function VariableTagInject2() {
2936
2980
  const scope = (0, import_editor25.useCurrentScope)();
2937
2981
  (0, import_react48.useLayoutEffect)(() => {
2938
2982
  const atMatcher = new import_view5.MatchDecorator({
2939
- regexp: /\{\{([^\}]+)\}\}/g,
2983
+ regexp: /\{\{([^\}\{]+)\}\}/g,
2940
2984
  decoration: (match) => import_view5.Decoration.replace({
2941
2985
  widget: new VariableTagWidget2({
2942
2986
  keyPath: match[1]?.split(".") ?? [],
@@ -2970,6 +3014,7 @@ function VariableTagInject2() {
2970
3014
  }
2971
3015
 
2972
3016
  // src/components/json-editor-with-variables/index.tsx
3017
+ var import_editor26 = require("@flowgram.ai/editor");
2973
3018
  function findAllMatches(inputString, regex) {
2974
3019
  const globalRegex = new RegExp(
2975
3020
  regex,
@@ -3003,7 +3048,7 @@ function JsonEditorWithVariables(props) {
3003
3048
  CodeEditor,
3004
3049
  {
3005
3050
  languageId: "json",
3006
- activeLinePlaceholder: "Press '@' to Select variable",
3051
+ activeLinePlaceholder: import_editor26.I18n.t("Press '@' to Select variable"),
3007
3052
  ...props,
3008
3053
  options: {
3009
3054
  transformer,
@@ -3017,7 +3062,7 @@ function JsonEditorWithVariables(props) {
3017
3062
 
3018
3063
  // src/components/inputs-values/index.tsx
3019
3064
  var import_react51 = __toESM(require("react"));
3020
- var import_editor26 = require("@flowgram.ai/editor");
3065
+ var import_editor27 = require("@flowgram.ai/editor");
3021
3066
  var import_semi_ui23 = require("@douyinfe/semi-ui");
3022
3067
  var import_semi_icons9 = require("@douyinfe/semi-icons");
3023
3068
 
@@ -3058,7 +3103,7 @@ function InputsValues({
3058
3103
  size: "small",
3059
3104
  value: item.key,
3060
3105
  onChange: (v) => updateKey(item.id, v),
3061
- placeholder: import_editor26.I18n.t("Input Key")
3106
+ placeholder: import_editor27.I18n.t("Input Key")
3062
3107
  }
3063
3108
  ), /* @__PURE__ */ import_react51.default.createElement(
3064
3109
  InjectDynamicValueInput,
@@ -3083,7 +3128,20 @@ function InputsValues({
3083
3128
  size: "small",
3084
3129
  onClick: () => remove(item.id)
3085
3130
  }
3086
- )))), /* @__PURE__ */ import_react51.default.createElement(import_semi_ui23.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react51.default.createElement(import_semi_icons9.IconPlus, null), size: "small", onClick: () => add() }, import_editor26.I18n.t("Add")));
3131
+ )))), /* @__PURE__ */ import_react51.default.createElement(
3132
+ import_semi_ui23.Button,
3133
+ {
3134
+ disabled: readonly,
3135
+ icon: /* @__PURE__ */ import_react51.default.createElement(import_semi_icons9.IconPlus, null),
3136
+ size: "small",
3137
+ onClick: () => add({
3138
+ type: "constant",
3139
+ content: "",
3140
+ schema: { type: "string" }
3141
+ })
3142
+ },
3143
+ import_editor27.I18n.t("Add")
3144
+ ));
3087
3145
  }
3088
3146
 
3089
3147
  // src/components/display-schema-tree/index.tsx
@@ -3195,7 +3253,7 @@ function SchemaTree(props) {
3195
3253
  // src/components/display-outputs/index.tsx
3196
3254
  var import_react54 = __toESM(require("react"));
3197
3255
  var import_json_schema9 = require("@flowgram.ai/json-schema");
3198
- var import_editor27 = require("@flowgram.ai/editor");
3256
+ var import_editor28 = require("@flowgram.ai/editor");
3199
3257
 
3200
3258
  // src/components/display-schema-tag/index.tsx
3201
3259
  var import_react53 = __toESM(require("react"));
@@ -3248,8 +3306,8 @@ var DisplayOutputsWrapper = import_styled_components13.default.div`
3248
3306
 
3249
3307
  // src/components/display-outputs/index.tsx
3250
3308
  function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3251
- const scope = (0, import_editor27.useCurrentScope)();
3252
- const refresh = (0, import_editor27.useRefresh)();
3309
+ const scope = (0, import_editor28.useCurrentScope)();
3310
+ const refresh = (0, import_editor28.useRefresh)();
3253
3311
  (0, import_react54.useEffect)(() => {
3254
3312
  if (!displayFromScope) {
3255
3313
  return () => null;
@@ -3284,9 +3342,9 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3284
3342
  // src/components/display-flow-value/index.tsx
3285
3343
  var import_react55 = __toESM(require("react"));
3286
3344
  var import_json_schema10 = require("@flowgram.ai/json-schema");
3287
- var import_editor28 = require("@flowgram.ai/editor");
3345
+ var import_editor29 = require("@flowgram.ai/editor");
3288
3346
  function DisplayFlowValue({ value, title, showIconInTree }) {
3289
- const available = (0, import_editor28.useScopeAvailable)();
3347
+ const available = (0, import_editor29.useScopeAvailable)();
3290
3348
  const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
3291
3349
  const schema = (0, import_react55.useMemo)(() => {
3292
3350
  if (value?.type === "ref") {
@@ -3314,7 +3372,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
3314
3372
  // src/components/display-inputs-values/index.tsx
3315
3373
  var import_react56 = __toESM(require("react"));
3316
3374
  var import_lodash8 = require("lodash");
3317
- var import_editor29 = require("@flowgram.ai/editor");
3375
+ var import_editor30 = require("@flowgram.ai/editor");
3318
3376
 
3319
3377
  // src/components/display-inputs-values/styles.ts
3320
3378
  var import_styled_components14 = __toESM(require("styled-components"));
@@ -3350,7 +3408,7 @@ function DisplayInputsValueAllInTag({
3350
3408
  title,
3351
3409
  showIconInTree
3352
3410
  }) {
3353
- const available = (0, import_editor29.useScopeAvailable)();
3411
+ const available = (0, import_editor30.useScopeAvailable)();
3354
3412
  const schema = (0, import_react56.useMemo)(
3355
3413
  () => FlowValueUtils.inferJsonSchema(value, available.scope),
3356
3414
  [available.version, value]
@@ -3360,7 +3418,7 @@ function DisplayInputsValueAllInTag({
3360
3418
 
3361
3419
  // src/components/assign-rows/index.tsx
3362
3420
  var import_react59 = __toESM(require("react"));
3363
- var import_editor30 = require("@flowgram.ai/editor");
3421
+ var import_editor31 = require("@flowgram.ai/editor");
3364
3422
  var import_semi_ui27 = require("@douyinfe/semi-ui");
3365
3423
  var import_semi_icons11 = require("@douyinfe/semi-icons");
3366
3424
 
@@ -3447,7 +3505,7 @@ function AssignRow(props) {
3447
3505
  // src/components/assign-rows/index.tsx
3448
3506
  function AssignRows(props) {
3449
3507
  const { name, readonly } = props;
3450
- 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(
3508
+ 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(
3451
3509
  AssignRow,
3452
3510
  {
3453
3511
  key: childField.key,
@@ -3481,7 +3539,7 @@ function AssignRows(props) {
3481
3539
 
3482
3540
  // src/components/inputs-values-tree/index.tsx
3483
3541
  var import_react63 = __toESM(require("react"));
3484
- var import_editor32 = require("@flowgram.ai/editor");
3542
+ var import_editor33 = require("@flowgram.ai/editor");
3485
3543
  var import_semi_ui29 = require("@douyinfe/semi-ui");
3486
3544
  var import_semi_icons14 = require("@douyinfe/semi-icons");
3487
3545
 
@@ -3591,7 +3649,7 @@ var IconAddChildren2 = () => /* @__PURE__ */ import_react60.default.createElemen
3591
3649
 
3592
3650
  // src/components/inputs-values-tree/row.tsx
3593
3651
  var import_react62 = __toESM(require("react"));
3594
- var import_editor31 = require("@flowgram.ai/editor");
3652
+ var import_editor32 = require("@flowgram.ai/editor");
3595
3653
  var import_semi_ui28 = require("@douyinfe/semi-ui");
3596
3654
  var import_semi_icons13 = require("@douyinfe/semi-icons");
3597
3655
 
@@ -3648,7 +3706,7 @@ var AddObjectChildStrategy = {
3648
3706
  size: "small",
3649
3707
  disabled: true,
3650
3708
  style: { pointerEvents: "none" },
3651
- value: import_editor31.I18n.t("Configure via child fields")
3709
+ value: import_editor32.I18n.t("Configure via child fields")
3652
3710
  }
3653
3711
  )
3654
3712
  };
@@ -3689,7 +3747,7 @@ function InputValueRow(props) {
3689
3747
  size: "small",
3690
3748
  value: keyName,
3691
3749
  onChange: (v) => onUpdateKey?.(v),
3692
- placeholder: import_editor31.I18n.t("Input Key")
3750
+ placeholder: import_editor32.I18n.t("Input Key")
3693
3751
  }
3694
3752
  ), /* @__PURE__ */ import_react62.default.createElement(
3695
3753
  InjectDynamicValueInput,
@@ -3712,7 +3770,11 @@ function InputValueRow(props) {
3712
3770
  theme: "borderless",
3713
3771
  icon: /* @__PURE__ */ import_react62.default.createElement(IconAddChildren2, null),
3714
3772
  onClick: () => {
3715
- add();
3773
+ add({
3774
+ type: "constant",
3775
+ content: "",
3776
+ schema: { type: "string" }
3777
+ });
3716
3778
  setCollapse(true);
3717
3779
  }
3718
3780
  }
@@ -3777,36 +3839,42 @@ function InputsValuesTree(props) {
3777
3839
  disabled: readonly,
3778
3840
  icon: /* @__PURE__ */ import_react63.default.createElement(import_semi_icons14.IconPlus, null),
3779
3841
  size: "small",
3780
- onClick: add
3842
+ onClick: () => {
3843
+ add({
3844
+ type: "constant",
3845
+ content: "",
3846
+ schema: { type: "string" }
3847
+ });
3848
+ }
3781
3849
  },
3782
- import_editor32.I18n.t("Add")
3850
+ import_editor33.I18n.t("Add")
3783
3851
  ));
3784
3852
  }
3785
3853
 
3786
3854
  // src/effects/provide-batch-input/index.ts
3787
- var import_editor33 = require("@flowgram.ai/editor");
3788
- var provideBatchInputEffect = (0, import_editor33.createEffectFromVariableProvider)({
3855
+ var import_editor34 = require("@flowgram.ai/editor");
3856
+ var provideBatchInputEffect = (0, import_editor34.createEffectFromVariableProvider)({
3789
3857
  private: true,
3790
3858
  parse: (value, ctx) => [
3791
- import_editor33.ASTFactory.createVariableDeclaration({
3859
+ import_editor34.ASTFactory.createVariableDeclaration({
3792
3860
  key: `${ctx.node.id}_locals`,
3793
3861
  meta: {
3794
- title: (0, import_editor33.getNodeForm)(ctx.node)?.getValueIn("title"),
3862
+ title: (0, import_editor34.getNodeForm)(ctx.node)?.getValueIn("title"),
3795
3863
  icon: ctx.node.getNodeRegistry().info?.icon
3796
3864
  },
3797
- type: import_editor33.ASTFactory.createObject({
3865
+ type: import_editor34.ASTFactory.createObject({
3798
3866
  properties: [
3799
- import_editor33.ASTFactory.createProperty({
3867
+ import_editor34.ASTFactory.createProperty({
3800
3868
  key: "item",
3801
- initializer: import_editor33.ASTFactory.createEnumerateExpression({
3802
- enumerateFor: import_editor33.ASTFactory.createKeyPathExpression({
3869
+ initializer: import_editor34.ASTFactory.createEnumerateExpression({
3870
+ enumerateFor: import_editor34.ASTFactory.createKeyPathExpression({
3803
3871
  keyPath: value.content || []
3804
3872
  })
3805
3873
  })
3806
3874
  }),
3807
- import_editor33.ASTFactory.createProperty({
3875
+ import_editor34.ASTFactory.createProperty({
3808
3876
  key: "index",
3809
- type: import_editor33.ASTFactory.createNumber()
3877
+ type: import_editor34.ASTFactory.createNumber()
3810
3878
  })
3811
3879
  ]
3812
3880
  })
@@ -3815,13 +3883,13 @@ var provideBatchInputEffect = (0, import_editor33.createEffectFromVariableProvid
3815
3883
  });
3816
3884
 
3817
3885
  // src/effects/auto-rename-ref/index.ts
3818
- var import_editor34 = require("@flowgram.ai/editor");
3886
+ var import_editor35 = require("@flowgram.ai/editor");
3819
3887
  var autoRenameRefEffect = [
3820
3888
  {
3821
- event: import_editor34.DataEvent.onValueInit,
3889
+ event: import_editor35.DataEvent.onValueInit,
3822
3890
  effect: (params) => {
3823
3891
  const { context, form, name } = params;
3824
- const renameService = context.node.getService(import_editor34.VariableFieldKeyRenameService);
3892
+ const renameService = context.node.getService(import_editor35.VariableFieldKeyRenameService);
3825
3893
  const disposable = renameService.onRename(({ before, after }) => {
3826
3894
  const beforeKeyPath = [
3827
3895
  ...before.parentFields.map((_field) => _field.key).reverse(),
@@ -3879,13 +3947,13 @@ function traverseRef(name, value, cb) {
3879
3947
 
3880
3948
  // src/effects/provide-json-schema-outputs/index.ts
3881
3949
  var import_json_schema11 = require("@flowgram.ai/json-schema");
3882
- var import_editor35 = require("@flowgram.ai/editor");
3883
- var provideJsonSchemaOutputs = (0, import_editor35.createEffectFromVariableProvider)({
3950
+ var import_editor36 = require("@flowgram.ai/editor");
3951
+ var provideJsonSchemaOutputs = (0, import_editor36.createEffectFromVariableProvider)({
3884
3952
  parse: (value, ctx) => [
3885
- import_editor35.ASTFactory.createVariableDeclaration({
3953
+ import_editor36.ASTFactory.createVariableDeclaration({
3886
3954
  key: `${ctx.node.id}`,
3887
3955
  meta: {
3888
- title: (0, import_editor35.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
3956
+ title: (0, import_editor36.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
3889
3957
  icon: ctx.node.getNodeRegistry().info?.icon
3890
3958
  },
3891
3959
  type: import_json_schema11.JsonSchemaUtils.schemaToAST(value)
@@ -3894,12 +3962,12 @@ var provideJsonSchemaOutputs = (0, import_editor35.createEffectFromVariableProvi
3894
3962
  });
3895
3963
 
3896
3964
  // src/effects/sync-variable-title/index.ts
3897
- var import_editor36 = require("@flowgram.ai/editor");
3965
+ var import_editor37 = require("@flowgram.ai/editor");
3898
3966
  var syncVariableTitle = [
3899
3967
  {
3900
- event: import_editor36.DataEvent.onValueChange,
3968
+ event: import_editor37.DataEvent.onValueChange,
3901
3969
  effect: ({ value, context }) => {
3902
- context.node.getData(import_editor36.FlowNodeVariableData).allScopes.forEach((_scope) => {
3970
+ context.node.getData(import_editor37.FlowNodeVariableData).allScopes.forEach((_scope) => {
3903
3971
  _scope.output.variables.forEach((_var) => {
3904
3972
  _var.updateMeta({
3905
3973
  ..._var.meta || {},
@@ -3914,14 +3982,14 @@ var syncVariableTitle = [
3914
3982
 
3915
3983
  // src/effects/validate-when-variable-sync/index.ts
3916
3984
  var import_lodash10 = require("lodash");
3917
- var import_editor37 = require("@flowgram.ai/editor");
3985
+ var import_editor38 = require("@flowgram.ai/editor");
3918
3986
  var validateWhenVariableSync = ({
3919
3987
  scope
3920
3988
  } = {}) => [
3921
3989
  {
3922
- event: import_editor37.DataEvent.onValueInit,
3990
+ event: import_editor38.DataEvent.onValueInit,
3923
3991
  effect: ({ context, form }) => {
3924
- const nodeScope = scope === "private" ? (0, import_editor37.getNodePrivateScope)(context.node) : (0, import_editor37.getNodeScope)(context.node);
3992
+ const nodeScope = scope === "private" ? (0, import_editor38.getNodePrivateScope)(context.node) : (0, import_editor38.getNodeScope)(context.node);
3925
3993
  const disposable = nodeScope.available.onListOrAnyVarChange(() => {
3926
3994
  if (!(0, import_lodash10.isEmpty)(form.state.errors)) {
3927
3995
  form.validate();
@@ -3933,16 +4001,16 @@ var validateWhenVariableSync = ({
3933
4001
  ];
3934
4002
 
3935
4003
  // src/effects/listen-ref-value-change/index.ts
3936
- var import_editor38 = require("@flowgram.ai/editor");
4004
+ var import_editor39 = require("@flowgram.ai/editor");
3937
4005
  var listenRefValueChange = (cb) => [
3938
4006
  {
3939
- event: import_editor38.DataEvent.onValueInitOrChange,
4007
+ event: import_editor39.DataEvent.onValueInitOrChange,
3940
4008
  effect: (params) => {
3941
4009
  const { context, value } = params;
3942
4010
  if (value?.type !== "ref") {
3943
4011
  return () => null;
3944
4012
  }
3945
- const disposable = (0, import_editor38.getNodeScope)(context.node).available.trackByKeyPath(
4013
+ const disposable = (0, import_editor39.getNodeScope)(context.node).available.trackByKeyPath(
3946
4014
  value?.content || [],
3947
4015
  (v) => {
3948
4016
  cb({ ...params, variable: v });
@@ -3957,16 +4025,16 @@ var listenRefValueChange = (cb) => [
3957
4025
 
3958
4026
  // src/effects/listen-ref-schema-change/index.ts
3959
4027
  var import_json_schema12 = require("@flowgram.ai/json-schema");
3960
- var import_editor39 = require("@flowgram.ai/editor");
4028
+ var import_editor40 = require("@flowgram.ai/editor");
3961
4029
  var listenRefSchemaChange = (cb) => [
3962
4030
  {
3963
- event: import_editor39.DataEvent.onValueInitOrChange,
4031
+ event: import_editor40.DataEvent.onValueInitOrChange,
3964
4032
  effect: (params) => {
3965
4033
  const { context, value } = params;
3966
4034
  if (value?.type !== "ref") {
3967
4035
  return () => null;
3968
4036
  }
3969
- const disposable = (0, import_editor39.getNodeScope)(context.node).available.trackByKeyPath(
4037
+ const disposable = (0, import_editor40.getNodeScope)(context.node).available.trackByKeyPath(
3970
4038
  value?.content || [],
3971
4039
  (_type) => {
3972
4040
  cb({ ...params, schema: import_json_schema12.JsonSchemaUtils.astToSchema(_type) });
@@ -3983,21 +4051,21 @@ var listenRefSchemaChange = (cb) => [
3983
4051
  ];
3984
4052
 
3985
4053
  // src/form-plugins/batch-outputs-plugin/index.ts
3986
- var import_editor40 = require("@flowgram.ai/editor");
3987
- var provideBatchOutputsEffect = (0, import_editor40.createEffectFromVariableProvider)({
4054
+ var import_editor41 = require("@flowgram.ai/editor");
4055
+ var provideBatchOutputsEffect = (0, import_editor41.createEffectFromVariableProvider)({
3988
4056
  parse: (value, ctx) => [
3989
- import_editor40.ASTFactory.createVariableDeclaration({
4057
+ import_editor41.ASTFactory.createVariableDeclaration({
3990
4058
  key: `${ctx.node.id}`,
3991
4059
  meta: {
3992
- title: (0, import_editor40.getNodeForm)(ctx.node)?.getValueIn("title"),
4060
+ title: (0, import_editor41.getNodeForm)(ctx.node)?.getValueIn("title"),
3993
4061
  icon: ctx.node.getNodeRegistry().info?.icon
3994
4062
  },
3995
- type: import_editor40.ASTFactory.createObject({
4063
+ type: import_editor41.ASTFactory.createObject({
3996
4064
  properties: Object.entries(value).map(
3997
- ([_key, value2]) => import_editor40.ASTFactory.createProperty({
4065
+ ([_key, value2]) => import_editor41.ASTFactory.createProperty({
3998
4066
  key: _key,
3999
- initializer: import_editor40.ASTFactory.createWrapArrayExpression({
4000
- wrapFor: import_editor40.ASTFactory.createKeyPathExpression({
4067
+ initializer: import_editor41.ASTFactory.createWrapArrayExpression({
4068
+ wrapFor: import_editor41.ASTFactory.createKeyPathExpression({
4001
4069
  keyPath: value2?.content || []
4002
4070
  })
4003
4071
  })
@@ -4007,7 +4075,7 @@ var provideBatchOutputsEffect = (0, import_editor40.createEffectFromVariableProv
4007
4075
  })
4008
4076
  ]
4009
4077
  });
4010
- var createBatchOutputsFormPlugin = (0, import_editor40.defineFormPluginCreator)({
4078
+ var createBatchOutputsFormPlugin = (0, import_editor41.defineFormPluginCreator)({
4011
4079
  name: "batch-outputs-plugin",
4012
4080
  onSetupFormMeta({ mergeEffect }, { outputKey }) {
4013
4081
  mergeEffect({
@@ -4015,7 +4083,7 @@ var createBatchOutputsFormPlugin = (0, import_editor40.defineFormPluginCreator)(
4015
4083
  });
4016
4084
  },
4017
4085
  onInit(ctx, { outputKey }) {
4018
- const chainTransformService = ctx.node.getService(import_editor40.ScopeChainTransformService);
4086
+ const chainTransformService = ctx.node.getService(import_editor41.ScopeChainTransformService);
4019
4087
  const batchNodeType = ctx.node.flowNodeType;
4020
4088
  const transformerId = `${batchNodeType}-outputs`;
4021
4089
  if (chainTransformService.hasTransformer(transformerId)) {
@@ -4025,21 +4093,21 @@ var createBatchOutputsFormPlugin = (0, import_editor40.defineFormPluginCreator)(
4025
4093
  transformCovers: (covers, ctx2) => {
4026
4094
  const node = ctx2.scope.meta?.node;
4027
4095
  if (node?.parent?.flowNodeType === batchNodeType) {
4028
- return [...covers, (0, import_editor40.getNodeScope)(node.parent)];
4096
+ return [...covers, (0, import_editor41.getNodeScope)(node.parent)];
4029
4097
  }
4030
4098
  return covers;
4031
4099
  },
4032
4100
  transformDeps(scopes, ctx2) {
4033
4101
  const scopeMeta = ctx2.scope.meta;
4034
- if (scopeMeta?.type === import_editor40.FlowNodeScopeType.private) {
4102
+ if (scopeMeta?.type === import_editor41.FlowNodeScopeType.private) {
4035
4103
  return scopes;
4036
4104
  }
4037
4105
  const node = scopeMeta?.node;
4038
4106
  if (node?.flowNodeType === batchNodeType) {
4039
4107
  const childBlocks = node.blocks;
4040
4108
  return [
4041
- (0, import_editor40.getNodePrivateScope)(node),
4042
- ...childBlocks.map((_childBlock) => (0, import_editor40.getNodeScope)(_childBlock))
4109
+ (0, import_editor41.getNodePrivateScope)(node),
4110
+ ...childBlocks.map((_childBlock) => (0, import_editor41.getNodeScope)(_childBlock))
4043
4111
  ];
4044
4112
  }
4045
4113
  return scopes;
@@ -4050,8 +4118,8 @@ var createBatchOutputsFormPlugin = (0, import_editor40.defineFormPluginCreator)(
4050
4118
 
4051
4119
  // src/form-plugins/infer-inputs-plugin/index.ts
4052
4120
  var import_lodash11 = require("lodash");
4053
- var import_editor41 = require("@flowgram.ai/editor");
4054
- var createInferInputsPlugin = (0, import_editor41.defineFormPluginCreator)({
4121
+ var import_editor42 = require("@flowgram.ai/editor");
4122
+ var createInferInputsPlugin = (0, import_editor42.defineFormPluginCreator)({
4055
4123
  onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
4056
4124
  if (!sourceKey || !targetKey) {
4057
4125
  return;
@@ -4062,7 +4130,7 @@ var createInferInputsPlugin = (0, import_editor41.defineFormPluginCreator)({
4062
4130
  targetKey,
4063
4131
  FlowValueUtils.inferJsonSchema(
4064
4132
  (0, import_lodash11.get)(formData, sourceKey),
4065
- scope === "private" ? (0, import_editor41.getNodePrivateScope)(ctx.node) : (0, import_editor41.getNodeScope)(ctx.node)
4133
+ scope === "private" ? (0, import_editor42.getNodePrivateScope)(ctx.node) : (0, import_editor42.getNodeScope)(ctx.node)
4066
4134
  )
4067
4135
  );
4068
4136
  return formData;
@@ -4073,32 +4141,32 @@ var createInferInputsPlugin = (0, import_editor41.defineFormPluginCreator)({
4073
4141
  // src/form-plugins/infer-assign-plugin/index.ts
4074
4142
  var import_lodash12 = require("lodash");
4075
4143
  var import_json_schema13 = require("@flowgram.ai/json-schema");
4076
- var import_editor42 = require("@flowgram.ai/editor");
4077
- var createInferAssignPlugin = (0, import_editor42.defineFormPluginCreator)({
4144
+ var import_editor43 = require("@flowgram.ai/editor");
4145
+ var createInferAssignPlugin = (0, import_editor43.defineFormPluginCreator)({
4078
4146
  onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
4079
4147
  if (!assignKey || !outputKey) {
4080
4148
  return;
4081
4149
  }
4082
4150
  mergeEffect({
4083
- [assignKey]: (0, import_editor42.createEffectFromVariableProvider)({
4151
+ [assignKey]: (0, import_editor43.createEffectFromVariableProvider)({
4084
4152
  parse: (value, ctx) => {
4085
4153
  const declareRows = (0, import_lodash12.uniqBy)(
4086
4154
  value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
4087
4155
  "left"
4088
4156
  );
4089
4157
  return [
4090
- import_editor42.ASTFactory.createVariableDeclaration({
4158
+ import_editor43.ASTFactory.createVariableDeclaration({
4091
4159
  key: `${ctx.node.id}`,
4092
4160
  meta: {
4093
- title: (0, import_editor42.getNodeForm)(ctx.node)?.getValueIn("title"),
4161
+ title: (0, import_editor43.getNodeForm)(ctx.node)?.getValueIn("title"),
4094
4162
  icon: ctx.node.getNodeRegistry().info?.icon
4095
4163
  },
4096
- type: import_editor42.ASTFactory.createObject({
4164
+ type: import_editor43.ASTFactory.createObject({
4097
4165
  properties: declareRows.map(
4098
- (_v) => import_editor42.ASTFactory.createProperty({
4166
+ (_v) => import_editor43.ASTFactory.createProperty({
4099
4167
  key: _v.left,
4100
4168
  type: _v.right?.type === "constant" ? import_json_schema13.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
4101
- initializer: _v.right?.type === "ref" ? import_editor42.ASTFactory.createKeyPathExpression({
4169
+ initializer: _v.right?.type === "ref" ? import_editor43.ASTFactory.createKeyPathExpression({
4102
4170
  keyPath: _v.right?.content || []
4103
4171
  }) : {}
4104
4172
  })
@@ -4113,7 +4181,7 @@ var createInferAssignPlugin = (0, import_editor42.defineFormPluginCreator)({
4113
4181
  (0, import_lodash12.set)(
4114
4182
  formData,
4115
4183
  outputKey,
4116
- import_json_schema13.JsonSchemaUtils.astToSchema((0, import_editor42.getNodeScope)(ctx.node).output.variables?.[0]?.type)
4184
+ import_json_schema13.JsonSchemaUtils.astToSchema((0, import_editor43.getNodeScope)(ctx.node).output.variables?.[0]?.type)
4117
4185
  );
4118
4186
  return formData;
4119
4187
  });
@@ -4122,7 +4190,7 @@ var createInferAssignPlugin = (0, import_editor42.defineFormPluginCreator)({
4122
4190
 
4123
4191
  // src/validate/validate-flow-value/index.tsx
4124
4192
  var import_lodash13 = require("lodash");
4125
- var import_editor43 = require("@flowgram.ai/editor");
4193
+ var import_editor44 = require("@flowgram.ai/editor");
4126
4194
  function validateFlowValue(value, ctx) {
4127
4195
  const { node, required, errorMessages } = ctx;
4128
4196
  const {
@@ -4131,26 +4199,26 @@ function validateFlowValue(value, ctx) {
4131
4199
  } = errorMessages || {};
4132
4200
  if (required && ((0, import_lodash13.isNil)(value) || (0, import_lodash13.isNil)(value?.content) || value?.content === "")) {
4133
4201
  return {
4134
- level: import_editor43.FeedbackLevel.Error,
4202
+ level: import_editor44.FeedbackLevel.Error,
4135
4203
  message: requiredMessage
4136
4204
  };
4137
4205
  }
4138
4206
  if (value?.type === "ref") {
4139
- const variable = (0, import_editor43.getNodeScope)(node).available.getByKeyPath(value?.content || []);
4207
+ const variable = (0, import_editor44.getNodeScope)(node).available.getByKeyPath(value?.content || []);
4140
4208
  if (!variable) {
4141
4209
  return {
4142
- level: import_editor43.FeedbackLevel.Error,
4210
+ level: import_editor44.FeedbackLevel.Error,
4143
4211
  message: unknownVariableMessage
4144
4212
  };
4145
4213
  }
4146
4214
  }
4147
4215
  if (value?.type === "template") {
4148
- const allRefs = getTemplateKeyPaths(value);
4216
+ const allRefs = FlowValueUtils.getTemplateKeyPaths(value);
4149
4217
  for (const ref of allRefs) {
4150
- const variable = (0, import_editor43.getNodeScope)(node).available.getByKeyPath(ref);
4218
+ const variable = (0, import_editor44.getNodeScope)(node).available.getByKeyPath(ref);
4151
4219
  if (!variable) {
4152
4220
  return {
4153
- level: import_editor43.FeedbackLevel.Error,
4221
+ level: import_editor44.FeedbackLevel.Error,
4154
4222
  message: unknownVariableMessage
4155
4223
  };
4156
4224
  }
@@ -4158,12 +4226,6 @@ function validateFlowValue(value, ctx) {
4158
4226
  }
4159
4227
  return void 0;
4160
4228
  }
4161
- function getTemplateKeyPaths(value) {
4162
- const keyPathReg = /{{(.*?)}}/g;
4163
- return (0, import_lodash13.uniq)(value.content?.match(keyPathReg) || []).map(
4164
- (_keyPath) => _keyPath.slice(2, -2).split(".")
4165
- );
4166
- }
4167
4229
  // Annotate the CommonJS export names for ESM import in node:
4168
4230
  0 && (module.exports = {
4169
4231
  AssignRow,
@@ -4218,6 +4280,7 @@ function getTemplateKeyPaths(value) {
4218
4280
  provideBatchOutputsEffect,
4219
4281
  provideJsonSchemaOutputs,
4220
4282
  syncVariableTitle,
4283
+ useObjectList,
4221
4284
  useTypeManager,
4222
4285
  useVariableTree,
4223
4286
  validateFlowValue,