@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/esm/index.js
CHANGED
|
@@ -943,6 +943,7 @@ var ConstantInputWrapper = styled2.div`
|
|
|
943
943
|
|
|
944
944
|
// src/components/json-schema-editor/hooks.tsx
|
|
945
945
|
import { useEffect, useMemo as useMemo3, useRef, useState } from "react";
|
|
946
|
+
import { omit } from "lodash";
|
|
946
947
|
var _id = 0;
|
|
947
948
|
function genId() {
|
|
948
949
|
return _id++;
|
|
@@ -1015,7 +1016,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1015
1016
|
if (!_property.name) {
|
|
1016
1017
|
continue;
|
|
1017
1018
|
}
|
|
1018
|
-
nextProperties[_property.name] = _property;
|
|
1019
|
+
nextProperties[_property.name] = omit(_property, ["key", "name", "isPropertyRequired"]);
|
|
1019
1020
|
if (_property.isPropertyRequired) {
|
|
1020
1021
|
nextRequired.push(_property.name);
|
|
1021
1022
|
}
|
|
@@ -2092,7 +2093,8 @@ function PromptEditor(props) {
|
|
|
2092
2093
|
activeLinePlaceholder,
|
|
2093
2094
|
style,
|
|
2094
2095
|
hasError,
|
|
2095
|
-
children
|
|
2096
|
+
children,
|
|
2097
|
+
disableMarkdownHighlight
|
|
2096
2098
|
} = props || {};
|
|
2097
2099
|
const editorRef = useRef3(null);
|
|
2098
2100
|
useEffect4(() => {
|
|
@@ -2117,7 +2119,7 @@ function PromptEditor(props) {
|
|
|
2117
2119
|
onChange({ type: "template", content: e.value });
|
|
2118
2120
|
}
|
|
2119
2121
|
}
|
|
2120
|
-
), activeLinePlaceholder && /* @__PURE__ */ React15.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder), /* @__PURE__ */ React15.createElement(markdown_default, null), /* @__PURE__ */ React15.createElement(language_support_default, null), /* @__PURE__ */ React15.createElement(jinja_default, null), children));
|
|
2122
|
+
), activeLinePlaceholder && /* @__PURE__ */ React15.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ React15.createElement(markdown_default, null), /* @__PURE__ */ React15.createElement(language_support_default, null), /* @__PURE__ */ React15.createElement(jinja_default, null), children));
|
|
2121
2123
|
}
|
|
2122
2124
|
|
|
2123
2125
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
@@ -3144,7 +3146,7 @@ var provideBatchOutputsEffect = createEffectFromVariableProvider2({
|
|
|
3144
3146
|
});
|
|
3145
3147
|
|
|
3146
3148
|
// src/effects/auto-rename-ref/index.ts
|
|
3147
|
-
import { isArray, isObject as isObject2 } from "lodash";
|
|
3149
|
+
import { isArray, isObject as isObject2, uniq } from "lodash";
|
|
3148
3150
|
import {
|
|
3149
3151
|
DataEvent,
|
|
3150
3152
|
VariableFieldKeyRenameService
|
|
@@ -3165,9 +3167,30 @@ var autoRenameRefEffect = [
|
|
|
3165
3167
|
after.key
|
|
3166
3168
|
];
|
|
3167
3169
|
traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
|
|
3168
|
-
if (
|
|
3169
|
-
|
|
3170
|
-
|
|
3170
|
+
if (_v.type === "ref") {
|
|
3171
|
+
if (isKeyPathMatch(_v.content, beforeKeyPath)) {
|
|
3172
|
+
_v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
|
|
3173
|
+
form.setValueIn(_drilldownName, _v);
|
|
3174
|
+
}
|
|
3175
|
+
} else if (_v.type === "template") {
|
|
3176
|
+
const templateKeyPaths = getTemplateKeyPaths(_v);
|
|
3177
|
+
let hasMatch = false;
|
|
3178
|
+
templateKeyPaths.forEach((_keyPath) => {
|
|
3179
|
+
if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
|
|
3180
|
+
hasMatch = true;
|
|
3181
|
+
const nextKeyPath = [
|
|
3182
|
+
...afterKeyPath,
|
|
3183
|
+
...(_keyPath || [])?.slice(beforeKeyPath.length)
|
|
3184
|
+
];
|
|
3185
|
+
_v.content = _v.content?.replace(
|
|
3186
|
+
`{{${_keyPath.join(".")}}`,
|
|
3187
|
+
`{{${nextKeyPath.join(".")}}`
|
|
3188
|
+
);
|
|
3189
|
+
}
|
|
3190
|
+
});
|
|
3191
|
+
if (hasMatch) {
|
|
3192
|
+
form.setValueIn(_drilldownName, { ..._v });
|
|
3193
|
+
}
|
|
3171
3194
|
}
|
|
3172
3195
|
});
|
|
3173
3196
|
});
|
|
@@ -3177,18 +3200,31 @@ var autoRenameRefEffect = [
|
|
|
3177
3200
|
}
|
|
3178
3201
|
}
|
|
3179
3202
|
];
|
|
3180
|
-
function
|
|
3181
|
-
return targetKeyPath.every((_key, index) => _key ===
|
|
3203
|
+
function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
3204
|
+
return targetKeyPath.every((_key, index) => _key === keyPath[index]);
|
|
3205
|
+
}
|
|
3206
|
+
function getTemplateKeyPaths(value) {
|
|
3207
|
+
const keyPathReg = /{{(.*?)}}/g;
|
|
3208
|
+
return uniq(value.content?.match(keyPathReg) || []).map(
|
|
3209
|
+
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3210
|
+
);
|
|
3182
3211
|
}
|
|
3183
3212
|
function isRef(value) {
|
|
3184
3213
|
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3185
3214
|
}
|
|
3215
|
+
function isTemplate(value) {
|
|
3216
|
+
return value?.type === "template" && typeof value?.content === "string";
|
|
3217
|
+
}
|
|
3186
3218
|
function traverseRef(name, value, cb) {
|
|
3187
3219
|
if (isObject2(value)) {
|
|
3188
3220
|
if (isRef(value)) {
|
|
3189
3221
|
cb(name, value);
|
|
3190
3222
|
return;
|
|
3191
3223
|
}
|
|
3224
|
+
if (isTemplate(value)) {
|
|
3225
|
+
cb(name, value);
|
|
3226
|
+
return;
|
|
3227
|
+
}
|
|
3192
3228
|
Object.entries(value).forEach(([_key, _value]) => {
|
|
3193
3229
|
traverseRef(`${name}.${_key}`, _value, cb);
|
|
3194
3230
|
});
|