@tanstack/vue-form 0.13.0 → 0.13.1
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/dist/cjs/createFormFactory.cjs +16 -0
- package/dist/cjs/createFormFactory.cjs.map +1 -0
- package/dist/cjs/formContext.cjs +18 -0
- package/dist/cjs/formContext.cjs.map +1 -0
- package/dist/cjs/index.cjs +11 -108
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/useField.cjs +50 -0
- package/dist/cjs/useField.cjs.map +1 -0
- package/dist/cjs/useForm.cjs +46 -0
- package/dist/cjs/useForm.cjs.map +1 -0
- package/dist/esm/createFormFactory.js +16 -0
- package/dist/esm/createFormFactory.js.map +1 -0
- package/dist/esm/formContext.js +18 -0
- package/dist/esm/formContext.js.map +1 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/useField.js +50 -0
- package/dist/esm/useField.js.map +1 -0
- package/dist/esm/useForm.js +46 -0
- package/dist/esm/useForm.js.map +1 -0
- package/package.json +11 -11
- package/dist/cjs/index.js +0 -119
- package/dist/cjs/tests/useField.test.d.ts +0 -1
- package/dist/cjs/tests/useForm.test.d.ts +0 -1
- package/dist/cjs/tests/utils.d.ts +0 -1
- package/dist/mjs/index.d.mts +0 -5
- package/dist/mjs/index.d.ts +0 -5
- package/dist/mjs/index.js +0 -113
- package/dist/mjs/index.mjs +0 -113
- package/dist/mjs/index.mjs.map +0 -1
- package/dist/mjs/tests/useField.test.d.ts +0 -1
- package/dist/mjs/tests/useForm.test.d.ts +0 -1
- package/dist/mjs/tests/utils.d.ts +0 -1
- /package/dist/cjs/{createFormFactory.d.ts → createFormFactory.d.cts} +0 -0
- /package/dist/cjs/{formContext.d.ts → formContext.d.cts} +0 -0
- /package/dist/cjs/{types.d.ts → types.d.cts} +0 -0
- /package/dist/cjs/{useField.d.ts → useField.d.cts} +0 -0
- /package/dist/cjs/{useForm.d.ts → useForm.d.cts} +0 -0
- /package/dist/{mjs → esm}/createFormFactory.d.ts +0 -0
- /package/dist/{mjs → esm}/formContext.d.ts +0 -0
- /package/dist/{cjs → esm}/index.d.ts +0 -0
- /package/dist/{mjs → esm}/types.d.ts +0 -0
- /package/dist/{mjs → esm}/useField.d.ts +0 -0
- /package/dist/{mjs → esm}/useForm.d.ts +0 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const useField = require("./useField.cjs");
|
4
|
+
const useForm = require("./useForm.cjs");
|
5
|
+
function createFormFactory(defaultOpts) {
|
6
|
+
return {
|
7
|
+
useForm: (opts) => {
|
8
|
+
const formOptions = Object.assign({}, defaultOpts, opts);
|
9
|
+
return useForm.useForm(formOptions);
|
10
|
+
},
|
11
|
+
useField: useField.useField,
|
12
|
+
Field: useField.Field
|
13
|
+
};
|
14
|
+
}
|
15
|
+
exports.createFormFactory = createFormFactory;
|
16
|
+
//# sourceMappingURL=createFormFactory.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createFormFactory.cjs","sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions, Validator } from '@tanstack/form-core'\n\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n useForm: (\n opts?: FormOptions<TFormData, TFormValidator>,\n ) => FormApi<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n Field: FieldComponent<TFormData, TFormValidator>\n}\n\nexport function createFormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n defaultOpts?: FormOptions<TFormData, TFormValidator>,\n): FormFactory<TFormData, TFormValidator> {\n return {\n useForm: (opts) => {\n const formOptions = Object.assign({}, defaultOpts, opts)\n return useForm<TFormData, TFormValidator>(formOptions)\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"names":["useForm","useField","Field"],"mappings":";;;;AAgBO,SAAS,kBAId,aACwC;AACjC,SAAA;AAAA,IACL,SAAS,CAAC,SAAS;AACjB,YAAM,cAAc,OAAO,OAAO,CAAA,GAAI,aAAa,IAAI;AACvD,aAAOA,QAAAA,QAAmC,WAAW;AAAA,IACvD;AAAA,IAAA,UACAC,SAAA;AAAA,IAAA,OACAC,SAAA;AAAA,EAAA;AAEJ;;"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const vue = require("vue");
|
4
|
+
const formContext = Symbol("FormContext");
|
5
|
+
function provideFormContext(val) {
|
6
|
+
vue.provide(formContext, val);
|
7
|
+
}
|
8
|
+
function useFormContext() {
|
9
|
+
const formApi = vue.inject(formContext);
|
10
|
+
if (!formApi) {
|
11
|
+
throw new Error(`You are trying to use the form API outside of a form!`);
|
12
|
+
}
|
13
|
+
return formApi;
|
14
|
+
}
|
15
|
+
exports.formContext = formContext;
|
16
|
+
exports.provideFormContext = provideFormContext;
|
17
|
+
exports.useFormContext = useFormContext;
|
18
|
+
//# sourceMappingURL=formContext.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"formContext.cjs","sources":["../../src/formContext.ts"],"sourcesContent":["import type { FormApi, Validator } from '@tanstack/form-core'\nimport { inject, provide } from 'vue'\n\nexport type FormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n formApi: FormApi<TFormData, TFormValidator>\n parentFieldName?: string\n} | null\n\nexport const formContext = Symbol('FormContext')\n\nexport function provideFormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(val: FormContext<TFormData, TFormValidator>) {\n provide(formContext, val)\n}\n\nexport function useFormContext() {\n const formApi = inject(formContext) as FormContext\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n"],"names":["provide","inject"],"mappings":";;;AAWa,MAAA,cAAc,OAAO,aAAa;AAExC,SAAS,mBAGd,KAA6C;AAC7CA,cAAQ,aAAa,GAAG;AAC1B;AAEO,SAAS,iBAAiB;AACzB,QAAA,UAAUC,WAAO,WAAW;AAElC,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAEO,SAAA;AACT;;;;"}
|
package/dist/cjs/index.cjs
CHANGED
@@ -1,114 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
3
|
const formCore = require("@tanstack/form-core");
|
4
|
-
const
|
5
|
-
const
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
return formApi;
|
16
|
-
}
|
17
|
-
function useField(opts) {
|
18
|
-
const { formApi, parentFieldName } = useFormContext();
|
19
|
-
const fieldApi = (() => {
|
20
|
-
const api = new formCore.FieldApi({
|
21
|
-
...opts,
|
22
|
-
form: formApi,
|
23
|
-
name: opts.name
|
24
|
-
});
|
25
|
-
api.Field = Field;
|
26
|
-
return api;
|
27
|
-
})();
|
28
|
-
const fieldState = vueStore.useStore(fieldApi.store, (state) => state);
|
29
|
-
let cleanup;
|
30
|
-
vue.onMounted(() => {
|
31
|
-
cleanup = fieldApi.mount();
|
32
|
-
});
|
33
|
-
vue.onUnmounted(() => {
|
34
|
-
cleanup();
|
35
|
-
});
|
36
|
-
vue.watch(
|
37
|
-
() => opts,
|
38
|
-
() => {
|
39
|
-
fieldApi.update({ ...opts, form: formApi });
|
40
|
-
}
|
41
|
-
);
|
42
|
-
return { api: fieldApi, state: fieldState };
|
43
|
-
}
|
44
|
-
const Field = vue.defineComponent(
|
45
|
-
(fieldOptions, context) => {
|
46
|
-
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
47
|
-
provideFormContext({
|
48
|
-
formApi: fieldApi.api.form,
|
49
|
-
parentFieldName: fieldApi.api.name
|
50
|
-
});
|
51
|
-
return () => context.slots.default({
|
52
|
-
field: fieldApi.api,
|
53
|
-
state: fieldApi.state.value
|
54
|
-
});
|
55
|
-
},
|
56
|
-
{ name: "Field", inheritAttrs: false }
|
57
|
-
);
|
58
|
-
function useForm(opts) {
|
59
|
-
const formApi = (() => {
|
60
|
-
const api = new formCore.FormApi(opts);
|
61
|
-
api.Provider = vue.defineComponent(
|
62
|
-
(_, context) => {
|
63
|
-
vue.onMounted(api.mount);
|
64
|
-
provideFormContext({ formApi });
|
65
|
-
return () => context.slots.default();
|
66
|
-
},
|
67
|
-
{ name: "Provider" }
|
68
|
-
);
|
69
|
-
api.provideFormContext = () => {
|
70
|
-
vue.onMounted(api.mount);
|
71
|
-
provideFormContext({ formApi });
|
72
|
-
};
|
73
|
-
api.Field = Field;
|
74
|
-
api.useField = useField;
|
75
|
-
api.useStore = (selector) => {
|
76
|
-
return vueStore.useStore(api.store, selector);
|
77
|
-
};
|
78
|
-
api.Subscribe = vue.defineComponent(
|
79
|
-
(props, context) => {
|
80
|
-
const allProps = { ...props, ...context.attrs };
|
81
|
-
const selector = allProps.selector ?? ((state) => state);
|
82
|
-
const data = vueStore.useStore(api.store, selector);
|
83
|
-
return () => context.slots.default(data.value);
|
84
|
-
},
|
85
|
-
{
|
86
|
-
name: "Subscribe",
|
87
|
-
inheritAttrs: false
|
88
|
-
}
|
89
|
-
);
|
90
|
-
return api;
|
91
|
-
})();
|
92
|
-
formApi.update(opts);
|
93
|
-
return formApi;
|
94
|
-
}
|
95
|
-
function createFormFactory(defaultOpts) {
|
96
|
-
return {
|
97
|
-
useForm: (opts) => {
|
98
|
-
const formOptions = Object.assign({}, defaultOpts, opts);
|
99
|
-
return useForm(formOptions);
|
100
|
-
},
|
101
|
-
useField,
|
102
|
-
Field
|
103
|
-
};
|
104
|
-
}
|
105
|
-
exports.Field = Field;
|
106
|
-
exports.createFormFactory = createFormFactory;
|
107
|
-
exports.formContext = formContext;
|
108
|
-
exports.provideFormContext = provideFormContext;
|
109
|
-
exports.useField = useField;
|
110
|
-
exports.useForm = useForm;
|
111
|
-
exports.useFormContext = useFormContext;
|
4
|
+
const createFormFactory = require("./createFormFactory.cjs");
|
5
|
+
const formContext = require("./formContext.cjs");
|
6
|
+
const useField = require("./useField.cjs");
|
7
|
+
const useForm = require("./useForm.cjs");
|
8
|
+
exports.createFormFactory = createFormFactory.createFormFactory;
|
9
|
+
exports.formContext = formContext.formContext;
|
10
|
+
exports.provideFormContext = formContext.provideFormContext;
|
11
|
+
exports.useFormContext = formContext.useFormContext;
|
12
|
+
exports.Field = useField.Field;
|
13
|
+
exports.useField = useField.useField;
|
14
|
+
exports.useForm = useForm.useForm;
|
112
15
|
Object.keys(formCore).forEach((k) => {
|
113
16
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
114
17
|
Object.defineProperty(exports, k, {
|
package/dist/cjs/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/formContext.ts","../../src/useField.tsx","../../src/useForm.tsx","../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, Validator } from '@tanstack/form-core'\nimport { inject, provide } from 'vue'\n\nexport type FormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n formApi: FormApi<TFormData, TFormValidator>\n parentFieldName?: string\n} | null\n\nexport const formContext = Symbol('FormContext')\n\nexport function provideFormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(val: FormContext<TFormData, TFormValidator>) {\n provide(formContext, val)\n}\n\nexport function useFormContext() {\n const formApi = inject(formContext) as FormContext\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n","import { FieldApi, type Validator } from '@tanstack/form-core'\nimport type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { defineComponent, onMounted, onUnmounted, watch } from 'vue'\nimport type { SlotsType, SetupContext, Ref } from 'vue'\nimport { provideFormContext, useFormContext } from './formContext'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData = DeepValue<TParentData, TName>,\n > {\n Field: FieldComponent<TParentData, TFormValidator>\n }\n}\n\nexport type UseField<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n >,\n) => FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n>\n\nexport function useField<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n opts: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >,\n): {\n api: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n >\n state: Readonly<\n Ref<\n FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n >\n >\n} {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const fieldApi = (() => {\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: opts.name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })()\n\n const fieldState = useStore(fieldApi.store, (state) => state)\n\n let cleanup!: () => void\n onMounted(() => {\n cleanup = fieldApi.mount()\n })\n\n onUnmounted(() => {\n cleanup()\n })\n\n watch(\n () => opts,\n () => {\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi } as never)\n },\n )\n\n return { api: fieldApi, state: fieldState } as never\n}\n\nexport type FieldValue<TParentData, TName> = TParentData extends any[]\n ? unknown extends TName\n ? TParentData[number]\n : DeepValue<TParentData[number], TName>\n : DeepValue<TParentData, TName>\n\ntype FieldComponentProps<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<\n UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator>,\n 'name' | 'index'\n >\n\nexport type FieldComponent<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n fieldOptions: FieldComponentProps<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext<\n {},\n SlotsType<{\n default: {\n field: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >\n state: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n }\n }>\n >,\n) => any\n\nexport const Field = defineComponent(\n <\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n >(\n fieldOptions: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext,\n ) => {\n const fieldApi = useField({ ...fieldOptions, ...context.attrs } as any)\n\n provideFormContext({\n formApi: fieldApi.api.form,\n parentFieldName: fieldApi.api.name,\n } as never)\n\n return () =>\n context.slots.default!({\n field: fieldApi.api,\n state: fieldApi.state.value,\n })\n },\n { name: 'Field', inheritAttrs: false },\n)\n","import {\n FormApi,\n type FormState,\n type FormOptions,\n type Validator,\n} from '@tanstack/form-core'\nimport { type NoInfer, useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport {\n type EmitsOptions,\n type SlotsType,\n type SetupContext,\n type Ref,\n defineComponent,\n onMounted,\n} from 'vue'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData, TFormValidator> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => Readonly<Ref<TSelected>>\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(\n props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n },\n context: SetupContext<\n EmitsOptions,\n SlotsType<{ default: NoInfer<FormState<TFormData>> }>\n >,\n ) => any\n }\n}\n\nexport function useForm<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n opts?: FormOptions<TFormData, TFormValidator>,\n): FormApi<TFormData, TFormValidator> {\n const formApi = (() => {\n const api = new FormApi<TFormData, TFormValidator>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n }\n api.Field = Field as never\n api.useField = useField as never\n api.useStore = (selector) => {\n return useStore(api.store as never, selector as never) as never\n }\n api.Subscribe = defineComponent(\n (props, context) => {\n const allProps = { ...props, ...context.attrs }\n const selector = allProps.selector ?? ((state) => state)\n const data = useStore(api.store as never, selector as never)\n return () => context.slots.default!(data.value)\n },\n {\n name: 'Subscribe',\n inheritAttrs: false,\n },\n )\n\n return api\n })()\n\n // formApi.useStore((state) => state.isSubmitting)\n formApi.update(opts)\n\n return formApi as never\n}\n","import type { FormApi, FormOptions, Validator } from '@tanstack/form-core'\n\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n useForm: (\n opts?: FormOptions<TFormData, TFormValidator>,\n ) => FormApi<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n Field: FieldComponent<TFormData, TFormValidator>\n}\n\nexport function createFormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n defaultOpts?: FormOptions<TFormData, TFormValidator>,\n): FormFactory<TFormData, TFormValidator> {\n return {\n useForm: (opts) => {\n const formOptions = Object.assign({}, defaultOpts, opts)\n return useForm<TFormData, TFormValidator>(formOptions)\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"names":["provide","inject","FieldApi","useStore","onMounted","onUnmounted","watch","defineComponent","FormApi"],"mappings":";;;;;AAWa,MAAA,cAAc,OAAO,aAAa;AAExC,SAAS,mBAGd,KAA6C;AAC7CA,cAAQ,aAAa,GAAG;AAC1B;AAEO,SAAS,iBAAiB;AACzB,QAAA,UAAUC,WAAO,WAAW;AAElC,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAEO,SAAA;AACT;ACuBO,SAAS,SAWd,MA6BA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,YAAY,MAAM;AAChB,UAAA,MAAM,IAAIC,kBAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN,MAAM,KAAK;AAAA,IAAA,CACH;AAEV,QAAI,QAAQ;AAEL,WAAA;AAAA,EAAA;AAGT,QAAM,aAAaC,SAAAA,SAAS,SAAS,OAAO,CAAC,UAAU,KAAK;AAExD,MAAA;AACJC,MAAAA,UAAU,MAAM;AACd,cAAU,SAAS;EAAM,CAC1B;AAEDC,MAAAA,YAAY,MAAM;AACR;EAAA,CACT;AAEDC,MAAA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAEJ,eAAS,OAAO,EAAE,GAAG,MAAM,MAAM,SAAkB;AAAA,IACrD;AAAA,EAAA;AAGF,SAAO,EAAE,KAAK,UAAU,OAAO,WAAW;AAC5C;AAwEO,MAAM,QAAQC,IAAA;AAAA,EACnB,CAUE,cAMA,YACG;AACG,UAAA,WAAW,SAAS,EAAE,GAAG,cAAc,GAAG,QAAQ,OAAc;AAEnD,uBAAA;AAAA,MACjB,SAAS,SAAS,IAAI;AAAA,MACtB,iBAAiB,SAAS,IAAI;AAAA,IAAA,CACtB;AAEH,WAAA,MACL,QAAQ,MAAM,QAAS;AAAA,MACrB,OAAO,SAAS;AAAA,MAChB,OAAO,SAAS,MAAM;AAAA,IAAA,CACvB;AAAA,EACL;AAAA,EACA,EAAE,MAAM,SAAS,cAAc,MAAM;AACvC;AChMO,SAAS,QAId,MACoC;AACpC,QAAM,WAAW,MAAM;AACf,UAAA,MAAM,IAAIC,iBAAmC,IAAI;AAEvD,QAAI,WAAWD,IAAA;AAAA,MACb,CAAC,GAAG,YAAY;AACdH,sBAAU,IAAI,KAAK;AACA,2BAAA,EAAE,SAA2B;AACzC,eAAA,MAAM,QAAQ,MAAM;MAC7B;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IAAA;AAErB,QAAI,qBAAqB,MAAM;AAC7BA,oBAAU,IAAI,KAAK;AACA,yBAAA,EAAE,SAA2B;AAAA,IAAA;AAElD,QAAI,QAAQ;AACZ,QAAI,WAAW;AACX,QAAA,WAAW,CAAC,aAAa;AACpB,aAAAD,kBAAS,IAAI,OAAgB,QAAiB;AAAA,IAAA;AAEvD,QAAI,YAAYI,IAAA;AAAA,MACd,CAAC,OAAO,YAAY;AAClB,cAAM,WAAW,EAAE,GAAG,OAAO,GAAG,QAAQ,MAAM;AAC9C,cAAM,WAAW,SAAS,aAAa,CAAC,UAAU;AAClD,cAAM,OAAOJ,SAAA,SAAS,IAAI,OAAgB,QAAiB;AAC3D,eAAO,MAAM,QAAQ,MAAM,QAAS,KAAK,KAAK;AAAA,MAChD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,cAAc;AAAA,MAChB;AAAA,IAAA;AAGK,WAAA;AAAA,EAAA;AAIT,UAAQ,OAAO,IAAI;AAEZ,SAAA;AACT;ACtEO,SAAS,kBAId,aACwC;AACjC,SAAA;AAAA,IACL,SAAS,CAAC,SAAS;AACjB,YAAM,cAAc,OAAO,OAAO,CAAA,GAAI,aAAa,IAAI;AACvD,aAAO,QAAmC,WAAW;AAAA,IACvD;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;;;;;;;;;;;;;;"}
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const formCore = require("@tanstack/form-core");
|
4
|
+
const vueStore = require("@tanstack/vue-store");
|
5
|
+
const vue = require("vue");
|
6
|
+
const formContext = require("./formContext.cjs");
|
7
|
+
function useField(opts) {
|
8
|
+
const { formApi, parentFieldName } = formContext.useFormContext();
|
9
|
+
const fieldApi = (() => {
|
10
|
+
const api = new formCore.FieldApi({
|
11
|
+
...opts,
|
12
|
+
form: formApi,
|
13
|
+
name: opts.name
|
14
|
+
});
|
15
|
+
api.Field = Field;
|
16
|
+
return api;
|
17
|
+
})();
|
18
|
+
const fieldState = vueStore.useStore(fieldApi.store, (state) => state);
|
19
|
+
let cleanup;
|
20
|
+
vue.onMounted(() => {
|
21
|
+
cleanup = fieldApi.mount();
|
22
|
+
});
|
23
|
+
vue.onUnmounted(() => {
|
24
|
+
cleanup();
|
25
|
+
});
|
26
|
+
vue.watch(
|
27
|
+
() => opts,
|
28
|
+
() => {
|
29
|
+
fieldApi.update({ ...opts, form: formApi });
|
30
|
+
}
|
31
|
+
);
|
32
|
+
return { api: fieldApi, state: fieldState };
|
33
|
+
}
|
34
|
+
const Field = vue.defineComponent(
|
35
|
+
(fieldOptions, context) => {
|
36
|
+
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
37
|
+
formContext.provideFormContext({
|
38
|
+
formApi: fieldApi.api.form,
|
39
|
+
parentFieldName: fieldApi.api.name
|
40
|
+
});
|
41
|
+
return () => context.slots.default({
|
42
|
+
field: fieldApi.api,
|
43
|
+
state: fieldApi.state.value
|
44
|
+
});
|
45
|
+
},
|
46
|
+
{ name: "Field", inheritAttrs: false }
|
47
|
+
);
|
48
|
+
exports.Field = Field;
|
49
|
+
exports.useField = useField;
|
50
|
+
//# sourceMappingURL=useField.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useField.cjs","sources":["../../src/useField.tsx"],"sourcesContent":["import { FieldApi, type Validator } from '@tanstack/form-core'\nimport type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { defineComponent, onMounted, onUnmounted, watch } from 'vue'\nimport type { SlotsType, SetupContext, Ref } from 'vue'\nimport { provideFormContext, useFormContext } from './formContext'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData = DeepValue<TParentData, TName>,\n > {\n Field: FieldComponent<TParentData, TFormValidator>\n }\n}\n\nexport type UseField<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n >,\n) => FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n>\n\nexport function useField<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n opts: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >,\n): {\n api: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n >\n state: Readonly<\n Ref<\n FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n >\n >\n} {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const fieldApi = (() => {\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: opts.name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })()\n\n const fieldState = useStore(fieldApi.store, (state) => state)\n\n let cleanup!: () => void\n onMounted(() => {\n cleanup = fieldApi.mount()\n })\n\n onUnmounted(() => {\n cleanup()\n })\n\n watch(\n () => opts,\n () => {\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi } as never)\n },\n )\n\n return { api: fieldApi, state: fieldState } as never\n}\n\nexport type FieldValue<TParentData, TName> = TParentData extends any[]\n ? unknown extends TName\n ? TParentData[number]\n : DeepValue<TParentData[number], TName>\n : DeepValue<TParentData, TName>\n\ntype FieldComponentProps<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<\n UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator>,\n 'name' | 'index'\n >\n\nexport type FieldComponent<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n fieldOptions: FieldComponentProps<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext<\n {},\n SlotsType<{\n default: {\n field: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >\n state: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n }\n }>\n >,\n) => any\n\nexport const Field = defineComponent(\n <\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n >(\n fieldOptions: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext,\n ) => {\n const fieldApi = useField({ ...fieldOptions, ...context.attrs } as any)\n\n provideFormContext({\n formApi: fieldApi.api.form,\n parentFieldName: fieldApi.api.name,\n } as never)\n\n return () =>\n context.slots.default!({\n field: fieldApi.api,\n state: fieldApi.state.value,\n })\n },\n { name: 'Field', inheritAttrs: false },\n)\n"],"names":["useFormContext","FieldApi","useStore","onMounted","onUnmounted","watch","defineComponent","provideFormContext"],"mappings":";;;;;;AAmDO,SAAS,SAWd,MA6BA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAIA,YAAe,eAAA;AAEpD,QAAM,YAAY,MAAM;AAChB,UAAA,MAAM,IAAIC,kBAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN,MAAM,KAAK;AAAA,IAAA,CACH;AAEV,QAAI,QAAQ;AAEL,WAAA;AAAA,EAAA;AAGT,QAAM,aAAaC,SAAAA,SAAS,SAAS,OAAO,CAAC,UAAU,KAAK;AAExD,MAAA;AACJC,MAAAA,UAAU,MAAM;AACd,cAAU,SAAS;EAAM,CAC1B;AAEDC,MAAAA,YAAY,MAAM;AACR;EAAA,CACT;AAEDC,MAAA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAEJ,eAAS,OAAO,EAAE,GAAG,MAAM,MAAM,SAAkB;AAAA,IACrD;AAAA,EAAA;AAGF,SAAO,EAAE,KAAK,UAAU,OAAO,WAAW;AAC5C;AAwEO,MAAM,QAAQC,IAAA;AAAA,EACnB,CAUE,cAMA,YACG;AACG,UAAA,WAAW,SAAS,EAAE,GAAG,cAAc,GAAG,QAAQ,OAAc;AAEnDC,mCAAA;AAAA,MACjB,SAAS,SAAS,IAAI;AAAA,MACtB,iBAAiB,SAAS,IAAI;AAAA,IAAA,CACtB;AAEH,WAAA,MACL,QAAQ,MAAM,QAAS;AAAA,MACrB,OAAO,SAAS;AAAA,MAChB,OAAO,SAAS,MAAM;AAAA,IAAA,CACvB;AAAA,EACL;AAAA,EACA,EAAE,MAAM,SAAS,cAAc,MAAM;AACvC;;;"}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const formCore = require("@tanstack/form-core");
|
4
|
+
const vueStore = require("@tanstack/vue-store");
|
5
|
+
const useField = require("./useField.cjs");
|
6
|
+
const formContext = require("./formContext.cjs");
|
7
|
+
const vue = require("vue");
|
8
|
+
function useForm(opts) {
|
9
|
+
const formApi = (() => {
|
10
|
+
const api = new formCore.FormApi(opts);
|
11
|
+
api.Provider = vue.defineComponent(
|
12
|
+
(_, context) => {
|
13
|
+
vue.onMounted(api.mount);
|
14
|
+
formContext.provideFormContext({ formApi });
|
15
|
+
return () => context.slots.default();
|
16
|
+
},
|
17
|
+
{ name: "Provider" }
|
18
|
+
);
|
19
|
+
api.provideFormContext = () => {
|
20
|
+
vue.onMounted(api.mount);
|
21
|
+
formContext.provideFormContext({ formApi });
|
22
|
+
};
|
23
|
+
api.Field = useField.Field;
|
24
|
+
api.useField = useField.useField;
|
25
|
+
api.useStore = (selector) => {
|
26
|
+
return vueStore.useStore(api.store, selector);
|
27
|
+
};
|
28
|
+
api.Subscribe = vue.defineComponent(
|
29
|
+
(props, context) => {
|
30
|
+
const allProps = { ...props, ...context.attrs };
|
31
|
+
const selector = allProps.selector ?? ((state) => state);
|
32
|
+
const data = vueStore.useStore(api.store, selector);
|
33
|
+
return () => context.slots.default(data.value);
|
34
|
+
},
|
35
|
+
{
|
36
|
+
name: "Subscribe",
|
37
|
+
inheritAttrs: false
|
38
|
+
}
|
39
|
+
);
|
40
|
+
return api;
|
41
|
+
})();
|
42
|
+
formApi.update(opts);
|
43
|
+
return formApi;
|
44
|
+
}
|
45
|
+
exports.useForm = useForm;
|
46
|
+
//# sourceMappingURL=useForm.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useForm.cjs","sources":["../../src/useForm.tsx"],"sourcesContent":["import {\n FormApi,\n type FormState,\n type FormOptions,\n type Validator,\n} from '@tanstack/form-core'\nimport { type NoInfer, useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport {\n type EmitsOptions,\n type SlotsType,\n type SetupContext,\n type Ref,\n defineComponent,\n onMounted,\n} from 'vue'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData, TFormValidator> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => Readonly<Ref<TSelected>>\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(\n props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n },\n context: SetupContext<\n EmitsOptions,\n SlotsType<{ default: NoInfer<FormState<TFormData>> }>\n >,\n ) => any\n }\n}\n\nexport function useForm<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n opts?: FormOptions<TFormData, TFormValidator>,\n): FormApi<TFormData, TFormValidator> {\n const formApi = (() => {\n const api = new FormApi<TFormData, TFormValidator>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n }\n api.Field = Field as never\n api.useField = useField as never\n api.useStore = (selector) => {\n return useStore(api.store as never, selector as never) as never\n }\n api.Subscribe = defineComponent(\n (props, context) => {\n const allProps = { ...props, ...context.attrs }\n const selector = allProps.selector ?? ((state) => state)\n const data = useStore(api.store as never, selector as never)\n return () => context.slots.default!(data.value)\n },\n {\n name: 'Subscribe',\n inheritAttrs: false,\n },\n )\n\n return api\n })()\n\n // formApi.useStore((state) => state.isSubmitting)\n formApi.update(opts)\n\n return formApi as never\n}\n"],"names":["FormApi","defineComponent","onMounted","provideFormContext","Field","useField","useStore"],"mappings":";;;;;;;AAwCO,SAAS,QAId,MACoC;AACpC,QAAM,WAAW,MAAM;AACf,UAAA,MAAM,IAAIA,iBAAmC,IAAI;AAEvD,QAAI,WAAWC,IAAA;AAAA,MACb,CAAC,GAAG,YAAY;AACdC,sBAAU,IAAI,KAAK;AACAC,uCAAA,EAAE,SAA2B;AACzC,eAAA,MAAM,QAAQ,MAAM;MAC7B;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IAAA;AAErB,QAAI,qBAAqB,MAAM;AAC7BD,oBAAU,IAAI,KAAK;AACAC,qCAAA,EAAE,SAA2B;AAAA,IAAA;AAElD,QAAI,QAAQC;AACZ,QAAI,WAAWC;AACX,QAAA,WAAW,CAAC,aAAa;AACpB,aAAAC,kBAAS,IAAI,OAAgB,QAAiB;AAAA,IAAA;AAEvD,QAAI,YAAYL,IAAA;AAAA,MACd,CAAC,OAAO,YAAY;AAClB,cAAM,WAAW,EAAE,GAAG,OAAO,GAAG,QAAQ,MAAM;AAC9C,cAAM,WAAW,SAAS,aAAa,CAAC,UAAU;AAClD,cAAM,OAAOK,SAAA,SAAS,IAAI,OAAgB,QAAiB;AAC3D,eAAO,MAAM,QAAQ,MAAM,QAAS,KAAK,KAAK;AAAA,MAChD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,cAAc;AAAA,MAChB;AAAA,IAAA;AAGK,WAAA;AAAA,EAAA;AAIT,UAAQ,OAAO,IAAI;AAEZ,SAAA;AACT;;"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { useField, Field } from "./useField.js";
|
2
|
+
import { useForm } from "./useForm.js";
|
3
|
+
function createFormFactory(defaultOpts) {
|
4
|
+
return {
|
5
|
+
useForm: (opts) => {
|
6
|
+
const formOptions = Object.assign({}, defaultOpts, opts);
|
7
|
+
return useForm(formOptions);
|
8
|
+
},
|
9
|
+
useField,
|
10
|
+
Field
|
11
|
+
};
|
12
|
+
}
|
13
|
+
export {
|
14
|
+
createFormFactory
|
15
|
+
};
|
16
|
+
//# sourceMappingURL=createFormFactory.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createFormFactory.js","sources":["../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, FormOptions, Validator } from '@tanstack/form-core'\n\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n useForm: (\n opts?: FormOptions<TFormData, TFormValidator>,\n ) => FormApi<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n Field: FieldComponent<TFormData, TFormValidator>\n}\n\nexport function createFormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n defaultOpts?: FormOptions<TFormData, TFormValidator>,\n): FormFactory<TFormData, TFormValidator> {\n return {\n useForm: (opts) => {\n const formOptions = Object.assign({}, defaultOpts, opts)\n return useForm<TFormData, TFormValidator>(formOptions)\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"names":[],"mappings":";;AAgBO,SAAS,kBAId,aACwC;AACjC,SAAA;AAAA,IACL,SAAS,CAAC,SAAS;AACjB,YAAM,cAAc,OAAO,OAAO,CAAA,GAAI,aAAa,IAAI;AACvD,aAAO,QAAmC,WAAW;AAAA,IACvD;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { provide, inject } from "vue";
|
2
|
+
const formContext = Symbol("FormContext");
|
3
|
+
function provideFormContext(val) {
|
4
|
+
provide(formContext, val);
|
5
|
+
}
|
6
|
+
function useFormContext() {
|
7
|
+
const formApi = inject(formContext);
|
8
|
+
if (!formApi) {
|
9
|
+
throw new Error(`You are trying to use the form API outside of a form!`);
|
10
|
+
}
|
11
|
+
return formApi;
|
12
|
+
}
|
13
|
+
export {
|
14
|
+
formContext,
|
15
|
+
provideFormContext,
|
16
|
+
useFormContext
|
17
|
+
};
|
18
|
+
//# sourceMappingURL=formContext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"formContext.js","sources":["../../src/formContext.ts"],"sourcesContent":["import type { FormApi, Validator } from '@tanstack/form-core'\nimport { inject, provide } from 'vue'\n\nexport type FormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n formApi: FormApi<TFormData, TFormValidator>\n parentFieldName?: string\n} | null\n\nexport const formContext = Symbol('FormContext')\n\nexport function provideFormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(val: FormContext<TFormData, TFormValidator>) {\n provide(formContext, val)\n}\n\nexport function useFormContext() {\n const formApi = inject(formContext) as FormContext\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n"],"names":[],"mappings":";AAWa,MAAA,cAAc,OAAO,aAAa;AAExC,SAAS,mBAGd,KAA6C;AAC7C,UAAQ,aAAa,GAAG;AAC1B;AAEO,SAAS,iBAAiB;AACzB,QAAA,UAAU,OAAO,WAAW;AAElC,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAEO,SAAA;AACT;"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export * from "@tanstack/form-core";
|
2
|
+
import { createFormFactory } from "./createFormFactory.js";
|
3
|
+
import { formContext, provideFormContext, useFormContext } from "./formContext.js";
|
4
|
+
import { Field, useField } from "./useField.js";
|
5
|
+
import { useForm } from "./useForm.js";
|
6
|
+
export {
|
7
|
+
Field,
|
8
|
+
createFormFactory,
|
9
|
+
formContext,
|
10
|
+
provideFormContext,
|
11
|
+
useField,
|
12
|
+
useForm,
|
13
|
+
useFormContext
|
14
|
+
};
|
15
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { FieldApi } from "@tanstack/form-core";
|
2
|
+
import { useStore } from "@tanstack/vue-store";
|
3
|
+
import { onMounted, onUnmounted, watch, defineComponent } from "vue";
|
4
|
+
import { useFormContext, provideFormContext } from "./formContext.js";
|
5
|
+
function useField(opts) {
|
6
|
+
const { formApi, parentFieldName } = useFormContext();
|
7
|
+
const fieldApi = (() => {
|
8
|
+
const api = new FieldApi({
|
9
|
+
...opts,
|
10
|
+
form: formApi,
|
11
|
+
name: opts.name
|
12
|
+
});
|
13
|
+
api.Field = Field;
|
14
|
+
return api;
|
15
|
+
})();
|
16
|
+
const fieldState = useStore(fieldApi.store, (state) => state);
|
17
|
+
let cleanup;
|
18
|
+
onMounted(() => {
|
19
|
+
cleanup = fieldApi.mount();
|
20
|
+
});
|
21
|
+
onUnmounted(() => {
|
22
|
+
cleanup();
|
23
|
+
});
|
24
|
+
watch(
|
25
|
+
() => opts,
|
26
|
+
() => {
|
27
|
+
fieldApi.update({ ...opts, form: formApi });
|
28
|
+
}
|
29
|
+
);
|
30
|
+
return { api: fieldApi, state: fieldState };
|
31
|
+
}
|
32
|
+
const Field = defineComponent(
|
33
|
+
(fieldOptions, context) => {
|
34
|
+
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
35
|
+
provideFormContext({
|
36
|
+
formApi: fieldApi.api.form,
|
37
|
+
parentFieldName: fieldApi.api.name
|
38
|
+
});
|
39
|
+
return () => context.slots.default({
|
40
|
+
field: fieldApi.api,
|
41
|
+
state: fieldApi.state.value
|
42
|
+
});
|
43
|
+
},
|
44
|
+
{ name: "Field", inheritAttrs: false }
|
45
|
+
);
|
46
|
+
export {
|
47
|
+
Field,
|
48
|
+
useField
|
49
|
+
};
|
50
|
+
//# sourceMappingURL=useField.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useField.js","sources":["../../src/useField.tsx"],"sourcesContent":["import { FieldApi, type Validator } from '@tanstack/form-core'\nimport type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { defineComponent, onMounted, onUnmounted, watch } from 'vue'\nimport type { SlotsType, SetupContext, Ref } from 'vue'\nimport { provideFormContext, useFormContext } from './formContext'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData = DeepValue<TParentData, TName>,\n > {\n Field: FieldComponent<TParentData, TFormValidator>\n }\n}\n\nexport type UseField<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n >,\n) => FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n>\n\nexport function useField<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n opts: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >,\n): {\n api: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n >\n state: Readonly<\n Ref<\n FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n >\n >\n} {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const fieldApi = (() => {\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: opts.name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })()\n\n const fieldState = useStore(fieldApi.store, (state) => state)\n\n let cleanup!: () => void\n onMounted(() => {\n cleanup = fieldApi.mount()\n })\n\n onUnmounted(() => {\n cleanup()\n })\n\n watch(\n () => opts,\n () => {\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi } as never)\n },\n )\n\n return { api: fieldApi, state: fieldState } as never\n}\n\nexport type FieldValue<TParentData, TName> = TParentData extends any[]\n ? unknown extends TName\n ? TParentData[number]\n : DeepValue<TParentData[number], TName>\n : DeepValue<TParentData, TName>\n\ntype FieldComponentProps<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<\n UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator>,\n 'name' | 'index'\n >\n\nexport type FieldComponent<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n fieldOptions: FieldComponentProps<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext<\n {},\n SlotsType<{\n default: {\n field: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >\n state: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n }\n }>\n >,\n) => any\n\nexport const Field = defineComponent(\n <\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n >(\n fieldOptions: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext,\n ) => {\n const fieldApi = useField({ ...fieldOptions, ...context.attrs } as any)\n\n provideFormContext({\n formApi: fieldApi.api.form,\n parentFieldName: fieldApi.api.name,\n } as never)\n\n return () =>\n context.slots.default!({\n field: fieldApi.api,\n state: fieldApi.state.value,\n })\n },\n { name: 'Field', inheritAttrs: false },\n)\n"],"names":[],"mappings":";;;;AAmDO,SAAS,SAWd,MA6BA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,YAAY,MAAM;AAChB,UAAA,MAAM,IAAI,SAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN,MAAM,KAAK;AAAA,IAAA,CACH;AAEV,QAAI,QAAQ;AAEL,WAAA;AAAA,EAAA;AAGT,QAAM,aAAa,SAAS,SAAS,OAAO,CAAC,UAAU,KAAK;AAExD,MAAA;AACJ,YAAU,MAAM;AACd,cAAU,SAAS;EAAM,CAC1B;AAED,cAAY,MAAM;AACR;EAAA,CACT;AAED;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAEJ,eAAS,OAAO,EAAE,GAAG,MAAM,MAAM,SAAkB;AAAA,IACrD;AAAA,EAAA;AAGF,SAAO,EAAE,KAAK,UAAU,OAAO,WAAW;AAC5C;AAwEO,MAAM,QAAQ;AAAA,EACnB,CAUE,cAMA,YACG;AACG,UAAA,WAAW,SAAS,EAAE,GAAG,cAAc,GAAG,QAAQ,OAAc;AAEnD,uBAAA;AAAA,MACjB,SAAS,SAAS,IAAI;AAAA,MACtB,iBAAiB,SAAS,IAAI;AAAA,IAAA,CACtB;AAEH,WAAA,MACL,QAAQ,MAAM,QAAS;AAAA,MACrB,OAAO,SAAS;AAAA,MAChB,OAAO,SAAS,MAAM;AAAA,IAAA,CACvB;AAAA,EACL;AAAA,EACA,EAAE,MAAM,SAAS,cAAc,MAAM;AACvC;"}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { FormApi } from "@tanstack/form-core";
|
2
|
+
import { useStore } from "@tanstack/vue-store";
|
3
|
+
import { Field, useField } from "./useField.js";
|
4
|
+
import { provideFormContext } from "./formContext.js";
|
5
|
+
import { defineComponent, onMounted } from "vue";
|
6
|
+
function useForm(opts) {
|
7
|
+
const formApi = (() => {
|
8
|
+
const api = new FormApi(opts);
|
9
|
+
api.Provider = defineComponent(
|
10
|
+
(_, context) => {
|
11
|
+
onMounted(api.mount);
|
12
|
+
provideFormContext({ formApi });
|
13
|
+
return () => context.slots.default();
|
14
|
+
},
|
15
|
+
{ name: "Provider" }
|
16
|
+
);
|
17
|
+
api.provideFormContext = () => {
|
18
|
+
onMounted(api.mount);
|
19
|
+
provideFormContext({ formApi });
|
20
|
+
};
|
21
|
+
api.Field = Field;
|
22
|
+
api.useField = useField;
|
23
|
+
api.useStore = (selector) => {
|
24
|
+
return useStore(api.store, selector);
|
25
|
+
};
|
26
|
+
api.Subscribe = defineComponent(
|
27
|
+
(props, context) => {
|
28
|
+
const allProps = { ...props, ...context.attrs };
|
29
|
+
const selector = allProps.selector ?? ((state) => state);
|
30
|
+
const data = useStore(api.store, selector);
|
31
|
+
return () => context.slots.default(data.value);
|
32
|
+
},
|
33
|
+
{
|
34
|
+
name: "Subscribe",
|
35
|
+
inheritAttrs: false
|
36
|
+
}
|
37
|
+
);
|
38
|
+
return api;
|
39
|
+
})();
|
40
|
+
formApi.update(opts);
|
41
|
+
return formApi;
|
42
|
+
}
|
43
|
+
export {
|
44
|
+
useForm
|
45
|
+
};
|
46
|
+
//# sourceMappingURL=useForm.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useForm.js","sources":["../../src/useForm.tsx"],"sourcesContent":["import {\n FormApi,\n type FormState,\n type FormOptions,\n type Validator,\n} from '@tanstack/form-core'\nimport { type NoInfer, useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport {\n type EmitsOptions,\n type SlotsType,\n type SetupContext,\n type Ref,\n defineComponent,\n onMounted,\n} from 'vue'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData, TFormValidator> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => Readonly<Ref<TSelected>>\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(\n props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n },\n context: SetupContext<\n EmitsOptions,\n SlotsType<{ default: NoInfer<FormState<TFormData>> }>\n >,\n ) => any\n }\n}\n\nexport function useForm<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n opts?: FormOptions<TFormData, TFormValidator>,\n): FormApi<TFormData, TFormValidator> {\n const formApi = (() => {\n const api = new FormApi<TFormData, TFormValidator>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n }\n api.Field = Field as never\n api.useField = useField as never\n api.useStore = (selector) => {\n return useStore(api.store as never, selector as never) as never\n }\n api.Subscribe = defineComponent(\n (props, context) => {\n const allProps = { ...props, ...context.attrs }\n const selector = allProps.selector ?? ((state) => state)\n const data = useStore(api.store as never, selector as never)\n return () => context.slots.default!(data.value)\n },\n {\n name: 'Subscribe',\n inheritAttrs: false,\n },\n )\n\n return api\n })()\n\n // formApi.useStore((state) => state.isSubmitting)\n formApi.update(opts)\n\n return formApi as never\n}\n"],"names":[],"mappings":";;;;;AAwCO,SAAS,QAId,MACoC;AACpC,QAAM,WAAW,MAAM;AACf,UAAA,MAAM,IAAI,QAAmC,IAAI;AAEvD,QAAI,WAAW;AAAA,MACb,CAAC,GAAG,YAAY;AACd,kBAAU,IAAI,KAAK;AACA,2BAAA,EAAE,SAA2B;AACzC,eAAA,MAAM,QAAQ,MAAM;MAC7B;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IAAA;AAErB,QAAI,qBAAqB,MAAM;AAC7B,gBAAU,IAAI,KAAK;AACA,yBAAA,EAAE,SAA2B;AAAA,IAAA;AAElD,QAAI,QAAQ;AACZ,QAAI,WAAW;AACX,QAAA,WAAW,CAAC,aAAa;AACpB,aAAA,SAAS,IAAI,OAAgB,QAAiB;AAAA,IAAA;AAEvD,QAAI,YAAY;AAAA,MACd,CAAC,OAAO,YAAY;AAClB,cAAM,WAAW,EAAE,GAAG,OAAO,GAAG,QAAQ,MAAM;AAC9C,cAAM,WAAW,SAAS,aAAa,CAAC,UAAU;AAClD,cAAM,OAAO,SAAS,IAAI,OAAgB,QAAiB;AAC3D,eAAO,MAAM,QAAQ,MAAM,QAAS,KAAK,KAAK;AAAA,MAChD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,cAAc;AAAA,MAChB;AAAA,IAAA;AAGK,WAAA;AAAA,EAAA;AAIT,UAAQ,OAAO,IAAI;AAEZ,SAAA;AACT;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tanstack/vue-form",
|
3
|
-
"version": "0.13.
|
3
|
+
"version": "0.13.1",
|
4
4
|
"description": "Powerful, type-safe forms for Vue.",
|
5
5
|
"author": "tannerlinsley",
|
6
6
|
"license": "MIT",
|
@@ -11,14 +11,14 @@
|
|
11
11
|
"url": "https://github.com/sponsors/tannerlinsley"
|
12
12
|
},
|
13
13
|
"type": "module",
|
14
|
-
"types": "dist/
|
14
|
+
"types": "dist/esm/index.d.ts",
|
15
15
|
"main": "dist/cjs/index.cjs",
|
16
|
-
"module": "dist/
|
16
|
+
"module": "dist/esm/index.js",
|
17
17
|
"exports": {
|
18
18
|
".": {
|
19
19
|
"import": {
|
20
|
-
"types": "./dist/
|
21
|
-
"default": "./dist/
|
20
|
+
"types": "./dist/esm/index.d.ts",
|
21
|
+
"default": "./dist/esm/index.js"
|
22
22
|
},
|
23
23
|
"require": {
|
24
24
|
"types": "./dist/cjs/index.d.cts",
|
@@ -33,11 +33,11 @@
|
|
33
33
|
"src"
|
34
34
|
],
|
35
35
|
"dependencies": {
|
36
|
-
"@tanstack/store": "0.1.3",
|
37
36
|
"@tanstack/vue-store": "0.1.3",
|
38
|
-
"@tanstack/form-core": "0.13.
|
37
|
+
"@tanstack/form-core": "0.13.1"
|
39
38
|
},
|
40
39
|
"devDependencies": {
|
40
|
+
"@vitejs/plugin-vue": "^4.5.0",
|
41
41
|
"vue": "^3.3.4"
|
42
42
|
},
|
43
43
|
"peerDependencies": {
|
@@ -46,10 +46,10 @@
|
|
46
46
|
"scripts": {
|
47
47
|
"clean": "rimraf ./dist && rimraf ./coverage",
|
48
48
|
"test:eslint": "eslint --ext .ts,.tsx ./src",
|
49
|
-
"test:types:versions49": "../../node_modules/typescript49/bin/tsc --
|
50
|
-
"test:types:versions50": "../../node_modules/typescript50/bin/tsc
|
51
|
-
"test:types:versions51": "../../node_modules/typescript51/bin/tsc
|
52
|
-
"test:types:versions52": "tsc
|
49
|
+
"test:types:versions49": "../../node_modules/typescript49/bin/tsc --project tsconfig.legacy.json",
|
50
|
+
"test:types:versions50": "../../node_modules/typescript50/bin/tsc",
|
51
|
+
"test:types:versions51": "../../node_modules/typescript51/bin/tsc",
|
52
|
+
"test:types:versions52": "tsc",
|
53
53
|
"test:types": "pnpm run \"/^test:types:versions.*/\"",
|
54
54
|
"fixme:test:lib": "pnpm run test:2 && pnpm run test:2.7 && pnpm run test:3",
|
55
55
|
"test:lib": "vitest",
|
package/dist/cjs/index.js
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
-
const formCore = require("@tanstack/form-core");
|
4
|
-
const vueStore = require("@tanstack/vue-store");
|
5
|
-
const vue = require("vue");
|
6
|
-
const formContext = Symbol("FormContext");
|
7
|
-
function provideFormContext(val) {
|
8
|
-
vue.provide(formContext, val);
|
9
|
-
}
|
10
|
-
function useFormContext() {
|
11
|
-
const formApi = vue.inject(formContext);
|
12
|
-
if (!formApi) {
|
13
|
-
throw new Error(`You are trying to use the form API outside of a form!`);
|
14
|
-
}
|
15
|
-
return formApi;
|
16
|
-
}
|
17
|
-
function useField(opts) {
|
18
|
-
const { formApi, parentFieldName } = useFormContext();
|
19
|
-
const fieldApi = (() => {
|
20
|
-
const api = new formCore.FieldApi({
|
21
|
-
...opts,
|
22
|
-
form: formApi,
|
23
|
-
name: opts.name
|
24
|
-
});
|
25
|
-
api.Field = Field;
|
26
|
-
return api;
|
27
|
-
})();
|
28
|
-
const fieldState = vueStore.useStore(fieldApi.store, (state) => state);
|
29
|
-
let cleanup;
|
30
|
-
vue.onMounted(() => {
|
31
|
-
cleanup = fieldApi.mount();
|
32
|
-
});
|
33
|
-
vue.onUnmounted(() => {
|
34
|
-
cleanup();
|
35
|
-
});
|
36
|
-
vue.watch(
|
37
|
-
() => opts,
|
38
|
-
() => {
|
39
|
-
fieldApi.update({ ...opts, form: formApi });
|
40
|
-
}
|
41
|
-
);
|
42
|
-
return { api: fieldApi, state: fieldState };
|
43
|
-
}
|
44
|
-
const Field = vue.defineComponent(
|
45
|
-
(fieldOptions, context) => {
|
46
|
-
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
47
|
-
provideFormContext({
|
48
|
-
formApi: fieldApi.api.form,
|
49
|
-
parentFieldName: fieldApi.api.name
|
50
|
-
});
|
51
|
-
return () => context.slots.default({
|
52
|
-
field: fieldApi.api,
|
53
|
-
state: fieldApi.state.value
|
54
|
-
});
|
55
|
-
},
|
56
|
-
{ name: "Field", inheritAttrs: false }
|
57
|
-
);
|
58
|
-
function useForm(opts) {
|
59
|
-
const formApi = (() => {
|
60
|
-
const api = new formCore.FormApi(opts);
|
61
|
-
api.Provider = vue.defineComponent(
|
62
|
-
(_, context) => {
|
63
|
-
vue.onMounted(api.mount);
|
64
|
-
provideFormContext({ formApi });
|
65
|
-
return () => context.slots.default();
|
66
|
-
},
|
67
|
-
{ name: "Provider" }
|
68
|
-
);
|
69
|
-
api.provideFormContext = () => {
|
70
|
-
vue.onMounted(api.mount);
|
71
|
-
provideFormContext({ formApi });
|
72
|
-
};
|
73
|
-
api.Field = Field;
|
74
|
-
api.useField = useField;
|
75
|
-
api.useStore = (selector) => {
|
76
|
-
return vueStore.useStore(api.store, selector);
|
77
|
-
};
|
78
|
-
api.Subscribe = vue.defineComponent(
|
79
|
-
(props, context) => {
|
80
|
-
const allProps = { ...props, ...context.attrs };
|
81
|
-
const selector = allProps.selector ?? ((state) => state);
|
82
|
-
const data = vueStore.useStore(api.store, selector);
|
83
|
-
return () => context.slots.default(data.value);
|
84
|
-
},
|
85
|
-
{
|
86
|
-
name: "Subscribe",
|
87
|
-
inheritAttrs: false
|
88
|
-
}
|
89
|
-
);
|
90
|
-
return api;
|
91
|
-
})();
|
92
|
-
formApi.update(opts);
|
93
|
-
return formApi;
|
94
|
-
}
|
95
|
-
function createFormFactory(defaultOpts) {
|
96
|
-
return {
|
97
|
-
useForm: (opts) => {
|
98
|
-
const formOptions = Object.assign({}, defaultOpts, opts);
|
99
|
-
return useForm(formOptions);
|
100
|
-
},
|
101
|
-
useField,
|
102
|
-
Field
|
103
|
-
};
|
104
|
-
}
|
105
|
-
exports.Field = Field;
|
106
|
-
exports.createFormFactory = createFormFactory;
|
107
|
-
exports.formContext = formContext;
|
108
|
-
exports.provideFormContext = provideFormContext;
|
109
|
-
exports.useField = useField;
|
110
|
-
exports.useForm = useForm;
|
111
|
-
exports.useFormContext = useFormContext;
|
112
|
-
Object.keys(formCore).forEach((k) => {
|
113
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
114
|
-
Object.defineProperty(exports, k, {
|
115
|
-
enumerable: true,
|
116
|
-
get: () => formCore[k]
|
117
|
-
});
|
118
|
-
});
|
119
|
-
//# sourceMappingURL=index.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
/// <reference lib="dom" />
|
@@ -1 +0,0 @@
|
|
1
|
-
/// <reference lib="dom" />
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function sleep(timeout: number): Promise<void>;
|
package/dist/mjs/index.d.mts
DELETED
package/dist/mjs/index.d.ts
DELETED
package/dist/mjs/index.js
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
import { FieldApi, FormApi } from "@tanstack/form-core";
|
2
|
-
export * from "@tanstack/form-core";
|
3
|
-
import { useStore } from "@tanstack/vue-store";
|
4
|
-
import { provide, inject, onMounted, onUnmounted, watch, defineComponent } from "vue";
|
5
|
-
const formContext = Symbol("FormContext");
|
6
|
-
function provideFormContext(val) {
|
7
|
-
provide(formContext, val);
|
8
|
-
}
|
9
|
-
function useFormContext() {
|
10
|
-
const formApi = inject(formContext);
|
11
|
-
if (!formApi) {
|
12
|
-
throw new Error(`You are trying to use the form API outside of a form!`);
|
13
|
-
}
|
14
|
-
return formApi;
|
15
|
-
}
|
16
|
-
function useField(opts) {
|
17
|
-
const { formApi, parentFieldName } = useFormContext();
|
18
|
-
const fieldApi = (() => {
|
19
|
-
const api = new FieldApi({
|
20
|
-
...opts,
|
21
|
-
form: formApi,
|
22
|
-
name: opts.name
|
23
|
-
});
|
24
|
-
api.Field = Field;
|
25
|
-
return api;
|
26
|
-
})();
|
27
|
-
const fieldState = useStore(fieldApi.store, (state) => state);
|
28
|
-
let cleanup;
|
29
|
-
onMounted(() => {
|
30
|
-
cleanup = fieldApi.mount();
|
31
|
-
});
|
32
|
-
onUnmounted(() => {
|
33
|
-
cleanup();
|
34
|
-
});
|
35
|
-
watch(
|
36
|
-
() => opts,
|
37
|
-
() => {
|
38
|
-
fieldApi.update({ ...opts, form: formApi });
|
39
|
-
}
|
40
|
-
);
|
41
|
-
return { api: fieldApi, state: fieldState };
|
42
|
-
}
|
43
|
-
const Field = defineComponent(
|
44
|
-
(fieldOptions, context) => {
|
45
|
-
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
46
|
-
provideFormContext({
|
47
|
-
formApi: fieldApi.api.form,
|
48
|
-
parentFieldName: fieldApi.api.name
|
49
|
-
});
|
50
|
-
return () => context.slots.default({
|
51
|
-
field: fieldApi.api,
|
52
|
-
state: fieldApi.state.value
|
53
|
-
});
|
54
|
-
},
|
55
|
-
{ name: "Field", inheritAttrs: false }
|
56
|
-
);
|
57
|
-
function useForm(opts) {
|
58
|
-
const formApi = (() => {
|
59
|
-
const api = new FormApi(opts);
|
60
|
-
api.Provider = defineComponent(
|
61
|
-
(_, context) => {
|
62
|
-
onMounted(api.mount);
|
63
|
-
provideFormContext({ formApi });
|
64
|
-
return () => context.slots.default();
|
65
|
-
},
|
66
|
-
{ name: "Provider" }
|
67
|
-
);
|
68
|
-
api.provideFormContext = () => {
|
69
|
-
onMounted(api.mount);
|
70
|
-
provideFormContext({ formApi });
|
71
|
-
};
|
72
|
-
api.Field = Field;
|
73
|
-
api.useField = useField;
|
74
|
-
api.useStore = (selector) => {
|
75
|
-
return useStore(api.store, selector);
|
76
|
-
};
|
77
|
-
api.Subscribe = defineComponent(
|
78
|
-
(props, context) => {
|
79
|
-
const allProps = { ...props, ...context.attrs };
|
80
|
-
const selector = allProps.selector ?? ((state) => state);
|
81
|
-
const data = useStore(api.store, selector);
|
82
|
-
return () => context.slots.default(data.value);
|
83
|
-
},
|
84
|
-
{
|
85
|
-
name: "Subscribe",
|
86
|
-
inheritAttrs: false
|
87
|
-
}
|
88
|
-
);
|
89
|
-
return api;
|
90
|
-
})();
|
91
|
-
formApi.update(opts);
|
92
|
-
return formApi;
|
93
|
-
}
|
94
|
-
function createFormFactory(defaultOpts) {
|
95
|
-
return {
|
96
|
-
useForm: (opts) => {
|
97
|
-
const formOptions = Object.assign({}, defaultOpts, opts);
|
98
|
-
return useForm(formOptions);
|
99
|
-
},
|
100
|
-
useField,
|
101
|
-
Field
|
102
|
-
};
|
103
|
-
}
|
104
|
-
export {
|
105
|
-
Field,
|
106
|
-
createFormFactory,
|
107
|
-
formContext,
|
108
|
-
provideFormContext,
|
109
|
-
useField,
|
110
|
-
useForm,
|
111
|
-
useFormContext
|
112
|
-
};
|
113
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/mjs/index.mjs
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
import { FieldApi, FormApi } from "@tanstack/form-core";
|
2
|
-
export * from "@tanstack/form-core";
|
3
|
-
import { useStore } from "@tanstack/vue-store";
|
4
|
-
import { provide, inject, onMounted, onUnmounted, watch, defineComponent } from "vue";
|
5
|
-
const formContext = Symbol("FormContext");
|
6
|
-
function provideFormContext(val) {
|
7
|
-
provide(formContext, val);
|
8
|
-
}
|
9
|
-
function useFormContext() {
|
10
|
-
const formApi = inject(formContext);
|
11
|
-
if (!formApi) {
|
12
|
-
throw new Error(`You are trying to use the form API outside of a form!`);
|
13
|
-
}
|
14
|
-
return formApi;
|
15
|
-
}
|
16
|
-
function useField(opts) {
|
17
|
-
const { formApi, parentFieldName } = useFormContext();
|
18
|
-
const fieldApi = (() => {
|
19
|
-
const api = new FieldApi({
|
20
|
-
...opts,
|
21
|
-
form: formApi,
|
22
|
-
name: opts.name
|
23
|
-
});
|
24
|
-
api.Field = Field;
|
25
|
-
return api;
|
26
|
-
})();
|
27
|
-
const fieldState = useStore(fieldApi.store, (state) => state);
|
28
|
-
let cleanup;
|
29
|
-
onMounted(() => {
|
30
|
-
cleanup = fieldApi.mount();
|
31
|
-
});
|
32
|
-
onUnmounted(() => {
|
33
|
-
cleanup();
|
34
|
-
});
|
35
|
-
watch(
|
36
|
-
() => opts,
|
37
|
-
() => {
|
38
|
-
fieldApi.update({ ...opts, form: formApi });
|
39
|
-
}
|
40
|
-
);
|
41
|
-
return { api: fieldApi, state: fieldState };
|
42
|
-
}
|
43
|
-
const Field = defineComponent(
|
44
|
-
(fieldOptions, context) => {
|
45
|
-
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
46
|
-
provideFormContext({
|
47
|
-
formApi: fieldApi.api.form,
|
48
|
-
parentFieldName: fieldApi.api.name
|
49
|
-
});
|
50
|
-
return () => context.slots.default({
|
51
|
-
field: fieldApi.api,
|
52
|
-
state: fieldApi.state.value
|
53
|
-
});
|
54
|
-
},
|
55
|
-
{ name: "Field", inheritAttrs: false }
|
56
|
-
);
|
57
|
-
function useForm(opts) {
|
58
|
-
const formApi = (() => {
|
59
|
-
const api = new FormApi(opts);
|
60
|
-
api.Provider = defineComponent(
|
61
|
-
(_, context) => {
|
62
|
-
onMounted(api.mount);
|
63
|
-
provideFormContext({ formApi });
|
64
|
-
return () => context.slots.default();
|
65
|
-
},
|
66
|
-
{ name: "Provider" }
|
67
|
-
);
|
68
|
-
api.provideFormContext = () => {
|
69
|
-
onMounted(api.mount);
|
70
|
-
provideFormContext({ formApi });
|
71
|
-
};
|
72
|
-
api.Field = Field;
|
73
|
-
api.useField = useField;
|
74
|
-
api.useStore = (selector) => {
|
75
|
-
return useStore(api.store, selector);
|
76
|
-
};
|
77
|
-
api.Subscribe = defineComponent(
|
78
|
-
(props, context) => {
|
79
|
-
const allProps = { ...props, ...context.attrs };
|
80
|
-
const selector = allProps.selector ?? ((state) => state);
|
81
|
-
const data = useStore(api.store, selector);
|
82
|
-
return () => context.slots.default(data.value);
|
83
|
-
},
|
84
|
-
{
|
85
|
-
name: "Subscribe",
|
86
|
-
inheritAttrs: false
|
87
|
-
}
|
88
|
-
);
|
89
|
-
return api;
|
90
|
-
})();
|
91
|
-
formApi.update(opts);
|
92
|
-
return formApi;
|
93
|
-
}
|
94
|
-
function createFormFactory(defaultOpts) {
|
95
|
-
return {
|
96
|
-
useForm: (opts) => {
|
97
|
-
const formOptions = Object.assign({}, defaultOpts, opts);
|
98
|
-
return useForm(formOptions);
|
99
|
-
},
|
100
|
-
useField,
|
101
|
-
Field
|
102
|
-
};
|
103
|
-
}
|
104
|
-
export {
|
105
|
-
Field,
|
106
|
-
createFormFactory,
|
107
|
-
formContext,
|
108
|
-
provideFormContext,
|
109
|
-
useField,
|
110
|
-
useForm,
|
111
|
-
useFormContext
|
112
|
-
};
|
113
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/mjs/index.mjs.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/formContext.ts","../../src/useField.tsx","../../src/useForm.tsx","../../src/createFormFactory.ts"],"sourcesContent":["import type { FormApi, Validator } from '@tanstack/form-core'\nimport { inject, provide } from 'vue'\n\nexport type FormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n formApi: FormApi<TFormData, TFormValidator>\n parentFieldName?: string\n} | null\n\nexport const formContext = Symbol('FormContext')\n\nexport function provideFormContext<\n TFormData = any,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(val: FormContext<TFormData, TFormValidator>) {\n provide(formContext, val)\n}\n\nexport function useFormContext() {\n const formApi = inject(formContext) as FormContext\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n","import { FieldApi, type Validator } from '@tanstack/form-core'\nimport type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { defineComponent, onMounted, onUnmounted, watch } from 'vue'\nimport type { SlotsType, SetupContext, Ref } from 'vue'\nimport { provideFormContext, useFormContext } from './formContext'\nimport type { UseFieldOptions } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData = DeepValue<TParentData, TName>,\n > {\n Field: FieldComponent<TParentData, TFormValidator>\n }\n}\n\nexport type UseField<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n>(\n opts?: { name: Narrow<TName> } & UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n >,\n) => FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n DeepValue<TParentData, TName>\n>\n\nexport function useField<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n opts: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >,\n): {\n api: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n // Omit<typeof opts, 'onMount'> & {\n // form: FormApi<TParentData>\n // }\n >\n state: Readonly<\n Ref<\n FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n >\n >\n} {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const fieldApi = (() => {\n const api = new FieldApi({\n ...opts,\n form: formApi,\n name: opts.name,\n } as never)\n\n api.Field = Field as never\n\n return api\n })()\n\n const fieldState = useStore(fieldApi.store, (state) => state)\n\n let cleanup!: () => void\n onMounted(() => {\n cleanup = fieldApi.mount()\n })\n\n onUnmounted(() => {\n cleanup()\n })\n\n watch(\n () => opts,\n () => {\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi } as never)\n },\n )\n\n return { api: fieldApi, state: fieldState } as never\n}\n\nexport type FieldValue<TParentData, TName> = TParentData extends any[]\n ? unknown extends TName\n ? TParentData[number]\n : DeepValue<TParentData[number], TName>\n : DeepValue<TParentData, TName>\n\ntype FieldComponentProps<\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = (TParentData extends any[]\n ? {\n name?: TName\n index: number\n }\n : {\n name: TName\n index?: never\n }) &\n Omit<\n UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator>,\n 'name' | 'index'\n >\n\nexport type FieldComponent<\n TParentData,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n> = <\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,\n>(\n fieldOptions: FieldComponentProps<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext<\n {},\n SlotsType<{\n default: {\n field: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >\n state: FieldApi<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator,\n TData\n >['state']\n }\n }>\n >,\n) => any\n\nexport const Field = defineComponent(\n <\n TParentData,\n TName extends DeepKeys<TParentData>,\n TFieldValidator extends\n | Validator<DeepValue<TParentData, TName>, unknown>\n | undefined = undefined,\n TFormValidator extends\n | Validator<TParentData, unknown>\n | undefined = undefined,\n >(\n fieldOptions: UseFieldOptions<\n TParentData,\n TName,\n TFieldValidator,\n TFormValidator\n >,\n context: SetupContext,\n ) => {\n const fieldApi = useField({ ...fieldOptions, ...context.attrs } as any)\n\n provideFormContext({\n formApi: fieldApi.api.form,\n parentFieldName: fieldApi.api.name,\n } as never)\n\n return () =>\n context.slots.default!({\n field: fieldApi.api,\n state: fieldApi.state.value,\n })\n },\n { name: 'Field', inheritAttrs: false },\n)\n","import {\n FormApi,\n type FormState,\n type FormOptions,\n type Validator,\n} from '@tanstack/form-core'\nimport { type NoInfer, useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport {\n type EmitsOptions,\n type SlotsType,\n type SetupContext,\n type Ref,\n defineComponent,\n onMounted,\n} from 'vue'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData, TFormValidator> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => Readonly<Ref<TSelected>>\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(\n props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n },\n context: SetupContext<\n EmitsOptions,\n SlotsType<{ default: NoInfer<FormState<TFormData>> }>\n >,\n ) => any\n }\n}\n\nexport function useForm<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n opts?: FormOptions<TFormData, TFormValidator>,\n): FormApi<TFormData, TFormValidator> {\n const formApi = (() => {\n const api = new FormApi<TFormData, TFormValidator>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n onMounted(api.mount)\n provideFormContext({ formApi: formApi as never })\n }\n api.Field = Field as never\n api.useField = useField as never\n api.useStore = (selector) => {\n return useStore(api.store as never, selector as never) as never\n }\n api.Subscribe = defineComponent(\n (props, context) => {\n const allProps = { ...props, ...context.attrs }\n const selector = allProps.selector ?? ((state) => state)\n const data = useStore(api.store as never, selector as never)\n return () => context.slots.default!(data.value)\n },\n {\n name: 'Subscribe',\n inheritAttrs: false,\n },\n )\n\n return api\n })()\n\n // formApi.useStore((state) => state.isSubmitting)\n formApi.update(opts)\n\n return formApi as never\n}\n","import type { FormApi, FormOptions, Validator } from '@tanstack/form-core'\n\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { useForm } from './useForm'\n\nexport type FormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n> = {\n useForm: (\n opts?: FormOptions<TFormData, TFormValidator>,\n ) => FormApi<TFormData, TFormValidator>\n useField: UseField<TFormData, TFormValidator>\n Field: FieldComponent<TFormData, TFormValidator>\n}\n\nexport function createFormFactory<\n TFormData,\n TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,\n>(\n defaultOpts?: FormOptions<TFormData, TFormValidator>,\n): FormFactory<TFormData, TFormValidator> {\n return {\n useForm: (opts) => {\n const formOptions = Object.assign({}, defaultOpts, opts)\n return useForm<TFormData, TFormValidator>(formOptions)\n },\n useField: useField as any,\n Field: Field as any,\n }\n}\n"],"names":[],"mappings":";;;;AAWa,MAAA,cAAc,OAAO,aAAa;AAExC,SAAS,mBAGd,KAA6C;AAC7C,UAAQ,aAAa,GAAG;AAC1B;AAEO,SAAS,iBAAiB;AACzB,QAAA,UAAU,OAAO,WAAW;AAElC,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAEO,SAAA;AACT;ACuBO,SAAS,SAWd,MA6BA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,YAAY,MAAM;AAChB,UAAA,MAAM,IAAI,SAAS;AAAA,MACvB,GAAG;AAAA,MACH,MAAM;AAAA,MACN,MAAM,KAAK;AAAA,IAAA,CACH;AAEV,QAAI,QAAQ;AAEL,WAAA;AAAA,EAAA;AAGT,QAAM,aAAa,SAAS,SAAS,OAAO,CAAC,UAAU,KAAK;AAExD,MAAA;AACJ,YAAU,MAAM;AACd,cAAU,SAAS;EAAM,CAC1B;AAED,cAAY,MAAM;AACR;EAAA,CACT;AAED;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAEJ,eAAS,OAAO,EAAE,GAAG,MAAM,MAAM,SAAkB;AAAA,IACrD;AAAA,EAAA;AAGF,SAAO,EAAE,KAAK,UAAU,OAAO,WAAW;AAC5C;AAwEO,MAAM,QAAQ;AAAA,EACnB,CAUE,cAMA,YACG;AACG,UAAA,WAAW,SAAS,EAAE,GAAG,cAAc,GAAG,QAAQ,OAAc;AAEnD,uBAAA;AAAA,MACjB,SAAS,SAAS,IAAI;AAAA,MACtB,iBAAiB,SAAS,IAAI;AAAA,IAAA,CACtB;AAEH,WAAA,MACL,QAAQ,MAAM,QAAS;AAAA,MACrB,OAAO,SAAS;AAAA,MAChB,OAAO,SAAS,MAAM;AAAA,IAAA,CACvB;AAAA,EACL;AAAA,EACA,EAAE,MAAM,SAAS,cAAc,MAAM;AACvC;AChMO,SAAS,QAId,MACoC;AACpC,QAAM,WAAW,MAAM;AACf,UAAA,MAAM,IAAI,QAAmC,IAAI;AAEvD,QAAI,WAAW;AAAA,MACb,CAAC,GAAG,YAAY;AACd,kBAAU,IAAI,KAAK;AACA,2BAAA,EAAE,SAA2B;AACzC,eAAA,MAAM,QAAQ,MAAM;MAC7B;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IAAA;AAErB,QAAI,qBAAqB,MAAM;AAC7B,gBAAU,IAAI,KAAK;AACA,yBAAA,EAAE,SAA2B;AAAA,IAAA;AAElD,QAAI,QAAQ;AACZ,QAAI,WAAW;AACX,QAAA,WAAW,CAAC,aAAa;AACpB,aAAA,SAAS,IAAI,OAAgB,QAAiB;AAAA,IAAA;AAEvD,QAAI,YAAY;AAAA,MACd,CAAC,OAAO,YAAY;AAClB,cAAM,WAAW,EAAE,GAAG,OAAO,GAAG,QAAQ,MAAM;AAC9C,cAAM,WAAW,SAAS,aAAa,CAAC,UAAU;AAClD,cAAM,OAAO,SAAS,IAAI,OAAgB,QAAiB;AAC3D,eAAO,MAAM,QAAQ,MAAM,QAAS,KAAK,KAAK;AAAA,MAChD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,cAAc;AAAA,MAChB;AAAA,IAAA;AAGK,WAAA;AAAA,EAAA;AAIT,UAAQ,OAAO,IAAI;AAEZ,SAAA;AACT;ACtEO,SAAS,kBAId,aACwC;AACjC,SAAA;AAAA,IACL,SAAS,CAAC,SAAS;AACjB,YAAM,cAAc,OAAO,OAAO,CAAA,GAAI,aAAa,IAAI;AACvD,aAAO,QAAmC,WAAW;AAAA,IACvD;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
@@ -1 +0,0 @@
|
|
1
|
-
/// <reference lib="dom" />
|
@@ -1 +0,0 @@
|
|
1
|
-
/// <reference lib="dom" />
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function sleep(timeout: number): Promise<void>;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|