@flowgram.ai/form-antd-materials 0.1.0-alpha.13 → 0.1.0-alpha.14
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/esm/index.js +9 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +62 -60
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/constant-input/index.tsx +4 -3
- package/src/components/json-schema-editor/index.tsx +2 -1
- package/src/effects/auto-rename-ref/config.json +6 -2
- package/src/effects/auto-rename-ref/index.ts +1 -1
- package/src/utils/format-legacy-refs/index.ts +1 -1
- package/src/utils/json-schema/config.json +6 -2
- package/src/utils/json-schema/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -71,9 +71,9 @@ var import_editor2 = require("@flowgram.ai/editor");
|
|
|
71
71
|
var import_react2 = __toESM(require("react"));
|
|
72
72
|
|
|
73
73
|
// src/utils/format-legacy-refs/index.ts
|
|
74
|
-
var
|
|
74
|
+
var import_lodash_es = require("lodash-es");
|
|
75
75
|
function formatLegacyRefOnSubmit(value) {
|
|
76
|
-
if ((0,
|
|
76
|
+
if ((0, import_lodash_es.isObject)(value)) {
|
|
77
77
|
if (isLegacyFlowRefValueSchema(value)) {
|
|
78
78
|
return formatLegacyRefToNewRef(value);
|
|
79
79
|
}
|
|
@@ -90,7 +90,7 @@ function formatLegacyRefOnSubmit(value) {
|
|
|
90
90
|
return value;
|
|
91
91
|
}
|
|
92
92
|
function formatLegacyRefOnInit(value) {
|
|
93
|
-
if ((0,
|
|
93
|
+
if ((0, import_lodash_es.isObject)(value)) {
|
|
94
94
|
if (isNewFlowRefValueSchema(value)) {
|
|
95
95
|
return formatNewRefToLegacyRef(value);
|
|
96
96
|
}
|
|
@@ -107,10 +107,10 @@ function formatLegacyRefOnInit(value) {
|
|
|
107
107
|
return value;
|
|
108
108
|
}
|
|
109
109
|
function isLegacyFlowRefValueSchema(value) {
|
|
110
|
-
return (0,
|
|
110
|
+
return (0, import_lodash_es.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
111
111
|
}
|
|
112
112
|
function isNewFlowRefValueSchema(value) {
|
|
113
|
-
return (0,
|
|
113
|
+
return (0, import_lodash_es.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
114
114
|
}
|
|
115
115
|
function formatLegacyRefToNewRef(value) {
|
|
116
116
|
const keyPath = value.content.split(".");
|
|
@@ -139,7 +139,7 @@ function SvgIcon(props) {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
// src/utils/json-schema/index.ts
|
|
142
|
-
var
|
|
142
|
+
var import_lodash_es2 = require("lodash-es");
|
|
143
143
|
var import_editor = require("@flowgram.ai/editor");
|
|
144
144
|
var JsonSchemaUtils;
|
|
145
145
|
((JsonSchemaUtils2) => {
|
|
@@ -155,7 +155,7 @@ var JsonSchemaUtils;
|
|
|
155
155
|
return { kind: import_editor.ASTKind.Object, weak: true };
|
|
156
156
|
}
|
|
157
157
|
return import_editor.ASTFactory.createObject({
|
|
158
|
-
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0,
|
|
158
|
+
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash_es2.get)(a?.[1], "extra.index") || 0) - ((0, import_lodash_es2.get)(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
|
|
159
159
|
key,
|
|
160
160
|
type: schemaToAST(_property),
|
|
161
161
|
meta: {
|
|
@@ -1155,13 +1155,14 @@ var UISelect = (0, import_styled_components3.default)(import_antd3.Select)`
|
|
|
1155
1155
|
`;
|
|
1156
1156
|
|
|
1157
1157
|
// src/components/constant-input/index.tsx
|
|
1158
|
+
var import_editor3 = require("@flowgram.ai/editor");
|
|
1158
1159
|
var defaultStrategies = [
|
|
1159
1160
|
{
|
|
1160
1161
|
hit: (schema) => schema?.type === "string",
|
|
1161
1162
|
Renderer: (props) => /* @__PURE__ */ import_react8.default.createElement(
|
|
1162
1163
|
UIInput,
|
|
1163
1164
|
{
|
|
1164
|
-
placeholder: "Please Input String",
|
|
1165
|
+
placeholder: import_editor3.I18n.t("Please Input String"),
|
|
1165
1166
|
size: "small",
|
|
1166
1167
|
disabled: props.readonly,
|
|
1167
1168
|
...props
|
|
@@ -1173,7 +1174,7 @@ var defaultStrategies = [
|
|
|
1173
1174
|
Renderer: (props) => /* @__PURE__ */ import_react8.default.createElement(
|
|
1174
1175
|
UIInputNumber,
|
|
1175
1176
|
{
|
|
1176
|
-
placeholder: "Please Input Number",
|
|
1177
|
+
placeholder: import_editor3.I18n.t("Please Input Number"),
|
|
1177
1178
|
size: "small",
|
|
1178
1179
|
disabled: props.readonly,
|
|
1179
1180
|
...props
|
|
@@ -1185,7 +1186,7 @@ var defaultStrategies = [
|
|
|
1185
1186
|
Renderer: (props) => /* @__PURE__ */ import_react8.default.createElement(
|
|
1186
1187
|
UIInputNumber,
|
|
1187
1188
|
{
|
|
1188
|
-
placeholder: "Please Input Integer",
|
|
1189
|
+
placeholder: import_editor3.I18n.t("Please Input Integer"),
|
|
1189
1190
|
size: "small",
|
|
1190
1191
|
disabled: props.readonly,
|
|
1191
1192
|
precision: 0,
|
|
@@ -1327,6 +1328,7 @@ function BlurInput(props) {
|
|
|
1327
1328
|
}
|
|
1328
1329
|
|
|
1329
1330
|
// src/components/json-schema-editor/index.tsx
|
|
1331
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
1330
1332
|
function JsonSchemaEditor(props) {
|
|
1331
1333
|
const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
|
|
1332
1334
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
@@ -1408,7 +1410,7 @@ function PropertyEdit(props) {
|
|
|
1408
1410
|
/* @__PURE__ */ import_react11.default.createElement(UIRow, null, /* @__PURE__ */ import_react11.default.createElement(UIName, null, /* @__PURE__ */ import_react11.default.createElement(
|
|
1409
1411
|
BlurInput,
|
|
1410
1412
|
{
|
|
1411
|
-
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1413
|
+
placeholder: config?.placeholder ?? import_editor4.I18n.t("Input Variable Name"),
|
|
1412
1414
|
size: "small",
|
|
1413
1415
|
value: name,
|
|
1414
1416
|
onChange: (value2) => onChange("name", value2)
|
|
@@ -1494,13 +1496,13 @@ function PropertyEdit(props) {
|
|
|
1494
1496
|
|
|
1495
1497
|
// src/components/batch-variable-selector/index.tsx
|
|
1496
1498
|
var import_react12 = __toESM(require("react"));
|
|
1497
|
-
var
|
|
1499
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
1498
1500
|
var batchVariableSchema = {
|
|
1499
1501
|
type: "array",
|
|
1500
1502
|
extra: { weak: true }
|
|
1501
1503
|
};
|
|
1502
1504
|
function BatchVariableSelector(props) {
|
|
1503
|
-
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1505
|
+
return /* @__PURE__ */ import_react12.default.createElement(import_editor5.PrivateScopeProvider, null, /* @__PURE__ */ import_react12.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1504
1506
|
}
|
|
1505
1507
|
|
|
1506
1508
|
// src/components/dynamic-value-input/index.tsx
|
|
@@ -1618,7 +1620,7 @@ var UIValues = import_styled_components5.default.div`
|
|
|
1618
1620
|
|
|
1619
1621
|
// src/components/condition-row/hooks/useRule.ts
|
|
1620
1622
|
var import_react14 = require("react");
|
|
1621
|
-
var
|
|
1623
|
+
var import_editor6 = require("@flowgram.ai/editor");
|
|
1622
1624
|
|
|
1623
1625
|
// src/components/condition-row/constants.ts
|
|
1624
1626
|
var rules = {
|
|
@@ -1744,7 +1746,7 @@ var opConfigs = {
|
|
|
1744
1746
|
|
|
1745
1747
|
// src/components/condition-row/hooks/useRule.ts
|
|
1746
1748
|
function useRule(left) {
|
|
1747
|
-
const available = (0,
|
|
1749
|
+
const available = (0, import_editor6.useScopeAvailable)();
|
|
1748
1750
|
const variable = (0, import_react14.useMemo)(() => {
|
|
1749
1751
|
if (!left) return void 0;
|
|
1750
1752
|
return available.getByKeyPath(left.content);
|
|
@@ -1870,29 +1872,29 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1870
1872
|
}
|
|
1871
1873
|
|
|
1872
1874
|
// src/effects/provide-batch-input/index.ts
|
|
1873
|
-
var
|
|
1874
|
-
var provideBatchInputEffect = (0,
|
|
1875
|
+
var import_editor7 = require("@flowgram.ai/editor");
|
|
1876
|
+
var provideBatchInputEffect = (0, import_editor7.createEffectFromVariableProvider)({
|
|
1875
1877
|
private: true,
|
|
1876
1878
|
parse: (value, ctx) => [
|
|
1877
|
-
|
|
1879
|
+
import_editor7.ASTFactory.createVariableDeclaration({
|
|
1878
1880
|
key: `${ctx.node.id}_locals`,
|
|
1879
1881
|
meta: {
|
|
1880
|
-
title: (0,
|
|
1882
|
+
title: (0, import_editor7.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1881
1883
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1882
1884
|
},
|
|
1883
|
-
type:
|
|
1885
|
+
type: import_editor7.ASTFactory.createObject({
|
|
1884
1886
|
properties: [
|
|
1885
|
-
|
|
1887
|
+
import_editor7.ASTFactory.createProperty({
|
|
1886
1888
|
key: "item",
|
|
1887
|
-
initializer:
|
|
1888
|
-
enumerateFor:
|
|
1889
|
+
initializer: import_editor7.ASTFactory.createEnumerateExpression({
|
|
1890
|
+
enumerateFor: import_editor7.ASTFactory.createKeyPathExpression({
|
|
1889
1891
|
keyPath: value.content || []
|
|
1890
1892
|
})
|
|
1891
1893
|
})
|
|
1892
1894
|
}),
|
|
1893
|
-
|
|
1895
|
+
import_editor7.ASTFactory.createProperty({
|
|
1894
1896
|
key: "index",
|
|
1895
|
-
type:
|
|
1897
|
+
type: import_editor7.ASTFactory.createNumber()
|
|
1896
1898
|
})
|
|
1897
1899
|
]
|
|
1898
1900
|
})
|
|
@@ -1901,21 +1903,21 @@ var provideBatchInputEffect = (0, import_editor5.createEffectFromVariableProvide
|
|
|
1901
1903
|
});
|
|
1902
1904
|
|
|
1903
1905
|
// src/effects/provide-batch-outputs/index.ts
|
|
1904
|
-
var
|
|
1905
|
-
var provideBatchOutputsEffect = (0,
|
|
1906
|
+
var import_editor8 = require("@flowgram.ai/editor");
|
|
1907
|
+
var provideBatchOutputsEffect = (0, import_editor8.createEffectFromVariableProvider)({
|
|
1906
1908
|
parse: (value, ctx) => [
|
|
1907
|
-
|
|
1909
|
+
import_editor8.ASTFactory.createVariableDeclaration({
|
|
1908
1910
|
key: `${ctx.node.id}`,
|
|
1909
1911
|
meta: {
|
|
1910
|
-
title: (0,
|
|
1912
|
+
title: (0, import_editor8.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1911
1913
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1912
1914
|
},
|
|
1913
|
-
type:
|
|
1915
|
+
type: import_editor8.ASTFactory.createObject({
|
|
1914
1916
|
properties: Object.entries(value).map(
|
|
1915
|
-
([_key, value2]) =>
|
|
1917
|
+
([_key, value2]) => import_editor8.ASTFactory.createProperty({
|
|
1916
1918
|
key: _key,
|
|
1917
|
-
initializer:
|
|
1918
|
-
wrapFor:
|
|
1919
|
+
initializer: import_editor8.ASTFactory.createWrapArrayExpression({
|
|
1920
|
+
wrapFor: import_editor8.ASTFactory.createKeyPathExpression({
|
|
1919
1921
|
keyPath: value2.content || []
|
|
1920
1922
|
})
|
|
1921
1923
|
})
|
|
@@ -1927,14 +1929,14 @@ var provideBatchOutputsEffect = (0, import_editor6.createEffectFromVariableProvi
|
|
|
1927
1929
|
});
|
|
1928
1930
|
|
|
1929
1931
|
// src/effects/auto-rename-ref/index.ts
|
|
1930
|
-
var
|
|
1931
|
-
var
|
|
1932
|
+
var import_lodash_es3 = require("lodash-es");
|
|
1933
|
+
var import_editor9 = require("@flowgram.ai/editor");
|
|
1932
1934
|
var autoRenameRefEffect = [
|
|
1933
1935
|
{
|
|
1934
|
-
event:
|
|
1936
|
+
event: import_editor9.DataEvent.onValueInit,
|
|
1935
1937
|
effect: (params) => {
|
|
1936
1938
|
const { context, form, name } = params;
|
|
1937
|
-
const renameService = context.node.getService(
|
|
1939
|
+
const renameService = context.node.getService(import_editor9.VariableFieldKeyRenameService);
|
|
1938
1940
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
1939
1941
|
const beforeKeyPath = [
|
|
1940
1942
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -1964,7 +1966,7 @@ function isRef(value) {
|
|
|
1964
1966
|
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
1965
1967
|
}
|
|
1966
1968
|
function traverseRef(name, value, cb) {
|
|
1967
|
-
if ((0,
|
|
1969
|
+
if ((0, import_lodash_es3.isObject)(value)) {
|
|
1968
1970
|
if (isRef(value)) {
|
|
1969
1971
|
cb(name, value);
|
|
1970
1972
|
return;
|
|
@@ -1974,7 +1976,7 @@ function traverseRef(name, value, cb) {
|
|
|
1974
1976
|
});
|
|
1975
1977
|
return;
|
|
1976
1978
|
}
|
|
1977
|
-
if ((0,
|
|
1979
|
+
if ((0, import_lodash_es3.isArray)(value)) {
|
|
1978
1980
|
value.forEach((_value, idx) => {
|
|
1979
1981
|
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
1980
1982
|
});
|
|
@@ -1984,13 +1986,13 @@ function traverseRef(name, value, cb) {
|
|
|
1984
1986
|
}
|
|
1985
1987
|
|
|
1986
1988
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
1987
|
-
var
|
|
1988
|
-
var provideJsonSchemaOutputs = (0,
|
|
1989
|
+
var import_editor10 = require("@flowgram.ai/editor");
|
|
1990
|
+
var provideJsonSchemaOutputs = (0, import_editor10.createEffectFromVariableProvider)({
|
|
1989
1991
|
parse: (value, ctx) => [
|
|
1990
|
-
|
|
1992
|
+
import_editor10.ASTFactory.createVariableDeclaration({
|
|
1991
1993
|
key: `${ctx.node.id}`,
|
|
1992
1994
|
meta: {
|
|
1993
|
-
title: (0,
|
|
1995
|
+
title: (0, import_editor10.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
1994
1996
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1995
1997
|
},
|
|
1996
1998
|
type: JsonSchemaUtils.schemaToAST(value)
|
|
@@ -1999,12 +2001,12 @@ var provideJsonSchemaOutputs = (0, import_editor8.createEffectFromVariableProvid
|
|
|
1999
2001
|
});
|
|
2000
2002
|
|
|
2001
2003
|
// src/effects/sync-variable-title/index.ts
|
|
2002
|
-
var
|
|
2004
|
+
var import_editor11 = require("@flowgram.ai/editor");
|
|
2003
2005
|
var syncVariableTitle = [
|
|
2004
2006
|
{
|
|
2005
|
-
event:
|
|
2007
|
+
event: import_editor11.DataEvent.onValueChange,
|
|
2006
2008
|
effect: ({ value, context }) => {
|
|
2007
|
-
context.node.getData(
|
|
2009
|
+
context.node.getData(import_editor11.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
2008
2010
|
_scope.output.variables.forEach((_var) => {
|
|
2009
2011
|
_var.updateMeta({
|
|
2010
2012
|
title: value || context.node.id,
|
|
@@ -2017,21 +2019,21 @@ var syncVariableTitle = [
|
|
|
2017
2019
|
];
|
|
2018
2020
|
|
|
2019
2021
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
2020
|
-
var
|
|
2021
|
-
var provideBatchOutputsEffect2 = (0,
|
|
2022
|
+
var import_editor12 = require("@flowgram.ai/editor");
|
|
2023
|
+
var provideBatchOutputsEffect2 = (0, import_editor12.createEffectFromVariableProvider)({
|
|
2022
2024
|
parse: (value, ctx) => [
|
|
2023
|
-
|
|
2025
|
+
import_editor12.ASTFactory.createVariableDeclaration({
|
|
2024
2026
|
key: `${ctx.node.id}`,
|
|
2025
2027
|
meta: {
|
|
2026
|
-
title: (0,
|
|
2028
|
+
title: (0, import_editor12.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
2027
2029
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
2028
2030
|
},
|
|
2029
|
-
type:
|
|
2031
|
+
type: import_editor12.ASTFactory.createObject({
|
|
2030
2032
|
properties: Object.entries(value).map(
|
|
2031
|
-
([_key, value2]) =>
|
|
2033
|
+
([_key, value2]) => import_editor12.ASTFactory.createProperty({
|
|
2032
2034
|
key: _key,
|
|
2033
|
-
initializer:
|
|
2034
|
-
wrapFor:
|
|
2035
|
+
initializer: import_editor12.ASTFactory.createWrapArrayExpression({
|
|
2036
|
+
wrapFor: import_editor12.ASTFactory.createKeyPathExpression({
|
|
2035
2037
|
keyPath: value2?.content || []
|
|
2036
2038
|
})
|
|
2037
2039
|
})
|
|
@@ -2041,7 +2043,7 @@ var provideBatchOutputsEffect2 = (0, import_editor10.createEffectFromVariablePro
|
|
|
2041
2043
|
})
|
|
2042
2044
|
]
|
|
2043
2045
|
});
|
|
2044
|
-
var createBatchOutputsFormPlugin = (0,
|
|
2046
|
+
var createBatchOutputsFormPlugin = (0, import_editor12.defineFormPluginCreator)({
|
|
2045
2047
|
name: "batch-outputs-plugin",
|
|
2046
2048
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
2047
2049
|
mergeEffect({
|
|
@@ -2049,7 +2051,7 @@ var createBatchOutputsFormPlugin = (0, import_editor10.defineFormPluginCreator)(
|
|
|
2049
2051
|
});
|
|
2050
2052
|
},
|
|
2051
2053
|
onInit(ctx, { outputKey }) {
|
|
2052
|
-
const chainTransformService = ctx.node.getService(
|
|
2054
|
+
const chainTransformService = ctx.node.getService(import_editor12.ScopeChainTransformService);
|
|
2053
2055
|
const batchNodeType = ctx.node.flowNodeType;
|
|
2054
2056
|
const transformerId = `${batchNodeType}-outputs`;
|
|
2055
2057
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -2059,21 +2061,21 @@ var createBatchOutputsFormPlugin = (0, import_editor10.defineFormPluginCreator)(
|
|
|
2059
2061
|
transformCovers: (covers, ctx2) => {
|
|
2060
2062
|
const node = ctx2.scope.meta?.node;
|
|
2061
2063
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
2062
|
-
return [...covers, (0,
|
|
2064
|
+
return [...covers, (0, import_editor12.getNodeScope)(node.parent)];
|
|
2063
2065
|
}
|
|
2064
2066
|
return covers;
|
|
2065
2067
|
},
|
|
2066
2068
|
transformDeps(scopes, ctx2) {
|
|
2067
2069
|
const scopeMeta = ctx2.scope.meta;
|
|
2068
|
-
if (scopeMeta?.type ===
|
|
2070
|
+
if (scopeMeta?.type === import_editor12.FlowNodeScopeType.private) {
|
|
2069
2071
|
return scopes;
|
|
2070
2072
|
}
|
|
2071
2073
|
const node = scopeMeta?.node;
|
|
2072
2074
|
if (node?.flowNodeType === batchNodeType) {
|
|
2073
2075
|
const childBlocks = node.blocks;
|
|
2074
2076
|
return [
|
|
2075
|
-
(0,
|
|
2076
|
-
...childBlocks.map((_childBlock) => (0,
|
|
2077
|
+
(0, import_editor12.getNodePrivateScope)(node),
|
|
2078
|
+
...childBlocks.map((_childBlock) => (0, import_editor12.getNodeScope)(_childBlock))
|
|
2077
2079
|
];
|
|
2078
2080
|
}
|
|
2079
2081
|
return scopes;
|