@keysdown/form-wrapper 0.0.5 → 0.0.7

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 CHANGED
@@ -12,12 +12,33 @@
12
12
  npm install @keysdown/form-wrapper --save
13
13
  ```
14
14
 
15
+ ## Importing
16
+
17
+ ```js
18
+ import {createForm} from '@keysdown/form-wrapper'
19
+
20
+ const form = ref(createForm({
21
+ first_name: null,
22
+ last_name: null,
23
+ username: null
24
+ }))
25
+
26
+ // Or
27
+
28
+ import FormWrapper from '@keysdown/form-wrapper'
29
+
30
+ const form = ref(new FormWrapper({
31
+ first_name: null,
32
+ last_name: null,
33
+ username: null
34
+ }))
35
+ ```
36
+
15
37
  ## Basic example
16
38
 
17
39
  Basic example using Vue.
18
40
 
19
41
  ```vue
20
-
21
42
  <template>
22
43
  <form @submit.prevent="submit">
23
44
  <input type="text" v-model="form.first_name"/>
@@ -30,9 +51,9 @@ Basic example using Vue.
30
51
  <script setup lang="ts">
31
52
  import axios from 'axios'
32
53
  import {ref} from 'vue'
33
- import Form from '@keysdown/form-wrapper'
54
+ import {createForm} from '@keysdown/form-wrapper'
34
55
 
35
- const form = ref(Form({
56
+ const form = ref(createForm({
36
57
  first_name: null,
37
58
  last_name: null,
38
59
  username: null
@@ -73,9 +94,9 @@ Basic example with validation using Vue.
73
94
  <script setup lang="ts">
74
95
  import axios from 'axios'
75
96
  import {ref} from 'vue'
76
- import Form from '@keysdown/form-wrapper'
97
+ import {createForm} from '@keysdown/form-wrapper'
77
98
 
78
- const form = ref(Form({
99
+ const form = ref(createForm({
79
100
  first_name: {
80
101
  value: null,
81
102
  rules: ['required'],
@@ -179,7 +200,7 @@ form.addFields({
179
200
  Method used when you want to fill in several form fields at once.
180
201
 
181
202
  ```js
182
- const form = Form({
203
+ const form = createForm({
183
204
  username: null
184
205
  })
185
206
 
@@ -197,7 +218,7 @@ console.log(form.values()) // {username: 'keysdown'}
197
218
  Method used when you want to remove a field from the form.
198
219
 
199
220
  ```js
200
- const form = Form({
221
+ const form = createForm({
201
222
  username: null
202
223
  })
203
224
 
@@ -213,7 +234,7 @@ console.log(form.values()) // {}
213
234
  Method used to remove multiple fields to the form.
214
235
 
215
236
  ```js
216
- const form = Form({
237
+ const form = createForm({
217
238
  username: null
218
239
  })
219
240
 
@@ -229,7 +250,7 @@ console.log(form.values()) // {}
229
250
  Method used to reset all form values to original state.
230
251
 
231
252
  ```js
232
- const form = Form({
253
+ const form = createForm({
233
254
  username: null
234
255
  })
235
256
 
@@ -247,7 +268,7 @@ console.log(form.values()) // {username: null}
247
268
  Method used to change the form loading state.
248
269
 
249
270
  ```js
250
- const form = Form({
271
+ const form = createForm({
251
272
  username: null
252
273
  })
253
274
 
@@ -267,7 +288,7 @@ console.log(form.awaiting) // false
267
288
  Method used to validate the entire form or a specific field.
268
289
 
269
290
  ```js
270
- const form = Form({
291
+ const form = createForm({
271
292
  username: {
272
293
  value: null,
273
294
  rules: ['required'],
@@ -301,7 +322,7 @@ form.validate()
301
322
  Method used to validate a specific field.
302
323
 
303
324
  ```js
304
- const form = Form({
325
+ const form = createForm({
305
326
  username: {
306
327
  value: null,
307
328
  rules: ['required'],
@@ -335,7 +356,7 @@ form.validate('username')
335
356
  Method used to validate the entire form.
336
357
 
337
358
  ```js
338
- const form = Form({
359
+ const form = createForm({
339
360
  username: {
340
361
  value: null,
341
362
  rules: ['required'],
@@ -371,7 +392,7 @@ form.validate()
371
392
  Method used to access all form values in json format.
372
393
 
373
394
  ```js
374
- const form = Form({
395
+ const form = createForm({
375
396
  username: null
376
397
  })
377
398
 
@@ -385,7 +406,7 @@ axios.post('some-api', form.values())
385
406
  Method used to access all form values as form data.
386
407
 
387
408
  ```js
388
- const form = Form({
409
+ const form = createForm({
389
410
  username: null
390
411
  })
391
412
 
@@ -0,0 +1,6 @@
1
+ export * from './main'
2
+ export {}
3
+ import FormWrapper from './main'
4
+ export default FormWrapper
5
+ export * from './main'
6
+ export {}
package/dist/main.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Form } from './core/Form';
2
- declare const createForm: (data: any) => Form;
3
- export { createForm };
4
- export default Form;
1
+ import { Form as FormWrapper } from './core/Form';
2
+ export declare const createForm: (data: any) => FormWrapper;
3
+ export default FormWrapper;
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@keysdown/form-wrapper",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/*"
7
7
  ],
8
8
  "main": "./dist/form-wrapper.umd.cjs",
9
9
  "module": "./dist/form-wrapper.js",
10
- "types": "./dist/main.d.ts",
10
+ "types": "./dist/form-wrapper.d.ts",
11
11
  "exports": {
12
12
  ".": {
13
13
  "import": "./dist/form-wrapper.js",
14
14
  "require": "./dist/form-wrapper.umd.cjs",
15
- "types": "./dist/main.d.ts"
15
+ "types": "./dist/form-wrapper.d.ts"
16
16
  }
17
17
  },
18
18
  "scripts": {