@prolibu-suite/cobalt-form 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.
Files changed (38) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  2. package/dist/cjs/co-form.cjs.entry.js +8 -0
  3. package/dist/cjs/cobalt-form.cjs.js +25 -0
  4. package/dist/cjs/index-8raPCV5a.js +2019 -0
  5. package/dist/cjs/index.cjs.js +9260 -0
  6. package/dist/cjs/loader.cjs.js +13 -0
  7. package/dist/cobalt-form/cobalt-form.esm.js +1 -0
  8. package/dist/cobalt-form/index.esm.js +7 -0
  9. package/dist/cobalt-form/p-DQuL1Twl.js +1 -0
  10. package/dist/cobalt-form/p-X0Keifac.js +2 -0
  11. package/dist/cobalt-form/p-ef70e055.entry.js +1 -0
  12. package/dist/collection/collection-manifest.json +13 -0
  13. package/dist/collection/components/co-form/co-form.css +23 -0
  14. package/dist/collection/components/co-form/co-form.js +750 -0
  15. package/dist/collection/index.js +1 -0
  16. package/dist/components/co-form.d.ts +11 -0
  17. package/dist/components/co-form.js +1 -0
  18. package/dist/components/index.d.ts +35 -0
  19. package/dist/components/index.js +7 -0
  20. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  21. package/dist/esm/co-form.entry.js +2 -0
  22. package/dist/esm/cobalt-form.js +21 -0
  23. package/dist/esm/index-X0Keifac.js +1993 -0
  24. package/dist/esm/index.js +9258 -0
  25. package/dist/esm/loader.js +11 -0
  26. package/dist/index.cjs.js +1 -0
  27. package/dist/index.js +1 -0
  28. package/dist/types/components/co-form/co-form.d.ts +88 -0
  29. package/dist/types/components.d.ts +217 -0
  30. package/dist/types/index.d.ts +1 -0
  31. package/dist/types/jsx-cobalt.d.ts +60 -0
  32. package/dist/types/stencil-public-runtime.d.ts +1860 -0
  33. package/loader/cdn.js +1 -0
  34. package/loader/index.cjs.js +1 -0
  35. package/loader/index.d.ts +24 -0
  36. package/loader/index.es2017.js +1 -0
  37. package/loader/index.js +2 -0
  38. package/package.json +56 -0
