@tanstack/svelte-form 1.31.0 → 1.32.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/dist/Field.svelte +51 -2
- package/package.json +2 -2
- package/src/Field.svelte +51 -2
package/dist/Field.svelte
CHANGED
|
@@ -96,10 +96,59 @@
|
|
|
96
96
|
api.update(current)
|
|
97
97
|
})
|
|
98
98
|
|
|
99
|
-
const storeSub = useStore(api.store)
|
|
99
|
+
const storeSub = useStore(api.store, (state) =>
|
|
100
|
+
options.mode === 'array'
|
|
101
|
+
? state.meta._arrayVersion || 0
|
|
102
|
+
: state.value,
|
|
103
|
+
)
|
|
104
|
+
const metaIsTouchedSub = useStore(
|
|
105
|
+
api.store,
|
|
106
|
+
(state) => state.meta.isTouched,
|
|
107
|
+
)
|
|
108
|
+
const metaIsBlurredSub = useStore(
|
|
109
|
+
api.store,
|
|
110
|
+
(state) => state.meta.isBlurred,
|
|
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(
|
|
115
|
+
api.store,
|
|
116
|
+
(state) => state.meta.errorSourceMap,
|
|
117
|
+
)
|
|
118
|
+
const metaIsValidatingSub = useStore(
|
|
119
|
+
api.store,
|
|
120
|
+
(state) => state.meta.isValidating,
|
|
121
|
+
)
|
|
100
122
|
Object.defineProperty(extendedApi, 'state', {
|
|
101
123
|
get() {
|
|
102
|
-
|
|
124
|
+
// Read all reactive sources to track them as dependencies. For array
|
|
125
|
+
// mode, `storeSub.current` is the array length so we still pull the
|
|
126
|
+
// actual value from the underlying api state.
|
|
127
|
+
// See: https://github.com/TanStack/form/issues/1961
|
|
128
|
+
// Note: we read from `api.store.state` (not `api.state`) to avoid
|
|
129
|
+
// infinite recursion since this getter shadows the prototype's `state`
|
|
130
|
+
// getter on the same object.
|
|
131
|
+
const trackedValue = storeSub.current
|
|
132
|
+
const isTouched = metaIsTouchedSub.current
|
|
133
|
+
const isBlurred = metaIsBlurredSub.current
|
|
134
|
+
const isDirty = metaIsDirtySub.current
|
|
135
|
+
const errorMap = metaErrorMapSub.current
|
|
136
|
+
const errorSourceMap = metaErrorSourceMapSub.current
|
|
137
|
+
const isValidating = metaIsValidatingSub.current
|
|
138
|
+
const baseState = api.store.state
|
|
139
|
+
return {
|
|
140
|
+
...baseState,
|
|
141
|
+
value: options.mode === 'array' ? baseState.value : trackedValue,
|
|
142
|
+
meta: {
|
|
143
|
+
...baseState.meta,
|
|
144
|
+
isTouched,
|
|
145
|
+
isBlurred,
|
|
146
|
+
isDirty,
|
|
147
|
+
errorMap,
|
|
148
|
+
errorSourceMap,
|
|
149
|
+
isValidating,
|
|
150
|
+
},
|
|
151
|
+
}
|
|
103
152
|
},
|
|
104
153
|
})
|
|
105
154
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-form",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.0",
|
|
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.10.1",
|
|
35
|
-
"@tanstack/form-core": "1.
|
|
35
|
+
"@tanstack/form-core": "1.32.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@sveltejs/package": "^2.5.3",
|
package/src/Field.svelte
CHANGED
|
@@ -96,10 +96,59 @@
|
|
|
96
96
|
api.update(current)
|
|
97
97
|
})
|
|
98
98
|
|
|
99
|
-
const storeSub = useStore(api.store)
|
|
99
|
+
const storeSub = useStore(api.store, (state) =>
|
|
100
|
+
options.mode === 'array'
|
|
101
|
+
? state.meta._arrayVersion || 0
|
|
102
|
+
: state.value,
|
|
103
|
+
)
|
|
104
|
+
const metaIsTouchedSub = useStore(
|
|
105
|
+
api.store,
|
|
106
|
+
(state) => state.meta.isTouched,
|
|
107
|
+
)
|
|
108
|
+
const metaIsBlurredSub = useStore(
|
|
109
|
+
api.store,
|
|
110
|
+
(state) => state.meta.isBlurred,
|
|
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(
|
|
115
|
+
api.store,
|
|
116
|
+
(state) => state.meta.errorSourceMap,
|
|
117
|
+
)
|
|
118
|
+
const metaIsValidatingSub = useStore(
|
|
119
|
+
api.store,
|
|
120
|
+
(state) => state.meta.isValidating,
|
|
121
|
+
)
|
|
100
122
|
Object.defineProperty(extendedApi, 'state', {
|
|
101
123
|
get() {
|
|
102
|
-
|
|
124
|
+
// Read all reactive sources to track them as dependencies. For array
|
|
125
|
+
// mode, `storeSub.current` is the array length so we still pull the
|
|
126
|
+
// actual value from the underlying api state.
|
|
127
|
+
// See: https://github.com/TanStack/form/issues/1961
|
|
128
|
+
// Note: we read from `api.store.state` (not `api.state`) to avoid
|
|
129
|
+
// infinite recursion since this getter shadows the prototype's `state`
|
|
130
|
+
// getter on the same object.
|
|
131
|
+
const trackedValue = storeSub.current
|
|
132
|
+
const isTouched = metaIsTouchedSub.current
|
|
133
|
+
const isBlurred = metaIsBlurredSub.current
|
|
134
|
+
const isDirty = metaIsDirtySub.current
|
|
135
|
+
const errorMap = metaErrorMapSub.current
|
|
136
|
+
const errorSourceMap = metaErrorSourceMapSub.current
|
|
137
|
+
const isValidating = metaIsValidatingSub.current
|
|
138
|
+
const baseState = api.store.state
|
|
139
|
+
return {
|
|
140
|
+
...baseState,
|
|
141
|
+
value: options.mode === 'array' ? baseState.value : trackedValue,
|
|
142
|
+
meta: {
|
|
143
|
+
...baseState.meta,
|
|
144
|
+
isTouched,
|
|
145
|
+
isBlurred,
|
|
146
|
+
isDirty,
|
|
147
|
+
errorMap,
|
|
148
|
+
errorSourceMap,
|
|
149
|
+
isValidating,
|
|
150
|
+
},
|
|
151
|
+
}
|
|
103
152
|
},
|
|
104
153
|
})
|
|
105
154
|
|