@tanstack/svelte-form 1.33.0 → 1.33.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.
package/dist/Field.svelte CHANGED
@@ -8,7 +8,7 @@
8
8
  type FormAsyncValidateOrFn,
9
9
  type FormValidateOrFn,
10
10
  } from '@tanstack/form-core'
11
- import { useStore } from '@tanstack/svelte-store'
11
+ import { useSelector } from '@tanstack/svelte-store'
12
12
  import { onMount, type Snippet } from 'svelte'
13
13
  import type { CreateFieldOptions } from './types.js'
14
14
 
@@ -96,26 +96,26 @@
96
96
  api.update(current)
97
97
  })
98
98
 
99
- const storeSub = useStore(api.store, (state) =>
99
+ const storeSub = useSelector(api.store, (state) =>
100
100
  options.mode === 'array'
101
101
  ? state.meta._arrayVersion || 0
102
102
  : state.value,
103
103
  )
104
- const metaIsTouchedSub = useStore(
104
+ const metaIsTouchedSub = useSelector(
105
105
  api.store,
106
106
  (state) => state.meta.isTouched,
107
107
  )
108
- const metaIsBlurredSub = useStore(
108
+ const metaIsBlurredSub = useSelector(
109
109
  api.store,
110
110
  (state) => state.meta.isBlurred,
111
111
  )
112
- const metaIsDirtySub = useStore(api.store, (state) => state.meta.isDirty)
113
- const metaErrorMapSub = useStore(api.store, (state) => state.meta.errorMap)
114
- const metaErrorSourceMapSub = useStore(
112
+ const metaIsDirtySub = useSelector(api.store, (state) => state.meta.isDirty)
113
+ const metaErrorMapSub = useSelector(api.store, (state) => state.meta.errorMap)
114
+ const metaErrorSourceMapSub = useSelector(
115
115
  api.store,
116
116
  (state) => state.meta.errorSourceMap,
117
117
  )
118
- const metaIsValidatingSub = useStore(
118
+ const metaIsValidatingSub = useSelector(
119
119
  api.store,
120
120
  (state) => state.meta.isValidating,
121
121
  )
@@ -9,7 +9,7 @@
9
9
  type FormAsyncValidateOrFn,
10
10
  type FormValidateOrFn,
11
11
  } from '@tanstack/form-core'
12
- import { useStore } from '@tanstack/svelte-store'
12
+ import { useSelector } from '@tanstack/svelte-store'
13
13
  import { onMount, type Snippet } from 'svelte'
14
14
 
15
15
  export function createFormGroup<
@@ -108,7 +108,7 @@
108
108
  api.update(current)
109
109
  })
110
110
 
111
- const storeSub = useStore(api.store)
111
+ const storeSub = useSelector(api.store)
112
112
  Object.defineProperty(extendedApi, 'state', {
113
113
  get() {
114
114
  return storeSub.current
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { useStore } from '@tanstack/svelte-store'
2
+ import { useSelector } from '@tanstack/svelte-store'
3
3
 
4
4
  // Don't bother typing this out, this component is only usable through a wrapper
5
5
  interface Props {
@@ -10,7 +10,7 @@
10
10
 
11
11
  let { children, store, selector = (state) => state }: Props = $props()
12
12
 
13
- const value = useStore(store, selector)
13
+ const value = useSelector(store, selector)
14
14
  </script>
15
15
 
16
16
  {@render children(value.current)}
@@ -5,6 +5,12 @@ import type { FieldComponent, FormGroupComponent, WithoutFunction } from './type
5
5
  export interface SvelteFormApi<TParentData, TFormOnMount extends undefined | FormValidateOrFn<TParentData>, TFormOnChange extends undefined | FormValidateOrFn<TParentData>, TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnBlur extends undefined | FormValidateOrFn<TParentData>, TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>, TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>, TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>, TSubmitMeta> {
6
6
  Field: FieldComponent<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TSubmitMeta>;
7
7
  FormGroup: FormGroupComponent<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TSubmitMeta>;
8
+ useSelector: <TSelected = NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>>(selector?: (state: NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>) => TSelected) => {
9
+ current: TSelected;
10
+ };
11
+ /**
12
+ * @deprecated Use `form.useSelector` instead.
13
+ */
8
14
  useStore: <TSelected = NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>>(selector?: (state: NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>) => TSelected) => {
9
15
  current: TSelected;
10
16
  };
@@ -1,5 +1,5 @@
1
1
  import { FormApi } from '@tanstack/form-core';
2
- import { useStore } from '@tanstack/svelte-store';
2
+ import { useSelector } from '@tanstack/svelte-store';
3
3
  import { onMount } from 'svelte';
4
4
  import Field from './Field.svelte';
5
5
  import FormGroup from './FormGroup.svelte';
@@ -12,7 +12,9 @@ export function createForm(opts) {
12
12
  extendedApi.Field = (internal, props) => Field(internal, { ...props, form: api });
13
13
  // @ts-expect-error constructor definition exists only on a type level
14
14
  extendedApi.FormGroup = (internal, props) => FormGroup(internal, { ...props, form: api });
15
- extendedApi.useStore = (selector) => useStore(api.store, selector);
15
+ extendedApi.useSelector = (selector) => useSelector(api.store, selector);
16
+ /** @deprecated Use `form.useSelector` instead. */
17
+ extendedApi.useStore = extendedApi.useSelector;
16
18
  // @ts-expect-error constructor definition exists only on a type level
17
19
  extendedApi.Subscribe = (internal, props) => Subscribe(internal, { ...props, store: api.store });
18
20
  onMount(api.mount);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from '@tanstack/form-core';
2
- export { useStore } from '@tanstack/svelte-store';
2
+ export { useSelector, useStore } from '@tanstack/svelte-store';
3
3
  export { createForm, type SvelteFormApi } from './createForm.svelte.js';
4
4
  export { default as Field, createField } from './Field.svelte';
5
5
  export { default as FormGroup, createFormGroup } from './FormGroup.svelte';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from '@tanstack/form-core';
2
- export { useStore } from '@tanstack/svelte-store';
2
+ export { useSelector, useStore } from '@tanstack/svelte-store';
3
3
  export { createForm } from './createForm.svelte.js';
4
4
  export { default as Field, createField } from './Field.svelte';
5
5
  export { default as FormGroup, createFormGroup } from './FormGroup.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/svelte-form",
3
- "version": "1.33.0",
3
+ "version": "1.33.1",
4
4
  "description": "Powerful, type-safe forms for Svelte.",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@tanstack/svelte-store": "^0.12.0",
35
- "@tanstack/form-core": "1.33.0"
35
+ "@tanstack/form-core": "1.33.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@sveltejs/package": "^2.5.3",
package/src/Field.svelte CHANGED
@@ -8,7 +8,7 @@
8
8
  type FormAsyncValidateOrFn,
9
9
  type FormValidateOrFn,
10
10
  } from '@tanstack/form-core'
11
- import { useStore } from '@tanstack/svelte-store'
11
+ import { useSelector } from '@tanstack/svelte-store'
12
12
  import { onMount, type Snippet } from 'svelte'
13
13
  import type { CreateFieldOptions } from './types.js'
14
14
 
@@ -96,26 +96,26 @@
96
96
  api.update(current)
97
97
  })
98
98
 
99
- const storeSub = useStore(api.store, (state) =>
99
+ const storeSub = useSelector(api.store, (state) =>
100
100
  options.mode === 'array'
101
101
  ? state.meta._arrayVersion || 0
102
102
  : state.value,
103
103
  )
104
- const metaIsTouchedSub = useStore(
104
+ const metaIsTouchedSub = useSelector(
105
105
  api.store,
106
106
  (state) => state.meta.isTouched,
107
107
  )
108
- const metaIsBlurredSub = useStore(
108
+ const metaIsBlurredSub = useSelector(
109
109
  api.store,
110
110
  (state) => state.meta.isBlurred,
111
111
  )
112
- const metaIsDirtySub = useStore(api.store, (state) => state.meta.isDirty)
113
- const metaErrorMapSub = useStore(api.store, (state) => state.meta.errorMap)
114
- const metaErrorSourceMapSub = useStore(
112
+ const metaIsDirtySub = useSelector(api.store, (state) => state.meta.isDirty)
113
+ const metaErrorMapSub = useSelector(api.store, (state) => state.meta.errorMap)
114
+ const metaErrorSourceMapSub = useSelector(
115
115
  api.store,
116
116
  (state) => state.meta.errorSourceMap,
117
117
  )
118
- const metaIsValidatingSub = useStore(
118
+ const metaIsValidatingSub = useSelector(
119
119
  api.store,
120
120
  (state) => state.meta.isValidating,
121
121
  )
@@ -9,7 +9,7 @@
9
9
  type FormAsyncValidateOrFn,
10
10
  type FormValidateOrFn,
11
11
  } from '@tanstack/form-core'
12
- import { useStore } from '@tanstack/svelte-store'
12
+ import { useSelector } from '@tanstack/svelte-store'
13
13
  import { onMount, type Snippet } from 'svelte'
14
14
 
15
15
  export function createFormGroup<
@@ -108,7 +108,7 @@
108
108
  api.update(current)
109
109
  })
110
110
 
111
- const storeSub = useStore(api.store)
111
+ const storeSub = useSelector(api.store)
112
112
  Object.defineProperty(extendedApi, 'state', {
113
113
  get() {
114
114
  return storeSub.current
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { useStore } from '@tanstack/svelte-store'
2
+ import { useSelector } from '@tanstack/svelte-store'
3
3
 
4
4
  // Don't bother typing this out, this component is only usable through a wrapper
5
5
  interface Props {
@@ -10,7 +10,7 @@
10
10
 
11
11
  let { children, store, selector = (state) => state }: Props = $props()
12
12
 
13
- const value = useStore(store, selector)
13
+ const value = useSelector(store, selector)
14
14
  </script>
15
15
 
16
16
  {@render children(value.current)}
@@ -1,5 +1,5 @@
1
1
  import { FormApi } from '@tanstack/form-core'
2
- import { useStore } from '@tanstack/svelte-store'
2
+ import { useSelector } from '@tanstack/svelte-store'
3
3
  import { onMount } from 'svelte'
4
4
  import Field from './Field.svelte'
5
5
  import FormGroup from './FormGroup.svelte'
@@ -64,6 +64,44 @@ export interface SvelteFormApi<
64
64
  TFormOnServer,
65
65
  TSubmitMeta
66
66
  >
67
+ useSelector: <
68
+ TSelected = NoInfer<
69
+ FormState<
70
+ TParentData,
71
+ TFormOnMount,
72
+ TFormOnChange,
73
+ TFormOnChangeAsync,
74
+ TFormOnBlur,
75
+ TFormOnBlurAsync,
76
+ TFormOnSubmit,
77
+ TFormOnSubmitAsync,
78
+ TFormOnDynamic,
79
+ TFormOnDynamicAsync,
80
+ TFormOnServer
81
+ >
82
+ >,
83
+ >(
84
+ selector?: (
85
+ state: NoInfer<
86
+ FormState<
87
+ TParentData,
88
+ TFormOnMount,
89
+ TFormOnChange,
90
+ TFormOnChangeAsync,
91
+ TFormOnBlur,
92
+ TFormOnBlurAsync,
93
+ TFormOnSubmit,
94
+ TFormOnSubmitAsync,
95
+ TFormOnDynamic,
96
+ TFormOnDynamicAsync,
97
+ TFormOnServer
98
+ >
99
+ >,
100
+ ) => TSelected,
101
+ ) => { current: TSelected }
102
+ /**
103
+ * @deprecated Use `form.useSelector` instead.
104
+ */
67
105
  useStore: <
68
106
  TSelected = NoInfer<
69
107
  FormState<
@@ -295,7 +333,9 @@ export function createForm<
295
333
  // @ts-expect-error constructor definition exists only on a type level
296
334
  extendedApi.FormGroup = (internal, props) =>
297
335
  FormGroup(internal, { ...props, form: api as never } as never)
298
- extendedApi.useStore = (selector) => useStore(api.store, selector)
336
+ extendedApi.useSelector = (selector) => useSelector(api.store, selector)
337
+ /** @deprecated Use `form.useSelector` instead. */
338
+ extendedApi.useStore = extendedApi.useSelector
299
339
  // @ts-expect-error constructor definition exists only on a type level
300
340
  extendedApi.Subscribe = (internal, props) =>
301
341
  Subscribe(internal, { ...props, store: api.store })
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from '@tanstack/form-core'
2
2
 
3
- export { useStore } from '@tanstack/svelte-store'
3
+ export { useSelector, useStore } from '@tanstack/svelte-store'
4
4
 
5
5
  export { createForm, type SvelteFormApi } from './createForm.svelte.js'
6
6