@prolibu-suite/cobalt-form-vue 0.1.0

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.
@@ -0,0 +1,30 @@
1
+ import { type Component } from 'vue';
2
+ import type { FieldDescriptor } from '@prolibu-suite/cobalt-form-core';
3
+ import { type RefState } from './fields/FieldRef.vue';
4
+ type __VLS_Props = {
5
+ field: FieldDescriptor;
6
+ value: any;
7
+ errors: string[];
8
+ disabled?: boolean;
9
+ refState?: RefState;
10
+ /**
11
+ * Per-app override map. Keyed by either `FieldKind` ('text', 'ref', ...) or
12
+ * by `originalAttrs.uiCom` (e.g. 'HtmlEditor', 'signature') for custom UIs.
13
+ */
14
+ fieldComponents?: Record<string, Component>;
15
+ };
16
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
+ "update:value": (value: any) => any;
18
+ blur: () => any;
19
+ search: (query: string) => any;
20
+ "load-more": () => any;
21
+ open: () => any;
22
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
23
+ "onUpdate:value"?: ((value: any) => any) | undefined;
24
+ onBlur?: (() => any) | undefined;
25
+ onSearch?: ((query: string) => any) | undefined;
26
+ "onLoad-more"?: (() => any) | undefined;
27
+ onOpen?: (() => any) | undefined;
28
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
29
+ export default _default;
30
+ //# sourceMappingURL=CoFieldRenderer.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoFieldRenderer.vue.d.ts","sourceRoot":"","sources":["../../src/components/CoFieldRenderer.vue"],"names":[],"mappings":"AAqEA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,iCAAiC,CAAC;AAOlF,OAAiB,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAchE,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CAC7C,CAAC;;;;;;;;;;;;;;AAoGF,wBAOG"}
@@ -0,0 +1,50 @@
1
+ import { type Component } from 'vue';
2
+ import { type FieldDescriptor, type RefResolver } from '@prolibu-suite/cobalt-form-core';
3
+ import type { UseFormReturn } from '../composables/useForm';
4
+ type __VLS_Props = {
5
+ form: UseFormReturn;
6
+ layout?: 'grid' | 'stack';
7
+ disabled?: boolean;
8
+ excludeFields?: string[];
9
+ fieldComponents?: Record<string, Component>;
10
+ refResolver?: RefResolver;
11
+ };
12
+ declare function onSubmit(): Promise<void>;
13
+ declare var __VLS_1: {
14
+ form: UseFormReturn;
15
+ }, __VLS_4: `field:${string}`, __VLS_5: {
16
+ field: FieldDescriptor;
17
+ value: any;
18
+ errors: string[];
19
+ setValue: (v: any) => void;
20
+ touch: () => void;
21
+ }, __VLS_18: {
22
+ form: UseFormReturn;
23
+ submit: typeof onSubmit;
24
+ };
25
+ type __VLS_Slots = {} & {
26
+ [K in NonNullable<typeof __VLS_4>]?: (props: typeof __VLS_5) => any;
27
+ } & {
28
+ header?: (props: typeof __VLS_1) => any;
29
+ } & {
30
+ footer?: (props: typeof __VLS_18) => any;
31
+ };
32
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
33
+ submit: (payload: {
34
+ values: Record<string, any>;
35
+ }) => any;
36
+ invalid: (errors: Record<string, string[]>) => any;
37
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
38
+ onSubmit?: ((payload: {
39
+ values: Record<string, any>;
40
+ }) => any) | undefined;
41
+ onInvalid?: ((errors: Record<string, string[]>) => any) | undefined;
42
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
43
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
44
+ export default _default;
45
+ type __VLS_WithSlots<T, S> = T & {
46
+ new (): {
47
+ $slots: S;
48
+ };
49
+ };
50
+ //# sourceMappingURL=CoFormRenderer.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoFormRenderer.vue.d.ts","sourceRoot":"","sources":["../../src/components/CoFormRenderer.vue"],"names":[],"mappings":"AAuQA,OAAO,EAAwC,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAC3E,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,WAAW,EAEjB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAI5D,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AA0CF,iBAAe,QAAQ,kBAYtB;AAyOD,QAAA,IAAI,OAAO;;CAAU,EAAE,OAAO,mBAAU,EAAE,OAAO;;;;kBA7ElC,GAAG;;CA6EyC,EAAE,QAAQ;;;CAAY,CAAE;AACnF,KAAK,WAAW,GAAG,EAAE,GACnB;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG;CAAE,GACvE;IAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC3C;IAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AA8B/C,QAAA,MAAM,eAAe;;gBA7TS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;gBAAnB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;kFAoU/C,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { FieldDescriptor } from '@prolibu-suite/cobalt-form-core';
2
+ type __VLS_Props = {
3
+ field: FieldDescriptor;
4
+ value: any;
5
+ errors: string[];
6
+ disabled?: boolean;
7
+ };
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:value": (value: any) => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ "onUpdate:value"?: ((value: any) => any) | undefined;
12
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ export default _default;
14
+ //# sourceMappingURL=FieldBoolean.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldBoolean.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FieldBoolean.vue"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;;;;;;AAsEF,wBAOG"}
@@ -0,0 +1,16 @@
1
+ import type { FieldDescriptor } from '@prolibu-suite/cobalt-form-core';
2
+ type __VLS_Props = {
3
+ field: FieldDescriptor;
4
+ value: any;
5
+ errors: string[];
6
+ disabled?: boolean;
7
+ };
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:value": (value: any) => any;
10
+ blur: () => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ "onUpdate:value"?: ((value: any) => any) | undefined;
13
+ onBlur?: (() => any) | undefined;
14
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ export default _default;
16
+ //# sourceMappingURL=FieldDate.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldDate.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FieldDate.vue"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;;;;;;;;AAmFF,wBAOG"}
@@ -0,0 +1,16 @@
1
+ import type { FieldDescriptor } from '@prolibu-suite/cobalt-form-core';
2
+ type __VLS_Props = {
3
+ field: FieldDescriptor;
4
+ value: any;
5
+ errors: string[];
6
+ disabled?: boolean;
7
+ };
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:value": (value: any) => any;
10
+ blur: () => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ "onUpdate:value"?: ((value: any) => any) | undefined;
13
+ onBlur?: (() => any) | undefined;
14
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ export default _default;
16
+ //# sourceMappingURL=FieldNumber.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldNumber.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FieldNumber.vue"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;;;;;;;;AA4FF,wBAOG"}
@@ -0,0 +1,30 @@
1
+ import type { FieldDescriptor, RefFieldOption } from '@prolibu-suite/cobalt-form-core';
2
+ export interface RefState {
3
+ options: RefFieldOption[];
4
+ selectedDisplay: RefFieldOption[];
5
+ loading: boolean;
6
+ total: number;
7
+ hasMore: boolean;
8
+ page: number;
9
+ query: string;
10
+ }
11
+ type __VLS_Props = {
12
+ field: FieldDescriptor;
13
+ value: any;
14
+ errors: string[];
15
+ disabled?: boolean;
16
+ refState?: RefState;
17
+ };
18
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ "update:value": (value: any) => any;
20
+ search: (query: string) => any;
21
+ "load-more": () => any;
22
+ open: () => any;
23
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
24
+ "onUpdate:value"?: ((value: any) => any) | undefined;
25
+ onSearch?: ((query: string) => any) | undefined;
26
+ "onLoad-more"?: (() => any) | undefined;
27
+ onOpen?: (() => any) | undefined;
28
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
29
+ export default _default;
30
+ //# sourceMappingURL=FieldRef.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldRef.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FieldRef.vue"],"names":[],"mappings":"AAqFA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEvF,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;;;;;;;;;;;;AAgJF,wBAOG"}
@@ -0,0 +1,16 @@
1
+ import type { FieldDescriptor } from '@prolibu-suite/cobalt-form-core';
2
+ type __VLS_Props = {
3
+ field: FieldDescriptor;
4
+ value: any;
5
+ errors: string[];
6
+ disabled?: boolean;
7
+ };
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:value": (value: any) => any;
10
+ blur: () => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ "onUpdate:value"?: ((value: any) => any) | undefined;
13
+ onBlur?: (() => any) | undefined;
14
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ export default _default;
16
+ //# sourceMappingURL=FieldSelect.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldSelect.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FieldSelect.vue"],"names":[],"mappings":"AA2CA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;;;;;;;;AA0FF,wBAOG"}
@@ -0,0 +1,16 @@
1
+ import type { FieldDescriptor } from '@prolibu-suite/cobalt-form-core';
2
+ type __VLS_Props = {
3
+ field: FieldDescriptor;
4
+ value: any;
5
+ errors: string[];
6
+ disabled?: boolean;
7
+ };
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:value": (value: any) => any;
10
+ blur: () => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ "onUpdate:value"?: ((value: any) => any) | undefined;
13
+ onBlur?: (() => any) | undefined;
14
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ export default _default;
16
+ //# sourceMappingURL=FieldText.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldText.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FieldText.vue"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;;;;;;;;AA8FF,wBAOG"}
@@ -0,0 +1,16 @@
1
+ import type { FieldDescriptor } from '@prolibu-suite/cobalt-form-core';
2
+ type __VLS_Props = {
3
+ field: FieldDescriptor;
4
+ value: any;
5
+ errors: string[];
6
+ disabled?: boolean;
7
+ };
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:value": (value: any) => any;
10
+ blur: () => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ "onUpdate:value"?: ((value: any) => any) | undefined;
13
+ onBlur?: (() => any) | undefined;
14
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ export default _default;
16
+ //# sourceMappingURL=FieldTextArea.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldTextArea.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FieldTextArea.vue"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;;;;;;;;AAmFF,wBAOG"}
@@ -0,0 +1,28 @@
1
+ import { createForm, type FieldDescriptor, type FormController, type FormControllerOptions, type FormSchemaLike, type SubmitResult } from '@prolibu-suite/cobalt-form-core';
2
+ import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
3
+ export interface UseFormReturn {
4
+ controller: Ref<FormController>;
5
+ values: ComputedRef<Record<string, any>>;
6
+ errors: ComputedRef<Record<string, string[]>>;
7
+ touched: ComputedRef<Record<string, boolean>>;
8
+ isValid: ComputedRef<boolean>;
9
+ isDirty: ComputedRef<boolean>;
10
+ isSubmitting: ComputedRef<boolean>;
11
+ fields: ComputedRef<FieldDescriptor[]>;
12
+ setValue: (name: string, value: any) => void;
13
+ setValues: (partial: Record<string, any>) => void;
14
+ touch: (name: string) => void;
15
+ touchAll: () => void;
16
+ setSchema: (instance: FormSchemaLike) => void;
17
+ validate: () => boolean;
18
+ submit: () => Promise<SubmitResult>;
19
+ reset: (values?: Record<string, any>) => void;
20
+ }
21
+ /**
22
+ * Bridges a {@link FormController} to Vue's reactivity. Returns reactive refs
23
+ * for state plus pass-through mutation helpers. Rebuilds the controller when
24
+ * the options change (e.g. schema swap).
25
+ */
26
+ export declare function useForm(options: MaybeRefOrGetter<FormControllerOptions>): UseFormReturn;
27
+ export { createForm };
28
+ //# sourceMappingURL=useForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/composables/useForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EAEnB,KAAK,YAAY,EAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,GAAG,EACT,MAAM,KAAK,CAAC;AAEb,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACzC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,EAAE,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC;IACvC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC7C,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAClD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,MAAM,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IACpC,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;CAC/C;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,aAAa,CAuDvF;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .co-form-layout[data-v-a8eb8e10]{display:grid;gap:var(--co-spacing-lg, 16px)}.co-form-layout--grid[data-v-a8eb8e10]{grid-template-columns:repeat(2,minmax(0,1fr))}.co-form-layout--stack[data-v-a8eb8e10]{grid-template-columns:1fr}.co-form-field--full[data-v-a8eb8e10]{grid-column:1 / -1}@media(max-width:640px){.co-form-layout--grid[data-v-a8eb8e10]{grid-template-columns:1fr}}.co-form-footer[data-v-a8eb8e10]{margin-top:var(--co-spacing-2xl, 24px)}
@@ -0,0 +1,14 @@
1
+ export { useForm, createForm } from './composables/useForm';
2
+ export type { UseFormReturn } from './composables/useForm';
3
+ export { default as CoFormRenderer } from './components/CoFormRenderer.vue';
4
+ export { default as CoFieldRenderer } from './components/CoFieldRenderer.vue';
5
+ export { default as FieldText } from './components/fields/FieldText.vue';
6
+ export { default as FieldTextArea } from './components/fields/FieldTextArea.vue';
7
+ export { default as FieldNumber } from './components/fields/FieldNumber.vue';
8
+ export { default as FieldDate } from './components/fields/FieldDate.vue';
9
+ export { default as FieldBoolean } from './components/fields/FieldBoolean.vue';
10
+ export { default as FieldSelect } from './components/fields/FieldSelect.vue';
11
+ export { default as FieldRef } from './components/fields/FieldRef.vue';
12
+ export type { RefState } from './components/fields/FieldRef.vue';
13
+ export type { FieldDescriptor, FieldKind, FormController, FormControllerOptions, FormSchemaInput, FormState, Locale, RefFieldOption, RefResolver, RefResolverArgs, RefResolverResult, SubmitResult, } from '@prolibu-suite/cobalt-form-core';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAE9E,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACvE,YAAY,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAEjE,YAAY,EACV,eAAe,EACf,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,SAAS,EACT,MAAM,EACN,cAAc,EACd,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,YAAY,GACb,MAAM,iCAAiC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,526 @@
1
+ import { createForm as U, normalizeForValidation as j } from "@prolibu-suite/cobalt-form-core";
2
+ import { createForm as me } from "@prolibu-suite/cobalt-form-core";
3
+ import { shallowRef as D, watch as J, toValue as z, onBeforeUnmount as P, computed as d, defineComponent as C, resolveComponent as A, openBlock as S, createBlock as $, resolveDynamicComponent as W, reactive as H, onMounted as G, createElementBlock as V, withModifiers as K, renderSlot as w, createElementVNode as k, normalizeClass as E, Fragment as Z, renderList as Q, createVNode as M } from "vue";
4
+ function ue(e) {
5
+ const c = D(null), t = D({
6
+ values: {},
7
+ errors: {},
8
+ touched: {},
9
+ isValid: !0,
10
+ isDirty: !1,
11
+ isSubmitting: !1
12
+ });
13
+ let r = null;
14
+ function m(a) {
15
+ r == null || r();
16
+ const s = U(a);
17
+ c.value = s, t.value = s.state, r = s.subscribe((o) => {
18
+ t.value = o;
19
+ });
20
+ }
21
+ return J(
22
+ () => z(e),
23
+ (a) => m(a),
24
+ { immediate: !0, deep: !1 }
25
+ ), P(() => {
26
+ r == null || r(), r = null;
27
+ }), {
28
+ controller: c,
29
+ values: d(() => t.value.values),
30
+ errors: d(() => t.value.errors),
31
+ touched: d(() => t.value.touched),
32
+ isValid: d(() => t.value.isValid),
33
+ isDirty: d(() => t.value.isDirty),
34
+ isSubmitting: d(() => t.value.isSubmitting),
35
+ fields: d(() => {
36
+ var a;
37
+ return ((a = c.value) == null ? void 0 : a.fields) ?? [];
38
+ }),
39
+ setValue: (a, s) => {
40
+ var o;
41
+ return (o = c.value) == null ? void 0 : o.setValue(a, s);
42
+ },
43
+ setValues: (a) => {
44
+ var s;
45
+ return (s = c.value) == null ? void 0 : s.setValues(a);
46
+ },
47
+ touch: (a) => {
48
+ var s;
49
+ return (s = c.value) == null ? void 0 : s.touch(a);
50
+ },
51
+ touchAll: () => {
52
+ var a;
53
+ return (a = c.value) == null ? void 0 : a.touchAll();
54
+ },
55
+ setSchema: (a) => {
56
+ var s;
57
+ return (s = c.value) == null ? void 0 : s.setSchema(a);
58
+ },
59
+ validate: () => {
60
+ var a;
61
+ return ((a = c.value) == null ? void 0 : a.validate()) ?? !0;
62
+ },
63
+ submit: () => {
64
+ var a;
65
+ return ((a = c.value) == null ? void 0 : a.submit()) ?? Promise.resolve({ values: {}, isValid: !0, errors: {} });
66
+ },
67
+ reset: (a) => {
68
+ var s;
69
+ return (s = c.value) == null ? void 0 : s.reset(a);
70
+ }
71
+ };
72
+ }
73
+ const X = /* @__PURE__ */ C({
74
+ __name: "FieldText",
75
+ props: {
76
+ field: {},
77
+ value: {},
78
+ errors: {},
79
+ disabled: { type: Boolean }
80
+ },
81
+ emits: ["update:value", "blur"],
82
+ setup(e, { emit: c }) {
83
+ const t = e, r = c, m = d(() => t.errors.length > 0 ? "error" : "default"), a = d(() => t.errors[0] || t.field.helperText), s = d(() => {
84
+ const o = t.field.originalAttrs, n = o.format || o.uiCom;
85
+ return n === "email" || t.field.name === "email" ? "email" : n === "password" || n === "Password" ? "password" : n === "tel" || n === "phone" ? "tel" : n === "url" ? "url" : "text";
86
+ });
87
+ return (o, n) => {
88
+ const h = A("co-input");
89
+ return S(), $(h, {
90
+ label: e.field.label,
91
+ placeholder: e.field.placeholder,
92
+ required: e.field.required,
93
+ disabled: e.disabled,
94
+ status: m.value,
95
+ "helper-text": a.value,
96
+ type: s.value,
97
+ value: String(e.value ?? ""),
98
+ onCoInput: n[0] || (n[0] = (f) => r("update:value", f.detail)),
99
+ onBlur: n[1] || (n[1] = (f) => r("blur"))
100
+ }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "type", "value"]);
101
+ };
102
+ }
103
+ }), O = /* @__PURE__ */ C({
104
+ __name: "FieldTextArea",
105
+ props: {
106
+ field: {},
107
+ value: {},
108
+ errors: {},
109
+ disabled: { type: Boolean }
110
+ },
111
+ emits: ["update:value", "blur"],
112
+ setup(e, { emit: c }) {
113
+ const t = e, r = c, m = d(() => t.errors.length > 0 ? "error" : "default"), a = d(() => t.errors[0] || t.field.helperText);
114
+ return (s, o) => {
115
+ const n = A("co-input");
116
+ return S(), $(n, {
117
+ label: e.field.label,
118
+ placeholder: e.field.placeholder,
119
+ required: e.field.required,
120
+ disabled: e.disabled,
121
+ status: m.value,
122
+ "helper-text": a.value,
123
+ multiline: "",
124
+ value: String(e.value ?? ""),
125
+ onCoInput: o[0] || (o[0] = (h) => r("update:value", h.detail)),
126
+ onBlur: o[1] || (o[1] = (h) => r("blur"))
127
+ }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "value"]);
128
+ };
129
+ }
130
+ }), Y = /* @__PURE__ */ C({
131
+ __name: "FieldNumber",
132
+ props: {
133
+ field: {},
134
+ value: {},
135
+ errors: {},
136
+ disabled: { type: Boolean }
137
+ },
138
+ emits: ["update:value", "blur"],
139
+ setup(e, { emit: c }) {
140
+ const t = e, r = c, m = d(() => t.errors.length > 0 ? "error" : "default"), a = d(() => t.errors[0] || t.field.helperText), s = d(() => t.field.originalAttrs.min), o = d(() => t.field.originalAttrs.max), n = d(() => typeof t.value == "number" ? t.value : void 0);
141
+ return (h, f) => {
142
+ const v = A("co-number-field");
143
+ return S(), $(v, {
144
+ label: e.field.label,
145
+ placeholder: e.field.placeholder,
146
+ required: e.field.required,
147
+ disabled: e.disabled,
148
+ status: m.value,
149
+ "helper-text": a.value,
150
+ min: s.value,
151
+ max: o.value,
152
+ value: n.value,
153
+ onCoChange: f[0] || (f[0] = (y) => r("update:value", y.detail)),
154
+ onBlur: f[1] || (f[1] = (y) => r("blur"))
155
+ }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "min", "max", "value"]);
156
+ };
157
+ }
158
+ }), _ = /* @__PURE__ */ C({
159
+ __name: "FieldDate",
160
+ props: {
161
+ field: {},
162
+ value: {},
163
+ errors: {},
164
+ disabled: { type: Boolean }
165
+ },
166
+ emits: ["update:value", "blur"],
167
+ setup(e, { emit: c }) {
168
+ const t = e, r = c, m = d(() => t.errors.length > 0 ? "error" : "default"), a = d(() => t.errors[0] || t.field.helperText);
169
+ return (s, o) => {
170
+ const n = A("co-input");
171
+ return S(), $(n, {
172
+ label: e.field.label,
173
+ placeholder: e.field.placeholder,
174
+ required: e.field.required,
175
+ disabled: e.disabled,
176
+ status: m.value,
177
+ "helper-text": a.value,
178
+ type: "date",
179
+ value: String(e.value ?? ""),
180
+ onCoInput: o[0] || (o[0] = (h) => r("update:value", h.detail)),
181
+ onBlur: o[1] || (o[1] = (h) => r("blur"))
182
+ }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "value"]);
183
+ };
184
+ }
185
+ }), ee = /* @__PURE__ */ C({
186
+ __name: "FieldBoolean",
187
+ props: {
188
+ field: {},
189
+ value: {},
190
+ errors: {},
191
+ disabled: { type: Boolean }
192
+ },
193
+ emits: ["update:value"],
194
+ setup(e, { emit: c }) {
195
+ const t = e, r = c, m = d(() => t.errors.length > 0 ? "error" : "default"), a = d(() => t.errors[0] || t.field.helperText);
196
+ return (s, o) => {
197
+ const n = A("co-switch");
198
+ return S(), $(n, {
199
+ label: e.field.label,
200
+ disabled: e.disabled,
201
+ status: m.value,
202
+ "helper-text": a.value,
203
+ checked: !!e.value,
204
+ onCoChange: o[0] || (o[0] = (h) => r("update:value", h.detail))
205
+ }, null, 8, ["label", "disabled", "status", "helper-text", "checked"]);
206
+ };
207
+ }
208
+ }), te = /* @__PURE__ */ C({
209
+ __name: "FieldSelect",
210
+ props: {
211
+ field: {},
212
+ value: {},
213
+ errors: {},
214
+ disabled: { type: Boolean }
215
+ },
216
+ emits: ["update:value", "blur"],
217
+ setup(e, { emit: c }) {
218
+ const t = e, r = c, m = d(() => t.errors.length > 0 ? "error" : "default"), a = d(() => t.errors[0] || t.field.helperText), s = d(() => {
219
+ const o = t.field.originalAttrs.enum;
220
+ return Array.isArray(o) ? JSON.stringify(o.map((n) => ({ label: String(n), value: String(n) }))) : "[]";
221
+ });
222
+ return (o, n) => {
223
+ const h = A("co-select");
224
+ return S(), $(h, {
225
+ label: e.field.label,
226
+ placeholder: e.field.placeholder,
227
+ required: e.field.required,
228
+ disabled: e.disabled,
229
+ status: m.value,
230
+ "helper-text": a.value,
231
+ options: s.value,
232
+ value: String(e.value ?? ""),
233
+ onCoChange: n[0] || (n[0] = (f) => r("update:value", f.detail)),
234
+ onBlur: n[1] || (n[1] = (f) => r("blur"))
235
+ }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "options", "value"]);
236
+ };
237
+ }
238
+ }), le = /* @__PURE__ */ C({
239
+ __name: "FieldRef",
240
+ props: {
241
+ field: {},
242
+ value: {},
243
+ errors: {},
244
+ disabled: { type: Boolean },
245
+ refState: {}
246
+ },
247
+ emits: ["update:value", "search", "load-more", "open"],
248
+ setup(e, { emit: c }) {
249
+ const t = e, r = c, m = d(() => t.errors.length > 0 ? "error" : "default"), a = d(() => t.errors[0] || t.field.helperText), s = d(
250
+ () => !!t.field.originalAttrs.multiple || t.field.originalAttrs.type === "array"
251
+ ), o = d(() => {
252
+ const v = t.value;
253
+ if (v == null) return "";
254
+ if (Array.isArray(v)) {
255
+ const y = v.map((x) => typeof x == "string" ? x : (x == null ? void 0 : x._id) || "");
256
+ return JSON.stringify(y);
257
+ }
258
+ return typeof v == "string" ? s.value ? JSON.stringify([v]) : v : typeof v == "object" && v._id ? s.value ? JSON.stringify([v._id]) : String(v._id) : "";
259
+ }), n = d(() => {
260
+ var v;
261
+ return JSON.stringify(((v = t.refState) == null ? void 0 : v.options) || []);
262
+ }), h = d(() => {
263
+ var v;
264
+ return JSON.stringify(((v = t.refState) == null ? void 0 : v.selectedDisplay) || []);
265
+ });
266
+ function f(v) {
267
+ const y = v.detail ?? {};
268
+ r("update:value", y.value);
269
+ }
270
+ return (v, y) => {
271
+ var R, B;
272
+ const x = A("co-ref-field");
273
+ return S(), $(x, {
274
+ label: e.field.label,
275
+ placeholder: e.field.placeholder,
276
+ required: e.field.required,
277
+ disabled: e.disabled,
278
+ clearable: !e.field.required,
279
+ multiple: s.value,
280
+ status: m.value,
281
+ "helper-text": a.value,
282
+ model: e.field.originalAttrs.ref,
283
+ value: o.value,
284
+ options: n.value,
285
+ "selected-display": h.value,
286
+ loading: ((R = e.refState) == null ? void 0 : R.loading) || !1,
287
+ total: ((B = e.refState) == null ? void 0 : B.total) || 0,
288
+ onCoOpen: y[0] || (y[0] = (q) => r("open")),
289
+ onCoSearch: y[1] || (y[1] = (q) => r("search", q.detail)),
290
+ onCoLoadMore: y[2] || (y[2] = (q) => r("load-more")),
291
+ onCoChange: f,
292
+ onCoClear: y[3] || (y[3] = (q) => r("update:value", s.value ? [] : null))
293
+ }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "multiple", "status", "helper-text", "model", "value", "options", "selected-display", "loading", "total"]);
294
+ };
295
+ }
296
+ }), re = /* @__PURE__ */ C({
297
+ __name: "CoFieldRenderer",
298
+ props: {
299
+ field: {},
300
+ value: {},
301
+ errors: {},
302
+ disabled: { type: Boolean },
303
+ refState: {},
304
+ fieldComponents: {}
305
+ },
306
+ emits: ["update:value", "blur", "search", "load-more", "open"],
307
+ setup(e, { emit: c }) {
308
+ const t = {
309
+ text: X,
310
+ textarea: O,
311
+ html: O,
312
+ number: Y,
313
+ date: _,
314
+ boolean: ee,
315
+ select: te,
316
+ ref: le,
317
+ custom: null
318
+ }, r = e, m = c, a = d(() => {
319
+ var o, n;
320
+ const s = r.field.originalAttrs.uiCom;
321
+ return s && ((o = r.fieldComponents) != null && o[s]) ? r.fieldComponents[s] : (n = r.fieldComponents) != null && n[r.field.kind] ? r.fieldComponents[r.field.kind] : t[r.field.kind] ?? null;
322
+ });
323
+ return (s, o) => (S(), $(W(a.value), {
324
+ field: e.field,
325
+ value: e.value,
326
+ errors: e.errors,
327
+ disabled: e.disabled,
328
+ "ref-state": e.refState,
329
+ "onUpdate:value": o[0] || (o[0] = (n) => m("update:value", n)),
330
+ onBlur: o[1] || (o[1] = (n) => m("blur")),
331
+ onSearch: o[2] || (o[2] = (n) => m("search", n)),
332
+ onLoadMore: o[3] || (o[3] = (n) => m("load-more")),
333
+ onOpen: o[4] || (o[4] = (n) => m("open"))
334
+ }, null, 40, ["field", "value", "errors", "disabled", "ref-state"]));
335
+ }
336
+ }), oe = { class: "co-form-footer" }, N = 20, ae = /* @__PURE__ */ C({
337
+ __name: "CoFormRenderer",
338
+ props: {
339
+ form: {},
340
+ layout: {},
341
+ disabled: { type: Boolean },
342
+ excludeFields: {},
343
+ fieldComponents: {},
344
+ refResolver: { type: Function }
345
+ },
346
+ emits: ["submit", "invalid"],
347
+ setup(e, { emit: c }) {
348
+ const t = e, r = c, m = d(() => t.layout ?? "grid"), a = d(() => {
349
+ const l = new Set(t.excludeFields ?? []);
350
+ return t.form.fields.value.filter((u) => !u.hidden && !l.has(u.name));
351
+ }), s = /* @__PURE__ */ new Set([
352
+ "TextArea",
353
+ "HtmlEditor",
354
+ "CodeEditor",
355
+ "TemplateEditor",
356
+ "FilterEditor",
357
+ "objectEditor",
358
+ "langEditor"
359
+ ]);
360
+ function o(l) {
361
+ var b;
362
+ if (l.fullWidth) return !0;
363
+ const u = (b = l.originalAttrs) == null ? void 0 : b.uiCom;
364
+ return typeof u == "string" && s.has(u);
365
+ }
366
+ function n(l) {
367
+ return t.form.touched.value[l.name] ? t.form.errors.value[l.name] || [] : [];
368
+ }
369
+ async function h() {
370
+ const l = await t.form.submit();
371
+ if (!l.isValid) {
372
+ t.form.touchAll(), r("invalid", l.errors);
373
+ return;
374
+ }
375
+ const u = t.form.fields.value.reduce((b, i) => (b[i.name] = i.ajvProperty, b), {});
376
+ r("submit", { values: j(l.values, u) });
377
+ }
378
+ const f = H({});
379
+ function v() {
380
+ return {
381
+ options: [],
382
+ selectedDisplay: [],
383
+ loading: !1,
384
+ total: 0,
385
+ hasMore: !1,
386
+ page: 1,
387
+ query: ""
388
+ };
389
+ }
390
+ function y(l, u) {
391
+ const b = l.originalAttrs.displayName || "name", i = [], p = [], F = (g) => {
392
+ g && (typeof g == "string" ? i.push(g) : typeof g == "object" && g._id && (i.push(g._id), p.push({
393
+ value: g._id,
394
+ label: String(g[b] ?? g.name ?? g._id),
395
+ meta: g
396
+ })));
397
+ };
398
+ return Array.isArray(u) ? u.forEach(F) : F(u), { ids: i, display: p };
399
+ }
400
+ async function x(l, u) {
401
+ if (!t.refResolver) return;
402
+ const b = f[l.name] || v();
403
+ b.loading = !0, f[l.name] = { ...b };
404
+ try {
405
+ const i = await t.refResolver({
406
+ model: l.originalAttrs.ref,
407
+ pageSize: N,
408
+ ...u
409
+ }), p = f[l.name], F = (u.page ?? 1) > 1;
410
+ f[l.name] = {
411
+ ...p,
412
+ options: F ? [...p.options, ...i.options] : i.options,
413
+ total: i.total ?? i.options.length,
414
+ hasMore: i.hasMore ?? (u.page ?? 1) * N < (i.total ?? i.options.length),
415
+ page: u.page ?? 1,
416
+ query: u.query ?? p.query,
417
+ loading: !1
418
+ };
419
+ } catch (i) {
420
+ console.error("[CoFormRenderer] refResolver failed:", i), f[l.name] = { ...f[l.name], loading: !1 };
421
+ }
422
+ }
423
+ async function R(l, u) {
424
+ if (!t.refResolver) return;
425
+ const b = f[l.name] || v();
426
+ b.loading = !0, f[l.name] = { ...b };
427
+ try {
428
+ const i = await t.refResolver({ model: l.originalAttrs.ref, ids: u }), p = f[l.name], F = new Set(p.selectedDisplay.map((T) => T.value)), g = [...p.selectedDisplay];
429
+ for (const T of i.options)
430
+ F.has(T.value) || g.push(T);
431
+ f[l.name] = { ...p, selectedDisplay: g, loading: !1 };
432
+ } catch (i) {
433
+ console.error("[CoFormRenderer] hydrateRef failed:", i), f[l.name] = { ...f[l.name], loading: !1 };
434
+ }
435
+ }
436
+ function B() {
437
+ for (const l of t.form.fields.value) {
438
+ if (l.kind !== "ref") continue;
439
+ const { ids: u, display: b } = y(l, t.form.values.value[l.name]);
440
+ f[l.name] = { ...v(), selectedDisplay: b };
441
+ const i = u.filter((p) => !b.some((F) => F.value === p));
442
+ i.length > 0 && R(l, i);
443
+ }
444
+ }
445
+ G(B), J(() => t.form.fields.value, B, { flush: "post" });
446
+ function q(l) {
447
+ const u = f[l.name];
448
+ u && u.options.length === 0 && !u.loading && x(l, { query: "", page: 1 });
449
+ }
450
+ function L(l, u) {
451
+ x(l, { query: u, page: 1 });
452
+ }
453
+ function I(l) {
454
+ const u = f[l.name];
455
+ !u || u.loading || !u.hasMore || x(l, { query: u.query, page: u.page + 1 });
456
+ }
457
+ return (l, u) => {
458
+ const b = A("co-button");
459
+ return S(), V("form", {
460
+ onSubmit: K(h, ["prevent"])
461
+ }, [
462
+ w(l.$slots, "header", { form: e.form }, void 0, !0),
463
+ k("div", {
464
+ class: E(["co-form-layout", `co-form-layout--${m.value}`])
465
+ }, [
466
+ (S(!0), V(Z, null, Q(a.value, (i) => (S(), V("div", {
467
+ key: i.name,
468
+ class: E(["co-form-field", { "co-form-field--full": o(i) }])
469
+ }, [
470
+ w(l.$slots, `field:${i.name}`, {
471
+ field: i,
472
+ value: e.form.values.value[i.name],
473
+ errors: n(i),
474
+ setValue: (p) => e.form.setValue(i.name, p),
475
+ touch: () => e.form.touch(i.name)
476
+ }, () => [
477
+ M(re, {
478
+ field: i,
479
+ value: e.form.values.value[i.name],
480
+ errors: n(i),
481
+ disabled: e.disabled || i.disabled,
482
+ "ref-state": f[i.name],
483
+ "field-components": e.fieldComponents,
484
+ "onUpdate:value": (p) => e.form.setValue(i.name, p),
485
+ onBlur: (p) => e.form.touch(i.name),
486
+ onSearch: (p) => L(i, p),
487
+ onLoadMore: (p) => I(i),
488
+ onOpen: (p) => q(i)
489
+ }, null, 8, ["field", "value", "errors", "disabled", "ref-state", "field-components", "onUpdate:value", "onBlur", "onSearch", "onLoadMore", "onOpen"])
490
+ ], !0)
491
+ ], 2))), 128))
492
+ ], 2),
493
+ k("div", oe, [
494
+ w(l.$slots, "footer", {
495
+ form: e.form,
496
+ submit: h
497
+ }, () => [
498
+ M(b, {
499
+ type: "submit",
500
+ label: "Enviar",
501
+ variant: "primary"
502
+ })
503
+ ], !0)
504
+ ])
505
+ ], 32);
506
+ };
507
+ }
508
+ }), ne = (e, c) => {
509
+ const t = e.__vccOpts || e;
510
+ for (const [r, m] of c)
511
+ t[r] = m;
512
+ return t;
513
+ }, de = /* @__PURE__ */ ne(ae, [["__scopeId", "data-v-a8eb8e10"]]);
514
+ export {
515
+ re as CoFieldRenderer,
516
+ de as CoFormRenderer,
517
+ ee as FieldBoolean,
518
+ _ as FieldDate,
519
+ Y as FieldNumber,
520
+ le as FieldRef,
521
+ te as FieldSelect,
522
+ X as FieldText,
523
+ O as FieldTextArea,
524
+ me as createForm,
525
+ ue as useForm
526
+ };
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@prolibu-suite/cobalt-form-vue",
3
+ "version": "0.1.0",
4
+ "description": "Cobalt Form — Vue 3 adapter. useForm() composable + CoFormRenderer component.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./style.css": "./dist/style.css"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "keywords": [
20
+ "form",
21
+ "schema",
22
+ "vue",
23
+ "cobalt",
24
+ "prolibu"
25
+ ],
26
+ "author": "Prolibu <contact@prolibu.com>",
27
+ "license": "MIT",
28
+ "peerDependencies": {
29
+ "vue": "^3.0.0",
30
+ "@prolibu-suite/cobalt-core": "0.1.0"
31
+ },
32
+ "dependencies": {
33
+ "@prolibu-suite/cobalt-form-core": "0.1.0"
34
+ },
35
+ "devDependencies": {
36
+ "@vitejs/plugin-vue": "^5.2.1",
37
+ "typescript": "^6.0.3",
38
+ "vite": "^6.0.0",
39
+ "vue": "^3.5.22",
40
+ "vue-tsc": "^2.2.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "build": "vite build && vue-tsc --emitDeclarationOnly -p tsconfig.json",
47
+ "dev": "vite build --watch",
48
+ "clean": "rm -rf dist"
49
+ }
50
+ }