|
1 | 1 | # formsnap
|
2 | 2 |
|
| 3 | +## 2.0.0 |
| 4 | + |
| 5 | +### Major Changes |
| 6 | + |
| 7 | +- Formsnap v2 - See [Migration Guide](https://formsnap.dev/docs/v2-migration-guide) ([#177](https://github.com/svecosystem/formsnap/pull/177)) |
| 8 | + |
3 | 9 | ## 2.0.0-next.1
|
4 | 10 |
|
5 | 11 | ### Patch Changes
|
|
102 | 108 |
|
103 | 109 | ### Minor Changes
|
104 | 110 |
|
105 |
| -- - Add utility function `getFormSchema()` ([#62](https://github.com/huntabyte/formsnap/pull/62)) |
| 111 | +- - Add utility function `getFormSchema()` ([#62](https://github.com/huntabyte/formsnap/pull/62)) |
106 | 112 |
|
107 | 113 | ## 0.1.4
|
108 | 114 |
|
|
135 | 141 | ### Minor Changes
|
136 | 142 |
|
137 | 143 | - 83dcbbd: - Add `getForm` helper
|
138 |
| - - Fix bug which was creating large `.d.ts` files and crashing editors |
| 144 | + - Fix bug which was creating large `.d.ts` files and crashing editors |
139 | 145 |
|
140 | 146 | ## 0.0.9
|
141 | 147 |
|
|
180 | 186 | - 0801f7d: Add the `handlers` object containing the event handler helpers as well as the `setValue` helper function to the `getFormField` return object.
|
181 | 187 | - 748f8e8: #### Add a `getFormField` helper function
|
182 | 188 |
|
183 |
| - The `getFormField` helper function must be called upon component initialization and provides some useful stores, actions, etc. when composing your own forms. |
184 |
| - For example, if I wanted to create a reusable `Form.Label` with conditional styles applied to it depending on the error state of the field, I could do something like this: |
185 |
| - |
186 |
| - ```svelte |
187 |
| - <!-- CustomLabel.svelte --> |
188 |
| - <script lang="ts"> |
189 |
| - import { Form, getFormField } from 'formsnap'; |
190 |
| - const { errors } = getFormField(); |
191 |
| - </script> |
192 |
| -
|
193 |
| - <Form.Label class={$errors ? 'text-red-500' : 'text-gray-800'}> |
194 |
| - <slot /> |
195 |
| - </Form.Label> |
196 |
| - ``` |
197 |
| - |
198 |
| - It returns the following type: |
199 |
| - |
200 |
| - ```ts |
201 |
| - export type FormFieldContext = { |
202 |
| - name: string; |
203 |
| - ids: { |
204 |
| - input: string; |
205 |
| - description: string; |
206 |
| - validation: string; |
| 189 | + The `getFormField` helper function must be called upon component initialization and provides some useful stores, actions, etc. when composing your own forms. |
| 190 | + For example, if I wanted to create a reusable `Form.Label` with conditional styles applied to it depending on the error state of the field, I could do something like this: |
| 191 | + |
| 192 | + ```svelte |
| 193 | + <!-- CustomLabel.svelte --> |
| 194 | + <script lang="ts"> |
| 195 | + import { Form, getFormField } from "formsnap"; |
| 196 | + const { errors } = getFormField(); |
| 197 | + </script> |
| 198 | +
|
| 199 | + <Form.Label class={$errors ? "text-red-500" : "text-gray-800"}> |
| 200 | + <slot /> |
| 201 | + </Form.Label> |
| 202 | + ``` |
| 203 | +
|
| 204 | + It returns the following type: |
| 205 | +
|
| 206 | + ```ts |
| 207 | + export type FormFieldContext = { |
| 208 | + name: string; |
| 209 | + ids: { |
| 210 | + input: string; |
| 211 | + description: string; |
| 212 | + validation: string; |
| 213 | + }; |
| 214 | + errors: Writable<string[] | undefined>; |
| 215 | + value: Writable<unknown>; |
| 216 | + hasDescription: Writable<boolean>; |
| 217 | + hasValidation: Writable<boolean>; |
| 218 | + attrStore: AttrStore; |
| 219 | + actions: ActionsObject; |
207 | 220 | };
|
208 |
| - errors: Writable<string[] | undefined>; |
209 |
| - value: Writable<unknown>; |
210 |
| - hasDescription: Writable<boolean>; |
211 |
| - hasValidation: Writable<boolean>; |
212 |
| - attrStore: AttrStore; |
213 |
| - actions: ActionsObject; |
214 |
| - }; |
215 |
| - ``` |
| 221 | + ``` |
216 | 222 |
|
217 | 223 | ## 0.0.2
|
218 | 224 |
|
219 | 225 | ### Patch Changes
|
220 | 226 |
|
221 | 227 | - 8596892: Exposes the following additional values from superforms as slot props via the `<Form.Root/>` component.
|
222 | 228 |
|
223 |
| - - `allErrors` |
224 |
| - - `delayed` |
225 |
| - - `errors` |
226 |
| - - `submitting` |
227 |
| - - `tainted` |
228 |
| - - `timeout` |
229 |
| - - `validate` |
230 |
| - - `posted` |
231 |
| - - `fields` |
232 |
| - - `message` |
233 |
| - - `options` |
234 |
| - - `formId` |
235 |
| - - `restore` |
236 |
| - - `capture` |
237 |
| - - `constraints` |
| 229 | + - `allErrors` |
| 230 | + - `delayed` |
| 231 | + - `errors` |
| 232 | + - `submitting` |
| 233 | + - `tainted` |
| 234 | + - `timeout` |
| 235 | + - `validate` |
| 236 | + - `posted` |
| 237 | + - `fields` |
| 238 | + - `message` |
| 239 | + - `options` |
| 240 | + - `formId` |
| 241 | + - `restore` |
| 242 | + - `capture` |
| 243 | + - `constraints` |
238 | 244 |
|
239 | 245 | ## 0.0.1
|
240 | 246 |
|
|
0 commit comments