@teamnovu/kit-vue-forms 0.2.5 → 0.2.7

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.
@@ -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, VNode } from 'vue';
5
5
  import { ValidationErrors, ErrorMessage } from '../index.js';
6
- export interface FieldProps<TData extends object, TPath extends string> extends UseFieldOptions<PickProps<TData, TPath>, TPath> {
7
- form: Form<TData>;
6
+ export interface FieldProps<TData extends object, TPath extends string, TDataOut = TData> extends UseFieldOptions<PickProps<TData, TPath>, TPath> {
7
+ form: Form<TData, TDataOut>;
8
8
  }
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;
9
+ declare const _default: <TData extends object, TPath extends Paths<TData>, TDataOut = 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, TDataOut> & Partial<{}>> & PublicProps;
11
11
  expose(exposed: ShallowUnwrapRef<{}>): void;
12
12
  attrs: any;
13
13
  slots: {
@@ -1,15 +1,15 @@
1
1
  import { Component, VNodeProps, AllowedComponentProps, ComponentCustomProps, PublicProps, ShallowUnwrapRef, VNode } from 'vue';
2
2
  import { ComponentProps } from 'vue-component-type-helpers';
3
3
  import { Paths } from '../types/util.ts';
4
- import { Form } from '../types/form.ts';
5
- export interface FormFieldWrapperProps<TData extends object, TPath extends string, TComponent> {
4
+ import { Form, FormDataDefault } from '../types/form.ts';
5
+ export interface FormFieldWrapperProps<TForm extends Form<FormDataDefault, unknown>, TPath extends string, TComponent> {
6
6
  component: TComponent;
7
7
  componentProps: Omit<ComponentProps<TComponent>, 'modelValue' | 'update:modelValue' | 'errors'>;
8
- form: Form<TData>;
8
+ form: TForm;
9
9
  path: TPath;
10
10
  }
11
- declare const _default: <TData extends object, TPath extends Paths<TData>, TComponent extends Component>(__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<{
12
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & FormFieldWrapperProps<TData, TPath, TComponent> & Partial<{}>> & PublicProps;
11
+ declare const _default: <TForm extends Form<FormDataDefault, unknown>, TPath extends Paths<TForm extends Form<infer Data> ? Data : never>, TComponent extends Component>(__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<{
12
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & FormFieldWrapperProps<TForm, TPath, TComponent> & Partial<{}>> & PublicProps;
13
13
  expose(exposed: ShallowUnwrapRef<{}>): void;
14
14
  attrs: any;
15
15
  slots: Partial<Record<number, (_: any) => any>> & {
@@ -1,12 +1,12 @@
1
1
  import { Form } from '../types/form.ts';
2
2
  import { EntityPaths, PickEntity } from '../types/util.ts';
3
3
  import { VNodeProps, AllowedComponentProps, ComponentCustomProps, PublicProps, ShallowUnwrapRef, VNode } from 'vue';
4
- export interface FormPartProps<TData extends object, TPath> {
5
- form: Form<TData>;
4
+ export interface FormPartProps<TData extends object, TPath, TDataOut = TData> {
5
+ form: Form<TData, TDataOut>;
6
6
  path: TPath;
7
7
  }
8
- declare const _default: <TData extends object, TPath extends EntityPaths<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<{
9
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & FormPartProps<TData, TPath> & Partial<{}>> & PublicProps;
8
+ declare const _default: <TData extends object, TPath extends EntityPaths<TData>, TDataOut = 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<{
9
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, never> & FormPartProps<TData, TPath, TDataOut> & Partial<{}>> & PublicProps;
10
10
  expose(exposed: ShallowUnwrapRef<{}>): void;
11
11
  attrs: any;
12
12
  slots: {
@@ -1,8 +1,8 @@
1
1
  import { ObjectOf, Paths } from './util';
2
2
  import { Form } from './form';
3
3
  import { DeepPartial } from '../utils/type-helpers';
4
- export interface FormComponentProps<TData extends object, TPath extends Paths<TData>, TModelValueType> {
5
- form: Form<TData & DeepPartial<ObjectOf<TPath, TModelValueType>>>;
4
+ export interface FormComponentProps<TData extends object, TPath extends Paths<TData>, TModelValueType, TOutData = TData> {
5
+ form: Form<TData & DeepPartial<ObjectOf<TPath, TModelValueType>>, TOutData>;
6
6
  path: TPath;
7
7
  }
8
8
  export type ExcludedFieldProps = 'modelValue' | 'onUpdate:modelValue' | 'errors';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnovu/kit-vue-forms",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -4,18 +4,22 @@
4
4
 
5
5
  <script
6
6
  setup lang="ts"
7
- generic="TData extends object, TPath extends Paths<TData>"
7
+ generic="TData extends object, TPath extends Paths<TData>, TDataOut = TData"
8
8
  >
9
9
  import { reactive } from 'vue'
10
10
  import type { Form } from '../types/form.ts'
11
11
  import type { Paths, PickProps } from '../types/util.ts'
12
12
  import type { UseFieldOptions } from '../composables/useField.ts'
13
13
 
14
- export interface FieldProps<TData extends object, TPath extends string> extends UseFieldOptions<PickProps<TData, TPath>, TPath> {
15
- form: Form<TData>
14
+ export interface FieldProps<
15
+ TData extends object,
16
+ TPath extends string,
17
+ TDataOut = TData,
18
+ > extends UseFieldOptions<PickProps<TData, TPath>, TPath> {
19
+ form: Form<TData, TDataOut>
16
20
  }
17
21
 
18
- const props = defineProps<FieldProps<TData, TPath>>()
22
+ const props = defineProps<FieldProps<TData, TPath, TDataOut>>()
19
23
 
20
24
  const field = props.form.defineField({
21
25
  path: props.path,
@@ -28,17 +28,25 @@
28
28
  <script
29
29
  setup
30
30
  lang="ts"
31
- generic="TData extends object, TPath extends Paths<TData>, TComponent extends Component"
31
+ generic="
32
+ TForm extends Form<FormDataDefault, unknown>,
33
+ TPath extends Paths<TForm extends Form<infer Data> ? Data : never>,
34
+ TComponent extends Component
35
+ "
32
36
  >
33
37
  import { type Component } from 'vue'
34
38
  import type { ComponentProps } from 'vue-component-type-helpers'
35
39
  import type { Paths } from '../types/util.ts'
36
- import type { Form } from '../types/form.ts'
40
+ import type { Form, FormDataDefault } from '../types/form.ts'
37
41
 
38
- export interface FormFieldWrapperProps<TData extends object, TPath extends string, TComponent> {
42
+ export interface FormFieldWrapperProps<
43
+ TForm extends Form<FormDataDefault, unknown>,
44
+ TPath extends string,
45
+ TComponent,
46
+ > {
39
47
  component: TComponent
40
48
  componentProps: Omit<ComponentProps<TComponent>, 'modelValue' | 'update:modelValue' | 'errors'>
41
- form: Form<TData>
49
+ form: TForm
42
50
  path: TPath
43
51
  }
44
52
 
@@ -46,5 +54,5 @@ defineOptions({
46
54
  inheritAttrs: false,
47
55
  })
48
56
 
49
- defineProps<FormFieldWrapperProps<TData, TPath, TComponent>>()
57
+ defineProps<FormFieldWrapperProps<TForm, TPath, TComponent>>()
50
58
  </script>
@@ -5,18 +5,18 @@
5
5
  <script
6
6
  setup
7
7
  lang="ts"
8
- generic="TData extends object, TPath extends EntityPaths<TData>"
8
+ generic="TData extends object, TPath extends EntityPaths<TData>, TDataOut = TData"
9
9
  >
10
10
  import { computed } from 'vue'
11
11
  import type { Form } from '../types/form.ts'
12
12
  import type { EntityPaths } from '../types/util.ts'
13
13
 
14
- export interface FormPartProps<TData extends object, TPath> {
15
- form: Form<TData>
14
+ export interface FormPartProps<TData extends object, TPath, TDataOut = TData> {
15
+ form: Form<TData, TDataOut>
16
16
  path: TPath
17
17
  }
18
18
 
19
- const props = defineProps<FormPartProps<TData, TPath>>()
19
+ const props = defineProps<FormPartProps<TData, TPath, TDataOut>>()
20
20
 
21
21
  const subform = computed(() => props.form.getSubForm(props.path))
22
22
  </script>
@@ -6,8 +6,9 @@ export interface FormComponentProps<
6
6
  TData extends object,
7
7
  TPath extends Paths<TData>,
8
8
  TModelValueType,
9
+ TOutData = TData,
9
10
  > {
10
- form: Form<TData & DeepPartial<ObjectOf<TPath, TModelValueType>>>
11
+ form: Form<TData & DeepPartial<ObjectOf<TPath, TModelValueType>>, TOutData>
11
12
  path: TPath
12
13
  }
13
14