@flowgram.ai/form-antd-materials 0.2.16 → 0.2.18

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 (53) hide show
  1. package/dist/esm/index.js +139 -10
  2. package/dist/esm/index.js.map +1 -1
  3. package/dist/index.d.mts +124 -6
  4. package/dist/index.d.ts +124 -6
  5. package/dist/index.js +127 -11
  6. package/dist/index.js.map +1 -1
  7. package/package.json +4 -4
  8. package/src/components/batch-variable-selector/index.tsx +5 -0
  9. package/src/components/condition-row/constants.ts +5 -0
  10. package/src/components/condition-row/hooks/styles.tsx +5 -0
  11. package/src/components/condition-row/hooks/useOp.tsx +5 -0
  12. package/src/components/condition-row/hooks/useRule.ts +5 -0
  13. package/src/components/condition-row/index.tsx +5 -0
  14. package/src/components/condition-row/styles.tsx +5 -0
  15. package/src/components/condition-row/types.ts +5 -0
  16. package/src/components/constant-input/index.tsx +5 -0
  17. package/src/components/constant-input/styles.tsx +5 -0
  18. package/src/components/constant-input/types.ts +5 -0
  19. package/src/components/dynamic-value-input/index.tsx +5 -0
  20. package/src/components/dynamic-value-input/styles.tsx +5 -0
  21. package/src/components/index.ts +5 -0
  22. package/src/components/json-schema-editor/components/blur-input.tsx +5 -0
  23. package/src/components/json-schema-editor/default-value.tsx +5 -0
  24. package/src/components/json-schema-editor/hooks.tsx +5 -0
  25. package/src/components/json-schema-editor/index.tsx +5 -0
  26. package/src/components/json-schema-editor/styles.tsx +5 -0
  27. package/src/components/json-schema-editor/types.ts +5 -0
  28. package/src/components/json-schema-editor/utils.ts +5 -0
  29. package/src/components/type-selector/constants.tsx +5 -0
  30. package/src/components/type-selector/index.tsx +5 -0
  31. package/src/components/variable-selector/index.tsx +5 -0
  32. package/src/components/variable-selector/styles.tsx +5 -0
  33. package/src/components/variable-selector/types.ts +5 -0
  34. package/src/components/variable-selector/use-variable-tree.tsx +5 -0
  35. package/src/effects/auto-rename-ref/index.ts +5 -0
  36. package/src/effects/index.ts +7 -0
  37. package/src/effects/provide-batch-input/index.ts +5 -0
  38. package/src/effects/provide-batch-outputs/index.ts +5 -1
  39. package/src/effects/provide-json-schema-outputs/config.json +8 -0
  40. package/src/effects/provide-json-schema-outputs/index.ts +28 -0
  41. package/src/effects/sync-variable-title/config.json +5 -0
  42. package/src/effects/sync-variable-title/index.ts +28 -0
  43. package/src/form-plugins/batch-outputs-plugin/config.json +7 -0
  44. package/src/form-plugins/batch-outputs-plugin/index.ts +104 -0
  45. package/src/form-plugins/index.ts +6 -0
  46. package/src/index.ts +6 -0
  47. package/src/typings/flow-value/index.ts +5 -0
  48. package/src/typings/index.ts +5 -0
  49. package/src/typings/json-schema/index.ts +5 -0
  50. package/src/utils/format-legacy-refs/index.ts +5 -0
  51. package/src/utils/index.ts +6 -1
  52. package/src/utils/json-schema/index.ts +21 -2
  53. package/src/utils/svg-icon/index.tsx +5 -0
package/dist/esm/index.js CHANGED
@@ -71,6 +71,12 @@ function formatNewRefToLegacyRef(value) {
71
71
  };
72
72
  }
73
73
 
74
+ // src/utils/svg-icon/index.tsx
75
+ import React from "react";
76
+ function SvgIcon(props) {
77
+ return /* @__PURE__ */ React.createElement("span", { className: "anticon" }, props.svg);
78
+ }
79
+
74
80
  // src/utils/json-schema/index.ts
75
81
  import { get } from "lodash";
76
82
  import { ASTFactory, ASTKind, ASTMatch } from "@flowgram.ai/editor";
