@muziehdesign/forms 19.2.979 → 20.0.0-beta.1007
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/fesm2022/muziehdesign-forms.mjs +220 -78
- package/fesm2022/muziehdesign-forms.mjs.map +1 -1
- package/index.d.ts +802 -3
- package/package.json +4 -4
- package/lib/checkbox-group/checkbox-group.component.d.ts +0 -21
- package/lib/constants.d.ts +0 -1
- package/lib/date-value-accessor.directive.d.ts +0 -19
- package/lib/field/field.component.d.ts +0 -18
- package/lib/field-error.d.ts +0 -5
- package/lib/field-errors/field-errors.component.d.ts +0 -8
- package/lib/field-schema.d.ts +0 -88
- package/lib/form/form.directive.d.ts +0 -14
- package/lib/forms.module.d.ts +0 -20
- package/lib/masks.d.ts +0 -22
- package/lib/model-schema.d.ts +0 -21
- package/lib/model-schema.factory.d.ts +0 -20
- package/lib/model-state-options.d.ts +0 -4
- package/lib/model-state-result.d.ts +0 -6
- package/lib/ng-form-model-state.service.d.ts +0 -12
- package/lib/ngform-model-state.d.ts +0 -25
- package/lib/type-annotations.d.ts +0 -131
- package/public-api.d.ts +0 -15
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Input, Component, forwardRef, Directive, Optional, SkipSelf, ContentChild, HostListener, NgModule } from '@angular/core';
|
|
2
|
+
import { Injectable, LOCALE_ID, Inject, Input, Component, forwardRef, Directive, Optional, SkipSelf, ContentChild, HostListener, NgModule } from '@angular/core';
|
|
3
3
|
import * as Yup from 'yup';
|
|
4
4
|
import { object } from 'yup';
|
|
5
5
|
import 'reflect-metadata';
|
|
6
|
-
import * as i1
|
|
6
|
+
import * as i1 from '@angular/forms';
|
|
7
7
|
import { FormGroup, FormArray, NG_VALUE_ACCESSOR, FormsModule as FormsModule$1, NgModel, NgModelGroup, NgForm, ControlContainer } from '@angular/forms';
|
|
8
8
|
import { BehaviorSubject, switchMap, from } from 'rxjs';
|
|
9
|
-
import * as i1 from '@angular/common';
|
|
10
9
|
import { CommonModule } from '@angular/common';
|
|
11
10
|
|
|
12
11
|
class ModelSchema {
|
|
13
12
|
// TODO: need to keep track of internal and external
|
|
14
13
|
//private definitions?: {[K in keyof T]: FieldSchema<any>};
|
|
15
|
-
constructor(metadata, schema) {
|
|
14
|
+
constructor(metadata, schema, name) {
|
|
16
15
|
this.metadata = metadata;
|
|
17
16
|
this.schema = schema;
|
|
17
|
+
this.name = name;
|
|
18
18
|
}
|
|
19
19
|
getMetadata(paths) {
|
|
20
20
|
//console.log('fetching metadata for path: ', paths);
|
|
@@ -110,9 +110,9 @@ class ModelSchemaFactory {
|
|
|
110
110
|
constructor() { }
|
|
111
111
|
build(model) {
|
|
112
112
|
const metadata = Reflect.getMetadata(SCHEMA_METADATA_NAMESPACE, model);
|
|
113
|
-
const schemaData = [...metadata.values()];
|
|
113
|
+
const schemaData = [...metadata.schemas.values()];
|
|
114
114
|
const schema = this.buildYupSchema(schemaData);
|
|
115
|
-
return new ModelSchema(schemaData, schema);
|
|
115
|
+
return new ModelSchema(schemaData, schema, metadata.name);
|
|
116
116
|
}
|
|
117
117
|
buildUntyped(raw) {
|
|
118
118
|
const schema = this.buildYupSchema(raw);
|
|
@@ -195,6 +195,12 @@ class ModelSchemaFactory {
|
|
|
195
195
|
if (original.label) {
|
|
196
196
|
schema.label(original.label);
|
|
197
197
|
}
|
|
198
|
+
schema = schema.transform(function (value, originalValue) {
|
|
199
|
+
if (originalValue === '') {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
return value;
|
|
203
|
+
});
|
|
198
204
|
const options = original.constraints;
|
|
199
205
|
if (options.required) {
|
|
200
206
|
schema = schema.required(options.required.message);
|
|
@@ -206,12 +212,17 @@ class ModelSchemaFactory {
|
|
|
206
212
|
schema = schema.max(options.max.max, options.max.message);
|
|
207
213
|
}
|
|
208
214
|
if (options.test) {
|
|
209
|
-
schema = schema.test({
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
schema = schema.test(options.test.name, function (v, context) {
|
|
216
|
+
if (v && options.test?.test(v) !== true) {
|
|
217
|
+
return context.createError({
|
|
218
|
+
message: options.test?.message,
|
|
219
|
+
path: context.path,
|
|
220
|
+
params: {
|
|
221
|
+
key: options.test?.name
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return true;
|
|
215
226
|
});
|
|
216
227
|
}
|
|
217
228
|
return schema;
|
|
@@ -249,7 +260,7 @@ class ModelSchemaFactory {
|
|
|
249
260
|
}
|
|
250
261
|
buildNestedObjectSchema(original) {
|
|
251
262
|
const metadata = Reflect.getMetadata(SCHEMA_METADATA_NAMESPACE, original.constraints.getInstance());
|
|
252
|
-
let nestedSchema = this.buildYupSchema([...metadata.values()]);
|
|
263
|
+
let nestedSchema = this.buildYupSchema([...metadata.schemas.values()]);
|
|
253
264
|
if (original.label) {
|
|
254
265
|
nestedSchema.label(original.label);
|
|
255
266
|
}
|
|
@@ -273,10 +284,10 @@ class ModelSchemaFactory {
|
|
|
273
284
|
}
|
|
274
285
|
return schema;
|
|
275
286
|
}
|
|
276
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
277
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
287
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ModelSchemaFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
288
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ModelSchemaFactory, providedIn: 'root' }); }
|
|
278
289
|
}
|
|
279
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
290
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: ModelSchemaFactory, decorators: [{
|
|
280
291
|
type: Injectable,
|
|
281
292
|
args: [{
|
|
282
293
|
providedIn: 'root',
|
|
@@ -284,9 +295,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
284
295
|
}], ctorParameters: () => [] });
|
|
285
296
|
|
|
286
297
|
const METADATA_KEY = 'custom:muziehdesign:annotations';
|
|
287
|
-
const
|
|
288
|
-
const metadata = Reflect.getMetadata(METADATA_KEY, target) || new Map();
|
|
289
|
-
metadata.set(propertyKey, schema);
|
|
298
|
+
const registerPropertyMetadata = (target, propertyKey, schema) => {
|
|
299
|
+
const metadata = Reflect.getMetadata(METADATA_KEY, target) || { schemas: new Map() };
|
|
300
|
+
metadata.schemas.set(propertyKey, schema);
|
|
301
|
+
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
302
|
+
};
|
|
303
|
+
const registerMetadata = (target, name) => {
|
|
304
|
+
const metadata = Reflect.getMetadata(METADATA_KEY, target) || { schemas: new Map() };
|
|
305
|
+
metadata.name = name;
|
|
290
306
|
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
291
307
|
};
|
|
292
308
|
function StringType(...annotations) {
|
|
@@ -294,9 +310,9 @@ function StringType(...annotations) {
|
|
|
294
310
|
const schema = {
|
|
295
311
|
name: propertyKey,
|
|
296
312
|
type: FieldSchemaType.string,
|
|
297
|
-
constraints: Object.assign({}, ...annotations)
|
|
313
|
+
constraints: Object.assign({}, ...annotations),
|
|
298
314
|
};
|
|
299
|
-
|
|
315
|
+
registerPropertyMetadata(target, propertyKey, schema);
|
|
300
316
|
};
|
|
301
317
|
}
|
|
302
318
|
function BooleanType(...annotations) {
|
|
@@ -304,9 +320,9 @@ function BooleanType(...annotations) {
|
|
|
304
320
|
const schema = {
|
|
305
321
|
name: propertyKey,
|
|
306
322
|
type: FieldSchemaType.boolean,
|
|
307
|
-
constraints: Object.assign({}, ...annotations)
|
|
323
|
+
constraints: Object.assign({}, ...annotations),
|
|
308
324
|
};
|
|
309
|
-
|
|
325
|
+
registerPropertyMetadata(target, propertyKey, schema);
|
|
310
326
|
};
|
|
311
327
|
}
|
|
312
328
|
function DateType(...annotations) {
|
|
@@ -314,9 +330,9 @@ function DateType(...annotations) {
|
|
|
314
330
|
const schema = {
|
|
315
331
|
name: propertyKey,
|
|
316
332
|
type: FieldSchemaType.date,
|
|
317
|
-
constraints: Object.assign({}, ...annotations)
|
|
333
|
+
constraints: Object.assign({}, ...annotations),
|
|
318
334
|
};
|
|
319
|
-
|
|
335
|
+
registerPropertyMetadata(target, propertyKey, schema);
|
|
320
336
|
};
|
|
321
337
|
}
|
|
322
338
|
function NumberType(...annotations) {
|
|
@@ -324,9 +340,9 @@ function NumberType(...annotations) {
|
|
|
324
340
|
const schema = {
|
|
325
341
|
name: propertyKey,
|
|
326
342
|
type: FieldSchemaType.number,
|
|
327
|
-
constraints: Object.assign({}, ...annotations)
|
|
343
|
+
constraints: Object.assign({}, ...annotations),
|
|
328
344
|
};
|
|
329
|
-
|
|
345
|
+
registerPropertyMetadata(target, propertyKey, schema);
|
|
330
346
|
};
|
|
331
347
|
}
|
|
332
348
|
function ObjectType(type, ...annotations) {
|
|
@@ -334,9 +350,9 @@ function ObjectType(type, ...annotations) {
|
|
|
334
350
|
const schema = {
|
|
335
351
|
name: propertyKey,
|
|
336
352
|
type: FieldSchemaType.object,
|
|
337
|
-
constraints: Object.assign({}, ...annotations, { getInstance: () => new type() })
|
|
353
|
+
constraints: Object.assign({}, ...annotations, { getInstance: () => new type() }),
|
|
338
354
|
};
|
|
339
|
-
|
|
355
|
+
registerPropertyMetadata(target, propertyKey, schema);
|
|
340
356
|
};
|
|
341
357
|
}
|
|
342
358
|
function ArrayType(...annotations) {
|
|
@@ -344,9 +360,9 @@ function ArrayType(...annotations) {
|
|
|
344
360
|
const schema = {
|
|
345
361
|
name: propertyKey,
|
|
346
362
|
type: FieldSchemaType.array,
|
|
347
|
-
constraints: Object.assign({}, ...annotations)
|
|
363
|
+
constraints: Object.assign({}, ...annotations),
|
|
348
364
|
};
|
|
349
|
-
|
|
365
|
+
registerPropertyMetadata(target, propertyKey, schema);
|
|
350
366
|
};
|
|
351
367
|
}
|
|
352
368
|
function FileType(...annotations) {
|
|
@@ -354,9 +370,17 @@ function FileType(...annotations) {
|
|
|
354
370
|
const schema = {
|
|
355
371
|
name: propertyKey,
|
|
356
372
|
type: FieldSchemaType.file,
|
|
357
|
-
constraints: Object.assign({}, ...annotations)
|
|
373
|
+
constraints: Object.assign({}, ...annotations),
|
|
358
374
|
};
|
|
359
|
-
|
|
375
|
+
registerPropertyMetadata(target, propertyKey, schema);
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function Model(name) {
|
|
379
|
+
return function (constructor) {
|
|
380
|
+
// Class decorators receive the constructor, but property decorators write to constructor.prototype
|
|
381
|
+
// So we need to write to constructor.prototype to share the same metadata object
|
|
382
|
+
registerMetadata(constructor.prototype, name);
|
|
383
|
+
return constructor;
|
|
360
384
|
};
|
|
361
385
|
}
|
|
362
386
|
function required(message) {
|
|
@@ -436,9 +460,11 @@ class NgFormModelState {
|
|
|
436
460
|
grouped.forEach((value, path) => {
|
|
437
461
|
let validationErrors = {};
|
|
438
462
|
value.forEach((v) => (validationErrors[v.type] = v.message));
|
|
463
|
+
//console.log('setting errors for path:', path, validationErrors);
|
|
439
464
|
const control = this.form.form.get(path);
|
|
440
465
|
if (!control) {
|
|
441
466
|
// TODO: use actual logging service
|
|
467
|
+
console.log('control not found for path:', path);
|
|
442
468
|
}
|
|
443
469
|
else {
|
|
444
470
|
control.setErrors(validationErrors);
|
|
@@ -501,27 +527,81 @@ class NgFormModelStateFactory {
|
|
|
501
527
|
const modelState = new NgFormModelState(form, this.factory.build(model), options);
|
|
502
528
|
return modelState;
|
|
503
529
|
}
|
|
504
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
505
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
530
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: NgFormModelStateFactory, deps: [{ token: ModelSchemaFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
531
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: NgFormModelStateFactory, providedIn: 'root' }); }
|
|
506
532
|
}
|
|
507
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
533
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: NgFormModelStateFactory, decorators: [{
|
|
508
534
|
type: Injectable,
|
|
509
535
|
args: [{
|
|
510
536
|
providedIn: 'root',
|
|
511
537
|
}]
|
|
512
538
|
}], ctorParameters: () => [{ type: ModelSchemaFactory }] });
|
|
513
539
|
|
|
540
|
+
class FormMessageService {
|
|
541
|
+
constructor(localeId) {
|
|
542
|
+
this.localeId = localeId;
|
|
543
|
+
this.localeData = {};
|
|
544
|
+
}
|
|
545
|
+
getMessage(messageProps, namespace) {
|
|
546
|
+
if (typeof messageProps === 'string') {
|
|
547
|
+
return messageProps;
|
|
548
|
+
}
|
|
549
|
+
try {
|
|
550
|
+
const parts = messageProps.key.split('.');
|
|
551
|
+
// get namespaced message
|
|
552
|
+
if (namespace && namespace.length > 0 && messageProps.path && messageProps.path.length > 0) {
|
|
553
|
+
const namespaced = this.getLocaleData([namespace, messageProps.path, ...parts]);
|
|
554
|
+
if (namespaced !== undefined) {
|
|
555
|
+
return namespaced;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
// get global message
|
|
559
|
+
const message = this.getLocaleData(parts);
|
|
560
|
+
if (!message) {
|
|
561
|
+
return messageProps.key;
|
|
562
|
+
}
|
|
563
|
+
return message;
|
|
564
|
+
}
|
|
565
|
+
catch {
|
|
566
|
+
return messageProps.key;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
registerFormMessages(data, localeId) {
|
|
570
|
+
this.localeData[localeId] = data;
|
|
571
|
+
}
|
|
572
|
+
getLocaleData(keyParts) {
|
|
573
|
+
const messages = this.localeData[this.localeId] || this.localeData['en'];
|
|
574
|
+
return keyParts.reduce((obj, part) => {
|
|
575
|
+
if (obj?.[part] === undefined) {
|
|
576
|
+
return undefined;
|
|
577
|
+
}
|
|
578
|
+
return obj[part];
|
|
579
|
+
}, messages);
|
|
580
|
+
}
|
|
581
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: FormMessageService, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
582
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: FormMessageService, providedIn: 'root' }); }
|
|
583
|
+
}
|
|
584
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: FormMessageService, decorators: [{
|
|
585
|
+
type: Injectable,
|
|
586
|
+
args: [{
|
|
587
|
+
providedIn: 'root',
|
|
588
|
+
}]
|
|
589
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
590
|
+
type: Inject,
|
|
591
|
+
args: [LOCALE_ID]
|
|
592
|
+
}] }] });
|
|
593
|
+
|
|
514
594
|
class FieldErrorsComponent {
|
|
515
595
|
get errorMessage() {
|
|
516
596
|
const errorKeys = Object.keys(this.field?.errors || {});
|
|
517
597
|
return errorKeys.length > 0 ? (this.field?.errors)[errorKeys[0]] : '';
|
|
518
598
|
}
|
|
519
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
520
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
599
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: FieldErrorsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
600
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.4", type: FieldErrorsComponent, isStandalone: false, selector: "mz-field-errors", inputs: { field: "field" }, ngImport: i0, template: "@if (errorMessage) {\n <div class=\"field-error\">{{ errorMessage }}</div>\n test test\n}\n", styles: [""] }); }
|
|
521
601
|
}
|
|
522
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
602
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: FieldErrorsComponent, decorators: [{
|
|
523
603
|
type: Component,
|
|
524
|
-
args: [{ selector: 'mz-field-errors', standalone: false, template: "<div class=\"field-error\"
|
|
604
|
+
args: [{ selector: 'mz-field-errors', standalone: false, template: "@if (errorMessage) {\n <div class=\"field-error\">{{ errorMessage }}</div>\n test test\n}\n" }]
|
|
525
605
|
}], propDecorators: { field: [{
|
|
526
606
|
type: Input
|
|
527
607
|
}] } });
|
|
@@ -618,8 +698,8 @@ class DateValueAccessor {
|
|
|
618
698
|
newDate.setHours(0, 0, 0);
|
|
619
699
|
return newDate;
|
|
620
700
|
}
|
|
621
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
622
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
701
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: DateValueAccessor, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
702
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.4", type: DateValueAccessor, isStandalone: true, selector: "[mzDateInput]", host: { listeners: { "input": "onChange($event.target.value)", "blur": "onTouched()" } }, providers: [
|
|
623
703
|
{
|
|
624
704
|
provide: NG_VALUE_ACCESSOR,
|
|
625
705
|
useExisting: forwardRef(() => DateValueAccessor),
|
|
@@ -627,7 +707,7 @@ class DateValueAccessor {
|
|
|
627
707
|
},
|
|
628
708
|
], ngImport: i0 }); }
|
|
629
709
|
}
|
|
630
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
710
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: DateValueAccessor, decorators: [{
|
|
631
711
|
type: Directive,
|
|
632
712
|
args: [{
|
|
633
713
|
selector: '[mzDateInput]',
|
|
@@ -681,8 +761,8 @@ class MzCheckboxGroup {
|
|
|
681
761
|
this.onChange(this.selections);
|
|
682
762
|
this.onTouched();
|
|
683
763
|
}
|
|
684
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
685
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
764
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: MzCheckboxGroup, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
765
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.4", type: MzCheckboxGroup, isStandalone: true, selector: "mz-checkbox-group", inputs: { options: "options", disabled: "disabled" }, providers: [
|
|
686
766
|
{
|
|
687
767
|
provide: NG_VALUE_ACCESSOR,
|
|
688
768
|
useExisting: forwardRef(() => MzCheckboxGroup),
|
|
@@ -690,7 +770,7 @@ class MzCheckboxGroup {
|
|
|
690
770
|
},
|
|
691
771
|
], ngImport: i0, template: "@for(option of options; track $index) {\n <label class=\"field-option\">\n <input type=\"checkbox\" class=\"form-checkbox\" [disabled]=\"disabled\" [value]=\"option.value\" [checked]=\"isChecked(option)\" (change)=\"onCheckboxChange($event, option)\" />\n <span class=\"checkbox-label\">{{option.label}}</span>\n </label>\n}\n", dependencies: [{ kind: "ngmodule", type: FormsModule$1 }] }); }
|
|
692
772
|
}
|
|
693
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
773
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: MzCheckboxGroup, decorators: [{
|
|
694
774
|
type: Component,
|
|
695
775
|
args: [{ selector: 'mz-checkbox-group', imports: [FormsModule$1], providers: [
|
|
696
776
|
{
|
|
@@ -708,50 +788,53 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
708
788
|
}] } });
|
|
709
789
|
|
|
710
790
|
function getControlContainer(group, form) {
|
|
711
|
-
console.log('getControlContainer', group, form);
|
|
712
791
|
return group ?? form;
|
|
713
792
|
}
|
|
714
793
|
class MzField {
|
|
715
|
-
constructor(
|
|
716
|
-
this.
|
|
794
|
+
constructor(message, form) {
|
|
795
|
+
this.message = message;
|
|
796
|
+
this.form = form;
|
|
717
797
|
this.controlType = 'other';
|
|
718
798
|
}
|
|
719
|
-
ngAfterContentInit() {
|
|
720
|
-
//this.fieldMetadata = this.form.schema.getMetadata(this.ngModel?.path || []);
|
|
721
|
-
}
|
|
722
799
|
getErrorMessage() {
|
|
723
800
|
try {
|
|
724
801
|
const list = Object.values(this.ngModel.errors);
|
|
725
|
-
return list[0];
|
|
802
|
+
return this.message.getMessage(list[0], this.form?.schema.name);
|
|
726
803
|
}
|
|
727
804
|
catch {
|
|
728
805
|
return undefined;
|
|
729
806
|
}
|
|
730
807
|
}
|
|
731
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
732
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
808
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: MzField, deps: [{ token: FormMessageService }, { token: MzForm, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
809
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.4", type: MzField, isStandalone: true, selector: "mz-field", inputs: { label: "label", controlType: "controlType" }, providers: [
|
|
733
810
|
{
|
|
734
811
|
provide: ControlContainer,
|
|
735
812
|
useFactory: getControlContainer,
|
|
736
|
-
deps: [
|
|
737
|
-
|
|
738
|
-
|
|
813
|
+
deps: [
|
|
814
|
+
[new Optional(), new SkipSelf(), NgModelGroup],
|
|
815
|
+
[new Optional(), new SkipSelf(), NgForm],
|
|
816
|
+
],
|
|
817
|
+
},
|
|
818
|
+
], queries: [{ propertyName: "ngModel", first: true, predicate: NgModel, descendants: true }], ngImport: i0, template: "<label class=\"field\">\n @if(label && controlType !== 'checkbox') {\n <span class=\"field-label\">\n {{ label }}\n </span>\n }\n <ng-content></ng-content>\n\n @if(controlType === 'checkbox' && label) {\n <span class=\"checkbox-label\">{{ label }}</span>\n }\n @if(ngModel?.touched && ngModel?.invalid) {\n <div class=\"field-error\">\n {{ getErrorMessage() }}\n </div>\n }\n</label>\n" }); }
|
|
739
819
|
}
|
|
740
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
820
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: MzField, decorators: [{
|
|
741
821
|
type: Component,
|
|
742
822
|
args: [{ selector: 'mz-field', imports: [], providers: [
|
|
743
823
|
{
|
|
744
824
|
provide: ControlContainer,
|
|
745
825
|
useFactory: getControlContainer,
|
|
746
|
-
deps: [
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
826
|
+
deps: [
|
|
827
|
+
[new Optional(), new SkipSelf(), NgModelGroup],
|
|
828
|
+
[new Optional(), new SkipSelf(), NgForm],
|
|
829
|
+
],
|
|
830
|
+
},
|
|
831
|
+
], template: "<label class=\"field\">\n @if(label && controlType !== 'checkbox') {\n <span class=\"field-label\">\n {{ label }}\n </span>\n }\n <ng-content></ng-content>\n\n @if(controlType === 'checkbox' && label) {\n <span class=\"checkbox-label\">{{ label }}</span>\n }\n @if(ngModel?.touched && ngModel?.invalid) {\n <div class=\"field-error\">\n {{ getErrorMessage() }}\n </div>\n }\n</label>\n" }]
|
|
832
|
+
}], ctorParameters: () => [{ type: FormMessageService }, { type: MzForm, decorators: [{
|
|
833
|
+
type: Optional
|
|
834
|
+
}] }], propDecorators: { label: [{
|
|
750
835
|
type: Input
|
|
751
836
|
}], controlType: [{
|
|
752
837
|
type: Input
|
|
753
|
-
}], schema: [{
|
|
754
|
-
type: Input
|
|
755
838
|
}], ngModel: [{
|
|
756
839
|
type: ContentChild,
|
|
757
840
|
args: [NgModel]
|
|
@@ -771,16 +854,16 @@ class MzForm {
|
|
|
771
854
|
event.stopImmediatePropagation();
|
|
772
855
|
}
|
|
773
856
|
}
|
|
774
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
775
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
857
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: MzForm, deps: [{ token: i1.NgForm }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
858
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.4", type: MzForm, isStandalone: true, selector: "[mzForm]", inputs: { schema: "schema" }, host: { listeners: { "submit": "onSubmit($event)" } }, ngImport: i0 }); }
|
|
776
859
|
}
|
|
777
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
860
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: MzForm, decorators: [{
|
|
778
861
|
type: Directive,
|
|
779
862
|
args: [{
|
|
780
863
|
selector: '[mzForm]',
|
|
781
864
|
standalone: true,
|
|
782
865
|
}]
|
|
783
|
-
}], ctorParameters: () => [{ type: i1
|
|
866
|
+
}], ctorParameters: () => [{ type: i1.NgForm }], propDecorators: { schema: [{
|
|
784
867
|
type: Input,
|
|
785
868
|
args: [{ required: true }]
|
|
786
869
|
}], onSubmit: [{
|
|
@@ -792,13 +875,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
792
875
|
* @deprecated
|
|
793
876
|
*/
|
|
794
877
|
class FormsModule {
|
|
795
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
796
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
878
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: FormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
879
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: FormsModule, declarations: [FieldErrorsComponent], imports: [CommonModule // TODO: can remove once done with temp error displaying
|
|
797
880
|
], exports: [FieldErrorsComponent] }); }
|
|
798
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
881
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: FormsModule, imports: [CommonModule // TODO: can remove once done with temp error displaying
|
|
799
882
|
] }); }
|
|
800
883
|
}
|
|
801
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
884
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: FormsModule, decorators: [{
|
|
802
885
|
type: NgModule,
|
|
803
886
|
args: [{
|
|
804
887
|
providers: [],
|
|
@@ -814,17 +897,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
814
897
|
}]
|
|
815
898
|
}] });
|
|
816
899
|
class MzFormsModule {
|
|
817
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
818
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
900
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: MzFormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
901
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: MzFormsModule, imports: [MzField,
|
|
819
902
|
MzForm,
|
|
820
903
|
DateValueAccessor,
|
|
821
904
|
MzCheckboxGroup], exports: [MzField,
|
|
822
905
|
MzForm,
|
|
823
906
|
DateValueAccessor,
|
|
824
907
|
MzCheckboxGroup] }); }
|
|
825
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
908
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: MzFormsModule, imports: [MzCheckboxGroup] }); }
|
|
826
909
|
}
|
|
827
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
910
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: MzFormsModule, decorators: [{
|
|
828
911
|
type: NgModule,
|
|
829
912
|
args: [{
|
|
830
913
|
providers: [],
|
|
@@ -843,6 +926,65 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
843
926
|
}]
|
|
844
927
|
}] });
|
|
845
928
|
|
|
929
|
+
const YUP_DEFAULT_LOCALES = {
|
|
930
|
+
mixed: {
|
|
931
|
+
required: 'Required',
|
|
932
|
+
notType: 'Invalid value',
|
|
933
|
+
},
|
|
934
|
+
};
|
|
935
|
+
function getMessage(message, key) {
|
|
936
|
+
if (typeof message === 'string') {
|
|
937
|
+
return { key: message };
|
|
938
|
+
}
|
|
939
|
+
return { ...message, key: message.key ?? key };
|
|
940
|
+
}
|
|
941
|
+
const YUP_LOCALE_KEYS = {
|
|
942
|
+
mixed: {
|
|
943
|
+
required: (params) => getMessage(params, 'mixed.required'),
|
|
944
|
+
notType: (params) => getMessage(params, 'mixed.notType'),
|
|
945
|
+
oneOf: (params) => getMessage(params, 'mixed.oneOf'),
|
|
946
|
+
notOneOf: (params) => getMessage(params, 'mixed.notOneOf'),
|
|
947
|
+
default: (params) => getMessage(params, 'mixed.default'),
|
|
948
|
+
defined: (params) => getMessage(params, 'mixed.defined'),
|
|
949
|
+
},
|
|
950
|
+
string: {
|
|
951
|
+
min: (params) => getMessage(params, 'string.min'),
|
|
952
|
+
max: (params) => getMessage(params, 'string.max'),
|
|
953
|
+
length: (params) => getMessage(params, 'string.length'),
|
|
954
|
+
matches: (params) => getMessage(params, 'string.matches'),
|
|
955
|
+
email: (params) => getMessage(params, 'string.email'),
|
|
956
|
+
url: (params) => getMessage(params, 'string.url'),
|
|
957
|
+
uuid: (params) => getMessage(params, 'string.uuid'),
|
|
958
|
+
trim: (params) => getMessage(params, 'string.trim'),
|
|
959
|
+
lowercase: (params) => getMessage(params, 'string.lowercase'),
|
|
960
|
+
uppercase: (params) => getMessage(params, 'string.uppercase'),
|
|
961
|
+
},
|
|
962
|
+
number: {
|
|
963
|
+
min: (params) => getMessage(params, 'number.min'),
|
|
964
|
+
max: (params) => getMessage(params, 'number.max'),
|
|
965
|
+
lessThan: (params) => getMessage(params, 'number.lessThan'),
|
|
966
|
+
moreThan: (params) => getMessage(params, 'number.moreThan'),
|
|
967
|
+
positive: (params) => getMessage(params, 'number.positive'),
|
|
968
|
+
negative: (params) => getMessage(params, 'number.negative'),
|
|
969
|
+
integer: (params) => getMessage(params, 'number.integer'),
|
|
970
|
+
},
|
|
971
|
+
date: {
|
|
972
|
+
min: (params) => getMessage(params, 'date.min'),
|
|
973
|
+
max: (params) => getMessage(params, 'date.max')
|
|
974
|
+
},
|
|
975
|
+
object: {
|
|
976
|
+
noUnknown: (params) => getMessage(params, 'object.noUnknown'),
|
|
977
|
+
},
|
|
978
|
+
array: {
|
|
979
|
+
min: (params) => getMessage(params, 'array.min'),
|
|
980
|
+
max: (params) => getMessage(params, 'array.max'),
|
|
981
|
+
length: (params) => getMessage(params, 'array.length'),
|
|
982
|
+
},
|
|
983
|
+
boolean: {
|
|
984
|
+
isValue: (params) => getMessage(params, 'boolean.isValue'),
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
|
|
846
988
|
/*
|
|
847
989
|
* Public API Surface of forms
|
|
848
990
|
*/
|
|
@@ -851,5 +993,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
851
993
|
* Generated bundle index. Do not edit.
|
|
852
994
|
*/
|
|
853
995
|
|
|
854
|
-
export { ArrayType, BooleanType, DateType, DateValueAccessor, FieldErrorsComponent, FieldSchemaType, FileType, FormsModule, ModelSchema, ModelSchemaFactory, MzCheckboxGroup, MzField, MzForm, MzFormsModule, NgFormModelState, NgFormModelStateFactory, NumberType, ObjectType, StringType, buildArraySchema, buildBooleanSchema, buildDateSchema, buildNumberSchema, buildStringSchema, currencyOptions, equals, integerOptions, length, max, maxLength, min, minLength, ofValues, pattern, phoneNumberOptions, required, ssnOptions, test };
|
|
996
|
+
export { ArrayType, BooleanType, DateType, DateValueAccessor, FieldErrorsComponent, FieldSchemaType, FileType, FormMessageService, FormsModule, Model, ModelSchema, ModelSchemaFactory, MzCheckboxGroup, MzField, MzForm, MzFormsModule, NgFormModelState, NgFormModelStateFactory, NumberType, ObjectType, StringType, YUP_DEFAULT_LOCALES, YUP_LOCALE_KEYS, buildArraySchema, buildBooleanSchema, buildDateSchema, buildNumberSchema, buildStringSchema, currencyOptions, equals, getMessage, integerOptions, length, max, maxLength, min, minLength, ofValues, pattern, phoneNumberOptions, required, ssnOptions, test };
|
|
855
997
|
//# sourceMappingURL=muziehdesign-forms.mjs.map
|