@mosaicoo/form-angular 0.3.0 → 0.5.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.
- package/README.md +15 -0
- package/fesm2022/mosaicoo-form-angular-designer.mjs +110 -11
- package/fesm2022/mosaicoo-form-angular-designer.mjs.map +1 -1
- package/fesm2022/mosaicoo-form-angular-material.mjs +393 -0
- package/fesm2022/mosaicoo-form-angular-material.mjs.map +1 -0
- package/fesm2022/mosaicoo-form-angular.mjs +358 -92
- package/fesm2022/mosaicoo-form-angular.mjs.map +1 -1
- package/package.json +17 -3
- package/types/mosaicoo-form-angular-designer.d.ts +8 -1
- package/types/mosaicoo-form-angular-material.d.ts +77 -0
- package/types/mosaicoo-form-angular.d.ts +139 -67
|
@@ -1,70 +1,10 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
2
|
import { Type, InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
3
3
|
import * as _mosaicoo_form_core from '@mosaicoo/form-core';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* `<mform-renderer>` — renders a form at runtime from a `FormSchema` (or any
|
|
8
|
-
* definition a registered importer understands) and manages its lifecycle:
|
|
9
|
-
* values, validation, conditional visibility and submission. Wizard schemas
|
|
10
|
-
* (`settings.display: 'wizard'`) render as steps with per-step validation.
|
|
11
|
-
*
|
|
12
|
-
* Theming: every visual primitive reads a `--mform-*` CSS custom property
|
|
13
|
-
* with a self-contained fallback, so the component looks finished on its own
|
|
14
|
-
* and adopts the host design system when the host overrides the tokens.
|
|
15
|
-
*/
|
|
16
|
-
declare class FormRendererComponent {
|
|
17
|
-
/** Native schema input. Takes precedence over `source`. */
|
|
18
|
-
readonly schema: _angular_core.InputSignal<FormSchema | null>;
|
|
19
|
-
/** Foreign definition (object or JSON string) resolved via importers. */
|
|
20
|
-
readonly source: _angular_core.InputSignal<unknown>;
|
|
21
|
-
/** Initial data merged over schema defaults. */
|
|
22
|
-
readonly initialData: _angular_core.InputSignal<Record<string, unknown> | null>;
|
|
23
|
-
/** Named providers resolving `optionsSource: provider` fields. */
|
|
24
|
-
readonly optionsProviders: _angular_core.InputSignal<OptionsProviderRegistry>;
|
|
25
|
-
/** Host-supplied message resolver (localization of validation messages). */
|
|
26
|
-
readonly messages: _angular_core.InputSignal<MessageResolver | null>;
|
|
27
|
-
/** Fixed renderer texts (override to localize). `{{count}}` in `summary`. */
|
|
28
|
-
readonly labels: _angular_core.InputSignalWithTransform<{
|
|
29
|
-
previous: string;
|
|
30
|
-
next: string;
|
|
31
|
-
submit: string;
|
|
32
|
-
summary: string;
|
|
33
|
-
}, Partial<{
|
|
34
|
-
previous: string;
|
|
35
|
-
next: string;
|
|
36
|
-
submit: string;
|
|
37
|
-
summary: string;
|
|
38
|
-
}>>;
|
|
39
|
-
summaryTitle(): string;
|
|
40
|
-
/** Fired on submit; `ok` is false when validation failed. */
|
|
41
|
-
readonly submitted: _angular_core.OutputEmitterRef<SubmitResult>;
|
|
42
|
-
/** Fired on every value change with the full data snapshot. */
|
|
43
|
-
readonly valueChanged: _angular_core.OutputEmitterRef<Record<string, unknown>>;
|
|
44
|
-
/** Bumped on every engine event; nodes read it to refresh. */
|
|
45
|
-
readonly tick: _angular_core.WritableSignal<number>;
|
|
46
|
-
/** Active wizard step index. */
|
|
47
|
-
readonly currentStep: _angular_core.WritableSignal<number>;
|
|
48
|
-
private readonly resolved;
|
|
49
|
-
/** Import degradations for the current `source`, if any. */
|
|
50
|
-
readonly importWarnings: _angular_core.Signal<ImportWarning[]>;
|
|
51
|
-
readonly engine: _angular_core.Signal<FormEngine | null>;
|
|
52
|
-
readonly isWizard: _angular_core.Signal<boolean>;
|
|
53
|
-
/** Wizard pages: the top-level containers of the schema. */
|
|
54
|
-
readonly steps: _angular_core.Signal<ContainerField[]>;
|
|
55
|
-
readonly errorSummary: _angular_core.WritableSignal<FieldError[]>;
|
|
56
|
-
constructor();
|
|
57
|
-
previousStep(): void;
|
|
58
|
-
nextStep(): void;
|
|
59
|
-
onSubmit(event: Event): void;
|
|
60
|
-
/** Finds the wizard step that owns a (possibly row-indexed) data path. */
|
|
61
|
-
private stepIndexForPath;
|
|
62
|
-
private readonly documentRef;
|
|
63
|
-
private focusFirstError;
|
|
64
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormRendererComponent, never>;
|
|
65
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormRendererComponent, "mform-renderer", never, { "schema": { "alias": "schema"; "required": false; "isSignal": true; }; "source": { "alias": "source"; "required": false; "isSignal": true; }; "initialData": { "alias": "initialData"; "required": false; "isSignal": true; }; "optionsProviders": { "alias": "optionsProviders"; "required": false; "isSignal": true; }; "messages": { "alias": "messages"; "required": false; "isSignal": true; }; "labels": { "alias": "labels"; "required": false; "isSignal": true; }; }, { "submitted": "submitted"; "valueChanged": "valueChanged"; }, never, never, true, never>;
|
|
66
|
-
}
|
|
4
|
+
import { FieldNode, FormEngine, OptionsProviderRegistry, FieldOption, InputField, ContainerField, FormSchema, MessageResolver, ValidatorRegistry, SubmitResult, ImportWarning, FieldError, RemoteOptionsFetcher } from '@mosaicoo/form-core';
|
|
67
5
|
|
|
6
|
+
/** Rendering mode: `readonly` hides actions, `disabled` grays everything. */
|
|
7
|
+
type FormMode = 'edit' | 'readonly' | 'disabled';
|
|
68
8
|
/**
|
|
69
9
|
* Renders one schema node (input, container or static) and recurses into
|
|
70
10
|
* children. State lives in the headless engine — this component only projects
|
|
@@ -82,14 +22,34 @@ declare class FormNodeComponent {
|
|
|
82
22
|
readonly bare: _angular_core.InputSignal<boolean>;
|
|
83
23
|
/** Host-registered providers for `optionsSource: provider` fields. */
|
|
84
24
|
readonly providers: _angular_core.InputSignal<OptionsProviderRegistry>;
|
|
25
|
+
/** Rendering mode inherited from the renderer. */
|
|
26
|
+
readonly mode: _angular_core.InputSignal<FormMode>;
|
|
27
|
+
/** Renderer-supplied refresh hook for async completions (zoneless-safe). */
|
|
28
|
+
readonly notify: _angular_core.InputSignal<() => void>;
|
|
85
29
|
readonly activeTab: _angular_core.WritableSignal<number>;
|
|
86
30
|
/** DI-registered custom field components (maps merge; later wins). */
|
|
87
31
|
private readonly componentMaps;
|
|
88
32
|
/** Host transport for remote options; plain fetch when absent. */
|
|
89
33
|
private readonly remoteFetcher;
|
|
34
|
+
/** Host-owned upload for `file` fields. */
|
|
35
|
+
private readonly uploader;
|
|
36
|
+
/**
|
|
37
|
+
* Async resolutions (debounce timers, provider promises) finish outside
|
|
38
|
+
* any template event — explicitly schedule the refresh for zoneless apps.
|
|
39
|
+
*/
|
|
40
|
+
private readonly changeDetector;
|
|
41
|
+
readonly uploading: _angular_core.WritableSignal<boolean>;
|
|
42
|
+
/** Effective disabled state: mode, schema flag or calculated field. */
|
|
43
|
+
controlDisabled(): boolean;
|
|
44
|
+
interactive(): boolean;
|
|
45
|
+
pending(): boolean;
|
|
90
46
|
/** Custom component registered for this field type, if any. */
|
|
91
47
|
customComponent(): Type<unknown> | null;
|
|
92
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Inputs handed to a custom component (MformFieldComponent contract).
|
|
50
|
+
* Only inputs the component actually declares are passed, so optional
|
|
51
|
+
* contract members (`mode`) never break third-party components.
|
|
52
|
+
*/
|
|
93
53
|
customInputs(): Record<string, unknown>;
|
|
94
54
|
/** Options resolved from a dynamic source (provider or remote URL). */
|
|
95
55
|
private readonly resolvedOptions;
|
|
@@ -130,16 +90,106 @@ declare class FormNodeComponent {
|
|
|
130
90
|
setChecked(event: Event): void;
|
|
131
91
|
toggleMap(option: string, event: Event): void;
|
|
132
92
|
setFiles(event: Event): void;
|
|
93
|
+
/** Names shown under a `file` control (refs or plain names). */
|
|
94
|
+
fileNames(): string[];
|
|
133
95
|
prefix(): string | null;
|
|
134
96
|
suffix(): string | null;
|
|
135
97
|
tagValues(): string[];
|
|
136
98
|
addTag(event: Event): void;
|
|
137
99
|
removeTag(index: number): void;
|
|
138
100
|
touch(): void;
|
|
101
|
+
readonly refOptions: _angular_core.WritableSignal<FieldOption[]>;
|
|
102
|
+
readonly refOpen: _angular_core.WritableSignal<boolean>;
|
|
103
|
+
private refTimer;
|
|
104
|
+
/** Label of the chosen option (falls back to the raw value). */
|
|
105
|
+
readonly refLabel: _angular_core.WritableSignal<string | null>;
|
|
106
|
+
refDisplay(): string;
|
|
107
|
+
refSearch(event: Event): void;
|
|
108
|
+
private refResolve;
|
|
109
|
+
refPick(option: FieldOption): void;
|
|
110
|
+
refBlur(): void;
|
|
139
111
|
addRow(): void;
|
|
140
112
|
removeRow(index: number): void;
|
|
141
113
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormNodeComponent, never>;
|
|
142
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormNodeComponent, "mform-node", never, { "node": { "alias": "node"; "required": true; "isSignal": true; }; "engine": { "alias": "engine"; "required": true; "isSignal": true; }; "tick": { "alias": "tick"; "required": true; "isSignal": true; }; "scope": { "alias": "scope"; "required": false; "isSignal": true; }; "bare": { "alias": "bare"; "required": false; "isSignal": true; }; "providers": { "alias": "providers"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
114
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormNodeComponent, "mform-node", never, { "node": { "alias": "node"; "required": true; "isSignal": true; }; "engine": { "alias": "engine"; "required": true; "isSignal": true; }; "tick": { "alias": "tick"; "required": true; "isSignal": true; }; "scope": { "alias": "scope"; "required": false; "isSignal": true; }; "bare": { "alias": "bare"; "required": false; "isSignal": true; }; "providers": { "alias": "providers"; "required": false; "isSignal": true; }; "mode": { "alias": "mode"; "required": false; "isSignal": true; }; "notify": { "alias": "notify"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* `<mform-renderer>` — renders a form at runtime from a `FormSchema` (or any
|
|
119
|
+
* definition a registered importer understands) and manages its lifecycle:
|
|
120
|
+
* values, validation, conditional visibility and submission. Wizard schemas
|
|
121
|
+
* (`settings.display: 'wizard'`) render as steps with per-step validation.
|
|
122
|
+
*
|
|
123
|
+
* Theming: every visual primitive reads a `--mform-*` CSS custom property
|
|
124
|
+
* with a self-contained fallback, so the component looks finished on its own
|
|
125
|
+
* and adopts the host design system when the host overrides the tokens.
|
|
126
|
+
*/
|
|
127
|
+
declare class FormRendererComponent {
|
|
128
|
+
/** Native schema input. Takes precedence over `source`. */
|
|
129
|
+
readonly schema: _angular_core.InputSignal<FormSchema | null>;
|
|
130
|
+
/** Foreign definition (object or JSON string) resolved via importers. */
|
|
131
|
+
readonly source: _angular_core.InputSignal<unknown>;
|
|
132
|
+
/** Initial data merged over schema defaults. */
|
|
133
|
+
readonly initialData: _angular_core.InputSignal<Record<string, unknown> | null>;
|
|
134
|
+
/** Named providers resolving `optionsSource: provider` fields. */
|
|
135
|
+
readonly optionsProviders: _angular_core.InputSignal<OptionsProviderRegistry>;
|
|
136
|
+
/** Host-supplied message resolver (localization of validation messages). */
|
|
137
|
+
readonly messages: _angular_core.InputSignal<MessageResolver | null>;
|
|
138
|
+
/** Named custom validators (sync or async — Promises get pending states). */
|
|
139
|
+
readonly validators: _angular_core.InputSignal<ValidatorRegistry | null>;
|
|
140
|
+
/** `edit` (default), `readonly` (no actions) or `disabled`. */
|
|
141
|
+
readonly mode: _angular_core.InputSignal<FormMode>;
|
|
142
|
+
/**
|
|
143
|
+
* Optional host submission: called after a VALID submit with the result;
|
|
144
|
+
* rejections surface as the submission error state. Persistence transport
|
|
145
|
+
* stays entirely on the host side.
|
|
146
|
+
*/
|
|
147
|
+
readonly submitHandler: _angular_core.InputSignal<((result: SubmitResult) => Promise<void>) | null>;
|
|
148
|
+
/** True while async validation or the submit handler is running. */
|
|
149
|
+
readonly submitting: _angular_core.WritableSignal<boolean>;
|
|
150
|
+
/** Message when the host submission rejected. */
|
|
151
|
+
readonly submitError: _angular_core.WritableSignal<string | null>;
|
|
152
|
+
/** Fixed renderer texts (override to localize). `{{count}}` in `summary`. */
|
|
153
|
+
readonly labels: _angular_core.InputSignalWithTransform<{
|
|
154
|
+
previous: string;
|
|
155
|
+
next: string;
|
|
156
|
+
submit: string;
|
|
157
|
+
summary: string;
|
|
158
|
+
}, Partial<{
|
|
159
|
+
previous: string;
|
|
160
|
+
next: string;
|
|
161
|
+
submit: string;
|
|
162
|
+
summary: string;
|
|
163
|
+
}>>;
|
|
164
|
+
summaryTitle(): string;
|
|
165
|
+
/** Fired on submit; `ok` is false when validation failed. */
|
|
166
|
+
readonly submitted: _angular_core.OutputEmitterRef<SubmitResult>;
|
|
167
|
+
/** Fired on every value change with the full data snapshot. */
|
|
168
|
+
readonly valueChanged: _angular_core.OutputEmitterRef<Record<string, unknown>>;
|
|
169
|
+
/** Bumped on every engine event; nodes read it to refresh. */
|
|
170
|
+
readonly tick: _angular_core.WritableSignal<number>;
|
|
171
|
+
/** Handed to nodes so async completions re-render (zoneless-safe). */
|
|
172
|
+
readonly bumpTick: () => void;
|
|
173
|
+
/** Active wizard step index. */
|
|
174
|
+
readonly currentStep: _angular_core.WritableSignal<number>;
|
|
175
|
+
private readonly resolved;
|
|
176
|
+
/** Import degradations for the current `source`, if any. */
|
|
177
|
+
readonly importWarnings: _angular_core.Signal<ImportWarning[]>;
|
|
178
|
+
readonly engine: _angular_core.Signal<FormEngine | null>;
|
|
179
|
+
readonly isWizard: _angular_core.Signal<boolean>;
|
|
180
|
+
/** Wizard pages: the top-level containers of the schema. */
|
|
181
|
+
readonly steps: _angular_core.Signal<ContainerField[]>;
|
|
182
|
+
readonly errorSummary: _angular_core.WritableSignal<FieldError[]>;
|
|
183
|
+
constructor();
|
|
184
|
+
previousStep(): void;
|
|
185
|
+
nextStep(): void;
|
|
186
|
+
onSubmit(event: Event): Promise<void>;
|
|
187
|
+
/** Finds the wizard step that owns a (possibly row-indexed) data path. */
|
|
188
|
+
private stepIndexForPath;
|
|
189
|
+
private readonly documentRef;
|
|
190
|
+
private focusFirstError;
|
|
191
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormRendererComponent, never>;
|
|
192
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormRendererComponent, "mform-renderer", never, { "schema": { "alias": "schema"; "required": false; "isSignal": true; }; "source": { "alias": "source"; "required": false; "isSignal": true; }; "initialData": { "alias": "initialData"; "required": false; "isSignal": true; }; "optionsProviders": { "alias": "optionsProviders"; "required": false; "isSignal": true; }; "messages": { "alias": "messages"; "required": false; "isSignal": true; }; "validators": { "alias": "validators"; "required": false; "isSignal": true; }; "mode": { "alias": "mode"; "required": false; "isSignal": true; }; "submitHandler": { "alias": "submitHandler"; "required": false; "isSignal": true; }; "labels": { "alias": "labels"; "required": false; "isSignal": true; }; }, { "submitted": "submitted"; "valueChanged": "valueChanged"; }, never, never, true, never>;
|
|
143
193
|
}
|
|
144
194
|
|
|
145
195
|
/**
|
|
@@ -165,6 +215,8 @@ interface MformFieldComponent {
|
|
|
165
215
|
path: () => string;
|
|
166
216
|
/** Bumped on every engine event; read it to stay in sync. */
|
|
167
217
|
tick: () => number;
|
|
218
|
+
/** Rendering mode of the surrounding form (optional input). */
|
|
219
|
+
mode?: () => 'edit' | 'readonly' | 'disabled';
|
|
168
220
|
}
|
|
169
221
|
/** Map of field `type` → component implementing {@link MformFieldComponent}. */
|
|
170
222
|
type FieldComponentMap = Record<string, Type<unknown>>;
|
|
@@ -176,11 +228,31 @@ declare const MFORM_FIELD_COMPONENTS: InjectionToken<FieldComponentMap[]>;
|
|
|
176
228
|
* base URLs, caching). Without it, a plain `fetch` is used.
|
|
177
229
|
*/
|
|
178
230
|
declare const MFORM_REMOTE_FETCHER: InjectionToken<RemoteOptionsFetcher>;
|
|
231
|
+
/** Reference the host returns after uploading one file. */
|
|
232
|
+
interface UploadedFileRef {
|
|
233
|
+
name: string;
|
|
234
|
+
id?: string;
|
|
235
|
+
url?: string;
|
|
236
|
+
size?: number;
|
|
237
|
+
[extra: string]: unknown;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Host-owned file upload: receives each selected file, delivers it wherever
|
|
241
|
+
* the host decides (API, bucket, queue) and returns the reference stored in
|
|
242
|
+
* the form data. Without it, `file` fields keep only file names.
|
|
243
|
+
*/
|
|
244
|
+
type FileUploadFn = (file: File, context: {
|
|
245
|
+
field: InputField;
|
|
246
|
+
path: string;
|
|
247
|
+
}) => Promise<UploadedFileRef>;
|
|
248
|
+
declare const MFORM_UPLOAD: InjectionToken<FileUploadFn>;
|
|
179
249
|
interface MosaicooFormConfig {
|
|
180
250
|
/** Custom/override field components, keyed by field `type`. */
|
|
181
251
|
components?: FieldComponentMap;
|
|
182
252
|
/** Host transport for remote options sources. */
|
|
183
253
|
remoteFetcher?: RemoteOptionsFetcher;
|
|
254
|
+
/** Host-owned file upload for `file` fields. */
|
|
255
|
+
uploadFiles?: FileUploadFn;
|
|
184
256
|
}
|
|
185
257
|
/**
|
|
186
258
|
* Registers renderer extensions at any injector level:
|
|
@@ -198,5 +270,5 @@ interface MosaicooFormConfig {
|
|
|
198
270
|
*/
|
|
199
271
|
declare function provideMosaicooForm(config: MosaicooFormConfig): EnvironmentProviders;
|
|
200
272
|
|
|
201
|
-
export { FormNodeComponent, FormRendererComponent, MFORM_FIELD_COMPONENTS, MFORM_REMOTE_FETCHER, provideMosaicooForm };
|
|
202
|
-
export type { FieldComponentMap, MformFieldComponent, MosaicooFormConfig };
|
|
273
|
+
export { FormNodeComponent, FormRendererComponent, MFORM_FIELD_COMPONENTS, MFORM_REMOTE_FETCHER, MFORM_UPLOAD, provideMosaicooForm };
|
|
274
|
+
export type { FieldComponentMap, FileUploadFn, FormMode, MformFieldComponent, MosaicooFormConfig, UploadedFileRef };
|