@mk-kit/ui 0.36.0 → 0.38.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 +11 -6
- package/fesm2022/mk-kit-ui-chat.mjs +490 -0
- package/fesm2022/mk-kit-ui-chat.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-core.mjs +310 -1
- package/fesm2022/mk-kit-ui-core.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-dynamic-form.mjs +578 -0
- package/fesm2022/mk-kit-ui-dynamic-form.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-feedback.mjs +400 -8
- package/fesm2022/mk-kit-ui-feedback.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-forms.mjs +816 -6
- package/fesm2022/mk-kit-ui-forms.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-query-builder.mjs +276 -0
- package/fesm2022/mk-kit-ui-query-builder.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-table.mjs +20 -1
- package/fesm2022/mk-kit-ui-table.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-testing.mjs +834 -0
- package/fesm2022/mk-kit-ui-testing.mjs.map +1 -0
- package/fesm2022/mk-kit-ui.mjs +3 -0
- package/fesm2022/mk-kit-ui.mjs.map +1 -1
- package/package.json +17 -1
- package/types/mk-kit-ui-chat.d.ts +288 -0
- package/types/mk-kit-ui-core.d.ts +167 -2
- package/types/mk-kit-ui-dynamic-form.d.ts +305 -0
- package/types/mk-kit-ui-feedback.d.ts +111 -2
- package/types/mk-kit-ui-forms.d.ts +264 -3
- package/types/mk-kit-ui-query-builder.d.ts +98 -0
- package/types/mk-kit-ui-table.d.ts +12 -0
- package/types/mk-kit-ui-testing.d.ts +344 -0
- package/types/mk-kit-ui.d.ts +3 -0
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
import * as i1 from '@angular/forms';
|
|
2
|
+
import { Validators, FormArray, FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { input, inject, TemplateRef, Directive, forwardRef, numberAttribute, computed, ChangeDetectionStrategy, Component, DestroyRef, model, booleanAttribute, output, contentChildren, signal, effect, untracked } from '@angular/core';
|
|
5
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
6
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
+
import { MK_I18N } from '@mk-kit/ui/core';
|
|
8
|
+
import { MkButton } from '@mk-kit/ui/button';
|
|
9
|
+
import { MkCheckbox } from '@mk-kit/ui/checkbox';
|
|
10
|
+
import { MkFormField, MkInput, MkNumberInput, MkCurrencyInput, MkSelect, MkMultiSelect, MkAutocomplete, MkRadioGroup, MkRadio, MkButtonToggleGroup, MkButtonToggle, MkSwitch, MkSlider, MkRating, MkColorPicker, MkTagInput, MkPhoneInput, MkFileUpload, MkCodeEditor, MkPasswordInput } from '@mk-kit/ui/forms';
|
|
11
|
+
import { MkDatePicker, MkTimePicker, MkDateTimePicker } from '@mk-kit/ui/datetime';
|
|
12
|
+
|
|
13
|
+
function mkIsGroup(f) {
|
|
14
|
+
return f.type === 'group';
|
|
15
|
+
}
|
|
16
|
+
function mkIsArray(f) {
|
|
17
|
+
return f.type === 'array';
|
|
18
|
+
}
|
|
19
|
+
function mkIsSection(f) {
|
|
20
|
+
return f.type === 'section';
|
|
21
|
+
}
|
|
22
|
+
function mkIsValueField(f) {
|
|
23
|
+
return f.type !== 'group' && f.type !== 'array' && f.type !== 'section';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* ------------------------------------------------------------------------ */
|
|
27
|
+
/* Defaults */
|
|
28
|
+
/* ------------------------------------------------------------------------ */
|
|
29
|
+
/** The empty value a field type starts with when no `default` is given. */
|
|
30
|
+
function mkDynamicEmptyValue(field) {
|
|
31
|
+
switch (field.type) {
|
|
32
|
+
case 'checkbox':
|
|
33
|
+
case 'switch':
|
|
34
|
+
return false;
|
|
35
|
+
case 'multi-select':
|
|
36
|
+
case 'tags':
|
|
37
|
+
case 'file':
|
|
38
|
+
return [];
|
|
39
|
+
case 'number':
|
|
40
|
+
case 'currency':
|
|
41
|
+
case 'slider':
|
|
42
|
+
case 'rating':
|
|
43
|
+
case 'date':
|
|
44
|
+
case 'time':
|
|
45
|
+
case 'datetime':
|
|
46
|
+
case 'select':
|
|
47
|
+
case 'radio':
|
|
48
|
+
case 'toggle':
|
|
49
|
+
case 'autocomplete':
|
|
50
|
+
case 'color':
|
|
51
|
+
case 'phone':
|
|
52
|
+
return null;
|
|
53
|
+
default:
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Default value object of a field list (groups nested, arrays as item lists). */
|
|
58
|
+
function mkDynamicDefaults(fields) {
|
|
59
|
+
const out = {};
|
|
60
|
+
for (const f of fields) {
|
|
61
|
+
if (mkIsSection(f))
|
|
62
|
+
continue;
|
|
63
|
+
if (mkIsGroup(f))
|
|
64
|
+
out[f.key] = mkDynamicDefaults(f.fields);
|
|
65
|
+
else if (mkIsArray(f))
|
|
66
|
+
out[f.key] = (f.default ?? []).map((item) => ({ ...mkDynamicDefaults(f.fields), ...item }));
|
|
67
|
+
else
|
|
68
|
+
out[f.key] = f.default !== undefined ? f.default : mkDynamicEmptyValue(f);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/* ------------------------------------------------------------------------ */
|
|
73
|
+
/* Validators */
|
|
74
|
+
/* ------------------------------------------------------------------------ */
|
|
75
|
+
/** Angular validators for one value field, from its declarative `validators` + `required`. */
|
|
76
|
+
function mkDynamicValidators(field) {
|
|
77
|
+
const v = field.validators ?? {};
|
|
78
|
+
const out = [];
|
|
79
|
+
if (field.required)
|
|
80
|
+
out.push(field.type === 'checkbox' || field.type === 'switch' ? Validators.requiredTrue : Validators.required);
|
|
81
|
+
if (v.min !== undefined)
|
|
82
|
+
out.push(Validators.min(v.min));
|
|
83
|
+
if (v.max !== undefined)
|
|
84
|
+
out.push(Validators.max(v.max));
|
|
85
|
+
if (v.minLength !== undefined)
|
|
86
|
+
out.push(Validators.minLength(v.minLength));
|
|
87
|
+
if (v.maxLength !== undefined)
|
|
88
|
+
out.push(Validators.maxLength(v.maxLength));
|
|
89
|
+
if (v.pattern !== undefined)
|
|
90
|
+
out.push(Validators.pattern(v.pattern));
|
|
91
|
+
if (v.email || field.type === 'email')
|
|
92
|
+
out.push(Validators.email);
|
|
93
|
+
if (v.custom)
|
|
94
|
+
out.push(...v.custom);
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
/* ------------------------------------------------------------------------ */
|
|
98
|
+
/* Form construction */
|
|
99
|
+
/* ------------------------------------------------------------------------ */
|
|
100
|
+
/** Build the `FormControl` / `FormGroup` / `FormArray` for one field. */
|
|
101
|
+
function mkDynamicControl(field, value) {
|
|
102
|
+
if (mkIsGroup(field))
|
|
103
|
+
return mkDynamicGroup(field.fields, value);
|
|
104
|
+
if (mkIsArray(field)) {
|
|
105
|
+
const items = value ?? field.default ?? [];
|
|
106
|
+
return new FormArray(items.map((item) => mkDynamicGroup(field.fields, item)), arrayValidators(field));
|
|
107
|
+
}
|
|
108
|
+
const f = field;
|
|
109
|
+
const initial = value !== undefined ? value : f.default !== undefined ? f.default : mkDynamicEmptyValue(f);
|
|
110
|
+
return new FormControl({ value: initial, disabled: !!f.disabled }, { validators: mkDynamicValidators(f) });
|
|
111
|
+
}
|
|
112
|
+
function arrayValidators(field) {
|
|
113
|
+
const out = [];
|
|
114
|
+
if (field.min)
|
|
115
|
+
out.push((c) => (c.length < field.min ? { minItems: { requiredLength: field.min, actualLength: c.length } } : null));
|
|
116
|
+
if (field.max)
|
|
117
|
+
out.push((c) => (c.length > field.max ? { maxItems: { requiredLength: field.max, actualLength: c.length } } : null));
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
/** A `FormGroup` for a field list; `value` (partial) overrides the defaults. */
|
|
121
|
+
function mkDynamicGroup(fields, value) {
|
|
122
|
+
const controls = {};
|
|
123
|
+
for (const f of fields) {
|
|
124
|
+
if (mkIsSection(f))
|
|
125
|
+
continue;
|
|
126
|
+
controls[f.key] = mkDynamicControl(f, value?.[f.key]);
|
|
127
|
+
}
|
|
128
|
+
return new FormGroup(controls);
|
|
129
|
+
}
|
|
130
|
+
/** Build the reactive form of a whole schema. */
|
|
131
|
+
function mkDynamicForm(schema, value) {
|
|
132
|
+
return mkDynamicGroup(schema.fields, value);
|
|
133
|
+
}
|
|
134
|
+
/* ------------------------------------------------------------------------ */
|
|
135
|
+
/* Conditions */
|
|
136
|
+
/* ------------------------------------------------------------------------ */
|
|
137
|
+
function read(value, path) {
|
|
138
|
+
return path.split('.').reduce((acc, k) => (acc && typeof acc === 'object' ? acc[k] : undefined), value);
|
|
139
|
+
}
|
|
140
|
+
function isEmpty(v) {
|
|
141
|
+
return v === null || v === undefined || v === '' || v === false || (Array.isArray(v) && v.length === 0);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Evaluate a condition against a form value. `value` is normally the whole
|
|
145
|
+
* form value; inside an array item the item's own value is used, with the
|
|
146
|
+
* root available under `$root`.
|
|
147
|
+
*/
|
|
148
|
+
function mkDynamicCondition(cond, value) {
|
|
149
|
+
if (cond === undefined)
|
|
150
|
+
return true;
|
|
151
|
+
if (typeof cond === 'function')
|
|
152
|
+
return !!cond(value);
|
|
153
|
+
if ('and' in cond)
|
|
154
|
+
return cond.and.every((c) => mkDynamicCondition(c, value));
|
|
155
|
+
if ('or' in cond)
|
|
156
|
+
return cond.or.some((c) => mkDynamicCondition(c, value));
|
|
157
|
+
if ('not' in cond)
|
|
158
|
+
return !mkDynamicCondition(cond.not, value);
|
|
159
|
+
const v = read(value, cond.field);
|
|
160
|
+
if ('eq' in cond && v !== cond.eq)
|
|
161
|
+
return false;
|
|
162
|
+
if ('neq' in cond && v === cond.neq)
|
|
163
|
+
return false;
|
|
164
|
+
if (cond.in && !cond.in.includes(v))
|
|
165
|
+
return false;
|
|
166
|
+
if (cond.notIn && cond.notIn.includes(v))
|
|
167
|
+
return false;
|
|
168
|
+
if (cond.truthy !== undefined && !!v !== cond.truthy)
|
|
169
|
+
return false;
|
|
170
|
+
if (cond.empty !== undefined && isEmpty(v) !== cond.empty)
|
|
171
|
+
return false;
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
/* ------------------------------------------------------------------------ */
|
|
175
|
+
/* Introspection helpers */
|
|
176
|
+
/* ------------------------------------------------------------------------ */
|
|
177
|
+
/** Depth-first list of every value field with its dotted path. */
|
|
178
|
+
function mkDynamicFlatten(fields, prefix = '') {
|
|
179
|
+
const out = [];
|
|
180
|
+
for (const f of fields) {
|
|
181
|
+
if (mkIsSection(f))
|
|
182
|
+
continue;
|
|
183
|
+
const path = prefix ? `${prefix}.${f.key}` : f.key;
|
|
184
|
+
out.push({ path, field: f });
|
|
185
|
+
if (mkIsGroup(f))
|
|
186
|
+
out.push(...mkDynamicFlatten(f.fields, path));
|
|
187
|
+
}
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
/** Column span a field takes in a grid of `columns`. */
|
|
191
|
+
function mkDynamicSpan(field, columns) {
|
|
192
|
+
const c = Math.min(12, Math.max(1, columns || 1));
|
|
193
|
+
if (mkIsSection(field) || mkIsGroup(field) || mkIsArray(field))
|
|
194
|
+
return field.span ?? 12;
|
|
195
|
+
const span = field.span ?? Math.round(12 / c);
|
|
196
|
+
return Math.min(12, Math.max(1, span));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Registers a renderer for a custom field type:
|
|
201
|
+
*
|
|
202
|
+
* ```html
|
|
203
|
+
* <mk-dynamic-form [schema]="schema">
|
|
204
|
+
* <ng-template mkDynamicField="signature" let-field let-control="control">
|
|
205
|
+
* <mk-signature-pad [formControl]="control" />
|
|
206
|
+
* </ng-template>
|
|
207
|
+
* </mk-dynamic-form>
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* A field `{ type: 'custom', key: 'sig', props: { renderer: 'signature' } }`
|
|
211
|
+
* (or any built-in `type` you want to override) then renders this template
|
|
212
|
+
* inside the usual `mk-form-field`.
|
|
213
|
+
*/
|
|
214
|
+
class MkDynamicFieldDef {
|
|
215
|
+
/** The type (or `props.renderer` name) this template renders. */
|
|
216
|
+
mkDynamicField = input.required(/* @ts-ignore */
|
|
217
|
+
...(ngDevMode ? [{ debugName: "mkDynamicField" }] : /* istanbul ignore next */ []));
|
|
218
|
+
template = inject(TemplateRef);
|
|
219
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MkDynamicFieldDef, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
223
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.7", type: MkDynamicFieldDef, isStandalone: true, selector: "ng-template[mkDynamicField]", inputs: { mkDynamicField: { classPropertyName: "mkDynamicField", publicName: "mkDynamicField", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
224
|
+
}
|
|
225
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MkDynamicFieldDef, decorators: [{
|
|
226
|
+
type: Directive,
|
|
227
|
+
args: [{ selector: 'ng-template[mkDynamicField]' }]
|
|
228
|
+
}], propDecorators: { mkDynamicField: [{ type: i0.Input, args: [{ isSignal: true, alias: "mkDynamicField", required: true }] }] } });
|
|
229
|
+
/**
|
|
230
|
+
* Renders one field list (the root, a group, or one array item) as a grid.
|
|
231
|
+
* Internal — projected by {@link MkDynamicForm}; recursive for groups/arrays.
|
|
232
|
+
*/
|
|
233
|
+
class MkDynamicFields {
|
|
234
|
+
root = inject(forwardRef(() => MkDynamicForm));
|
|
235
|
+
i18n = inject(MK_I18N);
|
|
236
|
+
fields = input.required(/* @ts-ignore */
|
|
237
|
+
...(ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []));
|
|
238
|
+
group = input.required(/* @ts-ignore */
|
|
239
|
+
...(ngDevMode ? [{ debugName: "group" }] : /* istanbul ignore next */ []));
|
|
240
|
+
columns = input(1, { ...(ngDevMode ? { debugName: "columns" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
241
|
+
/** Value the conditions of this level are evaluated against. */
|
|
242
|
+
scope = input.required(/* @ts-ignore */
|
|
243
|
+
...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
|
|
244
|
+
labelPosition = computed(() => this.root.labelPosition(), /* @ts-ignore */
|
|
245
|
+
...(ngDevMode ? [{ debugName: "labelPosition" }] : /* istanbul ignore next */ []));
|
|
246
|
+
size = computed(() => this.root.size(), /* @ts-ignore */
|
|
247
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
248
|
+
control(f) {
|
|
249
|
+
return this.group().get(f.key);
|
|
250
|
+
}
|
|
251
|
+
formGroup(f) {
|
|
252
|
+
return this.group().get(f.key);
|
|
253
|
+
}
|
|
254
|
+
formArray(f) {
|
|
255
|
+
return this.group().get(f.key);
|
|
256
|
+
}
|
|
257
|
+
isVisible(f) {
|
|
258
|
+
return mkDynamicCondition(f.showWhen, this.scope());
|
|
259
|
+
}
|
|
260
|
+
span(f) {
|
|
261
|
+
return mkDynamicSpan(f, this.columns());
|
|
262
|
+
}
|
|
263
|
+
columnsOf(f) {
|
|
264
|
+
return f.columns ?? this.columns();
|
|
265
|
+
}
|
|
266
|
+
isGroup = mkIsGroup;
|
|
267
|
+
isArray = mkIsArray;
|
|
268
|
+
isSection = mkIsSection;
|
|
269
|
+
isValue = mkIsValueField;
|
|
270
|
+
/** Custom template for a value field, if one is registered. */
|
|
271
|
+
customTemplate(f) {
|
|
272
|
+
const name = f.props?.['renderer'] ?? f.type;
|
|
273
|
+
return this.root.templateFor(name);
|
|
274
|
+
}
|
|
275
|
+
customContext(f) {
|
|
276
|
+
return { $implicit: f, field: f, control: this.control(f), value: this.scope() };
|
|
277
|
+
}
|
|
278
|
+
/** `props.x` with a typed default. */
|
|
279
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
280
|
+
p(f, key, fallback) {
|
|
281
|
+
const v = f.props?.[key];
|
|
282
|
+
return v === undefined ? fallback : v;
|
|
283
|
+
}
|
|
284
|
+
inputType(f) {
|
|
285
|
+
return f.type === 'text' || f.type === 'textarea' ? 'text' : f.type;
|
|
286
|
+
}
|
|
287
|
+
itemScope(f, index) {
|
|
288
|
+
const item = (this.formArray(f).at(index)?.getRawValue() ?? {});
|
|
289
|
+
return { ...item, $root: this.scope()['$root'] ?? this.scope(), $index: index };
|
|
290
|
+
}
|
|
291
|
+
canAdd(f) {
|
|
292
|
+
return !this.control(f).disabled && (!f.max || this.formArray(f).length < f.max);
|
|
293
|
+
}
|
|
294
|
+
canRemove(f) {
|
|
295
|
+
return !this.control(f).disabled && this.formArray(f).length > (f.min ?? 0);
|
|
296
|
+
}
|
|
297
|
+
addItem(f) {
|
|
298
|
+
const arr = this.formArray(f);
|
|
299
|
+
arr.push(mkDynamicGroup(f.fields));
|
|
300
|
+
arr.markAsDirty();
|
|
301
|
+
this.root.sync();
|
|
302
|
+
}
|
|
303
|
+
removeItem(f, index) {
|
|
304
|
+
const arr = this.formArray(f);
|
|
305
|
+
arr.removeAt(index);
|
|
306
|
+
arr.markAsDirty();
|
|
307
|
+
this.root.sync();
|
|
308
|
+
}
|
|
309
|
+
trackItem(index, item) {
|
|
310
|
+
return item;
|
|
311
|
+
}
|
|
312
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MkDynamicFields, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
313
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: MkDynamicFields, isStandalone: true, selector: "mk-dynamic-fields", inputs: { fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: true, transformFunction: null }, group: { classPropertyName: "group", publicName: "group", isSignal: true, isRequired: true, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, scope: { classPropertyName: "scope", publicName: "scope", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "style.--mk-dyn-columns": "columns()" }, classAttribute: "mk-dynamic-fields" }, ngImport: i0, template: "@for (f of fields(); track f.type + ':' + ($any(f).key ?? $any(f).label ?? $index)) {\n @if (isVisible(f)) {\n @if (isSection(f)) {\n <div class=\"mk-dynamic-fields__section\" [style.--mk-dyn-span]=\"span(f)\">\n <h3 class=\"mk-dynamic-fields__section-title\">{{ f.label }}</h3>\n @if (f.hint) {\n <p class=\"mk-dynamic-fields__section-hint\">{{ f.hint }}</p>\n }\n </div>\n } @else if (isGroup(f)) {\n <fieldset class=\"mk-dynamic-fields__group\" [style.--mk-dyn-span]=\"span(f)\" [disabled]=\"control(f).disabled\">\n @if (f.label) {\n <legend class=\"mk-dynamic-fields__legend\">{{ f.label }}</legend>\n }\n @if (f.hint) {\n <p class=\"mk-dynamic-fields__section-hint\">{{ f.hint }}</p>\n }\n <mk-dynamic-fields [fields]=\"f.fields\" [group]=\"formGroup(f)\" [columns]=\"columnsOf(f)\" [scope]=\"scope()\" />\n </fieldset>\n } @else if (isArray(f)) {\n <fieldset class=\"mk-dynamic-fields__array\" [style.--mk-dyn-span]=\"span(f)\" [disabled]=\"control(f).disabled\">\n @if (f.label) {\n <legend class=\"mk-dynamic-fields__legend\">{{ f.label }}</legend>\n }\n @if (f.hint) {\n <p class=\"mk-dynamic-fields__section-hint\">{{ f.hint }}</p>\n }\n @for (item of formArray(f).controls; track item; let i = $index) {\n <div class=\"mk-dynamic-fields__item\">\n <mk-dynamic-fields class=\"mk-dynamic-fields__item-fields\" [fields]=\"f.fields\" [group]=\"item\" [columns]=\"columnsOf(f)\" [scope]=\"itemScope(f, i)\" />\n <button\n mkButton\n type=\"button\"\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n iconOnly\n class=\"mk-dynamic-fields__remove\"\n [attr.aria-label]=\"i18n.dynamicFormRemove(i + 1)\"\n [title]=\"i18n.dynamicFormRemove(i + 1)\"\n [disabled]=\"!canRemove(f)\"\n (click)=\"removeItem(f, i)\"\n >\n <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M4 4l8 8M12 4l-8 8\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" />\n </svg>\n </button>\n </div>\n }\n <div class=\"mk-dynamic-fields__array-actions\">\n <button mkButton type=\"button\" variant=\"soft\" size=\"sm\" [disabled]=\"!canAdd(f)\" (click)=\"addItem(f)\">\n {{ f.addLabel || i18n.dynamicFormAdd }}\n </button>\n </div>\n </fieldset>\n } @else if (isValue(f)) {\n @let ctrl = control(f);\n @let custom = customTemplate(f);\n <mk-form-field\n class=\"mk-dynamic-fields__field\"\n [style.--mk-dyn-span]=\"span(f)\"\n [label]=\"f.type === 'checkbox' || f.type === 'switch' ? '' : (f.label ?? '')\"\n [hint]=\"f.hint ?? ''\"\n [required]=\"!!f.required\"\n [size]=\"size()\"\n [labelPosition]=\"labelPosition()\"\n >\n @if (custom) {\n <ng-container *ngTemplateOutlet=\"custom; context: customContext(f)\" />\n } @else {\n @switch (f.type) {\n @case ('textarea') {\n <textarea mkInput [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [rows]=\"p(f, 'rows', 3)\"></textarea>\n }\n @case ('password') {\n <mk-password-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [showStrength]=\"p(f, 'showStrength', false)\" [showRules]=\"p(f, 'showRules', false)\" [minLength]=\"p(f, 'minLength', 8)\" />\n }\n @case ('number') {\n <mk-number-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [min]=\"p(f, 'min', f.validators?.min ?? null)\" [max]=\"p(f, 'max', f.validators?.max ?? null)\" [step]=\"p(f, 'step', 1)\" />\n }\n @case ('currency') {\n <mk-currency-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [currency]=\"p(f, 'currency', 'USD')\" [locale]=\"p(f, 'locale', undefined)\" [min]=\"p(f, 'min', f.validators?.min ?? null)\" [max]=\"p(f, 'max', f.validators?.max ?? null)\" />\n }\n @case ('date') {\n <mk-date-picker [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [min]=\"p(f, 'min', null)\" [max]=\"p(f, 'max', null)\" [clearable]=\"p(f, 'clearable', true)\" />\n }\n @case ('time') {\n <mk-time-picker [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [step]=\"p(f, 'step', 15)\" [hour12]=\"p(f, 'hour12', false)\" [clearable]=\"p(f, 'clearable', true)\" />\n }\n @case ('datetime') {\n <mk-datetime-picker [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [min]=\"p(f, 'min', null)\" [max]=\"p(f, 'max', null)\" [clearable]=\"p(f, 'clearable', true)\" />\n }\n @case ('select') {\n <mk-select [formControl]=\"$any(ctrl)\" [options]=\"$any(f.options ?? [])\" [placeholder]=\"f.placeholder ?? ''\" />\n }\n @case ('multi-select') {\n <mk-multi-select [formControl]=\"$any(ctrl)\" [options]=\"$any(f.options ?? [])\" [placeholder]=\"f.placeholder ?? ''\" [max]=\"p(f, 'max', 0)\" />\n }\n @case ('autocomplete') {\n <mk-autocomplete [formControl]=\"$any(ctrl)\" [options]=\"$any(f.options ?? [])\" [placeholder]=\"f.placeholder ?? ''\" [requireSelection]=\"p(f, 'requireSelection', false)\" />\n }\n @case ('radio') {\n <mk-radio-group [formControl]=\"$any(ctrl)\" [orientation]=\"p(f, 'orientation', 'vertical')\">\n @for (o of f.options ?? []; track $index) {\n <mk-radio [value]=\"o.value\" [disabled]=\"!!o.disabled\">{{ o.label }}</mk-radio>\n }\n </mk-radio-group>\n }\n @case ('toggle') {\n <mk-button-toggle-group [formControl]=\"$any(ctrl)\" [multiple]=\"p(f, 'multiple', false)\" [aria-label]=\"f.label ?? ''\">\n @for (o of f.options ?? []; track $index) {\n <mk-button-toggle [value]=\"o.value\" [disabled]=\"!!o.disabled\">{{ o.label }}</mk-button-toggle>\n }\n </mk-button-toggle-group>\n }\n @case ('checkbox') {\n <mk-checkbox [formControl]=\"$any(ctrl)\" [required]=\"!!f.required\">{{ f.label }}</mk-checkbox>\n }\n @case ('switch') {\n <mk-switch [formControl]=\"$any(ctrl)\">{{ f.label }}</mk-switch>\n }\n @case ('slider') {\n <mk-slider [formControl]=\"$any(ctrl)\" [min]=\"p(f, 'min', f.validators?.min ?? 0)\" [max]=\"p(f, 'max', f.validators?.max ?? 100)\" [step]=\"p(f, 'step', 1)\" [aria-label]=\"f.label ?? ''\" />\n }\n @case ('rating') {\n <mk-rating [formControl]=\"$any(ctrl)\" [max]=\"p(f, 'max', 5)\" [ariaLabel]=\"f.label ?? ''\" />\n }\n @case ('color') {\n <mk-color-picker [formControl]=\"$any(ctrl)\" [swatches]=\"p(f, 'swatches', [])\" [ariaLabel]=\"f.label ?? ''\" />\n }\n @case ('tags') {\n <mk-tag-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [max]=\"p(f, 'max', 0)\" />\n }\n @case ('phone') {\n <mk-phone-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [valueFormat]=\"p(f, 'valueFormat', 'e164')\" [country]=\"p(f, 'country', undefined)\" />\n }\n @case ('file') {\n <mk-file-upload [formControl]=\"$any(ctrl)\" [accept]=\"p(f, 'accept', '')\" [multiple]=\"p(f, 'multiple', false)\" [maxSize]=\"p(f, 'maxSize', 0)\" [maxFiles]=\"p(f, 'maxFiles', 0)\" />\n }\n @case ('code') {\n <mk-code-editor [formControl]=\"$any(ctrl)\" [language]=\"p(f, 'language', 'json')\" [rows]=\"p(f, 'rows', 8)\" [placeholder]=\"f.placeholder ?? ''\" />\n }\n @default {\n <input\n mkInput\n [type]=\"inputType(f)\"\n [formControl]=\"$any(ctrl)\"\n [placeholder]=\"f.placeholder ?? ''\"\n [attr.maxlength]=\"f.validators?.maxLength ?? null\"\n />\n }\n }\n }\n </mk-form-field>\n }\n }\n}\n", dependencies: [{ kind: "component", type: i0.forwardRef(() => MkDynamicFields), selector: "mk-dynamic-fields", inputs: ["fields", "group", "columns", "scope"] }, { kind: "ngmodule", type: i0.forwardRef(() => ReactiveFormsModule) }, { kind: "directive", type: i0.forwardRef(() => i1.DefaultValueAccessor), selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i0.forwardRef(() => i1.NgControlStatus), selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i0.forwardRef(() => i1.RequiredValidator), selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i0.forwardRef(() => i1.FormControlDirective), selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i0.forwardRef(() => NgTemplateOutlet), selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i0.forwardRef(() => MkButton), selector: "button[mkButton], a[mkButton]", inputs: ["variant", "tone", "size", "loading", "fullWidth", "iconOnly", "disabled"] }, { kind: "component", type: i0.forwardRef(() => MkCheckbox), selector: "mk-checkbox", inputs: ["checked", "indeterminate", "disabled", "invalid", "required", "size", "tone", "aria-label"], outputs: ["checkedChange", "indeterminateChange"] }, { kind: "component", type: i0.forwardRef(() => MkFormField), selector: "mk-form-field", inputs: ["label", "hint", "error", "errorMessages", "errorOn", "required", "disabled", "size", "labelPosition"] }, { kind: "component", type: i0.forwardRef(() => MkInput), selector: "input[mkInput], textarea[mkInput]", inputs: ["size", "invalid"] }, { kind: "component", type: i0.forwardRef(() => MkNumberInput), selector: "mk-number-input", inputs: ["min", "max", "step", "value", "placeholder", "disabled", "invalid", "size"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => MkCurrencyInput), selector: "mk-currency-input", inputs: ["currency", "locale", "decimals", "min", "max", "allowNegative", "size", "invalid", "disabled", "placeholder", "value"], outputs: ["valueChange"], exportAs: ["mkCurrencyInput"] }, { kind: "component", type: i0.forwardRef(() => MkSelect), selector: "mk-select", inputs: ["options", "placeholder", "size", "invalid", "disabled", "value"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => MkMultiSelect), selector: "mk-multi-select", inputs: ["options", "placeholder", "size", "invalid", "disabled", "filterMode", "minChars", "loading", "max", "closeOnSelect", "emptyMessage", "value"], outputs: ["valueChange", "search", "optionAdded", "optionRemoved"] }, { kind: "component", type: i0.forwardRef(() => MkAutocomplete), selector: "mk-autocomplete", inputs: ["options", "placeholder", "size", "invalid", "disabled", "filterMode", "minChars", "loading", "requireSelection", "emptyMessage", "value"], outputs: ["valueChange", "search", "optionSelected"] }, { kind: "component", type: i0.forwardRef(() => MkRadioGroup), selector: "mk-radio-group", inputs: ["value", "disabled", "invalid", "required", "size", "tone", "name", "orientation"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => MkRadio), selector: "mk-radio", inputs: ["value", "disabled"] }, { kind: "component", type: i0.forwardRef(() => MkButtonToggleGroup), selector: "mk-button-toggle-group", inputs: ["multiple", "size", "tone", "disabled", "invalid", "aria-label", "value"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => MkButtonToggle), selector: "mk-button-toggle", inputs: ["value", "disabled"] }, { kind: "component", type: i0.forwardRef(() => MkSwitch), selector: "mk-switch", inputs: ["checked", "disabled", "invalid", "size", "tone", "aria-label"], outputs: ["checkedChange"] }, { kind: "component", type: i0.forwardRef(() => MkSlider), selector: "mk-slider", inputs: ["min", "max", "step", "disabled", "invalid", "size", "tone", "aria-label", "value"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => MkRating), selector: "mk-rating", inputs: ["max", "value", "readonly", "disabled", "invalid", "size", "ariaLabel"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => MkColorPicker), selector: "mk-color-picker", inputs: ["value", "swatches", "hexInput", "disabled", "invalid", "size", "ariaLabel"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => MkTagInput), selector: "mk-tag-input", inputs: ["value", "placeholder", "max", "allowDuplicates", "addOnBlur", "separators", "invalid", "disabled", "size"], outputs: ["valueChange", "added", "removed"] }, { kind: "component", type: i0.forwardRef(() => MkPhoneInput), selector: "mk-phone-input", inputs: ["countries", "preferredCountries", "valueFormat", "size", "invalid", "disabled", "placeholder", "country", "value"], outputs: ["countryChange", "valueChange"], exportAs: ["mkPhoneInput"] }, { kind: "component", type: i0.forwardRef(() => MkFileUpload), selector: "mk-file-upload", inputs: ["accept", "multiple", "maxSize", "maxFiles", "disabled", "invalid", "label", "hint", "hideList", "uploadFn", "autoUpload", "valueFormat", "files"], outputs: ["filesChange", "filesSelected", "rejected", "uploaded", "removed"] }, { kind: "component", type: i0.forwardRef(() => MkCodeEditor), selector: "mk-code-editor", inputs: ["language", "placeholder", "readOnly", "disabled", "invalid", "rows", "lineNumbers", "tabSize", "wrap", "size", "ariaLabel", "value"], outputs: ["valueChange", "validate"], exportAs: ["mkCodeEditor"] }, { kind: "component", type: i0.forwardRef(() => MkPasswordInput), selector: "mk-password-input", inputs: ["value", "placeholder", "disabled", "size", "invalid", "showStrength", "showRules", "minLength", "autocomplete"], outputs: ["valueChange"], exportAs: ["mkPasswordInput"] }, { kind: "component", type: i0.forwardRef(() => MkDatePicker), selector: "mk-date-picker", inputs: ["value", "min", "max", "disabledDate", "placeholder", "displayFormat", "disabled", "clearable", "invalid", "firstDayOfWeek", "size"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => MkTimePicker), selector: "mk-time-picker", inputs: ["value", "valueFormat", "min", "max", "step", "hour12", "disabled", "placeholder", "clearable", "invalid", "size"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => MkDateTimePicker), selector: "mk-datetime-picker", inputs: ["value", "min", "max", "disabledDate", "placeholder", "displayFormat", "step", "hour12", "disabled", "clearable", "invalid", "firstDayOfWeek", "size"], outputs: ["valueChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
314
|
+
}
|
|
315
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MkDynamicFields, decorators: [{
|
|
316
|
+
type: Component,
|
|
317
|
+
args: [{ selector: 'mk-dynamic-fields', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
318
|
+
ReactiveFormsModule,
|
|
319
|
+
NgTemplateOutlet,
|
|
320
|
+
MkButton,
|
|
321
|
+
MkCheckbox,
|
|
322
|
+
MkFormField,
|
|
323
|
+
MkInput,
|
|
324
|
+
MkNumberInput,
|
|
325
|
+
MkCurrencyInput,
|
|
326
|
+
MkSelect,
|
|
327
|
+
MkMultiSelect,
|
|
328
|
+
MkAutocomplete,
|
|
329
|
+
MkRadioGroup,
|
|
330
|
+
MkRadio,
|
|
331
|
+
MkButtonToggleGroup,
|
|
332
|
+
MkButtonToggle,
|
|
333
|
+
MkSwitch,
|
|
334
|
+
MkSlider,
|
|
335
|
+
MkRating,
|
|
336
|
+
MkColorPicker,
|
|
337
|
+
MkTagInput,
|
|
338
|
+
MkPhoneInput,
|
|
339
|
+
MkFileUpload,
|
|
340
|
+
MkCodeEditor,
|
|
341
|
+
MkPasswordInput,
|
|
342
|
+
MkDatePicker,
|
|
343
|
+
MkTimePicker,
|
|
344
|
+
MkDateTimePicker,
|
|
345
|
+
forwardRef(() => MkDynamicFields),
|
|
346
|
+
], host: {
|
|
347
|
+
class: 'mk-dynamic-fields',
|
|
348
|
+
'[style.--mk-dyn-columns]': 'columns()',
|
|
349
|
+
}, template: "@for (f of fields(); track f.type + ':' + ($any(f).key ?? $any(f).label ?? $index)) {\n @if (isVisible(f)) {\n @if (isSection(f)) {\n <div class=\"mk-dynamic-fields__section\" [style.--mk-dyn-span]=\"span(f)\">\n <h3 class=\"mk-dynamic-fields__section-title\">{{ f.label }}</h3>\n @if (f.hint) {\n <p class=\"mk-dynamic-fields__section-hint\">{{ f.hint }}</p>\n }\n </div>\n } @else if (isGroup(f)) {\n <fieldset class=\"mk-dynamic-fields__group\" [style.--mk-dyn-span]=\"span(f)\" [disabled]=\"control(f).disabled\">\n @if (f.label) {\n <legend class=\"mk-dynamic-fields__legend\">{{ f.label }}</legend>\n }\n @if (f.hint) {\n <p class=\"mk-dynamic-fields__section-hint\">{{ f.hint }}</p>\n }\n <mk-dynamic-fields [fields]=\"f.fields\" [group]=\"formGroup(f)\" [columns]=\"columnsOf(f)\" [scope]=\"scope()\" />\n </fieldset>\n } @else if (isArray(f)) {\n <fieldset class=\"mk-dynamic-fields__array\" [style.--mk-dyn-span]=\"span(f)\" [disabled]=\"control(f).disabled\">\n @if (f.label) {\n <legend class=\"mk-dynamic-fields__legend\">{{ f.label }}</legend>\n }\n @if (f.hint) {\n <p class=\"mk-dynamic-fields__section-hint\">{{ f.hint }}</p>\n }\n @for (item of formArray(f).controls; track item; let i = $index) {\n <div class=\"mk-dynamic-fields__item\">\n <mk-dynamic-fields class=\"mk-dynamic-fields__item-fields\" [fields]=\"f.fields\" [group]=\"item\" [columns]=\"columnsOf(f)\" [scope]=\"itemScope(f, i)\" />\n <button\n mkButton\n type=\"button\"\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n iconOnly\n class=\"mk-dynamic-fields__remove\"\n [attr.aria-label]=\"i18n.dynamicFormRemove(i + 1)\"\n [title]=\"i18n.dynamicFormRemove(i + 1)\"\n [disabled]=\"!canRemove(f)\"\n (click)=\"removeItem(f, i)\"\n >\n <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M4 4l8 8M12 4l-8 8\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" />\n </svg>\n </button>\n </div>\n }\n <div class=\"mk-dynamic-fields__array-actions\">\n <button mkButton type=\"button\" variant=\"soft\" size=\"sm\" [disabled]=\"!canAdd(f)\" (click)=\"addItem(f)\">\n {{ f.addLabel || i18n.dynamicFormAdd }}\n </button>\n </div>\n </fieldset>\n } @else if (isValue(f)) {\n @let ctrl = control(f);\n @let custom = customTemplate(f);\n <mk-form-field\n class=\"mk-dynamic-fields__field\"\n [style.--mk-dyn-span]=\"span(f)\"\n [label]=\"f.type === 'checkbox' || f.type === 'switch' ? '' : (f.label ?? '')\"\n [hint]=\"f.hint ?? ''\"\n [required]=\"!!f.required\"\n [size]=\"size()\"\n [labelPosition]=\"labelPosition()\"\n >\n @if (custom) {\n <ng-container *ngTemplateOutlet=\"custom; context: customContext(f)\" />\n } @else {\n @switch (f.type) {\n @case ('textarea') {\n <textarea mkInput [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [rows]=\"p(f, 'rows', 3)\"></textarea>\n }\n @case ('password') {\n <mk-password-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [showStrength]=\"p(f, 'showStrength', false)\" [showRules]=\"p(f, 'showRules', false)\" [minLength]=\"p(f, 'minLength', 8)\" />\n }\n @case ('number') {\n <mk-number-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [min]=\"p(f, 'min', f.validators?.min ?? null)\" [max]=\"p(f, 'max', f.validators?.max ?? null)\" [step]=\"p(f, 'step', 1)\" />\n }\n @case ('currency') {\n <mk-currency-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [currency]=\"p(f, 'currency', 'USD')\" [locale]=\"p(f, 'locale', undefined)\" [min]=\"p(f, 'min', f.validators?.min ?? null)\" [max]=\"p(f, 'max', f.validators?.max ?? null)\" />\n }\n @case ('date') {\n <mk-date-picker [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [min]=\"p(f, 'min', null)\" [max]=\"p(f, 'max', null)\" [clearable]=\"p(f, 'clearable', true)\" />\n }\n @case ('time') {\n <mk-time-picker [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [step]=\"p(f, 'step', 15)\" [hour12]=\"p(f, 'hour12', false)\" [clearable]=\"p(f, 'clearable', true)\" />\n }\n @case ('datetime') {\n <mk-datetime-picker [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [min]=\"p(f, 'min', null)\" [max]=\"p(f, 'max', null)\" [clearable]=\"p(f, 'clearable', true)\" />\n }\n @case ('select') {\n <mk-select [formControl]=\"$any(ctrl)\" [options]=\"$any(f.options ?? [])\" [placeholder]=\"f.placeholder ?? ''\" />\n }\n @case ('multi-select') {\n <mk-multi-select [formControl]=\"$any(ctrl)\" [options]=\"$any(f.options ?? [])\" [placeholder]=\"f.placeholder ?? ''\" [max]=\"p(f, 'max', 0)\" />\n }\n @case ('autocomplete') {\n <mk-autocomplete [formControl]=\"$any(ctrl)\" [options]=\"$any(f.options ?? [])\" [placeholder]=\"f.placeholder ?? ''\" [requireSelection]=\"p(f, 'requireSelection', false)\" />\n }\n @case ('radio') {\n <mk-radio-group [formControl]=\"$any(ctrl)\" [orientation]=\"p(f, 'orientation', 'vertical')\">\n @for (o of f.options ?? []; track $index) {\n <mk-radio [value]=\"o.value\" [disabled]=\"!!o.disabled\">{{ o.label }}</mk-radio>\n }\n </mk-radio-group>\n }\n @case ('toggle') {\n <mk-button-toggle-group [formControl]=\"$any(ctrl)\" [multiple]=\"p(f, 'multiple', false)\" [aria-label]=\"f.label ?? ''\">\n @for (o of f.options ?? []; track $index) {\n <mk-button-toggle [value]=\"o.value\" [disabled]=\"!!o.disabled\">{{ o.label }}</mk-button-toggle>\n }\n </mk-button-toggle-group>\n }\n @case ('checkbox') {\n <mk-checkbox [formControl]=\"$any(ctrl)\" [required]=\"!!f.required\">{{ f.label }}</mk-checkbox>\n }\n @case ('switch') {\n <mk-switch [formControl]=\"$any(ctrl)\">{{ f.label }}</mk-switch>\n }\n @case ('slider') {\n <mk-slider [formControl]=\"$any(ctrl)\" [min]=\"p(f, 'min', f.validators?.min ?? 0)\" [max]=\"p(f, 'max', f.validators?.max ?? 100)\" [step]=\"p(f, 'step', 1)\" [aria-label]=\"f.label ?? ''\" />\n }\n @case ('rating') {\n <mk-rating [formControl]=\"$any(ctrl)\" [max]=\"p(f, 'max', 5)\" [ariaLabel]=\"f.label ?? ''\" />\n }\n @case ('color') {\n <mk-color-picker [formControl]=\"$any(ctrl)\" [swatches]=\"p(f, 'swatches', [])\" [ariaLabel]=\"f.label ?? ''\" />\n }\n @case ('tags') {\n <mk-tag-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [max]=\"p(f, 'max', 0)\" />\n }\n @case ('phone') {\n <mk-phone-input [formControl]=\"$any(ctrl)\" [placeholder]=\"f.placeholder ?? ''\" [valueFormat]=\"p(f, 'valueFormat', 'e164')\" [country]=\"p(f, 'country', undefined)\" />\n }\n @case ('file') {\n <mk-file-upload [formControl]=\"$any(ctrl)\" [accept]=\"p(f, 'accept', '')\" [multiple]=\"p(f, 'multiple', false)\" [maxSize]=\"p(f, 'maxSize', 0)\" [maxFiles]=\"p(f, 'maxFiles', 0)\" />\n }\n @case ('code') {\n <mk-code-editor [formControl]=\"$any(ctrl)\" [language]=\"p(f, 'language', 'json')\" [rows]=\"p(f, 'rows', 8)\" [placeholder]=\"f.placeholder ?? ''\" />\n }\n @default {\n <input\n mkInput\n [type]=\"inputType(f)\"\n [formControl]=\"$any(ctrl)\"\n [placeholder]=\"f.placeholder ?? ''\"\n [attr.maxlength]=\"f.validators?.maxLength ?? null\"\n />\n }\n }\n }\n </mk-form-field>\n }\n }\n}\n" }]
|
|
350
|
+
}], propDecorators: { fields: [{ type: i0.Input, args: [{ isSignal: true, alias: "fields", required: true }] }], group: [{ type: i0.Input, args: [{ isSignal: true, alias: "group", required: true }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: false }] }], scope: [{ type: i0.Input, args: [{ isSignal: true, alias: "scope", required: true }] }] } });
|
|
351
|
+
/**
|
|
352
|
+
* Dynamic form — renders a form from a JSON schema and manages one reactive
|
|
353
|
+
* `FormGroup` for it. Every value field renders inside `mk-form-field`, so
|
|
354
|
+
* labels, hints, required marks and localised validation messages come from
|
|
355
|
+
* the schema alone.
|
|
356
|
+
*
|
|
357
|
+
* ```html
|
|
358
|
+
* <mk-dynamic-form [schema]="schema" [(value)]="user" (formSubmit)="save($event)">
|
|
359
|
+
* <button mkButton type="submit">Save</button>
|
|
360
|
+
* </mk-dynamic-form>
|
|
361
|
+
* ```
|
|
362
|
+
*
|
|
363
|
+
* ```ts
|
|
364
|
+
* schema: MkDynamicSchema = {
|
|
365
|
+
* columns: 2,
|
|
366
|
+
* fields: [
|
|
367
|
+
* { key: 'name', type: 'text', label: 'Name', required: true },
|
|
368
|
+
* { key: 'role', type: 'select', label: 'Role', options: roles },
|
|
369
|
+
* { key: 'company', type: 'text', label: 'Company', showWhen: { field: 'role', eq: 'b2b' } },
|
|
370
|
+
* ],
|
|
371
|
+
* };
|
|
372
|
+
* ```
|
|
373
|
+
*
|
|
374
|
+
* - Hidden fields (`showWhen` false) are disabled, so `value` only carries
|
|
375
|
+
* what the user can see; `form.getRawValue()` has everything.
|
|
376
|
+
* - `form` is the live `FormGroup` for anything the schema does not cover.
|
|
377
|
+
* - Custom field types: project an `ng-template[mkDynamicField]`.
|
|
378
|
+
*/
|
|
379
|
+
class MkDynamicForm {
|
|
380
|
+
destroyRef = inject(DestroyRef);
|
|
381
|
+
/** The schema. Changing it rebuilds the form (values of surviving keys are kept). */
|
|
382
|
+
schema = input.required(/* @ts-ignore */
|
|
383
|
+
...(ngDevMode ? [{ debugName: "schema" }] : /* istanbul ignore next */ []));
|
|
384
|
+
/** Two-way form value (visible, enabled fields only). */
|
|
385
|
+
value = model({}, /* @ts-ignore */
|
|
386
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
387
|
+
/** Disable every control. */
|
|
388
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
389
|
+
/** Label placement forwarded to every `mk-form-field`. */
|
|
390
|
+
labelPosition = input('top', /* @ts-ignore */
|
|
391
|
+
...(ngDevMode ? [{ debugName: "labelPosition" }] : /* istanbul ignore next */ []));
|
|
392
|
+
/** Control size forwarded to the fields. */
|
|
393
|
+
size = input('md', /* @ts-ignore */
|
|
394
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
395
|
+
/** Emits the value when the form is submitted and valid. */
|
|
396
|
+
formSubmit = output();
|
|
397
|
+
/** Emits when a submit is attempted while invalid (every control is marked touched). */
|
|
398
|
+
invalidSubmit = output();
|
|
399
|
+
defs = contentChildren(MkDynamicFieldDef, { ...(ngDevMode ? { debugName: "defs" } : /* istanbul ignore next */ {}), descendants: true });
|
|
400
|
+
formSignal = signal(new FormGroup({}), /* @ts-ignore */
|
|
401
|
+
...(ngDevMode ? [{ debugName: "formSignal" }] : /* istanbul ignore next */ []));
|
|
402
|
+
formValue = signal({}, /* @ts-ignore */
|
|
403
|
+
...(ngDevMode ? [{ debugName: "formValue" }] : /* istanbul ignore next */ []));
|
|
404
|
+
subscription = null;
|
|
405
|
+
applying = false;
|
|
406
|
+
/** The live reactive form. */
|
|
407
|
+
get form() {
|
|
408
|
+
return this.formSignal();
|
|
409
|
+
}
|
|
410
|
+
formRef = computed(() => this.formSignal(), /* @ts-ignore */
|
|
411
|
+
...(ngDevMode ? [{ debugName: "formRef" }] : /* istanbul ignore next */ []));
|
|
412
|
+
/** Value including disabled fields — what conditions are evaluated against. */
|
|
413
|
+
scope = computed(() => this.formValue(), /* @ts-ignore */
|
|
414
|
+
...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
|
|
415
|
+
columns = computed(() => this.schema().columns ?? 1, /* @ts-ignore */
|
|
416
|
+
...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
417
|
+
fields = computed(() => this.schema().fields, /* @ts-ignore */
|
|
418
|
+
...(ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []));
|
|
419
|
+
/** `true` while every control passes validation. */
|
|
420
|
+
valid = computed(() => {
|
|
421
|
+
this.formValue();
|
|
422
|
+
return this.formSignal().valid;
|
|
423
|
+
}, /* @ts-ignore */
|
|
424
|
+
...(ngDevMode ? [{ debugName: "valid" }] : /* istanbul ignore next */ []));
|
|
425
|
+
constructor() {
|
|
426
|
+
// Rebuild on schema change, keeping the current value where keys survive.
|
|
427
|
+
effect(() => {
|
|
428
|
+
const schema = this.schema();
|
|
429
|
+
const current = untracked(() => ({ ...this.formValue(), ...this.value() }));
|
|
430
|
+
const form = mkDynamicForm(schema, current);
|
|
431
|
+
untracked(() => this.attach(form));
|
|
432
|
+
});
|
|
433
|
+
// External value → form.
|
|
434
|
+
effect(() => {
|
|
435
|
+
const v = this.value();
|
|
436
|
+
untracked(() => {
|
|
437
|
+
if (this.applying)
|
|
438
|
+
return;
|
|
439
|
+
const form = this.formSignal();
|
|
440
|
+
if (!shallowEqual(v, form.value)) {
|
|
441
|
+
form.patchValue(v ?? {}, { emitEvent: true });
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
// Disabled input.
|
|
446
|
+
effect(() => {
|
|
447
|
+
const disabled = this.disabled();
|
|
448
|
+
untracked(() => {
|
|
449
|
+
const form = this.formSignal();
|
|
450
|
+
if (disabled)
|
|
451
|
+
form.disable({ emitEvent: false });
|
|
452
|
+
else
|
|
453
|
+
form.enable({ emitEvent: false });
|
|
454
|
+
this.applyConditions(form, this.schema().fields, form.getRawValue());
|
|
455
|
+
this.sync();
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
this.destroyRef.onDestroy(() => this.subscription?.unsubscribe());
|
|
459
|
+
}
|
|
460
|
+
attach(form) {
|
|
461
|
+
this.subscription?.unsubscribe();
|
|
462
|
+
this.subscription = form.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.sync());
|
|
463
|
+
this.formSignal.set(form);
|
|
464
|
+
if (this.disabled())
|
|
465
|
+
form.disable({ emitEvent: false });
|
|
466
|
+
this.sync();
|
|
467
|
+
}
|
|
468
|
+
/** Re-evaluate conditions and push the form value to `value`. @internal */
|
|
469
|
+
sync() {
|
|
470
|
+
const form = this.formSignal();
|
|
471
|
+
const raw = form.getRawValue();
|
|
472
|
+
this.applyConditions(form, this.schema().fields, raw);
|
|
473
|
+
this.formValue.set(raw);
|
|
474
|
+
const visible = form.value;
|
|
475
|
+
if (!shallowEqual(visible, this.value())) {
|
|
476
|
+
this.applying = true;
|
|
477
|
+
try {
|
|
478
|
+
this.value.set(visible);
|
|
479
|
+
}
|
|
480
|
+
finally {
|
|
481
|
+
this.applying = false;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
applyConditions(group, fields, scope) {
|
|
486
|
+
if (this.disabled())
|
|
487
|
+
return;
|
|
488
|
+
for (const f of fields) {
|
|
489
|
+
if (mkIsSection(f))
|
|
490
|
+
continue;
|
|
491
|
+
const ctrl = group.get(f.key);
|
|
492
|
+
if (!ctrl)
|
|
493
|
+
continue;
|
|
494
|
+
const visible = mkDynamicCondition(f.showWhen, scope);
|
|
495
|
+
const disabled = !visible || mkDynamicCondition(f.disabledWhen ?? (() => false), scope) || (mkIsValueField(f) && !!f.disabled);
|
|
496
|
+
if (disabled && ctrl.enabled)
|
|
497
|
+
ctrl.disable({ emitEvent: false });
|
|
498
|
+
else if (!disabled && ctrl.disabled)
|
|
499
|
+
ctrl.enable({ emitEvent: false });
|
|
500
|
+
if (visible && mkIsGroup(f))
|
|
501
|
+
this.applyConditions(ctrl, f.fields, scope);
|
|
502
|
+
if (visible && mkIsArray(f)) {
|
|
503
|
+
for (const item of ctrl.controls) {
|
|
504
|
+
this.applyConditions(item, f.fields, { ...item.getRawValue(), $root: scope });
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
/** Template registered for a custom type / renderer name. @internal */
|
|
510
|
+
templateFor(name) {
|
|
511
|
+
return this.defs().find((d) => d.mkDynamicField() === name)?.template ?? null;
|
|
512
|
+
}
|
|
513
|
+
/** Patch part of the value. */
|
|
514
|
+
patch(value) {
|
|
515
|
+
this.form.patchValue(value);
|
|
516
|
+
this.sync();
|
|
517
|
+
}
|
|
518
|
+
/** Reset to the schema defaults (or the given value). */
|
|
519
|
+
reset(value) {
|
|
520
|
+
const form = mkDynamicForm(this.schema(), value);
|
|
521
|
+
this.attach(form);
|
|
522
|
+
}
|
|
523
|
+
/** Mark every control touched so validation messages show. */
|
|
524
|
+
touchAll() {
|
|
525
|
+
this.form.markAllAsTouched();
|
|
526
|
+
this.formValue.set({ ...this.form.getRawValue() });
|
|
527
|
+
}
|
|
528
|
+
onSubmit(event) {
|
|
529
|
+
event.preventDefault();
|
|
530
|
+
const form = this.form;
|
|
531
|
+
if (form.valid) {
|
|
532
|
+
this.formSubmit.emit(form.value);
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
this.touchAll();
|
|
536
|
+
this.invalidSubmit.emit(form);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MkDynamicForm, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
540
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.7", type: MkDynamicForm, isStandalone: true, selector: "mk-dynamic-form", inputs: { schema: { classPropertyName: "schema", publicName: "schema", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, labelPosition: { classPropertyName: "labelPosition", publicName: "labelPosition", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", formSubmit: "formSubmit", invalidSubmit: "invalidSubmit" }, host: { properties: { "class.mk-dynamic-form--disabled": "disabled()" }, classAttribute: "mk-dynamic-form" }, queries: [{ propertyName: "defs", predicate: MkDynamicFieldDef, descendants: true, isSignal: true }], ngImport: i0, template: "<form class=\"mk-dynamic-form__form\" [formGroup]=\"formRef()\" (submit)=\"onSubmit($event)\" novalidate>\n <mk-dynamic-fields [fields]=\"fields()\" [group]=\"formRef()\" [columns]=\"columns()\" [scope]=\"scope()\" />\n <div class=\"mk-dynamic-form__actions\">\n <ng-content />\n </div>\n</form>\n", styles: [":host{display:block}.mk-dynamic-form__form{display:flex;flex-direction:column;gap:var(--mk-space-4)}.mk-dynamic-form__actions:empty{display:none}.mk-dynamic-form__actions{display:flex;flex-wrap:wrap;gap:var(--mk-space-2)}:host ::ng-deep .mk-dynamic-fields{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--mk-space-4) var(--mk-space-4);min-width:0}:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__field,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__section,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__group,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__array{grid-column:span var(--mk-dyn-span, 12);min-width:0}@media(max-width:640px){:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__field,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__section,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__group,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__array{grid-column:span 12}}:host ::ng-deep .mk-dynamic-fields__section{padding-top:var(--mk-space-2)}:host ::ng-deep .mk-dynamic-fields__section-title{margin:0;font-size:var(--mk-font-size-md);font-weight:var(--mk-font-weight-semibold);color:var(--mk-text)}:host ::ng-deep .mk-dynamic-fields__section-hint{margin:var(--mk-space-1) 0 0;font-size:var(--mk-font-size-sm);color:var(--mk-text-muted)}:host ::ng-deep .mk-dynamic-fields__group,:host ::ng-deep .mk-dynamic-fields__array{margin:0;padding:var(--mk-space-4);border:1px solid var(--mk-border);border-radius:var(--mk-radius-lg);min-width:0}:host ::ng-deep .mk-dynamic-fields__legend{padding:0 var(--mk-space-2);font-size:var(--mk-font-size-sm);font-weight:var(--mk-font-weight-semibold);color:var(--mk-text)}:host ::ng-deep .mk-dynamic-fields__group>.mk-dynamic-fields__section-hint,:host ::ng-deep .mk-dynamic-fields__array>.mk-dynamic-fields__section-hint{margin:0 0 var(--mk-space-3)}:host ::ng-deep .mk-dynamic-fields__item{display:flex;align-items:flex-start;gap:var(--mk-space-2);padding:var(--mk-space-3) 0;border-bottom:1px dashed var(--mk-border)}:host ::ng-deep .mk-dynamic-fields__item:first-of-type{padding-top:0}:host ::ng-deep .mk-dynamic-fields__item-fields{flex:1;min-width:0}:host ::ng-deep .mk-dynamic-fields__remove{flex:none;margin-top:var(--mk-space-6)}:host ::ng-deep .mk-dynamic-fields__array-actions{padding-top:var(--mk-space-3)}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: MkDynamicFields, selector: "mk-dynamic-fields", inputs: ["fields", "group", "columns", "scope"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
541
|
+
}
|
|
542
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MkDynamicForm, decorators: [{
|
|
543
|
+
type: Component,
|
|
544
|
+
args: [{ selector: 'mk-dynamic-form', changeDetection: ChangeDetectionStrategy.OnPush, imports: [ReactiveFormsModule, MkDynamicFields], host: {
|
|
545
|
+
class: 'mk-dynamic-form',
|
|
546
|
+
'[class.mk-dynamic-form--disabled]': 'disabled()',
|
|
547
|
+
}, template: "<form class=\"mk-dynamic-form__form\" [formGroup]=\"formRef()\" (submit)=\"onSubmit($event)\" novalidate>\n <mk-dynamic-fields [fields]=\"fields()\" [group]=\"formRef()\" [columns]=\"columns()\" [scope]=\"scope()\" />\n <div class=\"mk-dynamic-form__actions\">\n <ng-content />\n </div>\n</form>\n", styles: [":host{display:block}.mk-dynamic-form__form{display:flex;flex-direction:column;gap:var(--mk-space-4)}.mk-dynamic-form__actions:empty{display:none}.mk-dynamic-form__actions{display:flex;flex-wrap:wrap;gap:var(--mk-space-2)}:host ::ng-deep .mk-dynamic-fields{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--mk-space-4) var(--mk-space-4);min-width:0}:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__field,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__section,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__group,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__array{grid-column:span var(--mk-dyn-span, 12);min-width:0}@media(max-width:640px){:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__field,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__section,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__group,:host ::ng-deep .mk-dynamic-fields>.mk-dynamic-fields__array{grid-column:span 12}}:host ::ng-deep .mk-dynamic-fields__section{padding-top:var(--mk-space-2)}:host ::ng-deep .mk-dynamic-fields__section-title{margin:0;font-size:var(--mk-font-size-md);font-weight:var(--mk-font-weight-semibold);color:var(--mk-text)}:host ::ng-deep .mk-dynamic-fields__section-hint{margin:var(--mk-space-1) 0 0;font-size:var(--mk-font-size-sm);color:var(--mk-text-muted)}:host ::ng-deep .mk-dynamic-fields__group,:host ::ng-deep .mk-dynamic-fields__array{margin:0;padding:var(--mk-space-4);border:1px solid var(--mk-border);border-radius:var(--mk-radius-lg);min-width:0}:host ::ng-deep .mk-dynamic-fields__legend{padding:0 var(--mk-space-2);font-size:var(--mk-font-size-sm);font-weight:var(--mk-font-weight-semibold);color:var(--mk-text)}:host ::ng-deep .mk-dynamic-fields__group>.mk-dynamic-fields__section-hint,:host ::ng-deep .mk-dynamic-fields__array>.mk-dynamic-fields__section-hint{margin:0 0 var(--mk-space-3)}:host ::ng-deep .mk-dynamic-fields__item{display:flex;align-items:flex-start;gap:var(--mk-space-2);padding:var(--mk-space-3) 0;border-bottom:1px dashed var(--mk-border)}:host ::ng-deep .mk-dynamic-fields__item:first-of-type{padding-top:0}:host ::ng-deep .mk-dynamic-fields__item-fields{flex:1;min-width:0}:host ::ng-deep .mk-dynamic-fields__remove{flex:none;margin-top:var(--mk-space-6)}:host ::ng-deep .mk-dynamic-fields__array-actions{padding-top:var(--mk-space-3)}\n"] }]
|
|
548
|
+
}], ctorParameters: () => [], propDecorators: { schema: [{ type: i0.Input, args: [{ isSignal: true, alias: "schema", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], labelPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelPosition", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], formSubmit: [{ type: i0.Output, args: ["formSubmit"] }], invalidSubmit: [{ type: i0.Output, args: ["invalidSubmit"] }], defs: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => MkDynamicFieldDef), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
549
|
+
function shallowEqual(a, b) {
|
|
550
|
+
if (a === b)
|
|
551
|
+
return true;
|
|
552
|
+
if (!a || !b || typeof a !== 'object' || typeof b !== 'object')
|
|
553
|
+
return false;
|
|
554
|
+
const ka = Object.keys(a);
|
|
555
|
+
const kb = Object.keys(b);
|
|
556
|
+
if (ka.length !== kb.length)
|
|
557
|
+
return false;
|
|
558
|
+
for (const k of ka) {
|
|
559
|
+
const x = a[k];
|
|
560
|
+
const y = b[k];
|
|
561
|
+
if (x === y)
|
|
562
|
+
continue;
|
|
563
|
+
if (x && y && typeof x === 'object' && typeof y === 'object') {
|
|
564
|
+
if (JSON.stringify(x) !== JSON.stringify(y))
|
|
565
|
+
return false;
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
return true;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Generated bundle index. Do not edit.
|
|
575
|
+
*/
|
|
576
|
+
|
|
577
|
+
export { MkDynamicFieldDef, MkDynamicFields, MkDynamicForm, mkDynamicCondition, mkDynamicControl, mkDynamicDefaults, mkDynamicEmptyValue, mkDynamicFlatten, mkDynamicForm, mkDynamicGroup, mkDynamicSpan, mkDynamicValidators, mkIsArray, mkIsGroup, mkIsSection, mkIsValueField };
|
|
578
|
+
//# sourceMappingURL=mk-kit-ui-dynamic-form.mjs.map
|