@tanstack/vue-form 0.3.4 → 0.3.5
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/build/legacy/createFormFactory.cjs.map +1 -1
- package/build/legacy/createFormFactory.d.cts +1 -1
- package/build/legacy/createFormFactory.d.ts +1 -1
- package/build/legacy/createFormFactory.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/useField.cjs.map +1 -1
- package/build/legacy/useField.d.cts +16 -20
- package/build/legacy/useField.d.ts +16 -20
- package/build/legacy/useField.js +1 -3
- package/build/legacy/useField.js.map +1 -1
- package/build/legacy/useForm.cjs.map +1 -1
- package/build/legacy/useForm.d.cts +1 -1
- package/build/legacy/useForm.d.ts +1 -1
- package/build/legacy/useForm.js.map +1 -1
- package/build/modern/createFormFactory.cjs.map +1 -1
- package/build/modern/createFormFactory.d.cts +1 -1
- package/build/modern/createFormFactory.d.ts +1 -1
- package/build/modern/createFormFactory.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/useField.cjs.map +1 -1
- package/build/modern/useField.d.cts +16 -20
- package/build/modern/useField.d.ts +16 -20
- package/build/modern/useField.js +1 -3
- package/build/modern/useField.js.map +1 -1
- package/build/modern/useForm.cjs.map +1 -1
- package/build/modern/useForm.d.cts +1 -1
- package/build/modern/useForm.d.ts +1 -1
- package/build/modern/useForm.js.map +1 -1
- package/package.json +2 -2
- package/src/createFormFactory.ts +1 -1
- package/src/types.ts +3 -3
- package/src/useField.tsx +58 -55
- package/src/useForm.tsx +1 -1
- package/build/lib/createFormFactory.d.ts +0 -8
- package/build/lib/createFormFactory.js +0 -12
- package/build/lib/formContext.d.ts +0 -11
- package/build/lib/formContext.js +0 -12
- package/build/lib/index.d.ts +0 -5
- package/build/lib/index.js +0 -5
- package/build/lib/tests/useField.test.d.ts +0 -2
- package/build/lib/tests/useField.test.jsx +0 -109
- package/build/lib/tests/useForm.test.d.ts +0 -2
- package/build/lib/tests/useForm.test.jsx +0 -71
- package/build/lib/tests/utils.d.ts +0 -1
- package/build/lib/tests/utils.js +0 -5
- package/build/lib/types.d.ts +0 -4
- package/build/lib/types.js +0 -1
- package/build/lib/useField.d.ts +0 -42
- package/build/lib/useField.jsx +0 -41
- package/build/lib/useForm.d.ts +0 -19
- package/build/lib/useForm.jsx +0 -35
package/build/lib/useForm.d.ts
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import { FormApi, type FormState, type FormOptions } from '@tanstack/form-core';
|
2
|
-
import { type NoInfer } from '@tanstack/vue-store';
|
3
|
-
import { type UseField, type FieldComponent } from './useField';
|
4
|
-
import { type EmitsOptions, type SlotsType, type SetupContext } from 'vue-demi';
|
5
|
-
declare module '@tanstack/form-core' {
|
6
|
-
interface FormApi<TFormData> {
|
7
|
-
Provider: (props: Record<string, any> & {}) => any;
|
8
|
-
provideFormContext: () => void;
|
9
|
-
Field: FieldComponent<TFormData, TFormData>;
|
10
|
-
useField: UseField<TFormData>;
|
11
|
-
useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
|
12
|
-
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
|
13
|
-
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
|
14
|
-
}, context: SetupContext<EmitsOptions, SlotsType<{
|
15
|
-
default: NoInfer<FormState<TFormData>>;
|
16
|
-
}>>) => any;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
export declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
|
package/build/lib/useForm.jsx
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
import { FormApi } from '@tanstack/form-core';
|
2
|
-
import { useStore } from '@tanstack/vue-store';
|
3
|
-
import { Field, useField } from './useField';
|
4
|
-
import { provideFormContext } from './formContext';
|
5
|
-
import { defineComponent, } from 'vue-demi';
|
6
|
-
export function useForm(opts) {
|
7
|
-
const formApi = (() => {
|
8
|
-
const api = new FormApi(opts);
|
9
|
-
api.Provider = defineComponent((_, context) => {
|
10
|
-
provideFormContext({ formApi });
|
11
|
-
return () => context.slots.default();
|
12
|
-
}, { name: 'Provider' });
|
13
|
-
api.provideFormContext = () => {
|
14
|
-
provideFormContext({ formApi });
|
15
|
-
};
|
16
|
-
api.Field = Field;
|
17
|
-
api.useField = useField;
|
18
|
-
api.useStore = (selector) => {
|
19
|
-
return useStore(api.store, selector);
|
20
|
-
};
|
21
|
-
api.Subscribe = defineComponent((props, context) => {
|
22
|
-
const allProps = { ...props, ...context.attrs };
|
23
|
-
const selector = allProps.selector ?? ((state) => state);
|
24
|
-
const data = useStore(api.store, selector);
|
25
|
-
return () => context.slots.default(data.value);
|
26
|
-
}, {
|
27
|
-
name: 'Subscribe',
|
28
|
-
inheritAttrs: false,
|
29
|
-
});
|
30
|
-
return api;
|
31
|
-
})();
|
32
|
-
// formApi.useStore((state) => state.isSubmitting)
|
33
|
-
formApi.update(opts);
|
34
|
-
return formApi;
|
35
|
-
}
|