ng-primitives 0.0.7 → 0.2.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/README.md +14 -4
- package/accordion/accordion-trigger/accordion-trigger.directive.d.ts +2 -1
- package/autofill/README.md +3 -0
- package/autofill/autofill/autofill.directive.d.ts +19 -0
- package/{select/select-button/select-button.token.d.ts → autofill/autofill/autofill.token.d.ts} +4 -4
- package/autofill/index.d.ts +9 -0
- package/avatar/avatar/avatar.directive.d.ts +2 -1
- package/button/README.md +3 -0
- package/button/button/button.directive.d.ts +27 -0
- package/{select/select-option/select-option.token.d.ts → button/button/button.token.d.ts} +4 -4
- package/button/index.d.ts +9 -0
- package/checkbox/checkbox/checkbox.directive.d.ts +11 -61
- package/checkbox/index.d.ts +0 -4
- package/esm2022/a11y/visually-hidden/visually-hidden.directive.mjs +3 -3
- package/esm2022/accordion/accordion/accordion.directive.mjs +5 -4
- package/esm2022/accordion/accordion-content/accordion-content.directive.mjs +5 -6
- package/esm2022/accordion/accordion-item/accordion-item.directive.mjs +5 -5
- package/esm2022/accordion/accordion-trigger/accordion-trigger.directive.mjs +8 -5
- package/esm2022/autofill/autofill/autofill.directive.mjs +71 -0
- package/esm2022/autofill/autofill/autofill.token.mjs +16 -0
- package/esm2022/autofill/index.mjs +10 -0
- package/esm2022/autofill/ng-primitives-autofill.mjs +5 -0
- package/esm2022/avatar/avatar/avatar.directive.mjs +7 -4
- package/esm2022/avatar/avatar-fallback/avatar-fallback.directive.mjs +3 -3
- package/esm2022/avatar/avatar-image/avatar-image.directive.mjs +3 -3
- package/esm2022/button/button/button.directive.mjs +47 -0
- package/esm2022/button/button/button.token.mjs +16 -0
- package/esm2022/button/index.mjs +10 -0
- package/esm2022/button/ng-primitives-button.mjs +5 -0
- package/esm2022/checkbox/checkbox/checkbox.directive.mjs +29 -79
- package/esm2022/checkbox/index.mjs +1 -5
- package/esm2022/file-upload/file-upload/file-upload.directive.mjs +7 -4
- package/esm2022/focus-trap/focus-trap/focus-trap.directive.mjs +262 -0
- package/esm2022/focus-trap/focus-trap/focus-trap.token.mjs +16 -0
- package/esm2022/focus-trap/index.mjs +10 -0
- package/esm2022/focus-trap/ng-primitives-focus-trap.mjs +5 -0
- package/esm2022/form-field/description/description.directive.mjs +14 -14
- package/esm2022/form-field/error/error.directive.mjs +27 -29
- package/esm2022/form-field/form-control/form-control.directive.mjs +22 -16
- package/esm2022/form-field/form-field/form-field.directive.mjs +3 -3
- package/esm2022/form-field/form-field/form-field.token.mjs +3 -7
- package/esm2022/form-field/label/label.directive.mjs +56 -17
- package/esm2022/input/index.mjs +10 -0
- package/esm2022/input/input/input.directive.mjs +55 -0
- package/esm2022/input/input/input.token.mjs +16 -0
- package/esm2022/input/ng-primitives-input.mjs +5 -0
- package/esm2022/interactions/focus/focus.directive.mjs +15 -10
- package/esm2022/interactions/focus-visible/focus-visible.directive.mjs +12 -7
- package/esm2022/interactions/hover/hover.directive.mjs +16 -11
- package/esm2022/interactions/index.mjs +5 -1
- package/esm2022/interactions/move/move.directive.mjs +216 -0
- package/esm2022/interactions/move/move.token.mjs +16 -0
- package/esm2022/interactions/press/press.directive.mjs +118 -0
- package/esm2022/interactions/press/press.token.mjs +16 -0
- package/esm2022/internal/disabled/disabled.mjs +19 -0
- package/esm2022/internal/index.mjs +11 -0
- package/esm2022/internal/ng-primitives-internal.mjs +5 -0
- package/esm2022/internal/orientation/orientation.mjs +19 -0
- package/esm2022/internal/style-injector/style-injector.mjs +81 -0
- package/esm2022/progress/progress/progress.directive.mjs +3 -3
- package/esm2022/progress/progress-indicator/progress-indicator.directive.mjs +3 -3
- package/esm2022/radio/radio-group/radio-group.directive.mjs +14 -54
- package/esm2022/radio/radio-indicator/radio-indicator.directive.mjs +8 -5
- package/esm2022/radio/radio-item/radio-item.directive.mjs +8 -6
- package/esm2022/resize/resize/resize.directive.mjs +3 -3
- package/esm2022/roving-focus/roving-focus-group/roving-focus-group.directive.mjs +14 -9
- package/esm2022/roving-focus/roving-focus-item/roving-focus-item.directive.mjs +3 -3
- package/esm2022/search/index.mjs +10 -0
- package/esm2022/search/ng-primitives-search.mjs +5 -0
- package/esm2022/search/search-field/search-field.directive.mjs +47 -0
- package/esm2022/search/search-field/search-field.token.mjs +16 -0
- package/esm2022/select/index.mjs +1 -7
- package/esm2022/select/select/select.directive.mjs +23 -36
- package/esm2022/select/select/select.token.mjs +1 -1
- package/esm2022/slider/slider/slider.directive.mjs +18 -5
- package/esm2022/slider/slider-range/slider-range.directive.mjs +6 -5
- package/esm2022/slider/slider-thumb/slider-thumb.directive.mjs +7 -4
- package/esm2022/slider/slider-track/slider-track.directive.mjs +8 -4
- package/esm2022/switch/switch/switch.directive.mjs +18 -58
- package/esm2022/switch/switch-thumb/switch-thumb.directive.mjs +9 -6
- package/esm2022/tabs/tab-button/tab-button.directive.mjs +8 -6
- package/esm2022/tabs/tab-list/tab-list.directive.mjs +3 -3
- package/esm2022/tabs/tab-panel/tab-panel.directive.mjs +5 -6
- package/esm2022/tabs/tabset/tabset.directive.mjs +14 -18
- package/esm2022/textarea/index.mjs +10 -0
- package/esm2022/textarea/ng-primitives-textarea.mjs +5 -0
- package/esm2022/textarea/textarea/textarea.directive.mjs +37 -0
- package/esm2022/textarea/textarea/textarea.token.mjs +16 -0
- package/esm2022/toggle/toggle/toggle.directive.mjs +33 -13
- package/esm2022/tooltip/tooltip/tooltip.directive.mjs +3 -3
- package/esm2022/tooltip/tooltip-trigger/tooltip-trigger.directive.mjs +7 -7
- package/esm2022/utils/helpers/focus-manager.mjs +3 -3
- package/esm2022/utils/index.mjs +2 -2
- package/esm2022/utils/signals/async.mjs +11 -17
- package/fesm2022/ng-primitives-a11y.mjs +3 -3
- package/fesm2022/ng-primitives-accordion.mjs +19 -16
- package/fesm2022/ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/ng-primitives-autofill.mjs +100 -0
- package/fesm2022/ng-primitives-autofill.mjs.map +1 -0
- package/fesm2022/ng-primitives-avatar.mjs +13 -10
- package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/ng-primitives-button.mjs +76 -0
- package/fesm2022/ng-primitives-button.mjs.map +1 -0
- package/fesm2022/ng-primitives-checkbox.mjs +25 -203
- package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/ng-primitives-file-upload.mjs +6 -3
- package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
- package/fesm2022/ng-primitives-focus-trap.mjs +291 -0
- package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -0
- package/fesm2022/ng-primitives-form-field.mjs +119 -80
- package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
- package/fesm2022/ng-primitives-input.mjs +84 -0
- package/fesm2022/ng-primitives-input.mjs.map +1 -0
- package/fesm2022/ng-primitives-interactions.mjs +394 -26
- package/fesm2022/ng-primitives-interactions.mjs.map +1 -1
- package/fesm2022/ng-primitives-internal.mjs +132 -0
- package/fesm2022/ng-primitives-internal.mjs.map +1 -0
- package/fesm2022/ng-primitives-progress.mjs +6 -6
- package/fesm2022/ng-primitives-radio.mjs +25 -62
- package/fesm2022/ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/ng-primitives-resize.mjs +3 -3
- package/fesm2022/ng-primitives-roving-focus.mjs +15 -10
- package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/ng-primitives-search.mjs +76 -0
- package/fesm2022/ng-primitives-search.mjs.map +1 -0
- package/fesm2022/ng-primitives-select.mjs +23 -395
- package/fesm2022/ng-primitives-select.mjs.map +1 -1
- package/fesm2022/ng-primitives-slider.mjs +35 -14
- package/fesm2022/ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/ng-primitives-switch.mjs +23 -62
- package/fesm2022/ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/ng-primitives-tabs.mjs +27 -30
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/ng-primitives-textarea.mjs +66 -0
- package/fesm2022/ng-primitives-textarea.mjs.map +1 -0
- package/fesm2022/ng-primitives-toggle.mjs +32 -12
- package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/ng-primitives-tooltip.mjs +9 -9
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/ng-primitives-utils.mjs +14 -20
- package/fesm2022/ng-primitives-utils.mjs.map +1 -1
- package/file-upload/file-upload/file-upload.directive.d.ts +2 -1
- package/focus-trap/README.md +3 -0
- package/focus-trap/focus-trap/focus-trap.directive.d.ts +64 -0
- package/{select/select-options/select-options.token.d.ts → focus-trap/focus-trap/focus-trap.token.d.ts} +4 -4
- package/focus-trap/index.d.ts +9 -0
- package/form-field/description/description.directive.d.ts +1 -1
- package/form-field/error/error.directive.d.ts +9 -5
- package/form-field/form-control/form-control.directive.d.ts +7 -3
- package/form-field/form-field/form-field.token.d.ts +1 -1
- package/form-field/label/label.directive.d.ts +3 -2
- package/input/README.md +3 -0
- package/input/index.d.ts +9 -0
- package/input/input/input.directive.d.ts +33 -0
- package/input/input/input.token.d.ts +14 -0
- package/interactions/focus/focus.directive.d.ts +6 -2
- package/interactions/focus-visible/focus-visible.directive.d.ts +5 -1
- package/interactions/hover/hover.directive.d.ts +5 -1
- package/interactions/index.d.ts +4 -0
- package/interactions/move/move.directive.d.ts +126 -0
- package/interactions/move/move.token.d.ts +14 -0
- package/interactions/press/press.directive.d.ts +59 -0
- package/interactions/press/press.token.d.ts +14 -0
- package/internal/README.md +3 -0
- package/internal/disabled/disabled.d.ts +21 -0
- package/internal/index.d.ts +10 -0
- package/internal/orientation/orientation.d.ts +22 -0
- package/internal/style-injector/style-injector.d.ts +36 -0
- package/package.json +49 -7
- package/radio/radio-group/radio-group.directive.d.ts +4 -41
- package/radio/radio-indicator/radio-indicator.directive.d.ts +2 -1
- package/radio/radio-item/radio-item.directive.d.ts +2 -1
- package/roving-focus/roving-focus-group/roving-focus-group.directive.d.ts +7 -2
- package/search/README.md +3 -0
- package/search/index.d.ts +9 -0
- package/search/search-field/search-field.directive.d.ts +15 -0
- package/search/search-field/search-field.token.d.ts +14 -0
- package/select/index.d.ts +0 -6
- package/select/select/select.directive.d.ts +7 -22
- package/select/select/select.token.d.ts +2 -2
- package/slider/slider/slider.directive.d.ts +4 -2
- package/slider/slider-thumb/slider-thumb.directive.d.ts +2 -1
- package/slider/slider-track/slider-track.directive.d.ts +1 -1
- package/switch/switch/switch.directive.d.ts +5 -45
- package/switch/switch-thumb/switch-thumb.directive.d.ts +2 -1
- package/tabs/tab-button/tab-button.directive.d.ts +2 -1
- package/tabs/tabset/tabset.directive.d.ts +3 -9
- package/textarea/README.md +3 -0
- package/textarea/index.d.ts +9 -0
- package/textarea/textarea/textarea.directive.d.ts +20 -0
- package/textarea/textarea/textarea.token.d.ts +14 -0
- package/toggle/toggle/toggle.directive.d.ts +16 -4
- package/utils/index.d.ts +1 -1
- package/utils/signals/async.d.ts +10 -12
- package/checkbox/checkbox-indicator/checkbox-indicator.directive.d.ts +0 -19
- package/checkbox/checkbox-indicator/checkbox-indicator.token.d.ts +0 -15
- package/checkbox/checkbox-input/checkbox-input.directive.d.ts +0 -10
- package/checkbox/checkbox-label/checkbox-label.directive.d.ts +0 -9
- package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.directive.mjs +0 -51
- package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.token.mjs +0 -17
- package/esm2022/checkbox/checkbox-input/checkbox-input.directive.mjs +0 -40
- package/esm2022/checkbox/checkbox-label/checkbox-label.directive.mjs +0 -32
- package/esm2022/select/select-button/select-button.directive.mjs +0 -84
- package/esm2022/select/select-button/select-button.token.mjs +0 -16
- package/esm2022/select/select-option/select-option.directive.mjs +0 -90
- package/esm2022/select/select-option/select-option.token.mjs +0 -16
- package/esm2022/select/select-options/select-options.directive.mjs +0 -157
- package/esm2022/select/select-options/select-options.token.mjs +0 -16
- package/select/select-button/select-button.directive.d.ts +0 -51
- package/select/select-option/select-option.directive.d.ts +0 -57
- package/select/select-options/select-options.directive.d.ts +0 -65
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject,
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
2
|
+
import { InjectionToken, inject, input, booleanAttribute, Directive } from '@angular/core';
|
|
3
|
+
import * as i1 from 'ng-primitives/form-field';
|
|
4
|
+
import { NgpFormControl } from 'ng-primitives/form-field';
|
|
5
|
+
import * as i2 from 'ng-primitives/interactions';
|
|
6
|
+
import { NgpFocusVisible, NgpHover, NgpPress } from 'ng-primitives/interactions';
|
|
7
|
+
import { NgpDisabledToken } from 'ng-primitives/internal';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Copyright © 2024 Angular Primitives.
|
|
@@ -19,410 +21,36 @@ function injectSelect() {
|
|
|
19
21
|
return inject(NgpSelectToken);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
/**
|
|
23
|
-
* Copyright © 2024 Angular Primitives.
|
|
24
|
-
* https://github.com/ng-primitives/ng-primitives
|
|
25
|
-
*
|
|
26
|
-
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
27
|
-
* LICENSE file in the root directory of this source tree.
|
|
28
|
-
*/
|
|
29
|
-
const NgpSelectButtonToken = new InjectionToken('NgpSelectButtonToken');
|
|
30
|
-
/**
|
|
31
|
-
* Inject the SelectButton directive instance
|
|
32
|
-
*/
|
|
33
|
-
function injectSelectButton() {
|
|
34
|
-
return inject(NgpSelectButtonToken);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
class NgpSelectButton {
|
|
38
|
-
constructor() {
|
|
39
|
-
/**
|
|
40
|
-
* Access the parent select component.
|
|
41
|
-
*/
|
|
42
|
-
this.select = injectSelect();
|
|
43
|
-
/**
|
|
44
|
-
* Access the disposable helpers.
|
|
45
|
-
*/
|
|
46
|
-
this.disposables = injectDisposables();
|
|
47
|
-
/**
|
|
48
|
-
* Access the element reference.
|
|
49
|
-
* @internal
|
|
50
|
-
*/
|
|
51
|
-
this.element = inject(ElementRef);
|
|
52
|
-
/**
|
|
53
|
-
* Access the focus manager
|
|
54
|
-
*/
|
|
55
|
-
this.focusManager = inject(FocusManager);
|
|
56
|
-
/**
|
|
57
|
-
* Optionally define an id for the button. By default, the id is generated.
|
|
58
|
-
*/
|
|
59
|
-
this.id = input(uniqueId('select-button'));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Toggle the select open state.
|
|
63
|
-
*/
|
|
64
|
-
toggle() {
|
|
65
|
-
this.select.open.update(open => !open);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Handle keyboard events. If the list is closed, open it when the user presses the arrow keys.
|
|
69
|
-
* If the list is open then we navigate using active descendant.
|
|
70
|
-
* @param event
|
|
71
|
-
*/
|
|
72
|
-
keydown(event) {
|
|
73
|
-
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
74
|
-
this.select.open.set(true);
|
|
75
|
-
// stop the event from triggering scrolling on the dropdown
|
|
76
|
-
event.preventDefault();
|
|
77
|
-
}
|
|
78
|
-
// if the escape key is pressed, close the dropdown
|
|
79
|
-
if (event.key === 'Escape') {
|
|
80
|
-
this.select.open.set(false);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Focus the button element.
|
|
85
|
-
* @param origin
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
88
|
-
focus(origin) {
|
|
89
|
-
// we run after the next tick to ensure any in-progress events do not get
|
|
90
|
-
// redirected to the button element
|
|
91
|
-
this.disposables.requestAnimationFrame(() => this.focusManager.focus(this.element, origin));
|
|
92
|
-
}
|
|
93
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpSelectButton, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
94
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.0.2", type: NgpSelectButton, isStandalone: true, selector: "button[ngpSelectButton]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "type": "button", "aria-haspopup": "listbox" }, listeners: { "click": "toggle()", "keydown": "keydown($event)" }, properties: { "attr.id": "id()", "attr.aria-expanded": "select.open()", "attr.aria-controls": "select.open() ? select.options()?.id() : null", "attr.data-state": "select.open() ? \"open\" : \"closed\"" } }, providers: [{ provide: NgpSelectButtonToken, useExisting: NgpSelectButton }], exportAs: ["ngpSelectButton"], ngImport: i0 }); }
|
|
95
|
-
}
|
|
96
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpSelectButton, decorators: [{
|
|
97
|
-
type: Directive,
|
|
98
|
-
args: [{
|
|
99
|
-
standalone: true,
|
|
100
|
-
selector: 'button[ngpSelectButton]',
|
|
101
|
-
exportAs: 'ngpSelectButton',
|
|
102
|
-
providers: [{ provide: NgpSelectButtonToken, useExisting: NgpSelectButton }],
|
|
103
|
-
host: {
|
|
104
|
-
type: 'button',
|
|
105
|
-
'aria-haspopup': 'listbox',
|
|
106
|
-
'[attr.id]': 'id()',
|
|
107
|
-
'[attr.aria-expanded]': 'select.open()',
|
|
108
|
-
'[attr.aria-controls]': 'select.open() ? select.options()?.id() : null',
|
|
109
|
-
'[attr.data-state]': 'select.open() ? "open" : "closed"',
|
|
110
|
-
'(click)': 'toggle()',
|
|
111
|
-
'(keydown)': 'keydown($event)',
|
|
112
|
-
},
|
|
113
|
-
}]
|
|
114
|
-
}] });
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Copyright © 2024 Angular Primitives.
|
|
118
|
-
* https://github.com/ng-primitives/ng-primitives
|
|
119
|
-
*
|
|
120
|
-
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
121
|
-
* LICENSE file in the root directory of this source tree.
|
|
122
|
-
*/
|
|
123
|
-
const NgpSelectOptionToken = new InjectionToken('NgpSelectOptionToken');
|
|
124
|
-
/**
|
|
125
|
-
* Inject the SelectOption directive instance
|
|
126
|
-
*/
|
|
127
|
-
function injectSelectOption() {
|
|
128
|
-
return inject(NgpSelectOptionToken);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
class NgpSelectOption {
|
|
132
|
-
constructor() {
|
|
133
|
-
/**
|
|
134
|
-
* Access the parent select component.
|
|
135
|
-
*/
|
|
136
|
-
this.select = injectSelect();
|
|
137
|
-
/**
|
|
138
|
-
* Access the element reference.
|
|
139
|
-
*/
|
|
140
|
-
this.element = inject((ElementRef));
|
|
141
|
-
/**
|
|
142
|
-
* Optionally define an id for the option. By default, the id is generated.
|
|
143
|
-
*/
|
|
144
|
-
this.id = input(uniqueId('select-option'));
|
|
145
|
-
/**
|
|
146
|
-
* The value of the option.
|
|
147
|
-
*/
|
|
148
|
-
this.value = input.required({
|
|
149
|
-
alias: 'ngpSelectOptionValue',
|
|
150
|
-
});
|
|
151
|
-
/**
|
|
152
|
-
* Whether the option is disabled.
|
|
153
|
-
*/
|
|
154
|
-
this.isDisabled = input(false, {
|
|
155
|
-
alias: 'ngpSelectOptionDisabled',
|
|
156
|
-
transform: booleanAttribute,
|
|
157
|
-
});
|
|
158
|
-
/**
|
|
159
|
-
* Whether the option is the active descendant.
|
|
160
|
-
*/
|
|
161
|
-
this.active = signal(false);
|
|
162
|
-
/**
|
|
163
|
-
* Determine if the option is selected.
|
|
164
|
-
*/
|
|
165
|
-
this.selected = computed(() => this.select.value() === this.value());
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Set the active styles for the option.
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
setActiveStyles() {
|
|
172
|
-
this.active.set(true);
|
|
173
|
-
// scroll the option into view if needed
|
|
174
|
-
this.element.nativeElement.scrollIntoView({ block: 'nearest' });
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Set the inactive styles for the option.
|
|
178
|
-
* @internal
|
|
179
|
-
*/
|
|
180
|
-
setInactiveStyles() {
|
|
181
|
-
this.active.set(false);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Handle the click event on the option.
|
|
185
|
-
*/
|
|
186
|
-
selectOption() {
|
|
187
|
-
if (!this.isDisabled()) {
|
|
188
|
-
this.select.value.update(() => this.value());
|
|
189
|
-
// close the dropdown after selecting an option
|
|
190
|
-
this.select.open.set(false);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpSelectOption, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
194
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.0.2", 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: true, transformFunction: null }, isDisabled: { classPropertyName: "isDisabled", publicName: "ngpSelectOptionDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "option" }, listeners: { "click": "selectOption()" }, properties: { "attr.id": "id()", "attr.aria-selected": "selected()", "attr.aria-disabled": "isDisabled()", "attr.data-state": "selected() ? \"selected\" : \"unselected\"", "attr.data-active": "active() ? \"\" : null", "attr.data-disabled": "isDisabled()" } }, providers: [{ provide: NgpSelectOptionToken, useExisting: NgpSelectOption }], exportAs: ["ngpSelectOption"], ngImport: i0 }); }
|
|
195
|
-
}
|
|
196
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpSelectOption, decorators: [{
|
|
197
|
-
type: Directive,
|
|
198
|
-
args: [{
|
|
199
|
-
standalone: true,
|
|
200
|
-
selector: '[ngpSelectOption]',
|
|
201
|
-
exportAs: 'ngpSelectOption',
|
|
202
|
-
providers: [{ provide: NgpSelectOptionToken, useExisting: NgpSelectOption }],
|
|
203
|
-
host: {
|
|
204
|
-
role: 'option',
|
|
205
|
-
'[attr.id]': 'id()',
|
|
206
|
-
'[attr.aria-selected]': 'selected()',
|
|
207
|
-
'[attr.aria-disabled]': 'isDisabled()',
|
|
208
|
-
'[attr.data-state]': 'selected() ? "selected" : "unselected"',
|
|
209
|
-
'[attr.data-active]': 'active() ? "" : null',
|
|
210
|
-
'[attr.data-disabled]': 'isDisabled()',
|
|
211
|
-
'(click)': 'selectOption()',
|
|
212
|
-
},
|
|
213
|
-
}]
|
|
214
|
-
}] });
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Copyright © 2024 Angular Primitives.
|
|
218
|
-
* https://github.com/ng-primitives/ng-primitives
|
|
219
|
-
*
|
|
220
|
-
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
221
|
-
* LICENSE file in the root directory of this source tree.
|
|
222
|
-
*/
|
|
223
|
-
const NgpSelectOptionsToken = new InjectionToken('NgpSelectOptionsToken');
|
|
224
|
-
/**
|
|
225
|
-
* Inject the SelectOptions directive instance
|
|
226
|
-
*/
|
|
227
|
-
function injectSelectOptions() {
|
|
228
|
-
return inject(NgpSelectOptionsToken);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Copyright © 2024 Angular Primitives.
|
|
233
|
-
* https://github.com/ng-primitives/ng-primitives
|
|
234
|
-
*
|
|
235
|
-
* This source code is licensed under the CC BY-ND 4.0 license found in the
|
|
236
|
-
* LICENSE file in the root directory of this source tree.
|
|
237
|
-
*/
|
|
238
|
-
class NgpSelectOptions {
|
|
239
|
-
/**
|
|
240
|
-
* Focus the options list when it becomes visible.
|
|
241
|
-
*/
|
|
242
|
-
constructor() {
|
|
243
|
-
/**
|
|
244
|
-
* Access the parent select component.
|
|
245
|
-
*/
|
|
246
|
-
this.select = injectSelect();
|
|
247
|
-
/**
|
|
248
|
-
* Access the injector.
|
|
249
|
-
*/
|
|
250
|
-
this.injector = inject(Injector);
|
|
251
|
-
/**
|
|
252
|
-
* Access the element reference.
|
|
253
|
-
*/
|
|
254
|
-
this.element = inject(ElementRef);
|
|
255
|
-
/**
|
|
256
|
-
* Access the change detector.
|
|
257
|
-
*/
|
|
258
|
-
this.changeDetector = inject(ChangeDetectorRef);
|
|
259
|
-
/**
|
|
260
|
-
* Access all the options in the list.
|
|
261
|
-
*/
|
|
262
|
-
this.options = contentChildren(NgpSelectOptionToken, {
|
|
263
|
-
descendants: true,
|
|
264
|
-
});
|
|
265
|
-
/**
|
|
266
|
-
* Optionally define an id for the options list. By default, the id is generated.
|
|
267
|
-
*/
|
|
268
|
-
this.id = input(uniqueId('select-options'));
|
|
269
|
-
/**
|
|
270
|
-
* Handle the active descendant.
|
|
271
|
-
*/
|
|
272
|
-
this.activeDescendantKeyManager = new ActiveDescendantKeyManager(this.options, this.injector);
|
|
273
|
-
/**
|
|
274
|
-
* Get the active descendant id
|
|
275
|
-
*/
|
|
276
|
-
this.activeDescendant = signal(null);
|
|
277
|
-
// update the mounted state when the select dropdown is opened or closed
|
|
278
|
-
effect(() => (this.select.open() ? this.open() : this.close()), { allowSignalWrites: true });
|
|
279
|
-
// whenever the active descendant changes update the active descendant id
|
|
280
|
-
this.activeDescendantKeyManager.change
|
|
281
|
-
.pipe(takeUntilDestroyed())
|
|
282
|
-
.subscribe(() => this.activeDescendant.set(this.activeDescendantKeyManager.activeItem?.id() ?? null));
|
|
283
|
-
}
|
|
284
|
-
ngAfterViewInit() {
|
|
285
|
-
// by default the selected option should be active when the options list is opened.
|
|
286
|
-
// if there is no selected option, the first option should be active.
|
|
287
|
-
if (this.select.value() === null) {
|
|
288
|
-
this.activeDescendantKeyManager.setFirstItemActive();
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
const selectedOption = this.options().find(option => option.value() === this.select.value());
|
|
292
|
-
this.activeDescendantKeyManager.setActiveItem(selectedOption ?? this.options()[0]);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Handle the opening of the options list.
|
|
297
|
-
*/
|
|
298
|
-
open() {
|
|
299
|
-
// force change detection to ensure the options list is visible before focusing
|
|
300
|
-
this.changeDetector.detectChanges();
|
|
301
|
-
this.element.nativeElement.focus();
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Handle the closing of the options list.
|
|
305
|
-
* @param origin
|
|
306
|
-
*/
|
|
307
|
-
close(origin) {
|
|
308
|
-
// if the options list is already closed, do nothing
|
|
309
|
-
if (!this.select.open()) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
this.select.open.set(false);
|
|
313
|
-
this.select.button().focus(origin);
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* If the user clicks outside of the options list, close the dropdown.
|
|
317
|
-
* @param event
|
|
318
|
-
*/
|
|
319
|
-
closeOnOutsideClick(event) {
|
|
320
|
-
// if the user performs a click that is not within the options list or the slect button, close the dropdown
|
|
321
|
-
if (this.select.open() &&
|
|
322
|
-
!this.element.nativeElement.contains(event.target) &&
|
|
323
|
-
!this.select.button().element.nativeElement.contains(event.target)) {
|
|
324
|
-
this.close();
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Handle keyboard events.
|
|
329
|
-
*
|
|
330
|
-
* - If the user presses the tab key keep focus on the dropdown.
|
|
331
|
-
* - If the user presses the escape key, close the dropdown.
|
|
332
|
-
* @param event
|
|
333
|
-
*/
|
|
334
|
-
keydown(event) {
|
|
335
|
-
// forward the keyboard event to the active descendant key manager
|
|
336
|
-
this.activeDescendantKeyManager.onKeydown(event);
|
|
337
|
-
// prevent the default tab behavior - this is essentially a focus trap
|
|
338
|
-
if (event.key === 'Tab') {
|
|
339
|
-
event.preventDefault();
|
|
340
|
-
event.stopPropagation();
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
// if the escape key is pressed, close the dropdown
|
|
344
|
-
if (event.key === 'Escape') {
|
|
345
|
-
this.close('keyboard');
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
// if the space or enter key is pressed, select the active option
|
|
349
|
-
if (event.key === ' ' || event.key === 'Enter') {
|
|
350
|
-
const activeItem = this.activeDescendantKeyManager.activeItem;
|
|
351
|
-
if (activeItem && !activeItem.isDisabled()) {
|
|
352
|
-
this.select.value.set(activeItem.value());
|
|
353
|
-
this.close('keyboard');
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpSelectOptions, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
358
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "18.0.2", type: NgpSelectOptions, isStandalone: true, selector: "[ngpSelectOptions]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "listbox" }, listeners: { "keydown": "keydown($event)", "document:click": "closeOnOutsideClick($event)" }, properties: { "attr.id": "id()", "attr.aria-labelledby": "select.button().id()", "attr.tabindex": "0", "attr.aria-activedescendant": "activeDescendant()", "attr.data-state": "select.open() ? \"open\" : \"closed\"" } }, providers: [{ provide: NgpSelectOptionsToken, useExisting: NgpSelectOptions }], queries: [{ propertyName: "options", predicate: NgpSelectOptionToken, descendants: true, isSignal: true }], exportAs: ["ngpSelectOptions"], ngImport: i0 }); }
|
|
359
|
-
}
|
|
360
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NgpSelectOptions, decorators: [{
|
|
361
|
-
type: Directive,
|
|
362
|
-
args: [{
|
|
363
|
-
standalone: true,
|
|
364
|
-
selector: '[ngpSelectOptions]',
|
|
365
|
-
exportAs: 'ngpSelectOptions',
|
|
366
|
-
providers: [{ provide: NgpSelectOptionsToken, useExisting: NgpSelectOptions }],
|
|
367
|
-
host: {
|
|
368
|
-
role: 'listbox',
|
|
369
|
-
'[attr.id]': 'id()',
|
|
370
|
-
'[attr.aria-labelledby]': 'select.button().id()',
|
|
371
|
-
'[attr.tabindex]': '0',
|
|
372
|
-
'[attr.aria-activedescendant]': 'activeDescendant()',
|
|
373
|
-
'[attr.data-state]': 'select.open() ? "open" : "closed"',
|
|
374
|
-
'(keydown)': 'keydown($event)',
|
|
375
|
-
'(document:click)': 'closeOnOutsideClick($event)',
|
|
376
|
-
},
|
|
377
|
-
}]
|
|
378
|
-
}], ctorParameters: () => [] });
|
|
379
|
-
|
|
380
24
|
class NgpSelect {
|
|
381
25
|
constructor() {
|
|
382
26
|
/**
|
|
383
|
-
*
|
|
384
|
-
*/
|
|
385
|
-
this.value = model.required({
|
|
386
|
-
alias: 'ngpSelectValue',
|
|
387
|
-
});
|
|
388
|
-
/**
|
|
389
|
-
* Whether the select dropdown is open.
|
|
390
|
-
*/
|
|
391
|
-
this.open = model(false, {
|
|
392
|
-
alias: 'ngpSelectOpen',
|
|
393
|
-
});
|
|
394
|
-
/**
|
|
395
|
-
* Disable the select component.
|
|
27
|
+
* Whether the select is disabled.
|
|
396
28
|
*/
|
|
397
29
|
this.disabled = input(false, {
|
|
398
30
|
alias: 'ngpSelectDisabled',
|
|
399
31
|
transform: booleanAttribute,
|
|
400
32
|
});
|
|
401
|
-
/**
|
|
402
|
-
* Access the select button instance.
|
|
403
|
-
* @internal
|
|
404
|
-
*/
|
|
405
|
-
this.button = contentChild.required(NgpSelectButtonToken, {
|
|
406
|
-
descendants: true,
|
|
407
|
-
});
|
|
408
|
-
/**
|
|
409
|
-
* Access the select options instance.
|
|
410
|
-
* @internal
|
|
411
|
-
*/
|
|
412
|
-
this.options = contentChild.required(NgpSelectOptionsToken, {
|
|
413
|
-
descendants: true,
|
|
414
|
-
});
|
|
415
33
|
}
|
|
416
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.
|
|
417
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.
|
|
34
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
35
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.1.1", type: NgpSelect, isStandalone: true, selector: "select[ngpSelect]", inputs: { disabled: { classPropertyName: "disabled", publicName: "ngpSelectDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.disabled": "disabled() || null" } }, providers: [
|
|
36
|
+
{ provide: NgpSelectToken, useExisting: NgpSelect },
|
|
37
|
+
{ provide: NgpDisabledToken, useExisting: NgpSelect },
|
|
38
|
+
], exportAs: ["ngpSelect"], hostDirectives: [{ directive: i1.NgpFormControl }, { directive: i2.NgpFocusVisible }, { directive: i2.NgpHover }, { directive: i2.NgpPress }], ngImport: i0 }); }
|
|
418
39
|
}
|
|
419
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.
|
|
40
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: NgpSelect, decorators: [{
|
|
420
41
|
type: Directive,
|
|
421
42
|
args: [{
|
|
422
43
|
standalone: true,
|
|
423
|
-
selector: '[ngpSelect]',
|
|
44
|
+
selector: 'select[ngpSelect]',
|
|
424
45
|
exportAs: 'ngpSelect',
|
|
425
|
-
providers: [
|
|
46
|
+
providers: [
|
|
47
|
+
{ provide: NgpSelectToken, useExisting: NgpSelect },
|
|
48
|
+
{ provide: NgpDisabledToken, useExisting: NgpSelect },
|
|
49
|
+
],
|
|
50
|
+
hostDirectives: [NgpFormControl, NgpFocusVisible, NgpHover, NgpPress],
|
|
51
|
+
host: {
|
|
52
|
+
'[attr.disabled]': 'disabled() || null',
|
|
53
|
+
},
|
|
426
54
|
}]
|
|
427
55
|
}] });
|
|
428
56
|
|
|
@@ -438,5 +66,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
|
438
66
|
* Generated bundle index. Do not edit.
|
|
439
67
|
*/
|
|
440
68
|
|
|
441
|
-
export { NgpSelect,
|
|
69
|
+
export { NgpSelect, NgpSelectToken };
|
|
442
70
|
//# sourceMappingURL=ng-primitives-select.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-select.mjs","sources":["../../../../packages/ng-primitives/select/src/select/select.token.ts","../../../../packages/ng-primitives/select/src/select-button/select-button.token.ts","../../../../packages/ng-primitives/select/src/select-button/select-button.directive.ts","../../../../packages/ng-primitives/select/src/select-option/select-option.token.ts","../../../../packages/ng-primitives/select/src/select-option/select-option.directive.ts","../../../../packages/ng-primitives/select/src/select-options/select-options.token.ts","../../../../packages/ng-primitives/select/src/select-options/select-options.directive.ts","../../../../packages/ng-primitives/select/src/select/select.directive.ts","../../../../packages/ng-primitives/select/src/index.ts","../../../../packages/ng-primitives/select/src/ng-primitives-select.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpSelect } from './select.directive';\n\nexport const NgpSelectToken = new InjectionToken<NgpSelect<unknown>>('NgpSelectToken');\n\n/**\n * Inject the Select directive instance\n */\nexport function injectSelect<T>(): NgpSelect<T> {\n return inject<NgpSelect<T>>(NgpSelectToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpSelectButton } from './select-button.directive';\n\nexport const NgpSelectButtonToken = new InjectionToken<NgpSelectButton>('NgpSelectButtonToken');\n\n/**\n * Inject the SelectButton directive instance\n */\nexport function injectSelectButton(): NgpSelectButton {\n return inject(NgpSelectButtonToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { FocusOrigin } from '@angular/cdk/a11y';\nimport { Directive, ElementRef, inject, input } from '@angular/core';\nimport { FocusManager, injectDisposables, uniqueId } from 'ng-primitives/utils';\nimport { injectSelect } from '../select/select.token';\nimport { NgpSelectButtonToken } from './select-button.token';\n\n@Directive({\n standalone: true,\n selector: 'button[ngpSelectButton]',\n exportAs: 'ngpSelectButton',\n providers: [{ provide: NgpSelectButtonToken, useExisting: NgpSelectButton }],\n host: {\n type: 'button',\n 'aria-haspopup': 'listbox',\n '[attr.id]': 'id()',\n '[attr.aria-expanded]': 'select.open()',\n '[attr.aria-controls]': 'select.open() ? select.options()?.id() : null',\n '[attr.data-state]': 'select.open() ? \"open\" : \"closed\"',\n '(click)': 'toggle()',\n '(keydown)': 'keydown($event)',\n },\n})\nexport class NgpSelectButton {\n /**\n * Access the parent select component.\n */\n protected readonly select = injectSelect<unknown>();\n\n /**\n * Access the disposable helpers.\n */\n private readonly disposables = injectDisposables();\n\n /**\n * Access the element reference.\n * @internal\n */\n readonly element = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the focus manager\n */\n private readonly focusManager = inject(FocusManager);\n\n /**\n * Optionally define an id for the button. By default, the id is generated.\n */\n readonly id = input(uniqueId('select-button'));\n\n /**\n * Toggle the select open state.\n */\n protected toggle() {\n this.select.open.update(open => !open);\n }\n\n /**\n * Handle keyboard events. If the list is closed, open it when the user presses the arrow keys.\n * If the list is open then we navigate using active descendant.\n * @param event\n */\n protected keydown(event: KeyboardEvent) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n this.select.open.set(true);\n // stop the event from triggering scrolling on the dropdown\n event.preventDefault();\n }\n\n // if the escape key is pressed, close the dropdown\n if (event.key === 'Escape') {\n this.select.open.set(false);\n }\n }\n\n /**\n * Focus the button element.\n * @param origin\n * @internal\n */\n focus(origin?: FocusOrigin) {\n // we run after the next tick to ensure any in-progress events do not get\n // redirected to the button element\n this.disposables.requestAnimationFrame(() => this.focusManager.focus(this.element, origin));\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpSelectOption } from './select-option.directive';\n\nexport const NgpSelectOptionToken = new InjectionToken<NgpSelectOption<unknown>>(\n 'NgpSelectOptionToken',\n);\n\n/**\n * Inject the SelectOption directive instance\n */\nexport function injectSelectOption<T>(): NgpSelectOption<T> {\n return inject<NgpSelectOption<T>>(NgpSelectOptionToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Highlightable } from '@angular/cdk/a11y';\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport {\n Directive,\n ElementRef,\n booleanAttribute,\n computed,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectSelect } from '../select/select.token';\nimport { NgpSelectOptionToken } from './select-option.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpSelectOption]',\n exportAs: 'ngpSelectOption',\n providers: [{ provide: NgpSelectOptionToken, useExisting: NgpSelectOption }],\n host: {\n role: 'option',\n '[attr.id]': 'id()',\n '[attr.aria-selected]': 'selected()',\n '[attr.aria-disabled]': 'isDisabled()',\n '[attr.data-state]': 'selected() ? \"selected\" : \"unselected\"',\n '[attr.data-active]': 'active() ? \"\" : null',\n '[attr.data-disabled]': 'isDisabled()',\n '(click)': 'selectOption()',\n },\n})\nexport class NgpSelectOption<T> implements Highlightable {\n /**\n * Access the parent select component.\n */\n protected readonly select = injectSelect<T>();\n\n /**\n * Access the element reference.\n */\n protected readonly element = inject(ElementRef<HTMLElement>);\n\n /**\n * Optionally define an id for the option. By default, the id is generated.\n */\n readonly id = input<string>(uniqueId('select-option'));\n\n /**\n * The value of the option.\n */\n readonly value = input.required<T>({\n alias: 'ngpSelectOptionValue',\n });\n\n /**\n * Whether the option is disabled.\n */\n readonly isDisabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpSelectOptionDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the option is the active descendant.\n */\n protected readonly active = signal<boolean>(false);\n\n /**\n * Determine if the option is selected.\n */\n protected readonly selected = computed(() => this.select.value() === this.value());\n\n /**\n * Set the active styles for the option.\n * @internal\n */\n setActiveStyles(): void {\n this.active.set(true);\n\n // scroll the option into view if needed\n this.element.nativeElement.scrollIntoView({ block: 'nearest' });\n }\n\n /**\n * Set the inactive styles for the option.\n * @internal\n */\n setInactiveStyles(): void {\n this.active.set(false);\n }\n\n /**\n * Handle the click event on the option.\n */\n protected selectOption(): void {\n if (!this.isDisabled()) {\n this.select.value.update(() => this.value());\n // close the dropdown after selecting an option\n this.select.open.set(false);\n }\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpSelectOptions } from './select-options.directive';\n\nexport const NgpSelectOptionsToken = new InjectionToken<NgpSelectOptions<unknown>>(\n 'NgpSelectOptionsToken',\n);\n\n/**\n * Inject the SelectOptions directive instance\n */\nexport function injectSelectOptions<T>(): NgpSelectOptions<T> {\n return inject(NgpSelectOptionsToken) as NgpSelectOptions<T>;\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ActiveDescendantKeyManager, FocusOrigin } from '@angular/cdk/a11y';\nimport {\n AfterViewInit,\n ChangeDetectorRef,\n Directive,\n ElementRef,\n Injector,\n Signal,\n contentChildren,\n effect,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { NgpSelectOption } from '../select-option/select-option.directive';\nimport { NgpSelectOptionToken } from '../select-option/select-option.token';\nimport { injectSelect } from '../select/select.token';\nimport { NgpSelectOptionsToken } from './select-options.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpSelectOptions]',\n exportAs: 'ngpSelectOptions',\n providers: [{ provide: NgpSelectOptionsToken, useExisting: NgpSelectOptions }],\n host: {\n role: 'listbox',\n '[attr.id]': 'id()',\n '[attr.aria-labelledby]': 'select.button().id()',\n '[attr.tabindex]': '0',\n '[attr.aria-activedescendant]': 'activeDescendant()',\n '[attr.data-state]': 'select.open() ? \"open\" : \"closed\"',\n '(keydown)': 'keydown($event)',\n '(document:click)': 'closeOnOutsideClick($event)',\n },\n})\nexport class NgpSelectOptions<T> implements AfterViewInit {\n /**\n * Access the parent select component.\n */\n protected readonly select = injectSelect<T>();\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the element reference.\n */\n protected readonly element = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access the change detector.\n */\n protected readonly changeDetector = inject(ChangeDetectorRef);\n\n /**\n * Access all the options in the list.\n */\n private readonly options = contentChildren<NgpSelectOption<T>>(NgpSelectOptionToken, {\n descendants: true,\n });\n\n /**\n * Optionally define an id for the options list. By default, the id is generated.\n */\n readonly id = input(uniqueId('select-options'));\n\n /**\n * Handle the active descendant.\n */\n private readonly activeDescendantKeyManager = new ActiveDescendantKeyManager(\n this.options as Signal<NgpSelectOption<T>[]>,\n this.injector,\n );\n\n /**\n * Get the active descendant id\n */\n private readonly activeDescendant = signal<string | null>(null);\n\n /**\n * Focus the options list when it becomes visible.\n */\n constructor() {\n // update the mounted state when the select dropdown is opened or closed\n effect(() => (this.select.open() ? this.open() : this.close()), { allowSignalWrites: true });\n\n // whenever the active descendant changes update the active descendant id\n this.activeDescendantKeyManager.change\n .pipe(takeUntilDestroyed())\n .subscribe(() =>\n this.activeDescendant.set(this.activeDescendantKeyManager.activeItem?.id() ?? null),\n );\n }\n\n ngAfterViewInit(): void {\n // by default the selected option should be active when the options list is opened.\n // if there is no selected option, the first option should be active.\n if (this.select.value() === null) {\n this.activeDescendantKeyManager.setFirstItemActive();\n } else {\n const selectedOption = this.options().find(option => option.value() === this.select.value());\n this.activeDescendantKeyManager.setActiveItem(selectedOption ?? this.options()[0]);\n }\n }\n\n /**\n * Handle the opening of the options list.\n */\n private open(): void {\n // force change detection to ensure the options list is visible before focusing\n this.changeDetector.detectChanges();\n this.element.nativeElement.focus();\n }\n\n /**\n * Handle the closing of the options list.\n * @param origin\n */\n private close(origin?: FocusOrigin): void {\n // if the options list is already closed, do nothing\n if (!this.select.open()) {\n return;\n }\n\n this.select.open.set(false);\n this.select.button().focus(origin);\n }\n\n /**\n * If the user clicks outside of the options list, close the dropdown.\n * @param event\n */\n protected closeOnOutsideClick(event: MouseEvent): void {\n // if the user performs a click that is not within the options list or the slect button, close the dropdown\n if (\n this.select.open() &&\n !this.element.nativeElement.contains(event.target as Node) &&\n !this.select.button().element.nativeElement.contains(event.target as Node)\n ) {\n this.close();\n }\n }\n\n /**\n * Handle keyboard events.\n *\n * - If the user presses the tab key keep focus on the dropdown.\n * - If the user presses the escape key, close the dropdown.\n * @param event\n */\n protected keydown(event: KeyboardEvent) {\n // forward the keyboard event to the active descendant key manager\n this.activeDescendantKeyManager.onKeydown(event);\n\n // prevent the default tab behavior - this is essentially a focus trap\n if (event.key === 'Tab') {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n // if the escape key is pressed, close the dropdown\n if (event.key === 'Escape') {\n this.close('keyboard');\n return;\n }\n\n // if the space or enter key is pressed, select the active option\n if (event.key === ' ' || event.key === 'Enter') {\n const activeItem = this.activeDescendantKeyManager.activeItem;\n\n if (activeItem && !activeItem.isDisabled()) {\n this.select.value.set(activeItem.value());\n this.close('keyboard');\n }\n }\n }\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, booleanAttribute, contentChild, input, model } from '@angular/core';\nimport { NgpSelectButtonToken } from '../select-button/select-button.token';\nimport { NgpSelectOptionsToken } from '../select-options/select-options.token';\nimport { NgpSelectToken } from './select.token';\n\n@Directive({\n standalone: true,\n selector: '[ngpSelect]',\n exportAs: 'ngpSelect',\n providers: [{ provide: NgpSelectToken, useExisting: NgpSelect }],\n})\nexport class NgpSelect<T> {\n /**\n * The selected value.\n */\n readonly value = model.required<T>({\n alias: 'ngpSelectValue',\n });\n\n /**\n * Whether the select dropdown is open.\n */\n readonly open = model<boolean>(false, {\n alias: 'ngpSelectOpen',\n });\n\n /**\n * Disable the select component.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpSelectDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Access the select button instance.\n * @internal\n */\n readonly button = contentChild.required(NgpSelectButtonToken, {\n descendants: true,\n });\n\n /**\n * Access the select options instance.\n * @internal\n */\n readonly options = contentChild.required(NgpSelectOptionsToken, {\n descendants: true,\n });\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpSelectButton } from './select-button/select-button.directive';\nexport { NgpSelectButtonToken } from './select-button/select-button.token';\nexport { NgpSelectOption } from './select-option/select-option.directive';\nexport { NgpSelectOptionToken } from './select-option/select-option.token';\nexport { NgpSelectOptions } from './select-options/select-options.directive';\nexport { NgpSelectOptionsToken } from './select-options/select-options.token';\nexport { NgpSelect } from './select/select.directive';\nexport { NgpSelectToken } from './select/select.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;MAIU,cAAc,GAAG,IAAI,cAAc,CAAqB,gBAAgB,EAAE;AAEvF;;AAEG;SACa,YAAY,GAAA;AAC1B,IAAA,OAAO,MAAM,CAAe,cAAc,CAAC,CAAC;AAC9C;;ACjBA;;;;;;AAMG;MAIU,oBAAoB,GAAG,IAAI,cAAc,CAAkB,sBAAsB,EAAE;AAEhG;;AAEG;SACa,kBAAkB,GAAA;AAChC,IAAA,OAAO,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACtC;;MCYa,eAAe,CAAA;AAhB5B,IAAA,WAAA,GAAA;AAiBE;;AAEG;QACgB,IAAM,CAAA,MAAA,GAAG,YAAY,EAAW,CAAC;AAEpD;;AAEG;QACc,IAAW,CAAA,WAAA,GAAG,iBAAiB,EAAE,CAAC;AAEnD;;;AAGG;AACM,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAA0B,UAAU,CAAC,CAAC;AAE/D;;AAEG;AACc,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAErD;;AAEG;QACM,IAAE,CAAA,EAAA,GAAG,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;AAqChD,KAAA;AAnCC;;AAEG;IACO,MAAM,GAAA;AACd,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;KACxC;AAED;;;;AAIG;AACO,IAAA,OAAO,CAAC,KAAoB,EAAA;AACpC,QAAA,IAAI,KAAK,CAAC,GAAG,KAAK,WAAW,IAAI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;AACT,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,QAAQ,EAAE,WAAW;oBACrB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAW,SAAA,EAAE,CAAC;AACjE,iBAAA,CAAA;;;AClBD;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-select.mjs","sources":["../../../../packages/ng-primitives/select/src/select/select.token.ts","../../../../packages/ng-primitives/select/src/select/select.directive.ts","../../../../packages/ng-primitives/select/src/index.ts","../../../../packages/ng-primitives/select/src/ng-primitives-select.ts"],"sourcesContent":["/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { InjectionToken, inject } from '@angular/core';\nimport type { NgpSelect } from './select.directive';\n\nexport const NgpSelectToken = new InjectionToken<NgpSelect>('NgpSelectToken');\n\n/**\n * Inject the Select directive instance\n */\nexport function injectSelect(): NgpSelect {\n return inject(NgpSelectToken);\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport { NgpFormControl } from 'ng-primitives/form-field';\nimport { NgpFocusVisible, NgpHover, NgpPress } from 'ng-primitives/interactions';\nimport { NgpCanDisable, NgpDisabledToken } from 'ng-primitives/internal';\nimport { NgpSelectToken } from './select.token';\n\n@Directive({\n standalone: true,\n selector: 'select[ngpSelect]',\n exportAs: 'ngpSelect',\n providers: [\n { provide: NgpSelectToken, useExisting: NgpSelect },\n { provide: NgpDisabledToken, useExisting: NgpSelect },\n ],\n hostDirectives: [NgpFormControl, NgpFocusVisible, NgpHover, NgpPress],\n host: {\n '[attr.disabled]': 'disabled() || null',\n },\n})\nexport class NgpSelect implements NgpCanDisable {\n /**\n * Whether the select is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpSelectDisabled',\n transform: booleanAttribute,\n });\n}\n","/**\n * Copyright © 2024 Angular Primitives.\n * https://github.com/ng-primitives/ng-primitives\n *\n * This source code is licensed under the CC BY-ND 4.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nexport { NgpSelect } from './select/select.directive';\nexport { NgpSelectToken } from './select/select.token';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;AAMG;MAIU,cAAc,GAAG,IAAI,cAAc,CAAY,gBAAgB,EAAE;AAE9E;;AAEG;SACa,YAAY,GAAA;AAC1B,IAAA,OAAO,MAAM,CAAC,cAAc,CAAC,CAAC;AAChC;;MCUa,SAAS,CAAA;AAbtB,IAAA,WAAA,GAAA;AAcE;;AAEG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACtD,YAAA,KAAK,EAAE,mBAAmB;AAC1B,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC,CAAC;AACJ,KAAA;8GARY,SAAS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA,EAAA;AAAT,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,SAAS,EATT,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,mBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAA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