@caipira/tamandua 0.0.33 → 0.0.34
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/Form.js +2 -2
- package/dist/Form.vue_vue_type_script_setup_true_lang-O6nqLPyU.js +205 -0
- package/dist/ModalForm.js +2 -2
- package/dist/{ModalForm.vue_vue_type_script_setup_true_lang-BSEORivR.js → ModalForm.vue_vue_type_script_setup_true_lang-BpkPebgZ.js} +34 -32
- package/dist/components.js +2 -2
- package/dist/{crud-lKm5HfM4.js → crud-TcRx_r8S.js} +4 -4
- package/dist/form2.js +1 -1
- package/dist/{plugin-DF8iyfN5.js → plugin-BkoyYU7S.js} +1 -1
- package/dist/{plugin-C3jERS0X.js → plugin-JFEZqDsu.js} +1 -1
- package/dist/{plugins-BA8tojIo.js → plugins-Bc8aBhAD.js} +3 -3
- package/dist/plugins.js +3 -3
- package/dist/tamandua.js +1 -1
- package/dist/types/components/Dropdown/types.d.ts +1 -1
- package/dist/types/components/Form/Form.vue.d.ts +42 -24
- package/dist/types/components/Form/types.d.ts +8 -4
- package/dist/types/components/InputPassword/InputPassword.vue.d.ts +1 -1
- package/dist/types/components/InputPassword/types.d.ts +10 -2
- package/dist/types/components/InputPrice/InputPrice.vue.d.ts +19 -3
- package/dist/types/components/InputPrice/types.d.ts +4 -0
- package/dist/types/components/InputSelect/InputSelect.story.d.ts +1 -1
- package/dist/types/components/InputSelect/InputSelect.vue.d.ts +69 -2
- package/dist/types/components/InputSelect/types.d.ts +33 -2
- package/dist/types/components/ModalForm/ModalForm.vue.d.ts +6 -1
- package/dist/types/components/ModalForm/types.d.ts +6 -4
- package/dist/types/composables/useForm.d.ts +20 -0
- package/dist/types/form/crud.d.ts +5 -4
- package/dist/types/form/form-transformer.d.ts +2 -2
- package/dist/types/form/form-transformer.test.d.ts +1 -0
- package/dist/types/form/form-value-transformers.d.ts +2 -1
- package/dist/types/types/address.d.ts +8 -8
- package/dist/types/types/common.d.ts +1 -0
- package/dist/types/types/form.d.ts +14 -59
- package/package.json +7 -4
- package/dist/Form.vue_vue_type_script_setup_true_lang-CbuLc6sr.js +0 -186
- /package/dist/types/{form/form.test.d.ts → composables/useForm.test.d.ts} +0 -0
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { InputPriceModel } from './types.js';
|
|
2
|
+
|
|
3
|
+
declare const _default: import('vue').DefineComponent<{
|
|
4
|
+
modelValue: import("vue").PropType<InputPriceModel>;
|
|
5
|
+
resource: {
|
|
6
|
+
type: import("vue").PropType<() => any>;
|
|
7
|
+
};
|
|
8
|
+
disabled: {
|
|
9
|
+
type: import("vue").PropType<boolean>;
|
|
10
|
+
};
|
|
11
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
|
+
modelValue: import("vue").PropType<InputPriceModel>;
|
|
13
|
+
resource: {
|
|
14
|
+
type: import("vue").PropType<() => any>;
|
|
15
|
+
};
|
|
16
|
+
disabled: {
|
|
17
|
+
type: import("vue").PropType<boolean>;
|
|
18
|
+
};
|
|
19
|
+
}>>, {}, {}>;
|
|
4
20
|
export default _default;
|
|
@@ -1,10 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ElementSize, ElementPosition } from '../../enums/ui.js';
|
|
2
|
+
import { SelectOption, InputSelectProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<InputSelectProps>, {
|
|
5
|
+
size: ElementSize;
|
|
6
|
+
options: () => never[];
|
|
7
|
+
mapper: (i: any) => SelectOption;
|
|
8
|
+
filter: (input: string, option: SelectOption) => boolean;
|
|
9
|
+
tooltip: string;
|
|
10
|
+
multiple: boolean;
|
|
11
|
+
placeholder: string;
|
|
12
|
+
isSearchable: boolean;
|
|
13
|
+
dropdownPlacement: ElementPosition;
|
|
14
|
+
/**
|
|
15
|
+
* CSS Classes
|
|
16
|
+
*/
|
|
17
|
+
widthClass: string;
|
|
18
|
+
borderClass: string;
|
|
19
|
+
roundnessClass: string;
|
|
20
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
+
"update:model-value": (val: any) => void;
|
|
22
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<InputSelectProps>, {
|
|
23
|
+
size: ElementSize;
|
|
24
|
+
options: () => never[];
|
|
25
|
+
mapper: (i: any) => SelectOption;
|
|
26
|
+
filter: (input: string, option: SelectOption) => boolean;
|
|
27
|
+
tooltip: string;
|
|
28
|
+
multiple: boolean;
|
|
29
|
+
placeholder: string;
|
|
30
|
+
isSearchable: boolean;
|
|
31
|
+
dropdownPlacement: ElementPosition;
|
|
32
|
+
/**
|
|
33
|
+
* CSS Classes
|
|
34
|
+
*/
|
|
35
|
+
widthClass: string;
|
|
36
|
+
borderClass: string;
|
|
37
|
+
roundnessClass: string;
|
|
38
|
+
}>>> & {
|
|
39
|
+
"onUpdate:model-value"?: ((val: any) => any) | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
filter: (input: string, option: SelectOption) => boolean;
|
|
42
|
+
size: ElementSize;
|
|
43
|
+
multiple: boolean;
|
|
44
|
+
options: SelectOption[];
|
|
45
|
+
placeholder: string;
|
|
46
|
+
mapper: (i: any) => SelectOption;
|
|
47
|
+
tooltip: string;
|
|
48
|
+
isSearchable: boolean;
|
|
49
|
+
dropdownPlacement: "top-start" | "top" | "top-end" | "right-start" | "right" | "right-end" | "bottom-end" | "bottom" | "bottom-start" | "left-end" | "left" | "left-start";
|
|
50
|
+
widthClass: string;
|
|
51
|
+
borderClass: string;
|
|
52
|
+
roundnessClass: string;
|
|
3
53
|
}, {}>, {
|
|
4
54
|
selection?(_: {}): any;
|
|
5
55
|
default?(_: any): any;
|
|
6
56
|
}>;
|
|
7
57
|
export default _default;
|
|
58
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
59
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
60
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
61
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
62
|
+
} : {
|
|
63
|
+
type: import('vue').PropType<T[K]>;
|
|
64
|
+
required: true;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
type __VLS_WithDefaults<P, D> = {
|
|
68
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
69
|
+
default: D[K];
|
|
70
|
+
}> : P[K];
|
|
71
|
+
};
|
|
72
|
+
type __VLS_Prettify<T> = {
|
|
73
|
+
[K in keyof T]: T[K];
|
|
74
|
+
} & {};
|
|
8
75
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
9
76
|
new (): {
|
|
10
77
|
$slots: S;
|
|
@@ -1,8 +1,39 @@
|
|
|
1
|
-
import { ElementSize, ElementPosition } from '../../enums/ui.js';
|
|
2
|
-
import { SelectValue, SelectOption } from '../../types/form.js';
|
|
1
|
+
import { Icon, ElementSize, ElementPosition } from '../../enums/ui.js';
|
|
3
2
|
import { APISearchFilters } from '../../types/api.js';
|
|
4
3
|
import { Pagination } from '../../types/ui.js';
|
|
5
4
|
|
|
5
|
+
export type SelectValuePrimitives = string | number;
|
|
6
|
+
export type SelectValue = SelectValuePrimitives | Array<SelectValuePrimitives>;
|
|
7
|
+
export type SelectOption = {
|
|
8
|
+
/** Optional icon, to be appended to the label */
|
|
9
|
+
icon?: `${Icon}`;
|
|
10
|
+
/** Option label, either a string or an object containing the props necessary to render the option */
|
|
11
|
+
label: string | object;
|
|
12
|
+
/** Optional type, used to diferentiate options from one another */
|
|
13
|
+
type?: string;
|
|
14
|
+
/** Optional renderer, containing the fully resolved path to the component that will be used
|
|
15
|
+
* to render the option
|
|
16
|
+
*/
|
|
17
|
+
renderer?: string;
|
|
18
|
+
} & ({
|
|
19
|
+
/** If true, the option is a group label and can't be selected */
|
|
20
|
+
isGroupLabel: boolean;
|
|
21
|
+
value?: never;
|
|
22
|
+
action?: never;
|
|
23
|
+
} | {
|
|
24
|
+
/** Option value */
|
|
25
|
+
value: SelectValue;
|
|
26
|
+
action?: never;
|
|
27
|
+
isGroupLabel?: never;
|
|
28
|
+
} | {
|
|
29
|
+
/** Action to be executed once the option is selected */
|
|
30
|
+
action: (filters?: APISearchFilters) => Promise<{
|
|
31
|
+
items: unknown[];
|
|
32
|
+
pagination: Pagination;
|
|
33
|
+
}> | Promise<void> | void;
|
|
34
|
+
value?: never;
|
|
35
|
+
isGroupLabel?: never;
|
|
36
|
+
});
|
|
6
37
|
export type InputSelectProps = {
|
|
7
38
|
size?: ElementSize;
|
|
8
39
|
options?: SelectOption[];
|
|
@@ -6,6 +6,11 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
6
6
|
}>, {
|
|
7
7
|
open: (key: string, id?: string | undefined) => void;
|
|
8
8
|
delete: () => void;
|
|
9
|
+
submit: () => Promise<{
|
|
10
|
+
isValid: boolean;
|
|
11
|
+
form: FormData | import("../../index.js").JSONForm;
|
|
12
|
+
} | undefined>;
|
|
13
|
+
reset: () => void;
|
|
9
14
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
15
|
saved: () => void;
|
|
11
16
|
closed: () => void;
|
|
@@ -16,7 +21,7 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
16
21
|
onClosed?: (() => any) | undefined;
|
|
17
22
|
onSaved?: (() => any) | undefined;
|
|
18
23
|
}, {
|
|
19
|
-
options: import("
|
|
24
|
+
options: import("../InputSelect/types.js").SelectOption[];
|
|
20
25
|
formClass: string;
|
|
21
26
|
}, {}>;
|
|
22
27
|
export default _default;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentExposed } from 'vue-component-type-helpers';
|
|
2
|
+
import { SelectOption } from '../InputSelect/types.js';
|
|
3
|
+
import { default as Form } from '../Form/Form.vue';
|
|
2
4
|
|
|
3
|
-
export type
|
|
5
|
+
export type FormItem = {
|
|
4
6
|
key: string;
|
|
5
7
|
title: string;
|
|
6
|
-
component:
|
|
8
|
+
component: ComponentExposed<typeof Form>;
|
|
7
9
|
pinnable?: boolean;
|
|
8
10
|
};
|
|
9
11
|
export type ModalFormProps = {
|
|
10
|
-
forms:
|
|
12
|
+
forms: FormItem[];
|
|
11
13
|
options?: SelectOption[];
|
|
12
14
|
formClass?: string;
|
|
13
15
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FormSubmissionFormat } from '../enums/form.js';
|
|
2
|
+
import { FormSchema, FormInstance } from '../types/form.js';
|
|
3
|
+
import { Ref, UnwrapNestedRefs } from 'vue';
|
|
4
|
+
|
|
5
|
+
export default function useForm<TSchema extends FormSchema = FormSchema>(options: {
|
|
6
|
+
id?: Ref<string | number>;
|
|
7
|
+
idKey?: string;
|
|
8
|
+
schema: TSchema;
|
|
9
|
+
format?: FormSubmissionFormat;
|
|
10
|
+
}): {
|
|
11
|
+
form: UnwrapNestedRefs<FormInstance<TSchema>>;
|
|
12
|
+
setValue: <K extends keyof UnwrapNestedRefs<FormInstance<TSchema>>>(key: K, value: UnwrapNestedRefs<FormInstance<TSchema>>[K]) => void;
|
|
13
|
+
setValues: (values: Partial<FormInstance<TSchema>>) => void;
|
|
14
|
+
getValue: (key: keyof UnwrapNestedRefs<FormInstance<TSchema>>) => UnwrapNestedRefs<FormInstance<TSchema>>[keyof UnwrapNestedRefs<FormInstance<TSchema>>];
|
|
15
|
+
reset: () => void;
|
|
16
|
+
submit: () => Promise<{
|
|
17
|
+
isValid: boolean;
|
|
18
|
+
form: FormData | import('../types/form.js').JSONForm;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FormStates } from '../enums/form.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentExposed } from 'vue-component-type-helpers';
|
|
3
|
+
import { default as ModalForm } from '../components/ModalForm/ModalForm.vue';
|
|
3
4
|
|
|
4
5
|
export default class CrudService {
|
|
5
6
|
id: string;
|
|
@@ -11,8 +12,8 @@ export default class CrudService {
|
|
|
11
12
|
EDIT: string;
|
|
12
13
|
};
|
|
13
14
|
isLoading: boolean;
|
|
14
|
-
formReference:
|
|
15
|
-
constructor(entity: string, formReference:
|
|
15
|
+
formReference: ComponentExposed<typeof ModalForm> | undefined;
|
|
16
|
+
constructor(entity: string, formReference: ComponentExposed<typeof ModalForm>);
|
|
16
17
|
get isEditing(): boolean;
|
|
17
18
|
get isCreating(): boolean;
|
|
18
19
|
show(state?: FormStates): void;
|
|
@@ -20,7 +21,7 @@ export default class CrudService {
|
|
|
20
21
|
edit(id: string): void;
|
|
21
22
|
close(): void;
|
|
22
23
|
reset(): void;
|
|
23
|
-
save(): void
|
|
24
|
+
save(): Promise<void>;
|
|
24
25
|
onSave(close?: boolean): void;
|
|
25
26
|
delete(): void;
|
|
26
27
|
onDelete(close?: boolean): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FormSchema, FormInstance,
|
|
1
|
+
import { JSONForm, FormSchema, FormInstance, FormDataForm } from '../types/form.js';
|
|
2
2
|
import { FormSubmissionFormat } from '../enums/form.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Transforms the form values to a format that conforms to the submission format
|
|
6
6
|
*/
|
|
7
|
-
export declare const transformForm: <F extends FormSubmissionFormat, S extends FormSchema>(form: FormInstance<S>, schema:
|
|
7
|
+
export declare const transformForm: <F extends FormSubmissionFormat, S extends FormSchema>(form: FormInstance<S>, schema: S, format: F) => Promise<F extends FormSubmissionFormat.FormData ? FormDataForm : JSONForm>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputPasswordModel } from '../components/InputPassword/types.js';
|
|
2
|
+
import { InputPriceModel } from '../components/InputPrice/types.js';
|
|
2
3
|
import { Country } from '../types/address.js';
|
|
3
4
|
|
|
4
5
|
declare const formValueDateTransformer: (date: Date) => string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Country = {
|
|
2
2
|
name: string;
|
|
3
3
|
dialCode: string;
|
|
4
4
|
flag: string;
|
|
5
5
|
iso2: string;
|
|
6
6
|
order: string;
|
|
7
|
-
}
|
|
8
|
-
export
|
|
7
|
+
};
|
|
8
|
+
export type CountryStateOption = {
|
|
9
9
|
uuid: string;
|
|
10
10
|
name: string;
|
|
11
|
-
}
|
|
12
|
-
export
|
|
11
|
+
};
|
|
12
|
+
export type AddressResource = {
|
|
13
13
|
city?: string;
|
|
14
14
|
complement?: string;
|
|
15
15
|
country?: string;
|
|
@@ -22,8 +22,8 @@ export interface AddressResource {
|
|
|
22
22
|
street?: string;
|
|
23
23
|
town?: string;
|
|
24
24
|
zipCode?: string;
|
|
25
|
-
}
|
|
26
|
-
export
|
|
25
|
+
};
|
|
26
|
+
export type AddressModel = {
|
|
27
27
|
city?: string;
|
|
28
28
|
complement?: string;
|
|
29
29
|
country?: Country;
|
|
@@ -36,4 +36,4 @@ export interface AddressModel {
|
|
|
36
36
|
street?: string;
|
|
37
37
|
town?: string;
|
|
38
38
|
zipCode?: string;
|
|
39
|
-
}
|
|
39
|
+
};
|
|
@@ -1,59 +1,13 @@
|
|
|
1
1
|
import { FormDataTypes, FormSubmissionFormat } from '../enums/form.js';
|
|
2
|
-
import { Icon } from '../enums/ui.js';
|
|
3
2
|
import { AddressModel, Country } from './address.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { InputPasswordModel } from '../components/InputPassword/types.js';
|
|
4
|
+
import { InputPriceModel } from '../components/InputPrice/types.js';
|
|
6
5
|
import { Website } from './website.js';
|
|
6
|
+
import { Maybe } from './common.js';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/** Optional icon, to be appended to the label */
|
|
12
|
-
icon?: `${Icon}`;
|
|
13
|
-
/** Option label, either a string or an object containing the props necessary to render the option */
|
|
14
|
-
label: string | object;
|
|
15
|
-
/** Optional type, used to diferentiate options from one another */
|
|
16
|
-
type?: string;
|
|
17
|
-
/** Optional renderer, containing the fully resolved path to the component that will be used
|
|
18
|
-
* to render the option
|
|
19
|
-
*/
|
|
20
|
-
renderer?: string;
|
|
21
|
-
} & ({
|
|
22
|
-
/** If true, the option is a group label and can't be selected */
|
|
23
|
-
isGroupLabel: boolean;
|
|
24
|
-
value?: never;
|
|
25
|
-
action?: never;
|
|
26
|
-
} | {
|
|
27
|
-
/** Option value */
|
|
28
|
-
value: SelectValue;
|
|
29
|
-
action?: never;
|
|
30
|
-
isGroupLabel?: never;
|
|
31
|
-
} | {
|
|
32
|
-
/** Action to be executed once the option is selected */
|
|
33
|
-
action: (filters?: APISearchFilters) => Promise<{
|
|
34
|
-
items: unknown[];
|
|
35
|
-
pagination: Pagination;
|
|
36
|
-
}> | Promise<void> | void;
|
|
37
|
-
value?: never;
|
|
38
|
-
isGroupLabel?: never;
|
|
39
|
-
});
|
|
40
|
-
export interface InputPriceModel {
|
|
41
|
-
iso: string;
|
|
42
|
-
value?: number;
|
|
43
|
-
}
|
|
44
|
-
export interface InputPasswordModel {
|
|
45
|
-
/** Unencrypted password */
|
|
46
|
-
raw: string;
|
|
47
|
-
/** If an encryptor was passed, this prop will hold the encrypted value */
|
|
48
|
-
hash?: string;
|
|
49
|
-
/** Strength of the password */
|
|
50
|
-
strength?: number;
|
|
51
|
-
/** Date of creation or last update */
|
|
52
|
-
updatedAt?: Date;
|
|
53
|
-
}
|
|
54
|
-
export type FormStyle = {
|
|
55
|
-
[key in "label" | "input"]?: string;
|
|
56
|
-
};
|
|
8
|
+
/**
|
|
9
|
+
* Map of the form data types and their corresponding value types
|
|
10
|
+
*/
|
|
57
11
|
export type FormSchemaValueMap = {
|
|
58
12
|
[FormDataTypes.Address]: AddressModel;
|
|
59
13
|
[FormDataTypes.Boolean]: boolean;
|
|
@@ -69,6 +23,10 @@ export type FormSchemaValueMap = {
|
|
|
69
23
|
[FormDataTypes.StringArray]: string[];
|
|
70
24
|
[FormDataTypes.Website]: Website;
|
|
71
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Form in the FormData format
|
|
28
|
+
*/
|
|
29
|
+
export type FormDataForm = InstanceType<typeof FormData>;
|
|
72
30
|
/**
|
|
73
31
|
* Form in the JSON format
|
|
74
32
|
*/
|
|
@@ -76,9 +34,8 @@ export type JSONForm = {
|
|
|
76
34
|
[prop: string]: string | number | boolean | string[];
|
|
77
35
|
};
|
|
78
36
|
/**
|
|
79
|
-
* Form
|
|
37
|
+
* Form submission format map
|
|
80
38
|
*/
|
|
81
|
-
export type FormDataForm = InstanceType<typeof FormData>;
|
|
82
39
|
export type FormSubmissionFormatMap = {
|
|
83
40
|
[FormSubmissionFormat.FormData]: FormDataForm;
|
|
84
41
|
[FormSubmissionFormat.JSON]: JSONForm;
|
|
@@ -98,17 +55,15 @@ export type ValidationResult<T = FormSubmissionFormat.FormData> = {
|
|
|
98
55
|
/**
|
|
99
56
|
* Form schema, defining the form fields and their corresponding FormDataTypes
|
|
100
57
|
*/
|
|
101
|
-
export type FormSchema =
|
|
102
|
-
[key: string]: FormDataTypes;
|
|
103
|
-
};
|
|
58
|
+
export type FormSchema = Record<string, FormDataTypes>;
|
|
104
59
|
/**
|
|
105
60
|
* Object containing the form values, each value being of one of the types from
|
|
106
61
|
* FormDataTypes, defined by each corresponding input component
|
|
107
62
|
*/
|
|
108
63
|
export type FormInstance<T extends Record<string, FormDataTypes>> = {
|
|
109
|
-
[K in keyof T]: FormSchemaValueMap[T[K]];
|
|
64
|
+
[K in keyof T]: T[K] extends FormDataTypes ? Maybe<FormSchemaValueMap[T[K]]> : never;
|
|
110
65
|
};
|
|
111
66
|
/**
|
|
112
|
-
*
|
|
67
|
+
* Union type of the accepted values by FormData
|
|
113
68
|
*/
|
|
114
69
|
export type AcceptedFormDataValues = string | Blob;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caipira/tamandua",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UI library for the Caipira ecosystem",
|
|
6
6
|
"license": "GPL-3.0-only",
|
|
@@ -62,11 +62,12 @@
|
|
|
62
62
|
"build:dev": "vite build --mode development",
|
|
63
63
|
"build:prod": "vite build --mode production",
|
|
64
64
|
"preview": "vite preview",
|
|
65
|
-
"start
|
|
65
|
+
"test:start": "vitest",
|
|
66
66
|
"test": "vitest --run",
|
|
67
67
|
"typecheck": "vue-tsc --noEmit -p tsconfig.json --composite false",
|
|
68
68
|
"start:sb": "storybook dev",
|
|
69
|
-
"build:sb": "storybook build"
|
|
69
|
+
"build:sb": "storybook build",
|
|
70
|
+
"prepublishOnly": "npm run build:prod"
|
|
70
71
|
},
|
|
71
72
|
"dependencies": {
|
|
72
73
|
"@floating-ui/vue": "^1.0.6",
|
|
@@ -77,9 +78,11 @@
|
|
|
77
78
|
"peerDependencies": {
|
|
78
79
|
"tailwindcss": "^3.4.3",
|
|
79
80
|
"vue": "^3.0.0",
|
|
80
|
-
"vue-i18n": "9"
|
|
81
|
+
"vue-i18n": "9",
|
|
82
|
+
"vue-router": "4.3.0"
|
|
81
83
|
},
|
|
82
84
|
"devDependencies": {
|
|
85
|
+
"vue-component-type-helpers": "^2.0.19",
|
|
83
86
|
"@faker-js/faker": "^8.4.1",
|
|
84
87
|
"@storybook/addon-actions": "^8.0.8",
|
|
85
88
|
"@storybook/addon-essentials": "^8.0.8",
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { defineComponent as A, reactive as P, ref as _, watch as T, provide as N, resolveComponent as O, openBlock as B, createElementBlock as j, renderSlot as E, createElementVNode as J, normalizeClass as R, withDirectives as W, createVNode as M, mergeProps as z, vShow as K } from "vue";
|
|
2
|
-
import { B as L } from "./ui-BC6H9E93.js";
|
|
3
|
-
import { F as a, a as p } from "./form-BkXpIJ0e.js";
|
|
4
|
-
import { f as I } from "./index-CjvqeRf7.js";
|
|
5
|
-
const V = (t) => t ? I(t, "yyyy-MM-dd") : "", h = (t) => [`${t?.iso}`, `${t?.value}`], b = (t) => t?.iso2 ?? "", w = async (t) => t?.hash ? t.hash : t?.raw ?? "", i = {
|
|
6
|
-
default: (t, r, e) => (r[e] = t, r),
|
|
7
|
-
price: (t, r, e, n = ["Currency", "Value"]) => {
|
|
8
|
-
const [c, s] = h(t);
|
|
9
|
-
return r[`${e}${n[0]}`] = c, r[`${e}${n[1]}`] = s, r;
|
|
10
|
-
},
|
|
11
|
-
password: async (t, r, e) => (r[e] = await w(t), r),
|
|
12
|
-
stringArray: (t, r, e) => (r[e] = t, r)
|
|
13
|
-
}, Y = async (t, r, e, n) => {
|
|
14
|
-
switch (t) {
|
|
15
|
-
case a.Country:
|
|
16
|
-
return i.default(
|
|
17
|
-
b(e),
|
|
18
|
-
r,
|
|
19
|
-
n
|
|
20
|
-
);
|
|
21
|
-
case a.Documents:
|
|
22
|
-
return i.default(e, r, n);
|
|
23
|
-
case a.Date:
|
|
24
|
-
return i.default(
|
|
25
|
-
V(e),
|
|
26
|
-
r,
|
|
27
|
-
n
|
|
28
|
-
);
|
|
29
|
-
case a.Address:
|
|
30
|
-
return i.default(e, r, n);
|
|
31
|
-
case a.Price:
|
|
32
|
-
return i.price(e, r, n);
|
|
33
|
-
case a.Password:
|
|
34
|
-
return await i.password(e, r, n);
|
|
35
|
-
case a.StringArray:
|
|
36
|
-
return i.stringArray(e, r, n);
|
|
37
|
-
default:
|
|
38
|
-
return i.default(e, r, n);
|
|
39
|
-
}
|
|
40
|
-
}, m = (t) => (t == null ? t = "" : typeof t == "object" ? t = JSON.stringify(t) : typeof t == "number" ? t = t.toString() : typeof t == "boolean" && (t = t ? "1" : "0"), t), u = {
|
|
41
|
-
default: (t, r, e) => (t = m(t), t && r.append(e, t), r),
|
|
42
|
-
price: (t, r, e, n = ["Currency", "Value"]) => {
|
|
43
|
-
const [c, s] = h(t);
|
|
44
|
-
return r.append(`${e}${n[0]}`, m(c)), r.append(`${e}${n[1]}`, m(s)), r;
|
|
45
|
-
},
|
|
46
|
-
address: (t, r, e) => (r.append(
|
|
47
|
-
e,
|
|
48
|
-
JSON.stringify({
|
|
49
|
-
...t,
|
|
50
|
-
country: b(t?.country)
|
|
51
|
-
})
|
|
52
|
-
), r),
|
|
53
|
-
documents: (t, r, e) => (e.endsWith("[]") || (e = `${e}[]`), Array.from(t).forEach((n) => r.append(e, n)), r),
|
|
54
|
-
document: (t, r, e) => (r.append(e, t), r),
|
|
55
|
-
stringArray: (t, r, e) => (e.endsWith("[]") || (e = `${e}[]`), t.forEach((n) => r.append(e, m(n))), r)
|
|
56
|
-
}, q = async (t, r, e, n) => {
|
|
57
|
-
switch (t) {
|
|
58
|
-
case a.Country:
|
|
59
|
-
return u.default(
|
|
60
|
-
b(e),
|
|
61
|
-
r,
|
|
62
|
-
n
|
|
63
|
-
);
|
|
64
|
-
case a.Document:
|
|
65
|
-
return u.document(e, r, n);
|
|
66
|
-
case a.Documents:
|
|
67
|
-
return u.documents(e, r, n);
|
|
68
|
-
case a.Date:
|
|
69
|
-
return u.default(
|
|
70
|
-
V(e),
|
|
71
|
-
r,
|
|
72
|
-
n
|
|
73
|
-
);
|
|
74
|
-
case a.Address:
|
|
75
|
-
return u.address(e, r, n);
|
|
76
|
-
case a.Price:
|
|
77
|
-
return u.price(e, r, n);
|
|
78
|
-
case a.Password:
|
|
79
|
-
return u.default(
|
|
80
|
-
await w(e),
|
|
81
|
-
r,
|
|
82
|
-
n
|
|
83
|
-
);
|
|
84
|
-
case a.StringArray:
|
|
85
|
-
return u.stringArray(e, r, n);
|
|
86
|
-
default:
|
|
87
|
-
return u.default(e, r, n);
|
|
88
|
-
}
|
|
89
|
-
}, x = async (t, r, e) => {
|
|
90
|
-
switch (e) {
|
|
91
|
-
case p.JSON:
|
|
92
|
-
let n = {};
|
|
93
|
-
for (const s in t)
|
|
94
|
-
n = await Y(
|
|
95
|
-
r[s],
|
|
96
|
-
n,
|
|
97
|
-
t[s],
|
|
98
|
-
s
|
|
99
|
-
);
|
|
100
|
-
return n;
|
|
101
|
-
case p.FormData:
|
|
102
|
-
default:
|
|
103
|
-
let c = new FormData();
|
|
104
|
-
for (const s in t)
|
|
105
|
-
c = await q(
|
|
106
|
-
r[s],
|
|
107
|
-
c,
|
|
108
|
-
t[s],
|
|
109
|
-
s
|
|
110
|
-
);
|
|
111
|
-
return c;
|
|
112
|
-
}
|
|
113
|
-
}, X = /* @__PURE__ */ A({
|
|
114
|
-
name: "TForm",
|
|
115
|
-
__name: "Form",
|
|
116
|
-
props: {
|
|
117
|
-
id: { default: "" },
|
|
118
|
-
idKey: { default: "id" },
|
|
119
|
-
schema: { default: () => ({}) },
|
|
120
|
-
formStyle: { default: () => ({}) },
|
|
121
|
-
showSubmit: { type: Boolean, default: !1 },
|
|
122
|
-
submitLabel: { default: "Submit" },
|
|
123
|
-
buttonProps: {},
|
|
124
|
-
buttonVariant: { default: L.PRIMARY },
|
|
125
|
-
submissionFormat: { default: p.FormData },
|
|
126
|
-
buttonWrapperClasses: { default: "" }
|
|
127
|
-
},
|
|
128
|
-
emits: ["submit", "change"],
|
|
129
|
-
setup(t, { expose: r, emit: e }) {
|
|
130
|
-
const n = t, c = e, s = P({}), y = _(null), l = async () => {
|
|
131
|
-
c("submit", await F());
|
|
132
|
-
}, F = async () => {
|
|
133
|
-
const o = { ...s };
|
|
134
|
-
return n.id && (o[n.idKey] = n.id), {
|
|
135
|
-
isValid: !0,
|
|
136
|
-
form: await x(
|
|
137
|
-
o,
|
|
138
|
-
n.schema,
|
|
139
|
-
n.submissionFormat
|
|
140
|
-
)
|
|
141
|
-
};
|
|
142
|
-
}, S = () => {
|
|
143
|
-
Object.assign(s, {});
|
|
144
|
-
}, g = (o) => {
|
|
145
|
-
for (const [d, f] of Object.entries(o))
|
|
146
|
-
s[d] = f;
|
|
147
|
-
}, $ = () => s, D = (o, d) => {
|
|
148
|
-
s[o] = d;
|
|
149
|
-
}, C = (o) => s[o];
|
|
150
|
-
return T(s, (o) => {
|
|
151
|
-
c("change", o);
|
|
152
|
-
}), N("formStyle", n.formStyle), r({
|
|
153
|
-
submit: l,
|
|
154
|
-
reset: S,
|
|
155
|
-
setValues: g,
|
|
156
|
-
getValues: $,
|
|
157
|
-
setValue: D,
|
|
158
|
-
getValue: C
|
|
159
|
-
}), (o, d) => {
|
|
160
|
-
const f = O("t-button");
|
|
161
|
-
return B(), j("form", {
|
|
162
|
-
onSubmit: l,
|
|
163
|
-
ref_key: "formReference",
|
|
164
|
-
ref: y
|
|
165
|
-
}, [
|
|
166
|
-
E(o.$slots, "default", { form: s }),
|
|
167
|
-
J("div", {
|
|
168
|
-
class: R([n.buttonWrapperClasses])
|
|
169
|
-
}, [
|
|
170
|
-
W(M(f, z(n.buttonProps, {
|
|
171
|
-
type: "submit",
|
|
172
|
-
class: "mt-4",
|
|
173
|
-
variant: n.buttonVariant,
|
|
174
|
-
label: n.submitLabel,
|
|
175
|
-
onClick: l
|
|
176
|
-
}), null, 16, ["variant", "label"]), [
|
|
177
|
-
[K, n.showSubmit]
|
|
178
|
-
])
|
|
179
|
-
], 2)
|
|
180
|
-
], 544);
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
export {
|
|
185
|
-
X as _
|
|
186
|
-
};
|
|
File without changes
|