@stemy/ngx-dynamic-form 19.8.10 → 19.8.12
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/stemy-ngx-dynamic-form.mjs +234 -185
- package/fesm2022/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +9 -3
- package/ngx-dynamic-form/components/dynamic-form/dynamic-form.component.d.ts +2 -1
- package/ngx-dynamic-form/services/dynamic-form-builder.service.d.ts +14 -14
- package/ngx-dynamic-form/utils/decorators.d.ts +3 -4
- package/ngx-dynamic-form/utils/internal.d.ts +2 -2
- package/ngx-dynamic-form/utils/misc.d.ts +2 -0
- package/package.json +2 -2
- package/public_api.d.ts +3 -3
|
@@ -48,10 +48,11 @@ function defineFormControl(target, propertyKey, cb) {
|
|
|
48
48
|
ReflectUtils.defineMetadata("dynamicFormField", builder, target, propertyKey);
|
|
49
49
|
ReflectUtils.defineMetadata("dynamicFormFields", fields, target);
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
51
|
+
function defineFormFieldSet(target, data) {
|
|
52
|
+
const fieldSets = ReflectUtils.getMetadata("dynamicFormFieldSets", target) || new Map();
|
|
53
|
+
const existing = fieldSets.get(data.id) || data;
|
|
54
|
+
fieldSets.set(data.id, Object.assign({}, existing, data));
|
|
55
|
+
ReflectUtils.defineMetadata("dynamicFormFieldSets", fieldSets, target);
|
|
55
56
|
}
|
|
56
57
|
function FormInput(data) {
|
|
57
58
|
data = data || {};
|
|
@@ -83,10 +84,6 @@ function FormUpload(data) {
|
|
|
83
84
|
defineFormControl(target, key, (fb, path, options) => fb.createFormUpload(key, data, path, options));
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
|
-
function FormFile(data) {
|
|
87
|
-
console.warn(`@FormFile decorator is deprecated, use @FormUpload instead`);
|
|
88
|
-
return FormUpload(data);
|
|
89
|
-
}
|
|
90
87
|
function FormStatic(data) {
|
|
91
88
|
data = data || {};
|
|
92
89
|
return (target, key) => {
|
|
@@ -110,138 +107,16 @@ function FormArray(itemType, data) {
|
|
|
110
107
|
});
|
|
111
108
|
};
|
|
112
109
|
}
|
|
113
|
-
function
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function validationMessage(errorKey) {
|
|
119
|
-
const key = `form.error.${errorKey}`;
|
|
120
|
-
return (_, field) => {
|
|
121
|
-
const injector = field.options.formState?.injector;
|
|
122
|
-
const language = injector?.get(LANGUAGE_SERVICE);
|
|
123
|
-
return !language ? key : language.getTranslationSync(key, field);
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function withName(fn, name) {
|
|
127
|
-
fn.validatorName = name;
|
|
128
|
-
return fn;
|
|
129
|
-
}
|
|
130
|
-
function validateEach(each, cb, name) {
|
|
131
|
-
return withName((control) => {
|
|
132
|
-
const value = control.value;
|
|
133
|
-
return each ? Array.isArray(value) && value.every(cb) : cb(value);
|
|
134
|
-
}, name);
|
|
135
|
-
}
|
|
136
|
-
function addFieldValidators(field, validators) {
|
|
137
|
-
field.validators = field.validators || {};
|
|
138
|
-
const validation = field.validation || {};
|
|
139
|
-
const messages = validation.messages || {};
|
|
140
|
-
if (Array.isArray(validators)) {
|
|
141
|
-
validators.forEach((validator, ix) => {
|
|
142
|
-
const name = validator.validatorName || `validator_${ix}`;
|
|
143
|
-
field.validators[name] = validator;
|
|
144
|
-
messages[name] = validationMessage(name);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
else if (validators) {
|
|
148
|
-
Object.keys(validators).forEach(name => {
|
|
149
|
-
field.validators[name] = validators[name];
|
|
150
|
-
messages[name] = validationMessage(name);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
field.validation = {
|
|
154
|
-
...validation,
|
|
155
|
-
messages
|
|
110
|
+
function FormSerializable(data) {
|
|
111
|
+
return (target, key) => {
|
|
112
|
+
defineFormControl(target, key, (fb) => fb.createFormSerializer(key, data));
|
|
156
113
|
};
|
|
157
114
|
}
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const messages = Object.assign({}, validation.messages || {});
|
|
162
|
-
names.forEach(name => {
|
|
163
|
-
delete validators[name];
|
|
164
|
-
delete messages[name];
|
|
165
|
-
});
|
|
166
|
-
field.validators = validators;
|
|
167
|
-
field.validation = {
|
|
168
|
-
...validation,
|
|
169
|
-
messages
|
|
115
|
+
function FormFieldSet(data) {
|
|
116
|
+
return (target) => {
|
|
117
|
+
defineFormFieldSet(target, data);
|
|
170
118
|
};
|
|
171
119
|
}
|
|
172
|
-
function jsonValidation() {
|
|
173
|
-
return withName((control) => {
|
|
174
|
-
const value = control.value;
|
|
175
|
-
if (!value)
|
|
176
|
-
return false;
|
|
177
|
-
try {
|
|
178
|
-
JSON.parse(value);
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
catch (e) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
}, "json");
|
|
185
|
-
}
|
|
186
|
-
function requiredValidation() {
|
|
187
|
-
return withName((control) => ObjectUtils.isString(control.value) ? control.value.length > 0 : ObjectUtils.isDefined(control.value), "required");
|
|
188
|
-
}
|
|
189
|
-
function translationValidation(langs = ["de", "en"]) {
|
|
190
|
-
return withName((control) => {
|
|
191
|
-
const value = control.value;
|
|
192
|
-
if (!value || value.length == 0)
|
|
193
|
-
return false;
|
|
194
|
-
return value.findIndex(t => langs.includes(t.lang) && !t.translation) < 0;
|
|
195
|
-
}, "translation");
|
|
196
|
-
}
|
|
197
|
-
function phoneValidation() {
|
|
198
|
-
return withName((control) => {
|
|
199
|
-
const value = control.value;
|
|
200
|
-
if (!value)
|
|
201
|
-
return true;
|
|
202
|
-
const phoneRegexp = /^\d{10,12}$/;
|
|
203
|
-
return phoneRegexp.test(value);
|
|
204
|
-
}, "phone");
|
|
205
|
-
}
|
|
206
|
-
function emailValidation() {
|
|
207
|
-
return withName((control) => {
|
|
208
|
-
const value = control.value;
|
|
209
|
-
if (!value)
|
|
210
|
-
return true;
|
|
211
|
-
const emailRegexp = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g;
|
|
212
|
-
return emailRegexp.test(value);
|
|
213
|
-
}, "email");
|
|
214
|
-
}
|
|
215
|
-
function arrayLengthValidation(min = 1, max = Number.MAX_SAFE_INTEGER) {
|
|
216
|
-
return withName((control) => {
|
|
217
|
-
const value = control.value;
|
|
218
|
-
return !Array.isArray(value) || (min <= value.length && value.length <= max);
|
|
219
|
-
}, "arrayLength");
|
|
220
|
-
}
|
|
221
|
-
function minLengthValidation(minLength, each) {
|
|
222
|
-
return validateEach(each, v => typeof v == "string" && v.length >= minLength, "minLength");
|
|
223
|
-
}
|
|
224
|
-
function maxLengthValidation(maxLength, each) {
|
|
225
|
-
return validateEach(each, v => typeof v == "string" && v.length <= maxLength, "maxLength");
|
|
226
|
-
}
|
|
227
|
-
function minValueValidation(min, each) {
|
|
228
|
-
return validateEach(each, v => {
|
|
229
|
-
if (min instanceof Date) {
|
|
230
|
-
const date = new Date(v);
|
|
231
|
-
return isNaN(date) || date >= min;
|
|
232
|
-
}
|
|
233
|
-
return v == null || v >= min;
|
|
234
|
-
}, "minValue");
|
|
235
|
-
}
|
|
236
|
-
function maxValueValidation(max, each) {
|
|
237
|
-
return validateEach(each, v => {
|
|
238
|
-
if (max instanceof Date) {
|
|
239
|
-
const date = new Date(v);
|
|
240
|
-
return isNaN(date) || date <= max;
|
|
241
|
-
}
|
|
242
|
-
return v == null || v <= max;
|
|
243
|
-
}, "maxValue");
|
|
244
|
-
}
|
|
245
120
|
|
|
246
121
|
function replaceSpecialChars(str, to = "-") {
|
|
247
122
|
return `${str}`.replace(/[&\/\\#, +()$~%.@'":*?<>{}]/g, to);
|
|
@@ -402,10 +277,158 @@ function setFieldHooks(field, hooks) {
|
|
|
402
277
|
: hooks[name];
|
|
403
278
|
});
|
|
404
279
|
}
|
|
280
|
+
function isFieldVisible(field) {
|
|
281
|
+
let visible = true;
|
|
282
|
+
let current = field;
|
|
283
|
+
while (current && visible) {
|
|
284
|
+
const hiddenFn = current.props?.__hidden;
|
|
285
|
+
const injector = field.options?.formState?.injector;
|
|
286
|
+
visible = visible && (!injector || !hiddenFn?.(current, injector));
|
|
287
|
+
current = current.parent;
|
|
288
|
+
}
|
|
289
|
+
if (Array.isArray(field.fieldGroup) && field.fieldGroup.length) {
|
|
290
|
+
return visible && field.fieldGroup.some(f => isFieldVisible(f));
|
|
291
|
+
}
|
|
292
|
+
return visible;
|
|
293
|
+
}
|
|
294
|
+
function isFieldHidden(field) {
|
|
295
|
+
return !isFieldVisible(field);
|
|
296
|
+
}
|
|
405
297
|
const MIN_INPUT_NUM = -1999999999;
|
|
406
298
|
const MAX_INPUT_NUM = 1999999999;
|
|
407
299
|
const EDITOR_FORMATS = ["php", "json", "html", "css", "scss"];
|
|
408
300
|
|
|
301
|
+
function validationMessage(errorKey) {
|
|
302
|
+
const key = `form.error.${errorKey}`;
|
|
303
|
+
return (_, field) => {
|
|
304
|
+
const injector = field.options.formState?.injector;
|
|
305
|
+
const language = injector?.get(LANGUAGE_SERVICE);
|
|
306
|
+
return !language ? key : language.getTranslationSync(key, field);
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function withName(fn, name) {
|
|
310
|
+
const mainFn = (control, field) => {
|
|
311
|
+
return isFieldHidden(field) || fn(control, field);
|
|
312
|
+
};
|
|
313
|
+
mainFn.validatorName = name;
|
|
314
|
+
return mainFn;
|
|
315
|
+
}
|
|
316
|
+
function validateEach(each, cb, name) {
|
|
317
|
+
return withName((control) => {
|
|
318
|
+
const value = control.value;
|
|
319
|
+
return each ? Array.isArray(value) && value.every(cb) : cb(value);
|
|
320
|
+
}, name);
|
|
321
|
+
}
|
|
322
|
+
function addFieldValidators(field, validators) {
|
|
323
|
+
field.validators = field.validators || {};
|
|
324
|
+
const validation = field.validation || {};
|
|
325
|
+
const messages = validation.messages || {};
|
|
326
|
+
if (Array.isArray(validators)) {
|
|
327
|
+
validators.forEach((validator, ix) => {
|
|
328
|
+
const name = validator.validatorName || `validator_${ix}`;
|
|
329
|
+
field.validators[name] = validator;
|
|
330
|
+
messages[name] = validationMessage(name);
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
else if (validators) {
|
|
334
|
+
Object.keys(validators).forEach(name => {
|
|
335
|
+
field.validators[name] = validators[name];
|
|
336
|
+
messages[name] = validationMessage(name);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
field.validation = {
|
|
340
|
+
...validation,
|
|
341
|
+
messages
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function removeFieldValidators(field, ...names) {
|
|
345
|
+
const validators = Object.assign({}, field.validators || {});
|
|
346
|
+
const validation = field.validation || {};
|
|
347
|
+
const messages = Object.assign({}, validation.messages || {});
|
|
348
|
+
names.forEach(name => {
|
|
349
|
+
delete validators[name];
|
|
350
|
+
delete messages[name];
|
|
351
|
+
});
|
|
352
|
+
field.validators = validators;
|
|
353
|
+
field.validation = {
|
|
354
|
+
...validation,
|
|
355
|
+
messages
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function jsonValidation() {
|
|
359
|
+
return withName((control) => {
|
|
360
|
+
const value = control.value;
|
|
361
|
+
if (!value)
|
|
362
|
+
return false;
|
|
363
|
+
try {
|
|
364
|
+
JSON.parse(value);
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
catch (e) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
}, "json");
|
|
371
|
+
}
|
|
372
|
+
function requiredValidation() {
|
|
373
|
+
return withName((control) => ObjectUtils.isString(control.value) ? control.value.length > 0 : ObjectUtils.isDefined(control.value), "required");
|
|
374
|
+
}
|
|
375
|
+
function translationValidation(langs = ["de", "en"]) {
|
|
376
|
+
return withName((control) => {
|
|
377
|
+
const value = control.value;
|
|
378
|
+
if (!value || value.length == 0)
|
|
379
|
+
return false;
|
|
380
|
+
return value.findIndex(t => langs.includes(t.lang) && !t.translation) < 0;
|
|
381
|
+
}, "translation");
|
|
382
|
+
}
|
|
383
|
+
function phoneValidation() {
|
|
384
|
+
return withName((control) => {
|
|
385
|
+
const value = control.value;
|
|
386
|
+
if (!value)
|
|
387
|
+
return true;
|
|
388
|
+
const phoneRegexp = /^\d{10,12}$/;
|
|
389
|
+
return phoneRegexp.test(value);
|
|
390
|
+
}, "phone");
|
|
391
|
+
}
|
|
392
|
+
function emailValidation() {
|
|
393
|
+
return withName((control) => {
|
|
394
|
+
const value = control.value;
|
|
395
|
+
if (!value)
|
|
396
|
+
return true;
|
|
397
|
+
const emailRegexp = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g;
|
|
398
|
+
return emailRegexp.test(value);
|
|
399
|
+
}, "email");
|
|
400
|
+
}
|
|
401
|
+
function arrayLengthValidation(min = 1, max = Number.MAX_SAFE_INTEGER) {
|
|
402
|
+
return withName((control) => {
|
|
403
|
+
const value = control.value;
|
|
404
|
+
return !Array.isArray(value) || (min <= value.length && value.length <= max);
|
|
405
|
+
}, "arrayLength");
|
|
406
|
+
}
|
|
407
|
+
function minLengthValidation(minLength, each) {
|
|
408
|
+
return validateEach(each, v => typeof v == "string" && v.length >= minLength, "minLength");
|
|
409
|
+
}
|
|
410
|
+
function maxLengthValidation(maxLength, each) {
|
|
411
|
+
return validateEach(each, v => typeof v == "string" && v.length <= maxLength, "maxLength");
|
|
412
|
+
}
|
|
413
|
+
function minValueValidation(min, each) {
|
|
414
|
+
return validateEach(each, v => {
|
|
415
|
+
if (min instanceof Date) {
|
|
416
|
+
const date = new Date(v);
|
|
417
|
+
return isNaN(date) || date >= min;
|
|
418
|
+
}
|
|
419
|
+
return v == null || v >= min;
|
|
420
|
+
}, "minValue");
|
|
421
|
+
}
|
|
422
|
+
function maxValueValidation(max, each) {
|
|
423
|
+
return validateEach(each, v => {
|
|
424
|
+
if (max instanceof Date) {
|
|
425
|
+
const date = new Date(v);
|
|
426
|
+
return isNaN(date) || date <= max;
|
|
427
|
+
}
|
|
428
|
+
return v == null || v <= max;
|
|
429
|
+
}, "maxValue");
|
|
430
|
+
}
|
|
431
|
+
|
|
409
432
|
class ModelUtils {
|
|
410
433
|
static getLanguages(language) {
|
|
411
434
|
return async () => {
|
|
@@ -476,6 +499,9 @@ class ConfigForSchemaWrap {
|
|
|
476
499
|
get labelCustomizer() {
|
|
477
500
|
return this.opts.labelCustomizer;
|
|
478
501
|
}
|
|
502
|
+
get legacyLabels() {
|
|
503
|
+
return this.opts.legacyLabels;
|
|
504
|
+
}
|
|
479
505
|
get testId() {
|
|
480
506
|
return this.opts.testId;
|
|
481
507
|
}
|
|
@@ -584,9 +610,11 @@ class DynamicFormBuilderService {
|
|
|
584
610
|
this.events.languageChanged.subscribe(value => lang.next(value));
|
|
585
611
|
this.language = lang;
|
|
586
612
|
}
|
|
587
|
-
resolveFormFields(
|
|
588
|
-
const
|
|
589
|
-
const
|
|
613
|
+
resolveFormFields(type, parent, options) {
|
|
614
|
+
const target = type || { prototype: null };
|
|
615
|
+
const prototype = target.prototype || target;
|
|
616
|
+
const fields = ReflectUtils.getMetadata("dynamicFormFields", prototype) || new Set();
|
|
617
|
+
const sets = ReflectUtils.getMetadata("dynamicFormFieldSets", target) || new Map();
|
|
590
618
|
const result = [];
|
|
591
619
|
for (const key of fields) {
|
|
592
620
|
const builder = ReflectUtils.getMetadata("dynamicFormField", prototype, key);
|
|
@@ -595,25 +623,25 @@ class DynamicFormBuilderService {
|
|
|
595
623
|
result.push(field);
|
|
596
624
|
}
|
|
597
625
|
}
|
|
598
|
-
return this.createFieldSets(result, parent, options);
|
|
626
|
+
return this.createFieldSets(result, parent, options, Array.from(sets.values()));
|
|
599
627
|
}
|
|
600
|
-
resolveFormGroup(key, target, data, parent = null, options
|
|
628
|
+
resolveFormGroup(key, target, data, parent = null, options) {
|
|
601
629
|
return this.createFormGroup(key, sp => this.resolveFormFields(target, sp, options), data, parent, options);
|
|
602
630
|
}
|
|
603
|
-
resolveFormArray(key, itemType, data, parent = null, options
|
|
631
|
+
resolveFormArray(key, itemType, data, parent = null, options) {
|
|
604
632
|
return this.createFormArray(key, sp => {
|
|
605
633
|
return typeof itemType === "function" ? this.resolveFormFields(itemType, sp, options) : this.createFormInput("", typeof itemType === "string" ? { type: `${itemType}` } : itemType, sp, options);
|
|
606
634
|
}, data, parent, options);
|
|
607
635
|
}
|
|
608
|
-
createFieldSets(fields, parent, options) {
|
|
636
|
+
createFieldSets(fields, parent, options, sets = []) {
|
|
609
637
|
const result = [];
|
|
610
638
|
const groups = {};
|
|
611
639
|
fields = Array.from(fields || [])
|
|
612
640
|
.sort((a, b) => a.priority - b.priority);
|
|
613
|
-
fields.forEach(
|
|
614
|
-
if (
|
|
641
|
+
fields.forEach(field => {
|
|
642
|
+
if (this.isFieldset(field)) {
|
|
615
643
|
// This field is an already existing set
|
|
616
|
-
groups[
|
|
644
|
+
groups[field.id] = field.fieldGroup;
|
|
617
645
|
}
|
|
618
646
|
});
|
|
619
647
|
for (const field of fields) {
|
|
@@ -621,6 +649,7 @@ class DynamicFormBuilderService {
|
|
|
621
649
|
// If we have a fieldset name defined, then push the property fields into a group
|
|
622
650
|
if (fsName) {
|
|
623
651
|
const id = !parent?.path ? fsName : `${parent.path}.${fsName}`;
|
|
652
|
+
const set = sets.find(s => s.id === fsName);
|
|
624
653
|
let fieldGroup = groups[id];
|
|
625
654
|
if (!fieldGroup) {
|
|
626
655
|
fieldGroup = [];
|
|
@@ -630,9 +659,10 @@ class DynamicFormBuilderService {
|
|
|
630
659
|
fieldGroup,
|
|
631
660
|
wrappers: ["form-fieldset"],
|
|
632
661
|
props: {
|
|
633
|
-
label: this.getLabel(fsName,
|
|
662
|
+
label: this.getLabel(fsName, null, parent, options, "title"),
|
|
634
663
|
hidden: false,
|
|
635
|
-
|
|
664
|
+
classes: set?.classes,
|
|
665
|
+
layout: set?.layout,
|
|
636
666
|
},
|
|
637
667
|
hooks: {},
|
|
638
668
|
expressions: {}
|
|
@@ -646,13 +676,14 @@ class DynamicFormBuilderService {
|
|
|
646
676
|
}
|
|
647
677
|
else if (field.asFieldSet && !groups[field.id]) {
|
|
648
678
|
const fsName = String(field.key);
|
|
649
|
-
const
|
|
650
|
-
field.id =
|
|
679
|
+
const set = sets.find(s => s.id === fsName);
|
|
680
|
+
field.id = !parent?.path ? fsName : `${parent.path}.${fsName}`;
|
|
651
681
|
field.wrappers = ["form-fieldset"];
|
|
652
682
|
field.props = {
|
|
653
|
-
label: this.getLabel(fsName,
|
|
683
|
+
label: this.getLabel(fsName, null, parent, options, "title"),
|
|
654
684
|
hidden: false,
|
|
655
|
-
|
|
685
|
+
classes: set?.classes,
|
|
686
|
+
layout: set?.layout,
|
|
656
687
|
};
|
|
657
688
|
field.expressions = {};
|
|
658
689
|
this.setExpressions(field, options);
|
|
@@ -874,9 +905,21 @@ class DynamicFormBuilderService {
|
|
|
874
905
|
control.setValue(field.defaultValue);
|
|
875
906
|
return options;
|
|
876
907
|
}
|
|
877
|
-
|
|
908
|
+
isFieldset(field) {
|
|
909
|
+
return Array.isArray(field.fieldGroup) && Array.isArray(field.wrappers) && field.wrappers[0] === "form-fieldset";
|
|
910
|
+
}
|
|
911
|
+
getLabel(key, label, parent, options, legacyPrefix = "") {
|
|
912
|
+
options = options || { labelPrefix: "" };
|
|
878
913
|
const labelPrefix = !ObjectUtils.isString(options.labelPrefix) ? `` : options.labelPrefix;
|
|
879
|
-
|
|
914
|
+
if (ObjectUtils.isFunction(options.labelCustomizer)) {
|
|
915
|
+
return options.labelCustomizer(key, label, parent, labelPrefix) || "";
|
|
916
|
+
}
|
|
917
|
+
// Exceptional case, to be able to have an "empty" label element in the HTML just to fill the space.
|
|
918
|
+
if (label === " ")
|
|
919
|
+
return "\u200B";
|
|
920
|
+
const pathPrefix = options.legacyLabels
|
|
921
|
+
? String(legacyPrefix || labelPrefix)
|
|
922
|
+
: String(parent?.props?.label || labelPrefix);
|
|
880
923
|
const labelItems = ObjectUtils.isString(label)
|
|
881
924
|
? (!label ? [] : [labelPrefix, label])
|
|
882
925
|
: [pathPrefix, `${key || ""}`];
|
|
@@ -903,8 +946,7 @@ class DynamicFormBuilderService {
|
|
|
903
946
|
props: {
|
|
904
947
|
...(data.props || {}),
|
|
905
948
|
...props,
|
|
906
|
-
label:
|
|
907
|
-
?? this.getLabel(key, data.label, parent, options),
|
|
949
|
+
label: this.getLabel(key, data.label, parent, options),
|
|
908
950
|
labelAlign: data.labelAlign === "after" ? "after" : "before",
|
|
909
951
|
description: data.description,
|
|
910
952
|
hideLabel: data.hideLabel === true,
|
|
@@ -926,8 +968,7 @@ class DynamicFormBuilderService {
|
|
|
926
968
|
return !!disabled(target, this.injector);
|
|
927
969
|
},
|
|
928
970
|
"props.hidden": target => {
|
|
929
|
-
|
|
930
|
-
return !!hidden(target, this.injector);
|
|
971
|
+
return isFieldHidden(target);
|
|
931
972
|
}
|
|
932
973
|
}
|
|
933
974
|
};
|
|
@@ -941,13 +982,6 @@ class DynamicFormBuilderService {
|
|
|
941
982
|
this.setExpressions(field, options);
|
|
942
983
|
return field;
|
|
943
984
|
}
|
|
944
|
-
shouldDisplay(field) {
|
|
945
|
-
const display = field.props?.hidden !== true;
|
|
946
|
-
if (Array.isArray(field.fieldGroup) && field.fieldGroup.length) {
|
|
947
|
-
return display && field.fieldGroup.some(f => this.shouldDisplay(f));
|
|
948
|
-
}
|
|
949
|
-
return display;
|
|
950
|
-
}
|
|
951
985
|
isValid(field) {
|
|
952
986
|
const control = field.formControl;
|
|
953
987
|
const valid = field.key && control ? (control.disabled || control.valid) !== false : true;
|
|
@@ -958,7 +992,7 @@ class DynamicFormBuilderService {
|
|
|
958
992
|
}
|
|
959
993
|
setExpressions(field, options) {
|
|
960
994
|
const expressions = {
|
|
961
|
-
display: target =>
|
|
995
|
+
display: target => isFieldVisible(target),
|
|
962
996
|
valid: target => this.isValid(target),
|
|
963
997
|
className: (target) => {
|
|
964
998
|
if (!target.display) {
|
|
@@ -968,11 +1002,22 @@ class DynamicFormBuilderService {
|
|
|
968
1002
|
if (className) {
|
|
969
1003
|
return className;
|
|
970
1004
|
}
|
|
971
|
-
const
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1005
|
+
const idName = String(field.id || field.key || "").replace(/\./, "-");
|
|
1006
|
+
let baseName = `dynamic-form-fieldset dynamic-form-fieldset-${idName}`;
|
|
1007
|
+
if (!this.isFieldset(target)) {
|
|
1008
|
+
const type = String(target.type || "group").replace("formly-", "");
|
|
1009
|
+
const typeName = ObjectUtils.isConstructor(type)
|
|
1010
|
+
? `${target.type.name}`.toLowerCase().replace("component", "")
|
|
1011
|
+
: type;
|
|
1012
|
+
baseName = `dynamic-form-field dynamic-form-field-${target.key} dynamic-form-${typeName}`;
|
|
1013
|
+
}
|
|
1014
|
+
const classesName = Array.isArray(classes) ? classes : [classes];
|
|
1015
|
+
const layoutName = Array.isArray(layout) ? layout : [layout];
|
|
1016
|
+
return [
|
|
1017
|
+
baseName,
|
|
1018
|
+
...classesName,
|
|
1019
|
+
...layoutName.map(l => !l ? null : `dynamic-form-layout-${l}`)
|
|
1020
|
+
].filter(ObjectUtils.isStringWithValue).join(" ");
|
|
976
1021
|
},
|
|
977
1022
|
path: target => {
|
|
978
1023
|
const tp = target.parent;
|
|
@@ -982,7 +1027,7 @@ class DynamicFormBuilderService {
|
|
|
982
1027
|
},
|
|
983
1028
|
testId: target => {
|
|
984
1029
|
const tp = target.parent;
|
|
985
|
-
const prefix = !tp?.testId ? options
|
|
1030
|
+
const prefix = !tp?.testId ? options?.testId || "" : tp.testId;
|
|
986
1031
|
const key = !target.key ? `` : `-${target.key}`;
|
|
987
1032
|
return !prefix ? String(target.key ?? "") : `${prefix}${key}`;
|
|
988
1033
|
}
|
|
@@ -1038,7 +1083,7 @@ class DynamicFormSchemaService {
|
|
|
1038
1083
|
const propFields = await this.getFormFieldsForProp(property, schema, options, parent);
|
|
1039
1084
|
fields.push(...propFields);
|
|
1040
1085
|
}
|
|
1041
|
-
return this.builder.createFieldSets(fields.filter(f => null !== f), parent, options);
|
|
1086
|
+
return this.builder.createFieldSets(fields.filter(f => null !== f), parent, options, schema.sets || []);
|
|
1042
1087
|
}
|
|
1043
1088
|
async getFormFieldsForProp(property, schema, options, parent) {
|
|
1044
1089
|
const field = await this.getFormFieldForProp(property, options, parent);
|
|
@@ -1727,6 +1772,7 @@ class DynamicFormComponent {
|
|
|
1727
1772
|
labelCustomizer = input(null);
|
|
1728
1773
|
testId = input("");
|
|
1729
1774
|
useTabs = input(false);
|
|
1775
|
+
legacyLabels = input(false);
|
|
1730
1776
|
data = input({});
|
|
1731
1777
|
fields = input(null);
|
|
1732
1778
|
fieldChanges = new Subject();
|
|
@@ -1740,11 +1786,14 @@ class DynamicFormComponent {
|
|
|
1740
1786
|
const options = {
|
|
1741
1787
|
labelPrefix: this.labelPrefix(),
|
|
1742
1788
|
labelCustomizer: this.labelCustomizer(),
|
|
1789
|
+
legacyLabels: this.legacyLabels(),
|
|
1743
1790
|
testId: this.testId(),
|
|
1744
1791
|
};
|
|
1745
|
-
const fields = this.fields() || this.builder.resolveFormFields(this.data()?.constructor, null, options);
|
|
1746
1792
|
return [
|
|
1747
|
-
this.builder.createFormGroup(null,
|
|
1793
|
+
this.builder.createFormGroup(null, parent => {
|
|
1794
|
+
const fields = this.fields() || this.builder.resolveFormFields(this.data()?.constructor, parent, options);
|
|
1795
|
+
return this.builder.createFieldSets(fields, parent, options);
|
|
1796
|
+
}, {
|
|
1748
1797
|
label: "",
|
|
1749
1798
|
useTabs: this.useTabs(),
|
|
1750
1799
|
hidden: false,
|
|
@@ -1800,7 +1849,7 @@ class DynamicFormComponent {
|
|
|
1800
1849
|
return field?.formControl ?? null;
|
|
1801
1850
|
}
|
|
1802
1851
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormComponent, deps: [{ token: DynamicFormService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1803
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormComponent, isStandalone: false, selector: "dynamic-form", inputs: { labelPrefix: { classPropertyName: "labelPrefix", publicName: "labelPrefix", isSignal: true, isRequired: false, transformFunction: null }, labelCustomizer: { classPropertyName: "labelCustomizer", publicName: "labelCustomizer", isSignal: true, isRequired: false, transformFunction: null }, testId: { classPropertyName: "testId", publicName: "testId", isSignal: true, isRequired: false, transformFunction: null }, useTabs: { classPropertyName: "useTabs", publicName: "useTabs", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSubmit: "onSubmit", onChanges: "onChanges" }, ngImport: i0, template: "@if (config() && group()) {\n <form [formGroup]=\"group()\" (ngSubmit)=\"submit()\" autocomplete=\"off\" role=\"presentation\">\n <input type=\"submit\" [hidden]=\"true\" />\n <formly-form [model]=\"data()\"\n [fields]=\"config()\"\n [form]=\"group()\"\n [options]=\"options\"></formly-form>\n <ng-content></ng-content>\n </form>\n}\n", styles: [".dynamic-form-field.dynamic-form-hidden{display:none}\n"], dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.LegacyFormlyForm, selector: "formly-form" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1852
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormComponent, isStandalone: false, selector: "dynamic-form", inputs: { labelPrefix: { classPropertyName: "labelPrefix", publicName: "labelPrefix", isSignal: true, isRequired: false, transformFunction: null }, labelCustomizer: { classPropertyName: "labelCustomizer", publicName: "labelCustomizer", isSignal: true, isRequired: false, transformFunction: null }, testId: { classPropertyName: "testId", publicName: "testId", isSignal: true, isRequired: false, transformFunction: null }, useTabs: { classPropertyName: "useTabs", publicName: "useTabs", isSignal: true, isRequired: false, transformFunction: null }, legacyLabels: { classPropertyName: "legacyLabels", publicName: "legacyLabels", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSubmit: "onSubmit", onChanges: "onChanges" }, ngImport: i0, template: "@if (config() && group()) {\n <form [formGroup]=\"group()\" (ngSubmit)=\"submit()\" autocomplete=\"off\" role=\"presentation\">\n <input type=\"submit\" [hidden]=\"true\" />\n <formly-form [model]=\"data()\"\n [fields]=\"config()\"\n [form]=\"group()\"\n [options]=\"options\"></formly-form>\n <ng-content></ng-content>\n </form>\n}\n", styles: [".dynamic-form-field.dynamic-form-hidden{display:none}\n"], dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.LegacyFormlyForm, selector: "formly-form" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1804
1853
|
}
|
|
1805
1854
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormComponent, decorators: [{
|
|
1806
1855
|
type: Component,
|
|
@@ -1827,11 +1876,11 @@ class DynamicFormArrayComponent extends FieldArrayType {
|
|
|
1827
1876
|
this.currentTab.set(Math.min(this.currentTab(), length - 1));
|
|
1828
1877
|
}
|
|
1829
1878
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormArrayComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1830
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormArrayComponent, isStandalone: false, selector: "dynamic-form-array", usesInheritance: true, ngImport: i0, template: "@if (field.display) {\n @if (
|
|
1879
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormArrayComponent, isStandalone: false, selector: "dynamic-form-array", usesInheritance: true, ngImport: i0, template: "@let label = !props.label || props.hideLabel ? null : props.label | translate;\n@if (field.display) {\n @if (label) {\n <label class=\"field-label\">\n <span [innerHTML]=\"label | safe: 'html'\"></span>\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n @if (props.markRequired) {\n <span class=\"field-required\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n <div class=\"field-container\">\n <tabs class=\"form-array-items\" [(value)]=\"currentTab\">\n @for (itemField of field.fieldGroup; track itemField.key; let ix = $index) {\n <ng-template #fieldContent>\n <div class=\"form-array-buttons\">\n @if (itemField.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (itemField.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"itemField\"></formly-field>\n </ng-template>\n @if (props.useTabs) {\n <div class=\"form-array-item\"\n [tabsItem]=\"ix\"\n [label]=\"(itemField.formControl.value | getValue : props.tabsLabel) || ix + 1\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n } @else {\n <div class=\"form-array-item\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n }\n }\n </tabs>\n\n <div class=\"form-array-buttons\">\n @if (props.clearItems) {\n <btn icon=\"trash\" label=\"button.clear-items\" (click)=\"clearItems()\"></btn>\n }\n @if (props.addItem) {\n <btn icon=\"plus\" label=\"button.insert-item\" (click)=\"addItem()\"></btn>\n }\n </div>\n\n <div *ngIf=\"showError\" class=\"field-errors invalid-feedback\">\n <formly-validation-message\n [field]=\"field\"\n id=\"{{ id }}-formly-validation-error\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n </div>\n}\n", styles: [".form-array-item.hidden-tab{display:none}.form-array-buttons{display:flex;gap:5px;margin-bottom:5px}.field-errors.invalid-feedback{display:block}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.TabsItemDirective, selector: "[tabsItem]", inputs: ["tabsItem", "label", "tooltip", "icon", "disabled", "classes"] }, { kind: "component", type: i2.BtnComponent, selector: "btn", inputs: ["label", "tooltip", "icon", "disabled", "type", "size"] }, { kind: "component", type: i2.TabsComponent, selector: "tabs", inputs: ["value", "options", "type", "size", "testId", "tabsClass"], outputs: ["valueChange", "selectedChange"] }, { kind: "component", type: i3.LegacyFormlyField, selector: "formly-field" }, { kind: "component", type: i3.LegacyFormlyValidationMessage, selector: "formly-validation-message" }, { kind: "pipe", type: i2.GetValuePipe, name: "getValue" }, { kind: "pipe", type: i2.SafeHtmlPipe, name: "safe" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1831
1880
|
}
|
|
1832
1881
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormArrayComponent, decorators: [{
|
|
1833
1882
|
type: Component,
|
|
1834
|
-
args: [{ standalone: false, selector: "dynamic-form-array", encapsulation: ViewEncapsulation.None, template: "@if (field.display) {\n @if (
|
|
1883
|
+
args: [{ standalone: false, selector: "dynamic-form-array", encapsulation: ViewEncapsulation.None, template: "@let label = !props.label || props.hideLabel ? null : props.label | translate;\n@if (field.display) {\n @if (label) {\n <label class=\"field-label\">\n <span [innerHTML]=\"label | safe: 'html'\"></span>\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n @if (props.markRequired) {\n <span class=\"field-required\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n <div class=\"field-container\">\n <tabs class=\"form-array-items\" [(value)]=\"currentTab\">\n @for (itemField of field.fieldGroup; track itemField.key; let ix = $index) {\n <ng-template #fieldContent>\n <div class=\"form-array-buttons\">\n @if (itemField.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (itemField.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"itemField\"></formly-field>\n </ng-template>\n @if (props.useTabs) {\n <div class=\"form-array-item\"\n [tabsItem]=\"ix\"\n [label]=\"(itemField.formControl.value | getValue : props.tabsLabel) || ix + 1\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n } @else {\n <div class=\"form-array-item\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n }\n }\n </tabs>\n\n <div class=\"form-array-buttons\">\n @if (props.clearItems) {\n <btn icon=\"trash\" label=\"button.clear-items\" (click)=\"clearItems()\"></btn>\n }\n @if (props.addItem) {\n <btn icon=\"plus\" label=\"button.insert-item\" (click)=\"addItem()\"></btn>\n }\n </div>\n\n <div *ngIf=\"showError\" class=\"field-errors invalid-feedback\">\n <formly-validation-message\n [field]=\"field\"\n id=\"{{ id }}-formly-validation-error\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n </div>\n}\n", styles: [".form-array-item.hidden-tab{display:none}.form-array-buttons{display:flex;gap:5px;margin-bottom:5px}.field-errors.invalid-feedback{display:block}\n"] }]
|
|
1835
1884
|
}] });
|
|
1836
1885
|
|
|
1837
1886
|
class DynamicFormChipsComponent extends DynamicFieldType {
|
|
@@ -1924,29 +1973,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
|
|
|
1924
1973
|
|
|
1925
1974
|
class DynamicFormFieldComponent extends FieldWrapper {
|
|
1926
1975
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1927
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormFieldComponent, isStandalone: false, selector: "dynamic-form-field", usesInheritance: true, ngImport: i0, template: "<ng-template #labelTemplate>\n @
|
|
1976
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormFieldComponent, isStandalone: false, selector: "dynamic-form-field", usesInheritance: true, ngImport: i0, template: "<ng-template #labelTemplate>\n @let label = !props.label || props.hideLabel ? null : props.label | translate;\n @if (label) {\n <label class=\"field-label\" [for]=\"id\">\n <span [innerHTML]=\"label | safe: 'html'\"></span>\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n @if (props.markRequired) {\n <span class=\"field-required\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n</ng-template>\n@if (props.labelAlign === \"before\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n}\n<div class=\"field-container\">\n <ng-container #fieldComponent></ng-container>\n <div *ngIf=\"showError\" class=\"field-errors invalid-feedback\">\n <formly-validation-message\n [field]=\"field\"\n id=\"{{ id }}-formly-validation-error\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n</div>\n@if (props.labelAlign === \"after\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n}\n", dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i3.LegacyFormlyValidationMessage, selector: "formly-validation-message" }, { kind: "pipe", type: i2.SafeHtmlPipe, name: "safe" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1928
1977
|
}
|
|
1929
1978
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormFieldComponent, decorators: [{
|
|
1930
1979
|
type: Component,
|
|
1931
|
-
args: [{ standalone: false, selector: "dynamic-form-field", encapsulation: ViewEncapsulation.None, template: "<ng-template #labelTemplate>\n @
|
|
1980
|
+
args: [{ standalone: false, selector: "dynamic-form-field", encapsulation: ViewEncapsulation.None, template: "<ng-template #labelTemplate>\n @let label = !props.label || props.hideLabel ? null : props.label | translate;\n @if (label) {\n <label class=\"field-label\" [for]=\"id\">\n <span [innerHTML]=\"label | safe: 'html'\"></span>\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n @if (props.markRequired) {\n <span class=\"field-required\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n</ng-template>\n@if (props.labelAlign === \"before\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n}\n<div class=\"field-container\">\n <ng-container #fieldComponent></ng-container>\n <div *ngIf=\"showError\" class=\"field-errors invalid-feedback\">\n <formly-validation-message\n [field]=\"field\"\n id=\"{{ id }}-formly-validation-error\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n</div>\n@if (props.labelAlign === \"after\") {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\"></ng-container>\n}\n" }]
|
|
1932
1981
|
}] });
|
|
1933
1982
|
|
|
1934
1983
|
class DynamicFormFieldsetComponent extends FieldWrapper {
|
|
1935
1984
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormFieldsetComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1936
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormFieldsetComponent, isStandalone: false, selector: "dynamic-form-fieldset", usesInheritance: true, ngImport: i0, template: "@if (field.display) {\n <legend class=\"field-legend\" *ngIf=\"
|
|
1985
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormFieldsetComponent, isStandalone: false, selector: "dynamic-form-fieldset", usesInheritance: true, ngImport: i0, template: "@let label = !props.label || props.hideLabel || field.parent.props.useTabs ? null : props.label | translate;\n@if (field.display) {\n <legend class=\"field-legend\" *ngIf=\"label\">\n <span [innerHTML]=\"label | safe: 'html'\"></span>\n </legend>\n <div class=\"field-container\">\n @for (itemField of field.fieldGroup; track itemField) {\n @if (itemField.display) {\n <formly-field [field]=\"itemField\"></formly-field>\n }\n }\n </div>\n}\n", dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.LegacyFormlyField, selector: "formly-field" }, { kind: "pipe", type: i2.SafeHtmlPipe, name: "safe" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1937
1986
|
}
|
|
1938
1987
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormFieldsetComponent, decorators: [{
|
|
1939
1988
|
type: Component,
|
|
1940
|
-
args: [{ standalone: false, selector: "dynamic-form-fieldset", encapsulation: ViewEncapsulation.None, template: "@if (field.display) {\n <legend class=\"field-legend\" *ngIf=\"
|
|
1989
|
+
args: [{ standalone: false, selector: "dynamic-form-fieldset", encapsulation: ViewEncapsulation.None, template: "@let label = !props.label || props.hideLabel || field.parent.props.useTabs ? null : props.label | translate;\n@if (field.display) {\n <legend class=\"field-legend\" *ngIf=\"label\">\n <span [innerHTML]=\"label | safe: 'html'\"></span>\n </legend>\n <div class=\"field-container\">\n @for (itemField of field.fieldGroup; track itemField) {\n @if (itemField.display) {\n <formly-field [field]=\"itemField\"></formly-field>\n }\n }\n </div>\n}\n" }]
|
|
1941
1990
|
}] });
|
|
1942
1991
|
|
|
1943
1992
|
class DynamicFormGroupComponent extends FieldWrapper {
|
|
1944
1993
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormGroupComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1945
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormGroupComponent, isStandalone: false, selector: "dynamic-form-group", usesInheritance: true, ngImport: i0, template: "@if (field.display) {\n @if (
|
|
1994
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormGroupComponent, isStandalone: false, selector: "dynamic-form-group", usesInheritance: true, ngImport: i0, template: "@let label = !props.label || props.hideLabel ? null : props.label | translate;\n@if (field.display) {\n @if (label) {\n <label class=\"field-label\">\n <span [innerHTML]=\"label | safe: 'html'\"></span>\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n @if (props.markRequired) {\n <span class=\"field-required\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n <tabs class=\"field-container\">\n @for (itemField of field.fieldGroup; track itemField; let ix = $index) {\n @if (itemField.display) {\n @if (props.useTabs && itemField.wrappers | includes: 'form-fieldset') {\n <div class=\"form-fieldset-item\"\n [tabsItem]=\"ix\"\n [classes]=\"['form-fieldset-tab', itemField.valid === false ? 'invalid' : 'valid']\"\n [label]=\"itemField.props.label\">\n <formly-field [field]=\"itemField\"></formly-field>\n </div>\n } @else {\n <formly-field [field]=\"itemField\"></formly-field>\n }\n }\n }\n <div *ngIf=\"showError\" class=\"field-errors invalid-feedback\">\n <formly-validation-message\n [field]=\"field\"\n id=\"{{ id }}-formly-validation-error\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n </tabs>\n}\n", styles: [".form-fieldset-item.hidden-tab{display:none}.form-fieldset-tab{position:relative;--invalid-bg: rgba(184, 38, 38, 1);--invalid-border: rgba(184, 38, 38, .6);--invalid-color: #ececec;--invalid-box-size: 15px;--invalid-box-pull: -3px}.form-fieldset-tab.invalid>btn .async-target{border:1px solid var(--invalid-border)}.form-fieldset-tab.invalid:after{background:var(--invalid-bg);color:var(--invalid-color);font-size:10px;line-height:var(--invalid-box-size);width:var(--invalid-box-size);height:var(--invalid-box-size);text-align:center;border-radius:5px;content:\"!\";display:block;position:absolute;top:var(--invalid-box-pull);right:var(--invalid-box-pull)}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.TabsItemDirective, selector: "[tabsItem]", inputs: ["tabsItem", "label", "tooltip", "icon", "disabled", "classes"] }, { kind: "component", type: i2.TabsComponent, selector: "tabs", inputs: ["value", "options", "type", "size", "testId", "tabsClass"], outputs: ["valueChange", "selectedChange"] }, { kind: "component", type: i3.LegacyFormlyField, selector: "formly-field" }, { kind: "component", type: i3.LegacyFormlyValidationMessage, selector: "formly-validation-message" }, { kind: "pipe", type: i2.IncludesPipe, name: "includes" }, { kind: "pipe", type: i2.SafeHtmlPipe, name: "safe" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1946
1995
|
}
|
|
1947
1996
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormGroupComponent, decorators: [{
|
|
1948
1997
|
type: Component,
|
|
1949
|
-
args: [{ standalone: false, selector: "dynamic-form-group", encapsulation: ViewEncapsulation.None, template: "@if (field.display) {\n @if (
|
|
1998
|
+
args: [{ standalone: false, selector: "dynamic-form-group", encapsulation: ViewEncapsulation.None, template: "@let label = !props.label || props.hideLabel ? null : props.label | translate;\n@if (field.display) {\n @if (label) {\n <label class=\"field-label\">\n <span [innerHTML]=\"label | safe: 'html'\"></span>\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n @if (props.markRequired) {\n <span class=\"field-required\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n <tabs class=\"field-container\">\n @for (itemField of field.fieldGroup; track itemField; let ix = $index) {\n @if (itemField.display) {\n @if (props.useTabs && itemField.wrappers | includes: 'form-fieldset') {\n <div class=\"form-fieldset-item\"\n [tabsItem]=\"ix\"\n [classes]=\"['form-fieldset-tab', itemField.valid === false ? 'invalid' : 'valid']\"\n [label]=\"itemField.props.label\">\n <formly-field [field]=\"itemField\"></formly-field>\n </div>\n } @else {\n <formly-field [field]=\"itemField\"></formly-field>\n }\n }\n }\n <div *ngIf=\"showError\" class=\"field-errors invalid-feedback\">\n <formly-validation-message\n [field]=\"field\"\n id=\"{{ id }}-formly-validation-error\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n </tabs>\n}\n", styles: [".form-fieldset-item.hidden-tab{display:none}.form-fieldset-tab{position:relative;--invalid-bg: rgba(184, 38, 38, 1);--invalid-border: rgba(184, 38, 38, .6);--invalid-color: #ececec;--invalid-box-size: 15px;--invalid-box-pull: -3px}.form-fieldset-tab.invalid>btn .async-target{border:1px solid var(--invalid-border)}.form-fieldset-tab.invalid:after{background:var(--invalid-bg);color:var(--invalid-color);font-size:10px;line-height:var(--invalid-box-size);width:var(--invalid-box-size);height:var(--invalid-box-size);text-align:center;border-radius:5px;content:\"!\";display:block;position:absolute;top:var(--invalid-box-pull);right:var(--invalid-box-pull)}\n"] }]
|
|
1950
1999
|
}] });
|
|
1951
2000
|
|
|
1952
2001
|
// --- Components ---
|
|
@@ -2070,5 +2119,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
|
|
|
2070
2119
|
* Generated bundle index. Do not edit.
|
|
2071
2120
|
*/
|
|
2072
2121
|
|
|
2073
|
-
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormAlertComponent, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormStaticComponent, DynamicFormTranslationComponent, DynamicFormUploadComponent, DynamicFormWysiwygComponent, EDITOR_FORMATS, FORM_ROOT_ID, FormArray,
|
|
2122
|
+
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormAlertComponent, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormStaticComponent, DynamicFormTranslationComponent, DynamicFormUploadComponent, DynamicFormWysiwygComponent, EDITOR_FORMATS, FORM_ROOT_ID, FormArray, FormFieldSet, FormGroup, FormInput, FormSelect, FormSerializable, FormStatic, FormUpload, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, RichTranslationModel, TranslationModel, addFieldValidators, arrayLengthValidation, clearFieldArray, controlStatus, controlValues, convertToDate, convertToDateFormat, convertToNumber, customizeFormField, emailValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, getSelectOptions, insertToFieldArray, isFieldHidden, isFieldVisible, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, removeFieldValidators, removeFromFieldArray, replaceFieldArray, replaceSpecialChars, requiredValidation, setFieldDefault, setFieldDisabled, setFieldHidden, setFieldHooks, setFieldProp, setFieldProps, setFieldValue, translationValidation };
|
|
2074
2123
|
//# sourceMappingURL=stemy-ngx-dynamic-form.mjs.map
|