@elderbyte/ngx-starter 21.4.2 → 21.4.3
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.
|
@@ -23573,62 +23573,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImpor
|
|
|
23573
23573
|
}] } });
|
|
23574
23574
|
|
|
23575
23575
|
class ElderSelectOnTabDirective {
|
|
23576
|
-
|
|
23577
|
-
* *
|
|
23578
|
-
* Constructor *
|
|
23579
|
-
* *
|
|
23580
|
-
**************************************************************************/
|
|
23581
|
-
constructor(autoTrigger, elderSelectBase) {
|
|
23582
|
-
this.autoTrigger = autoTrigger;
|
|
23583
|
-
this.elderSelectBase = elderSelectBase;
|
|
23576
|
+
constructor() {
|
|
23584
23577
|
/***************************************************************************
|
|
23585
23578
|
* *
|
|
23586
23579
|
* Fields *
|
|
23587
23580
|
* *
|
|
23588
23581
|
**************************************************************************/
|
|
23589
23582
|
this.logger = LoggerFactory.getLogger(this.constructor.name);
|
|
23583
|
+
this.autoTrigger = inject(MatAutocompleteTrigger);
|
|
23584
|
+
this.elderSelectBase = inject(ELDER_SELECT_BASE, {
|
|
23585
|
+
skipSelf: true,
|
|
23586
|
+
});
|
|
23590
23587
|
this.destroy$ = new Subject$1();
|
|
23591
|
-
|
|
23592
|
-
* Whether the autocomplete panel was open before the event
|
|
23593
|
-
*/
|
|
23588
|
+
this.controlValueAccessor = this.elderSelectBase;
|
|
23594
23589
|
this.panelOpen = false;
|
|
23595
|
-
|
|
23596
|
-
* Whether the user selected an option.
|
|
23597
|
-
* (We want to ignore selections if there is already a selection present and the user tabs away)
|
|
23598
|
-
*/
|
|
23599
|
-
this.userInput = false;
|
|
23600
|
-
this.controlValueAccessor = elderSelectBase;
|
|
23590
|
+
this.userInteracted = false;
|
|
23601
23591
|
}
|
|
23602
23592
|
/***************************************************************************
|
|
23603
23593
|
* *
|
|
23604
23594
|
* Event Listener *
|
|
23605
23595
|
* *
|
|
23606
23596
|
**************************************************************************/
|
|
23607
|
-
|
|
23608
|
-
this.
|
|
23597
|
+
handleVerticalArrowKeyPress() {
|
|
23598
|
+
this.userInteracted = true;
|
|
23609
23599
|
}
|
|
23610
|
-
|
|
23600
|
+
handleTabKeyPress() {
|
|
23611
23601
|
if (!this.panelOpen) {
|
|
23612
23602
|
return;
|
|
23613
23603
|
}
|
|
23614
|
-
if (
|
|
23615
|
-
|
|
23616
|
-
if (this.controlValueAccessor.value) {
|
|
23617
|
-
this.logger.warn('Discarding TAB since the user did probably not intend to change the value! userInput:', this.userInput);
|
|
23618
|
-
return;
|
|
23619
|
-
}
|
|
23620
|
-
if (!this.elderSelectBase.required) {
|
|
23621
|
-
// The user did not select any option and no current value is present.
|
|
23622
|
-
// Since the input is NOT marked as required, we assume the user did not want to select a value
|
|
23623
|
-
return;
|
|
23624
|
-
}
|
|
23625
|
-
}
|
|
23626
|
-
const activeOption = this.autoTrigger.activeOption;
|
|
23627
|
-
if (activeOption) {
|
|
23628
|
-
const entity = activeOption.value;
|
|
23629
|
-
this.writeEntity(entity);
|
|
23604
|
+
if (this.userInteracted || this.isRequiredAndEmpty()) {
|
|
23605
|
+
this.selectActiveOption();
|
|
23630
23606
|
}
|
|
23631
|
-
this.reset();
|
|
23632
23607
|
}
|
|
23633
23608
|
/***************************************************************************
|
|
23634
23609
|
* *
|
|
@@ -23636,15 +23611,8 @@ class ElderSelectOnTabDirective {
|
|
|
23636
23611
|
* *
|
|
23637
23612
|
**************************************************************************/
|
|
23638
23613
|
ngAfterViewInit() {
|
|
23639
|
-
|
|
23640
|
-
|
|
23641
|
-
.pipe(takeUntil(this.destroy$), delay(0))
|
|
23642
|
-
.subscribe((value) => (this.panelOpen = value));
|
|
23643
|
-
this.autoTrigger.optionSelections
|
|
23644
|
-
.pipe(
|
|
23645
|
-
// TODO https://github.com/angular/components/pull/14813
|
|
23646
|
-
takeUntil(this.destroy$), tap((opt) => this.logger.debug('[optionSelections] CHANGED ', opt)), map((opt) => opt.isUserInput))
|
|
23647
|
-
.subscribe((isUserInput) => (this.userInput = isUserInput));
|
|
23614
|
+
this.observePanelOpen();
|
|
23615
|
+
this.observeAutocompleteSelection();
|
|
23648
23616
|
}
|
|
23649
23617
|
ngOnDestroy() {
|
|
23650
23618
|
this.destroy$.next();
|
|
@@ -23655,8 +23623,36 @@ class ElderSelectOnTabDirective {
|
|
|
23655
23623
|
* Private methods *
|
|
23656
23624
|
* *
|
|
23657
23625
|
**************************************************************************/
|
|
23658
|
-
|
|
23659
|
-
this.
|
|
23626
|
+
isRequiredAndEmpty() {
|
|
23627
|
+
return !this.controlValueAccessor.value && this.elderSelectBase.required;
|
|
23628
|
+
}
|
|
23629
|
+
resetInteractionState() {
|
|
23630
|
+
this.userInteracted = false;
|
|
23631
|
+
}
|
|
23632
|
+
observePanelOpen() {
|
|
23633
|
+
const autocomplete = this.autoTrigger.autocomplete;
|
|
23634
|
+
merge(autocomplete.opened.pipe(map(() => true)), autocomplete.closed.pipe(map(() => false)))
|
|
23635
|
+
.pipe(takeUntil(this.destroy$), delay(0))
|
|
23636
|
+
.subscribe((isOpen) => {
|
|
23637
|
+
this.panelOpen = isOpen;
|
|
23638
|
+
if (isOpen) {
|
|
23639
|
+
this.resetInteractionState();
|
|
23640
|
+
}
|
|
23641
|
+
});
|
|
23642
|
+
}
|
|
23643
|
+
observeAutocompleteSelection() {
|
|
23644
|
+
this.autoTrigger.optionSelections
|
|
23645
|
+
.pipe(
|
|
23646
|
+
// TODO https://github.com/angular/components/pull/14813
|
|
23647
|
+
takeUntil(this.destroy$), tap((opt) => this.logger.debug('[optionSelections] CHANGED ', opt)), map((opt) => opt.isUserInput))
|
|
23648
|
+
.subscribe((isUserInput) => (this.userInteracted = isUserInput));
|
|
23649
|
+
}
|
|
23650
|
+
selectActiveOption() {
|
|
23651
|
+
const activeOption = this.autoTrigger.activeOption;
|
|
23652
|
+
if (activeOption) {
|
|
23653
|
+
const entity = activeOption.value;
|
|
23654
|
+
this.writeEntity(entity);
|
|
23655
|
+
}
|
|
23660
23656
|
}
|
|
23661
23657
|
writeEntity(entity) {
|
|
23662
23658
|
const value = this.entityToValue(entity);
|
|
@@ -23676,26 +23672,21 @@ class ElderSelectOnTabDirective {
|
|
|
23676
23672
|
return entity;
|
|
23677
23673
|
}
|
|
23678
23674
|
}
|
|
23679
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ElderSelectOnTabDirective, deps: [
|
|
23680
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.2", type: ElderSelectOnTabDirective, isStandalone: true, selector: "[elderSelectOnTab]", host: { listeners: { "keydown.arrowup": "
|
|
23675
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ElderSelectOnTabDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
23676
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.2", type: ElderSelectOnTabDirective, isStandalone: true, selector: "[elderSelectOnTab]", host: { listeners: { "keydown.arrowup": "handleVerticalArrowKeyPress()", "keydown.arrowdown": "handleVerticalArrowKeyPress()", "keydown.tab": "handleTabKeyPress()" } }, ngImport: i0 }); }
|
|
23681
23677
|
}
|
|
23682
23678
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ElderSelectOnTabDirective, decorators: [{
|
|
23683
23679
|
type: Directive,
|
|
23684
23680
|
args: [{
|
|
23685
23681
|
selector: '[elderSelectOnTab]',
|
|
23686
23682
|
}]
|
|
23687
|
-
}],
|
|
23688
|
-
type: SkipSelf
|
|
23689
|
-
}, {
|
|
23690
|
-
type: Inject,
|
|
23691
|
-
args: [ELDER_SELECT_BASE]
|
|
23692
|
-
}] }], propDecorators: { onOptionSelect: [{
|
|
23683
|
+
}], propDecorators: { handleVerticalArrowKeyPress: [{
|
|
23693
23684
|
type: HostListener,
|
|
23694
23685
|
args: ['keydown.arrowup']
|
|
23695
23686
|
}, {
|
|
23696
23687
|
type: HostListener,
|
|
23697
23688
|
args: ['keydown.arrowdown']
|
|
23698
|
-
}],
|
|
23689
|
+
}], handleTabKeyPress: [{
|
|
23699
23690
|
type: HostListener,
|
|
23700
23691
|
args: ['keydown.tab']
|
|
23701
23692
|
}] } });
|