@texaryn/vue 0.0.0 → 0.1.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 +13 -0
- package/LICENSE +190 -0
- package/README.md +91 -0
- package/dist/components/FormRoot.d.ts +17 -0
- package/dist/components/FormRoot.d.ts.map +1 -0
- package/dist/components/FormRoot.js +24 -0
- package/dist/components/FormRoot.js.map +1 -0
- package/dist/components/NodeRenderer.d.ts +22 -0
- package/dist/components/NodeRenderer.d.ts.map +1 -0
- package/dist/components/NodeRenderer.js +24 -0
- package/dist/components/NodeRenderer.js.map +1 -0
- package/dist/context.d.ts +29 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +43 -0
- package/dist/context.js.map +1 -0
- package/dist/field-props.d.ts +29 -0
- package/dist/field-props.d.ts.map +1 -0
- package/dist/field-props.js +26 -0
- package/dist/field-props.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/use-field-array.d.ts +20 -0
- package/dist/use-field-array.d.ts.map +1 -0
- package/dist/use-field-array.js +43 -0
- package/dist/use-field-array.js.map +1 -0
- package/dist/use-field-widget.d.ts +33 -0
- package/dist/use-field-widget.d.ts.map +1 -0
- package/dist/use-field-widget.js +66 -0
- package/dist/use-field-widget.js.map +1 -0
- package/dist/use-field.d.ts +28 -0
- package/dist/use-field.d.ts.map +1 -0
- package/dist/use-field.js +47 -0
- package/dist/use-field.js.map +1 -0
- package/dist/use-form.d.ts +26 -0
- package/dist/use-form.d.ts.map +1 -0
- package/dist/use-form.js +36 -0
- package/dist/use-form.js.map +1 -0
- package/dist/use-store.d.ts +19 -0
- package/dist/use-store.d.ts.map +1 -0
- package/dist/use-store.js +29 -0
- package/dist/use-store.js.map +1 -0
- package/dist/widget.d.ts +11 -0
- package/dist/widget.d.ts.map +1 -0
- package/dist/widget.js +2 -0
- package/dist/widget.js.map +1 -0
- package/dist/widgets/FieldErrors.d.ts +24 -0
- package/dist/widgets/FieldErrors.d.ts.map +1 -0
- package/dist/widgets/FieldErrors.js +16 -0
- package/dist/widgets/FieldErrors.js.map +1 -0
- package/dist/widgets/containers.d.ts +29 -0
- package/dist/widgets/containers.d.ts.map +1 -0
- package/dist/widgets/containers.js +50 -0
- package/dist/widgets/containers.js.map +1 -0
- package/dist/widgets/default-registry.d.ts +9 -0
- package/dist/widgets/default-registry.d.ts.map +1 -0
- package/dist/widgets/default-registry.js +46 -0
- package/dist/widgets/default-registry.js.map +1 -0
- package/dist/widgets/inputs.d.ts +68 -0
- package/dist/widgets/inputs.d.ts.map +1 -0
- package/dist/widgets/inputs.js +94 -0
- package/dist/widgets/inputs.js.map +1 -0
- package/package.json +50 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @texaryn/vue
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f002477: First release of `@texaryn/vue`: Vue 3 bindings over the same core the React packages use.
|
|
8
|
+
|
|
9
|
+
Composables (`useForm`, `useField`, `useFieldArray`, `useStore`), provide/inject context, `FormRoot` and `NodeRenderer`, and a default widget set matching the React registry's tests and ranks.
|
|
10
|
+
|
|
11
|
+
Two things work differently from `@texaryn/react`, and both follow from `setup` running once where a hook re-runs per render. `useStore` accepts a store or a getter and watches it. `useField` and `useFieldArray` take the node id as a ref or getter, which is what keeps a field attached to its own array item across a move rather than to the position it left. `useForm` and `useStore` require an active scope, because each owns something only teardown releases.
|
|
12
|
+
|
|
13
|
+
The whole example catalog runs through this package in the conformance matrix, and the playground renders it over the same `FormRuntime` instance the React shell owns.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2024-2026 Hamza Hamidi
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @texaryn/vue
|
|
2
|
+
|
|
3
|
+
Vue 3 bindings for Texaryn: composables, provide/inject context, a renderer
|
|
4
|
+
and a small set of native widgets.
|
|
5
|
+
|
|
6
|
+
A `0.0.0` placeholder exists on npm to reserve the name. The first usable
|
|
7
|
+
release will be `0.1.0`.
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { createJsonSchemaAdapter } from '@texaryn/schema-json'
|
|
12
|
+
import { useForm, provideFormRuntime, createDefaultRegistry } from '@texaryn/vue'
|
|
13
|
+
|
|
14
|
+
const schema = {
|
|
15
|
+
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: { name: { type: 'string', title: 'Name' } },
|
|
18
|
+
required: ['name'],
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const port = await createJsonSchemaAdapter(schema, {})
|
|
22
|
+
const form = useForm(port, { initialData: { name: '' } })
|
|
23
|
+
provideFormRuntime(form.runtime)
|
|
24
|
+
|
|
25
|
+
const registry = createDefaultRegistry()
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<!-- FormRoot has to be a descendant, not this component itself -->
|
|
30
|
+
<FormRoot :registry="registry" />
|
|
31
|
+
</template>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`useForm` creates the runtime and ties it to the calling scope. Providing is a
|
|
35
|
+
separate call rather than a side effect of construction: React's equivalent is
|
|
36
|
+
`<FormProvider>` in the template, and Vue's is a setup call.
|
|
37
|
+
|
|
38
|
+
A component cannot inject what it provided itself, so `FormRoot` and anything
|
|
39
|
+
calling `useField` has to be a descendant of whichever component called
|
|
40
|
+
`provideFormRuntime`.
|
|
41
|
+
|
|
42
|
+
## Lifetime is a requirement, not a convention
|
|
43
|
+
|
|
44
|
+
`useForm` and `useStore` throw when called outside `setup()` or an active
|
|
45
|
+
`effectScope`. Both own something that only teardown releases, a runtime with
|
|
46
|
+
live validation timers and a store subscription, and neither returns a handle
|
|
47
|
+
the caller could stop. Requiring a scope is what makes that ownership real:
|
|
48
|
+
the check runs before anything is created, so a misuse cannot leak the thing
|
|
49
|
+
it was about to allocate. Stopping the scope destroys the runtime and
|
|
50
|
+
unsubscribes.
|
|
51
|
+
|
|
52
|
+
## What it does not depend on
|
|
53
|
+
|
|
54
|
+
`@texaryn/core` and Vue. Not `@texaryn/react`. The point of a second binding is
|
|
55
|
+
to find out what core actually promises, and reaching into the first binding
|
|
56
|
+
for a helper would answer a different question.
|
|
57
|
+
|
|
58
|
+
## Node ids are accepted as refs or getters, and that matters
|
|
59
|
+
|
|
60
|
+
`useField` and `useFieldArray` take `MaybeRefOrGetter<NodeId>`, not `NodeId`.
|
|
61
|
+
|
|
62
|
+
Node ids follow position in the document. Array item identity is carried
|
|
63
|
+
separately as `StableItemId`, and a row keyed on that keeps its component
|
|
64
|
+
instance through a move while the node underneath it becomes a different one.
|
|
65
|
+
React re-reads the id on every render, so it follows for free. A Vue
|
|
66
|
+
composable that captured the id in `setup` would keep reading the old position
|
|
67
|
+
and keep writing to it, so typing into a moved row would overwrite the row
|
|
68
|
+
that took its place.
|
|
69
|
+
|
|
70
|
+
The same reasoning applies to reads. `getNodeState` is a map lookup with no
|
|
71
|
+
reactivity of its own, and the runtime replaces a node's state bundle when its
|
|
72
|
+
id leaves the document and returns. `useField` reads the document ref when it
|
|
73
|
+
resolves the bundle so a recompile re-resolves it.
|
|
74
|
+
|
|
75
|
+
Both are covered by tests that fail when the behaviour is removed.
|
|
76
|
+
|
|
77
|
+
## Conformance
|
|
78
|
+
|
|
79
|
+
`tests/example-conformance/vue.test.ts` runs the whole catalog through this
|
|
80
|
+
package and makes the same two claims the React renderers make: every example
|
|
81
|
+
mounts without a console error or warning, and every active node in every
|
|
82
|
+
example resolves a widget. The framework-neutral half of that harness is
|
|
83
|
+
shared; mounting is not, because the two frameworks do not share a mounting
|
|
84
|
+
model.
|
|
85
|
+
|
|
86
|
+
## No single file components
|
|
87
|
+
|
|
88
|
+
The package ships plain TypeScript with render functions, so it builds with
|
|
89
|
+
the same `tsc --build` as every other package in the workspace and needs no
|
|
90
|
+
Vue-specific toolchain to compile. Consumers are free to use SFCs; nothing
|
|
91
|
+
here requires them to.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
import type { RendererRegistry } from '@texaryn/core';
|
|
3
|
+
import type { WidgetComponent } from '../widget.js';
|
|
4
|
+
export declare const FormRoot: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
|
+
registry: {
|
|
6
|
+
type: PropType<RendererRegistry<WidgetComponent>>;
|
|
7
|
+
required: true;
|
|
8
|
+
};
|
|
9
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
|
+
registry: {
|
|
13
|
+
type: PropType<RendererRegistry<WidgetComponent>>;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
17
|
+
//# sourceMappingURL=FormRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormRoot.d.ts","sourceRoot":"","sources":["../../src/components/FormRoot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAGrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,eAAO,MAAM,QAAQ;;cAIC,QAAQ,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;;;;;;;cAA3C,QAAQ,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;;;iGAgB/D,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { computed, defineComponent, h } from 'vue';
|
|
2
|
+
import { provideRendererRegistry, useFormRuntime } from '../context.js';
|
|
3
|
+
import { useStore } from '../use-store.js';
|
|
4
|
+
import { NodeRenderer } from './NodeRenderer.js';
|
|
5
|
+
export const FormRoot = defineComponent({
|
|
6
|
+
name: 'FormRoot',
|
|
7
|
+
props: {
|
|
8
|
+
registry: {
|
|
9
|
+
type: Object,
|
|
10
|
+
required: true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
setup(props) {
|
|
14
|
+
const runtime = useFormRuntime();
|
|
15
|
+
// Provided once here rather than at every node: inject walks the parent
|
|
16
|
+
// chain, so one provide reaches the whole tree. Passed as a getter so a
|
|
17
|
+
// changed prop re-resolves that tree instead of freezing it.
|
|
18
|
+
provideRendererRegistry(() => props.registry);
|
|
19
|
+
const document = useStore(runtime.document, runtime.document.getSnapshot());
|
|
20
|
+
const rootNode = computed(() => document.value.nodes[document.value.rootId]);
|
|
21
|
+
return () => (rootNode.value ? h(NodeRenderer, { node: rootNode.value }) : null);
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=FormRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormRoot.js","sourceRoot":"","sources":["../../src/components/FormRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGlD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC;IACtC,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE;QACL,QAAQ,EAAE;YACR,IAAI,EAAE,MAAqD;YAC3D,QAAQ,EAAE,IAAI;SACf;KACF;IACD,KAAK,CAAC,KAAK;QACT,MAAM,OAAO,GAAG,cAAc,EAAE,CAAA;QAChC,wEAAwE;QACxE,wEAAwE;QACxE,6DAA6D;QAC7D,uBAAuB,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAE7C,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAA;QAC3E,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;QAE5E,OAAO,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAClF,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
import type { UINode } from '@texaryn/core';
|
|
3
|
+
/**
|
|
4
|
+
* Compiling a schema with `active: false` produces a node with
|
|
5
|
+
* `visible: false`. That is the source of truth for hiding a node, so it is
|
|
6
|
+
* read off the node rather than through useField, which would cost a
|
|
7
|
+
* subscription for a subtree that never renders.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NodeRenderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
|
+
node: {
|
|
11
|
+
type: PropType<UINode>;
|
|
12
|
+
required: true;
|
|
13
|
+
};
|
|
14
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
|
+
node: {
|
|
18
|
+
type: PropType<UINode>;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
22
|
+
//# sourceMappingURL=NodeRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeRenderer.d.ts","sourceRoot":"","sources":["../../src/components/NodeRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAG3C;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;cAGG,QAAQ,CAAC,MAAM,CAAC;;;;;;;cAAhB,QAAQ,CAAC,MAAM,CAAC;;;iGAW1C,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { computed, defineComponent, h } from 'vue';
|
|
2
|
+
import { useRendererRegistry } from '../context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Compiling a schema with `active: false` produces a node with
|
|
5
|
+
* `visible: false`. That is the source of truth for hiding a node, so it is
|
|
6
|
+
* read off the node rather than through useField, which would cost a
|
|
7
|
+
* subscription for a subtree that never renders.
|
|
8
|
+
*/
|
|
9
|
+
export const NodeRenderer = defineComponent({
|
|
10
|
+
name: 'NodeRenderer',
|
|
11
|
+
props: {
|
|
12
|
+
node: { type: Object, required: true },
|
|
13
|
+
},
|
|
14
|
+
setup(props) {
|
|
15
|
+
const registry = useRendererRegistry();
|
|
16
|
+
const widget = computed(() => registry.value.resolve(props.node));
|
|
17
|
+
return () => {
|
|
18
|
+
if (!props.node.visible || !widget.value)
|
|
19
|
+
return null;
|
|
20
|
+
return h(widget.value, { node: props.node });
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=NodeRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeRenderer.js","sourceRoot":"","sources":["../../src/components/NodeRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGlD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;IAC1C,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE;QACL,IAAI,EAAE,EAAE,IAAI,EAAE,MAA0B,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC3D;IACD,KAAK,CAAC,KAAK;QACT,MAAM,QAAQ,GAAG,mBAAmB,EAAE,CAAA;QACtC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAEjE,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAA;YACrD,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;QAC9C,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey, MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import type { FormRuntime, RendererRegistry } from '@texaryn/core';
|
|
3
|
+
import type { WidgetComponent } from './widget.js';
|
|
4
|
+
export declare const FormRuntimeKey: InjectionKey<FormRuntime>;
|
|
5
|
+
export declare const RendererRegistryKey: InjectionKey<ComputedRef<RendererRegistry<WidgetComponent>>>;
|
|
6
|
+
export declare function provideFormRuntime(runtime: FormRuntime): void;
|
|
7
|
+
export declare function useFormRuntime(): FormRuntime;
|
|
8
|
+
/**
|
|
9
|
+
* The registry is provided as a computed rather than a value, so a caller
|
|
10
|
+
* that swaps renderers re-resolves the tree it already has.
|
|
11
|
+
*
|
|
12
|
+
* Providing the value itself would freeze the tree on whichever renderer was
|
|
13
|
+
* selected when it mounted. React gets this free by re-providing on every
|
|
14
|
+
* render; Vue provides once, so the reactivity has to be in what is provided.
|
|
15
|
+
* The playground switches renderer without remounting the form, because the
|
|
16
|
+
* runtime belongs to the example rather than to the presentation over it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function provideRendererRegistry(registry: MaybeRefOrGetter<RendererRegistry<WidgetComponent>>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Provided once by FormRoot rather than per node.
|
|
21
|
+
*
|
|
22
|
+
* React re-provides it at every NodeRenderer because a context value has to
|
|
23
|
+
* sit above the component that reads it in the element tree it builds. Vue's
|
|
24
|
+
* inject walks the component parent chain, so one provide at the root reaches
|
|
25
|
+
* every widget however deeply nested, and repeating it per node would create
|
|
26
|
+
* an injection scope per node for no gain.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useRendererRegistry(): ComputedRef<RendererRegistry<WidgetComponent>>;
|
|
29
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,cAAc,EAAE,YAAY,CAAC,WAAW,CAA6B,CAAA;AAClF,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,WAAW,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CACjE,CAAA;AAE5B,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAE7D;AAED,wBAAgB,cAAc,IAAI,WAAW,CAM5C;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,GAC5D,IAAI,CAEN;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,WAAW,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAMpF"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { computed, inject, provide, toValue } from 'vue';
|
|
2
|
+
export const FormRuntimeKey = Symbol('texaryn.runtime');
|
|
3
|
+
export const RendererRegistryKey = Symbol('texaryn.registry');
|
|
4
|
+
export function provideFormRuntime(runtime) {
|
|
5
|
+
provide(FormRuntimeKey, runtime);
|
|
6
|
+
}
|
|
7
|
+
export function useFormRuntime() {
|
|
8
|
+
const runtime = inject(FormRuntimeKey, null);
|
|
9
|
+
if (!runtime) {
|
|
10
|
+
throw new Error('useFormRuntime must be used under a component that called provideFormRuntime');
|
|
11
|
+
}
|
|
12
|
+
return runtime;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The registry is provided as a computed rather than a value, so a caller
|
|
16
|
+
* that swaps renderers re-resolves the tree it already has.
|
|
17
|
+
*
|
|
18
|
+
* Providing the value itself would freeze the tree on whichever renderer was
|
|
19
|
+
* selected when it mounted. React gets this free by re-providing on every
|
|
20
|
+
* render; Vue provides once, so the reactivity has to be in what is provided.
|
|
21
|
+
* The playground switches renderer without remounting the form, because the
|
|
22
|
+
* runtime belongs to the example rather than to the presentation over it.
|
|
23
|
+
*/
|
|
24
|
+
export function provideRendererRegistry(registry) {
|
|
25
|
+
provide(RendererRegistryKey, computed(() => toValue(registry)));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Provided once by FormRoot rather than per node.
|
|
29
|
+
*
|
|
30
|
+
* React re-provides it at every NodeRenderer because a context value has to
|
|
31
|
+
* sit above the component that reads it in the element tree it builds. Vue's
|
|
32
|
+
* inject walks the component parent chain, so one provide at the root reaches
|
|
33
|
+
* every widget however deeply nested, and repeating it per node would create
|
|
34
|
+
* an injection scope per node for no gain.
|
|
35
|
+
*/
|
|
36
|
+
export function useRendererRegistry() {
|
|
37
|
+
const registry = inject(RendererRegistryKey, null);
|
|
38
|
+
if (!registry) {
|
|
39
|
+
throw new Error('useRendererRegistry must be used inside a FormRoot tree');
|
|
40
|
+
}
|
|
41
|
+
return registry;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAKxD,MAAM,CAAC,MAAM,cAAc,GAA8B,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAC9B,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAE5B,MAAM,UAAU,kBAAkB,CAAC,OAAoB;IACrD,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;IAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAA;IACjG,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAA6D;IAE7D,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AACjE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,QAAQ,GAAG,MAAM,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAA;IAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FieldNode, ValidationError } from '@texaryn/core';
|
|
2
|
+
/**
|
|
3
|
+
* The accessible attribute surface for a field, derived from the node and its
|
|
4
|
+
* current state.
|
|
5
|
+
*
|
|
6
|
+
* This is a deliberate reimplementation of `@texaryn/react`'s prop getters
|
|
7
|
+
* rather than an import of them: this package must not depend on the React
|
|
8
|
+
* binding, and the slice exists to find out what the two genuinely share.
|
|
9
|
+
* Nothing here is Vue specific, which makes it the first candidate for a
|
|
10
|
+
* framework-neutral home. That move waits for evidence from a second
|
|
11
|
+
* consumer, not from this file existing.
|
|
12
|
+
*/
|
|
13
|
+
export interface FieldAria {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
'aria-required': boolean;
|
|
18
|
+
'aria-invalid'?: boolean;
|
|
19
|
+
'aria-describedby'?: string;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function makeId(nodeId: string, suffix: string): string;
|
|
23
|
+
export declare function fieldAria(node: FieldNode, state: {
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
showErrors: boolean;
|
|
26
|
+
errors: readonly ValidationError[];
|
|
27
|
+
}): FieldAria;
|
|
28
|
+
export declare function fieldLabel(node: FieldNode): string;
|
|
29
|
+
//# sourceMappingURL=field-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-props.d.ts","sourceRoot":"","sources":["../src/field-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,eAAe,EAAE,OAAO,CAAA;IACxB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;CAAE,GACpF,SAAS,CAoBX;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function makeId(nodeId, suffix) {
|
|
2
|
+
return `texaryn-${nodeId}-${suffix}`;
|
|
3
|
+
}
|
|
4
|
+
export function fieldAria(node, state) {
|
|
5
|
+
const describedBy = [];
|
|
6
|
+
if (node.helpText ?? node.annotations?.description) {
|
|
7
|
+
describedBy.push(makeId(node.id, 'description'));
|
|
8
|
+
}
|
|
9
|
+
const invalid = state.showErrors && state.errors.length > 0;
|
|
10
|
+
if (invalid) {
|
|
11
|
+
describedBy.push(makeId(node.id, 'error'));
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
id: makeId(node.id, 'input'),
|
|
15
|
+
name: node.dataPointer || node.id,
|
|
16
|
+
disabled: state.disabled,
|
|
17
|
+
'aria-required': Boolean(node.constraints?.required),
|
|
18
|
+
'aria-invalid': invalid ? true : undefined,
|
|
19
|
+
'aria-describedby': describedBy.length > 0 ? describedBy.join(' ') : undefined,
|
|
20
|
+
placeholder: node.placeholder ?? undefined,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function fieldLabel(node) {
|
|
24
|
+
return node.annotations.title ?? node.dataPointer ?? node.id;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=field-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-props.js","sourceRoot":"","sources":["../src/field-props.ts"],"names":[],"mappings":"AAuBA,MAAM,UAAU,MAAM,CAAC,MAAc,EAAE,MAAc;IACnD,OAAO,WAAW,MAAM,IAAI,MAAM,EAAE,CAAA;AACtC,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,IAAe,EACf,KAAqF;IAErF,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC;QACnD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;IAC3D,IAAI,OAAO,EAAE,CAAC;QACZ,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC;QAC5B,IAAI,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,EAAE;QACjC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;QACpD,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAC1C,kBAAkB,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAC9E,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,SAAS;KAC3C,CAAA;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAe;IACxC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,EAAE,CAAA;AAC9D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { useStore } from './use-store.js';
|
|
2
|
+
export { useForm } from './use-form.js';
|
|
3
|
+
export type { UseFormReturn } from './use-form.js';
|
|
4
|
+
export { FormRuntimeKey, RendererRegistryKey, provideFormRuntime, provideRendererRegistry, useFormRuntime, useRendererRegistry, } from './context.js';
|
|
5
|
+
export { useField } from './use-field.js';
|
|
6
|
+
export type { UseFieldReturn } from './use-field.js';
|
|
7
|
+
export { useFieldArray } from './use-field-array.js';
|
|
8
|
+
export type { FieldArrayItem, UseFieldArrayReturn } from './use-field-array.js';
|
|
9
|
+
export { useFieldWidget } from './use-field-widget.js';
|
|
10
|
+
export type { FieldKind, FieldWidget } from './use-field-widget.js';
|
|
11
|
+
export { fieldAria, fieldLabel, makeId } from './field-props.js';
|
|
12
|
+
export type { FieldAria } from './field-props.js';
|
|
13
|
+
export type { WidgetComponent } from './widget.js';
|
|
14
|
+
export { FormRoot } from './components/FormRoot.js';
|
|
15
|
+
export { NodeRenderer } from './components/NodeRenderer.js';
|
|
16
|
+
export { FieldErrors } from './widgets/FieldErrors.js';
|
|
17
|
+
export { Checkbox, NumberInput, Select, Textarea, TextInput } from './widgets/inputs.js';
|
|
18
|
+
export { ArrayControl, ObjectLayout } from './widgets/containers.js';
|
|
19
|
+
export { createDefaultRegistry } from './widgets/default-registry.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAChE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { useStore } from './use-store.js';
|
|
2
|
+
export { useForm } from './use-form.js';
|
|
3
|
+
export { FormRuntimeKey, RendererRegistryKey, provideFormRuntime, provideRendererRegistry, useFormRuntime, useRendererRegistry, } from './context.js';
|
|
4
|
+
export { useField } from './use-field.js';
|
|
5
|
+
export { useFieldArray } from './use-field-array.js';
|
|
6
|
+
export { useFieldWidget } from './use-field-widget.js';
|
|
7
|
+
export { fieldAria, fieldLabel, makeId } from './field-props.js';
|
|
8
|
+
export { FormRoot } from './components/FormRoot.js';
|
|
9
|
+
export { NodeRenderer } from './components/NodeRenderer.js';
|
|
10
|
+
export { FieldErrors } from './widgets/FieldErrors.js';
|
|
11
|
+
export { Checkbox, NumberInput, Select, Textarea, TextInput } from './widgets/inputs.js';
|
|
12
|
+
export { ArrayControl, ObjectLayout } from './widgets/containers.js';
|
|
13
|
+
export { createDefaultRegistry } from './widgets/default-registry.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAGtD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAIhE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
import type { NodeId, StableItemId } from '@texaryn/core';
|
|
3
|
+
export interface FieldArrayItem {
|
|
4
|
+
/** Survives inserts, removes and moves. The key to render this row with. */
|
|
5
|
+
id: StableItemId;
|
|
6
|
+
/** Positional, so it changes under a row that moves. Undefined when the
|
|
7
|
+
* projection emitted no per-item child pointer. */
|
|
8
|
+
nodeId: NodeId | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface UseFieldArrayReturn {
|
|
11
|
+
items: Ref<FieldArrayItem[]>;
|
|
12
|
+
canAdd: Ref<boolean>;
|
|
13
|
+
canRemove: Ref<boolean>;
|
|
14
|
+
canReorder: Ref<boolean>;
|
|
15
|
+
add(value?: unknown): void;
|
|
16
|
+
remove(index: number): void;
|
|
17
|
+
move(from: number, to: number): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function useFieldArray(nodeId: MaybeRefOrGetter<NodeId>): UseFieldArrayReturn;
|
|
20
|
+
//# sourceMappingURL=use-field-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-field-array.d.ts","sourceRoot":"","sources":["../src/use-field-array.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAChD,OAAO,KAAK,EAAiB,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAIxE,MAAM,WAAW,cAAc;IAC7B,4EAA4E;IAC5E,EAAE,EAAE,YAAY,CAAA;IAChB;uDACmD;IACnD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,GAAG,CAAC,cAAc,EAAE,CAAC,CAAA;IAC5B,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACpB,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACvB,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACxB,GAAG,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;CACrC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,mBAAmB,CAwCnF"}
|