notform 3.0.1 → 4.0.0-alpha.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 (4) hide show
  1. package/README.md +14 -186
  2. package/dist/index.d.ts +459 -475
  3. package/dist/index.js +1103 -790
  4. package/package.json +19 -22
package/README.md CHANGED
@@ -1,195 +1,23 @@
1
- <p align="center">
2
- <img alt="header" src="https://shieldcn.dev/header/surface.svg?title=NotForm%28Core%29&amp;subtitle=Headless%2C+schema-agnostic+form+management+for+Vue+3&amp;logo=https%3A%2F%2Fnotformdocs.vercel.app%2Ffavicon.svg&amp;size=wide&amp;mode=dark&amp;font=fira-code" />
3
- </p>
1
+ <h1 align="center">
2
+ <img alt="NotForm Logo" loading="lazy" width="50" height="50" decoding="async" data-nimg="1" style="color:transparent" src="https://notformdocs.vercel.app/favicon.svg">
3
+ </br>
4
+ NotForm
5
+ </h1>
4
6
 
5
7
  <p align="center">
6
- <a href="https://www.npmjs.com/package/notform"><img alt="version" src="https://shieldcn.dev/npm/notform.svg?variant=secondary&amp;size=xs&amp;font=fira-code&amp;label=Version" /></a>
7
- <a href="https://www.npmjs.com/package/notform"><img alt="downloads" src="https://shieldcn.dev/npm/dm/notform.svg?variant=secondary&amp;size=xs&amp;font=fira-code&amp;label=Downloads" /></a>
8
- <a href="https://www.npmjs.com/package/notform"><img alt="Custom badge" src="https://shieldcn.dev/bundlephobia/min/notform.svg?variant=secondary&amp;size=xs&amp;font=fira-code&amp;label=Unpacked+Size" /></a>
8
+ Vue Forms Without the Friction.
9
9
  </p>
10
10
 
11
- `notform` is the core NotForm package for Vue 3.
12
-
13
- It provides reactive form state, schema-based validation, field state, submission handling, and renderless components that work with any UI you choose.
14
-
15
- ## Installation
16
-
17
- ```bash
18
- pnpm add notform
19
- ```
20
-
21
- Install a Standard Schema-compatible validator separately, for example:
22
-
23
- ```bash
24
- pnpm add zod
25
- ```
26
-
27
- ## Basic Usage
28
-
29
- ### Single Fields
30
-
31
- ```vue
32
- <script setup lang="ts">
33
- import { NotField, NotForm, NotMessage, useNotForm } from 'notform'
34
- import { z } from 'zod'
35
-
36
- const schema = z.object({
37
- email: z.email('Enter a valid email address'),
38
- name: z.string('Enter a valid name'),
39
- })
40
-
41
- const form = useNotForm({
42
- initialValues: {
43
- email: '',
44
- name: '',
45
- },
46
- onSubmit(values) {
47
- console.log('Submitted:', values)
48
- },
49
- schema,
50
- })
51
- </script>
52
-
53
- <template>
54
- <NotForm
55
- :form="form"
56
- @submit="form.submit"
57
- @reset="form.reset()"
58
- >
59
- <NotField
60
- v-slot="{ events, path }"
61
- path="name"
62
- >
63
- <div>
64
- <label :for="path">Name</label>
65
-
66
- <input
67
- :id="path"
68
- v-model="form.values.name"
69
- v-bind="events"
70
- name="name"
71
- type="text"
72
- autocomplete="name"
73
- >
74
-
75
- <NotMessage :path="path" />
76
- </div>
77
- </NotField>
78
-
79
- <NotField
80
- v-slot="{ events, path }"
81
- path="email"
82
- >
83
- <div>
84
- <label :for="path">Email address</label>
85
-
86
- <input
87
- :id="path"
88
- v-model="form.values.email"
89
- v-bind="events"
90
- name="email"
91
- type="email"
92
- autocomplete="email"
93
- >
94
-
95
- <NotMessage :path="path" />
96
- </div>
97
- </NotField>
98
-
99
- <button type="submit">
100
- Submit
101
- </button>
102
-
103
- <button type="reset">
104
- Reset
105
- </button>
106
- </NotForm>
107
- </template>
108
- ```
109
-
110
- ### Array Fields
111
-
112
- `NotArrayField` provides renderless operations for dynamic arrays while preserving stable item keys during reordering.
113
-
114
- ```vue
115
- <script setup lang="ts">
116
- import { NotArrayField, NotField, NotForm, NotMessage, useNotForm } from 'notform'
117
- import { z } from 'zod'
118
-
119
- const tagSchema = z.string()
120
-
121
- const schema = z.object({
122
- tags: z.array(tagSchema).optional(),
123
- })
124
-
125
- const form = useNotForm({
126
- initialValues: {
127
- tags: [''],
128
- },
129
- onSubmit(values) {
130
- console.log('Submitted:', values)
131
- },
132
- schema,
133
- })
134
- </script>
135
-
136
- <template>
137
- <NotForm
138
- :form="form"
139
- @submit="form.submit"
140
- @reset="form.reset()"
141
- >
142
- <NotArrayField
143
- v-slot="{ items, append, remove }"
144
- path="tags"
145
- :item-schema="tagSchema"
146
- >
147
- <div
148
- v-for="(item, index) in items"
149
- :key="item.key"
150
- >
151
- <NotField
152
- v-slot="{ events, path }"
153
- :path="item.path"
154
- >
155
- <label :for="path">Tag {{ index + 1 }}</label>
156
-
157
- <input
158
- :id="path"
159
- v-model="form.values.tags[index]"
160
- v-bind="events"
161
- :name="path"
162
- type="text"
163
- >
164
-
165
- <NotMessage :path="path" />
166
- </NotField>
167
-
168
- <button
169
- type="button"
170
- @click="remove(index)"
171
- >
172
- Remove
173
- </button>
174
- </div>
175
-
176
- <button
177
- type="button"
178
- @click="append('')"
179
- >
180
- Add tag
181
- </button>
182
- </NotArrayField>
183
- </NotForm>
184
- </template>
185
- ```
11
+ NotForm keeps your form's values, errors and field state in one place and leaves the markup to you. Describe the data with the schema library you already use, bind inputs, and read form states wherever you need them.
186
12
 
187
- ## Requirements
13
+ - **Bring your own schema.** Zod, Valibot, ArkType, or anything else that implements [Standard Schema](https://standardschema.dev). No adapters.
14
+ - **Typed safe.** Field paths, values, and method signatures are checked against your schema.
15
+ - **Dynamic arrays that behave.** Add, remove or reorder rows and each row keeps its touched state and its errors.
16
+ - **Safe async validation.** Auto disposal of inflight validation results making sure stale results cannot overwrite newer form state.
17
+ - **No UI imposed.** The components render a native `<form>` and, for errors, a `<span>` you can change. Everything else is yours.
188
18
 
189
- - Vue 3
190
- - Node.js 24 or later for development in this repository
191
- - A Standard Schema-compatible validator
19
+ See the [Documentation](https://notformdocs.vercel.app/) for validation, submission, and array-field guides.
192
20
 
193
21
  ## License
194
22
 
195
- [MIT](../../LICENSE) © [Favour Emeka](https://github.com/favorodera)
23
+ MIT © [Favour Emeka](https://github.com/favorodera)