Skip to content

Commit 98e3cc5

Browse files
authored
feat: Add blurred state to devtools (#229)
* chore: include blurred state in the devtools * chore: add changeset
1 parent 3d3a371 commit 98e3cc5

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

.changeset/fast-nights-peel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@formwerk/devtools': minor
3+
---
4+
5+
Enhance the devtools to include blurred state at the form and field level

packages/devtools/src/helpers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export function buildFieldState(state: FieldState | PathState): CustomInspectorS
2929
key: 'touched',
3030
value: state.touched,
3131
},
32+
{
33+
key: 'blurred',
34+
value: state.blurred,
35+
},
3236
{
3337
key: 'dirty',
3438
value: state.dirty,
@@ -56,6 +60,10 @@ export function buildFormState(form: FormState): CustomInspectorState {
5660
key: 'touched',
5761
value: form.touched,
5862
},
63+
{
64+
key: 'blurred',
65+
value: form.blurred,
66+
},
5967
{
6068
key: 'dirty',
6169
value: form.dirty,
@@ -152,6 +160,7 @@ export function decodeNode(nodeId: string): NodeState | null {
152160
path: idObject.fp,
153161
formId: idObject.f,
154162
touched: form.isTouched(idObject.fp),
163+
blurred: form.isBlurred(idObject.fp),
155164
dirty: form.isDirty(idObject.fp),
156165
valid: form.isValid(idObject.fp),
157166
errors: form.getErrors(idObject.fp),
@@ -278,6 +287,7 @@ export function buildFormTree(
278287
const nodeState: PathState = {
279288
formId: form.context.id,
280289
dirty: form.isDirty(fullPath),
290+
blurred: form.isBlurred(fullPath),
281291
valid: form.isValid(fullPath),
282292
errors: form.getErrors(fullPath),
283293
value: form.getValue(fullPath),

packages/devtools/src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ComponentInternalInstance, MaybeRefOrGetter } from 'vue';
33

44
interface BaseState<TValue = unknown> {
55
touched: boolean;
6+
blurred: boolean;
67
dirty: boolean;
78
valid: boolean;
89
errors: string[];
@@ -66,6 +67,7 @@ export function formToState(form: FormReturns): FormState {
6667
return {
6768
id: form.context.id,
6869
touched: form.isTouched(),
70+
blurred: form.isBlurred(),
6971
dirty: form.isDirty(),
7072
isSubmitting: form.isSubmitting.value,
7173
submitCount: form.submitAttemptsCount.value,
@@ -82,6 +84,7 @@ export function fieldToState(field: CoreFieldState<unknown>, formId?: string): F
8284
path: field.getPath() ?? '',
8385
name: field.getName() ?? '',
8486
touched: field.isTouched.value,
87+
blurred: field.isBlurred.value,
8588
dirty: field.isDirty.value,
8689
valid: !!field.isValid.value,
8790
value: field.fieldValue,

0 commit comments

Comments
 (0)