@flowgram.ai/form-materials 0.2.25 → 0.2.27
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 +45 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +62 -26
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/json-schema-editor/hooks.tsx +3 -1
- package/src/components/prompt-editor/index.tsx +2 -1
- package/src/components/prompt-editor/types.tsx +1 -0
- package/src/effects/auto-rename-ref/index.ts +59 -8
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1003,6 +1003,7 @@ var ConstantInputWrapper = import_styled_components2.default.div`
|
|
|
1003
1003
|
|
|
1004
1004
|
// src/components/json-schema-editor/hooks.tsx
|
|
1005
1005
|
var import_react6 = require("react");
|
|
1006
|
+
var import_lodash2 = require("lodash");
|
|
1006
1007
|
var _id = 0;
|
|
1007
1008
|
function genId() {
|
|
1008
1009
|
return _id++;
|
|
@@ -1075,7 +1076,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1075
1076
|
if (!_property.name) {
|
|
1076
1077
|
continue;
|
|
1077
1078
|
}
|
|
1078
|
-
nextProperties[_property.name] = _property;
|
|
1079
|
+
nextProperties[_property.name] = (0, import_lodash2.omit)(_property, ["key", "name", "isPropertyRequired"]);
|
|
1079
1080
|
if (_property.isPropertyRequired) {
|
|
1080
1081
|
nextRequired.push(_property.name);
|
|
1081
1082
|
}
|
|
@@ -1737,9 +1738,9 @@ var opConfigs = {
|
|
|
1737
1738
|
};
|
|
1738
1739
|
|
|
1739
1740
|
// src/utils/format-legacy-refs/index.ts
|
|
1740
|
-
var
|
|
1741
|
+
var import_lodash3 = require("lodash");
|
|
1741
1742
|
function formatLegacyRefOnSubmit(value) {
|
|
1742
|
-
if ((0,
|
|
1743
|
+
if ((0, import_lodash3.isObject)(value)) {
|
|
1743
1744
|
if (isLegacyFlowRefValueSchema(value)) {
|
|
1744
1745
|
return formatLegacyRefToNewRef(value);
|
|
1745
1746
|
}
|
|
@@ -1756,7 +1757,7 @@ function formatLegacyRefOnSubmit(value) {
|
|
|
1756
1757
|
return value;
|
|
1757
1758
|
}
|
|
1758
1759
|
function formatLegacyRefOnInit(value) {
|
|
1759
|
-
if ((0,
|
|
1760
|
+
if ((0, import_lodash3.isObject)(value)) {
|
|
1760
1761
|
if (isNewFlowRefValueSchema(value)) {
|
|
1761
1762
|
return formatNewRefToLegacyRef(value);
|
|
1762
1763
|
}
|
|
@@ -1773,10 +1774,10 @@ function formatLegacyRefOnInit(value) {
|
|
|
1773
1774
|
return value;
|
|
1774
1775
|
}
|
|
1775
1776
|
function isLegacyFlowRefValueSchema(value) {
|
|
1776
|
-
return (0,
|
|
1777
|
+
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1777
1778
|
}
|
|
1778
1779
|
function isNewFlowRefValueSchema(value) {
|
|
1779
|
-
return (0,
|
|
1780
|
+
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1780
1781
|
}
|
|
1781
1782
|
function formatLegacyRefToNewRef(value) {
|
|
1782
1783
|
const keyPath = value.content.split(".");
|
|
@@ -1895,7 +1896,7 @@ var import_semi_icons8 = require("@douyinfe/semi-icons");
|
|
|
1895
1896
|
|
|
1896
1897
|
// src/components/batch-outputs/use-list.ts
|
|
1897
1898
|
var import_react16 = require("react");
|
|
1898
|
-
var
|
|
1899
|
+
var import_lodash4 = require("lodash");
|
|
1899
1900
|
var _id2 = 0;
|
|
1900
1901
|
function genId2() {
|
|
1901
1902
|
return _id2++;
|
|
@@ -1906,7 +1907,7 @@ function useList({ value, onChange }) {
|
|
|
1906
1907
|
setList((_prevList) => {
|
|
1907
1908
|
const newKeys = Object.keys(value || {});
|
|
1908
1909
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1909
|
-
const addKeys = (0,
|
|
1910
|
+
const addKeys = (0, import_lodash4.difference)(newKeys, oldKeys);
|
|
1910
1911
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1911
1912
|
id: item.id,
|
|
1912
1913
|
key: item.key,
|
|
@@ -2152,7 +2153,8 @@ function PromptEditor(props) {
|
|
|
2152
2153
|
activeLinePlaceholder,
|
|
2153
2154
|
style,
|
|
2154
2155
|
hasError,
|
|
2155
|
-
children
|
|
2156
|
+
children,
|
|
2157
|
+
disableMarkdownHighlight
|
|
2156
2158
|
} = props || {};
|
|
2157
2159
|
const editorRef = (0, import_react24.useRef)(null);
|
|
2158
2160
|
(0, import_react24.useEffect)(() => {
|
|
@@ -2177,7 +2179,7 @@ function PromptEditor(props) {
|
|
|
2177
2179
|
onChange({ type: "template", content: e.value });
|
|
2178
2180
|
}
|
|
2179
2181
|
}
|
|
2180
|
-
), activeLinePlaceholder && /* @__PURE__ */ import_react24.default.createElement(import_react25.ActiveLinePlaceholder, null, activeLinePlaceholder), /* @__PURE__ */ import_react24.default.createElement(markdown_default, null), /* @__PURE__ */ import_react24.default.createElement(language_support_default, null), /* @__PURE__ */ import_react24.default.createElement(jinja_default, null), children));
|
|
2182
|
+
), activeLinePlaceholder && /* @__PURE__ */ import_react24.default.createElement(import_react25.ActiveLinePlaceholder, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ import_react24.default.createElement(markdown_default, null), /* @__PURE__ */ import_react24.default.createElement(language_support_default, null), /* @__PURE__ */ import_react24.default.createElement(jinja_default, null), children));
|
|
2181
2183
|
}
|
|
2182
2184
|
|
|
2183
2185
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
@@ -2243,7 +2245,7 @@ function VariableTree() {
|
|
|
2243
2245
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2244
2246
|
var import_react_dom = __toESM(require("react-dom"));
|
|
2245
2247
|
var import_react28 = __toESM(require("react"));
|
|
2246
|
-
var
|
|
2248
|
+
var import_lodash5 = require("lodash");
|
|
2247
2249
|
var import_editor7 = require("@flowgram.ai/editor");
|
|
2248
2250
|
var import_semi_ui13 = require("@douyinfe/semi-ui");
|
|
2249
2251
|
var import_semi_icons9 = require("@douyinfe/semi-icons");
|
|
@@ -2311,7 +2313,7 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2311
2313
|
);
|
|
2312
2314
|
return;
|
|
2313
2315
|
}
|
|
2314
|
-
const rootField = (0,
|
|
2316
|
+
const rootField = (0, import_lodash5.last)(v.parentFields);
|
|
2315
2317
|
const rootTitle = /* @__PURE__ */ import_react28.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2316
2318
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2317
2319
|
this.renderReact(
|
|
@@ -2345,7 +2347,7 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2345
2347
|
return dom;
|
|
2346
2348
|
}
|
|
2347
2349
|
eq(other) {
|
|
2348
|
-
return (0,
|
|
2350
|
+
return (0, import_lodash5.isEqual)(this.keyPath, other.keyPath);
|
|
2349
2351
|
}
|
|
2350
2352
|
ignoreEvent() {
|
|
2351
2353
|
return false;
|
|
@@ -2407,7 +2409,7 @@ var import_react33 = require("@coze-editor/editor/react");
|
|
|
2407
2409
|
|
|
2408
2410
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2409
2411
|
var import_react31 = __toESM(require("react"));
|
|
2410
|
-
var
|
|
2412
|
+
var import_lodash6 = require("lodash");
|
|
2411
2413
|
var import_editor8 = require("@flowgram.ai/editor");
|
|
2412
2414
|
var import_semi_ui14 = require("@douyinfe/semi-ui");
|
|
2413
2415
|
function InputsPicker({
|
|
@@ -2442,7 +2444,7 @@ function InputsPicker({
|
|
|
2442
2444
|
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2443
2445
|
return {
|
|
2444
2446
|
key,
|
|
2445
|
-
label: (0,
|
|
2447
|
+
label: (0, import_lodash6.last)(keyPath),
|
|
2446
2448
|
value: key,
|
|
2447
2449
|
children
|
|
2448
2450
|
};
|
|
@@ -2904,7 +2906,7 @@ function VariableTree2() {
|
|
|
2904
2906
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2905
2907
|
var import_react39 = __toESM(require("react"));
|
|
2906
2908
|
var import_client = require("react-dom/client");
|
|
2907
|
-
var
|
|
2909
|
+
var import_lodash7 = require("lodash");
|
|
2908
2910
|
var import_editor10 = require("@flowgram.ai/editor");
|
|
2909
2911
|
var import_semi_ui18 = require("@douyinfe/semi-ui");
|
|
2910
2912
|
var import_semi_icons10 = require("@douyinfe/semi-icons");
|
|
@@ -2969,7 +2971,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2969
2971
|
);
|
|
2970
2972
|
return;
|
|
2971
2973
|
}
|
|
2972
|
-
const rootField = (0,
|
|
2974
|
+
const rootField = (0, import_lodash7.last)(v.parentFields);
|
|
2973
2975
|
const rootTitle = /* @__PURE__ */ import_react39.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2974
2976
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2975
2977
|
this.root.render(
|
|
@@ -3003,7 +3005,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
3003
3005
|
return dom;
|
|
3004
3006
|
}
|
|
3005
3007
|
eq(other) {
|
|
3006
|
-
return (0,
|
|
3008
|
+
return (0, import_lodash7.isEqual)(this.keyPath, other.keyPath);
|
|
3007
3009
|
}
|
|
3008
3010
|
ignoreEvent() {
|
|
3009
3011
|
return false;
|
|
@@ -3154,7 +3156,7 @@ var provideBatchOutputsEffect = (0, import_editor12.createEffectFromVariableProv
|
|
|
3154
3156
|
});
|
|
3155
3157
|
|
|
3156
3158
|
// src/effects/auto-rename-ref/index.ts
|
|
3157
|
-
var
|
|
3159
|
+
var import_lodash8 = require("lodash");
|
|
3158
3160
|
var import_editor13 = require("@flowgram.ai/editor");
|
|
3159
3161
|
var autoRenameRefEffect = [
|
|
3160
3162
|
{
|
|
@@ -3172,9 +3174,30 @@ var autoRenameRefEffect = [
|
|
|
3172
3174
|
after.key
|
|
3173
3175
|
];
|
|
3174
3176
|
traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
|
|
3175
|
-
if (
|
|
3176
|
-
|
|
3177
|
-
|
|
3177
|
+
if (_v.type === "ref") {
|
|
3178
|
+
if (isKeyPathMatch(_v.content, beforeKeyPath)) {
|
|
3179
|
+
_v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
|
|
3180
|
+
form.setValueIn(_drilldownName, _v);
|
|
3181
|
+
}
|
|
3182
|
+
} else if (_v.type === "template") {
|
|
3183
|
+
const templateKeyPaths = getTemplateKeyPaths(_v);
|
|
3184
|
+
let hasMatch = false;
|
|
3185
|
+
templateKeyPaths.forEach((_keyPath) => {
|
|
3186
|
+
if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
|
|
3187
|
+
hasMatch = true;
|
|
3188
|
+
const nextKeyPath = [
|
|
3189
|
+
...afterKeyPath,
|
|
3190
|
+
...(_keyPath || [])?.slice(beforeKeyPath.length)
|
|
3191
|
+
];
|
|
3192
|
+
_v.content = _v.content?.replace(
|
|
3193
|
+
`{{${_keyPath.join(".")}}`,
|
|
3194
|
+
`{{${nextKeyPath.join(".")}}`
|
|
3195
|
+
);
|
|
3196
|
+
}
|
|
3197
|
+
});
|
|
3198
|
+
if (hasMatch) {
|
|
3199
|
+
form.setValueIn(_drilldownName, { ..._v });
|
|
3200
|
+
}
|
|
3178
3201
|
}
|
|
3179
3202
|
});
|
|
3180
3203
|
});
|
|
@@ -3184,24 +3207,37 @@ var autoRenameRefEffect = [
|
|
|
3184
3207
|
}
|
|
3185
3208
|
}
|
|
3186
3209
|
];
|
|
3187
|
-
function
|
|
3188
|
-
return targetKeyPath.every((_key, index) => _key ===
|
|
3210
|
+
function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
3211
|
+
return targetKeyPath.every((_key, index) => _key === keyPath[index]);
|
|
3212
|
+
}
|
|
3213
|
+
function getTemplateKeyPaths(value) {
|
|
3214
|
+
const keyPathReg = /{{(.*?)}}/g;
|
|
3215
|
+
return (0, import_lodash8.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3216
|
+
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3217
|
+
);
|
|
3189
3218
|
}
|
|
3190
3219
|
function isRef(value) {
|
|
3191
3220
|
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3192
3221
|
}
|
|
3222
|
+
function isTemplate(value) {
|
|
3223
|
+
return value?.type === "template" && typeof value?.content === "string";
|
|
3224
|
+
}
|
|
3193
3225
|
function traverseRef(name, value, cb) {
|
|
3194
|
-
if ((0,
|
|
3226
|
+
if ((0, import_lodash8.isObject)(value)) {
|
|
3195
3227
|
if (isRef(value)) {
|
|
3196
3228
|
cb(name, value);
|
|
3197
3229
|
return;
|
|
3198
3230
|
}
|
|
3231
|
+
if (isTemplate(value)) {
|
|
3232
|
+
cb(name, value);
|
|
3233
|
+
return;
|
|
3234
|
+
}
|
|
3199
3235
|
Object.entries(value).forEach(([_key, _value]) => {
|
|
3200
3236
|
traverseRef(`${name}.${_key}`, _value, cb);
|
|
3201
3237
|
});
|
|
3202
3238
|
return;
|
|
3203
3239
|
}
|
|
3204
|
-
if ((0,
|
|
3240
|
+
if ((0, import_lodash8.isArray)(value)) {
|
|
3205
3241
|
value.forEach((_value, idx) => {
|
|
3206
3242
|
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3207
3243
|
});
|