@formvk/schema 0.0.0-stage → 1.0.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # @formvk/schema
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 65c066c: 添加readme.md文档
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [65c066c]
12
+ - @formvk/core@1.0.0
13
+ - @formvk/reactive@1.0.0
14
+ - @formvk/shared@1.0.0
package/README.md CHANGED
@@ -1,3 +1,66 @@
1
- # Temporary Holding Version
1
+ # @formvk/schema
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Schema-first layer for Formvk. `createFragment` turns registered components into typed schema constructors, `createSchema` assembles a typed object schema, and `{{ ... }}` expressions are compiled into reactive field state when the schema is rendered by `@formvk/react` or `@formvk/vue`.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @formvk/schema
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { createFragment, createSchema } from '@formvk/schema'
15
+
16
+ const f = createFragment()
17
+
18
+ export const schema = createSchema({
19
+ username: f.Field({ title: 'Username', component: 'Input', required: true }),
20
+ tags: f.Array(f.Field({ component: 'Input' })),
21
+ })
22
+ ```
23
+
24
+ Register component props to get full type inference for `componentProps`:
25
+
26
+ ```ts
27
+ const f = createFragment<{
28
+ Input: { placeholder?: string; value?: string }
29
+ }>()
30
+
31
+ const schema = createSchema({
32
+ username: f.Input({ title: 'Username', componentProps: { placeholder: 'Your name' } }),
33
+ })
34
+ ```
35
+
36
+ Expressions use the `{{ ... }}` syntax and are evaluated against form values and scope:
37
+
38
+ ```ts
39
+ const schema = createSchema({
40
+ limit: f.Input({ title: 'Limit' }),
41
+ name: f.Input({
42
+ title: 'Name',
43
+ maxLength: '{{$values.limit}}',
44
+ }),
45
+ })
46
+ ```
47
+
48
+ ## API
49
+
50
+ - `createFragment(options?)` — returns `Field`, `Object`, `Array`, `Void`, `transform`, plus one constructor per registered component name.
51
+ - `createSchema(properties, patches?)` — builds a typed `object` schema.
52
+ - `Schema` — imperative schema tree; `ISchema` is the plain-object form.
53
+ - Expressions — `SchemaExpression`, `ExpressionProps`, `createExpression`, `createExpressionFn`, `getExpression`.
54
+ - Compiler — `compile`, `shallowCompile`, `registerCompiler`, `silent`.
55
+ - Types — `FieldSchema`, `ObjectSchema`, `ArraySchema`, `VoidSchema`, `Fragment`, `SchemaCreator`.
56
+
57
+ In Vue/React apps, `createSchemaField` from `@formvk/vue` / `@formvk/react` binds component maps to a fragment and renders the schema.
58
+
59
+ ## Documentation
60
+
61
+ - Schema guide: https://formvk.github.io/core/guide/schema
62
+ - Schema API: https://formvk.github.io/core/api/schema
63
+
64
+ ## License
65
+
66
+ MIT