@flowgram.ai/form-materials 0.4.3 → 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/bin/index.ts CHANGED
@@ -72,17 +72,6 @@ program
72
72
  let { packagesToInstall } = copyMaterial(material, projectInfo);
73
73
 
74
74
  // 4. Install the dependencies
75
- packagesToInstall = packagesToInstall.map((_pkg) => {
76
- if (
77
- _pkg.startsWith(`@flowgram.ai/`) &&
78
- projectInfo.flowgramVersion !== 'workspace:*' &&
79
- !_pkg.endsWith(`@${projectInfo.flowgramVersion}`)
80
- ) {
81
- return `${_pkg}@${projectInfo.flowgramVersion}`;
82
- }
83
- return _pkg;
84
- });
85
-
86
75
  console.log(chalk.bold('These npm dependencies will be added to your project'));
87
76
  console.log(packagesToInstall);
88
77
  installDependencies(packagesToInstall, projectInfo);
package/bin/materials.ts CHANGED
@@ -61,12 +61,21 @@ export function listAllMaterials(): Material[] {
61
61
  return _materials;
62
62
  }
63
63
 
64
+ export const getFormMaterialDependencies = (): Record<string, string> => {
65
+ const packageJsonPath: string = path.join(__dirname, '..', 'package.json');
66
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
67
+
68
+ return packageJson.dependencies;
69
+ };
70
+
64
71
  export const copyMaterial = (
65
72
  material: Material,
66
73
  projectInfo: ProjectInfo
67
74
  ): {
68
75
  packagesToInstall: string[];
69
76
  } => {
77
+ const formMaterialDependencies = getFormMaterialDependencies();
78
+
70
79
  const sourceDir: string = material.path;
71
80
  const materialRoot: string = path.join(
72
81
  projectInfo.projectPath,
@@ -92,10 +101,28 @@ export const copyMaterial = (
92
101
  { ...importDeclaration, source: '@flowgram.ai/form-materials' },
93
102
  ])
94
103
  );
104
+ if (projectInfo.flowgramVersion !== 'workspace:*') {
105
+ packagesToInstall.add(`@flowgram.ai/form-materials@${projectInfo.flowgramVersion}`);
106
+ continue;
107
+ }
95
108
  packagesToInstall.add('@flowgram.ai/form-materials');
96
109
  } else if (!source.startsWith('.') && !source.startsWith('react')) {
97
- // check if is third party npm packages
98
- packagesToInstall.add(source);
110
+ // check if is in form material dependencies
111
+ const [dep, version] =
112
+ Object.entries(formMaterialDependencies).find(([_key]) => source.startsWith(_key)) ||
113
+ [];
114
+ if (!dep) {
115
+ continue;
116
+ }
117
+ if (version === 'workspace:*') {
118
+ if (projectInfo.flowgramVersion !== 'workspace:*') {
119
+ packagesToInstall.add(`${dep}@${projectInfo.flowgramVersion}`);
120
+ } else {
121
+ packagesToInstall.add(dep);
122
+ }
123
+ } else {
124
+ packagesToInstall.add(`${dep}@${version}`);
125
+ }
99
126
  }
100
127
  }
101
128
  }
