@teamnovu/kit-vue-forms 0.0.6 → 0.0.8
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/components/Field.vue.d.ts +3 -3
- package/dist/composables/useField.d.ts +0 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.mjs +5 -8
- package/dist/types/util.d.ts +4 -0
- package/package.json +1 -1
- package/src/components/Field.vue +3 -3
- package/src/composables/useField.ts +0 -2
- package/src/index.ts +1 -2
- package/src/types/util.ts +7 -0
|
@@ -3,11 +3,11 @@ import { Paths, PickProps } from '../types/util.ts';
|
|
|
3
3
|
import { UseFieldOptions } from '../composables/useField.ts';
|
|
4
4
|
import { VNodeProps, AllowedComponentProps, ComponentCustomProps, PublicProps, ShallowUnwrapRef, Ref, VNode } from 'vue';
|
|
5
5
|
import { ValidationErrors, ErrorMessage } from '../index.js';
|
|
6
|
-
export interface FieldProps<
|
|
6
|
+
export interface FieldProps<TData extends object, TPath extends string> extends UseFieldOptions<PickProps<TData, TPath>, TPath> {
|
|
7
7
|
form: Form<TData>;
|
|
8
8
|
}
|
|
9
|
-
declare const _default: <TPath extends Paths<TData
|
|
10
|
-
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & FieldProps<
|
|
9
|
+
declare const _default: <TData extends object, TPath extends Paths<TData>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
10
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & FieldProps<TData, TPath> & Partial<{}>> & PublicProps;
|
|
11
11
|
expose(exposed: ShallowUnwrapRef<{}>): void;
|
|
12
12
|
attrs: any;
|
|
13
13
|
slots: {
|
|
@@ -4,8 +4,6 @@ import { ValidationErrors } from '../types/validation';
|
|
|
4
4
|
export interface UseFieldOptions<T, K extends string> {
|
|
5
5
|
value?: MaybeRef<T>;
|
|
6
6
|
initialValue?: MaybeRefOrGetter<Readonly<T>>;
|
|
7
|
-
type?: MaybeRef<string>;
|
|
8
|
-
required?: MaybeRef<boolean>;
|
|
9
7
|
path: K;
|
|
10
8
|
errors?: MaybeRef<ValidationErrors>;
|
|
11
9
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export { useForm } from './composables/useForm';
|
|
2
2
|
export type { UseFormOptions } from './composables/useForm';
|
|
3
|
-
export { useField } from './composables/useField';
|
|
4
3
|
export type { UseFieldOptions } from './composables/useField';
|
|
5
4
|
export type { ValidationStrategy, ValidationErrorMessage as ErrorMessage, ValidationResult, ErrorBag, Validator, ValidationFunction, ValidationErrors } from './types/validation';
|
|
6
5
|
export type { DeepPartial } from './utils/type-helpers';
|
|
7
6
|
export type { Form, FormField } from './types/form';
|
|
8
|
-
export type { SplitPath, Paths, PickProps } from './types/util';
|
|
7
|
+
export type { SplitPath, Paths, PickProps, ObjectOf, EntityPaths } from './types/util';
|
|
9
8
|
export { default as Field } from './components/Field.vue';
|
|
10
9
|
export type { FieldProps } from './components/Field.vue';
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var R = (e, r, t) =>
|
|
4
|
-
import { toValue as
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var K = (e, r, t) => r in e ? x(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var R = (e, r, t) => K(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { toValue as W, toRaw as q, computed as d, unref as c, reactive as b, watch as F, toRefs as O, toRef as S, ref as A, isRef as _, getCurrentScope as I, onBeforeUnmount as J, defineComponent as T, renderSlot as B, normalizeProps as G, guardReactiveProps as L } from "vue";
|
|
5
5
|
import "zod";
|
|
6
6
|
function y(e) {
|
|
7
|
-
const r =
|
|
7
|
+
const r = W(e), t = q(r);
|
|
8
8
|
return structuredClone(t);
|
|
9
9
|
}
|
|
10
10
|
function N(e) {
|
|
@@ -411,8 +411,6 @@ const pr = /* @__PURE__ */ T({
|
|
|
411
411
|
form: {},
|
|
412
412
|
value: {},
|
|
413
413
|
initialValue: {},
|
|
414
|
-
type: {},
|
|
415
|
-
required: {},
|
|
416
414
|
path: {},
|
|
417
415
|
errors: {}
|
|
418
416
|
},
|
|
@@ -426,6 +424,5 @@ const pr = /* @__PURE__ */ T({
|
|
|
426
424
|
});
|
|
427
425
|
export {
|
|
428
426
|
pr as Field,
|
|
429
|
-
k as useField,
|
|
430
427
|
vr as useForm
|
|
431
428
|
};
|
package/dist/types/util.d.ts
CHANGED
|
@@ -24,3 +24,7 @@ export type ButLast<T extends string> = T extends `${infer Rest}.${infer Last}`
|
|
|
24
24
|
export type EntityPaths<T> = ButLast<Paths<T>> & Paths<T>;
|
|
25
25
|
export type PickEntity<Entity, PropertyKeys extends string> = PropertyKeys extends unknown ? PickProps<Entity, EntityPaths<Entity> & PropertyKeys> & FormDataDefault : never;
|
|
26
26
|
export type RestPath<T extends string, P extends string> = P extends `${T}.${infer Rest}` ? Rest : never;
|
|
27
|
+
export type RootPath<P extends string> = P extends `${infer TRoot}.${string}` ? TRoot : P;
|
|
28
|
+
export type ObjectOf<TPath extends string, T> = {
|
|
29
|
+
[K in RootPath<TPath>]: RestPath<K, TPath> extends never ? T : ObjectOf<RestPath<K, TPath>, T>;
|
|
30
|
+
};
|
package/package.json
CHANGED
package/src/components/Field.vue
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
<script
|
|
6
6
|
setup lang="ts"
|
|
7
|
-
generic="TPath extends Paths<TData
|
|
7
|
+
generic="TData extends object, TPath extends Paths<TData>"
|
|
8
8
|
>
|
|
9
9
|
import type { Form } from '../types/form.ts'
|
|
10
10
|
import type { Paths, PickProps } from '../types/util.ts'
|
|
11
11
|
import type { UseFieldOptions } from '../composables/useField.ts'
|
|
12
12
|
|
|
13
|
-
export interface FieldProps<
|
|
13
|
+
export interface FieldProps<TData extends object, TPath extends string> extends UseFieldOptions<PickProps<TData, TPath>, TPath> {
|
|
14
14
|
form: Form<TData>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const props = defineProps<FieldProps<
|
|
17
|
+
const props = defineProps<FieldProps<TData, TPath>>()
|
|
18
18
|
|
|
19
19
|
const field = props.form.defineField({
|
|
20
20
|
path: props.path,
|
|
@@ -6,8 +6,6 @@ import { cloneRefValue } from '../utils/general'
|
|
|
6
6
|
export interface UseFieldOptions<T, K extends string> {
|
|
7
7
|
value?: MaybeRef<T>
|
|
8
8
|
initialValue?: MaybeRefOrGetter<Readonly<T>>
|
|
9
|
-
type?: MaybeRef<string>
|
|
10
|
-
required?: MaybeRef<boolean>
|
|
11
9
|
path: K
|
|
12
10
|
errors?: MaybeRef<ValidationErrors>
|
|
13
11
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ export { useForm } from './composables/useForm'
|
|
|
3
3
|
export type { UseFormOptions } from './composables/useForm'
|
|
4
4
|
|
|
5
5
|
// Field composable
|
|
6
|
-
export { useField } from './composables/useField'
|
|
7
6
|
export type { UseFieldOptions } from './composables/useField'
|
|
8
7
|
|
|
9
8
|
// Types
|
|
@@ -11,7 +10,7 @@ export type { ValidationStrategy, ValidationErrorMessage as ErrorMessage, Valida
|
|
|
11
10
|
export type { DeepPartial } from './utils/type-helpers'
|
|
12
11
|
|
|
13
12
|
export type { Form, FormField } from './types/form'
|
|
14
|
-
export type { SplitPath, Paths, PickProps } from './types/util'
|
|
13
|
+
export type { SplitPath, Paths, PickProps, ObjectOf, EntityPaths } from './types/util'
|
|
15
14
|
|
|
16
15
|
export { default as Field } from './components/Field.vue'
|
|
17
16
|
export type { FieldProps } from './components/Field.vue'
|
package/src/types/util.ts
CHANGED
|
@@ -71,3 +71,10 @@ export type PickEntity<Entity, PropertyKeys extends string> =
|
|
|
71
71
|
|
|
72
72
|
export type RestPath<T extends string, P extends string> =
|
|
73
73
|
P extends `${T}.${infer Rest}` ? Rest : never
|
|
74
|
+
|
|
75
|
+
export type RootPath<P extends string> =
|
|
76
|
+
P extends `${infer TRoot}.${string}` ? TRoot : P
|
|
77
|
+
|
|
78
|
+
export type ObjectOf<TPath extends string, T> = {
|
|
79
|
+
[K in RootPath<TPath>]: RestPath<K, TPath> extends never ? T : ObjectOf<RestPath<K, TPath>, T>
|
|
80
|
+
}
|