@@ -91,7 +97,10 @@ var JsonSchemaUtils;
91
97
  properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => (get(a?.[1], "extra.index") || 0) - (get(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
92
98
  key,
93
99
  type: schemaToAST(_property),
94
- meta: { description: _property.description }
100
+ meta: {
101
+ title: _property.title,
102
+ description: _property.description
103
+ }
95
104
  }))
96
105
  });
97
106
  case "array":
@@ -147,7 +156,16 @@ var JsonSchemaUtils;
147
156
  return {
148
157
  type: "object",
149
158
  properties: drilldown ? Object.fromEntries(
150
- Object.entries(typeAST.properties).map(([key, value]) => [key, astToSchema(value)])
159
+ typeAST.properties.map((property) => {
160
+ const schema = astToSchema(property.type);
161
+ if (property.meta?.title && schema) {
162
+ schema.title = property.meta.title;
163
+ }
164
+ if (property.meta?.description && schema) {
165
+ schema.description = property.meta.description;
166
+ }
167
+ return [property.key, schema];
168
+ })
151
169
  ) : {}
152
170
  };
153
171
  }
@@ -184,12 +202,6 @@ var JsonSchemaUtils;
184
202
  JsonSchemaUtils2.isASTMatchSchema = isASTMatchSchema;
185
203
  })(JsonSchemaUtils || (JsonSchemaUtils = {}));
186
204
 
187
- // src/utils/svg-icon/index.tsx
188
- import React from "react";
189
- function SvgIcon(props) {
190
- return /* @__PURE__ */ React.createElement("span", { className: "anticon" }, props.svg);
191
- }
192
-
193
205
  // src/components/type-selector/constants.tsx