package/dist/esm/index.js CHANGED
@@ -1448,7 +1448,7 @@ function PropertyEdit(props) {
1448
1448
  BlurInput,
1449
1449
  {
1450
1450
  disabled: readonly,
1451
- placeholder: config?.placeholder ?? "Input Variable Name",
1451
+ placeholder: config?.placeholder ?? I18n9.t("Input Variable Name"),
1452
1452
  size: "small",
1453
1453
  value: name,
1454
1454
  onChange: (value2) => onChange("name", value2)
@@ -2985,6 +2985,7 @@ function VariableTagInject2() {
2985
2985
  }
2986
2986
 
2987
2987
  // src/components/json-editor-with-variables/index.tsx
2988
+ import { I18n as I18n13 } from "@flowgram.ai/editor";
2988
2989
  function findAllMatches(inputString, regex) {
2989
2990
  const globalRegex = new RegExp(
2990
2991
  regex,
@@ -3018,7 +3019,7 @@ function JsonEditorWithVariables(props) {
3018
3019
  CodeEditor,
3019
3020
  {
3020
3021
  languageId: "json",
3021
- activeLinePlaceholder: "Press '@' to Select variable",
3022
+ activeLinePlaceholder: I18n13.t("Press '@' to Select variable"),
3022
3023
  ...props,
3023
3024
  options: {
3024
3025
  transformer,
@@ -3032,7 +3033,7 @@ function JsonEditorWithVariables(props) {
3032
3033
 
3033
3034
  // src/components/inputs-values/index.tsx
3034
3035
  import React34 from "react";
3035
- import { I18n as I18n13 } from "@flowgram.ai/editor";
3036
+ import { I18n as I18n14 } from "@flowgram.ai/editor";
3036
3037
  import { Button as Button4, IconButton as IconButton4 } from "@douyinfe/semi-ui";
3037
3038
  import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
3038
3039
 
@@ -3073,7 +3074,7 @@ function InputsValues({
3073
3074
  size: "small",
3074
3075
  value: item.key,
3075
3076
  onChange: (v) => updateKey(item.id, v),
3076
- placeholder: I18n13.t("Input Key")
3077
+ placeholder: I18n14.t("Input Key")
3077
3078
  }
3078
3079
  ), /* @__PURE__ */ React34.createElement(
3079
3080
  InjectDynamicValueInput,
@@ -3110,7 +3111,7 @@ function InputsValues({
3110
3111
  schema: { type: "string" }
3111
3112
  })
3112
3113
  },
3113
- I18n13.t("Add")
3114
+ I18n14.t("Add")
3114
3115
  ));
3115
3116
  }
3116
3117
 
@@ -3509,7 +3510,7 @@ function AssignRows(props) {
3509
3510
 
3510
3511
  // src/components/inputs-values-tree/index.tsx
3511
3512
  import React45 from "react";
3512
- import { I18n as I18n15 } from "@flowgram.ai/editor";
3513
+ import { I18n as I18n16 } from "@flowgram.ai/editor";
3513
3514
  import { Button as Button6 } from "@douyinfe/semi-ui";
3514
3515
  import { IconPlus as IconPlus5 } from "@douyinfe/semi-icons";
3515
3516
 
@@ -3619,7 +3620,7 @@ var IconAddChildren2 = () => /* @__PURE__ */ React43.createElement(Icon4, { size
3619
3620
 
3620
3621
  // src/components/inputs-values-tree/row.tsx
3621
3622
  import React44, { useMemo as useMemo13, useState as useState10 } from "react";
3622
- import { I18n as I18n14 } from "@flowgram.ai/editor";
3623
+ import { I18n as I18n15 } from "@flowgram.ai/editor";
3623
3624
  import { IconButton as IconButton6, Input as Input7 } from "@douyinfe/semi-ui";
3624
3625
  import { IconChevronDown as IconChevronDown2, IconChevronRight as IconChevronRight2, IconDelete as IconDelete3 } from "@douyinfe/semi-icons";
3625
3626
 
@@ -3676,7 +3677,7 @@ var AddObjectChildStrategy = {
3676
3677
  size: "small",
3677
3678
  disabled: true,
3678
3679
  style: { pointerEvents: "none" },
3679
- value: I18n14.t("Configure via child fields")
3680
+ value: I18n15.t("Configure via child fields")
3680
3681
  }
3681
3682
  )
3682
3683
  };
@@ -3717,7 +3718,7 @@ function InputValueRow(props) {
3717
3718
  size: "small",
3718
3719
  value: keyName,
3719
3720
  onChange: (v) => onUpdateKey?.(v),
3720
- placeholder: I18n14.t("Input Key")
3721
+ placeholder: I18n15.t("Input Key")
3721
3722
  }
3722
3723
  ), /* @__PURE__ */ React44.createElement(
3723
3724
  InjectDynamicValueInput,
@@ -3817,7 +3818,7 @@ function InputsValuesTree(props) {
3817
3818
  });
3818
3819
  }
3819
3820
  },
3820
- I18n15.t("Add")
3821
+ I18n16.t("Add")
3821
3822
  ));
3822
3823
  }
3823
3824