@spartan-ng/brain 1.5.0-beta.8 → 1.5.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/spartan-ng-brain-autocomplete.mjs +19 -7
- package/fesm2022/spartan-ng-brain-autocomplete.mjs.map +1 -1
- package/fesm2022/spartan-ng-brain-combobox.mjs +44 -19
- package/fesm2022/spartan-ng-brain-combobox.mjs.map +1 -1
- package/fesm2022/spartan-ng-brain-select.mjs +75 -18
- package/fesm2022/spartan-ng-brain-select.mjs.map +1 -1
- package/package.json +1 -1
- package/types/spartan-ng-brain-autocomplete.d.ts +3 -2
- package/types/spartan-ng-brain-combobox.d.ts +6 -4
- package/types/spartan-ng-brain-select.d.ts +36 -10
|
@@ -176,6 +176,7 @@ class BrnCombobox {
|
|
|
176
176
|
this.keyManager
|
|
177
177
|
.withVerticalOrientation()
|
|
178
178
|
.withHomeAndEnd()
|
|
179
|
+
.withPageUpDown()
|
|
179
180
|
.withWrap()
|
|
180
181
|
.skipPredicate((item) => item.disabled || !item.visible());
|
|
181
182
|
this._brnPopover?.closed.subscribe(() => {
|
|
@@ -223,7 +224,11 @@ class BrnCombobox {
|
|
|
223
224
|
selectActiveItem() {
|
|
224
225
|
if (!this.isExpanded())
|
|
225
226
|
return;
|
|
226
|
-
const
|
|
227
|
+
const activeItem = this.keyManager.activeItem;
|
|
228
|
+
// setActiveItem() bypasses skipPredicate, so the active item may be disabled.
|
|
229
|
+
if (activeItem?.disabled)
|
|
230
|
+
return;
|
|
231
|
+
const value = activeItem?.value();
|
|
227
232
|
if (this.isSingleValuePresent()(value)) {
|
|
228
233
|
this.select(value);
|
|
229
234
|
}
|
|
@@ -350,10 +355,10 @@ class BrnComboboxChipInput {
|
|
|
350
355
|
/** The id of the combobox input */
|
|
351
356
|
id = input(`brn-combobox-input-${++BrnComboboxChipInput._id}`, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
352
357
|
/** Manual override for aria-invalid. When not set, auto-detects from the parent combobox error state. */
|
|
353
|
-
|
|
358
|
+
ariaInvalidInput = input(undefined, { ...(ngDevMode ? { debugName: "ariaInvalidInput" } : /* istanbul ignore next */ {}), transform: (v) => (v === '' || v === undefined ? undefined : booleanAttribute(v)),
|
|
354
359
|
alias: 'aria-invalid' });
|
|
355
360
|
/** Computed aria-invalid: uses manual override if provided, otherwise reads from parent error state. */
|
|
356
|
-
_ariaInvalid = computed(() => this.
|
|
361
|
+
_ariaInvalid = computed(() => this.ariaInvalidInput() ?? this._combobox.controlState?.()?.invalid, ...(ngDevMode ? [{ debugName: "_ariaInvalid" }] : /* istanbul ignore next */ []));
|
|
357
362
|
_dirty = computed(() => this._combobox.controlState?.()?.dirty, ...(ngDevMode ? [{ debugName: "_dirty" }] : /* istanbul ignore next */ []));
|
|
358
363
|
_touched = computed(() => this._combobox.controlState?.()?.touched, ...(ngDevMode ? [{ debugName: "_touched" }] : /* istanbul ignore next */ []));
|
|
359
364
|
_spartanInvalid = computed(() => this._combobox.controlState?.()?.spartanInvalid, ...(ngDevMode ? [{ debugName: "_spartanInvalid" }] : /* istanbul ignore next */ []));
|
|
@@ -382,6 +387,11 @@ class BrnComboboxChipInput {
|
|
|
382
387
|
event.preventDefault();
|
|
383
388
|
this._combobox.selectActiveItem();
|
|
384
389
|
}
|
|
390
|
+
if (this._isExpanded() && event.key === 'Tab') {
|
|
391
|
+
// Tab moves focus on to the next control. Close the popup without toggling the
|
|
392
|
+
// highlighted option.
|
|
393
|
+
this._combobox.close();
|
|
394
|
+
}
|
|
385
395
|
if (!this._isExpanded()) {
|
|
386
396
|
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
387
397
|
this._combobox.open();
|
|
@@ -396,7 +406,7 @@ class BrnComboboxChipInput {
|
|
|
396
406
|
this._combobox.keyManager.onKeydown(event);
|
|
397
407
|
}
|
|
398
408
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnComboboxChipInput, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
399
|
-
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnComboboxChipInput, isStandalone: true, selector: "input[brnComboboxChipInput]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null },
|
|
409
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnComboboxChipInput, isStandalone: true, selector: "input[brnComboboxChipInput]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, ariaInvalidInput: { classPropertyName: "ariaInvalidInput", publicName: "aria-invalid", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "type": "text", "role": "combobox", "autocomplete": "off", "autocorrect": "off", "autocapitalize": "none", "spellcheck": "false", "aria-autocomplete": "list", "aria-haspopup": "listbox" }, listeners: { "keydown": "onKeyDown($event)", "input": "onInput($event)" }, properties: { "id": "id()", "attr.aria-expanded": "_isExpanded()", "attr.aria-invalid": "_ariaInvalid() ? \"true\" : null", "attr.data-invalid": "_ariaInvalid() ? \"true\" : null", "attr.data-matches-spartan-invalid": "_spartanInvalid() ? \"true\" : null", "attr.data-dirty": "_touched() ? \"true\" : null", "attr.data-touched": "_touched() ? \"true\" : null", "attr.disabled": "_disabled() ? \"\" : null", "attr.data-disabled": "_disabled() ? \"\" : null" } }, ngImport: i0 });
|
|
400
410
|
}
|
|
401
411
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnComboboxChipInput, decorators: [{
|
|
402
412
|
type: Directive,
|
|
@@ -424,7 +434,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
424
434
|
'(input)': 'onInput($event)',
|
|
425
435
|
},
|
|
426
436
|
}]
|
|
427
|
-
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }],
|
|
437
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], ariaInvalidInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-invalid", required: false }] }] } });
|
|
428
438
|
|
|
429
439
|
class BrnComboboxChipRemove {
|
|
430
440
|
_combobox = injectBrnComboboxBase();
|
|
@@ -577,7 +587,7 @@ class BrnComboboxInput {
|
|
|
577
587
|
/** The id of the combobox input */
|
|
578
588
|
id = input(`brn-combobox-input-${++BrnComboboxInput._id}`, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
579
589
|
/** Manual override for aria-invalid. When not set, auto-detects from the parent combobox error state. */
|
|
580
|
-
|
|
590
|
+
ariaInvalidInput = input(undefined, { ...(ngDevMode ? { debugName: "ariaInvalidInput" } : /* istanbul ignore next */ {}), transform: (v) => (v === '' || v === undefined ? undefined : booleanAttribute(v)),
|
|
581
591
|
alias: 'aria-invalid' });
|
|
582
592
|
/** Forces the invalid state visually, regardless of form control state. */
|
|
583
593
|
forceInvalid = input(false, { ...(ngDevMode ? { debugName: "forceInvalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
@@ -586,7 +596,7 @@ class BrnComboboxInput {
|
|
|
586
596
|
_isExpanded = this._combobox.isExpanded;
|
|
587
597
|
_activeDescendant = signal(undefined, ...(ngDevMode ? [{ debugName: "_activeDescendant" }] : /* istanbul ignore next */ []));
|
|
588
598
|
/** Computed aria-invalid: uses manual override if provided, otherwise reads from parent error state. */
|
|
589
|
-
_ariaInvalid = computed(() => this.
|
|
599
|
+
_ariaInvalid = computed(() => this.ariaInvalidInput() ?? this._combobox.controlState?.()?.invalid, ...(ngDevMode ? [{ debugName: "_ariaInvalid" }] : /* istanbul ignore next */ []));
|
|
590
600
|
_dirty = computed(() => this._combobox.controlState?.()?.dirty, ...(ngDevMode ? [{ debugName: "_dirty" }] : /* istanbul ignore next */ []));
|
|
591
601
|
_touched = computed(() => this._combobox.controlState?.()?.touched, ...(ngDevMode ? [{ debugName: "_touched" }] : /* istanbul ignore next */ []));
|
|
592
602
|
_spartanInvalid = computed(() => this.forceInvalid() || this._combobox.controlState?.()?.spartanInvalid, ...(ngDevMode ? [{ debugName: "_spartanInvalid" }] : /* istanbul ignore next */ []));
|
|
@@ -631,19 +641,18 @@ class BrnComboboxInput {
|
|
|
631
641
|
}
|
|
632
642
|
if (wasExpanded) {
|
|
633
643
|
if (event.key === 'Tab') {
|
|
644
|
+
// Tab moves focus on to the next control. Close the popup without committing so
|
|
645
|
+
// the highlighted suggestion does not overwrite the typed value.
|
|
646
|
+
//
|
|
634
647
|
// In popup mode the input lives inside a CDK overlay which is appended to <body>.
|
|
635
648
|
// Without preventDefault the browser has nowhere to Tab to inside the overlay and
|
|
636
|
-
// jumps straight to the browser's address bar.
|
|
637
|
-
//
|
|
638
|
-
//
|
|
649
|
+
// jumps straight to the browser's address bar. We intercept the key and let
|
|
650
|
+
// BrnOverlay._restoreFocus restore focus to the trigger so the user can continue
|
|
651
|
+
// tabbing through the page normally.
|
|
639
652
|
if (!this._isCombobox()) {
|
|
640
653
|
event.preventDefault();
|
|
641
|
-
this._combobox.selectActiveItem();
|
|
642
|
-
this._combobox.close();
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
645
|
-
this._combobox.selectActiveItem();
|
|
646
654
|
}
|
|
655
|
+
this._combobox.close();
|
|
647
656
|
}
|
|
648
657
|
}
|
|
649
658
|
else {
|
|
@@ -657,7 +666,7 @@ class BrnComboboxInput {
|
|
|
657
666
|
this._combobox.keyManager.onKeydown(event);
|
|
658
667
|
}
|
|
659
668
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnComboboxInput, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
660
|
-
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnComboboxInput, isStandalone: true, selector: "input[brnComboboxInput]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null },
|
|
669
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnComboboxInput, isStandalone: true, selector: "input[brnComboboxInput]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, ariaInvalidInput: { classPropertyName: "ariaInvalidInput", publicName: "aria-invalid", isSignal: true, isRequired: false, transformFunction: null }, forceInvalid: { classPropertyName: "forceInvalid", publicName: "forceInvalid", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "type": "text", "role": "combobox", "autocomplete": "off", "autocorrect": "off", "autocapitalize": "none", "spellcheck": "false", "aria-autocomplete": "list", "aria-haspopup": "listbox" }, listeners: { "keydown": "onKeyDown($event)", "input": "onInput($event)" }, properties: { "id": "id()", "attr.aria-expanded": "_isExpanded()", "attr.aria-controls": "_isExpanded() ? _comboboxListId() : null", "attr.aria-activedescendant": "_isExpanded() ? _activeDescendant() : null", "attr.aria-invalid": "_isCombobox() && _ariaInvalid() ? \"true\": null", "attr.data-invalid": "_isCombobox() && _ariaInvalid() ? \"true\": null", "attr.data-matches-spartan-invalid": "_isCombobox() && _spartanInvalid() ? \"true\": null", "attr.data-touched": "_isCombobox() && _touched() ? \"true\": null", "attr.data-dirty": "_isCombobox() && _dirty() ? \"true\": null", "attr.disabled": "disabled() ? \"\" : null" } }, exportAs: ["brnComboboxInput"], ngImport: i0 });
|
|
661
670
|
}
|
|
662
671
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnComboboxInput, decorators: [{
|
|
663
672
|
type: Directive,
|
|
@@ -687,7 +696,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
687
696
|
'(input)': 'onInput($event)',
|
|
688
697
|
},
|
|
689
698
|
}]
|
|
690
|
-
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }],
|
|
699
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], ariaInvalidInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-invalid", required: false }] }], forceInvalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "forceInvalid", required: false }] }] } });
|
|
691
700
|
|
|
692
701
|
class BrnComboboxItem {
|
|
693
702
|
static _id = 0;
|
|
@@ -742,8 +751,12 @@ class BrnComboboxItem {
|
|
|
742
751
|
this._combobox.keyManager.setActiveItem(this);
|
|
743
752
|
this._activatedByPointer = false;
|
|
744
753
|
}
|
|
754
|
+
/** Prevent the press from moving DOM focus off the trigger (aria-activedescendant model). */
|
|
755
|
+
onMouseDown(event) {
|
|
756
|
+
event.preventDefault();
|
|
757
|
+
}
|
|
745
758
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnComboboxItem, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
746
|
-
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnComboboxItem, isStandalone: true, selector: "[brnComboboxItem]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, _disabled: { classPropertyName: "_disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "option" }, listeners: { "click": "select()", "mouseenter": "activate()" }, properties: { "id": "id()", "attr.data-highlighted": "_highlighted() ? \"\" : null", "attr.data-value": "value()", "attr.data-hidden": "!visible() ? '' : null", "attr.aria-selected": "active()", "attr.aria-disabled": "_disabled()", "attr.data-disabled": "_disabled() ? \"\" : null" } }, providers: [provideBrnComboboxItem(BrnComboboxItem)], ngImport: i0 });
|
|
759
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnComboboxItem, isStandalone: true, selector: "[brnComboboxItem]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, _disabled: { classPropertyName: "_disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "option" }, listeners: { "click": "select()", "mouseenter": "activate()", "mousedown": "onMouseDown($event)" }, properties: { "id": "id()", "attr.data-highlighted": "_highlighted() ? \"\" : null", "attr.data-value": "value()", "attr.data-hidden": "!visible() ? '' : null", "attr.aria-selected": "active()", "attr.aria-disabled": "_disabled()", "attr.data-disabled": "_disabled() ? \"\" : null" } }, providers: [provideBrnComboboxItem(BrnComboboxItem)], ngImport: i0 });
|
|
747
760
|
}
|
|
748
761
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnComboboxItem, decorators: [{
|
|
749
762
|
type: Directive,
|
|
@@ -761,6 +774,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
761
774
|
'[attr.data-disabled]': '_disabled() ? "" : null',
|
|
762
775
|
'(click)': 'select()',
|
|
763
776
|
'(mouseenter)': 'activate()',
|
|
777
|
+
'(mousedown)': 'onMouseDown($event)',
|
|
764
778
|
},
|
|
765
779
|
}]
|
|
766
780
|
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], _disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
@@ -872,6 +886,7 @@ class BrnComboboxMultiple {
|
|
|
872
886
|
this.keyManager
|
|
873
887
|
.withVerticalOrientation()
|
|
874
888
|
.withHomeAndEnd()
|
|
889
|
+
.withPageUpDown()
|
|
875
890
|
.withWrap()
|
|
876
891
|
.skipPredicate((item) => item.disabled || !item.visible());
|
|
877
892
|
this._brnPopover?.closed.subscribe(() => {
|
|
@@ -926,7 +941,11 @@ class BrnComboboxMultiple {
|
|
|
926
941
|
selectActiveItem() {
|
|
927
942
|
if (!this.isExpanded())
|
|
928
943
|
return;
|
|
929
|
-
const
|
|
944
|
+
const activeItem = this.keyManager.activeItem;
|
|
945
|
+
// setActiveItem() bypasses skipPredicate, so the active item may be disabled.
|
|
946
|
+
if (activeItem?.disabled)
|
|
947
|
+
return;
|
|
948
|
+
const value = activeItem?.value();
|
|
930
949
|
if (this.isValuePresent()(value)) {
|
|
931
950
|
this.select(value);
|
|
932
951
|
}
|
|
@@ -1114,6 +1133,12 @@ class BrnComboboxTrigger {
|
|
|
1114
1133
|
onKeyDown(event) {
|
|
1115
1134
|
if (!this._combobox.isExpanded() && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
1116
1135
|
this._combobox.open();
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
if (this._combobox.isExpanded() && event.key === 'Tab') {
|
|
1139
|
+
// The trigger lives in the page, so Tab moves focus naturally. Close the popup so
|
|
1140
|
+
// it is not left open with nothing focused inside it.
|
|
1141
|
+
this._combobox.close();
|
|
1117
1142
|
}
|
|
1118
1143
|
}
|
|
1119
1144
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnComboboxTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|