@verbb/formie-vue 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,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ - Initial public release.
package/LICENSE.md ADDED
@@ -0,0 +1,40 @@
1
+ Copyright © Verbb
2
+
3
+ Permission is hereby granted to any person obtaining a copy of this software
4
+ (the “Software”) to use, copy, modify, merge, publish and/or distribute copies
5
+ of the Software, and to permit persons to whom the Software is furnished to do
6
+ so, subject to the following conditions:
7
+
8
+ 1. **Don’t plagiarize.** The above copyright notice and this license shall be
9
+ included in all copies or substantial portions of the Software.
10
+
11
+ 2. **Don’t use the same license on more than one project.** Each licensed copy
12
+ of the Software shall be actively installed in no more than one production
13
+ environment at a time.
14
+
15
+ 3. **Don’t mess with the licensing features.** Software features related to
16
+ licensing shall not be altered or circumvented in any way, including (but
17
+ not limited to) license validation, payment prompts, feature restrictions,
18
+ and update eligibility.
19
+
20
+ 4. **Pay up.** Payment shall be made immediately upon receipt of any notice,
21
+ prompt, reminder, or other message indicating that a payment is owed.
22
+
23
+ 5. **Follow the law.** All use of the Software shall not violate any applicable
24
+ law or regulation, nor infringe the rights of any other person or entity.
25
+
26
+ Failure to comply with the foregoing conditions will automatically and
27
+ immediately result in termination of the permission granted hereby. This
28
+ license does not include any right to receive updates to the Software or
29
+ technical support. Licensees bear all risk related to the quality and
30
+ performance of the Software and any modifications made or obtained to it,
31
+ including liability for actual and consequential harm, such as loss or
32
+ corruption of data, and any necessary service, repair, or correction.
33
+
34
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
38
+ LIABILITY, INCLUDING SPECIAL, INCIDENTAL AND CONSEQUENTIAL DAMAGES, WHETHER IN
39
+ AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @verbb/formie-vue
2
+
3
+ Vue bindings for Formie's server-rendered and client-rendered front-end packages.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @verbb/formie-browser @verbb/formie-vue vue
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { FormieForm, FormieClientForm, useFormieHtml } from '@verbb/formie-vue';
15
+ import '@verbb/formie-browser/css/formie.css';
16
+ ```
17
+
18
+ ## Public Surface
19
+
20
+ Use only the root package entry:
21
+
22
+ - `@verbb/formie-vue`
23
+
24
+ CSS continues to come from `@verbb/formie-browser`.
@@ -0,0 +1,243 @@
1
+ import { type FrontendFieldDefinition, type FrontendFormDefinition, type FrontendFormEnvelope, type FrontendFormSession, type FrontendFormInstance, type FrontendFormState, type FrontendSubmitResult } from '@verbb/formie-core';
2
+ import { type Component, type ComputedRef, type PropType, type ShallowRef, type VNode } from 'vue';
3
+ export type FormieDefinitionSource = {
4
+ transport: 'rest';
5
+ endpoint: string;
6
+ formHandle: string;
7
+ siteId?: number;
8
+ } | {
9
+ transport: 'graphql';
10
+ endpoint: string;
11
+ formHandle: string;
12
+ siteId?: number;
13
+ } | {
14
+ definition: FrontendFormEnvelope;
15
+ transport: {
16
+ type: 'rest';
17
+ endpoint: string;
18
+ formHandle: string;
19
+ siteId?: number;
20
+ };
21
+ } | {
22
+ definition: FrontendFormEnvelope;
23
+ transport: {
24
+ type: 'graphql';
25
+ endpoint: string;
26
+ formHandle: string;
27
+ siteId?: number;
28
+ };
29
+ };
30
+ export type FormieVueEvent = {
31
+ name: string;
32
+ payload: unknown;
33
+ };
34
+ export type FormieFormComponentProps = {
35
+ definition: FrontendFormDefinition;
36
+ session: FrontendFormSession;
37
+ state: FrontendFormState;
38
+ className?: string;
39
+ onSubmit: () => void;
40
+ };
41
+ export type FormiePageComponentProps = {
42
+ page: FrontendFormDefinition['pages'][number];
43
+ state: FrontendFormState;
44
+ };
45
+ export type FormieFieldProps = {
46
+ field: FrontendFieldDefinition;
47
+ errors: string[];
48
+ };
49
+ export type FormieErrorSummaryProps = {
50
+ errors: string[];
51
+ };
52
+ export type FormieFieldComponentProps = {
53
+ field: FrontendFieldDefinition;
54
+ value: unknown;
55
+ errors: string[];
56
+ errorKey: string;
57
+ disabled: boolean;
58
+ hidden: boolean;
59
+ setValue: (value: unknown) => void;
60
+ };
61
+ export type FormieSlotComponentProps = {
62
+ slotKey: string;
63
+ attributes?: Record<string, unknown>;
64
+ };
65
+ export type FormieVueComponents = {
66
+ Form?: Component;
67
+ Page?: Component;
68
+ Field?: Component;
69
+ ErrorSummary?: Component;
70
+ };
71
+ export declare const DefinitionFormView: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
72
+ readonly source: {
73
+ readonly type: PropType<FormieDefinitionSource>;
74
+ readonly required: true;
75
+ };
76
+ readonly components: {
77
+ readonly type: PropType<FormieVueComponents>;
78
+ readonly default: () => {};
79
+ };
80
+ readonly fieldComponents: {
81
+ readonly type: PropType<Partial<Record<string, Component>>>;
82
+ readonly default: () => {};
83
+ };
84
+ readonly slots: {
85
+ readonly type: PropType<Partial<Record<string, Component>>>;
86
+ readonly default: () => {};
87
+ };
88
+ readonly className: {
89
+ readonly type: StringConstructor;
90
+ readonly default: any;
91
+ };
92
+ readonly onMount: {
93
+ readonly type: PropType<(instance: FrontendFormInstance) => void>;
94
+ readonly default: any;
95
+ };
96
+ readonly onReady: {
97
+ readonly type: PropType<(instance: FrontendFormInstance) => void>;
98
+ readonly default: any;
99
+ };
100
+ readonly onUnmount: {
101
+ readonly type: PropType<() => void>;
102
+ readonly default: any;
103
+ };
104
+ readonly onResult: {
105
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
106
+ readonly default: any;
107
+ };
108
+ readonly onSuccess: {
109
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
110
+ readonly default: any;
111
+ };
112
+ readonly onError: {
113
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
114
+ readonly default: any;
115
+ };
116
+ readonly onSubmitResult: {
117
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
118
+ readonly default: any;
119
+ };
120
+ readonly onSubmitSuccess: {
121
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
122
+ readonly default: any;
123
+ };
124
+ readonly onSubmitError: {
125
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
126
+ readonly default: any;
127
+ };
128
+ readonly onEvent: {
129
+ readonly type: PropType<(event: FormieVueEvent) => void>;
130
+ readonly default: any;
131
+ };
132
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
133
+ [key: string]: any;
134
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("error" | "mount" | "ready" | "unmount" | "result" | "success" | "submit-result" | "submit-success" | "submit-error" | "event")[], "error" | "mount" | "ready" | "unmount" | "result" | "success" | "submit-result" | "submit-success" | "submit-error" | "event", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
135
+ readonly source: {
136
+ readonly type: PropType<FormieDefinitionSource>;
137
+ readonly required: true;
138
+ };
139
+ readonly components: {
140
+ readonly type: PropType<FormieVueComponents>;
141
+ readonly default: () => {};
142
+ };
143
+ readonly fieldComponents: {
144
+ readonly type: PropType<Partial<Record<string, Component>>>;
145
+ readonly default: () => {};
146
+ };
147
+ readonly slots: {
148
+ readonly type: PropType<Partial<Record<string, Component>>>;
149
+ readonly default: () => {};
150
+ };
151
+ readonly className: {
152
+ readonly type: StringConstructor;
153
+ readonly default: any;
154
+ };
155
+ readonly onMount: {
156
+ readonly type: PropType<(instance: FrontendFormInstance) => void>;
157
+ readonly default: any;
158
+ };
159
+ readonly onReady: {
160
+ readonly type: PropType<(instance: FrontendFormInstance) => void>;
161
+ readonly default: any;
162
+ };
163
+ readonly onUnmount: {
164
+ readonly type: PropType<() => void>;
165
+ readonly default: any;
166
+ };
167
+ readonly onResult: {
168
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
169
+ readonly default: any;
170
+ };
171
+ readonly onSuccess: {
172
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
173
+ readonly default: any;
174
+ };
175
+ readonly onError: {
176
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
177
+ readonly default: any;
178
+ };
179
+ readonly onSubmitResult: {
180
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
181
+ readonly default: any;
182
+ };
183
+ readonly onSubmitSuccess: {
184
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
185
+ readonly default: any;
186
+ };
187
+ readonly onSubmitError: {
188
+ readonly type: PropType<(result: FrontendSubmitResult) => void>;
189
+ readonly default: any;
190
+ };
191
+ readonly onEvent: {
192
+ readonly type: PropType<(event: FormieVueEvent) => void>;
193
+ readonly default: any;
194
+ };
195
+ }>> & Readonly<{
196
+ onError?: (...args: any[]) => any;
197
+ onMount?: (...args: any[]) => any;
198
+ onReady?: (...args: any[]) => any;
199
+ onUnmount?: (...args: any[]) => any;
200
+ onResult?: (...args: any[]) => any;
201
+ onSuccess?: (...args: any[]) => any;
202
+ onEvent?: (...args: any[]) => any;
203
+ "onSubmit-result"?: (...args: any[]) => any;
204
+ "onSubmit-success"?: (...args: any[]) => any;
205
+ "onSubmit-error"?: (...args: any[]) => any;
206
+ }>, {
207
+ readonly onError: (result: FrontendSubmitResult) => void;
208
+ readonly components: FormieVueComponents;
209
+ readonly slots: Partial<Record<string, Component>>;
210
+ readonly className: string;
211
+ readonly fieldComponents: Partial<Record<string, Component>>;
212
+ readonly onMount: (instance: FrontendFormInstance) => void;
213
+ readonly onReady: (instance: FrontendFormInstance) => void;
214
+ readonly onUnmount: () => void;
215
+ readonly onResult: (result: FrontendSubmitResult) => void;
216
+ readonly onSuccess: (result: FrontendSubmitResult) => void;
217
+ readonly onSubmitResult: (result: FrontendSubmitResult) => void;
218
+ readonly onSubmitSuccess: (result: FrontendSubmitResult) => void;
219
+ readonly onSubmitError: (result: FrontendSubmitResult) => void;
220
+ readonly onEvent: (event: FormieVueEvent) => void;
221
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
222
+ export declare function useFormie(): {
223
+ definition: ComputedRef<FrontendFormDefinition>;
224
+ session: ComputedRef<FrontendFormSession>;
225
+ state: ShallowRef<FrontendFormState>;
226
+ instance: ShallowRef<FrontendFormInstance>;
227
+ };
228
+ export declare function useFormieField(fieldId: string): {
229
+ field: ComputedRef<FrontendFieldDefinition>;
230
+ value: ComputedRef<unknown>;
231
+ errors: ComputedRef<string[]>;
232
+ hidden: ComputedRef<boolean>;
233
+ disabled: ComputedRef<boolean>;
234
+ setValue(value: unknown): void;
235
+ };
236
+ export declare function useFormiePage(pageId: string): {
237
+ page: ComputedRef<import("@verbb/formie-core").FrontendPageDefinition>;
238
+ isCurrent: ComputedRef<boolean>;
239
+ hidden: ComputedRef<boolean>;
240
+ };
241
+ export declare function useFormieInstance(): ShallowRef<FrontendFormInstance>;
242
+ export declare function useFormieSlot(key: string): ComputedRef<Component>;
243
+ //# sourceMappingURL=definition-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition-form.d.ts","sourceRoot":"","sources":["../src/definition-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAcH,KAAK,uBAAuB,EAE5B,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAWH,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,QAAQ,EAEb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