@tanstack/vue-form 0.3.6 → 0.3.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-form",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Powerful, type-safe forms for Vue.",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  "@tanstack/store": "0.1.3",
46
46
  "@tanstack/vue-store": "0.1.3",
47
47
  "vue-demi": "^0.14.6",
48
- "@tanstack/form-core": "0.3.6"
48
+ "@tanstack/form-core": "0.3.7"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@vue/composition-api": "1.7.2",
@@ -68,7 +68,7 @@ describe('useForm', () => {
68
68
  form.provideFormContext()
69
69
 
70
70
  return () => (
71
- <form.Field name="firstName" defaultValue="">
71
+ <form.Field name="firstName">
72
72
  {({ field }: { field: FieldApi<Person, 'firstName'> }) => (
73
73
  <p>{field.state.value}</p>
74
74
  )}
@@ -81,6 +81,37 @@ describe('useForm', () => {
81
81
  expect(queryByText('LastName')).not.toBeInTheDocument()
82
82
  })
83
83
 
84
+ it('should use field default value first', async () => {
85
+ type Person = {
86
+ firstName: string
87
+ lastName: string
88
+ }
89
+
90
+ const formFactory = createFormFactory<Person>()
91
+
92
+ const Comp = defineComponent(() => {
93
+ const form = formFactory.useForm({
94
+ defaultValues: {
95
+ firstName: 'FirstName',
96
+ lastName: 'LastName',
97
+ },
98
+ })
99
+ form.provideFormContext()
100
+
101
+ return () => (
102
+ <form.Field name="firstName" defaultValue="otherName">
103
+ {({ field }: { field: FieldApi<Person, 'firstName'> }) => (
104
+ <p>{field.state.value}</p>
105
+ )}
106
+ </form.Field>
107
+ )
108
+ })
109
+
110
+ const { findByText, queryByText } = render(Comp)
111
+ expect(await findByText('otherName')).toBeInTheDocument()
112
+ expect(queryByText('LastName')).not.toBeInTheDocument()
113
+ })
114
+
84
115
  it('should handle submitting properly', async () => {
85
116
  const Comp = defineComponent(() => {
86
117
  const submittedData = ref<{ firstName: string }>()