@tanstack/vue-form 0.2.0 → 0.2.2
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.d.cts +11 -2
- package/build/legacy/createFormFactory.d.ts +11 -2
- package/build/legacy/index.d.cts +4 -20
- package/build/legacy/index.d.ts +4 -20
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +2 -1
- package/build/legacy/types.d.ts +2 -1
- package/build/legacy/useField.cjs +71 -0
- package/build/legacy/useField.cjs.map +1 -0
- package/build/legacy/{createFormFactory-161e85f9.d.ts → useField.d.cts} +2 -9
- package/build/{modern/createFormFactory-161e85f9.d.ts → legacy/useField.d.ts} +2 -9
- package/build/legacy/useField.js +52 -0
- package/build/legacy/useField.js.map +1 -0
- package/build/legacy/useForm.cjs +70 -0
- package/build/legacy/useForm.cjs.map +1 -0
- package/build/legacy/useForm.d.cts +20 -0
- package/build/legacy/useForm.d.ts +20 -0
- package/build/legacy/useForm.js +45 -0
- package/build/legacy/useForm.js.map +1 -0
- package/build/lib/types.d.ts +1 -0
- package/build/lib/types.d.ts.map +1 -1
- package/build/modern/createFormFactory.d.cts +11 -2
- package/build/modern/createFormFactory.d.ts +11 -2
- package/build/modern/index.d.cts +4 -20
- package/build/modern/index.d.ts +4 -20
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +2 -1
- package/build/modern/types.d.ts +2 -1
- package/build/modern/useField.cjs +71 -0
- package/build/modern/useField.cjs.map +1 -0
- package/build/modern/useField.d.cts +35 -0
- package/build/modern/useField.d.ts +35 -0
- package/build/modern/useField.js +52 -0
- package/build/modern/useField.js.map +1 -0
- package/build/modern/useForm.cjs +70 -0
- package/build/modern/useForm.cjs.map +1 -0
- package/build/modern/useForm.d.cts +20 -0
- package/build/modern/useForm.d.ts +20 -0
- package/build/modern/useForm.js +45 -0
- package/build/modern/useForm.js.map +1 -0
- package/package.json +1 -1
- package/src/types.ts +2 -0
@@ -1,3 +1,12 @@
|
|
1
|
-
import '@tanstack/form-core';
|
2
|
-
|
1
|
+
import { FormOptions, FormApi } from '@tanstack/form-core';
|
2
|
+
import { UseField, FieldComponent } from './useField.cjs';
|
3
3
|
import 'vue-demi';
|
4
|
+
|
5
|
+
type FormFactory<TFormData> = {
|
6
|
+
useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>;
|
7
|
+
useField: UseField<TFormData>;
|
8
|
+
Field: FieldComponent<TFormData, TFormData>;
|
9
|
+
};
|
10
|
+
declare function createFormFactory<TFormData>(defaultOpts?: FormOptions<TFormData>): FormFactory<TFormData>;
|
11
|
+
|
12
|
+
export { FormFactory, createFormFactory };
|
@@ -1,3 +1,12 @@
|
|
1
|
-
import '@tanstack/form-core';
|
2
|
-
|
1
|
+
import { FormOptions, FormApi } from '@tanstack/form-core';
|
2
|
+
import { UseField, FieldComponent } from './useField.js';
|
3
3
|
import 'vue-demi';
|
4
|
+
|
5
|
+
type FormFactory<TFormData> = {
|
6
|
+
useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>;
|
7
|
+
useField: UseField<TFormData>;
|
8
|
+
Field: FieldComponent<TFormData, TFormData>;
|
9
|
+
};
|
10
|
+
declare function createFormFactory<TFormData>(defaultOpts?: FormOptions<TFormData>): FormFactory<TFormData>;
|
11
|
+
|
12
|
+
export { FormFactory, createFormFactory };
|
package/build/legacy/index.d.cts
CHANGED
@@ -1,23 +1,7 @@
|
|
1
|
-
import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
|
2
1
|
export * from '@tanstack/form-core';
|
3
|
-
|
4
|
-
export { e as Field, d as FieldValue, a as FormFactory, b as UseFieldOptions, c as createFormFactory, u as useField } from './createFormFactory-161e85f9.js';
|
2
|
+
export { FormFactory, createFormFactory } from './createFormFactory.cjs';
|
5
3
|
export { FormContext, formContext, provideFormContext, useFormContext } from './formContext.cjs';
|
6
|
-
|
4
|
+
export { Field, FieldComponent, FieldValue, UseField, UseFieldOptions, useField } from './useField.cjs';
|
5
|
+
export { useForm } from './useForm.cjs';
|
7
6
|
import 'vue-demi';
|
8
|
-
|
9
|
-
declare module '@tanstack/form-core' {
|
10
|
-
interface FormApi<TFormData> {
|
11
|
-
Provider: (props: Record<string, any> & {}) => any;
|
12
|
-
provideFormContext: () => void;
|
13
|
-
Field: FieldComponent<TFormData, TFormData>;
|
14
|
-
useField: UseField<TFormData>;
|
15
|
-
useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
|
16
|
-
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
|
17
|
-
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
|
18
|
-
}) => any;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
|
22
|
-
|
23
|
-
export { FieldComponent, UseField, useForm };
|
7
|
+
import './types.cjs';
|
package/build/legacy/index.d.ts
CHANGED
@@ -1,23 +1,7 @@
|
|
1
|
-
import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
|
2
1
|
export * from '@tanstack/form-core';
|
3
|
-
|
4
|
-
export { e as Field, d as FieldValue, a as FormFactory, b as UseFieldOptions, c as createFormFactory, u as useField } from './createFormFactory-161e85f9.js';
|
2
|
+
export { FormFactory, createFormFactory } from './createFormFactory.js';
|
5
3
|
export { FormContext, formContext, provideFormContext, useFormContext } from './formContext.js';
|
6
|
-
|
4
|
+
export { Field, FieldComponent, FieldValue, UseField, UseFieldOptions, useField } from './useField.js';
|
5
|
+
export { useForm } from './useForm.js';
|
7
6
|
import 'vue-demi';
|
8
|
-
|
9
|
-
declare module '@tanstack/form-core' {
|
10
|
-
interface FormApi<TFormData> {
|
11
|
-
Provider: (props: Record<string, any> & {}) => any;
|
12
|
-
provideFormContext: () => void;
|
13
|
-
Field: FieldComponent<TFormData, TFormData>;
|
14
|
-
useField: UseField<TFormData>;
|
15
|
-
useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
|
16
|
-
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
|
17
|
-
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
|
18
|
-
}) => any;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
|
22
|
-
|
23
|
-
export { FieldComponent, UseField, useForm };
|
7
|
+
import './types.js';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["export type NoInfer<T> = [T][T extends any ? 0 : never]\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
1
|
+
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["export type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport type ReleaseVersion = 2\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/build/legacy/types.d.cts
CHANGED
package/build/legacy/types.d.ts
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/useField.tsx
|
21
|
+
var useField_exports = {};
|
22
|
+
__export(useField_exports, {
|
23
|
+
Field: () => Field,
|
24
|
+
useField: () => useField
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(useField_exports);
|
27
|
+
var import_form_core = require("@tanstack/form-core");
|
28
|
+
var import_vue_store = require("@tanstack/vue-store");
|
29
|
+
var import_vue_demi = require("vue-demi");
|
30
|
+
var import_formContext = require("./formContext.cjs");
|
31
|
+
function useField(opts) {
|
32
|
+
const { formApi, parentFieldName } = (0, import_formContext.useFormContext)();
|
33
|
+
const fieldApi = (() => {
|
34
|
+
const name = (typeof opts.index === "number" ? [parentFieldName, opts.index, opts.name] : [parentFieldName, opts.name]).filter((d) => d !== void 0).join(".");
|
35
|
+
const api = new import_form_core.FieldApi({ ...opts, form: formApi, name });
|
36
|
+
api.Field = Field;
|
37
|
+
return api;
|
38
|
+
})();
|
39
|
+
const fieldState = (0, import_vue_store.useStore)(fieldApi.store, (state) => state);
|
40
|
+
let cleanup;
|
41
|
+
(0, import_vue_demi.onMounted)(() => {
|
42
|
+
cleanup = fieldApi.mount();
|
43
|
+
});
|
44
|
+
(0, import_vue_demi.onUnmounted)(() => {
|
45
|
+
cleanup();
|
46
|
+
});
|
47
|
+
(0, import_vue_demi.watch)(
|
48
|
+
() => opts,
|
49
|
+
() => {
|
50
|
+
fieldApi.update({ ...opts, form: formApi });
|
51
|
+
}
|
52
|
+
);
|
53
|
+
return { api: fieldApi, state: fieldState };
|
54
|
+
}
|
55
|
+
var Field = (0, import_vue_demi.defineComponent)(
|
56
|
+
(fieldOptions, context) => {
|
57
|
+
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
58
|
+
(0, import_formContext.provideFormContext)({
|
59
|
+
formApi: fieldApi.api.form,
|
60
|
+
parentFieldName: fieldApi.api.name
|
61
|
+
});
|
62
|
+
return () => context.slots.default(fieldApi.api, fieldApi.state.value);
|
63
|
+
},
|
64
|
+
{ name: "Field", inheritAttrs: false }
|
65
|
+
);
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
67
|
+
0 && (module.exports = {
|
68
|
+
Field,
|
69
|
+
useField
|
70
|
+
});
|
71
|
+
//# sourceMappingURL=useField.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import {\n type DeepKeys,\n type DeepValue,\n FieldApi,\n type FieldOptions,\n type Narrow,\n} from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport {\n type SetupContext,\n defineComponent,\n type Ref,\n onMounted,\n onUnmounted,\n watch,\n} from 'vue-demi'\nimport { provideFormContext, useFormContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<TData, TFormData> {\n Field: FieldComponent<TData, TFormData>\n }\n}\n\nexport interface UseFieldOptions<TData, TFormData>\n extends FieldOptions<TData, TFormData> {\n mode?: 'value' | 'array'\n}\n\nexport type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(\n opts?: { name: Narrow<TField> } & UseFieldOptions<\n DeepValue<TFormData, TField>,\n TFormData\n >,\n) => FieldApi<DeepValue<TFormData, TField>, TFormData>\n\nexport function useField<TData, TFormData>(\n opts: UseFieldOptions<TData, TFormData>,\n): {\n api: FieldApi<TData, TFormData>\n state: Readonly<Ref<FieldApi<TData, TFormData>['state']>>\n} {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const fieldApi = (() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({ ...opts, form: formApi, name: name 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\n// export type FieldValue<TFormData, TField> = TFormData extends any[]\n// ? TField extends `[${infer TIndex extends number | 'i'}].${infer TRest}`\n// ? DeepValue<TFormData[TIndex extends 'i' ? number : TIndex], TRest>\n// : TField extends `[${infer TIndex extends number | 'i'}]`\n// ? TFormData[TIndex extends 'i' ? number : TIndex]\n// : never\n// : TField extends `${infer TPrefix}[${infer TIndex extends\n// | number\n// | 'i'}].${infer TRest}`\n// ? DeepValue<\n// DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex],\n// TRest\n// >\n// : TField extends `${infer TPrefix}[${infer TIndex extends number | 'i'}]`\n// ? DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex]\n// : DeepValue<TFormData, TField>\n\nexport type FieldValue<TFormData, TField> = TFormData extends any[]\n ? unknown extends TField\n ? TFormData[number]\n : DeepValue<TFormData[number], TField>\n : DeepValue<TFormData, TField>\n\n// type Test1 = FieldValue<{ foo: { bar: string }[] }, 'foo'>\n// // ^?\n// type Test2 = FieldValue<{ foo: { bar: string }[] }, 'foo[i]'>\n// // ^?\n// type Test3 = FieldValue<{ foo: { bar: string }[] }, 'foo[2].bar'>\n// // ^?\n\nexport type FieldComponent<TParentData, TFormData> = <TField>(\n fieldOptions: {\n children?: (\n fieldApi: FieldApi<FieldValue<TParentData, TField>, TFormData>,\n ) => any\n } & Omit<\n UseFieldOptions<FieldValue<TParentData, TField>, TFormData>,\n 'name' | 'index'\n > &\n (TParentData extends any[]\n ? {\n name?: TField extends undefined ? TField : DeepKeys<TParentData>\n index: number\n }\n : {\n name: TField extends undefined ? TField : DeepKeys<TParentData>\n index?: never\n }),\n context: SetupContext,\n) => any\n\nexport const Field = defineComponent(\n <TData, TFormData>(\n fieldOptions: UseFieldOptions<TData, TFormData>,\n context: SetupContext,\n ) => {\n const fieldApi = useField({ ...fieldOptions, ...context.attrs })\n\n provideFormContext({\n formApi: fieldApi.api.form,\n parentFieldName: fieldApi.api.name,\n } as never)\n\n return () => context.slots.default!(fieldApi.api, fieldApi.state.value)\n },\n { name: 'Field', inheritAttrs: false },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAMO;AACP,uBAAyB;AACzB,sBAOO;AACP,yBAAmD;AAqB5C,SAAS,SACd,MAIA;AAEA,QAAM,EAAE,SAAS,gBAAgB,QAAI,mCAAe;AAEpD,QAAM,YAAY,MAAM;AACtB,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,0BAAS,EAAE,GAAG,MAAM,MAAM,SAAS,KAAoB,CAAC;AAExE,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,GAAG;AAEH,QAAM,iBAAa,2BAAS,SAAS,OAAO,CAAC,UAAU,KAAK;AAE5D,MAAI;AACJ,iCAAU,MAAM;AACd,cAAU,SAAS,MAAM;AAAA,EAC3B,CAAC;AAED,mCAAY,MAAM;AAChB,YAAQ;AAAA,EACV,CAAC;AAED;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAEJ,eAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,IACrD;AAAA,EACF;AAEA,SAAO,EAAE,KAAK,UAAU,OAAO,WAAW;AAC5C;AAqDO,IAAM,YAAQ;AAAA,EACnB,CACE,cACA,YACG;AACH,UAAM,WAAW,SAAS,EAAE,GAAG,cAAc,GAAG,QAAQ,MAAM,CAAC;AAE/D,+CAAmB;AAAA,MACjB,SAAS,SAAS,IAAI;AAAA,MACtB,iBAAiB,SAAS,IAAI;AAAA,IAChC,CAAU;AAEV,WAAO,MAAM,QAAQ,MAAM,QAAS,SAAS,KAAK,SAAS,MAAM,KAAK;AAAA,EACxE;AAAA,EACA,EAAE,MAAM,SAAS,cAAc,MAAM;AACvC;","names":[]}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FieldApi, DeepKeys, FieldOptions, Narrow, DeepValue
|
1
|
+
import { FieldApi, DeepKeys, FieldOptions, Narrow, DeepValue } from '@tanstack/form-core';
|
2
2
|
import { SetupContext, Ref } from 'vue-demi';
|
3
3
|
|
4
4
|
declare module '@tanstack/form-core' {
|
@@ -32,11 +32,4 @@ declare const Field: <TData, TFormData>(props: UseFieldOptions<TData, TFormData>
|
|
32
32
|
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
33
33
|
})) => any;
|
34
34
|
|
35
|
-
|
36
|
-
useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>;
|
37
|
-
useField: UseField<TFormData>;
|
38
|
-
Field: FieldComponent<TFormData, TFormData>;
|
39
|
-
};
|
40
|
-
declare function createFormFactory<TFormData>(defaultOpts?: FormOptions<TFormData>): FormFactory<TFormData>;
|
41
|
-
|
42
|
-
export { FieldComponent as F, UseField as U, FormFactory as a, UseFieldOptions as b, createFormFactory as c, FieldValue as d, Field as e, useField as u };
|
35
|
+
export { Field, FieldComponent, FieldValue, UseField, UseFieldOptions, useField };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FieldApi, DeepKeys, FieldOptions, Narrow, DeepValue
|
1
|
+
import { FieldApi, DeepKeys, FieldOptions, Narrow, DeepValue } from '@tanstack/form-core';
|
2
2
|
import { SetupContext, Ref } from 'vue-demi';
|
3
3
|
|
4
4
|
declare module '@tanstack/form-core' {
|
@@ -32,11 +32,4 @@ declare const Field: <TData, TFormData>(props: UseFieldOptions<TData, TFormData>
|
|
32
32
|
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
33
33
|
})) => any;
|
34
34
|
|
35
|
-
|
36
|
-
useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>;
|
37
|
-
useField: UseField<TFormData>;
|
38
|
-
Field: FieldComponent<TFormData, TFormData>;
|
39
|
-
};
|
40
|
-
declare function createFormFactory<TFormData>(defaultOpts?: FormOptions<TFormData>): FormFactory<TFormData>;
|
41
|
-
|
42
|
-
export { FieldComponent as F, UseField as U, FormFactory as a, UseFieldOptions as b, createFormFactory as c, FieldValue as d, Field as e, useField as u };
|
35
|
+
export { Field, FieldComponent, FieldValue, UseField, UseFieldOptions, useField };
|
@@ -0,0 +1,52 @@
|
|
1
|
+
// src/useField.tsx
|
2
|
+
import {
|
3
|
+
FieldApi
|
4
|
+
} from "@tanstack/form-core";
|
5
|
+
import { useStore } from "@tanstack/vue-store";
|
6
|
+
import {
|
7
|
+
defineComponent,
|
8
|
+
onMounted,
|
9
|
+
onUnmounted,
|
10
|
+
watch
|
11
|
+
} from "vue-demi";
|
12
|
+
import { provideFormContext, useFormContext } from "./formContext.js";
|
13
|
+
function useField(opts) {
|
14
|
+
const { formApi, parentFieldName } = useFormContext();
|
15
|
+
const fieldApi = (() => {
|
16
|
+
const name = (typeof opts.index === "number" ? [parentFieldName, opts.index, opts.name] : [parentFieldName, opts.name]).filter((d) => d !== void 0).join(".");
|
17
|
+
const api = new FieldApi({ ...opts, form: formApi, name });
|
18
|
+
api.Field = Field;
|
19
|
+
return api;
|
20
|
+
})();
|
21
|
+
const fieldState = useStore(fieldApi.store, (state) => state);
|
22
|
+
let cleanup;
|
23
|
+
onMounted(() => {
|
24
|
+
cleanup = fieldApi.mount();
|
25
|
+
});
|
26
|
+
onUnmounted(() => {
|
27
|
+
cleanup();
|
28
|
+
});
|
29
|
+
watch(
|
30
|
+
() => opts,
|
31
|
+
() => {
|
32
|
+
fieldApi.update({ ...opts, form: formApi });
|
33
|
+
}
|
34
|
+
);
|
35
|
+
return { api: fieldApi, state: fieldState };
|
36
|
+
}
|
37
|
+
var Field = defineComponent(
|
38
|
+
(fieldOptions, context) => {
|
39
|
+
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
40
|
+
provideFormContext({
|
41
|
+
formApi: fieldApi.api.form,
|
42
|
+
parentFieldName: fieldApi.api.name
|
43
|
+
});
|
44
|
+
return () => context.slots.default(fieldApi.api, fieldApi.state.value);
|
45
|
+
},
|
46
|
+
{ name: "Field", inheritAttrs: false }
|
47
|
+
);
|
48
|
+
export {
|
49
|
+
Field,
|
50
|
+
useField
|
51
|
+
};
|
52
|
+
//# sourceMappingURL=useField.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import {\n type DeepKeys,\n type DeepValue,\n FieldApi,\n type FieldOptions,\n type Narrow,\n} from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport {\n type SetupContext,\n defineComponent,\n type Ref,\n onMounted,\n onUnmounted,\n watch,\n} from 'vue-demi'\nimport { provideFormContext, useFormContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<TData, TFormData> {\n Field: FieldComponent<TData, TFormData>\n }\n}\n\nexport interface UseFieldOptions<TData, TFormData>\n extends FieldOptions<TData, TFormData> {\n mode?: 'value' | 'array'\n}\n\nexport type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(\n opts?: { name: Narrow<TField> } & UseFieldOptions<\n DeepValue<TFormData, TField>,\n TFormData\n >,\n) => FieldApi<DeepValue<TFormData, TField>, TFormData>\n\nexport function useField<TData, TFormData>(\n opts: UseFieldOptions<TData, TFormData>,\n): {\n api: FieldApi<TData, TFormData>\n state: Readonly<Ref<FieldApi<TData, TFormData>['state']>>\n} {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const fieldApi = (() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({ ...opts, form: formApi, name: name 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\n// export type FieldValue<TFormData, TField> = TFormData extends any[]\n// ? TField extends `[${infer TIndex extends number | 'i'}].${infer TRest}`\n// ? DeepValue<TFormData[TIndex extends 'i' ? number : TIndex], TRest>\n// : TField extends `[${infer TIndex extends number | 'i'}]`\n// ? TFormData[TIndex extends 'i' ? number : TIndex]\n// : never\n// : TField extends `${infer TPrefix}[${infer TIndex extends\n// | number\n// | 'i'}].${infer TRest}`\n// ? DeepValue<\n// DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex],\n// TRest\n// >\n// : TField extends `${infer TPrefix}[${infer TIndex extends number | 'i'}]`\n// ? DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex]\n// : DeepValue<TFormData, TField>\n\nexport type FieldValue<TFormData, TField> = TFormData extends any[]\n ? unknown extends TField\n ? TFormData[number]\n : DeepValue<TFormData[number], TField>\n : DeepValue<TFormData, TField>\n\n// type Test1 = FieldValue<{ foo: { bar: string }[] }, 'foo'>\n// // ^?\n// type Test2 = FieldValue<{ foo: { bar: string }[] }, 'foo[i]'>\n// // ^?\n// type Test3 = FieldValue<{ foo: { bar: string }[] }, 'foo[2].bar'>\n// // ^?\n\nexport type FieldComponent<TParentData, TFormData> = <TField>(\n fieldOptions: {\n children?: (\n fieldApi: FieldApi<FieldValue<TParentData, TField>, TFormData>,\n ) => any\n } & Omit<\n UseFieldOptions<FieldValue<TParentData, TField>, TFormData>,\n 'name' | 'index'\n > &\n (TParentData extends any[]\n ? {\n name?: TField extends undefined ? TField : DeepKeys<TParentData>\n index: number\n }\n : {\n name: TField extends undefined ? TField : DeepKeys<TParentData>\n index?: never\n }),\n context: SetupContext,\n) => any\n\nexport const Field = defineComponent(\n <TData, TFormData>(\n fieldOptions: UseFieldOptions<TData, TFormData>,\n context: SetupContext,\n ) => {\n const fieldApi = useField({ ...fieldOptions, ...context.attrs })\n\n provideFormContext({\n formApi: fieldApi.api.form,\n parentFieldName: fieldApi.api.name,\n } as never)\n\n return () => context.slots.default!(fieldApi.api, fieldApi.state.value)\n },\n { name: 'Field', inheritAttrs: false },\n)\n"],"mappings":";AAAA;AAAA,EAGE;AAAA,OAGK;AACP,SAAS,gBAAgB;AACzB;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;AAqB5C,SAAS,SACd,MAIA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,YAAY,MAAM;AACtB,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,SAAS,EAAE,GAAG,MAAM,MAAM,SAAS,KAAoB,CAAC;AAExE,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,GAAG;AAEH,QAAM,aAAa,SAAS,SAAS,OAAO,CAAC,UAAU,KAAK;AAE5D,MAAI;AACJ,YAAU,MAAM;AACd,cAAU,SAAS,MAAM;AAAA,EAC3B,CAAC;AAED,cAAY,MAAM;AAChB,YAAQ;AAAA,EACV,CAAC;AAED;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAEJ,eAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,IACrD;AAAA,EACF;AAEA,SAAO,EAAE,KAAK,UAAU,OAAO,WAAW;AAC5C;AAqDO,IAAM,QAAQ;AAAA,EACnB,CACE,cACA,YACG;AACH,UAAM,WAAW,SAAS,EAAE,GAAG,cAAc,GAAG,QAAQ,MAAM,CAAC;AAE/D,uBAAmB;AAAA,MACjB,SAAS,SAAS,IAAI;AAAA,MACtB,iBAAiB,SAAS,IAAI;AAAA,IAChC,CAAU;AAEV,WAAO,MAAM,QAAQ,MAAM,QAAS,SAAS,KAAK,SAAS,MAAM,KAAK;AAAA,EACxE;AAAA,EACA,EAAE,MAAM,SAAS,cAAc,MAAM;AACvC;","names":[]}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/useForm.tsx
|
21
|
+
var useForm_exports = {};
|
22
|
+
__export(useForm_exports, {
|
23
|
+
useForm: () => useForm
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(useForm_exports);
|
26
|
+
var import_form_core = require("@tanstack/form-core");
|
27
|
+
var import_vue_store = require("@tanstack/vue-store");
|
28
|
+
var import_useField = require("./useField.cjs");
|
29
|
+
var import_formContext = require("./formContext.cjs");
|
30
|
+
var import_vue_demi = require("vue-demi");
|
31
|
+
function useForm(opts) {
|
32
|
+
const formApi = (() => {
|
33
|
+
const api = new import_form_core.FormApi(opts);
|
34
|
+
api.Provider = (0, import_vue_demi.defineComponent)(
|
35
|
+
(_, context) => {
|
36
|
+
(0, import_formContext.provideFormContext)({ formApi });
|
37
|
+
return () => context.slots.default();
|
38
|
+
},
|
39
|
+
{ name: "Provider" }
|
40
|
+
);
|
41
|
+
api.provideFormContext = () => {
|
42
|
+
(0, import_formContext.provideFormContext)({ formApi });
|
43
|
+
};
|
44
|
+
api.Field = import_useField.Field;
|
45
|
+
api.useField = import_useField.useField;
|
46
|
+
api.useStore = (selector) => {
|
47
|
+
return (0, import_vue_store.useStore)(api.store, selector);
|
48
|
+
};
|
49
|
+
api.Subscribe = (0, import_vue_demi.defineComponent)(
|
50
|
+
(props, context) => {
|
51
|
+
const allProps = { ...props, ...context.attrs };
|
52
|
+
const selector = allProps.selector ?? ((state) => state);
|
53
|
+
const data = (0, import_vue_store.useStore)(api.store, selector);
|
54
|
+
return () => context.slots.default(data.value);
|
55
|
+
},
|
56
|
+
{
|
57
|
+
name: "Subscribe",
|
58
|
+
inheritAttrs: false
|
59
|
+
}
|
60
|
+
);
|
61
|
+
return api;
|
62
|
+
})();
|
63
|
+
formApi.update(opts);
|
64
|
+
return formApi;
|
65
|
+
}
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
67
|
+
0 && (module.exports = {
|
68
|
+
useForm
|
69
|
+
});
|
70
|
+
//# sourceMappingURL=useForm.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/useForm.tsx"],"sourcesContent":["import { FormApi, type FormState, type FormOptions } from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport { defineComponent } from 'vue-demi'\nimport type { NoInfer } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n }) => any\n }\n}\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const formApi = (() => {\n const api = new FormApi<TData>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n provideFormContext({ formApi })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n provideFormContext({ formApi })\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0D;AAC1D,uBAAyB;AACzB,sBAAoE;AACpE,yBAAmC;AACnC,sBAAgC;AAmBzB,SAAS,QAAe,MAA2C;AACxE,QAAM,WAAW,MAAM;AACrB,UAAM,MAAM,IAAI,yBAAe,IAAI;AAEnC,QAAI,eAAW;AAAA,MACb,CAAC,GAAG,YAAY;AACd,mDAAmB,EAAE,QAAQ,CAAC;AAC9B,eAAO,MAAM,QAAQ,MAAM,QAAS;AAAA,MACtC;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IACrB;AACA,QAAI,qBAAqB,MAAM;AAC7B,iDAAmB,EAAE,QAAQ,CAAC;AAAA,IAChC;AACA,QAAI,QAAQ;AACZ,QAAI,WAAW;AACf,QAAI,WAAW,CAAC,aAAa;AAC3B,iBAAO,2BAAS,IAAI,OAAgB,QAAiB;AAAA,IACvD;AACA,QAAI,gBAAY;AAAA,MACd,CAAC,OAAO,YAAY;AAClB,cAAM,WAAW,EAAE,GAAG,OAAO,GAAG,QAAQ,MAAM;AAC9C,cAAM,WAAW,SAAS,aAAa,CAAC,UAAU;AAClD,cAAM,WAAO,2BAAS,IAAI,OAAgB,QAAiB;AAC3D,eAAO,MAAM,QAAQ,MAAM,QAAS,KAAK,KAAK;AAAA,MAChD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,cAAc;AAAA,MAChB;AAAA,IACF;AAEA,WAAO;AAAA,EACT,GAAG;AAGH,UAAQ,OAAO,IAAI;AAEnB,SAAO;AACT;","names":[]}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
|
2
|
+
import { FieldComponent, UseField } from './useField.cjs';
|
3
|
+
import { NoInfer } from './types.cjs';
|
4
|
+
import 'vue-demi';
|
5
|
+
|
6
|
+
declare module '@tanstack/form-core' {
|
7
|
+
interface FormApi<TFormData> {
|
8
|
+
Provider: (props: Record<string, any> & {}) => any;
|
9
|
+
provideFormContext: () => void;
|
10
|
+
Field: FieldComponent<TFormData, TFormData>;
|
11
|
+
useField: UseField<TFormData>;
|
12
|
+
useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
|
13
|
+
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
|
14
|
+
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
|
15
|
+
}) => any;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
|
19
|
+
|
20
|
+
export { useForm };
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
|
2
|
+
import { FieldComponent, UseField } from './useField.js';
|
3
|
+
import { NoInfer } from './types.js';
|
4
|
+
import 'vue-demi';
|
5
|
+
|
6
|
+
declare module '@tanstack/form-core' {
|
7
|
+
interface FormApi<TFormData> {
|
8
|
+
Provider: (props: Record<string, any> & {}) => any;
|
9
|
+
provideFormContext: () => void;
|
10
|
+
Field: FieldComponent<TFormData, TFormData>;
|
11
|
+
useField: UseField<TFormData>;
|
12
|
+
useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
|
13
|
+
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
|
14
|
+
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
|
15
|
+
}) => any;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
|
19
|
+
|
20
|
+
export { useForm };
|
@@ -0,0 +1,45 @@
|
|
1
|
+
// src/useForm.tsx
|
2
|
+
import { FormApi } from "@tanstack/form-core";
|
3
|
+
import { useStore } from "@tanstack/vue-store";
|
4
|
+
import { Field, useField } from "./useField.js";
|
5
|
+
import { provideFormContext } from "./formContext.js";
|
6
|
+
import { defineComponent } from "vue-demi";
|
7
|
+
function useForm(opts) {
|
8
|
+
const formApi = (() => {
|
9
|
+
const api = new FormApi(opts);
|
10
|
+
api.Provider = defineComponent(
|
11
|
+
(_, context) => {
|
12
|
+
provideFormContext({ formApi });
|
13
|
+
return () => context.slots.default();
|
14
|
+
},
|
15
|
+
{ name: "Provider" }
|
16
|
+
);
|
17
|
+
api.provideFormContext = () => {
|
18
|
+
provideFormContext({ formApi });
|
19
|
+
};
|
20
|
+
api.Field = Field;
|
21
|
+
api.useField = useField;
|
22
|
+
api.useStore = (selector) => {
|
23
|
+
return useStore(api.store, selector);
|
24
|
+
};
|
25
|
+
api.Subscribe = defineComponent(
|
26
|
+
(props, context) => {
|
27
|
+
const allProps = { ...props, ...context.attrs };
|
28
|
+
const selector = allProps.selector ?? ((state) => state);
|
29
|
+
const data = useStore(api.store, selector);
|
30
|
+
return () => context.slots.default(data.value);
|
31
|
+
},
|
32
|
+
{
|
33
|
+
name: "Subscribe",
|
34
|
+
inheritAttrs: false
|
35
|
+
}
|
36
|
+
);
|
37
|
+
return api;
|
38
|
+
})();
|
39
|
+
formApi.update(opts);
|
40
|
+
return formApi;
|
41
|
+
}
|
42
|
+
export {
|
43
|
+
useForm
|
44
|
+
};
|
45
|
+
//# sourceMappingURL=useForm.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/useForm.tsx"],"sourcesContent":["import { FormApi, type FormState, type FormOptions } from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport { defineComponent } from 'vue-demi'\nimport type { NoInfer } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n }) => any\n }\n}\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const formApi = (() => {\n const api = new FormApi<TData>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n provideFormContext({ formApi })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n provideFormContext({ formApi })\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"],"mappings":";AAAA,SAAS,eAAiD;AAC1D,SAAS,gBAAgB;AACzB,SAA6C,OAAO,gBAAgB;AACpE,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAmBzB,SAAS,QAAe,MAA2C;AACxE,QAAM,WAAW,MAAM;AACrB,UAAM,MAAM,IAAI,QAAe,IAAI;AAEnC,QAAI,WAAW;AAAA,MACb,CAAC,GAAG,YAAY;AACd,2BAAmB,EAAE,QAAQ,CAAC;AAC9B,eAAO,MAAM,QAAQ,MAAM,QAAS;AAAA,MACtC;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IACrB;AACA,QAAI,qBAAqB,MAAM;AAC7B,yBAAmB,EAAE,QAAQ,CAAC;AAAA,IAChC;AACA,QAAI,QAAQ;AACZ,QAAI,WAAW;AACf,QAAI,WAAW,CAAC,aAAa;AAC3B,aAAO,SAAS,IAAI,OAAgB,QAAiB;AAAA,IACvD;AACA,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,IACF;AAEA,WAAO;AAAA,EACT,GAAG;AAGH,UAAQ,OAAO,IAAI;AAEnB,SAAO;AACT;","names":[]}
|
package/build/lib/types.d.ts
CHANGED
package/build/lib/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA"}
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAA"}
|
@@ -1,3 +1,12 @@
|
|
1
|
-
import '@tanstack/form-core';
|
2
|
-
|
1
|
+
import { FormOptions, FormApi } from '@tanstack/form-core';
|
2
|
+
import { UseField, FieldComponent } from './useField.cjs';
|
3
3
|
import 'vue-demi';
|
4
|
+
|
5
|
+
type FormFactory<TFormData> = {
|
6
|
+
useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>;
|
7
|
+
useField: UseField<TFormData>;
|
8
|
+
Field: FieldComponent<TFormData, TFormData>;
|
9
|
+
};
|
10
|
+
declare function createFormFactory<TFormData>(defaultOpts?: FormOptions<TFormData>): FormFactory<TFormData>;
|
11
|
+
|
12
|
+
export { FormFactory, createFormFactory };
|
@@ -1,3 +1,12 @@
|
|
1
|
-
import '@tanstack/form-core';
|
2
|
-
|
1
|
+
import { FormOptions, FormApi } from '@tanstack/form-core';
|
2
|
+
import { UseField, FieldComponent } from './useField.js';
|
3
3
|
import 'vue-demi';
|
4
|
+
|
5
|
+
type FormFactory<TFormData> = {
|
6
|
+
useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>;
|
7
|
+
useField: UseField<TFormData>;
|
8
|
+
Field: FieldComponent<TFormData, TFormData>;
|
9
|
+
};
|
10
|
+
declare function createFormFactory<TFormData>(defaultOpts?: FormOptions<TFormData>): FormFactory<TFormData>;
|
11
|
+
|
12
|
+
export { FormFactory, createFormFactory };
|
package/build/modern/index.d.cts
CHANGED
@@ -1,23 +1,7 @@
|
|
1
|
-
import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
|
2
1
|
export * from '@tanstack/form-core';
|
3
|
-
|
4
|
-
export { e as Field, d as FieldValue, a as FormFactory, b as UseFieldOptions, c as createFormFactory, u as useField } from './createFormFactory-161e85f9.js';
|
2
|
+
export { FormFactory, createFormFactory } from './createFormFactory.cjs';
|
5
3
|
export { FormContext, formContext, provideFormContext, useFormContext } from './formContext.cjs';
|
6
|
-
|
4
|
+
export { Field, FieldComponent, FieldValue, UseField, UseFieldOptions, useField } from './useField.cjs';
|
5
|
+
export { useForm } from './useForm.cjs';
|
7
6
|
import 'vue-demi';
|
8
|
-
|
9
|
-
declare module '@tanstack/form-core' {
|
10
|
-
interface FormApi<TFormData> {
|
11
|
-
Provider: (props: Record<string, any> & {}) => any;
|
12
|
-
provideFormContext: () => void;
|
13
|
-
Field: FieldComponent<TFormData, TFormData>;
|
14
|
-
useField: UseField<TFormData>;
|
15
|
-
useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
|
16
|
-
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
|
17
|
-
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
|
18
|
-
}) => any;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
|
22
|
-
|
23
|
-
export { FieldComponent, UseField, useForm };
|
7
|
+
import './types.cjs';
|
package/build/modern/index.d.ts
CHANGED
@@ -1,23 +1,7 @@
|
|
1
|
-
import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
|
2
1
|
export * from '@tanstack/form-core';
|
3
|
-
|
4
|
-
export { e as Field, d as FieldValue, a as FormFactory, b as UseFieldOptions, c as createFormFactory, u as useField } from './createFormFactory-161e85f9.js';
|
2
|
+
export { FormFactory, createFormFactory } from './createFormFactory.js';
|
5
3
|
export { FormContext, formContext, provideFormContext, useFormContext } from './formContext.js';
|
6
|
-
|
4
|
+
export { Field, FieldComponent, FieldValue, UseField, UseFieldOptions, useField } from './useField.js';
|
5
|
+
export { useForm } from './useForm.js';
|
7
6
|
import 'vue-demi';
|
8
|
-
|
9
|
-
declare module '@tanstack/form-core' {
|
10
|
-
interface FormApi<TFormData> {
|
11
|
-
Provider: (props: Record<string, any> & {}) => any;
|
12
|
-
provideFormContext: () => void;
|
13
|
-
Field: FieldComponent<TFormData, TFormData>;
|
14
|
-
useField: UseField<TFormData>;
|
15
|
-
useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
|
16
|
-
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
|
17
|
-
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
|
18
|
-
}) => any;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
|
22
|
-
|
23
|
-
export { FieldComponent, UseField, useForm };
|
7
|
+
import './types.js';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["export type NoInfer<T> = [T][T extends any ? 0 : never]\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
1
|
+
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["export type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport type ReleaseVersion = 2\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/build/modern/types.d.cts
CHANGED
package/build/modern/types.d.ts
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/useField.tsx
|
21
|
+
var useField_exports = {};
|
22
|
+
__export(useField_exports, {
|
23
|
+
Field: () => Field,
|
24
|
+
useField: () => useField
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(useField_exports);
|
27
|
+
var import_form_core = require("@tanstack/form-core");
|
28
|
+
var import_vue_store = require("@tanstack/vue-store");
|
29
|
+
var import_vue_demi = require("vue-demi");
|
30
|
+
var import_formContext = require("./formContext.cjs");
|
31
|
+
function useField(opts) {
|
32
|
+
const { formApi, parentFieldName } = (0, import_formContext.useFormContext)();
|
33
|
+
const fieldApi = (() => {
|
34
|
+
const name = (typeof opts.index === "number" ? [parentFieldName, opts.index, opts.name] : [parentFieldName, opts.name]).filter((d) => d !== void 0).join(".");
|
35
|
+
const api = new import_form_core.FieldApi({ ...opts, form: formApi, name });
|
36
|
+
api.Field = Field;
|
37
|
+
return api;
|
38
|
+
})();
|
39
|
+
const fieldState = (0, import_vue_store.useStore)(fieldApi.store, (state) => state);
|
40
|
+
let cleanup;
|
41
|
+
(0, import_vue_demi.onMounted)(() => {
|
42
|
+
cleanup = fieldApi.mount();
|
43
|
+
});
|
44
|
+
(0, import_vue_demi.onUnmounted)(() => {
|
45
|
+
cleanup();
|
46
|
+
});
|
47
|
+
(0, import_vue_demi.watch)(
|
48
|
+
() => opts,
|
49
|
+
() => {
|
50
|
+
fieldApi.update({ ...opts, form: formApi });
|
51
|
+
}
|
52
|
+
);
|
53
|
+
return { api: fieldApi, state: fieldState };
|
54
|
+
}
|
55
|
+
var Field = (0, import_vue_demi.defineComponent)(
|
56
|
+
(fieldOptions, context) => {
|
57
|
+
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
58
|
+
(0, import_formContext.provideFormContext)({
|
59
|
+
formApi: fieldApi.api.form,
|
60
|
+
parentFieldName: fieldApi.api.name
|
61
|
+
});
|
62
|
+
return () => context.slots.default(fieldApi.api, fieldApi.state.value);
|
63
|
+
},
|
64
|
+
{ name: "Field", inheritAttrs: false }
|
65
|
+
);
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
67
|
+
0 && (module.exports = {
|
68
|
+
Field,
|
69
|
+
useField
|
70
|
+
});
|
71
|
+
//# sourceMappingURL=useField.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import {\n type DeepKeys,\n type DeepValue,\n FieldApi,\n type FieldOptions,\n type Narrow,\n} from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport {\n type SetupContext,\n defineComponent,\n type Ref,\n onMounted,\n onUnmounted,\n watch,\n} from 'vue-demi'\nimport { provideFormContext, useFormContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<TData, TFormData> {\n Field: FieldComponent<TData, TFormData>\n }\n}\n\nexport interface UseFieldOptions<TData, TFormData>\n extends FieldOptions<TData, TFormData> {\n mode?: 'value' | 'array'\n}\n\nexport type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(\n opts?: { name: Narrow<TField> } & UseFieldOptions<\n DeepValue<TFormData, TField>,\n TFormData\n >,\n) => FieldApi<DeepValue<TFormData, TField>, TFormData>\n\nexport function useField<TData, TFormData>(\n opts: UseFieldOptions<TData, TFormData>,\n): {\n api: FieldApi<TData, TFormData>\n state: Readonly<Ref<FieldApi<TData, TFormData>['state']>>\n} {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const fieldApi = (() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({ ...opts, form: formApi, name: name 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\n// export type FieldValue<TFormData, TField> = TFormData extends any[]\n// ? TField extends `[${infer TIndex extends number | 'i'}].${infer TRest}`\n// ? DeepValue<TFormData[TIndex extends 'i' ? number : TIndex], TRest>\n// : TField extends `[${infer TIndex extends number | 'i'}]`\n// ? TFormData[TIndex extends 'i' ? number : TIndex]\n// : never\n// : TField extends `${infer TPrefix}[${infer TIndex extends\n// | number\n// | 'i'}].${infer TRest}`\n// ? DeepValue<\n// DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex],\n// TRest\n// >\n// : TField extends `${infer TPrefix}[${infer TIndex extends number | 'i'}]`\n// ? DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex]\n// : DeepValue<TFormData, TField>\n\nexport type FieldValue<TFormData, TField> = TFormData extends any[]\n ? unknown extends TField\n ? TFormData[number]\n : DeepValue<TFormData[number], TField>\n : DeepValue<TFormData, TField>\n\n// type Test1 = FieldValue<{ foo: { bar: string }[] }, 'foo'>\n// // ^?\n// type Test2 = FieldValue<{ foo: { bar: string }[] }, 'foo[i]'>\n// // ^?\n// type Test3 = FieldValue<{ foo: { bar: string }[] }, 'foo[2].bar'>\n// // ^?\n\nexport type FieldComponent<TParentData, TFormData> = <TField>(\n fieldOptions: {\n children?: (\n fieldApi: FieldApi<FieldValue<TParentData, TField>, TFormData>,\n ) => any\n } & Omit<\n UseFieldOptions<FieldValue<TParentData, TField>, TFormData>,\n 'name' | 'index'\n > &\n (TParentData extends any[]\n ? {\n name?: TField extends undefined ? TField : DeepKeys<TParentData>\n index: number\n }\n : {\n name: TField extends undefined ? TField : DeepKeys<TParentData>\n index?: never\n }),\n context: SetupContext,\n) => any\n\nexport const Field = defineComponent(\n <TData, TFormData>(\n fieldOptions: UseFieldOptions<TData, TFormData>,\n context: SetupContext,\n ) => {\n const fieldApi = useField({ ...fieldOptions, ...context.attrs })\n\n provideFormContext({\n formApi: fieldApi.api.form,\n parentFieldName: fieldApi.api.name,\n } as never)\n\n return () => context.slots.default!(fieldApi.api, fieldApi.state.value)\n },\n { name: 'Field', inheritAttrs: false },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAMO;AACP,uBAAyB;AACzB,sBAOO;AACP,yBAAmD;AAqB5C,SAAS,SACd,MAIA;AAEA,QAAM,EAAE,SAAS,gBAAgB,QAAI,mCAAe;AAEpD,QAAM,YAAY,MAAM;AACtB,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,0BAAS,EAAE,GAAG,MAAM,MAAM,SAAS,KAAoB,CAAC;AAExE,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,GAAG;AAEH,QAAM,iBAAa,2BAAS,SAAS,OAAO,CAAC,UAAU,KAAK;AAE5D,MAAI;AACJ,iCAAU,MAAM;AACd,cAAU,SAAS,MAAM;AAAA,EAC3B,CAAC;AAED,mCAAY,MAAM;AAChB,YAAQ;AAAA,EACV,CAAC;AAED;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAEJ,eAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,IACrD;AAAA,EACF;AAEA,SAAO,EAAE,KAAK,UAAU,OAAO,WAAW;AAC5C;AAqDO,IAAM,YAAQ;AAAA,EACnB,CACE,cACA,YACG;AACH,UAAM,WAAW,SAAS,EAAE,GAAG,cAAc,GAAG,QAAQ,MAAM,CAAC;AAE/D,+CAAmB;AAAA,MACjB,SAAS,SAAS,IAAI;AAAA,MACtB,iBAAiB,SAAS,IAAI;AAAA,IAChC,CAAU;AAEV,WAAO,MAAM,QAAQ,MAAM,QAAS,SAAS,KAAK,SAAS,MAAM,KAAK;AAAA,EACxE;AAAA,EACA,EAAE,MAAM,SAAS,cAAc,MAAM;AACvC;","names":[]}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { FieldApi, DeepKeys, FieldOptions, Narrow, DeepValue } from '@tanstack/form-core';
|
2
|
+
import { SetupContext, Ref } from 'vue-demi';
|
3
|
+
|
4
|
+
declare module '@tanstack/form-core' {
|
5
|
+
interface FieldApi<TData, TFormData> {
|
6
|
+
Field: FieldComponent<TData, TFormData>;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
interface UseFieldOptions<TData, TFormData> extends FieldOptions<TData, TFormData> {
|
10
|
+
mode?: 'value' | 'array';
|
11
|
+
}
|
12
|
+
type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(opts?: {
|
13
|
+
name: Narrow<TField>;
|
14
|
+
} & UseFieldOptions<DeepValue<TFormData, TField>, TFormData>) => FieldApi<DeepValue<TFormData, TField>, TFormData>;
|
15
|
+
declare function useField<TData, TFormData>(opts: UseFieldOptions<TData, TFormData>): {
|
16
|
+
api: FieldApi<TData, TFormData>;
|
17
|
+
state: Readonly<Ref<FieldApi<TData, TFormData>['state']>>;
|
18
|
+
};
|
19
|
+
type FieldValue<TFormData, TField> = TFormData extends any[] ? unknown extends TField ? TFormData[number] : DeepValue<TFormData[number], TField> : DeepValue<TFormData, TField>;
|
20
|
+
type FieldComponent<TParentData, TFormData> = <TField>(fieldOptions: {
|
21
|
+
children?: (fieldApi: FieldApi<FieldValue<TParentData, TField>, TFormData>) => any;
|
22
|
+
} & Omit<UseFieldOptions<FieldValue<TParentData, TField>, TFormData>, 'name' | 'index'> & (TParentData extends any[] ? {
|
23
|
+
name?: TField extends undefined ? TField : DeepKeys<TParentData>;
|
24
|
+
index: number;
|
25
|
+
} : {
|
26
|
+
name: TField extends undefined ? TField : DeepKeys<TParentData>;
|
27
|
+
index?: never;
|
28
|
+
}), context: SetupContext) => any;
|
29
|
+
declare const Field: <TData, TFormData>(props: UseFieldOptions<TData, TFormData> & ({
|
30
|
+
[x: `on${Capitalize<string>}`]: ((...args: never) => any) | undefined;
|
31
|
+
} | {
|
32
|
+
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
33
|
+
})) => any;
|
34
|
+
|
35
|
+
export { Field, FieldComponent, FieldValue, UseField, UseFieldOptions, useField };
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { FieldApi, DeepKeys, FieldOptions, Narrow, DeepValue } from '@tanstack/form-core';
|
2
|
+
import { SetupContext, Ref } from 'vue-demi';
|
3
|
+
|
4
|
+
declare module '@tanstack/form-core' {
|
5
|
+
interface FieldApi<TData, TFormData> {
|
6
|
+
Field: FieldComponent<TData, TFormData>;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
interface UseFieldOptions<TData, TFormData> extends FieldOptions<TData, TFormData> {
|
10
|
+
mode?: 'value' | 'array';
|
11
|
+
}
|
12
|
+
type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(opts?: {
|
13
|
+
name: Narrow<TField>;
|
14
|
+
} & UseFieldOptions<DeepValue<TFormData, TField>, TFormData>) => FieldApi<DeepValue<TFormData, TField>, TFormData>;
|
15
|
+
declare function useField<TData, TFormData>(opts: UseFieldOptions<TData, TFormData>): {
|
16
|
+
api: FieldApi<TData, TFormData>;
|
17
|
+
state: Readonly<Ref<FieldApi<TData, TFormData>['state']>>;
|
18
|
+
};
|
19
|
+
type FieldValue<TFormData, TField> = TFormData extends any[] ? unknown extends TField ? TFormData[number] : DeepValue<TFormData[number], TField> : DeepValue<TFormData, TField>;
|
20
|
+
type FieldComponent<TParentData, TFormData> = <TField>(fieldOptions: {
|
21
|
+
children?: (fieldApi: FieldApi<FieldValue<TParentData, TField>, TFormData>) => any;
|
22
|
+
} & Omit<UseFieldOptions<FieldValue<TParentData, TField>, TFormData>, 'name' | 'index'> & (TParentData extends any[] ? {
|
23
|
+
name?: TField extends undefined ? TField : DeepKeys<TParentData>;
|
24
|
+
index: number;
|
25
|
+
} : {
|
26
|
+
name: TField extends undefined ? TField : DeepKeys<TParentData>;
|
27
|
+
index?: never;
|
28
|
+
}), context: SetupContext) => any;
|
29
|
+
declare const Field: <TData, TFormData>(props: UseFieldOptions<TData, TFormData> & ({
|
30
|
+
[x: `on${Capitalize<string>}`]: ((...args: never) => any) | undefined;
|
31
|
+
} | {
|
32
|
+
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
33
|
+
})) => any;
|
34
|
+
|
35
|
+
export { Field, FieldComponent, FieldValue, UseField, UseFieldOptions, useField };
|
@@ -0,0 +1,52 @@
|
|
1
|
+
// src/useField.tsx
|
2
|
+
import {
|
3
|
+
FieldApi
|
4
|
+
} from "@tanstack/form-core";
|
5
|
+
import { useStore } from "@tanstack/vue-store";
|
6
|
+
import {
|
7
|
+
defineComponent,
|
8
|
+
onMounted,
|
9
|
+
onUnmounted,
|
10
|
+
watch
|
11
|
+
} from "vue-demi";
|
12
|
+
import { provideFormContext, useFormContext } from "./formContext.js";
|
13
|
+
function useField(opts) {
|
14
|
+
const { formApi, parentFieldName } = useFormContext();
|
15
|
+
const fieldApi = (() => {
|
16
|
+
const name = (typeof opts.index === "number" ? [parentFieldName, opts.index, opts.name] : [parentFieldName, opts.name]).filter((d) => d !== void 0).join(".");
|
17
|
+
const api = new FieldApi({ ...opts, form: formApi, name });
|
18
|
+
api.Field = Field;
|
19
|
+
return api;
|
20
|
+
})();
|
21
|
+
const fieldState = useStore(fieldApi.store, (state) => state);
|
22
|
+
let cleanup;
|
23
|
+
onMounted(() => {
|
24
|
+
cleanup = fieldApi.mount();
|
25
|
+
});
|
26
|
+
onUnmounted(() => {
|
27
|
+
cleanup();
|
28
|
+
});
|
29
|
+
watch(
|
30
|
+
() => opts,
|
31
|
+
() => {
|
32
|
+
fieldApi.update({ ...opts, form: formApi });
|
33
|
+
}
|
34
|
+
);
|
35
|
+
return { api: fieldApi, state: fieldState };
|
36
|
+
}
|
37
|
+
var Field = defineComponent(
|
38
|
+
(fieldOptions, context) => {
|
39
|
+
const fieldApi = useField({ ...fieldOptions, ...context.attrs });
|
40
|
+
provideFormContext({
|
41
|
+
formApi: fieldApi.api.form,
|
42
|
+
parentFieldName: fieldApi.api.name
|
43
|
+
});
|
44
|
+
return () => context.slots.default(fieldApi.api, fieldApi.state.value);
|
45
|
+
},
|
46
|
+
{ name: "Field", inheritAttrs: false }
|
47
|
+
);
|
48
|
+
export {
|
49
|
+
Field,
|
50
|
+
useField
|
51
|
+
};
|
52
|
+
//# sourceMappingURL=useField.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/useField.tsx"],"sourcesContent":["import {\n type DeepKeys,\n type DeepValue,\n FieldApi,\n type FieldOptions,\n type Narrow,\n} from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport {\n type SetupContext,\n defineComponent,\n type Ref,\n onMounted,\n onUnmounted,\n watch,\n} from 'vue-demi'\nimport { provideFormContext, useFormContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldApi<TData, TFormData> {\n Field: FieldComponent<TData, TFormData>\n }\n}\n\nexport interface UseFieldOptions<TData, TFormData>\n extends FieldOptions<TData, TFormData> {\n mode?: 'value' | 'array'\n}\n\nexport type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(\n opts?: { name: Narrow<TField> } & UseFieldOptions<\n DeepValue<TFormData, TField>,\n TFormData\n >,\n) => FieldApi<DeepValue<TFormData, TField>, TFormData>\n\nexport function useField<TData, TFormData>(\n opts: UseFieldOptions<TData, TFormData>,\n): {\n api: FieldApi<TData, TFormData>\n state: Readonly<Ref<FieldApi<TData, TFormData>['state']>>\n} {\n // Get the form API either manually or from context\n const { formApi, parentFieldName } = useFormContext()\n\n const fieldApi = (() => {\n const name = (\n typeof opts.index === 'number'\n ? [parentFieldName, opts.index, opts.name]\n : [parentFieldName, opts.name]\n )\n .filter((d) => d !== undefined)\n .join('.')\n\n const api = new FieldApi({ ...opts, form: formApi, name: name 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\n// export type FieldValue<TFormData, TField> = TFormData extends any[]\n// ? TField extends `[${infer TIndex extends number | 'i'}].${infer TRest}`\n// ? DeepValue<TFormData[TIndex extends 'i' ? number : TIndex], TRest>\n// : TField extends `[${infer TIndex extends number | 'i'}]`\n// ? TFormData[TIndex extends 'i' ? number : TIndex]\n// : never\n// : TField extends `${infer TPrefix}[${infer TIndex extends\n// | number\n// | 'i'}].${infer TRest}`\n// ? DeepValue<\n// DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex],\n// TRest\n// >\n// : TField extends `${infer TPrefix}[${infer TIndex extends number | 'i'}]`\n// ? DeepValue<TFormData, TPrefix>[TIndex extends 'i' ? number : TIndex]\n// : DeepValue<TFormData, TField>\n\nexport type FieldValue<TFormData, TField> = TFormData extends any[]\n ? unknown extends TField\n ? TFormData[number]\n : DeepValue<TFormData[number], TField>\n : DeepValue<TFormData, TField>\n\n// type Test1 = FieldValue<{ foo: { bar: string }[] }, 'foo'>\n// // ^?\n// type Test2 = FieldValue<{ foo: { bar: string }[] }, 'foo[i]'>\n// // ^?\n// type Test3 = FieldValue<{ foo: { bar: string }[] }, 'foo[2].bar'>\n// // ^?\n\nexport type FieldComponent<TParentData, TFormData> = <TField>(\n fieldOptions: {\n children?: (\n fieldApi: FieldApi<FieldValue<TParentData, TField>, TFormData>,\n ) => any\n } & Omit<\n UseFieldOptions<FieldValue<TParentData, TField>, TFormData>,\n 'name' | 'index'\n > &\n (TParentData extends any[]\n ? {\n name?: TField extends undefined ? TField : DeepKeys<TParentData>\n index: number\n }\n : {\n name: TField extends undefined ? TField : DeepKeys<TParentData>\n index?: never\n }),\n context: SetupContext,\n) => any\n\nexport const Field = defineComponent(\n <TData, TFormData>(\n fieldOptions: UseFieldOptions<TData, TFormData>,\n context: SetupContext,\n ) => {\n const fieldApi = useField({ ...fieldOptions, ...context.attrs })\n\n provideFormContext({\n formApi: fieldApi.api.form,\n parentFieldName: fieldApi.api.name,\n } as never)\n\n return () => context.slots.default!(fieldApi.api, fieldApi.state.value)\n },\n { name: 'Field', inheritAttrs: false },\n)\n"],"mappings":";AAAA;AAAA,EAGE;AAAA,OAGK;AACP,SAAS,gBAAgB;AACzB;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;AAqB5C,SAAS,SACd,MAIA;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI,eAAe;AAEpD,QAAM,YAAY,MAAM;AACtB,UAAM,QACJ,OAAO,KAAK,UAAU,WAClB,CAAC,iBAAiB,KAAK,OAAO,KAAK,IAAI,IACvC,CAAC,iBAAiB,KAAK,IAAI,GAE9B,OAAO,CAAC,MAAM,MAAM,MAAS,EAC7B,KAAK,GAAG;AAEX,UAAM,MAAM,IAAI,SAAS,EAAE,GAAG,MAAM,MAAM,SAAS,KAAoB,CAAC;AAExE,QAAI,QAAQ;AAEZ,WAAO;AAAA,EACT,GAAG;AAEH,QAAM,aAAa,SAAS,SAAS,OAAO,CAAC,UAAU,KAAK;AAE5D,MAAI;AACJ,YAAU,MAAM;AACd,cAAU,SAAS,MAAM;AAAA,EAC3B,CAAC;AAED,cAAY,MAAM;AAChB,YAAQ;AAAA,EACV,CAAC;AAED;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAEJ,eAAS,OAAO,EAAE,GAAG,MAAM,MAAM,QAAQ,CAAU;AAAA,IACrD;AAAA,EACF;AAEA,SAAO,EAAE,KAAK,UAAU,OAAO,WAAW;AAC5C;AAqDO,IAAM,QAAQ;AAAA,EACnB,CACE,cACA,YACG;AACH,UAAM,WAAW,SAAS,EAAE,GAAG,cAAc,GAAG,QAAQ,MAAM,CAAC;AAE/D,uBAAmB;AAAA,MACjB,SAAS,SAAS,IAAI;AAAA,MACtB,iBAAiB,SAAS,IAAI;AAAA,IAChC,CAAU;AAEV,WAAO,MAAM,QAAQ,MAAM,QAAS,SAAS,KAAK,SAAS,MAAM,KAAK;AAAA,EACxE;AAAA,EACA,EAAE,MAAM,SAAS,cAAc,MAAM;AACvC;","names":[]}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/useForm.tsx
|
21
|
+
var useForm_exports = {};
|
22
|
+
__export(useForm_exports, {
|
23
|
+
useForm: () => useForm
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(useForm_exports);
|
26
|
+
var import_form_core = require("@tanstack/form-core");
|
27
|
+
var import_vue_store = require("@tanstack/vue-store");
|
28
|
+
var import_useField = require("./useField.cjs");
|
29
|
+
var import_formContext = require("./formContext.cjs");
|
30
|
+
var import_vue_demi = require("vue-demi");
|
31
|
+
function useForm(opts) {
|
32
|
+
const formApi = (() => {
|
33
|
+
const api = new import_form_core.FormApi(opts);
|
34
|
+
api.Provider = (0, import_vue_demi.defineComponent)(
|
35
|
+
(_, context) => {
|
36
|
+
(0, import_formContext.provideFormContext)({ formApi });
|
37
|
+
return () => context.slots.default();
|
38
|
+
},
|
39
|
+
{ name: "Provider" }
|
40
|
+
);
|
41
|
+
api.provideFormContext = () => {
|
42
|
+
(0, import_formContext.provideFormContext)({ formApi });
|
43
|
+
};
|
44
|
+
api.Field = import_useField.Field;
|
45
|
+
api.useField = import_useField.useField;
|
46
|
+
api.useStore = (selector) => {
|
47
|
+
return (0, import_vue_store.useStore)(api.store, selector);
|
48
|
+
};
|
49
|
+
api.Subscribe = (0, import_vue_demi.defineComponent)(
|
50
|
+
(props, context) => {
|
51
|
+
const allProps = { ...props, ...context.attrs };
|
52
|
+
const selector = allProps.selector ?? ((state) => state);
|
53
|
+
const data = (0, import_vue_store.useStore)(api.store, selector);
|
54
|
+
return () => context.slots.default(data.value);
|
55
|
+
},
|
56
|
+
{
|
57
|
+
name: "Subscribe",
|
58
|
+
inheritAttrs: false
|
59
|
+
}
|
60
|
+
);
|
61
|
+
return api;
|
62
|
+
})();
|
63
|
+
formApi.update(opts);
|
64
|
+
return formApi;
|
65
|
+
}
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
67
|
+
0 && (module.exports = {
|
68
|
+
useForm
|
69
|
+
});
|
70
|
+
//# sourceMappingURL=useForm.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/useForm.tsx"],"sourcesContent":["import { FormApi, type FormState, type FormOptions } from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport { defineComponent } from 'vue-demi'\nimport type { NoInfer } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n }) => any\n }\n}\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const formApi = (() => {\n const api = new FormApi<TData>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n provideFormContext({ formApi })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n provideFormContext({ formApi })\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0D;AAC1D,uBAAyB;AACzB,sBAAoE;AACpE,yBAAmC;AACnC,sBAAgC;AAmBzB,SAAS,QAAe,MAA2C;AACxE,QAAM,WAAW,MAAM;AACrB,UAAM,MAAM,IAAI,yBAAe,IAAI;AAEnC,QAAI,eAAW;AAAA,MACb,CAAC,GAAG,YAAY;AACd,mDAAmB,EAAE,QAAQ,CAAC;AAC9B,eAAO,MAAM,QAAQ,MAAM,QAAS;AAAA,MACtC;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IACrB;AACA,QAAI,qBAAqB,MAAM;AAC7B,iDAAmB,EAAE,QAAQ,CAAC;AAAA,IAChC;AACA,QAAI,QAAQ;AACZ,QAAI,WAAW;AACf,QAAI,WAAW,CAAC,aAAa;AAC3B,iBAAO,2BAAS,IAAI,OAAgB,QAAiB;AAAA,IACvD;AACA,QAAI,gBAAY;AAAA,MACd,CAAC,OAAO,YAAY;AAClB,cAAM,WAAW,EAAE,GAAG,OAAO,GAAG,QAAQ,MAAM;AAC9C,cAAM,WAAW,SAAS,aAAa,CAAC,UAAU;AAClD,cAAM,WAAO,2BAAS,IAAI,OAAgB,QAAiB;AAC3D,eAAO,MAAM,QAAQ,MAAM,QAAS,KAAK,KAAK;AAAA,MAChD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,cAAc;AAAA,MAChB;AAAA,IACF;AAEA,WAAO;AAAA,EACT,GAAG;AAGH,UAAQ,OAAO,IAAI;AAEnB,SAAO;AACT;","names":[]}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
|
2
|
+
import { FieldComponent, UseField } from './useField.cjs';
|
3
|
+
import { NoInfer } from './types.cjs';
|
4
|
+
import 'vue-demi';
|
5
|
+
|
6
|
+
declare module '@tanstack/form-core' {
|
7
|
+
interface FormApi<TFormData> {
|
8
|
+
Provider: (props: Record<string, any> & {}) => any;
|
9
|
+
provideFormContext: () => void;
|
10
|
+
Field: FieldComponent<TFormData, TFormData>;
|
11
|
+
useField: UseField<TFormData>;
|
12
|
+
useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
|
13
|
+
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
|
14
|
+
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
|
15
|
+
}) => any;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
|
19
|
+
|
20
|
+
export { useForm };
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { FormState, FormOptions, FormApi } from '@tanstack/form-core';
|
2
|
+
import { FieldComponent, UseField } from './useField.js';
|
3
|
+
import { NoInfer } from './types.js';
|
4
|
+
import 'vue-demi';
|
5
|
+
|
6
|
+
declare module '@tanstack/form-core' {
|
7
|
+
interface FormApi<TFormData> {
|
8
|
+
Provider: (props: Record<string, any> & {}) => any;
|
9
|
+
provideFormContext: () => void;
|
10
|
+
Field: FieldComponent<TFormData, TFormData>;
|
11
|
+
useField: UseField<TFormData>;
|
12
|
+
useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
|
13
|
+
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
|
14
|
+
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
|
15
|
+
}) => any;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
|
19
|
+
|
20
|
+
export { useForm };
|
@@ -0,0 +1,45 @@
|
|
1
|
+
// src/useForm.tsx
|
2
|
+
import { FormApi } from "@tanstack/form-core";
|
3
|
+
import { useStore } from "@tanstack/vue-store";
|
4
|
+
import { Field, useField } from "./useField.js";
|
5
|
+
import { provideFormContext } from "./formContext.js";
|
6
|
+
import { defineComponent } from "vue-demi";
|
7
|
+
function useForm(opts) {
|
8
|
+
const formApi = (() => {
|
9
|
+
const api = new FormApi(opts);
|
10
|
+
api.Provider = defineComponent(
|
11
|
+
(_, context) => {
|
12
|
+
provideFormContext({ formApi });
|
13
|
+
return () => context.slots.default();
|
14
|
+
},
|
15
|
+
{ name: "Provider" }
|
16
|
+
);
|
17
|
+
api.provideFormContext = () => {
|
18
|
+
provideFormContext({ formApi });
|
19
|
+
};
|
20
|
+
api.Field = Field;
|
21
|
+
api.useField = useField;
|
22
|
+
api.useStore = (selector) => {
|
23
|
+
return useStore(api.store, selector);
|
24
|
+
};
|
25
|
+
api.Subscribe = defineComponent(
|
26
|
+
(props, context) => {
|
27
|
+
const allProps = { ...props, ...context.attrs };
|
28
|
+
const selector = allProps.selector ?? ((state) => state);
|
29
|
+
const data = useStore(api.store, selector);
|
30
|
+
return () => context.slots.default(data.value);
|
31
|
+
},
|
32
|
+
{
|
33
|
+
name: "Subscribe",
|
34
|
+
inheritAttrs: false
|
35
|
+
}
|
36
|
+
);
|
37
|
+
return api;
|
38
|
+
})();
|
39
|
+
formApi.update(opts);
|
40
|
+
return formApi;
|
41
|
+
}
|
42
|
+
export {
|
43
|
+
useForm
|
44
|
+
};
|
45
|
+
//# sourceMappingURL=useForm.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/useForm.tsx"],"sourcesContent":["import { FormApi, type FormState, type FormOptions } from '@tanstack/form-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { type UseField, type FieldComponent, Field, useField } from './useField'\nimport { provideFormContext } from './formContext'\nimport { defineComponent } from 'vue-demi'\nimport type { NoInfer } from './types'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Provider: (props: Record<string, any> & {}) => any\n provideFormContext: () => void\n Field: FieldComponent<TFormData, TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n }) => any\n }\n}\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const formApi = (() => {\n const api = new FormApi<TData>(opts)\n\n api.Provider = defineComponent(\n (_, context) => {\n provideFormContext({ formApi })\n return () => context.slots.default!()\n },\n { name: 'Provider' },\n )\n api.provideFormContext = () => {\n provideFormContext({ formApi })\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"],"mappings":";AAAA,SAAS,eAAiD;AAC1D,SAAS,gBAAgB;AACzB,SAA6C,OAAO,gBAAgB;AACpE,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAmBzB,SAAS,QAAe,MAA2C;AACxE,QAAM,WAAW,MAAM;AACrB,UAAM,MAAM,IAAI,QAAe,IAAI;AAEnC,QAAI,WAAW;AAAA,MACb,CAAC,GAAG,YAAY;AACd,2BAAmB,EAAE,QAAQ,CAAC;AAC9B,eAAO,MAAM,QAAQ,MAAM,QAAS;AAAA,MACtC;AAAA,MACA,EAAE,MAAM,WAAW;AAAA,IACrB;AACA,QAAI,qBAAqB,MAAM;AAC7B,yBAAmB,EAAE,QAAQ,CAAC;AAAA,IAChC;AACA,QAAI,QAAQ;AACZ,QAAI,WAAW;AACf,QAAI,WAAW,CAAC,aAAa;AAC3B,aAAO,SAAS,IAAI,OAAgB,QAAiB;AAAA,IACvD;AACA,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,IACF;AAEA,WAAO;AAAA,EACT,GAAG;AAGH,UAAQ,OAAO,IAAI;AAEnB,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
package/src/types.ts
CHANGED