@speykye/vue-form-engine-core 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +259 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,259 @@
1
+ # @speykye/vue-form-engine-core
2
+
3
+ Core protocol and runtime utilities for Vue Form Engine.
4
+
5
+ > Status: Experimental / 0.x. The API may change before 1.0.
6
+
7
+ This package contains the UI-agnostic core layer of Vue Form Engine.
8
+
9
+ It defines the schema protocol, registry system, condition evaluation, validation helpers, visibility helpers, model utilities, submit value collection, and plugin interfaces.
10
+
11
+ Most users should install and use `@speykye/vue-form-engine` instead.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pnpm add @speykye/vue-form-engine-core
17
+ ```
18
+
19
+ Or:
20
+
21
+ ```bash
22
+ npm install @speykye/vue-form-engine-core
23
+ ```
24
+
25
+ ## What is inside
26
+
27
+ This package provides the core building blocks for a schema-driven form runtime:
28
+
29
+ - Form schema types
30
+ - Field schema types
31
+ - Block schema types
32
+ - Array field schema types
33
+ - Form condition types
34
+ - Form rule types
35
+ - Hidden value strategy
36
+ - Field registry
37
+ - Block registry
38
+ - Validator registry
39
+ - Condition operator registry
40
+ - Plugin system
41
+ - Visibility evaluation
42
+ - Disabled state evaluation
43
+ - Validation helpers
44
+ - Model initialization helpers
45
+ - Submit value collection helpers
46
+
47
+ ## Architecture
48
+
49
+ Vue Form Engine is split into multiple layers:
50
+
51
+ ```text
52
+ @speykye/vue-form-engine-core
53
+
54
+ @speykye/vue-form-engine
55
+
56
+ @speykye/vue-form-engine-adapter-antdv
57
+ ```
58
+
59
+ This package does not depend on any UI component library.
60
+
61
+ It should not import Ant Design Vue, Element Plus, Vant, Naive UI, or any other UI library.
62
+
63
+ ## Basic engine creation
64
+
65
+ ```ts
66
+ import { createFormEngine } from '@speykye/vue-form-engine-core';
67
+
68
+ const engine = createFormEngine();
69
+
70
+ engine.registerField('input', InputField);
71
+ engine.registerBlock('captcha', CaptchaBlock);
72
+ ```
73
+
74
+ ## Batch registration
75
+
76
+ You can register multiple components at once:
77
+
78
+ ```ts
79
+ engine.registerComponents({
80
+ fields: {
81
+ input: InputField,
82
+ select: SelectField,
83
+ switch: SwitchField
84
+ },
85
+ blocks: {
86
+ captcha: CaptchaBlock,
87
+ invitationCode: InvitationCodeBlock
88
+ }
89
+ });
90
+ ```
91
+
92
+ ## Plugin registration
93
+
94
+ Adapters and business presets can be registered as plugins.
95
+
96
+ ```ts
97
+ engine.use({
98
+ name: 'business-form-preset',
99
+ fields: {
100
+ captcha: CaptchaField
101
+ },
102
+ blocks: {
103
+ invitationCode: InvitationCodeBlock
104
+ },
105
+ validators: {
106
+ uniqueEmail: async value => {
107
+ return true;
108
+ }
109
+ },
110
+ conditionOperators: {
111
+ isVerified: actual => actual === true
112
+ }
113
+ });
114
+ ```
115
+
116
+ ## Schema types
117
+
118
+ Example schema:
119
+
120
+ ```ts
121
+ import type { FormSchema } from '@speykye/vue-form-engine-core';
122
+
123
+ const schema: FormSchema = {
124
+ sections: [
125
+ {
126
+ title: 'Account',
127
+ items: [
128
+ {
129
+ key: 'username',
130
+ type: 'input',
131
+ label: 'Username',
132
+ rules: [{ required: true, message: 'Username is required' }]
133
+ },
134
+ {
135
+ key: 'companyName',
136
+ type: 'input',
137
+ label: 'Company Name',
138
+ visibleWhen: {
139
+ deps: ['userType'],
140
+ predicate: model => model.userType === 'enterprise'
141
+ }
142
+ }
143
+ ]
144
+ }
145
+ ],
146
+ hiddenValueStrategy: 'submitVisibleOnly'
147
+ };
148
+ ```
149
+
150
+ ## Conditions
151
+
152
+ Conditions can be declared with operators:
153
+
154
+ ```ts
155
+ {
156
+ field: 'userType',
157
+ operator: 'eq',
158
+ value: 'enterprise'
159
+ }
160
+ ```
161
+
162
+ Or with a predicate:
163
+
164
+ ```ts
165
+ {
166
+ deps: ['userType'],
167
+ predicate: model => model.userType === 'enterprise'
168
+ }
169
+ ```
170
+
171
+ ## Hidden value strategy
172
+
173
+ The core supports hidden value strategies:
174
+
175
+ ```ts
176
+ type HiddenValueStrategy = 'keep' | 'clear' | 'submitVisibleOnly';
177
+ ```
178
+
179
+ Recommended strategy for business forms:
180
+
181
+ ```ts
182
+ hiddenValueStrategy: 'submitVisibleOnly'
183
+ ```
184
+
185
+ This prevents hidden fields from leaking into the submitted payload.
186
+
187
+ ## Custom validators
188
+
189
+ Register a named validator:
190
+
191
+ ```ts
192
+ engine.registerValidator('uniqueEmail', async value => {
193
+ const available = await checkEmail(value);
194
+ return available || 'Email is already taken';
195
+ });
196
+ ```
197
+
198
+ Use it in schema:
199
+
200
+ ```ts
201
+ {
202
+ key: 'email',
203
+ type: 'input',
204
+ label: 'Email',
205
+ rules: [
206
+ {
207
+ type: 'uniqueEmail',
208
+ trigger: 'onBlur'
209
+ }
210
+ ]
211
+ }
212
+ ```
213
+
214
+ ## Custom condition operators
215
+
216
+ Register a condition operator:
217
+
218
+ ```ts
219
+ engine.registerConditionOperator('isVerified', actual => {
220
+ return actual === true;
221
+ });
222
+ ```
223
+
224
+ Use it in schema:
225
+
226
+ ```ts
227
+ {
228
+ key: 'serviceArea',
229
+ type: 'select',
230
+ visibleWhen: {
231
+ field: 'invitationVerified',
232
+ operator: 'isVerified'
233
+ }
234
+ }
235
+ ```
236
+
237
+ ## Intended users
238
+
239
+ This package is mainly intended for:
240
+
241
+ - Adapter authors
242
+ - Advanced Vue developers
243
+ - Internal platform developers
244
+ - Developers building custom form runtimes
245
+ - Developers who need direct access to the core protocol
246
+
247
+ For normal application usage, use:
248
+
249
+ ```bash
250
+ pnpm add @speykye/vue-form-engine
251
+ ```
252
+
253
+ ## Links
254
+
255
+ - GitHub: https://github.com/speykye/vue-form-engine
256
+
257
+ ## License
258
+
259
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speykye/vue-form-engine-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -13,7 +13,8 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "README.md"
17
18
  ],
18
19
  "peerDependencies": {
19
20
  "vue": "^3.5.0"