Skip to content

Commit eda9802

Browse files
committed
chore: missed vue and svelte
1 parent 0ed4692 commit eda9802

2 files changed

Lines changed: 64 additions & 22 deletions

File tree

docs/framework/svelte/guides/basic-concepts.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,54 @@ Example:
7272

7373
## Field State
7474

75-
Each field has its own state, which includes its current value, validation status, error messages, and other metadata. You can access a field's state using the `field.state` property.
75+
Each field has its own state, which includes its current value, validation status, error messages, and other metadata. You can access a field's state using the `field().state` property.
7676

7777
Example:
7878

79-
```ts
79+
```tsx
8080
const {
8181
value,
8282
meta: { errors, isValidating },
83-
} = field.state
83+
} = field().state
8484
```
8585

8686
There are four states in the metadata that can be useful to see how the user interacts with a field:
8787

8888
- _"isTouched"_, after the user changes the field or blurs the field
89-
- _"isDirty"_, after the field's value has been changed, even if it's been reverted to the default. Opposite of _"isPristine"_
90-
- _"isBlurred"_, after the field has been blurred (exited)
91-
- _"isDefaultValue"_, whether the field's current value is the default value
89+
- _"isDirty"_, after the field's value has been changed, even if it's been reverted to the default. Opposite of `isPristine`
90+
- _"isPristine"_, until the user changes the field value. Opposite of `isDirty`
91+
- _"isBlurred"_, after the field has been blurred
92+
93+
```tsx
94+
const { isTouched, isDirty, isPristine, isBlurred } = field.state.meta
95+
```
9296

93-
There is also one additional derived state:
97+
![Field states](https://raw.githubusercontent.com/TanStack/form/main/docs/assets/field-states.png)
9498

95-
- _"isPristine"_, until the user changes the field value. Opposite of _"isDirty"_
99+
## Understanding 'isDirty' in Different Libraries
96100

97-
```ts
98-
const { isTouched, isDirty, isBlurred, isDefaultValue, isPristine } = field.state.meta
101+
Non-Persistent `dirty` state
102+
103+
- **Libraries**: React Hook Form (RHF), Formik, Final Form.
104+
- **Behavior**: A field is 'dirty' if its value differs from the default. Reverting to the default value makes it 'clean' again.
105+
106+
Persistent `dirty` state
107+
108+
- **Libraries**: Angular Form, Vue FormKit.
109+
- **Behavior**: A field remains 'dirty' once changed, even if reverted to the default value.
110+
111+
We have chosen the persistent 'dirty' state model. To also support a non-persistent 'dirty' state, we introduce an additional flag:
112+
113+
- _"isDefaultValue"_, whether the field's current value is the default value
114+
115+
```tsx
116+
const { isDefaultValue, isTouched } = field.state.meta
117+
118+
// The following line will re-create the non-Persistent `dirty` functionality.
119+
const nonPersistentIsDirty = !isDefaultValue
99120
```
100121

101-
![Field states](https://raw.githubusercontent.com/TanStack/form/main/docs/assets/field-states.png)
122+
![Field states extended](https://raw.githubusercontent.com/TanStack/form/main/docs/assets/field-states-extended.png)
102123

103124
## Field API
104125

docs/framework/vue/guides/basic-concepts.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,33 +76,54 @@ Example:
7676

7777
## Field State
7878

79-
Each field has its own state, which includes its current value, validation status, error messages, and other metadata. You can access a field's state using the `field.state` property.
79+
Each field has its own state, which includes its current value, validation status, error messages, and other metadata. You can access a field's state using the `field().state` property.
8080

8181
Example:
8282

83-
```js
83+
```tsx
8484
const {
8585
value,
8686
meta: { errors, isValidating },
87-
} = field.state
87+
} = field().state
8888
```
8989

9090
There are four states in the metadata that can be useful to see how the user interacts with a field:
9191

9292
- _"isTouched"_, after the user changes the field or blurs the field
93-
- _"isDirty"_, after the field's value has been changed, even if it's been reverted to the default. Opposite of _"isPristine"_
94-
- _"isBlurred"_, after the field has been blurred (exited)
95-
- _"isDefaultValue"_, whether the field's current value is the default value
93+
- _"isDirty"_, after the field's value has been changed, even if it's been reverted to the default. Opposite of `isPristine`
94+
- _"isPristine"_, until the user changes the field value. Opposite of `isDirty`
95+
- _"isBlurred"_, after the field has been blurred
96+
97+
```tsx
98+
const { isTouched, isDirty, isPristine, isBlurred } = field.state.meta
99+
```
96100

97-
There is also one additional derived state:
101+
![Field states](https://raw.githubusercontent.com/TanStack/form/main/docs/assets/field-states.png)
98102

99-
- _"isPristine"_, until the user changes the field value. Opposite of _"isDirty"_
103+
## Understanding 'isDirty' in Different Libraries
100104

101-
```js
102-
const { isTouched, isDirty, isBlurred, isDefaultValue, isPristine } = field.state.meta
105+
Non-Persistent `dirty` state
106+
107+
- **Libraries**: React Hook Form (RHF), Formik, Final Form.
108+
- **Behavior**: A field is 'dirty' if its value differs from the default. Reverting to the default value makes it 'clean' again.
109+
110+
Persistent `dirty` state
111+
112+
- **Libraries**: Angular Form, Vue FormKit.
113+
- **Behavior**: A field remains 'dirty' once changed, even if reverted to the default value.
114+
115+
We have chosen the persistent 'dirty' state model. To also support a non-persistent 'dirty' state, we introduce an additional flag:
116+
117+
- _"isDefaultValue"_, whether the field's current value is the default value
118+
119+
```tsx
120+
const { isDefaultValue, isTouched } = field.state.meta
121+
122+
// The following line will re-create the non-Persistent `dirty` functionality.
123+
const nonPersistentIsDirty = !isDefaultValue
103124
```
104125

105-
![Field states](https://raw.githubusercontent.com/TanStack/form/main/docs/assets/field-states.png)
126+
![Field states extended](https://raw.githubusercontent.com/TanStack/form/main/docs/assets/field-states-extended.png)
106127

107128
## Field API
108129

0 commit comments

Comments
 (0)