Skip to content

Commit 674ee5a

Browse files
committed
Allow getter as inputs for vue
1 parent 413c6d0 commit 674ee5a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/vue/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { cloneDeep, get, set } from 'lodash-es'
55

66
export { client }
77

8-
export const useForm = <Data extends Record<string, unknown>>(method: RequestMethod | (() => RequestMethod), url: string | (() => string), inputs: Data, config: ValidationConfig = {}): Data & Form<Data> => {
8+
export const useForm = <Data extends Record<string, unknown>>(method: RequestMethod | (() => RequestMethod), url: string | (() => string), inputs: Data | (() => Data), config: ValidationConfig = {}): Data & Form<Data> => {
99
/**
1010
* The original data.
1111
*/
12-
const originalData = cloneDeep(inputs)
12+
const originalData = typeof inputs === 'function' ? cloneDeep(inputs()) : cloneDeep(inputs)
1313

1414
/**
1515
* The original input names.
@@ -143,7 +143,7 @@ export const useForm = <Data extends Record<string, unknown>>(method: RequestMet
143143
return form
144144
},
145145
reset(...names) {
146-
const original = cloneDeep(originalData)
146+
const original = typeof inputs === 'function' ? cloneDeep(inputs()) : cloneDeep(originalData)
147147

148148
if (names.length === 0) {
149149
// @ts-expect-error

0 commit comments

Comments
 (0)