@flowgram.ai/form-materials 0.1.30 → 0.2.0

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 (39) hide show
  1. package/bin/materials.js +21 -5
  2. package/dist/esm/index.js +463 -57
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/index.d.mts +171 -28
  5. package/dist/index.d.ts +171 -28
  6. package/dist/index.js +472 -60
  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 +18 -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/hooks.tsx +33 -22
  19. package/src/components/json-schema-editor/index.tsx +11 -7
  20. package/src/components/json-schema-editor/types.ts +7 -0
  21. package/src/components/type-selector/index.tsx +5 -2
  22. package/src/components/type-selector/types.ts +4 -18
  23. package/src/components/variable-selector/config.json +1 -1
  24. package/src/components/variable-selector/index.tsx +80 -16
  25. package/src/components/variable-selector/styles.tsx +43 -0
  26. package/src/components/variable-selector/use-variable-tree.tsx +29 -7
  27. package/src/effects/index.ts +2 -0
  28. package/src/effects/provide-batch-input/config.json +5 -0
  29. package/src/effects/provide-batch-input/index.ts +38 -0
  30. package/src/effects/provide-batch-outputs/config.json +5 -0
  31. package/src/effects/provide-batch-outputs/index.ts +34 -0
  32. package/src/index.ts +3 -0
  33. package/src/typings/flow-value/config.json +5 -0
  34. package/src/typings/flow-value/index.ts +27 -0
  35. package/src/typings/index.ts +1 -0
  36. package/src/utils/format-legacy-refs/config.json +5 -0
  37. package/src/utils/format-legacy-refs/index.ts +153 -0
  38. package/src/utils/format-legacy-refs/readme.md +38 -0
  39. package/src/utils/index.ts +1 -0
package/bin/materials.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
- const _types = ['components'];
4
+ const _types = ['components', 'effects', 'utils', 'typings'];
5
5
 
6
6
  export function listAllMaterials() {
7
7
  const _materials = [];
@@ -32,7 +32,9 @@ export function listAllMaterials() {
32
32
 
33
33
  export function bfsMaterials(material, _materials = []) {
34
34
  function findConfigByName(name) {
35
- return _materials.find((_config) => _config.name === name);
35
+ return _materials.find(
36
+ (_config) => _config.name === name || `${_config.type}/${_config.name}` === name
37
+ );
36
38
  }
37
39
 
38
40
  const queue = [material];
@@ -67,11 +69,25 @@ export function bfsMaterials(material, _materials = []) {
67
69
 
68
70
  export const copyMaterial = (material, projectInfo) => {
69
71
  const sourceDir = material.path;
70
- const targetDir = path.join(
72
+ const materialRoot = path.join(
71
73
  projectInfo.projectPath,
74
+ 'src',
72
75
  'form-materials',
73
- `${material.type}`,
74
- material.name
76
+ `${material.type}`
75
77
  );
78
+ const targetDir = path.join(materialRoot, material.name);
76
79
  fs.cpSync(sourceDir, targetDir, { recursive: true });
80
+
81
+ let materialRootIndexTs = '';
82
+ if (fs.existsSync(path.join(materialRoot, 'index.ts'))) {
83
+ materialRootIndexTs = fs.readFileSync(path.join(materialRoot, 'index.ts'), 'utf8');
84
+ }
85
+ if (!materialRootIndexTs.includes(material.name)) {
86
+ fs.writeFileSync(
87
+ path.join(materialRoot, 'index.ts'),
88
+ `${materialRootIndexTs}${materialRootIndexTs.endsWith('\n') ? '' : '\n'}export * from './${
89
+ material.name
90
+ }';\n`
91
+ );
92
+ }
77
93
  };