@klippa/ngx-enhancy-forms 18.23.9 → 18.25.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/esm2022/lib/elements/sortable-grouped-items/sortable-grouped-items.component.mjs +8 -6
- package/esm2022/lib/elements/sortable-items/sortable-items.component.mjs +134 -33
- package/esm2022/lib/form/form.component.mjs +46 -35
- package/fesm2022/klippa-ngx-enhancy-forms.mjs +181 -68
- package/fesm2022/klippa-ngx-enhancy-forms.mjs.map +1 -1
- package/lib/elements/sortable-items/sortable-items.component.d.ts +21 -12
- package/lib/form/form.component.d.ts +5 -3
- package/package.json +2 -4
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Directive, Input, EventEmitter, Component, SkipSelf, Optional, Output, InjectionToken, TemplateRef, Inject, ViewChild, ContentChild, Host, HostBinding, inject, NgModule } from '@angular/core';
|
|
2
|
+
import { Directive, Input, EventEmitter, Component, SkipSelf, Optional, Output, InjectionToken, TemplateRef, Inject, ViewChild, ContentChild, Host, HostBinding, ViewChildren, inject, NgModule } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import * as i2 from '@angular/forms';
|
|
6
|
-
import { UntypedFormArray, UntypedFormGroup, FormControl, UntypedFormControl,
|
|
6
|
+
import { UntypedFormArray, UntypedFormGroup, FormControl, UntypedFormControl, FormGroup, FormArray, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
7
7
|
import { isString } from 'lodash-es';
|
|
8
8
|
import { isArray } from 'lodash';
|
|
9
9
|
import * as i4 from '@ng-select/ng-select';
|
|
10
10
|
import { NgSelectModule } from '@ng-select/ng-select';
|
|
11
|
-
import * as i2$1 from '@dustfoundation/ngx-sortablejs';
|
|
12
11
|
import { SortablejsModule } from '@dustfoundation/ngx-sortablejs';
|
|
13
12
|
import { isSameDay, format, startOfMonth, endOfMonth, parse } from 'date-fns';
|
|
14
13
|
import * as i3 from '@angular/material/core';
|
|
@@ -173,6 +172,7 @@ class FormComponent {
|
|
|
173
172
|
this.activeControls = [];
|
|
174
173
|
}
|
|
175
174
|
ngOnInit() {
|
|
175
|
+
this.topLevelFormControl = this.formGroup ?? this.formArray;
|
|
176
176
|
if (isValueSet(this.patchValueInterceptor)) {
|
|
177
177
|
this.addSupportForPatchValueInterceptor();
|
|
178
178
|
}
|
|
@@ -184,13 +184,13 @@ class FormComponent {
|
|
|
184
184
|
throw new Error(`cannot index FormArray with ${typeof injectAt}`);
|
|
185
185
|
}
|
|
186
186
|
if (injectInto.at(injectAt)?.disabled) {
|
|
187
|
-
this.
|
|
187
|
+
this.topLevelFormControl.disable();
|
|
188
188
|
}
|
|
189
189
|
const valueBeforeInject = injectInto.at(injectAt)?.value;
|
|
190
190
|
if (isValueSet(valueBeforeInject)) {
|
|
191
|
-
this.
|
|
191
|
+
this.topLevelFormControl.patchValue(valueBeforeInject);
|
|
192
192
|
}
|
|
193
|
-
injectInto.setControl(injectAt, this.
|
|
193
|
+
injectInto.setControl(injectAt, this.topLevelFormControl);
|
|
194
194
|
this.onInjected.emit(valueBeforeInject);
|
|
195
195
|
}
|
|
196
196
|
else if (injectInto instanceof UntypedFormGroup) {
|
|
@@ -198,13 +198,13 @@ class FormComponent {
|
|
|
198
198
|
throw new Error(`cannot index FormGroup with ${typeof injectAt}`);
|
|
199
199
|
}
|
|
200
200
|
if (injectInto.get(injectAt)?.disabled) {
|
|
201
|
-
this.
|
|
201
|
+
this.topLevelFormControl.disable();
|
|
202
202
|
}
|
|
203
203
|
const valueBeforeInject = injectInto.get(injectAt)?.value;
|
|
204
204
|
if (isValueSet(valueBeforeInject)) {
|
|
205
|
-
this.
|
|
205
|
+
this.topLevelFormControl.patchValue(valueBeforeInject);
|
|
206
206
|
}
|
|
207
|
-
injectInto.setControl(injectAt, this.
|
|
207
|
+
injectInto.setControl(injectAt, this.topLevelFormControl);
|
|
208
208
|
this.onInjected.emit(valueBeforeInject);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -225,7 +225,7 @@ class FormComponent {
|
|
|
225
225
|
const injectInto = this.subFormPlaceholder.injectInto;
|
|
226
226
|
const injectAt = this.subFormPlaceholder.at;
|
|
227
227
|
if (injectInto instanceof UntypedFormArray) {
|
|
228
|
-
const idx = injectInto.controls.findIndex(e => e === this.
|
|
228
|
+
const idx = injectInto.controls.findIndex(e => e === this.topLevelFormControl);
|
|
229
229
|
injectInto.setControl(idx, new FormControl());
|
|
230
230
|
}
|
|
231
231
|
else if (injectInto instanceof UntypedFormGroup) {
|
|
@@ -275,15 +275,15 @@ class FormComponent {
|
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
277
|
addSupportForPatchValueInterceptor() {
|
|
278
|
-
const fn = this.
|
|
278
|
+
const fn = this.topLevelFormControl.patchValue;
|
|
279
279
|
const newFn = (value, options) => {
|
|
280
280
|
this.patchValueInterceptor(value).then((val) => {
|
|
281
281
|
setTimeout(() => {
|
|
282
|
-
fn.call(this.
|
|
282
|
+
fn.call(this.topLevelFormControl, val, options);
|
|
283
283
|
});
|
|
284
284
|
});
|
|
285
285
|
};
|
|
286
|
-
this.
|
|
286
|
+
this.topLevelFormControl.patchValue = newFn;
|
|
287
287
|
}
|
|
288
288
|
registerControl(formControl, formElement) {
|
|
289
289
|
this.activeControls.push({ formControl, formElement });
|
|
@@ -334,7 +334,12 @@ class FormComponent {
|
|
|
334
334
|
}
|
|
335
335
|
getAllFormControls() {
|
|
336
336
|
const result = [];
|
|
337
|
-
|
|
337
|
+
if (this.topLevelFormControl instanceof FormGroup) {
|
|
338
|
+
this.addFormGroupControls(this.topLevelFormControl, result);
|
|
339
|
+
}
|
|
340
|
+
else if (this.topLevelFormControl instanceof FormArray) {
|
|
341
|
+
this.addFormArrayControls(this.topLevelFormControl, result);
|
|
342
|
+
}
|
|
338
343
|
return result;
|
|
339
344
|
}
|
|
340
345
|
addFormControl(control, result) {
|
|
@@ -352,36 +357,39 @@ class FormComponent {
|
|
|
352
357
|
return this.warnings.get(control);
|
|
353
358
|
}
|
|
354
359
|
trySubmit() {
|
|
355
|
-
this.
|
|
360
|
+
this.topLevelFormControl.markAllAsTouched();
|
|
356
361
|
const allControls = this.getAllFormControls();
|
|
357
362
|
const originalDisabledStates = allControls.map(e => {
|
|
358
363
|
return { control: e, disabled: e.disabled };
|
|
359
364
|
});
|
|
360
365
|
allControls.forEach(e => this.disableInactiveFormControl(e));
|
|
361
366
|
allControls.forEach(e => e.updateValueAndValidity());
|
|
362
|
-
const formGroupValue = this.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
.
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
367
|
+
const formGroupValue = this.topLevelFormControl.value;
|
|
368
|
+
if (this.topLevelFormControl instanceof FormGroup) {
|
|
369
|
+
const renderedAndEnabledValues = this.getRenderedFieldValuesFormGroup(this.topLevelFormControl, true);
|
|
370
|
+
const renderedButDisabledValues = this.getRenderedFieldValuesFormGroup(this.topLevelFormControl, false);
|
|
371
|
+
return new Promise((resolve, reject) => {
|
|
372
|
+
if (this.topLevelFormControl.pending) {
|
|
373
|
+
const sub = this.topLevelFormControl.statusChanges.subscribe((res) => {
|
|
374
|
+
if (res !== 'PENDING') {
|
|
375
|
+
sub.unsubscribe();
|
|
376
|
+
this.handleSubmission(originalDisabledStates, renderedAndEnabledValues, renderedButDisabledValues, formGroupValue)
|
|
377
|
+
.then(resolve)
|
|
378
|
+
.catch(reject);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
this.handleSubmission(originalDisabledStates, renderedAndEnabledValues, renderedButDisabledValues, formGroupValue)
|
|
384
|
+
.then(resolve)
|
|
385
|
+
.catch(reject);
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
throw new Error('Submitting a FormArray as topLevel not supported (yet). Wrap it in a FormGroup.');
|
|
382
390
|
}
|
|
383
391
|
handleSubmission(originalDisabledStates, renderedAndEnabledValues, renderedButDisabledValues, formGroupValue) {
|
|
384
|
-
if (this.
|
|
392
|
+
if (this.topLevelFormControl.invalid) {
|
|
385
393
|
this.activeControls.find((e) => e.formControl.invalid)?.formElement?.scrollTo();
|
|
386
394
|
this.setDisabledStatesForAllControls(originalDisabledStates);
|
|
387
395
|
return Promise.reject(invalidFieldsSymbol);
|
|
@@ -436,7 +444,7 @@ class FormComponent {
|
|
|
436
444
|
});
|
|
437
445
|
}
|
|
438
446
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: FormComponent, deps: [{ token: FormComponent, optional: true, skipSelf: true }, { token: SubFormDirective, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
439
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: FormComponent, selector: "klp-form", inputs: { readOnly: "readOnly", showErrorMessages: "showErrorMessages", errorMessageLocation: "errorMessageLocation", formGroup: "formGroup", warnings: "warnings", errors: "errors", patchValueInterceptor: "patchValueInterceptor", allowSubmitOn: "allowSubmitOn" }, outputs: { onInjected: "onInjected" }, usesOnChanges: true, ngImport: i0, template: "<form>\n\t<ng-content></ng-content>\n</form>\n\n\n", styles: [":host{display:block}:host.row{display:flex}:host form{height:inherit}\n"], dependencies: [{ kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] }); }
|
|
447
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: FormComponent, selector: "klp-form", inputs: { readOnly: "readOnly", showErrorMessages: "showErrorMessages", errorMessageLocation: "errorMessageLocation", formGroup: "formGroup", formArray: "formArray", warnings: "warnings", errors: "errors", patchValueInterceptor: "patchValueInterceptor", allowSubmitOn: "allowSubmitOn" }, outputs: { onInjected: "onInjected" }, usesOnChanges: true, ngImport: i0, template: "<form>\n\t<ng-content></ng-content>\n</form>\n\n\n", styles: [":host{display:block}:host.row{display:flex}:host form{height:inherit}\n"], dependencies: [{ kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] }); }
|
|
440
448
|
}
|
|
441
449
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: FormComponent, decorators: [{
|
|
442
450
|
type: Component,
|
|
@@ -455,6 +463,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
|
|
|
455
463
|
type: Input
|
|
456
464
|
}], formGroup: [{
|
|
457
465
|
type: Input
|
|
466
|
+
}], formArray: [{
|
|
467
|
+
type: Input
|
|
458
468
|
}], warnings: [{
|
|
459
469
|
type: Input
|
|
460
470
|
}], errors: [{
|
|
@@ -1489,39 +1499,130 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
|
|
|
1489
1499
|
}] } });
|
|
1490
1500
|
|
|
1491
1501
|
class SortableItemsComponent extends ValueAccessorBase {
|
|
1492
|
-
constructor() {
|
|
1493
|
-
super(
|
|
1502
|
+
constructor(parent, controlContainer, ngZone) {
|
|
1503
|
+
super(parent, controlContainer);
|
|
1504
|
+
this.parent = parent;
|
|
1505
|
+
this.controlContainer = controlContainer;
|
|
1506
|
+
this.ngZone = ngZone;
|
|
1494
1507
|
this.sortableItemSize = 'lg';
|
|
1495
|
-
this.useCustomScroll = false;
|
|
1496
1508
|
this.scrollInterval = null;
|
|
1497
|
-
this.
|
|
1498
|
-
|
|
1509
|
+
this.onDragOver = (ev) => {
|
|
1510
|
+
ev.preventDefault();
|
|
1499
1511
|
};
|
|
1500
|
-
this.
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1512
|
+
this.onDragEnter = (ev) => {
|
|
1513
|
+
if (ev.clientY < 80) {
|
|
1514
|
+
this.scrollPage(40);
|
|
1515
|
+
}
|
|
1516
|
+
else if (window.innerHeight - ev.clientY < 80) {
|
|
1517
|
+
this.scrollPage(-40);
|
|
1504
1518
|
}
|
|
1505
1519
|
else {
|
|
1506
1520
|
this.stopScrolling();
|
|
1507
1521
|
}
|
|
1522
|
+
ev.dataTransfer.dropEffect = 'move';
|
|
1523
|
+
const targetIndex = this.dragItems.map(e => e.nativeElement).findIndex(e => e === ev.target);
|
|
1524
|
+
if (targetIndex === -1) {
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
this.currentDragPosition = targetIndex;
|
|
1528
|
+
this.dragItems.forEach((dragItem, i) => {
|
|
1529
|
+
if (this.dragSourceIndex === i) {
|
|
1530
|
+
if (this.dragSourceIndex > this.currentDragPosition) {
|
|
1531
|
+
const heightsAbove = this.dragItems.filter((e, i) => {
|
|
1532
|
+
if (i >= this.dragSourceIndex) {
|
|
1533
|
+
return false;
|
|
1534
|
+
}
|
|
1535
|
+
return i > this.currentDragPosition - 1;
|
|
1536
|
+
}).reduce((acc, cur, i) => {
|
|
1537
|
+
return acc + cur.nativeElement.getBoundingClientRect().height;
|
|
1538
|
+
}, 0);
|
|
1539
|
+
dragItem.nativeElement.querySelector('.visual').style.transform = `translateY(${-heightsAbove}px)`;
|
|
1540
|
+
}
|
|
1541
|
+
else if (this.dragSourceIndex < this.currentDragPosition) {
|
|
1542
|
+
const heightsAbove = this.dragItems.filter((e, i) => {
|
|
1543
|
+
if (i <= this.dragSourceIndex) {
|
|
1544
|
+
return false;
|
|
1545
|
+
}
|
|
1546
|
+
return i <= this.currentDragPosition;
|
|
1547
|
+
}).reduce((acc, cur, i) => {
|
|
1548
|
+
return acc + cur.nativeElement.getBoundingClientRect().height;
|
|
1549
|
+
}, 0);
|
|
1550
|
+
dragItem.nativeElement.querySelector('.visual').style.transform = `translateY(${heightsAbove}px)`;
|
|
1551
|
+
}
|
|
1552
|
+
else {
|
|
1553
|
+
dragItem.nativeElement.querySelector('.visual').style.transform = `translateY(${0}px)`;
|
|
1554
|
+
}
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
const heightOfCurrentlyDraggedItem = (this.dragItems.get(this.dragSourceIndex).nativeElement.getBoundingClientRect().height);
|
|
1558
|
+
if (this.shouldShoveDown(i)) {
|
|
1559
|
+
dragItem.nativeElement.querySelector('.visual').style.transform = `translateY(${heightOfCurrentlyDraggedItem}px)`;
|
|
1560
|
+
}
|
|
1561
|
+
else if (this.shouldShoveUp(i)) {
|
|
1562
|
+
dragItem.nativeElement.querySelector('.visual').style.transform = `translateY(${-heightOfCurrentlyDraggedItem}px)`;
|
|
1563
|
+
}
|
|
1564
|
+
else {
|
|
1565
|
+
dragItem.nativeElement.querySelector('.visual').style.transform = `translateY(0%)`;
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
this.currentDragPosition = targetIndex;
|
|
1569
|
+
};
|
|
1570
|
+
this.onDragStart = (ev) => {
|
|
1571
|
+
ev.dataTransfer.effectAllowed = 'move';
|
|
1572
|
+
this.ngZone.run(() => {
|
|
1573
|
+
this.dragSourceIndex = this.dragItems.map(e => e.nativeElement).findIndex(e => e === ev.target);
|
|
1574
|
+
this.currentDragPosition = this.dragSourceIndex;
|
|
1575
|
+
});
|
|
1508
1576
|
};
|
|
1509
|
-
this.
|
|
1577
|
+
this.onDragEnd = (ev) => {
|
|
1510
1578
|
this.stopScrolling();
|
|
1579
|
+
const movedElement = this.innerValue[this.dragSourceIndex];
|
|
1580
|
+
const isMovedToLastPlace = this.currentDragPosition === this.innerValue.length - 1;
|
|
1581
|
+
this.ngZone.run(() => {
|
|
1582
|
+
this.innerValue = this.innerValue
|
|
1583
|
+
.filter((e, i) => i !== this.dragSourceIndex)
|
|
1584
|
+
.reduce((acc, cur, i) => {
|
|
1585
|
+
if (i === this.currentDragPosition) {
|
|
1586
|
+
return [...acc, movedElement, cur];
|
|
1587
|
+
}
|
|
1588
|
+
return [...acc, cur];
|
|
1589
|
+
}, []);
|
|
1590
|
+
if (isMovedToLastPlace) {
|
|
1591
|
+
this.innerValue = [...this.innerValue, movedElement];
|
|
1592
|
+
}
|
|
1593
|
+
this.dragItems.forEach((dragItem, i) => {
|
|
1594
|
+
dragItem.nativeElement.querySelector('.visual').style.transform = `translateY(0%)`;
|
|
1595
|
+
});
|
|
1596
|
+
this.currentDragPosition = -1;
|
|
1597
|
+
this.dragSourceIndex = -1;
|
|
1598
|
+
this.setInnerValueAndNotify(this.innerValue);
|
|
1599
|
+
});
|
|
1511
1600
|
};
|
|
1512
1601
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1602
|
+
ngAfterViewInit() {
|
|
1603
|
+
this.dragItems.changes.subscribe(() => {
|
|
1604
|
+
this.dragItems.forEach(e => {
|
|
1605
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1606
|
+
e.nativeElement.removeEventListener('dragstart', this.onDragStart);
|
|
1607
|
+
e.nativeElement.removeEventListener('dragover', this.onDragOver);
|
|
1608
|
+
e.nativeElement.removeEventListener('dragenter', this.onDragEnter);
|
|
1609
|
+
e.nativeElement.removeEventListener('dragend', this.onDragEnd);
|
|
1610
|
+
e.nativeElement.addEventListener('dragstart', this.onDragStart);
|
|
1611
|
+
e.nativeElement.addEventListener('dragover', this.onDragOver);
|
|
1612
|
+
e.nativeElement.addEventListener('dragenter', this.onDragEnter);
|
|
1613
|
+
e.nativeElement.addEventListener('dragend', this.onDragEnd);
|
|
1614
|
+
this.dragItems.forEach((dragItem, i) => {
|
|
1615
|
+
dragItem.nativeElement.querySelector('.visual').style.transform = `translateY(0%)`;
|
|
1616
|
+
});
|
|
1617
|
+
});
|
|
1618
|
+
});
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
shouldShoveDown(index) {
|
|
1622
|
+
return this.dragSourceIndex > index && this.currentDragPosition <= index;
|
|
1623
|
+
}
|
|
1624
|
+
shouldShoveUp(index) {
|
|
1625
|
+
return this.dragSourceIndex < index && this.currentDragPosition >= index;
|
|
1525
1626
|
}
|
|
1526
1627
|
scrollPage(scrollAmount) {
|
|
1527
1628
|
if (!isValueSet(this.scrollInterval)) {
|
|
@@ -1540,14 +1641,14 @@ class SortableItemsComponent extends ValueAccessorBase {
|
|
|
1540
1641
|
clearInterval(this.scrollInterval);
|
|
1541
1642
|
this.scrollInterval = null;
|
|
1542
1643
|
}
|
|
1543
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: SortableItemsComponent, deps:
|
|
1544
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: SortableItemsComponent, selector: "klp-form-sortable-items", inputs: { sortableItemSize: "sortableItemSize"
|
|
1644
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: SortableItemsComponent, deps: [{ token: FormElementComponent, host: true, optional: true }, { token: i2.ControlContainer, host: true, optional: true }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1645
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: SortableItemsComponent, selector: "klp-form-sortable-items", inputs: { sortableItemSize: "sortableItemSize" }, providers: [
|
|
1545
1646
|
{
|
|
1546
1647
|
provide: NG_VALUE_ACCESSOR,
|
|
1547
1648
|
useExisting: SortableItemsComponent,
|
|
1548
1649
|
multi: true,
|
|
1549
1650
|
},
|
|
1550
|
-
], queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], usesInheritance: true, ngImport: i0, template: "<ng-template #listItem>\n\t<li *ngFor=\"let item of innerValue; index as index\"\n\t\t\tclass=\"sortableItem\"\n\t\t\t[ngClass]=\"{\n\t\t\tlargeSortableItem: sortableItemSize === 'lg',\n\t\t \tsmallSortableItem: sortableItemSize === 'sm'
|
|
1651
|
+
], queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], viewQueries: [{ propertyName: "dragItems", predicate: ["dragItem"], descendants: true }], usesInheritance: true, ngImport: i0, template: "dragInProgress {{dragSourceIndex}} {{innerValue | json}}\n<ng-template #listItem>\n\t<li *ngFor=\"let item of innerValue; index as index\"\n\t\t\tclass=\"sortableItem\"\n\t\t\t[draggable]=\"!disabled\"\n\t\t\t[ngClass]=\"{\n\t\t\tlargeSortableItem: sortableItemSize === 'lg',\n\t\t \tsmallSortableItem: sortableItemSize === 'sm',\n\t\t \t}\"\n\t\t\t#dragItem\n\t>\n\t\t<div class=\"visual\">\n\t\t\t<ng-container [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item, index:index }\"></ng-container>\n\t\t</div>\n\t</li>\n</ng-template>\n\n<ol *ngIf='!disabled'\n\t\tclass=\"itemsContainer\"\n\t\t[ngClass]=\"{dragInProgress: dragSourceIndex >= 0}\"\n>\n\t<ng-container *ngTemplateOutlet=\"listItem\"></ng-container>\n</ol>\n\n<ol *ngIf='disabled' class=\"itemsContainer disabled-mouse-cursor\">\n\t<ng-container *ngTemplateOutlet=\"listItem\"></ng-container>\n</ol>\n", styles: [":host{display:block}.itemsContainer{border:1px solid #e6ecf5;border-radius:5px;padding:0;margin-bottom:0}.dragInProgress .visual{pointer-events:none;transition:transform .1s linear}.sortableItem{list-style:none;cursor:grab}.sortableItem .visual{border-top:1px solid #e6ecf5}.sortableItem .visual:hover{background:#f8f9fa}.largeSortableItem .visual{padding:15px}.smallSortableItem .visual{padding:0 10px}.disabled-mouse-cursor li{cursor:no-drop}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.JsonPipe, name: "json" }] }); }
|
|
1551
1652
|
}
|
|
1552
1653
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: SortableItemsComponent, decorators: [{
|
|
1553
1654
|
type: Component,
|
|
@@ -1557,14 +1658,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
|
|
|
1557
1658
|
useExisting: SortableItemsComponent,
|
|
1558
1659
|
multi: true,
|
|
1559
1660
|
},
|
|
1560
|
-
], template: "<ng-template #listItem>\n\t<li *ngFor=\"let item of innerValue; index as index\"\n\t\t\tclass=\"sortableItem\"\n\t\t\t[ngClass]=\"{\n\t\t\tlargeSortableItem: sortableItemSize === 'lg',\n\t\t \tsmallSortableItem: sortableItemSize === 'sm'
|
|
1561
|
-
}],
|
|
1661
|
+
], template: "dragInProgress {{dragSourceIndex}} {{innerValue | json}}\n<ng-template #listItem>\n\t<li *ngFor=\"let item of innerValue; index as index\"\n\t\t\tclass=\"sortableItem\"\n\t\t\t[draggable]=\"!disabled\"\n\t\t\t[ngClass]=\"{\n\t\t\tlargeSortableItem: sortableItemSize === 'lg',\n\t\t \tsmallSortableItem: sortableItemSize === 'sm',\n\t\t \t}\"\n\t\t\t#dragItem\n\t>\n\t\t<div class=\"visual\">\n\t\t\t<ng-container [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item, index:index }\"></ng-container>\n\t\t</div>\n\t</li>\n</ng-template>\n\n<ol *ngIf='!disabled'\n\t\tclass=\"itemsContainer\"\n\t\t[ngClass]=\"{dragInProgress: dragSourceIndex >= 0}\"\n>\n\t<ng-container *ngTemplateOutlet=\"listItem\"></ng-container>\n</ol>\n\n<ol *ngIf='disabled' class=\"itemsContainer disabled-mouse-cursor\">\n\t<ng-container *ngTemplateOutlet=\"listItem\"></ng-container>\n</ol>\n", styles: [":host{display:block}.itemsContainer{border:1px solid #e6ecf5;border-radius:5px;padding:0;margin-bottom:0}.dragInProgress .visual{pointer-events:none;transition:transform .1s linear}.sortableItem{list-style:none;cursor:grab}.sortableItem .visual{border-top:1px solid #e6ecf5}.sortableItem .visual:hover{background:#f8f9fa}.largeSortableItem .visual{padding:15px}.smallSortableItem .visual{padding:0 10px}.disabled-mouse-cursor li{cursor:no-drop}\n"] }]
|
|
1662
|
+
}], ctorParameters: () => [{ type: FormElementComponent, decorators: [{
|
|
1663
|
+
type: Host
|
|
1664
|
+
}, {
|
|
1665
|
+
type: Optional
|
|
1666
|
+
}] }, { type: i2.ControlContainer, decorators: [{
|
|
1667
|
+
type: Host
|
|
1668
|
+
}, {
|
|
1669
|
+
type: Optional
|
|
1670
|
+
}] }, { type: i0.NgZone }], propDecorators: { template: [{
|
|
1562
1671
|
type: ContentChild,
|
|
1563
1672
|
args: [TemplateRef]
|
|
1564
1673
|
}], sortableItemSize: [{
|
|
1565
1674
|
type: Input
|
|
1566
|
-
}],
|
|
1567
|
-
type:
|
|
1675
|
+
}], dragItems: [{
|
|
1676
|
+
type: ViewChildren,
|
|
1677
|
+
args: ['dragItem']
|
|
1568
1678
|
}] } });
|
|
1569
1679
|
|
|
1570
1680
|
class TextInputComponent extends ValueAccessorBase {
|
|
@@ -2372,6 +2482,7 @@ class SortableGroupedItemsComponent extends ValueAccessorBase {
|
|
|
2372
2482
|
setTimeout(() => {
|
|
2373
2483
|
if (arrayIsSetAndFilled(value)) {
|
|
2374
2484
|
this.items = value.flatMap(e => [...e, '']);
|
|
2485
|
+
console.log(this.items);
|
|
2375
2486
|
}
|
|
2376
2487
|
else {
|
|
2377
2488
|
this.items = [];
|
|
@@ -2380,6 +2491,8 @@ class SortableGroupedItemsComponent extends ValueAccessorBase {
|
|
|
2380
2491
|
});
|
|
2381
2492
|
}
|
|
2382
2493
|
onItemsRearranged(value) {
|
|
2494
|
+
console.log('gers');
|
|
2495
|
+
console.log(value);
|
|
2383
2496
|
const result = splitArrayByCondition(value, e => e === '').filter(arrayIsSetAndFilled);
|
|
2384
2497
|
this.setInnerValueAndNotify(result);
|
|
2385
2498
|
this.reloader = false;
|
|
@@ -2397,11 +2510,11 @@ class SortableGroupedItemsComponent extends ValueAccessorBase {
|
|
|
2397
2510
|
});
|
|
2398
2511
|
}
|
|
2399
2512
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: SortableGroupedItemsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2400
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: SortableGroupedItemsComponent, selector: "klp-form-sortable-grouped-items", providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: SortableGroupedItemsComponent, multi: true }], usesInheritance: true, ngImport: i0, template: "<ng-container
|
|
2513
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: SortableGroupedItemsComponent, selector: "klp-form-sortable-grouped-items", providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: SortableGroupedItemsComponent, multi: true }], usesInheritance: true, ngImport: i0, template: "<ng-container>\n\t<klp-form-sortable-items\n\t\t[(ngModel)]=\"items\"\n\t\t(ngModelChange)=\"onItemsRearranged($event)\"\n\t>\n\t\t<ng-template let-item=\"item\">\n\t\t\t<div>{{item}}</div>\n\t\t</ng-template>\n\t</klp-form-sortable-items>\n</ng-container>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: SortableItemsComponent, selector: "klp-form-sortable-items", inputs: ["sortableItemSize"] }] }); }
|
|
2401
2514
|
}
|
|
2402
2515
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: SortableGroupedItemsComponent, decorators: [{
|
|
2403
2516
|
type: Component,
|
|
2404
|
-
args: [{ selector: 'klp-form-sortable-grouped-items', providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: SortableGroupedItemsComponent, multi: true }], template: "<ng-container
|
|
2517
|
+
args: [{ selector: 'klp-form-sortable-grouped-items', providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: SortableGroupedItemsComponent, multi: true }], template: "<ng-container>\n\t<klp-form-sortable-items\n\t\t[(ngModel)]=\"items\"\n\t\t(ngModelChange)=\"onItemsRearranged($event)\"\n\t>\n\t\t<ng-template let-item=\"item\">\n\t\t\t<div>{{item}}</div>\n\t\t</ng-template>\n\t</klp-form-sortable-items>\n</ng-container>\n", styles: [":host{display:block}\n"] }]
|
|
2405
2518
|
}] });
|
|
2406
2519
|
|
|
2407
2520
|
const invalidTimeKey = '--invalid_time--';
|