@xbeeant/form-engine-designer 0.0.1
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/README.md +69 -0
- package/dist/es/Canvas.js +636 -0
- package/dist/es/Canvas.js.map +1 -0
- package/dist/es/Designer.js +162 -0
- package/dist/es/Designer.js.map +1 -0
- package/dist/es/DesignerContext.js +97 -0
- package/dist/es/DesignerContext.js.map +1 -0
- package/dist/es/Palette.js +148 -0
- package/dist/es/Palette.js.map +1 -0
- package/dist/es/PropertyPanel.js +294 -0
- package/dist/es/PropertyPanel.js.map +1 -0
- package/dist/es/ResizablePanel.js +103 -0
- package/dist/es/ResizablePanel.js.map +1 -0
- package/dist/es/catalog.js +514 -0
- package/dist/es/catalog.js.map +1 -0
- package/dist/es/form-engine-designer.css +1 -0
- package/dist/es/index.js +20 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/property/basic-property.js +115 -0
- package/dist/es/property/basic-property.js.map +1 -0
- package/dist/es/react/src/components/FormController.js +154 -0
- package/dist/es/react/src/components/FormController.js.map +1 -0
- package/dist/es/react/src/components/NexusField.js +99 -0
- package/dist/es/react/src/components/NexusField.js.map +1 -0
- package/dist/es/react/src/components/NexusForm.js +121 -0
- package/dist/es/react/src/components/NexusForm.js.map +1 -0
- package/dist/es/react/src/components/NexusFormProvider.js +19 -0
- package/dist/es/react/src/components/NexusFormProvider.js.map +1 -0
- package/dist/es/react/src/components/NexusLayout.js +49 -0
- package/dist/es/react/src/components/NexusLayout.js.map +1 -0
- package/dist/es/react/src/components/NexusObject.js +65 -0
- package/dist/es/react/src/components/NexusObject.js.map +1 -0
- package/dist/es/react/src/contexts/FieldInheritContext.js +6 -0
- package/dist/es/react/src/contexts/FieldInheritContext.js.map +1 -0
- package/dist/es/react/src/contexts/GridContext.js +6 -0
- package/dist/es/react/src/contexts/GridContext.js.map +1 -0
- package/dist/es/react/src/contexts/LayoutConfigContext.js +6 -0
- package/dist/es/react/src/contexts/LayoutConfigContext.js.map +1 -0
- package/dist/es/react/src/contexts/NexusContext.js +13 -0
- package/dist/es/react/src/contexts/NexusContext.js.map +1 -0
- package/dist/es/react/src/hooks/useForm.js +10 -0
- package/dist/es/react/src/hooks/useForm.js.map +1 -0
- package/dist/es/react/src/utils/renderTreeNode.js +18 -0
- package/dist/es/react/src/utils/renderTreeNode.js.map +1 -0
- package/dist/es/react/src/utils/resolveColSpan.js +10 -0
- package/dist/es/react/src/utils/resolveColSpan.js.map +1 -0
- package/dist/es/schemaUtils.js +286 -0
- package/dist/es/schemaUtils.js.map +1 -0
- package/dist/es/schemaUtils.test.js +188 -0
- package/dist/es/schemaUtils.test.js.map +1 -0
- package/dist/es/types.js +2 -0
- package/dist/es/types.js.map +1 -0
- package/dist/es/vite-env.d.js +2 -0
- package/dist/es/vite-env.d.js.map +1 -0
- package/dist/es/widgets/BindEditor.js +67 -0
- package/dist/es/widgets/BindEditor.js.map +1 -0
- package/dist/es/widgets/CodeEditor.js +84 -0
- package/dist/es/widgets/CodeEditor.js.map +1 -0
- package/dist/es/widgets/DefaultEditor.js +55 -0
- package/dist/es/widgets/DefaultEditor.js.map +1 -0
- package/dist/es/widgets/DependenciesEditor.js +36 -0
- package/dist/es/widgets/DependenciesEditor.js.map +1 -0
- package/dist/es/widgets/EnumEditor.js +49 -0
- package/dist/es/widgets/EnumEditor.js.map +1 -0
- package/dist/es/widgets/ExpressionBuilder.js +367 -0
- package/dist/es/widgets/ExpressionBuilder.js.map +1 -0
- package/dist/es/widgets/ExpressionSwitch.js +47 -0
- package/dist/es/widgets/ExpressionSwitch.js.map +1 -0
- package/dist/es/widgets/OptionsEditor.js +102 -0
- package/dist/es/widgets/OptionsEditor.js.map +1 -0
- package/dist/es/widgets/ReactionsEditor.js +401 -0
- package/dist/es/widgets/ReactionsEditor.js.map +1 -0
- package/dist/es/widgets/RemoteDataEditor.js +314 -0
- package/dist/es/widgets/RemoteDataEditor.js.map +1 -0
- package/dist/es/widgets/ValidateEditor.js +118 -0
- package/dist/es/widgets/ValidateEditor.js.map +1 -0
- package/dist/es/widgets/expressionModel.js +340 -0
- package/dist/es/widgets/expressionModel.js.map +1 -0
- package/dist/es/widgets/expressionModel.test.js +193 -0
- package/dist/es/widgets/expressionModel.test.js.map +1 -0
- package/dist/es/widgets/index.js +57 -0
- package/dist/es/widgets/index.js.map +1 -0
- package/dist/es/widgets/reactionsModel.js +107 -0
- package/dist/es/widgets/reactionsModel.js.map +1 -0
- package/dist/es/widgets/useFormDataFields.js +16 -0
- package/dist/es/widgets/useFormDataFields.js.map +1 -0
- package/package.json +62 -0
- package/src/Canvas.tsx +1111 -0
- package/src/Designer.css +206 -0
- package/src/Designer.tsx +254 -0
- package/src/DesignerContext.tsx +192 -0
- package/src/Palette.tsx +261 -0
- package/src/PropertyPanel.tsx +486 -0
- package/src/ResizablePanel.tsx +210 -0
- package/src/catalog.ts +526 -0
- package/src/index.ts +25 -0
- package/src/property/basic-property.ts +126 -0
- package/src/schemaUtils.test.ts +261 -0
- package/src/schemaUtils.ts +627 -0
- package/src/types.ts +38 -0
- package/src/vite-env.d.ts +1 -0
- package/src/widgets/BindEditor.tsx +105 -0
- package/src/widgets/CodeEditor.tsx +114 -0
- package/src/widgets/DefaultEditor.tsx +73 -0
- package/src/widgets/DependenciesEditor.tsx +56 -0
- package/src/widgets/EnumEditor.tsx +66 -0
- package/src/widgets/ExpressionBuilder.tsx +509 -0
- package/src/widgets/ExpressionSwitch.tsx +62 -0
- package/src/widgets/OptionsEditor.tsx +141 -0
- package/src/widgets/ReactionsEditor.tsx +532 -0
- package/src/widgets/RemoteDataEditor.tsx +382 -0
- package/src/widgets/ValidateEditor.tsx +162 -0
- package/src/widgets/expressionModel.test.ts +262 -0
- package/src/widgets/expressionModel.ts +573 -0
- package/src/widgets/index.ts +45 -0
- package/src/widgets/reactionsModel.ts +190 -0
- package/src/widgets/useFormDataFields.ts +21 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { bindEditorWidget as r } from "./BindEditor.js";
|
|
2
|
+
import { codeEditorWidget as e } from "./CodeEditor.js";
|
|
3
|
+
import { defaultEditorWidget as o } from "./DefaultEditor.js";
|
|
4
|
+
import { dependenciesEditorWidget as t } from "./DependenciesEditor.js";
|
|
5
|
+
import { enumNamesEditorWidget as i, enumEditorWidget as p } from "./EnumEditor.js";
|
|
6
|
+
import { expressionSwitchWidget as d } from "./ExpressionSwitch.js";
|
|
7
|
+
import { optionsEditorWidget as m } from "./OptionsEditor.js";
|
|
8
|
+
import { reactionsEditorWidget as a } from "./ReactionsEditor.js";
|
|
9
|
+
import { remoteDataEditorWidget as n } from "./RemoteDataEditor.js";
|
|
10
|
+
import { validateEditorWidget as s } from "./ValidateEditor.js";
|
|
11
|
+
import { ExpressionBuilder as S } from "./ExpressionBuilder.js";
|
|
12
|
+
import { NO_RIGHT_OPERATORS as C, OPERATOR_OPTIONS as I, RIGHT_MODE_OPTIONS as N, buildExpression as V, createCondition as _, formatRightValue as P, genConditionId as h, isConditionComplete as B, parseExpression as v, parseRightValue as A, parseSimpleVariable as F, parseVariable as G, stripBraces as H, variableToString as w } from "./expressionModel.js";
|
|
13
|
+
import { useFormDataFields as j } from "./useFormDataFields.js";
|
|
14
|
+
const x = {
|
|
15
|
+
propertyExpr: d,
|
|
16
|
+
propertyBind: r,
|
|
17
|
+
propertyValidate: s,
|
|
18
|
+
propertyDependencies: t,
|
|
19
|
+
propertyReactions: a,
|
|
20
|
+
propertyEnum: p,
|
|
21
|
+
propertyEnumNames: i,
|
|
22
|
+
propertyOptions: m,
|
|
23
|
+
propertyRemoteData: n,
|
|
24
|
+
propertyCodeEditor: e,
|
|
25
|
+
propertyDefault: o
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
S as ExpressionBuilder,
|
|
29
|
+
C as NO_RIGHT_OPERATORS,
|
|
30
|
+
I as OPERATOR_OPTIONS,
|
|
31
|
+
N as RIGHT_MODE_OPTIONS,
|
|
32
|
+
r as bindEditorWidget,
|
|
33
|
+
V as buildExpression,
|
|
34
|
+
e as codeEditorWidget,
|
|
35
|
+
_ as createCondition,
|
|
36
|
+
o as defaultEditorWidget,
|
|
37
|
+
t as dependenciesEditorWidget,
|
|
38
|
+
p as enumEditorWidget,
|
|
39
|
+
i as enumNamesEditorWidget,
|
|
40
|
+
d as expressionSwitchWidget,
|
|
41
|
+
P as formatRightValue,
|
|
42
|
+
h as genConditionId,
|
|
43
|
+
B as isConditionComplete,
|
|
44
|
+
m as optionsEditorWidget,
|
|
45
|
+
v as parseExpression,
|
|
46
|
+
A as parseRightValue,
|
|
47
|
+
F as parseSimpleVariable,
|
|
48
|
+
G as parseVariable,
|
|
49
|
+
x as propertyWidgets,
|
|
50
|
+
a as reactionsEditorWidget,
|
|
51
|
+
n as remoteDataEditorWidget,
|
|
52
|
+
H as stripBraces,
|
|
53
|
+
j as useFormDataFields,
|
|
54
|
+
s as validateEditorWidget,
|
|
55
|
+
w as variableToString
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/widgets/index.ts"],"sourcesContent":["// ============================================================================\n// @xbeeant/form-engine-designer — 属性面板专用 Widget 注册\n// ============================================================================\n\nimport type { ReactNode } from 'react';\nimport { bindEditorWidget } from './BindEditor';\nimport { codeEditorWidget } from './CodeEditor';\nimport { defaultEditorWidget } from './DefaultEditor';\nimport { dependenciesEditorWidget } from './DependenciesEditor';\nimport { enumEditorWidget, enumNamesEditorWidget } from './EnumEditor';\nimport { expressionSwitchWidget } from './ExpressionSwitch';\nimport { optionsEditorWidget } from './OptionsEditor';\nimport { reactionsEditorWidget } from './ReactionsEditor';\nimport { remoteDataEditorWidget } from './RemoteDataEditor';\nimport { validateEditorWidget } from './ValidateEditor';\n\n/** 属性面板专用的 widget 集合,注册到属性表单的引擎实例中 */\nexport const propertyWidgets: Record<string, (props: any) => ReactNode> = {\n propertyExpr: expressionSwitchWidget,\n propertyBind: bindEditorWidget,\n propertyValidate: validateEditorWidget,\n propertyDependencies: dependenciesEditorWidget,\n propertyReactions: reactionsEditorWidget,\n propertyEnum: enumEditorWidget,\n propertyEnumNames: enumNamesEditorWidget,\n propertyOptions: optionsEditorWidget,\n propertyRemoteData: remoteDataEditorWidget,\n propertyCodeEditor: codeEditorWidget,\n propertyDefault: defaultEditorWidget,\n};\n\nexport { bindEditorWidget } from './BindEditor';\nexport { codeEditorWidget } from './CodeEditor';\nexport { defaultEditorWidget } from './DefaultEditor';\nexport { dependenciesEditorWidget } from './DependenciesEditor';\nexport { enumEditorWidget, enumNamesEditorWidget } from './EnumEditor';\nexport type { ExpressionBuilderProps } from './ExpressionBuilder';\nexport { ExpressionBuilder } from './ExpressionBuilder';\nexport { expressionSwitchWidget } from './ExpressionSwitch';\nexport * from './expressionModel';\nexport { optionsEditorWidget } from './OptionsEditor';\nexport { reactionsEditorWidget } from './ReactionsEditor';\nexport { remoteDataEditorWidget } from './RemoteDataEditor';\nexport { useFormDataFields } from './useFormDataFields';\nexport { validateEditorWidget } from './ValidateEditor';\n"],"names":["propertyWidgets","expressionSwitchWidget","bindEditorWidget","validateEditorWidget","dependenciesEditorWidget","reactionsEditorWidget","enumEditorWidget","enumNamesEditorWidget","optionsEditorWidget","remoteDataEditorWidget","codeEditorWidget","defaultEditorWidget"],"mappings":";;;;;;;;;;;;;AAiBO,MAAMA,IAA6D;AAAA,EACxE,cAAcC;AAAA,EACd,cAAcC;AAAA,EACd,kBAAkBC;AAAA,EAClB,sBAAsBC;AAAA,EACtB,mBAAmBC;AAAA,EACnB,cAAcC;AAAA,EACd,mBAAmBC;AAAA,EACnB,iBAAiBC;AAAA,EACjB,oBAAoBC;AAAA,EACpB,oBAAoBC;AAAA,EACpB,iBAAiBC;AACnB;"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const v = /* @__PURE__ */ new Set([
|
|
2
|
+
"visible",
|
|
3
|
+
"hidden",
|
|
4
|
+
"disabled",
|
|
5
|
+
"readOnly",
|
|
6
|
+
"required",
|
|
7
|
+
"loading"
|
|
8
|
+
]), f = "__props", b = [
|
|
9
|
+
{ label: "计算值(value)", value: "value" },
|
|
10
|
+
{ label: "显示(visible)", value: "visible" },
|
|
11
|
+
{ label: "隐藏(hidden)", value: "hidden" },
|
|
12
|
+
{ label: "禁用(disabled)", value: "disabled" },
|
|
13
|
+
{ label: "只读(readOnly)", value: "readOnly" },
|
|
14
|
+
{ label: "必填(required)", value: "required" },
|
|
15
|
+
{ label: "加载中(loading)", value: "loading" },
|
|
16
|
+
{ label: "标题(title)", value: "title" },
|
|
17
|
+
{ label: "描述(description)", value: "description" },
|
|
18
|
+
{ label: "组件属性(props.*)", value: f }
|
|
19
|
+
];
|
|
20
|
+
function c() {
|
|
21
|
+
return Math.random().toString(36).slice(2, 8);
|
|
22
|
+
}
|
|
23
|
+
function w(e) {
|
|
24
|
+
const t = e.trim();
|
|
25
|
+
return t === "true" ? !0 : t === "false" ? !1 : /^-?\d+(\.\d+)?$/.test(t) ? Number(t) : e;
|
|
26
|
+
}
|
|
27
|
+
function d(e) {
|
|
28
|
+
const t = {};
|
|
29
|
+
for (const l of e) {
|
|
30
|
+
const i = l.key.trim();
|
|
31
|
+
i && (l.value === void 0 || l.value === "" || (t[i] = l.value));
|
|
32
|
+
}
|
|
33
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
34
|
+
}
|
|
35
|
+
function s(e) {
|
|
36
|
+
return e ? Object.entries(e).map(([t, l]) => ({ key: t, value: l })) : [];
|
|
37
|
+
}
|
|
38
|
+
function h(e) {
|
|
39
|
+
const t = e.trim();
|
|
40
|
+
if (t)
|
|
41
|
+
try {
|
|
42
|
+
const l = JSON.parse(t);
|
|
43
|
+
if (l && typeof l == "object" && !Array.isArray(l))
|
|
44
|
+
return l;
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function u(e) {
|
|
49
|
+
if (!e || Object.keys(e).length === 0)
|
|
50
|
+
return "";
|
|
51
|
+
try {
|
|
52
|
+
return JSON.stringify(e, null, 2);
|
|
53
|
+
} catch {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function p(e) {
|
|
58
|
+
return {
|
|
59
|
+
id: c(),
|
|
60
|
+
deps: (e.dependencies ?? []).join(", "),
|
|
61
|
+
when: e.when ?? "",
|
|
62
|
+
fulfillEnabled: !!e.fulfill,
|
|
63
|
+
fulfillRows: s(e.fulfill?.state),
|
|
64
|
+
fulfillSchema: u(e.fulfill?.schema),
|
|
65
|
+
otherwiseEnabled: !!e.otherwise,
|
|
66
|
+
otherwiseRows: s(e.otherwise?.state),
|
|
67
|
+
otherwiseSchema: u(e.otherwise?.schema)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function a(e, t) {
|
|
71
|
+
if (!(t === "fulfill" ? e.fulfillEnabled : e.otherwiseEnabled))
|
|
72
|
+
return;
|
|
73
|
+
const i = t === "fulfill" ? e.fulfillRows : e.otherwiseRows, o = t === "fulfill" ? e.fulfillSchema : e.otherwiseSchema, n = d(i), r = h(o);
|
|
74
|
+
if (!(n === void 0 && r === void 0))
|
|
75
|
+
return {
|
|
76
|
+
...n !== void 0 ? { state: n } : {},
|
|
77
|
+
...r !== void 0 ? { schema: r } : {}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function m(e) {
|
|
81
|
+
const t = {
|
|
82
|
+
dependencies: e.deps.split(",").map((n) => n.trim()).filter(Boolean)
|
|
83
|
+
}, l = e.when.trim();
|
|
84
|
+
l && (t.when = l);
|
|
85
|
+
const i = a(e, "fulfill"), o = a(e, "otherwise");
|
|
86
|
+
return i && (t.fulfill = i), o && (t.otherwise = o), t;
|
|
87
|
+
}
|
|
88
|
+
function y(e) {
|
|
89
|
+
return Array.isArray(e) ? e.filter(
|
|
90
|
+
(t) => !!t && t._autoExpr !== !0
|
|
91
|
+
) : [];
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
v as BOOLEAN_STATE_KEYS,
|
|
95
|
+
f as PROPS_KEY,
|
|
96
|
+
b as STATE_KEY_OPTIONS,
|
|
97
|
+
m as cardToReaction,
|
|
98
|
+
c as genId,
|
|
99
|
+
w as parsePatchValue,
|
|
100
|
+
h as parseSchemaText,
|
|
101
|
+
p as reactionToCard,
|
|
102
|
+
d as rowsToState,
|
|
103
|
+
u as schemaToText,
|
|
104
|
+
s as stateToRows,
|
|
105
|
+
y as toManualReactions
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=reactionsModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactionsModel.js","sources":["../../../src/widgets/reactionsModel.ts"],"sourcesContent":["// ============================================================================\n// reactionsModel — ReactionsEditor 的纯数据模型(无 React / DOM 依赖)\n// Reaction ↔ 可编辑卡片(Card)之间的双向转换,以及补丁值解析\n// ============================================================================\n\nimport type { Reaction } from '@xbeeant/form-engine';\n\nexport const BOOLEAN_STATE_KEYS = new Set([\n 'visible',\n 'hidden',\n 'disabled',\n 'readOnly',\n 'required',\n 'loading',\n]);\n\nexport const PROPS_KEY = '__props';\n\nexport const STATE_KEY_OPTIONS: Array<{ label: string; value: string }> = [\n { label: '计算值(value)', value: 'value' },\n { label: '显示(visible)', value: 'visible' },\n { label: '隐藏(hidden)', value: 'hidden' },\n { label: '禁用(disabled)', value: 'disabled' },\n { label: '只读(readOnly)', value: 'readOnly' },\n { label: '必填(required)', value: 'required' },\n { label: '加载中(loading)', value: 'loading' },\n { label: '标题(title)', value: 'title' },\n { label: '描述(description)', value: 'description' },\n { label: '组件属性(props.*)', value: PROPS_KEY },\n];\n\nexport interface PatchRow {\n key: string;\n value: unknown;\n}\n\nexport interface Card {\n id: string;\n deps: string;\n when: string;\n fulfillEnabled: boolean;\n fulfillRows: PatchRow[];\n fulfillSchema: string;\n otherwiseEnabled: boolean;\n otherwiseRows: PatchRow[];\n otherwiseSchema: string;\n}\n\nexport function genId(): string {\n return Math.random().toString(36).slice(2, 8);\n}\n\n/** 文本 → 补丁值:true/false 转布尔、数字转 number,其余(含 {{ }} 表达式)保留字符串 */\nexport function parsePatchValue(text: string): unknown {\n const t = text.trim();\n if (t === 'true') {\n return true;\n }\n if (t === 'false') {\n return false;\n }\n if (/^-?\\d+(\\.\\d+)?$/.test(t)) {\n return Number(t);\n }\n return text;\n}\n\nexport function rowsToState(\n rows: PatchRow[],\n): Record<string, unknown> | undefined {\n const state: Record<string, unknown> = {};\n for (const r of rows) {\n const key = r.key.trim();\n if (!key) {\n continue;\n }\n if (r.value === undefined || r.value === '') {\n continue;\n }\n state[key] = r.value;\n }\n return Object.keys(state).length > 0 ? state : undefined;\n}\n\nexport function stateToRows(state: object | undefined): PatchRow[] {\n return state\n ? Object.entries(state).map(([key, value]) => ({ key, value }))\n : [];\n}\n\nexport function parseSchemaText(\n text: string,\n): Record<string, unknown> | undefined {\n const t = text.trim();\n if (!t) {\n return undefined;\n }\n try {\n const parsed = JSON.parse(t) as unknown;\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n return parsed as Record<string, unknown>;\n }\n } catch {\n // 非法 JSON:忽略本次提交,等待用户修正\n }\n return undefined;\n}\n\nexport function schemaToText(\n schema: Record<string, unknown> | undefined,\n): string {\n if (!schema || Object.keys(schema).length === 0) {\n return '';\n }\n try {\n return JSON.stringify(schema, null, 2);\n } catch {\n return '';\n }\n}\n\nexport function reactionToCard(r: Reaction): Card {\n return {\n id: genId(),\n deps: (r.dependencies ?? []).join(', '),\n when: r.when ?? '',\n fulfillEnabled: !!r.fulfill,\n fulfillRows: stateToRows(r.fulfill?.state),\n fulfillSchema: schemaToText(r.fulfill?.schema),\n otherwiseEnabled: !!r.otherwise,\n otherwiseRows: stateToRows(r.otherwise?.state),\n otherwiseSchema: schemaToText(r.otherwise?.schema),\n };\n}\n\nfunction buildBranch(\n card: Card,\n branch: 'fulfill' | 'otherwise',\n):\n | { state?: Record<string, unknown>; schema?: Record<string, unknown> }\n | undefined {\n const enabled =\n branch === 'fulfill' ? card.fulfillEnabled : card.otherwiseEnabled;\n if (!enabled) {\n return undefined;\n }\n const rows = branch === 'fulfill' ? card.fulfillRows : card.otherwiseRows;\n const schemaText =\n branch === 'fulfill' ? card.fulfillSchema : card.otherwiseSchema;\n const state = rowsToState(rows);\n const schema = parseSchemaText(schemaText);\n if (state === undefined && schema === undefined) {\n return undefined;\n }\n return {\n ...(state !== undefined ? { state } : {}),\n ...(schema !== undefined ? { schema } : {}),\n };\n}\n\nexport function cardToReaction(card: Card): Reaction {\n const reaction: Reaction = {\n dependencies: card.deps\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean),\n };\n const when = card.when.trim();\n if (when) {\n reaction.when = when;\n }\n const fulfill = buildBranch(card, 'fulfill');\n const otherwise = buildBranch(card, 'otherwise');\n if (fulfill) {\n reaction.fulfill = fulfill;\n }\n if (otherwise) {\n reaction.otherwise = otherwise;\n }\n return reaction;\n}\n\nexport function toManualReactions(value: unknown): Reaction[] {\n if (!Array.isArray(value)) {\n return [];\n }\n return value.filter(\n (r): r is Reaction => !!r && (r as Reaction)._autoExpr !== true,\n );\n}\n"],"names":["BOOLEAN_STATE_KEYS","PROPS_KEY","STATE_KEY_OPTIONS","genId","parsePatchValue","text","rowsToState","rows","state","r","key","stateToRows","value","parseSchemaText","parsed","schemaToText","schema","reactionToCard","buildBranch","card","branch","schemaText","cardToReaction","reaction","s","when","fulfill","otherwise","toManualReactions"],"mappings":"AAOO,MAAMA,wBAAyB,IAAI;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC,GAEYC,IAAY,WAEZC,IAA6D;AAAA,EACxE,EAAE,OAAO,cAAc,OAAO,QAAA;AAAA,EAC9B,EAAE,OAAO,eAAe,OAAO,UAAA;AAAA,EAC/B,EAAE,OAAO,cAAc,OAAO,SAAA;AAAA,EAC9B,EAAE,OAAO,gBAAgB,OAAO,WAAA;AAAA,EA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AElB,QAAMC,IAAUR,EAAYC,GAAM,SAAS,GACrCQ,IAAYT,EAAYC,GAAM,WAAW;AAC/C,SAAIO,MACFH,EAAS,UAAUG,IAEjBC,MACFJ,EAAS,YAAYI,IAEhBJ;AACT;AAEO,SAASK,EAAkBhB,GAA4B;AAC5D,SAAK,MAAM,QAAQA,CAAK,IAGjBA,EAAM;AAAA,IACX,CAACH,MAAqB,CAAC,CAACA,KAAMA,EAAe,cAAc;AAAA,EAAA,IAHpD,CAAA;AAKX;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useMemo as e } from "react";
|
|
2
|
+
import { useDesigner as o } from "../DesignerContext.js";
|
|
3
|
+
import { collectDataFieldPaths as r, collectDataFieldOptions as s } from "../schemaUtils.js";
|
|
4
|
+
function n() {
|
|
5
|
+
const { schema: t } = o();
|
|
6
|
+
return e(() => r(t), [t]);
|
|
7
|
+
}
|
|
8
|
+
function c() {
|
|
9
|
+
const { schema: t } = o();
|
|
10
|
+
return e(() => s(t), [t]);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
c as useFormDataFieldOptions,
|
|
14
|
+
n as useFormDataFields
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useFormDataFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormDataFields.js","sources":["../../../src/widgets/useFormDataFields.ts"],"sourcesContent":["// ============================================================================\n// useFormDataFields — 从当前设计器 schema 收集 formData 字段(供变量/依赖选择)\n// ============================================================================\n\nimport { useMemo } from 'react';\nimport { useDesigner } from '../DesignerContext';\nimport { collectDataFieldOptions, collectDataFieldPaths } from '../schemaUtils';\n\nexport function useFormDataFields(): string[] {\n const { schema } = useDesigner();\n return useMemo(() => collectDataFieldPaths(schema), [schema]);\n}\n\n/** 带字段标题的选项列表:显示 title,值为路径 key(供 dependencies 等选择器) */\nexport function useFormDataFieldOptions(): Array<{\n value: string;\n label: string;\n}> {\n const { schema } = useDesigner();\n return useMemo(() => collectDataFieldOptions(schema), [schema]);\n}\n"],"names":["useFormDataFields","schema","useDesigner","useMemo","collectDataFieldPaths","useFormDataFieldOptions","collectDataFieldOptions"],"mappings":";;;AAQO,SAASA,IAA8B;AAC5C,QAAM,EAAE,QAAAC,EAAA,IAAWC,EAAA;AACnB,SAAOC,EAAQ,MAAMC,EAAsBH,CAAM,GAAG,CAACA,CAAM,CAAC;AAC9D;AAGO,SAASI,IAGb;AACD,QAAM,EAAE,QAAAJ,EAAA,IAAWC,EAAA;AACnB,SAAOC,EAAQ,MAAMG,EAAwBL,CAAM,GAAG,CAACA,CAAM,CAAC;AAChE;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xbeeant/form-engine-designer",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"registry": "https://registry.npmjs.org/"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/es/index.js",
|
|
10
|
+
"module": "./dist/es/index.js",
|
|
11
|
+
"types": "./dist/es/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/es/index.d.ts",
|
|
15
|
+
"import": "./dist/es/index.js",
|
|
16
|
+
"require": "./dist/cjs/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": [
|
|
26
|
+
"**/*.css"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -b && vite build",
|
|
30
|
+
"prepublishOnly": "npm run build",
|
|
31
|
+
"lint": "biome check .",
|
|
32
|
+
"lint:fix": "biome check --write .",
|
|
33
|
+
"test": "vitest run"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"antd": ">=5.0.0",
|
|
37
|
+
"dayjs": ">=1.11.0",
|
|
38
|
+
"react": ">=18.0.0",
|
|
39
|
+
"react-dom": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"antd": {
|
|
43
|
+
"optional": false
|
|
44
|
+
},
|
|
45
|
+
"react": {
|
|
46
|
+
"optional": false
|
|
47
|
+
},
|
|
48
|
+
"react-dom": {
|
|
49
|
+
"optional": false
|
|
50
|
+
},
|
|
51
|
+
"dayjs": {
|
|
52
|
+
"optional": false
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@xbeeant/form-engine": "^0.0.1",
|
|
57
|
+
"@xbeeant/form-engine-ui": "^0.0.1"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"vitest": "^4.1.10"
|
|
61
|
+
}
|
|
62
|
+
}
|