@@ -0,0 +1,11 @@
1
+ import { b as bootstrapLazy } from './index-X0Keifac.js';
2
+ export { s as setNonce } from './index-X0Keifac.js';
3
+ import { g as globalScripts } from './app-globals-DQuL1Twl.js';
4
+
5
+ const defineCustomElements = async (win, options) => {
6
+ if (typeof window === 'undefined') return undefined;
7
+ await globalScripts();
8
+ return bootstrapLazy([["co-form",[[260,"co-form",{"schema":[1],"initialValues":[1,"initial-values"],"schemaInstance":[16],"refResolver":[16],"locale":[1],"layout":[1],"excludeFields":[1,"exclude-fields"],"disabled":[4],"readOnly":[4,"read-only"],"snapshot":[32],"refStates":[32],"setValue":[64],"getValue":[64],"touch":[64]},null,{"schema":[{"onSchemaChange":0}],"schemaInstance":[{"onSchemaChange":0}],"locale":[{"onSchemaChange":0}]}]]]], options);
9
+ };
10
+
11
+ export { defineCustomElements };
@@ -0,0 +1 @@
1
+ module.exports = require('./cjs/index.cjs.js');
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './esm/index.js';
@@ -0,0 +1,88 @@
1
+ import { EventEmitter } from '../../stencil-public-runtime';
2
+ import { type FormSchemaLike, type Locale, type RefResolver } from '@prolibu-suite/cobalt-form-core';
3
+ /**
4
+ * Schema-driven form. Renders Cobalt input components from an inline
5
+ * Prolibu/Mongoose-style JSON schema and emits the validated payload on submit.
6
+ *
7
+ * Validation: bundled AJV (via `createInlineValidator` in form-core) handles
8
+ * required, format, min/max, minLength/maxLength, enum, regex out of the box.
9
+ * Hosts wanting full Prolibu FormSchemaWeb behavior can assign a pre-built
10
+ * `FormSchemaLike` to the `schemaInstance` element property.
11
+ *
12
+ * Ref fields: assign a `refResolver` function to the element to enable
13
+ * search + pagination + label hydration against your backend. See
14
+ * {@link RefResolver}.
15
+ *
16
+ * @slot header - Content above the fields.
17
+ * @slot footer - Content below the fields (default: a primary submit button).
18
+ * @slot field:<name> - Override the rendering of a specific field by name.
19
+ */
20
+ export declare class CoForm {
21
+ host: HTMLElement;
22
+ /** Raw Mongoose-style schema as a JSON string. */
23
+ schema: string;
24
+ /** Initial field values as a JSON string. */
25
+ initialValues?: string;
26
+ /** Pre-built FormSchemaLike — assigned as a JS property, bypasses parsing. */
27
+ schemaInstance?: FormSchemaLike;
28
+ /** Host-provided resolver for ref fields. Set as a JS property. */
29
+ refResolver?: RefResolver;
30
+ /** Locale for labels and AJV error messages. */
31
+ locale: Locale;
32
+ /** Layout strategy for the field grid. */
33
+ layout: 'grid' | 'stack';
34
+ /** Comma-separated list of field names to exclude from rendering. */
35
+ excludeFields?: string;
36
+ /** Disable all fields. */
37
+ disabled: boolean;
38
+ /** Read-only mode for all fields. */
39
+ readOnly: boolean;
40
+ /** Emits the payload (refs normalized to `_id`) after a successful submit. */
41
+ coSubmit: EventEmitter<{
42
+ values: Record<string, any>;
43
+ }>;
44
+ /** Emits whenever a field changes. */
45
+ coChange: EventEmitter<{
46
+ name: string;
47
+ value: any;
48
+ }>;
49
+ /** Emits validation state changes. */
50
+ coValidate: EventEmitter<{
51
+ isValid: boolean;
52
+ errors: Record<string, string[]>;
53
+ }>;
54
+ private snapshot;
55
+ private refStates;
56
+ private controller;
57
+ private fields;
58
+ private unsubscribe;
59
+ componentWillLoad(): void;
60
+ onSchemaChange(): void;
61
+ disconnectedCallback(): void;
62
+ private rebuildController;
63
+ private resolveSchemaInstance;
64
+ private parseInitialValues;
65
+ private get excludedSet();
66
+ /** Push a value into the controller from outside (e.g. from slot content). */
67
+ setValue(name: string, value: any): Promise<void>;
68
+ /** Read the current value of a field. */
69
+ getValue(name: string): Promise<any>;
70
+ /** Mark a field as touched (forces its errors to be visible). */
71
+ touch(name: string): Promise<void>;
72
+ private handleFieldChange;
73
+ private hasSlotContent;
74
+ private handleSubmit;
75
+ private initRefStates;
76
+ /** Given a raw value, return the canonical {ids, display} pair. */
77
+ private normalizeRefValue;
78
+ private hydrateRefFieldLabels;
79
+ private patchRefState;
80
+ private handleRefSearch;
81
+ private handleRefLoadMore;
82
+ private fetchRefPage;
83
+ private handleRefSelect;
84
+ private refValueAsString;
85
+ render(): any;
86
+ private renderField;
87
+ private optionsFor;
88
+ }
@@ -0,0 +1,217 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ /**
4
+ * This is an autogenerated file created by the Stencil compiler.
5
+ * It contains typing information for all components that exist in this project.
6
+ */
7
+ import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
8
+ import { FormSchemaLike, Locale, RefResolver } from "@prolibu-suite/cobalt-form-core";
9
+ export { FormSchemaLike, Locale, RefResolver } from "@prolibu-suite/cobalt-form-core";
10
+ export namespace Components {
11
+ /**
12
+ * Schema-driven form. Renders Cobalt input components from an inline
13
+ * Prolibu/Mongoose-style JSON schema and emits the validated payload on submit.
14
+ * Validation: bundled AJV (via `createInlineValidator` in form-core) handles
15
+ * required, format, min/max, minLength/maxLength, enum, regex out of the box.
16
+ * Hosts wanting full Prolibu FormSchemaWeb behavior can assign a pre-built
17
+ * `FormSchemaLike` to the `schemaInstance` element property.
18
+ * Ref fields: assign a `refResolver` function to the element to enable
19
+ * search + pagination + label hydration against your backend. See
20
+ * {@link RefResolver}.
21
+ */
22
+ interface CoForm {
23
+ /**
24
+ * Disable all fields.
25
+ * @default false
26
+ */
27
+ "disabled": boolean;
28
+ /**
29
+ * Comma-separated list of field names to exclude from rendering.
30
+ */
31
+ "excludeFields"?: string;
32
+ /**
33
+ * Read the current value of a field.
34
+ */
35
+ "getValue": (name: string) => Promise<any>;
36
+ /**
37
+ * Initial field values as a JSON string.
38
+ */
39
+ "initialValues"?: string;
40
+ /**
41
+ * Layout strategy for the field grid.
42
+ * @default 'grid'
43
+ */
44
+ "layout": 'grid' | 'stack';
45
+ /**
46
+ * Locale for labels and AJV error messages.
47
+ * @default 'es'
48
+ */
49
+ "locale": Locale;
50
+ /**
51
+ * Read-only mode for all fields.
52
+ * @default false
53
+ */
54
+ "readOnly": boolean;
55
+ /**
56
+ * Host-provided resolver for ref fields. Set as a JS property.
57
+ */
58
+ "refResolver"?: RefResolver;
59
+ /**
60
+ * Raw Mongoose-style schema as a JSON string.
61
+ */
62
+ "schema": string;
63
+ /**
64
+ * Pre-built FormSchemaLike — assigned as a JS property, bypasses parsing.
65
+ */
66
+ "schemaInstance"?: FormSchemaLike;
67
+ /**
68
+ * Push a value into the controller from outside (e.g. from slot content).
69
+ */
70
+ "setValue": (name: string, value: any) => Promise<void>;
71
+ /**
72
+ * Mark a field as touched (forces its errors to be visible).
73
+ */
74
+ "touch": (name: string) => Promise<void>;
75
+ }
76
+ }
77
+ export interface CoFormCustomEvent<T> extends CustomEvent<T> {
78
+ detail: T;
79
+ target: HTMLCoFormElement;
80
+ }
81
+ declare global {
82
+ interface HTMLCoFormElementEventMap {
83
+ "coSubmit": { values: Record<string, any> };
84
+ "coChange": { name: string; value: any };
85
+ "coValidate": { isValid: boolean; errors: Record<string, string[]> };
86
+ }
87
+ /**
88
+ * Schema-driven form. Renders Cobalt input components from an inline
89
+ * Prolibu/Mongoose-style JSON schema and emits the validated payload on submit.
90
+ * Validation: bundled AJV (via `createInlineValidator` in form-core) handles
91
+ * required, format, min/max, minLength/maxLength, enum, regex out of the box.
92
+ * Hosts wanting full Prolibu FormSchemaWeb behavior can assign a pre-built
93
+ * `FormSchemaLike` to the `schemaInstance` element property.
94
+ * Ref fields: assign a `refResolver` function to the element to enable
95
+ * search + pagination + label hydration against your backend. See
96
+ * {@link RefResolver}.
97
+ */
98
+ interface HTMLCoFormElement extends Components.CoForm, HTMLStencilElement {
99
+ addEventListener<K extends keyof HTMLCoFormElementEventMap>(type: K, listener: (this: HTMLCoFormElement, ev: CoFormCustomEvent<HTMLCoFormElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
100
+ addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
101
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
102
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
103
+ removeEventListener<K extends keyof HTMLCoFormElementEventMap>(type: K, listener: (this: HTMLCoFormElement, ev: CoFormCustomEvent<HTMLCoFormElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
104
+ removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
105
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
106
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
107
+ }
108
+ var HTMLCoFormElement: {
109
+ prototype: HTMLCoFormElement;
110
+ new (): HTMLCoFormElement;
111
+ };
112
+ interface HTMLElementTagNameMap {
113
+ "co-form": HTMLCoFormElement;
114
+ }
115
+ }
116
+ declare namespace LocalJSX {
117
+ type OneOf<K extends string, PropT, AttrT = PropT> = { [P in K]: PropT } & { [P in `attr:${K}` | `prop:${K}`]?: never } | { [P in `attr:${K}`]: AttrT } & { [P in K | `prop:${K}`]?: never } | { [P in `prop:${K}`]: PropT } & { [P in K | `attr:${K}`]?: never };
118
+
119
+ /**
120
+ * Schema-driven form. Renders Cobalt input components from an inline
121
+ * Prolibu/Mongoose-style JSON schema and emits the validated payload on submit.
122
+ * Validation: bundled AJV (via `createInlineValidator` in form-core) handles
123
+ * required, format, min/max, minLength/maxLength, enum, regex out of the box.
124
+ * Hosts wanting full Prolibu FormSchemaWeb behavior can assign a pre-built
125
+ * `FormSchemaLike` to the `schemaInstance` element property.
126
+ * Ref fields: assign a `refResolver` function to the element to enable
127
+ * search + pagination + label hydration against your backend. See
128
+ * {@link RefResolver}.
129
+ */
130
+ interface CoForm {
131
+ /**
132
+ * Disable all fields.
133
+ * @default false
134
+ */
135
+ "disabled"?: boolean;
136
+ /**
137
+ * Comma-separated list of field names to exclude from rendering.
138
+ */
139
+ "excludeFields"?: string;
140
+ /**
141
+ * Initial field values as a JSON string.
142
+ */
143
+ "initialValues"?: string;
144
+ /**
145
+ * Layout strategy for the field grid.
146
+ * @default 'grid'
147
+ */
148
+ "layout"?: 'grid' | 'stack';
149
+ /**
150
+ * Locale for labels and AJV error messages.
151
+ * @default 'es'
152
+ */
153
+ "locale"?: Locale;
154
+ /**
155
+ * Emits whenever a field changes.
156
+ */
157
+ "onCoChange"?: (event: CoFormCustomEvent<{ name: string; value: any }>) => void;
158
+ /**
159
+ * Emits the payload (refs normalized to `_id`) after a successful submit.
160
+ */
161
+ "onCoSubmit"?: (event: CoFormCustomEvent<{ values: Record<string, any> }>) => void;
162
+ /**
163
+ * Emits validation state changes.
164
+ */
165
+ "onCoValidate"?: (event: CoFormCustomEvent<{ isValid: boolean; errors: Record<string, string[]> }>) => void;
166
+ /**
167
+ * Read-only mode for all fields.
168
+ * @default false
169
+ */
170
+ "readOnly"?: boolean;
171
+ /**
172
+ * Host-provided resolver for ref fields. Set as a JS property.
173
+ */
174
+ "refResolver"?: RefResolver;
175
+ /**
176
+ * Raw Mongoose-style schema as a JSON string.
177
+ */
178
+ "schema": string;
179
+ /**
180
+ * Pre-built FormSchemaLike — assigned as a JS property, bypasses parsing.
181
+ */
182
+ "schemaInstance"?: FormSchemaLike;
183
+ }
184
+
185
+ interface CoFormAttributes {
186
+ "schema": string;
187
+ "initialValues": string;
188
+ "locale": Locale;
189
+ "layout": 'grid' | 'stack';
190
+ "excludeFields": string;
191
+ "disabled": boolean;
192
+ "readOnly": boolean;
193
+ }
194
+
195
+ interface IntrinsicElements {
196
+ "co-form": Omit<CoForm, keyof CoFormAttributes> & { [K in keyof CoForm & keyof CoFormAttributes]?: CoForm[K] } & { [K in keyof CoForm & keyof CoFormAttributes as `attr:${K}`]?: CoFormAttributes[K] } & { [K in keyof CoForm & keyof CoFormAttributes as `prop:${K}`]?: CoForm[K] } & OneOf<"schema", CoForm["schema"], CoFormAttributes["schema"]>;
197
+ }
198
+ }
199
+ export { LocalJSX as JSX };
200
+ declare module "@stencil/core" {
201
+ export namespace JSX {
202
+ interface IntrinsicElements {
203
+ /**
204
+ * Schema-driven form. Renders Cobalt input components from an inline
205
+ * Prolibu/Mongoose-style JSON schema and emits the validated payload on submit.
206
+ * Validation: bundled AJV (via `createInlineValidator` in form-core) handles
207
+ * required, format, min/max, minLength/maxLength, enum, regex out of the box.
208
+ * Hosts wanting full Prolibu FormSchemaWeb behavior can assign a pre-built
209
+ * `FormSchemaLike` to the `schemaInstance` element property.
210
+ * Ref fields: assign a `refResolver` function to the element to enable
211
+ * search + pagination + label hydration against your backend. See
212
+ * {@link RefResolver}.
213
+ */
214
+ "co-form": LocalJSX.IntrinsicElements["co-form"] & JSXBase.HTMLAttributes<HTMLCoFormElement>;
215
+ }
216
+ }
217
+ }
@@ -0,0 +1 @@
1
+ export { CoForm } from './components/co-form/co-form';
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Ambient JSX declarations for Cobalt custom elements consumed inside this
3
+ * Stencil project. These are minimal — they let TypeScript accept the tags
4
+ * without bringing in `@prolibu-suite/cobalt-core`'s build-time types (which would
5
+ * create a circular build dependency in some configurations).
6
+ *
7
+ * The runtime contract is the public API of `@prolibu-suite/cobalt-core` v0.x.
8
+ */
9
+
10
+ import { JSX as StencilJSX } from './stencil-public-runtime';
11
+
12
+ type CommonFieldAttrs = {
13
+ label?: string;
14
+ placeholder?: string;
15
+ value?: string | number | boolean | null;
16
+ disabled?: boolean;
17
+ readonly?: boolean;
18
+ required?: boolean;
19
+ status?: 'default' | 'error' | 'success' | 'warning' | 'info';
20
+ helperText?: string;
21
+ 'onCoChange'?: (e: CustomEvent<any>) => void;
22
+ 'onCoInput'?: (e: CustomEvent<any>) => void;
23
+ 'onCoClear'?: (e: CustomEvent<any>) => void;
24
+ key?: string | number;
25
+ class?: string;
26
+ style?: { [key: string]: string | number };
27
+ };
28
+
29
+ declare module '@stencil/core' {
30
+ export namespace JSX {
31
+ interface IntrinsicElements {
32
+ 'co-input': CommonFieldAttrs & { type?: string; multiline?: boolean };
33
+ 'co-number-field': CommonFieldAttrs & { min?: number; max?: number; step?: number };
34
+ 'co-select': CommonFieldAttrs & { options?: string; multiple?: boolean };
35
+ 'co-ref-field': CommonFieldAttrs & {
36
+ model?: string;
37
+ multiple?: boolean;
38
+ options?: string;
39
+ selectedDisplay?: string;
40
+ loading?: boolean;
41
+ total?: number;
42
+ clearable?: boolean;
43
+ 'onCoSearch'?: (e: CustomEvent<string>) => void;
44
+ 'onCoLoadMore'?: (e: CustomEvent<void>) => void;
45
+ 'onCoRemove'?: (e: CustomEvent<string>) => void;
46
+ 'onCoOpen'?: (e: CustomEvent<void>) => void;
47
+ };
48
+ 'co-switch': CommonFieldAttrs & { checked?: boolean };
49
+ 'co-button': {
50
+ label?: string;
51
+ variant?: string;
52
+ type?: 'button' | 'submit' | 'reset';
53
+ disabled?: boolean;
54
+ onClick?: (e: MouseEvent) => void;
55
+ key?: string | number;
56
+ class?: string;
57
+ };
58
+ }
59
+ }
60
+ }