194
206
  var VariableTypeIcons = {
195
207
  custom: /* @__PURE__ */ React2.createElement(
@@ -1835,7 +1847,6 @@ import {
1835
1847
  getNodeForm as getNodeForm2
1836
1848
  } from "@flowgram.ai/editor";
1837
1849
  var provideBatchOutputsEffect = createEffectFromVariableProvider2({
1838
- private: true,
1839
1850
  parse: (value, ctx) => [
1840
1851
  ASTFactory3.createVariableDeclaration({
1841
1852
  key: `${ctx.node.id}`,
@@ -1918,6 +1929,121 @@ function traverseRef(name, value, cb) {
1918
1929
  }
1919
1930
  return;
1920
1931
  }
1932
+
1933
+ // src/effects/provide-json-schema-outputs/index.ts
1934
+ import {
1935
+ ASTFactory as ASTFactory4,
1936
+ createEffectFromVariableProvider as createEffectFromVariableProvider3,
1937
+ getNodeForm as getNodeForm3
1938
+ } from "@flowgram.ai/editor";
1939
+ var provideJsonSchemaOutputs = createEffectFromVariableProvider3({
1940
+ parse: (value, ctx) => [
1941
+ ASTFactory4.createVariableDeclaration({
1942
+ key: `${ctx.node.id}`,
1943
+ meta: {
1944
+ title: getNodeForm3(ctx.node)?.getValueIn("title") || ctx.node.id,
1945
+ icon: ctx.node.getNodeRegistry().info?.icon
1946
+ },
1947
+ type: JsonSchemaUtils.schemaToAST(value)
1948
+ })
1949
+ ]
1950
+ });
1951
+
1952
+ // src/effects/sync-variable-title/index.ts
1953
+ import {
1954
+ DataEvent as DataEvent2,
1955
+ FlowNodeVariableData
1956
+ } from "@flowgram.ai/editor";
1957
+ var syncVariableTitle = [
1958
+ {
1959
+ event: DataEvent2.onValueChange,
1960
+ effect: ({ value, context }) => {
1961
+ context.node.getData(FlowNodeVariableData).allScopes.forEach((_scope) => {
1962
+ _scope.output.variables.forEach((_var) => {
1963
+ _var.updateMeta({
1964
+ title: value || context.node.id,
1965
+ icon: context.node.getNodeRegistry().info?.icon
1966
+ });
1967
+ });
1968
+ });
1969
+ }
1970
+ }
1971
+ ];
1972
+
1973
+ // src/form-plugins/batch-outputs-plugin/index.ts
1974
+ import {
1975
+ ASTFactory as ASTFactory5,
1976
+ createEffectFromVariableProvider as createEffectFromVariableProvider4,
1977
+ defineFormPluginCreator,
1978
+ getNodeForm as getNodeForm4,
1979
+ getNodePrivateScope,
1980
+ getNodeScope,
1981
+ ScopeChainTransformService,
1982
+ FlowNodeScopeType
1983
+ } from "@flowgram.ai/editor";
1984
+ var provideBatchOutputsEffect2 = createEffectFromVariableProvider4({
1985
+ parse: (value, ctx) => [
1986
+ ASTFactory5.createVariableDeclaration({
1987
+ key: `${ctx.node.id}`,
1988
+ meta: {
1989
+ title: getNodeForm4(ctx.node)?.getValueIn("title"),
1990
+ icon: ctx.node.getNodeRegistry().info?.icon
1991
+ },
1992
+ type: ASTFactory5.createObject({
1993
+ properties: Object.entries(value).map(
1994
+ ([_key, value2]) => ASTFactory5.createProperty({
1995
+ key: _key,
1996
+ initializer: ASTFactory5.createWrapArrayExpression({
1997
+ wrapFor: ASTFactory5.createKeyPathExpression({
1998
+ keyPath: value2?.content || []
1999
+ })
2000
+ })
2001
+ })
2002
+ )
2003
+ })
2004
+ })
2005
+ ]
2006
+ });
2007
+ var createBatchOutputsFormPlugin = defineFormPluginCreator({
2008
+ name: "batch-outputs-plugin",
2009
+ onSetupFormMeta({ mergeEffect }, { outputKey }) {
2010
+ mergeEffect({
2011
+ [outputKey]: provideBatchOutputsEffect2
2012
+ });
2013
+ },
2014
+ onInit(ctx, { outputKey }) {
2015
+ const chainTransformService = ctx.node.getService(ScopeChainTransformService);
2016
+ const batchNodeType = ctx.node.flowNodeType;
2017
+ const transformerId = `${batchNodeType}-outputs`;
2018
+ if (chainTransformService.hasTransformer(transformerId)) {
2019
+ return;
2020
+ }
2021
+ chainTransformService.registerTransformer(transformerId, {
2022
+ transformCovers: (covers, ctx2) => {
2023
+ const node = ctx2.scope.meta?.node;
2024
+ if (node?.parent?.flowNodeType === batchNodeType) {
2025
+ return [...covers, getNodeScope(node.parent)];
2026
+ }
2027
+ return covers;
2028
+ },
2029
+ transformDeps(scopes, ctx2) {
2030
+ const scopeMeta = ctx2.scope.meta;
2031
+ if (scopeMeta?.type === FlowNodeScopeType.private) {
2032
+ return scopes;
2033
+ }
2034
+ const node = scopeMeta?.node;
2035
+ if (node?.flowNodeType === batchNodeType) {
2036
+ const childBlocks = node.blocks;
2037
+ return [
2038
+ getNodePrivateScope(node),
2039
+ ...childBlocks.map((_childBlock) => getNodeScope(_childBlock))
2040
+ ];
2041
+ }
2042
+ return scopes;
2043
+ }
2044
+ });
2045
+ }
2046
+ });
1921
2047
  export {
1922
2048
  ArrayIcons,
1923
2049
  BatchVariableSelector,
@@ -1931,6 +2057,7 @@ export {
1931
2057
  VariableSelector,
1932
2058
  VariableTypeIcons,
1933
2059
  autoRenameRefEffect,
2060
+ createBatchOutputsFormPlugin,
1934
2061
  formatLegacyRefOnInit,
1935
2062
  formatLegacyRefOnSubmit,
1936
2063
  formatLegacyRefToNewRef,
@@ -1941,6 +2068,8 @@ export {
1941
2068
  isNewFlowRefValueSchema,
1942
2069
  parseTypeSelectValue,
1943
2070
  provideBatchInputEffect,
1944
- provideBatchOutputsEffect
2071
+ provideBatchOutputsEffect,
2072
+ provideJsonSchemaOutputs,
2073
+ syncVariableTitle
1945
2074
  };
1946
2075
  //# sourceMappingURL=index.js.map