ng-primitives 0.99.6 → 0.100.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/a11y/index.d.ts +68 -24
- package/combobox/index.d.ts +49 -16
- package/fesm2022/ng-primitives-a11y.mjs +116 -96
- package/fesm2022/ng-primitives-a11y.mjs.map +1 -1
- package/fesm2022/ng-primitives-combobox.mjs +151 -51
- package/fesm2022/ng-primitives-combobox.mjs.map +1 -1
- package/fesm2022/ng-primitives-internal.mjs +27 -1
- package/fesm2022/ng-primitives-internal.mjs.map +1 -1
- package/fesm2022/ng-primitives-select.mjs +137 -48
- package/fesm2022/ng-primitives-select.mjs.map +1 -1
- package/fesm2022/ng-primitives-slider.mjs +0 -1
- package/fesm2022/ng-primitives-slider.mjs.map +1 -1
- package/internal/index.d.ts +10 -1
- package/package.json +1 -1
- package/schematics/mcp-setup/index.js +0 -1
- package/schematics/mcp-setup/index.js.map +1 -1
- package/select/index.d.ts +41 -17
|
@@ -4,7 +4,7 @@ import { ngpFormControl } from 'ng-primitives/form-field';
|
|
|
4
4
|
import { ngpInteractions } from 'ng-primitives/interactions';
|
|
5
5
|
import { uniqueId } from 'ng-primitives/utils';
|
|
6
6
|
import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
|
|
7
|
-
import { observeResize, injectElementRef } from 'ng-primitives/internal';
|
|
7
|
+
import { observeResize, injectElementRef, scrollIntoViewIfNeeded, domSort } from 'ng-primitives/internal';
|
|
8
8
|
import { createOverlay } from 'ng-primitives/portal';
|
|
9
9
|
import { activeDescendantManager } from 'ng-primitives/a11y';
|
|
10
10
|
|
|
@@ -142,11 +142,23 @@ class NgpSelectOption {
|
|
|
142
142
|
alias: 'ngpSelectOptionDisabled',
|
|
143
143
|
transform: booleanAttribute,
|
|
144
144
|
}]));
|
|
145
|
+
/** The index of the option in the list. */
|
|
146
|
+
this.index = input(undefined, ...(ngDevMode ? [{ debugName: "index", alias: 'ngpSelectOptionIndex' }] : [{
|
|
147
|
+
alias: 'ngpSelectOptionIndex',
|
|
148
|
+
}]));
|
|
145
149
|
/**
|
|
146
150
|
* Whether this option is the active descendant.
|
|
147
151
|
* @internal
|
|
148
152
|
*/
|
|
149
|
-
this.active = computed(() =>
|
|
153
|
+
this.active = computed(() => {
|
|
154
|
+
// if the option has an index, use that to determine if it's active because this
|
|
155
|
+
// is required for virtual scrolling scenarios
|
|
156
|
+
const index = this.index();
|
|
157
|
+
if (index !== undefined) {
|
|
158
|
+
return this.state().activeDescendantManager.index() === index;
|
|
159
|
+
}
|
|
160
|
+
return this.state().activeDescendantManager.id() === this.id();
|
|
161
|
+
}, ...(ngDevMode ? [{ debugName: "active" }] : []));
|
|
150
162
|
/** Whether this option is selected. */
|
|
151
163
|
this.selected = computed(() => {
|
|
152
164
|
const value = this.value();
|
|
@@ -182,31 +194,47 @@ class NgpSelectOption {
|
|
|
182
194
|
if (this.disabled()) {
|
|
183
195
|
return;
|
|
184
196
|
}
|
|
185
|
-
this.state().toggleOption(this);
|
|
197
|
+
this.state().toggleOption(this.id());
|
|
186
198
|
}
|
|
187
199
|
/**
|
|
188
200
|
* Scroll the option into view.
|
|
189
201
|
* @internal
|
|
190
202
|
*/
|
|
191
203
|
scrollIntoView() {
|
|
192
|
-
this.elementRef.nativeElement
|
|
204
|
+
scrollIntoViewIfNeeded(this.elementRef.nativeElement);
|
|
193
205
|
}
|
|
194
206
|
/**
|
|
195
207
|
* Whenever the pointer enters the option, activate it.
|
|
196
208
|
* @internal
|
|
197
209
|
*/
|
|
198
210
|
onPointerEnter() {
|
|
199
|
-
|
|
211
|
+
// if we have a known index, use that to activate the option because this
|
|
212
|
+
// is required for virtual scrolling scenarios
|
|
213
|
+
const index = this.index();
|
|
214
|
+
if (index !== undefined) {
|
|
215
|
+
this.state().activeDescendantManager.activateByIndex(index, {
|
|
216
|
+
scroll: false,
|
|
217
|
+
origin: 'pointer',
|
|
218
|
+
});
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
// otherwise, activate by id
|
|
222
|
+
this.state().activeDescendantManager.activateById(this.id(), {
|
|
223
|
+
scroll: false,
|
|
224
|
+
origin: 'pointer',
|
|
225
|
+
});
|
|
200
226
|
}
|
|
201
227
|
/**
|
|
202
228
|
* Whenever the pointer leaves the option, deactivate it.
|
|
203
229
|
* @internal
|
|
204
230
|
*/
|
|
205
231
|
onPointerLeave() {
|
|
206
|
-
this.state().activeDescendantManager.
|
|
232
|
+
if (this.state().activeDescendantManager.id() === this.id()) {
|
|
233
|
+
this.state().activeDescendantManager.reset({ origin: 'pointer' });
|
|
234
|
+
}
|
|
207
235
|
}
|
|
208
236
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpSelectOption, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
209
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpSelectOption, isStandalone: true, selector: "[ngpSelectOption]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "ngpSelectOptionValue", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpSelectOptionDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "option" }, listeners: { "click": "select()", "pointerenter": "onPointerEnter()", "pointerleave": "onPointerLeave()" }, properties: { "id": "id()", "attr.tabindex": "-1", "attr.aria-selected": "selected() ? \"true\" : undefined", "attr.data-selected": "selected() ? \"\" : undefined", "attr.data-active": "active() ? \"\" : undefined", "attr.data-disabled": "disabled() ? \"\" : undefined" } }, exportAs: ["ngpSelectOption"], ngImport: i0 }); }
|
|
237
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpSelectOption, isStandalone: true, selector: "[ngpSelectOption]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "ngpSelectOptionValue", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpSelectOptionDisabled", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "ngpSelectOptionIndex", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "option" }, listeners: { "click": "select()", "pointerenter": "onPointerEnter()", "pointerleave": "onPointerLeave()" }, properties: { "id": "id()", "attr.tabindex": "-1", "attr.aria-selected": "selected() ? \"true\" : undefined", "attr.data-selected": "selected() ? \"\" : undefined", "attr.data-active": "active() ? \"\" : undefined", "attr.data-disabled": "disabled() ? \"\" : undefined" } }, exportAs: ["ngpSelectOption"], ngImport: i0 }); }
|
|
210
238
|
}
|
|
211
239
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpSelectOption, decorators: [{
|
|
212
240
|
type: Directive,
|
|
@@ -224,7 +252,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
224
252
|
'(click)': 'select()',
|
|
225
253
|
},
|
|
226
254
|
}]
|
|
227
|
-
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectOptionValue", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectOptionDisabled", required: false }] }], onPointerEnter: [{
|
|
255
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectOptionValue", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectOptionDisabled", required: false }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectOptionIndex", required: false }] }], onPointerEnter: [{
|
|
228
256
|
type: HostListener,
|
|
229
257
|
args: ['pointerenter']
|
|
230
258
|
}], onPointerLeave: [{
|
|
@@ -374,6 +402,21 @@ class NgpSelect {
|
|
|
374
402
|
this.container = input(this.config.container, ...(ngDevMode ? [{ debugName: "container", alias: 'ngpSelectDropdownContainer' }] : [{
|
|
375
403
|
alias: 'ngpSelectDropdownContainer',
|
|
376
404
|
}]));
|
|
405
|
+
/**
|
|
406
|
+
* A function that will scroll the active option into view. This can be overridden
|
|
407
|
+
* for cases such as virtual scrolling where we cannot scroll the option directly because
|
|
408
|
+
* it may not be rendered.
|
|
409
|
+
*/
|
|
410
|
+
this.scrollToOption = input(undefined, ...(ngDevMode ? [{ debugName: "scrollToOption", alias: 'ngpSelectScrollToOption' }] : [{
|
|
411
|
+
alias: 'ngpSelectScrollToOption',
|
|
412
|
+
}]));
|
|
413
|
+
/**
|
|
414
|
+
* Provide all the option values to the select. This is useful for virtual scrolling scenarios
|
|
415
|
+
* where not all options are rendered in the DOM. This is not an alternative to adding the options
|
|
416
|
+
* in the DOM, it is only to provide the select with the full list of options. This list should match
|
|
417
|
+
* the order of the options as they would appear in the DOM.
|
|
418
|
+
*/
|
|
419
|
+
this.allOptions = input(undefined, ...(ngDevMode ? [{ debugName: "allOptions", alias: 'ngpSelectOptions' }] : [{ alias: 'ngpSelectOptions' }]));
|
|
377
420
|
/**
|
|
378
421
|
* Store the select portal.
|
|
379
422
|
* @internal
|
|
@@ -399,6 +442,11 @@ class NgpSelect {
|
|
|
399
442
|
* @internal
|
|
400
443
|
*/
|
|
401
444
|
this.open = computed(() => this.overlay()?.isOpen() ?? false, ...(ngDevMode ? [{ debugName: "open" }] : []));
|
|
445
|
+
/**
|
|
446
|
+
* The options sorted by their index or DOM position.
|
|
447
|
+
* @internal
|
|
448
|
+
*/
|
|
449
|
+
this.sortedOptions = computed(() => domSort(this.options(), option => option.elementRef.nativeElement, option => option.index?.()), ...(ngDevMode ? [{ debugName: "sortedOptions" }] : []));
|
|
402
450
|
/**
|
|
403
451
|
* The active key descendant manager.
|
|
404
452
|
* @internal
|
|
@@ -406,13 +454,16 @@ class NgpSelect {
|
|
|
406
454
|
this.activeDescendantManager = activeDescendantManager({
|
|
407
455
|
// we must wrap the signal in a computed to ensure it is not used before it is defined
|
|
408
456
|
disabled: computed(() => this.state.disabled()),
|
|
409
|
-
|
|
410
|
-
|
|
457
|
+
wrap: signal(true),
|
|
458
|
+
count: computed(() => this.allOptions()?.length ?? this.options().length),
|
|
459
|
+
getItemId: index => this.getOptionAtIndex(index)?.id(),
|
|
460
|
+
isItemDisabled: index => this.getOptionAtIndex(index)?.disabled() ?? false,
|
|
461
|
+
scrollIntoView: index => {
|
|
411
462
|
const isPositioned = this.portal()?.overlay()?.isPositioned() ?? false;
|
|
412
|
-
if (!isPositioned ||
|
|
463
|
+
if (!isPositioned || index === -1) {
|
|
413
464
|
return;
|
|
414
465
|
}
|
|
415
|
-
this.
|
|
466
|
+
this.scrollTo(index);
|
|
416
467
|
},
|
|
417
468
|
});
|
|
418
469
|
/** The state of the select. */
|
|
@@ -436,16 +487,27 @@ class NgpSelect {
|
|
|
436
487
|
}
|
|
437
488
|
this.openChange.emit(true);
|
|
438
489
|
await this.portal()?.show();
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
490
|
+
let selectedOptionIdx = -1;
|
|
491
|
+
// if we have been provided with allOptions, we need to find the selected option(s) from that list
|
|
492
|
+
if (this.state.allOptions()) {
|
|
493
|
+
selectedOptionIdx = this.state
|
|
494
|
+
.allOptions()
|
|
495
|
+
.findIndex(option => this.isOptionSelected(option));
|
|
496
|
+
}
|
|
497
|
+
// if we don't have allOptions, find the selected option(s) from the registered options
|
|
498
|
+
if (selectedOptionIdx === -1) {
|
|
499
|
+
// if there is a selected option(s), set the active descendant to the first selected option
|
|
500
|
+
selectedOptionIdx = this.sortedOptions().findIndex(option => this.isOptionSelected(option.value()));
|
|
501
|
+
}
|
|
502
|
+
// if after checking there is a selected option, set the active descendant to the first option
|
|
503
|
+
if (selectedOptionIdx !== -1) {
|
|
504
|
+
// scroll to and activate the selected option
|
|
505
|
+
this.scrollTo(selectedOptionIdx);
|
|
506
|
+
this.activeDescendantManager.activateByIndex(selectedOptionIdx);
|
|
445
507
|
return;
|
|
446
508
|
}
|
|
447
509
|
// activate the selected option or the first option
|
|
448
|
-
this.activeDescendantManager.
|
|
510
|
+
this.activeDescendantManager.first();
|
|
449
511
|
}
|
|
450
512
|
/**
|
|
451
513
|
* Close the dropdown.
|
|
@@ -474,13 +536,14 @@ class NgpSelect {
|
|
|
474
536
|
}
|
|
475
537
|
/**
|
|
476
538
|
* Select an option.
|
|
477
|
-
* @param
|
|
539
|
+
* @param index The index of the option to select.
|
|
478
540
|
* @internal
|
|
479
541
|
*/
|
|
480
|
-
selectOption(
|
|
542
|
+
selectOption(id) {
|
|
481
543
|
if (this.state.disabled()) {
|
|
482
544
|
return;
|
|
483
545
|
}
|
|
546
|
+
const option = this.sortedOptions().find(opt => opt.id() === id);
|
|
484
547
|
if (!option) {
|
|
485
548
|
this.state.value.set(undefined);
|
|
486
549
|
this.closeDropdown();
|
|
@@ -488,7 +551,7 @@ class NgpSelect {
|
|
|
488
551
|
}
|
|
489
552
|
if (this.state.multiple()) {
|
|
490
553
|
// if the option is already selected, do nothing
|
|
491
|
-
if (this.isOptionSelected(option)) {
|
|
554
|
+
if (this.isOptionSelected(option.value())) {
|
|
492
555
|
return;
|
|
493
556
|
}
|
|
494
557
|
const value = [...(this.state.value() ?? []), option.value()];
|
|
@@ -511,7 +574,7 @@ class NgpSelect {
|
|
|
511
574
|
deselectOption(option) {
|
|
512
575
|
// if the select is disabled or the option is not selected, do nothing
|
|
513
576
|
// if the select is single selection, we don't allow deselecting
|
|
514
|
-
if (this.state.disabled() || !this.isOptionSelected(option) || !this.state.multiple()) {
|
|
577
|
+
if (this.state.disabled() || !this.isOptionSelected(option.value()) || !this.state.multiple()) {
|
|
515
578
|
return;
|
|
516
579
|
}
|
|
517
580
|
const values = this.state.value() ?? [];
|
|
@@ -522,25 +585,29 @@ class NgpSelect {
|
|
|
522
585
|
}
|
|
523
586
|
/**
|
|
524
587
|
* Toggle the selection of an option.
|
|
525
|
-
* @param
|
|
588
|
+
* @param id The id of the option to toggle.
|
|
526
589
|
* @internal
|
|
527
590
|
*/
|
|
528
|
-
toggleOption(
|
|
591
|
+
toggleOption(id) {
|
|
529
592
|
if (this.state.disabled()) {
|
|
530
593
|
return;
|
|
531
594
|
}
|
|
595
|
+
const option = this.sortedOptions().find(opt => opt.id() === id);
|
|
596
|
+
if (!option) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
532
599
|
// if the state is single selection, we don't allow toggling
|
|
533
600
|
if (!this.state.multiple()) {
|
|
534
601
|
// always select the option in single selection mode even if it is already selected so that we update the input
|
|
535
|
-
this.selectOption(
|
|
602
|
+
this.selectOption(id);
|
|
536
603
|
return;
|
|
537
604
|
}
|
|
538
605
|
// otherwise toggle the option
|
|
539
|
-
if (this.isOptionSelected(option)) {
|
|
606
|
+
if (this.isOptionSelected(option.value())) {
|
|
540
607
|
this.deselectOption(option);
|
|
541
608
|
}
|
|
542
609
|
else {
|
|
543
|
-
this.selectOption(
|
|
610
|
+
this.selectOption(id);
|
|
544
611
|
}
|
|
545
612
|
}
|
|
546
613
|
/**
|
|
@@ -557,9 +624,9 @@ class NgpSelect {
|
|
|
557
624
|
return false;
|
|
558
625
|
}
|
|
559
626
|
if (this.state.multiple()) {
|
|
560
|
-
return value && value.some(v => this.state.compareWith()(option
|
|
627
|
+
return value && value.some(v => this.state.compareWith()(option, v));
|
|
561
628
|
}
|
|
562
|
-
return this.state.compareWith()(option
|
|
629
|
+
return this.state.compareWith()(option, value);
|
|
563
630
|
}
|
|
564
631
|
/**
|
|
565
632
|
* Activate the next option in the list if there is one.
|
|
@@ -570,21 +637,21 @@ class NgpSelect {
|
|
|
570
637
|
if (this.state.disabled()) {
|
|
571
638
|
return;
|
|
572
639
|
}
|
|
573
|
-
const options = this.
|
|
640
|
+
const options = this.sortedOptions();
|
|
574
641
|
// if there are no options, do nothing
|
|
575
642
|
if (options.length === 0) {
|
|
576
643
|
return;
|
|
577
644
|
}
|
|
578
645
|
// if there is no active option, activate the first option
|
|
579
|
-
if (
|
|
580
|
-
const selectedOption = options.
|
|
646
|
+
if (this.activeDescendantManager.index() === -1) {
|
|
647
|
+
const selectedOption = options.findIndex(option => this.isOptionSelected(option.value()));
|
|
581
648
|
// if there is a selected option(s), set the active descendant to the first selected option
|
|
582
|
-
const targetOption = selectedOption
|
|
583
|
-
this.activeDescendantManager.
|
|
649
|
+
const targetOption = selectedOption !== -1 ? selectedOption : 0;
|
|
650
|
+
this.activeDescendantManager.activateByIndex(targetOption, { origin: 'keyboard' });
|
|
584
651
|
return;
|
|
585
652
|
}
|
|
586
653
|
// otherwise activate the next option
|
|
587
|
-
this.activeDescendantManager.next();
|
|
654
|
+
this.activeDescendantManager.next({ origin: 'keyboard' });
|
|
588
655
|
}
|
|
589
656
|
/**
|
|
590
657
|
* Activate the previous option in the list if there is one.
|
|
@@ -594,21 +661,21 @@ class NgpSelect {
|
|
|
594
661
|
if (this.state.disabled()) {
|
|
595
662
|
return;
|
|
596
663
|
}
|
|
597
|
-
const options = this.
|
|
664
|
+
const options = this.sortedOptions();
|
|
598
665
|
// if there are no options, do nothing
|
|
599
666
|
if (options.length === 0) {
|
|
600
667
|
return;
|
|
601
668
|
}
|
|
602
669
|
// if there is no active option, activate the last option
|
|
603
|
-
if (
|
|
604
|
-
const selectedOption = options.
|
|
670
|
+
if (this.activeDescendantManager.index() === -1) {
|
|
671
|
+
const selectedOption = options.findIndex(option => this.isOptionSelected(option.value()));
|
|
605
672
|
// if there is a selected option(s), set the active descendant to the first selected option
|
|
606
|
-
const targetOption = selectedOption
|
|
607
|
-
this.activeDescendantManager.
|
|
673
|
+
const targetOption = selectedOption !== -1 ? selectedOption : options.length - 1;
|
|
674
|
+
this.activeDescendantManager.activateByIndex(targetOption, { origin: 'keyboard' });
|
|
608
675
|
return;
|
|
609
676
|
}
|
|
610
677
|
// otherwise activate the previous option
|
|
611
|
-
this.activeDescendantManager.previous();
|
|
678
|
+
this.activeDescendantManager.previous({ origin: 'keyboard' });
|
|
612
679
|
}
|
|
613
680
|
/**
|
|
614
681
|
* Register the dropdown portal with the select.
|
|
@@ -673,19 +740,22 @@ class NgpSelect {
|
|
|
673
740
|
break;
|
|
674
741
|
case 'Home':
|
|
675
742
|
if (this.open()) {
|
|
676
|
-
this.activeDescendantManager.first();
|
|
743
|
+
this.activeDescendantManager.first({ origin: 'keyboard' });
|
|
677
744
|
}
|
|
678
745
|
event.preventDefault();
|
|
679
746
|
break;
|
|
680
747
|
case 'End':
|
|
681
748
|
if (this.open()) {
|
|
682
|
-
this.activeDescendantManager.last();
|
|
749
|
+
this.activeDescendantManager.last({ origin: 'keyboard' });
|
|
683
750
|
}
|
|
684
751
|
event.preventDefault();
|
|
685
752
|
break;
|
|
686
753
|
case 'Enter':
|
|
687
754
|
if (this.open()) {
|
|
688
|
-
this.
|
|
755
|
+
const activeId = this.activeDescendantManager.id();
|
|
756
|
+
if (activeId) {
|
|
757
|
+
this.selectOption(activeId);
|
|
758
|
+
}
|
|
689
759
|
}
|
|
690
760
|
else {
|
|
691
761
|
this.openDropdown();
|
|
@@ -707,8 +777,27 @@ class NgpSelect {
|
|
|
707
777
|
this.closeDropdown();
|
|
708
778
|
event.preventDefault();
|
|
709
779
|
}
|
|
780
|
+
scrollTo(index) {
|
|
781
|
+
const scrollToOption = this.state.scrollToOption();
|
|
782
|
+
if (scrollToOption) {
|
|
783
|
+
scrollToOption(index);
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
const option = this.getOptionAtIndex(index);
|
|
787
|
+
if (option) {
|
|
788
|
+
option.scrollIntoView();
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
getOptionAtIndex(index) {
|
|
792
|
+
// if the option has an index, use that to get the option because this is required for virtual scrolling scenarios
|
|
793
|
+
const optionIndex = this.options().findIndex(opt => opt.index?.() === index);
|
|
794
|
+
if (optionIndex !== -1) {
|
|
795
|
+
return this.options()[optionIndex];
|
|
796
|
+
}
|
|
797
|
+
return this.sortedOptions()[index];
|
|
798
|
+
}
|
|
710
799
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
711
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpSelect, isStandalone: true, selector: "[ngpSelect]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "ngpSelectValue", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "ngpSelectMultiple", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpSelectDisabled", isSignal: true, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "ngpSelectCompareWith", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpSelectDropdownPlacement", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpSelectDropdownContainer", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "ngpSelectValueChange", openChange: "ngpSelectOpenChange" }, host: { attributes: { "role": "combobox" }, listeners: { "click": "toggleDropdown()", "keydown": "handleKeydown($event)", "blur": "onBlur($event)" }, properties: { "id": "state.id()", "attr.aria-expanded": "open()", "attr.aria-controls": "open() ? dropdown()?.id() : undefined", "attr.aria-activedescendant": "open() ? activeDescendantManager.
|
|
800
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: NgpSelect, isStandalone: true, selector: "[ngpSelect]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "ngpSelectValue", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "ngpSelectMultiple", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpSelectDisabled", isSignal: true, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "ngpSelectCompareWith", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpSelectDropdownPlacement", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpSelectDropdownContainer", isSignal: true, isRequired: false, transformFunction: null }, scrollToOption: { classPropertyName: "scrollToOption", publicName: "ngpSelectScrollToOption", isSignal: true, isRequired: false, transformFunction: null }, allOptions: { classPropertyName: "allOptions", publicName: "ngpSelectOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "ngpSelectValueChange", openChange: "ngpSelectOpenChange" }, host: { attributes: { "role": "combobox" }, listeners: { "click": "toggleDropdown()", "keydown": "handleKeydown($event)", "blur": "onBlur($event)" }, properties: { "id": "state.id()", "attr.aria-expanded": "open()", "attr.aria-controls": "open() ? dropdown()?.id() : undefined", "attr.aria-activedescendant": "open() ? activeDescendantManager.id() : undefined", "attr.tabindex": "state.disabled() ? -1 : 0", "attr.data-open": "open() ? \"\" : undefined", "attr.data-disabled": "state.disabled() ? \"\" : undefined", "attr.data-multiple": "state.multiple() ? \"\" : undefined" } }, providers: [provideSelectState()], exportAs: ["ngpSelect"], ngImport: i0 }); }
|
|
712
801
|
}
|
|
713
802
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgpSelect, decorators: [{
|
|
714
803
|
type: Directive,
|
|
@@ -721,14 +810,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
721
810
|
'[id]': 'state.id()',
|
|
722
811
|
'[attr.aria-expanded]': 'open()',
|
|
723
812
|
'[attr.aria-controls]': 'open() ? dropdown()?.id() : undefined',
|
|
724
|
-
'[attr.aria-activedescendant]': 'open() ? activeDescendantManager.
|
|
813
|
+
'[attr.aria-activedescendant]': 'open() ? activeDescendantManager.id() : undefined',
|
|
725
814
|
'[attr.tabindex]': 'state.disabled() ? -1 : 0',
|
|
726
815
|
'[attr.data-open]': 'open() ? "" : undefined',
|
|
727
816
|
'[attr.data-disabled]': 'state.disabled() ? "" : undefined',
|
|
728
817
|
'[attr.data-multiple]': 'state.multiple() ? "" : undefined',
|
|
729
818
|
},
|
|
730
819
|
}]
|
|
731
|
-
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectValue", required: false }] }], valueChange: [{ type: i0.Output, args: ["ngpSelectValueChange"] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectMultiple", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectDisabled", required: false }] }], openChange: [{ type: i0.Output, args: ["ngpSelectOpenChange"] }], compareWith: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectCompareWith", required: false }] }], placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectDropdownPlacement", required: false }] }], container: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectDropdownContainer", required: false }] }], toggleDropdown: [{
|
|
820
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectValue", required: false }] }], valueChange: [{ type: i0.Output, args: ["ngpSelectValueChange"] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectMultiple", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectDisabled", required: false }] }], openChange: [{ type: i0.Output, args: ["ngpSelectOpenChange"] }], compareWith: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectCompareWith", required: false }] }], placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectDropdownPlacement", required: false }] }], container: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectDropdownContainer", required: false }] }], scrollToOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectScrollToOption", required: false }] }], allOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpSelectOptions", required: false }] }], toggleDropdown: [{
|
|
732
821
|
type: HostListener,
|
|
733
822
|
args: ['click']
|
|
734
823
|
}], handleKeydown: [{
|