@3kles/kles-material-dynamicforms 22.1.0 → 22.1.1
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.
|
@@ -2131,6 +2131,175 @@ class KlesFormArray extends KlesFormControl {
|
|
|
2131
2131
|
}
|
|
2132
2132
|
}
|
|
2133
2133
|
|
|
2134
|
+
class ArrayUiState extends AbstractUiState {
|
|
2135
|
+
constructor(states) {
|
|
2136
|
+
super();
|
|
2137
|
+
this.states = [];
|
|
2138
|
+
this.states = states ?? [];
|
|
2139
|
+
this.states.forEach((state, index) => {
|
|
2140
|
+
state.setParent(this, index);
|
|
2141
|
+
});
|
|
2142
|
+
this._value.set(this.states.map((state) => state.value()));
|
|
2143
|
+
}
|
|
2144
|
+
setValue(value) {
|
|
2145
|
+
if (!Array.isArray(value)) {
|
|
2146
|
+
return;
|
|
2147
|
+
}
|
|
2148
|
+
value.forEach((newValue, index) => {
|
|
2149
|
+
this.at(index)?.setValue(newValue);
|
|
2150
|
+
});
|
|
2151
|
+
this._value.set(value);
|
|
2152
|
+
this.notifyParent();
|
|
2153
|
+
}
|
|
2154
|
+
patchValue(value) {
|
|
2155
|
+
if (value == null) {
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
value.forEach((newValue, index) => {
|
|
2159
|
+
const st = this.at(index);
|
|
2160
|
+
if (st) {
|
|
2161
|
+
st.patchValue(newValue);
|
|
2162
|
+
}
|
|
2163
|
+
});
|
|
2164
|
+
const curr = this._value() ?? [];
|
|
2165
|
+
const next = [...curr];
|
|
2166
|
+
value.forEach((newValue, index) => {
|
|
2167
|
+
next[index] = {
|
|
2168
|
+
...(next[index] ?? {}),
|
|
2169
|
+
...newValue,
|
|
2170
|
+
};
|
|
2171
|
+
});
|
|
2172
|
+
this._value.set(next);
|
|
2173
|
+
this.notifyParent();
|
|
2174
|
+
}
|
|
2175
|
+
childValueChanged(key, value) {
|
|
2176
|
+
const index = typeof key === 'number' ? key : Number(key);
|
|
2177
|
+
if (!Number.isInteger(index) || index < 0)
|
|
2178
|
+
return;
|
|
2179
|
+
const curr = this._value() ?? [];
|
|
2180
|
+
const next = [...curr];
|
|
2181
|
+
next[index] = value;
|
|
2182
|
+
this._value.set(next);
|
|
2183
|
+
this.notifyParent();
|
|
2184
|
+
}
|
|
2185
|
+
at(index) {
|
|
2186
|
+
return this.states?.[index] ?? null;
|
|
2187
|
+
}
|
|
2188
|
+
_find(name) {
|
|
2189
|
+
const idx = typeof name === 'number' ? name : Number(name);
|
|
2190
|
+
return Number.isFinite(idx) ? this.at(idx) : null;
|
|
2191
|
+
}
|
|
2192
|
+
push(control) {
|
|
2193
|
+
const items = Array.isArray(control) ? control : [control];
|
|
2194
|
+
if (items.length === 0) {
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2197
|
+
for (const item of items) {
|
|
2198
|
+
const index = this.states.length;
|
|
2199
|
+
this.states.push(item);
|
|
2200
|
+
item.setParent(this, index);
|
|
2201
|
+
}
|
|
2202
|
+
this._value.set(this.states.map((s) => s.value()));
|
|
2203
|
+
this.notifyParent();
|
|
2204
|
+
}
|
|
2205
|
+
insert(index, state) {
|
|
2206
|
+
const items = Array.isArray(state) ? state : [state];
|
|
2207
|
+
if (items.length === 0) {
|
|
2208
|
+
return;
|
|
2209
|
+
}
|
|
2210
|
+
const safeIndex = Math.max(0, Math.min(index, this.states.length));
|
|
2211
|
+
this.states.splice(safeIndex, 0, ...items);
|
|
2212
|
+
for (let i = safeIndex; i < this.states.length; i++) {
|
|
2213
|
+
this.states[i]?.setParent(this, i);
|
|
2214
|
+
}
|
|
2215
|
+
const curr = this._value();
|
|
2216
|
+
const next = [...curr];
|
|
2217
|
+
next.splice(safeIndex, 0, ...items.map((item) => item.value()));
|
|
2218
|
+
this._value.set(next);
|
|
2219
|
+
this.notifyParent();
|
|
2220
|
+
}
|
|
2221
|
+
removeAt(index) {
|
|
2222
|
+
if (index < 0 || index >= this.states.length)
|
|
2223
|
+
return;
|
|
2224
|
+
this.states.splice(index, 1);
|
|
2225
|
+
this.states.forEach((state, i) => {
|
|
2226
|
+
state.setParent(this, i);
|
|
2227
|
+
});
|
|
2228
|
+
const curr = this._value() ?? [];
|
|
2229
|
+
const next = [...curr];
|
|
2230
|
+
next.splice(index, 1);
|
|
2231
|
+
this._value.set(next);
|
|
2232
|
+
this.notifyParent();
|
|
2233
|
+
}
|
|
2234
|
+
clear() {
|
|
2235
|
+
this.states.length = 0;
|
|
2236
|
+
this._value.set([]);
|
|
2237
|
+
this.notifyParent();
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
class KlesFormUiArray extends KlesFormUiControl {
|
|
2242
|
+
create() {
|
|
2243
|
+
const array = new ArrayUiState();
|
|
2244
|
+
if (this.field.value && Array.isArray(this.field.value)) {
|
|
2245
|
+
if (this.field.collections && Array.isArray(this.field.collections)) {
|
|
2246
|
+
this.field.value.forEach(() => {
|
|
2247
|
+
const group = new GroupUiState();
|
|
2248
|
+
this.field.collections?.forEach((subfield) => {
|
|
2249
|
+
let control;
|
|
2250
|
+
if (subfield.type) {
|
|
2251
|
+
control = componentMapper.find((c) => c.type === subfield.type)?.ui(subfield) || klesFieldUiFactory(subfield);
|
|
2252
|
+
}
|
|
2253
|
+
else {
|
|
2254
|
+
control = componentMapper.find((c) => c.component === subfield.component)?.ui(subfield) || klesFieldUiFactory(subfield);
|
|
2255
|
+
}
|
|
2256
|
+
group.addUiState(subfield.name, control);
|
|
2257
|
+
});
|
|
2258
|
+
array.push(group);
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
else {
|
|
2263
|
+
const group = new GroupUiState();
|
|
2264
|
+
this.field.collections?.forEach((subfield) => {
|
|
2265
|
+
let control;
|
|
2266
|
+
if (subfield.type) {
|
|
2267
|
+
control = componentMapper.find((c) => c.type === subfield.type)?.ui(subfield) || klesFieldUiFactory(subfield);
|
|
2268
|
+
}
|
|
2269
|
+
else {
|
|
2270
|
+
control = componentMapper.find((c) => c.component === subfield.component)?.ui(subfield) || klesFieldUiFactory(subfield);
|
|
2271
|
+
}
|
|
2272
|
+
group.addUiState(subfield.name, control);
|
|
2273
|
+
});
|
|
2274
|
+
array.push(group);
|
|
2275
|
+
}
|
|
2276
|
+
return array;
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
class KlesFormUiGroup extends KlesFormUiControl {
|
|
2281
|
+
create() {
|
|
2282
|
+
const subGroup = new GroupUiState();
|
|
2283
|
+
if (this.field.collections && Array.isArray(this.field.collections)) {
|
|
2284
|
+
this.field.collections.forEach((subfield) => {
|
|
2285
|
+
let ui;
|
|
2286
|
+
if (subfield.type) {
|
|
2287
|
+
ui =
|
|
2288
|
+
componentMapper.find((c) => c.type === subfield.type)?.ui({ ...subfield, value: subfield.value || this.field.value?.[subfield.name] }) ||
|
|
2289
|
+
klesFieldUiFactory({ ...subfield, value: subfield.value || this.field.value?.[subfield.name] });
|
|
2290
|
+
}
|
|
2291
|
+
else {
|
|
2292
|
+
ui =
|
|
2293
|
+
componentMapper.find((c) => c.component === subfield.component)?.ui({ ...subfield, value: subfield.value || this.field.value?.[subfield.name] }) ||
|
|
2294
|
+
klesFieldUiFactory({ ...subfield, value: subfield.value || this.field.value?.[subfield.name] });
|
|
2295
|
+
}
|
|
2296
|
+
subGroup.addUiState(subfield.name, ui);
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
return subGroup;
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2134
2303
|
let KlesFormListFieldComponent = class KlesFormListFieldComponent extends KlesFieldAbstract {
|
|
2135
2304
|
constructor() {
|
|
2136
2305
|
super();
|
|
@@ -2143,8 +2312,12 @@ let KlesFormListFieldComponent = class KlesFormListFieldComponent extends KlesFi
|
|
|
2143
2312
|
}));
|
|
2144
2313
|
}
|
|
2145
2314
|
ngOnInit() {
|
|
2315
|
+
this.subUi = this.ui?.get(this.field.name);
|
|
2146
2316
|
super.ngOnInit();
|
|
2147
2317
|
}
|
|
2318
|
+
getRowUi(index) {
|
|
2319
|
+
return this.subUi.at(index);
|
|
2320
|
+
}
|
|
2148
2321
|
get hasLayout() {
|
|
2149
2322
|
return (this.field.collections ?? []).some((subfield) => subfield.layout != null);
|
|
2150
2323
|
}
|
|
@@ -2155,10 +2328,12 @@ let KlesFormListFieldComponent = class KlesFormListFieldComponent extends KlesFi
|
|
|
2155
2328
|
return this.field.direction ?? 'row';
|
|
2156
2329
|
}
|
|
2157
2330
|
deleteField(index) {
|
|
2331
|
+
this.subUi.removeAt(index);
|
|
2158
2332
|
this.formArray.removeAt(index);
|
|
2159
2333
|
this.collections.update((collections) => collections.filter((_, currentIndex) => currentIndex !== index));
|
|
2160
2334
|
}
|
|
2161
2335
|
addField() {
|
|
2336
|
+
this.subUi.push(new KlesFormUiGroup({ ...this.field, value: undefined }).create());
|
|
2162
2337
|
this.formArray.push(createKlesFormArrayGroup(this.field));
|
|
2163
2338
|
this.collections.update((collections) => [...collections, cloneDeep(this.field.collections ?? [])]);
|
|
2164
2339
|
}
|
|
@@ -2216,7 +2391,7 @@ let KlesFormListFieldComponent = class KlesFormListFieldComponent extends KlesFi
|
|
|
2216
2391
|
>
|
|
2217
2392
|
@for (subfield of collections()[idx]; track subfield.name) {
|
|
2218
2393
|
<div class="list-field__field" [style.grid-column]="getGridColumn(subfield)" [style.grid-row]="getGridRow(subfield)">
|
|
2219
|
-
<ng-container klesDynamicField [field]="subfield" [group]="subGroup" [siblingFields]="collections()[idx]" [context]="context" />
|
|
2394
|
+
<ng-container klesDynamicField [field]="subfield" [group]="subGroup" [siblingFields]="collections()[idx]" [ui]="getRowUi(idx)" [context]="context" />
|
|
2220
2395
|
</div>
|
|
2221
2396
|
}
|
|
2222
2397
|
</div>
|
|
@@ -2241,7 +2416,7 @@ let KlesFormListFieldComponent = class KlesFormListFieldComponent extends KlesFi
|
|
|
2241
2416
|
`, isInline: true, styles: [":host{display:block;width:100%;min-width:0}.list-field{display:flex;flex-direction:column;gap:8px;width:100%;min-width:0}.list-field__header{display:flex;align-items:center;gap:8px;min-height:36px}.list-field__label{min-width:0;font-weight:500}.list-field__add{margin-left:auto;flex-shrink:0}.list-field__content{display:flex;flex-direction:column;gap:10px;width:100%;min-width:0}.list-field__row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:8px;width:100%;min-width:0}.list-field__fields{width:100%;min-width:0}.list-field__fields--column{display:flex;flex-direction:column;gap:10px}.list-field__fields--column>.list-field__field{width:100%}.list-field__fields--row{display:flex;flex-direction:row;flex-wrap:wrap;align-items:baseline;gap:10px}.list-field__fields--row>.list-field__field{flex:1 1 0;width:auto;min-width:0}.list-field__fields--row.list-field__fields--nowrap{flex-wrap:nowrap}.list-field__fields--grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:12px}.list-field__fields--inline-grid{display:inline-grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:12px}.list-field__field{width:100%;min-width:0}.list-field__delete{align-self:start;margin-top:4px;flex-shrink:0}.list-field__empty{padding:16px;text-align:center;opacity:.7}.list-field__errors{display:flex;flex-direction:column;gap:4px;min-width:0}\n"], dependencies: [{ kind: "directive", type: MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "directive", type: KlesDynamicFieldDirective, selector: "[klesDynamicField]", inputs: ["field", "group", "ui", "siblingFields", "context"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2$2.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatErrorFormDirective, selector: "[matErrorForm]", inputs: ["form", "validations", "asyncValidations"] }] }); }
|
|
2242
2417
|
};
|
|
2243
2418
|
KlesFormListFieldComponent = __decorate([
|
|
2244
|
-
FieldMapper({ type: 'listfield', factory: (field) => new KlesFormArray(field).create() })
|
|
2419
|
+
FieldMapper({ type: 'listfield', factory: (field) => new KlesFormArray(field).create(), ui: (field) => new KlesFormUiArray(field).create() })
|
|
2245
2420
|
], KlesFormListFieldComponent);
|
|
2246
2421
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: KlesFormListFieldComponent, decorators: [{
|
|
2247
2422
|
type: Component,
|
|
@@ -2273,7 +2448,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImpor
|
|
|
2273
2448
|
>
|
|
2274
2449
|
@for (subfield of collections()[idx]; track subfield.name) {
|
|
2275
2450
|
<div class="list-field__field" [style.grid-column]="getGridColumn(subfield)" [style.grid-row]="getGridRow(subfield)">
|
|
2276
|
-
<ng-container klesDynamicField [field]="subfield" [group]="subGroup" [siblingFields]="collections()[idx]" [context]="context" />
|
|
2451
|
+
<ng-container klesDynamicField [field]="subfield" [group]="subGroup" [siblingFields]="collections()[idx]" [ui]="getRowUi(idx)" [context]="context" />
|
|
2277
2452
|
</div>
|
|
2278
2453
|
}
|
|
2279
2454
|
</div>
|
|
@@ -3133,29 +3308,6 @@ class KlesFormGroup extends KlesFormControl {
|
|
|
3133
3308
|
}
|
|
3134
3309
|
}
|
|
3135
3310
|
|
|
3136
|
-
class KlesFormUiGroup extends KlesFormUiControl {
|
|
3137
|
-
create() {
|
|
3138
|
-
const subGroup = new GroupUiState();
|
|
3139
|
-
if (this.field.collections && Array.isArray(this.field.collections)) {
|
|
3140
|
-
this.field.collections.forEach((subfield) => {
|
|
3141
|
-
let ui;
|
|
3142
|
-
if (subfield.type) {
|
|
3143
|
-
ui =
|
|
3144
|
-
componentMapper.find((c) => c.type === subfield.type)?.ui({ ...subfield, value: subfield.value || this.field.value?.[subfield.name] }) ||
|
|
3145
|
-
klesFieldUiFactory({ ...subfield, value: subfield.value || this.field.value?.[subfield.name] });
|
|
3146
|
-
}
|
|
3147
|
-
else {
|
|
3148
|
-
ui =
|
|
3149
|
-
componentMapper.find((c) => c.component === subfield.component)?.ui({ ...subfield, value: subfield.value || this.field.value?.[subfield.name] }) ||
|
|
3150
|
-
klesFieldUiFactory({ ...subfield, value: subfield.value || this.field.value?.[subfield.name] });
|
|
3151
|
-
}
|
|
3152
|
-
subGroup.addUiState(subfield.name, ui);
|
|
3153
|
-
});
|
|
3154
|
-
}
|
|
3155
|
-
return subGroup;
|
|
3156
|
-
}
|
|
3157
|
-
}
|
|
3158
|
-
|
|
3159
3311
|
let KlesFormGroupComponent = class KlesFormGroupComponent extends KlesFieldAbstract {
|
|
3160
3312
|
constructor() {
|
|
3161
3313
|
super(...arguments);
|
|
@@ -3969,152 +4121,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImpor
|
|
|
3969
4121
|
}]
|
|
3970
4122
|
}], propDecorators: { buttonToggles: [{ type: i0.ViewChildren, args: [i0.forwardRef(() => MatButtonToggle), { isSignal: true }] }] } });
|
|
3971
4123
|
|
|
3972
|
-
class ArrayUiState extends AbstractUiState {
|
|
3973
|
-
constructor(states) {
|
|
3974
|
-
super();
|
|
3975
|
-
this.states = [];
|
|
3976
|
-
this.states = states ?? [];
|
|
3977
|
-
this.states.forEach((state, index) => {
|
|
3978
|
-
state.setParent(this, index);
|
|
3979
|
-
});
|
|
3980
|
-
this._value.set(this.states.map((state) => state.value()));
|
|
3981
|
-
}
|
|
3982
|
-
setValue(value) {
|
|
3983
|
-
if (!Array.isArray(value)) {
|
|
3984
|
-
return;
|
|
3985
|
-
}
|
|
3986
|
-
value.forEach((newValue, index) => {
|
|
3987
|
-
this.at(index)?.setValue(newValue);
|
|
3988
|
-
});
|
|
3989
|
-
this._value.set(value);
|
|
3990
|
-
this.notifyParent();
|
|
3991
|
-
}
|
|
3992
|
-
patchValue(value) {
|
|
3993
|
-
if (value == null) {
|
|
3994
|
-
return;
|
|
3995
|
-
}
|
|
3996
|
-
value.forEach((newValue, index) => {
|
|
3997
|
-
const st = this.at(index);
|
|
3998
|
-
if (st) {
|
|
3999
|
-
st.patchValue(newValue);
|
|
4000
|
-
}
|
|
4001
|
-
});
|
|
4002
|
-
const curr = this._value() ?? [];
|
|
4003
|
-
const next = [...curr];
|
|
4004
|
-
value.forEach((newValue, index) => {
|
|
4005
|
-
next[index] = {
|
|
4006
|
-
...(next[index] ?? {}),
|
|
4007
|
-
...newValue,
|
|
4008
|
-
};
|
|
4009
|
-
});
|
|
4010
|
-
this._value.set(next);
|
|
4011
|
-
this.notifyParent();
|
|
4012
|
-
}
|
|
4013
|
-
childValueChanged(key, value) {
|
|
4014
|
-
const index = typeof key === 'number' ? key : Number(key);
|
|
4015
|
-
if (!Number.isInteger(index) || index < 0)
|
|
4016
|
-
return;
|
|
4017
|
-
const curr = this._value() ?? [];
|
|
4018
|
-
const next = [...curr];
|
|
4019
|
-
next[index] = value;
|
|
4020
|
-
this._value.set(next);
|
|
4021
|
-
this.notifyParent();
|
|
4022
|
-
}
|
|
4023
|
-
at(index) {
|
|
4024
|
-
return this.states?.[index] ?? null;
|
|
4025
|
-
}
|
|
4026
|
-
_find(name) {
|
|
4027
|
-
const idx = typeof name === 'number' ? name : Number(name);
|
|
4028
|
-
return Number.isFinite(idx) ? this.at(idx) : null;
|
|
4029
|
-
}
|
|
4030
|
-
push(control) {
|
|
4031
|
-
const items = Array.isArray(control) ? control : [control];
|
|
4032
|
-
if (items.length === 0) {
|
|
4033
|
-
return;
|
|
4034
|
-
}
|
|
4035
|
-
for (const item of items) {
|
|
4036
|
-
const index = this.states.length;
|
|
4037
|
-
this.states.push(item);
|
|
4038
|
-
item.setParent(this, index);
|
|
4039
|
-
}
|
|
4040
|
-
this._value.set(this.states.map((s) => s.value()));
|
|
4041
|
-
this.notifyParent();
|
|
4042
|
-
}
|
|
4043
|
-
insert(index, state) {
|
|
4044
|
-
const items = Array.isArray(state) ? state : [state];
|
|
4045
|
-
if (items.length === 0) {
|
|
4046
|
-
return;
|
|
4047
|
-
}
|
|
4048
|
-
const safeIndex = Math.max(0, Math.min(index, this.states.length));
|
|
4049
|
-
this.states.splice(safeIndex, 0, ...items);
|
|
4050
|
-
for (let i = safeIndex; i < this.states.length; i++) {
|
|
4051
|
-
this.states[i]?.setParent(this, i);
|
|
4052
|
-
}
|
|
4053
|
-
const curr = this._value();
|
|
4054
|
-
const next = [...curr];
|
|
4055
|
-
next.splice(safeIndex, 0, ...items.map((item) => item.value()));
|
|
4056
|
-
this._value.set(next);
|
|
4057
|
-
this.notifyParent();
|
|
4058
|
-
}
|
|
4059
|
-
removeAt(index) {
|
|
4060
|
-
if (index < 0 || index >= this.states.length)
|
|
4061
|
-
return;
|
|
4062
|
-
this.states.splice(index, 1);
|
|
4063
|
-
this.states.forEach((state, i) => {
|
|
4064
|
-
state.setParent(this, i);
|
|
4065
|
-
});
|
|
4066
|
-
const curr = this._value() ?? [];
|
|
4067
|
-
const next = [...curr];
|
|
4068
|
-
next.splice(index, 1);
|
|
4069
|
-
this._value.set(next);
|
|
4070
|
-
this.notifyParent();
|
|
4071
|
-
}
|
|
4072
|
-
clear() {
|
|
4073
|
-
this.states.length = 0;
|
|
4074
|
-
this._value.set([]);
|
|
4075
|
-
this.notifyParent();
|
|
4076
|
-
}
|
|
4077
|
-
}
|
|
4078
|
-
|
|
4079
|
-
class KlesFormUiArray extends KlesFormUiControl {
|
|
4080
|
-
create() {
|
|
4081
|
-
const array = new ArrayUiState();
|
|
4082
|
-
if (this.field.value && Array.isArray(this.field.value)) {
|
|
4083
|
-
if (this.field.collections && Array.isArray(this.field.collections)) {
|
|
4084
|
-
this.field.value.forEach(() => {
|
|
4085
|
-
const group = new GroupUiState();
|
|
4086
|
-
this.field.collections?.forEach((subfield) => {
|
|
4087
|
-
let control;
|
|
4088
|
-
if (subfield.type) {
|
|
4089
|
-
control = componentMapper.find((c) => c.type === subfield.type)?.ui(subfield) || klesFieldUiFactory(subfield);
|
|
4090
|
-
}
|
|
4091
|
-
else {
|
|
4092
|
-
control = componentMapper.find((c) => c.component === subfield.component)?.ui(subfield) || klesFieldUiFactory(subfield);
|
|
4093
|
-
}
|
|
4094
|
-
group.addUiState(subfield.name, control);
|
|
4095
|
-
});
|
|
4096
|
-
array.push(group);
|
|
4097
|
-
});
|
|
4098
|
-
}
|
|
4099
|
-
}
|
|
4100
|
-
else {
|
|
4101
|
-
const group = new GroupUiState();
|
|
4102
|
-
this.field.collections?.forEach((subfield) => {
|
|
4103
|
-
let control;
|
|
4104
|
-
if (subfield.type) {
|
|
4105
|
-
control = componentMapper.find((c) => c.type === subfield.type)?.ui(subfield) || klesFieldUiFactory(subfield);
|
|
4106
|
-
}
|
|
4107
|
-
else {
|
|
4108
|
-
control = componentMapper.find((c) => c.component === subfield.component)?.ui(subfield) || klesFieldUiFactory(subfield);
|
|
4109
|
-
}
|
|
4110
|
-
group.addUiState(subfield.name, control);
|
|
4111
|
-
});
|
|
4112
|
-
array.push(group);
|
|
4113
|
-
}
|
|
4114
|
-
return array;
|
|
4115
|
-
}
|
|
4116
|
-
}
|
|
4117
|
-
|
|
4118
4124
|
let KlesFormArrayComponent = class KlesFormArrayComponent extends KlesFieldAbstract {
|
|
4119
4125
|
constructor() {
|
|
4120
4126
|
super();
|