@radix-ng/primitives 0.50.0 → 1.0.0-beta.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/collection/README.md +1 -0
- package/fesm2022/radix-ng-primitives-accordion.mjs +134 -66
- package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs +224 -132
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-arrow.mjs +26 -10
- package/fesm2022/radix-ng-primitives-arrow.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-aspect-ratio.mjs +6 -6
- package/fesm2022/radix-ng-primitives-aspect-ratio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-avatar.mjs +68 -75
- package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-button.mjs +123 -0
- package/fesm2022/radix-ng-primitives-button.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-calendar.mjs +104 -103
- package/fesm2022/radix-ng-primitives-calendar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-checkbox.mjs +414 -80
- package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collapsible.mjs +193 -92
- package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collection.mjs +72 -0
- package/fesm2022/radix-ng-primitives-collection.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-config.mjs +5 -5
- package/fesm2022/radix-ng-primitives-config.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-context-menu.mjs +143 -427
- package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +757 -757
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-cropper.mjs +55 -53
- package/fesm2022/radix-ng-primitives-cropper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-date-field.mjs +93 -86
- package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dialog.mjs +658 -330
- package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +98 -76
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-drawer.mjs +1059 -0
- package/fesm2022/radix-ng-primitives-drawer.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-editable.mjs +20 -20
- package/fesm2022/radix-ng-primitives-editable.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-field.mjs +363 -0
- package/fesm2022/radix-ng-primitives-field.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-fieldset.mjs +79 -0
- package/fesm2022/radix-ng-primitives-fieldset.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-focus-guards.mjs +3 -3
- package/fesm2022/radix-ng-primitives-focus-guards.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-focus-scope.mjs +29 -14
- package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-input.mjs +172 -0
- package/fesm2022/radix-ng-primitives-input.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-label.mjs +11 -11
- package/fesm2022/radix-ng-primitives-label.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menu.mjs +1484 -353
- package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menubar.mjs +290 -162
- package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-meter.mjs +271 -0
- package/fesm2022/radix-ng-primitives-meter.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs +1060 -1553
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-number-field.mjs +1102 -366
- package/fesm2022/radix-ng-primitives-number-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-pagination.mjs +51 -51
- package/fesm2022/radix-ng-primitives-pagination.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popover.mjs +980 -995
- package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popper.mjs +137 -82
- package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-portal.mjs +40 -16
- package/fesm2022/radix-ng-primitives-portal.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-presence.mjs +134 -246
- package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-preview-card.mjs +997 -0
- package/fesm2022/radix-ng-primitives-preview-card.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-progress.mjs +231 -92
- package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-radio.mjs +211 -70
- package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-roving-focus.mjs +127 -77
- package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-select.mjs +791 -511
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-separator.mjs +16 -45
- package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-slider.mjs +976 -720
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-stepper.mjs +69 -71
- package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +128 -124
- package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tabs.mjs +388 -115
- package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-time-field.mjs +111 -117
- package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +122 -248
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +99 -62
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toolbar.mjs +307 -94
- package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tooltip.mjs +690 -1079
- package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs +46 -87
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives.mjs.map +1 -1
- package/meter/README.md +3 -0
- package/navigation-menu/README.md +2 -1
- package/package.json +85 -63
- package/portal/README.md +2 -0
- package/preview-card/README.md +3 -0
- package/schematics/collection.json +1 -0
- package/schematics/ng-add/index.d.ts +3 -2
- package/schematics/ng-add/index.js +62 -31
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/package-config.d.ts +4 -2
- package/schematics/ng-add/package-config.js +10 -2
- package/schematics/ng-add/package-config.js.map +1 -1
- package/schematics/ng-add/schema.d.ts +3 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +14 -0
- package/select/README.md +2 -0
- package/{accordion/index.d.ts → types/radix-ng-primitives-accordion.d.ts} +102 -67
- package/types/radix-ng-primitives-alert-dialog.d.ts +114 -0
- package/{arrow/index.d.ts → types/radix-ng-primitives-arrow.d.ts} +1 -1
- package/{aspect-ratio/index.d.ts → types/radix-ng-primitives-aspect-ratio.d.ts} +1 -1
- package/{avatar/index.d.ts → types/radix-ng-primitives-avatar.d.ts} +7 -11
- package/types/radix-ng-primitives-button.d.ts +73 -0
- package/{calendar/index.d.ts → types/radix-ng-primitives-calendar.d.ts} +2 -3
- package/types/radix-ng-primitives-checkbox.d.ts +337 -0
- package/types/radix-ng-primitives-collapsible.d.ts +159 -0
- package/types/radix-ng-primitives-collection.d.ts +44 -0
- package/{config/index.d.ts → types/radix-ng-primitives-config.d.ts} +1 -1
- package/types/radix-ng-primitives-context-menu.d.ts +73 -0
- package/{core/index.d.ts → types/radix-ng-primitives-core.d.ts} +311 -236
- package/{cropper/index.d.ts → types/radix-ng-primitives-cropper.d.ts} +6 -5
- package/{date-field/index.d.ts → types/radix-ng-primitives-date-field.d.ts} +42 -27
- package/types/radix-ng-primitives-dialog.d.ts +323 -0
- package/{dismissable-layer/index.d.ts → types/radix-ng-primitives-dismissable-layer.d.ts} +15 -7
- package/types/radix-ng-primitives-drawer.d.ts +448 -0
- package/{editable/index.d.ts → types/radix-ng-primitives-editable.d.ts} +1 -1
- package/types/radix-ng-primitives-field.d.ts +373 -0
- package/types/radix-ng-primitives-fieldset.d.ts +48 -0
- package/{focus-scope/index.d.ts → types/radix-ng-primitives-focus-scope.d.ts} +13 -5
- package/types/radix-ng-primitives-input.d.ts +87 -0
- package/{label/index.d.ts → types/radix-ng-primitives-label.d.ts} +0 -1
- package/types/radix-ng-primitives-menu.d.ts +612 -0
- package/types/radix-ng-primitives-menubar.d.ts +66 -0
- package/types/radix-ng-primitives-meter.d.ts +193 -0
- package/types/radix-ng-primitives-navigation-menu.d.ts +488 -0
- package/types/radix-ng-primitives-number-field.d.ts +464 -0
- package/{pagination/index.d.ts → types/radix-ng-primitives-pagination.d.ts} +2 -2
- package/types/radix-ng-primitives-popover.d.ts +416 -0
- package/{popper/index.d.ts → types/radix-ng-primitives-popper.d.ts} +50 -9
- package/types/radix-ng-primitives-portal.d.ts +30 -0
- package/types/radix-ng-primitives-presence.d.ts +55 -0
- package/types/radix-ng-primitives-preview-card.d.ts +359 -0
- package/types/radix-ng-primitives-progress.d.ts +206 -0
- package/{radio/index.d.ts → types/radix-ng-primitives-radio.d.ts} +56 -26
- package/{roving-focus/index.d.ts → types/radix-ng-primitives-roving-focus.d.ts} +38 -27
- package/types/radix-ng-primitives-select.d.ts +512 -0
- package/types/radix-ng-primitives-separator.d.ts +38 -0
- package/types/radix-ng-primitives-slider.d.ts +377 -0
- package/{stepper/index.d.ts → types/radix-ng-primitives-stepper.d.ts} +21 -22
- package/types/radix-ng-primitives-switch.d.ts +121 -0
- package/types/radix-ng-primitives-tabs.d.ts +247 -0
- package/{time-field/index.d.ts → types/radix-ng-primitives-time-field.d.ts} +46 -31
- package/types/radix-ng-primitives-toggle-group.d.ts +116 -0
- package/types/radix-ng-primitives-toggle.d.ts +65 -0
- package/types/radix-ng-primitives-toolbar.d.ts +180 -0
- package/types/radix-ng-primitives-tooltip.d.ts +395 -0
- package/{visually-hidden/index.d.ts → types/radix-ng-primitives-visually-hidden.d.ts} +19 -19
- package/alert-dialog/index.d.ts +0 -57
- package/checkbox/index.d.ts +0 -164
- package/collapsible/index.d.ts +0 -85
- package/context-menu/index.d.ts +0 -129
- package/dialog/index.d.ts +0 -205
- package/dropdown-menu/README.md +0 -1
- package/dropdown-menu/index.d.ts +0 -171
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +0 -583
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-hover-card.mjs +0 -1246
- package/fesm2022/radix-ng-primitives-hover-card.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-tooltip2.mjs +0 -740
- package/fesm2022/radix-ng-primitives-tooltip2.mjs.map +0 -1
- package/hover-card/README.md +0 -3
- package/hover-card/index.d.ts +0 -472
- package/menu/index.d.ts +0 -139
- package/menubar/index.d.ts +0 -56
- package/navigation-menu/index.d.ts +0 -405
- package/number-field/index.d.ts +0 -203
- package/popover/index.d.ts +0 -403
- package/portal/index.d.ts +0 -22
- package/presence/index.d.ts +0 -103
- package/progress/index.d.ts +0 -79
- package/select/index.d.ts +0 -214
- package/separator/index.d.ts +0 -63
- package/slider/index.d.ts +0 -263
- package/switch/index.d.ts +0 -105
- package/tabs/index.d.ts +0 -112
- package/toggle/index.d.ts +0 -75
- package/toggle-group/index.d.ts +0 -194
- package/toolbar/index.d.ts +0 -55
- package/tooltip/index.d.ts +0 -433
- package/tooltip2/README.md +0 -3
- package/tooltip2/index.d.ts +0 -325
- /package/{focus-guards/index.d.ts → types/radix-ng-primitives-focus-guards.d.ts} +0 -0
- /package/{index.d.ts → types/radix-ng-primitives.d.ts} +0 -0
|
@@ -1,619 +1,899 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject,
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import * as i1 from '@
|
|
10
|
-
import {
|
|
2
|
+
import { inject, model, input, booleanAttribute, computed, signal, Directive, InjectionToken, ElementRef, afterNextRender, effect, ContentChild, linkedSignal, DestroyRef, numberAttribute, forwardRef } from '@angular/core';
|
|
3
|
+
import { outputFromObservable, outputToObservable } from '@angular/core/rxjs-interop';
|
|
4
|
+
import * as i3 from '@radix-ng/primitives/collection';
|
|
5
|
+
import { RdxCollectionProvider, RdxCollectionItem } from '@radix-ng/primitives/collection';
|
|
6
|
+
import { isEqual, getActiveElement, createContext, isNullish, injectId, handleAndDispatchCustomEvent } from '@radix-ng/primitives/core';
|
|
7
|
+
import * as i2 from '@radix-ng/primitives/dismissable-layer';
|
|
8
|
+
import { RdxDismissableLayer, provideRdxDismissableLayerConfig } from '@radix-ng/primitives/dismissable-layer';
|
|
9
|
+
import * as i1$1 from '@radix-ng/primitives/focus-scope';
|
|
10
|
+
import { RdxFocusScope } from '@radix-ng/primitives/focus-scope';
|
|
11
|
+
import * as i1 from '@radix-ng/primitives/popper';
|
|
12
|
+
import { RdxPopper, RdxPopperContent, RdxPopperContentWrapper, RdxPopperAnchor } from '@radix-ng/primitives/popper';
|
|
13
|
+
import * as i1$2 from '@radix-ng/primitives/portal';
|
|
14
|
+
import { RdxPortal } from '@radix-ng/primitives/portal';
|
|
15
|
+
import * as i1$3 from '@radix-ng/primitives/presence';
|
|
16
|
+
import { provideRdxPresenceContext, RdxPresenceDirective } from '@radix-ng/primitives/presence';
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
const OPEN_KEYS = [' ', 'Enter', 'ArrowUp', 'ArrowDown'];
|
|
19
|
+
const SELECTION_KEYS = [' ', 'Enter'];
|
|
20
|
+
const CONTENT_MARGIN = 10;
|
|
21
|
+
function valueComparator(value, currentValue, comparator) {
|
|
22
|
+
if (value === undefined)
|
|
23
|
+
return false;
|
|
24
|
+
else if (Array.isArray(value))
|
|
25
|
+
return value.some((val) => compare(val, currentValue, comparator));
|
|
26
|
+
else
|
|
27
|
+
return compare(value, currentValue, comparator);
|
|
28
|
+
}
|
|
29
|
+
function compare(value, currentValue, comparator) {
|
|
30
|
+
if (value === undefined || currentValue === undefined)
|
|
31
|
+
return false;
|
|
32
|
+
if (typeof value === 'string')
|
|
33
|
+
return value === currentValue;
|
|
34
|
+
if (typeof comparator === 'function')
|
|
35
|
+
return comparator(value, currentValue);
|
|
36
|
+
if (typeof comparator === 'string')
|
|
37
|
+
return value?.[comparator] === currentValue?.[comparator];
|
|
38
|
+
return isEqual(value, currentValue);
|
|
39
|
+
}
|
|
40
|
+
function shouldShowPlaceholder(value) {
|
|
41
|
+
return value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);
|
|
42
|
+
}
|
|
43
|
+
function focusFirst(candidates) {
|
|
44
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = getActiveElement();
|
|
45
|
+
for (const candidate of candidates) {
|
|
46
|
+
// if focus is already where we want to go, we don't want to keep going through the candidates
|
|
47
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT)
|
|
48
|
+
return;
|
|
49
|
+
candidate.focus();
|
|
50
|
+
if (getActiveElement() !== PREVIOUSLY_FOCUSED_ELEMENT)
|
|
51
|
+
return;
|
|
15
52
|
}
|
|
16
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: RdxSelectValueDirective, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
17
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.3", type: RdxSelectValueDirective, isStandalone: true, selector: "[rdxSelectValue]", inputs: { placeholder: "placeholder" }, exportAs: ["rdxSelectValue"], ngImport: i0, template: `
|
|
18
|
-
{{ select.selectionModel.isEmpty() ? placeholder : select.selected }}
|
|
19
|
-
`, isInline: true, styles: [":host{pointer-events:none}\n"] }); }
|
|
20
53
|
}
|
|
21
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: RdxSelectValueDirective, decorators: [{
|
|
22
|
-
type: Component,
|
|
23
|
-
args: [{ selector: '[rdxSelectValue]', standalone: true, exportAs: 'rdxSelectValue', template: `
|
|
24
|
-
{{ select.selectionModel.isEmpty() ? placeholder : select.selected }}
|
|
25
|
-
`, styles: [":host{pointer-events:none}\n"] }]
|
|
26
|
-
}], propDecorators: { placeholder: [{
|
|
27
|
-
type: Input
|
|
28
|
-
}] } });
|
|
29
54
|
|
|
30
|
-
|
|
55
|
+
const context$2 = () => {
|
|
56
|
+
const context = inject(RdxSelectRoot);
|
|
57
|
+
return {
|
|
58
|
+
triggerElement: context.triggerElement,
|
|
59
|
+
valueElement: context.valueElement,
|
|
60
|
+
triggerPointerDownPosRef: context.triggerPointerDownPosRef,
|
|
61
|
+
contentId: '',
|
|
62
|
+
dir: context.dir,
|
|
63
|
+
value: context.value,
|
|
64
|
+
multiple: context.multiple,
|
|
65
|
+
by: context.by,
|
|
66
|
+
open: context.open,
|
|
67
|
+
disabled: context.disabled,
|
|
68
|
+
optionsSet: context.optionsSet,
|
|
69
|
+
onOptionAdd: (option) => {
|
|
70
|
+
const existingOption = context.getOption(option());
|
|
71
|
+
if (existingOption) {
|
|
72
|
+
context.optionsSet().delete(existingOption);
|
|
73
|
+
}
|
|
74
|
+
context.optionsSet().add(option());
|
|
75
|
+
},
|
|
76
|
+
onOptionRemove: (option) => {
|
|
77
|
+
const existingOption = context.getOption(option());
|
|
78
|
+
if (existingOption) {
|
|
79
|
+
context.optionsSet().delete(existingOption);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
onValueChange: context.handleValueChange,
|
|
83
|
+
onTriggerChange: (node) => {
|
|
84
|
+
context.triggerElement.set(node.nativeElement);
|
|
85
|
+
},
|
|
86
|
+
onValueElementChange: (node) => {
|
|
87
|
+
context.valueElement.set(node);
|
|
88
|
+
},
|
|
89
|
+
onOpenChange: (value) => {
|
|
90
|
+
context.open.set(value);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
const [injectSelectRootContext, provideSelectRootContext] = createContext('RdxSelectRootContext');
|
|
95
|
+
class RdxSelectRoot {
|
|
31
96
|
constructor() {
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
97
|
+
this.open = model(false, ...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
98
|
+
this.value = model(...(ngDevMode ? [undefined, { debugName: "value" }] : /* istanbul ignore next */ []));
|
|
99
|
+
this.multiple = input(false, { ...(ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
100
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
101
|
+
this.dir = input('ltr', ...(ngDevMode ? [{ debugName: "dir" }] : /* istanbul ignore next */ []));
|
|
102
|
+
/** Use this to compare objects by a particular field, or pass your own comparison function for complete control over how objects are compared. */
|
|
103
|
+
this.by = input(...(ngDevMode ? [undefined, { debugName: "by" }] : /* istanbul ignore next */ []));
|
|
104
|
+
this.isEmptyModelValue = computed(() => {
|
|
105
|
+
if (this.multiple() && Array.isArray(this.value())) {
|
|
106
|
+
return Array(this.value())?.length === 0;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return isNullish(this.value());
|
|
110
|
+
}
|
|
111
|
+
}, ...(ngDevMode ? [{ debugName: "isEmptyModelValue" }] : /* istanbul ignore next */ []));
|
|
112
|
+
this.optionsSet = signal(new Set(), ...(ngDevMode ? [{ debugName: "optionsSet" }] : /* istanbul ignore next */ []));
|
|
113
|
+
// The native `select` only associates the correct default value if the corresponding
|
|
114
|
+
// `option` is rendered as a child **at the same time** as itself.
|
|
115
|
+
// Because it might take a few renders for our items to gather the information to build
|
|
116
|
+
// the native `option`(s), we generate a key on the `select` to make sure Vue re-builds it
|
|
117
|
+
// each time the options change.
|
|
118
|
+
this.nativeSelectKey = computed(() => {
|
|
119
|
+
return Array.from(this.optionsSet())
|
|
120
|
+
.map((option) => option.value)
|
|
121
|
+
.join(';');
|
|
122
|
+
}, ...(ngDevMode ? [{ debugName: "nativeSelectKey" }] : /* istanbul ignore next */ []));
|
|
123
|
+
this.triggerElement = signal(null, ...(ngDevMode ? [{ debugName: "triggerElement" }] : /* istanbul ignore next */ []));
|
|
124
|
+
this.valueElement = signal(null, ...(ngDevMode ? [{ debugName: "valueElement" }] : /* istanbul ignore next */ []));
|
|
125
|
+
this.triggerPointerDownPosRef = signal({
|
|
126
|
+
x: 0,
|
|
127
|
+
y: 0
|
|
128
|
+
}, ...(ngDevMode ? [{ debugName: "triggerPointerDownPosRef" }] : /* istanbul ignore next */ []));
|
|
129
|
+
}
|
|
130
|
+
getOption(value) {
|
|
131
|
+
return Array.from(this.optionsSet()).find((option) => valueComparator(value, option.value, this.by()));
|
|
132
|
+
}
|
|
133
|
+
handleValueChange(value) {
|
|
134
|
+
if (this.multiple()) {
|
|
135
|
+
const array = Array.isArray(this.value()) ? [...Array(this.value())] : [];
|
|
136
|
+
const index = array.findIndex((i) => compare(i, value, this.by()));
|
|
137
|
+
index === -1 ? array.push(value) : array.splice(index, 1);
|
|
138
|
+
this.value.set([...array]);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this.value.set(value);
|
|
51
142
|
}
|
|
52
|
-
this.ngZone.runOutsideAngular(() => {
|
|
53
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
54
|
-
this.select.triggerSize.set([this.nativeElement.offsetWidth, this.nativeElement.offsetHeight]);
|
|
55
|
-
});
|
|
56
|
-
this.resizeObserver.observe(this.nativeElement);
|
|
57
|
-
});
|
|
58
143
|
}
|
|
59
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
60
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.
|
|
144
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectRoot, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
145
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxSelectRoot, isStandalone: true, selector: "[rdxSelectRoot]", inputs: { open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, dir: { classPropertyName: "dir", publicName: "dir", isSignal: true, isRequired: false, transformFunction: null }, by: { classPropertyName: "by", publicName: "by", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { open: "openChange", value: "valueChange" }, providers: [provideSelectRootContext(context$2)], exportAs: ["rdxSelectRoot"], hostDirectives: [{ directive: i1.RdxPopper }], ngImport: i0 }); }
|
|
61
146
|
}
|
|
62
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
147
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectRoot, decorators: [{
|
|
63
148
|
type: Directive,
|
|
64
149
|
args: [{
|
|
65
|
-
selector: '[
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
'[attr.role]': '"combobox"',
|
|
70
|
-
'[attr.aria-autocomplete]': '"none"',
|
|
71
|
-
'[attr.dir]': 'select.dir.value',
|
|
72
|
-
'[attr.aria-expanded]': 'select.open',
|
|
73
|
-
'[attr.aria-required]': 'select.required',
|
|
74
|
-
'[attr.disabled]': 'select.disabled ? "" : null',
|
|
75
|
-
'[attr.data-disabled]': 'select.disabled ? "" : null',
|
|
76
|
-
'[attr.data-state]': "select.open ? 'open': 'closed'",
|
|
77
|
-
'[attr.data-placeholder]': 'value().placeholder || null'
|
|
78
|
-
}
|
|
150
|
+
selector: '[rdxSelectRoot]',
|
|
151
|
+
exportAs: 'rdxSelectRoot',
|
|
152
|
+
providers: [provideSelectRootContext(context$2)],
|
|
153
|
+
hostDirectives: [RdxPopper]
|
|
79
154
|
}]
|
|
80
|
-
}] });
|
|
155
|
+
}], propDecorators: { open: [{ type: i0.Input, args: [{ isSignal: true, alias: "open", required: false }] }, { type: i0.Output, args: ["openChange"] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dir: [{ type: i0.Input, args: [{ isSignal: true, alias: "dir", required: false }] }], by: [{ type: i0.Input, args: [{ isSignal: true, alias: "by", required: false }] }] } });
|
|
81
156
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* The width of the trigger element.
|
|
102
|
-
* @returns The width of the trigger element.
|
|
103
|
-
*/
|
|
104
|
-
this.triggerWidth = computed(() => this.triggerSize()[0], ...(ngDevMode ? [{ debugName: "triggerWidth" }] : []));
|
|
105
|
-
/**
|
|
106
|
-
* This position config ensures that the top "start" corner of the overlay
|
|
107
|
-
* is aligned with the top "start" of the origin by default (overlapping
|
|
108
|
-
* the trigger completely). If the panel cannot fit below the trigger, it
|
|
109
|
-
* will fall back to a position above the trigger.
|
|
110
|
-
*/
|
|
111
|
-
this.positions = [
|
|
112
|
-
{
|
|
113
|
-
originX: 'start',
|
|
114
|
-
originY: 'bottom',
|
|
115
|
-
overlayX: 'start',
|
|
116
|
-
overlayY: 'top'
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
originX: 'start',
|
|
120
|
-
originY: 'top',
|
|
121
|
-
overlayX: 'start',
|
|
122
|
-
overlayY: 'bottom'
|
|
157
|
+
const context$1 = () => {
|
|
158
|
+
const context = inject(RdxSelectContent);
|
|
159
|
+
return {
|
|
160
|
+
content: context.content,
|
|
161
|
+
viewport: context.viewport,
|
|
162
|
+
isPositioned: context.isPositioned,
|
|
163
|
+
selectedItem: context.selectedItem,
|
|
164
|
+
selectedItemText: context.selectedItemText,
|
|
165
|
+
onViewportChange: (node) => {
|
|
166
|
+
context.viewport.set(node);
|
|
167
|
+
},
|
|
168
|
+
onItemLeave: () => {
|
|
169
|
+
context.content()?.focus();
|
|
170
|
+
},
|
|
171
|
+
itemRefCallback: (node, value, disabled) => {
|
|
172
|
+
const isFirstValidItem = !context.firstValidItemFoundRef() && !disabled;
|
|
173
|
+
const isSelectedItem = valueComparator(context.rootContext.value(), value, context.rootContext.by());
|
|
174
|
+
if (isSelectedItem || isFirstValidItem) {
|
|
175
|
+
context.selectedItem.set(node);
|
|
123
176
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
177
|
+
if (isFirstValidItem) {
|
|
178
|
+
context.firstValidItemFoundRef.set(true);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
itemTextRefCallback: (node, value, disabled) => {
|
|
182
|
+
const isFirstValidItem = !context.firstValidItemFoundRef() && !disabled;
|
|
183
|
+
const isSelectedItem = valueComparator(context.rootContext.value(), value, context.rootContext.by());
|
|
184
|
+
if (isSelectedItem || isFirstValidItem) {
|
|
185
|
+
context.selectedItemText.set(node);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
const [injectSelectContentContext, provideSelectContentContext] = createContext('RdxSelectContent');
|
|
191
|
+
const RDX_SELECT_POSITIONER_TOKEN = new InjectionToken('RDX_SELECT_POSITIONER_TOKEN');
|
|
192
|
+
class RdxSelectContent {
|
|
193
|
+
set positioner(port) {
|
|
194
|
+
if (port) {
|
|
195
|
+
port.placed.subscribe(() => {
|
|
196
|
+
this.focusSelectedItem();
|
|
197
|
+
this.isPositioned.set(true);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
constructor() {
|
|
202
|
+
this.dismissableLayer = inject(RdxDismissableLayer);
|
|
203
|
+
this.currentElement = inject(ElementRef);
|
|
204
|
+
this.collection = inject(RdxCollectionProvider);
|
|
205
|
+
this.rootContext = injectSelectRootContext();
|
|
206
|
+
this.selectedItem = signal(undefined, ...(ngDevMode ? [{ debugName: "selectedItem" }] : /* istanbul ignore next */ []));
|
|
207
|
+
this.selectedItemText = signal(undefined, ...(ngDevMode ? [{ debugName: "selectedItemText" }] : /* istanbul ignore next */ []));
|
|
208
|
+
this.firstValidItemFoundRef = signal(false, ...(ngDevMode ? [{ debugName: "firstValidItemFoundRef" }] : /* istanbul ignore next */ []));
|
|
209
|
+
this.viewport = signal(undefined, ...(ngDevMode ? [{ debugName: "viewport" }] : /* istanbul ignore next */ []));
|
|
210
|
+
this.isPositioned = signal(false, ...(ngDevMode ? [{ debugName: "isPositioned" }] : /* istanbul ignore next */ []));
|
|
130
211
|
/**
|
|
131
|
-
*
|
|
212
|
+
* Event handler called when the escape key is down.
|
|
213
|
+
* Can be prevented.
|
|
132
214
|
*/
|
|
133
|
-
this.
|
|
134
|
-
this.open = false;
|
|
215
|
+
this.escapeKeyDown = outputFromObservable(outputToObservable(this.dismissableLayer.escapeKeyDown));
|
|
135
216
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
217
|
+
* Event handler called when a `pointerdown` event happens outside of the `DismissableLayer`.
|
|
218
|
+
* Can be prevented.
|
|
138
219
|
*/
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
142
|
-
this.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
220
|
+
this.pointerDownOutside = outputFromObservable(outputToObservable(this.dismissableLayer.pointerDownOutside));
|
|
221
|
+
this.content = signal(null, ...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
222
|
+
this.dismissableLayer.focusOutside.subscribe((e) => e.preventDefault());
|
|
223
|
+
this.dismissableLayer.dismiss.subscribe(() => this.rootContext.onOpenChange(false));
|
|
224
|
+
const focusScope = inject(RdxFocusScope);
|
|
225
|
+
afterNextRender(() => {
|
|
226
|
+
focusScope.unmountAutoFocus.subscribe((event) => {
|
|
227
|
+
if (event.defaultPrevented)
|
|
228
|
+
return;
|
|
229
|
+
this.rootContext.triggerElement()?.focus({ preventScroll: true });
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
});
|
|
232
|
+
focusScope.mountAutoFocus.subscribe((event) => {
|
|
233
|
+
event.preventDefault();
|
|
234
|
+
});
|
|
235
|
+
this.content.set(this.currentElement.nativeElement.firstElementChild);
|
|
148
236
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
237
|
+
effect((onCleanup) => {
|
|
238
|
+
if (!this.content())
|
|
239
|
+
return;
|
|
240
|
+
let pointerMoveDelta = { x: 0, y: 0 };
|
|
241
|
+
const handlePointerMove = (event) => {
|
|
242
|
+
pointerMoveDelta = {
|
|
243
|
+
x: Math.abs(Math.round(event.pageX) - (this.rootContext.triggerPointerDownPosRef()?.x ?? 0)),
|
|
244
|
+
y: Math.abs(Math.round(event.pageY) - (this.rootContext.triggerPointerDownPosRef()?.y ?? 0))
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
const handlePointerUp = (event) => {
|
|
248
|
+
// Prevent options from being untappable on touch devices
|
|
249
|
+
if (event.pointerType === 'touch')
|
|
250
|
+
return;
|
|
251
|
+
// If the pointer hasn't moved by a certain threshold then we prevent selecting item on `pointerup`.
|
|
252
|
+
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
|
|
253
|
+
event.preventDefault();
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
// otherwise, if the event was outside the content, close.
|
|
257
|
+
if (!this.content()?.contains(event.target))
|
|
258
|
+
this.rootContext.onOpenChange(false);
|
|
259
|
+
}
|
|
260
|
+
document.removeEventListener('pointermove', handlePointerMove);
|
|
261
|
+
this.rootContext.triggerPointerDownPosRef.set(null);
|
|
262
|
+
};
|
|
263
|
+
if (this.rootContext.triggerPointerDownPosRef() !== null) {
|
|
264
|
+
document.addEventListener('pointermove', handlePointerMove);
|
|
265
|
+
document.addEventListener('pointerup', handlePointerUp, {
|
|
266
|
+
capture: true,
|
|
267
|
+
once: true
|
|
268
|
+
});
|
|
174
269
|
}
|
|
270
|
+
onCleanup(() => {
|
|
271
|
+
document.removeEventListener('pointermove', handlePointerMove);
|
|
272
|
+
document.removeEventListener('pointerup', handlePointerUp, {
|
|
273
|
+
capture: true
|
|
274
|
+
});
|
|
275
|
+
});
|
|
175
276
|
});
|
|
176
277
|
}
|
|
177
|
-
|
|
178
|
-
this.
|
|
179
|
-
|
|
180
|
-
this.selectionModel.clear();
|
|
181
|
-
this.selectionModel.select(event.source);
|
|
182
|
-
this.close();
|
|
183
|
-
this.trigger().focus();
|
|
184
|
-
});
|
|
185
|
-
this.content().keyManager.tabOut.subscribe(() => {
|
|
186
|
-
if (this.open)
|
|
187
|
-
this.close();
|
|
188
|
-
});
|
|
189
|
-
if (this.defaultOpen) {
|
|
190
|
-
this.openPanel();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Callback that is invoked when the overlay panel has been attached.
|
|
195
|
-
*/
|
|
196
|
-
onAttached() {
|
|
197
|
-
this.closeSubscription = this.closingActions()
|
|
198
|
-
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
199
|
-
.pipe(delay(0))
|
|
200
|
-
.subscribe(() => this.close());
|
|
201
|
-
}
|
|
202
|
-
onDetach() {
|
|
203
|
-
this.close();
|
|
204
|
-
this.closeSubscription.unsubscribe();
|
|
205
|
-
}
|
|
206
|
-
/** Toggles the overlay panel open or closed. */
|
|
207
|
-
toggle() {
|
|
208
|
-
if (this.open) {
|
|
209
|
-
this.close();
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
this.openPanel();
|
|
278
|
+
focusSelectedItem() {
|
|
279
|
+
if (this.selectedItem() && this.content()) {
|
|
280
|
+
focusFirst([this.selectedItem(), this.content()]);
|
|
213
281
|
}
|
|
214
282
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const option = this.content()?.options.find((option) => option.value === value);
|
|
233
|
-
if (option) {
|
|
234
|
-
option.selected = true;
|
|
235
|
-
option.highlighted = true;
|
|
236
|
-
this.selectionModel.select(option);
|
|
237
|
-
this.updateActiveItem(option);
|
|
283
|
+
handleKeyDown(event) {
|
|
284
|
+
const keyEvent = event;
|
|
285
|
+
// select should not be navigated using tab key so we prevent it
|
|
286
|
+
if (keyEvent.key === 'Tab')
|
|
287
|
+
event.preventDefault();
|
|
288
|
+
if (['ArrowUp', 'ArrowDown', 'Home', 'End'].includes(keyEvent.key)) {
|
|
289
|
+
const collectionItems = this.collection.items().map((i) => i.element);
|
|
290
|
+
let candidateNodes = [...collectionItems];
|
|
291
|
+
if (['ArrowUp', 'End'].includes(keyEvent.key))
|
|
292
|
+
candidateNodes = candidateNodes.slice().reverse();
|
|
293
|
+
if (['ArrowUp', 'ArrowDown'].includes(keyEvent.key)) {
|
|
294
|
+
const currentElement = event.target;
|
|
295
|
+
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
296
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
297
|
+
}
|
|
298
|
+
setTimeout(() => focusFirst(candidateNodes));
|
|
299
|
+
event.preventDefault();
|
|
238
300
|
}
|
|
239
301
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
[cdkConnectedOverlayOrigin]="elementRef"
|
|
250
|
-
[cdkConnectedOverlayPositions]="positions"
|
|
251
|
-
[cdkConnectedOverlayScrollStrategy]="overlay.scrollStrategies.reposition()"
|
|
252
|
-
[cdkConnectedOverlayMinWidth]="triggerWidth() > 0 ? triggerWidth() : 'auto'"
|
|
253
|
-
[cdkConnectedOverlayWidth]="matchTriggerWidth ? triggerWidth() : 'auto'"
|
|
254
|
-
[cdkConnectedOverlay]
|
|
255
|
-
(attach)="onAttached()"
|
|
256
|
-
(backdropClick)="close()"
|
|
257
|
-
(detach)="onDetach()"
|
|
258
|
-
cdkConnectedOverlayLockPosition
|
|
259
|
-
cdkConnectedOverlayHasBackdrop
|
|
260
|
-
cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
|
|
261
|
-
cdkConnectedOverlay
|
|
262
|
-
>
|
|
263
|
-
<ng-content select="[rdxSelectContent]" />
|
|
264
|
-
</ng-template>
|
|
265
|
-
`, isInline: true, dependencies: [{ kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i1.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }] }); }
|
|
302
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
303
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectContent, isStandalone: true, selector: "[rdxSelectContent]", outputs: { escapeKeyDown: "escapeKeyDown", pointerDownOutside: "pointerDownOutside" }, host: { attributes: { "role": "listbox" }, listeners: { "keydown": "handleKeyDown($event)" }, properties: { "attr.data-state": "rootContext.open() ? \"open\" : \"closed\"", "dir": "rootContext.dir()", "style": "{\n display: 'flex',\n flexDirection: 'column',\n outline: 'none'\n }" } }, providers: [
|
|
304
|
+
provideSelectContentContext(context$1),
|
|
305
|
+
provideRdxDismissableLayerConfig(() => {
|
|
306
|
+
return {
|
|
307
|
+
disableOutsidePointerEvents: signal(true)
|
|
308
|
+
};
|
|
309
|
+
})
|
|
310
|
+
], queries: [{ propertyName: "positioner", first: true, predicate: RDX_SELECT_POSITIONER_TOKEN, descendants: true }], hostDirectives: [{ directive: i1$1.RdxFocusScope }, { directive: i2.RdxDismissableLayer }, { directive: i3.RdxCollectionProvider }], ngImport: i0 }); }
|
|
266
311
|
}
|
|
267
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
268
|
-
type:
|
|
312
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectContent, decorators: [{
|
|
313
|
+
type: Directive,
|
|
269
314
|
args: [{
|
|
270
|
-
selector: '[
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
[cdkConnectedOverlayWidth]="matchTriggerWidth ? triggerWidth() : 'auto'"
|
|
281
|
-
[cdkConnectedOverlay]
|
|
282
|
-
(attach)="onAttached()"
|
|
283
|
-
(backdropClick)="close()"
|
|
284
|
-
(detach)="onDetach()"
|
|
285
|
-
cdkConnectedOverlayLockPosition
|
|
286
|
-
cdkConnectedOverlayHasBackdrop
|
|
287
|
-
cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
|
|
288
|
-
cdkConnectedOverlay
|
|
289
|
-
>
|
|
290
|
-
<ng-content select="[rdxSelectContent]" />
|
|
291
|
-
</ng-template>
|
|
292
|
-
`,
|
|
315
|
+
selector: '[rdxSelectContent]',
|
|
316
|
+
hostDirectives: [RdxFocusScope, RdxDismissableLayer, RdxCollectionProvider],
|
|
317
|
+
providers: [
|
|
318
|
+
provideSelectContentContext(context$1),
|
|
319
|
+
provideRdxDismissableLayerConfig(() => {
|
|
320
|
+
return {
|
|
321
|
+
disableOutsidePointerEvents: signal(true)
|
|
322
|
+
};
|
|
323
|
+
})
|
|
324
|
+
],
|
|
293
325
|
host: {
|
|
294
|
-
|
|
295
|
-
'[
|
|
296
|
-
'
|
|
297
|
-
'(keydown)': '
|
|
298
|
-
|
|
299
|
-
|
|
326
|
+
role: 'listbox',
|
|
327
|
+
'[attr.data-state]': 'rootContext.open() ? "open" : "closed"',
|
|
328
|
+
'[dir]': 'rootContext.dir()',
|
|
329
|
+
'(keydown)': 'handleKeyDown($event)',
|
|
330
|
+
'[style]': `{
|
|
331
|
+
display: 'flex',
|
|
332
|
+
flexDirection: 'column',
|
|
333
|
+
outline: 'none'
|
|
334
|
+
}`
|
|
335
|
+
}
|
|
300
336
|
}]
|
|
301
|
-
}], propDecorators: {
|
|
302
|
-
type:
|
|
303
|
-
|
|
304
|
-
type: Input
|
|
305
|
-
}], defaultOpen: [{
|
|
306
|
-
type: Input,
|
|
307
|
-
args: [{ transform: booleanAttribute }]
|
|
308
|
-
}], open: [{
|
|
309
|
-
type: Input,
|
|
310
|
-
args: [{ transform: booleanAttribute }]
|
|
311
|
-
}], disabled: [{
|
|
312
|
-
type: Input,
|
|
313
|
-
args: [{ transform: booleanAttribute }]
|
|
314
|
-
}], required: [{
|
|
315
|
-
type: Input,
|
|
316
|
-
args: [{ transform: booleanAttribute }]
|
|
317
|
-
}], matchTriggerWidth: [{
|
|
318
|
-
type: Input,
|
|
319
|
-
args: [{ transform: booleanAttribute }]
|
|
320
|
-
}], value: [{
|
|
321
|
-
type: Input
|
|
322
|
-
}], onValueChange: [{
|
|
323
|
-
type: Output
|
|
324
|
-
}], onOpenChange: [{
|
|
325
|
-
type: Output
|
|
337
|
+
}], ctorParameters: () => [], propDecorators: { escapeKeyDown: [{ type: i0.Output, args: ["escapeKeyDown"] }], pointerDownOutside: [{ type: i0.Output, args: ["pointerDownOutside"] }], positioner: [{
|
|
338
|
+
type: ContentChild,
|
|
339
|
+
args: [RDX_SELECT_POSITIONER_TOKEN, { descendants: true }]
|
|
326
340
|
}] } });
|
|
327
341
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
this.source = source;
|
|
342
|
+
class RdxSelectGroup {
|
|
343
|
+
constructor() {
|
|
344
|
+
this.id = injectId('rdx-select-group-');
|
|
332
345
|
}
|
|
346
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
347
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectGroup, isStandalone: true, selector: "[rdxSelectGroup]", host: { attributes: { "role": "group" }, properties: { "attr.aria-labelledby": "id" } }, exportAs: ["rdxSelectGroup"], ngImport: i0 }); }
|
|
333
348
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
349
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectGroup, decorators: [{
|
|
350
|
+
type: Directive,
|
|
351
|
+
args: [{
|
|
352
|
+
selector: '[rdxSelectGroup]',
|
|
353
|
+
exportAs: 'rdxSelectGroup',
|
|
354
|
+
host: {
|
|
355
|
+
role: 'group',
|
|
356
|
+
'[attr.aria-labelledby]': 'id'
|
|
357
|
+
}
|
|
358
|
+
}]
|
|
359
|
+
}] });
|
|
360
|
+
|
|
361
|
+
const context = () => {
|
|
362
|
+
const context = inject(RdxSelectItem);
|
|
363
|
+
return {
|
|
364
|
+
value: context.value,
|
|
365
|
+
disabled: context.disabled,
|
|
366
|
+
isSelected: context.isSelected,
|
|
367
|
+
textId: context.textId,
|
|
368
|
+
onItemTextChange: (node) => {
|
|
369
|
+
context.textValue$.set(((context.textValue$() || node.textContent) ?? '').trim());
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
const [injectSelectItemContext, provideSelectItemContext] = createContext('RdxSelectItemContext');
|
|
374
|
+
class RdxSelectItem {
|
|
375
|
+
constructor() {
|
|
376
|
+
this.rootContext = injectSelectRootContext();
|
|
377
|
+
this.contentContext = injectSelectContentContext();
|
|
378
|
+
this.currentElement = inject(ElementRef);
|
|
379
|
+
this.value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : /* istanbul ignore next */ []));
|
|
380
|
+
this.textValue = input('', ...(ngDevMode ? [{ debugName: "textValue" }] : /* istanbul ignore next */ []));
|
|
381
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
382
|
+
this.textValue$ = linkedSignal(this.textValue, ...(ngDevMode ? [{ debugName: "textValue$" }] : /* istanbul ignore next */ []));
|
|
383
|
+
this.isSelected = computed(() => valueComparator(this.rootContext.value(), this.value(), this.rootContext.by()), ...(ngDevMode ? [{ debugName: "isSelected" }] : /* istanbul ignore next */ []));
|
|
384
|
+
this.isFocused = signal(false, ...(ngDevMode ? [{ debugName: "isFocused" }] : /* istanbul ignore next */ []));
|
|
385
|
+
this.textId = injectId('rdx-select-item-text-');
|
|
386
|
+
this.afterNextRender = afterNextRender(() => {
|
|
387
|
+
this.contentContext.itemRefCallback(this.currentElement.nativeElement, this.value(), this.disabled());
|
|
388
|
+
});
|
|
389
|
+
this.SELECT_SELECT = 'select.select';
|
|
350
390
|
}
|
|
351
|
-
|
|
352
|
-
|
|
391
|
+
onPointerDown(event) {
|
|
392
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
353
393
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
this.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
this.id = `rdx-select-item-${nextId++}`;
|
|
365
|
-
this.textValue = null;
|
|
366
|
-
this.content.highlighted.pipe(takeUntilDestroyed()).subscribe((value) => {
|
|
367
|
-
if (value !== this) {
|
|
368
|
-
this.highlighted = false;
|
|
394
|
+
onPointerUp(event) {
|
|
395
|
+
if (event.defaultPrevented)
|
|
396
|
+
return;
|
|
397
|
+
const eventDetail = { originalEvent: event, value: this.value() };
|
|
398
|
+
handleAndDispatchCustomEvent(this.SELECT_SELECT, async (event) => {
|
|
399
|
+
if (event.defaultPrevented)
|
|
400
|
+
return;
|
|
401
|
+
this.rootContext.onValueChange(this.value());
|
|
402
|
+
if (!this.rootContext.multiple()) {
|
|
403
|
+
this.rootContext.onOpenChange(false);
|
|
369
404
|
}
|
|
370
|
-
});
|
|
405
|
+
}, eventDetail);
|
|
371
406
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
407
|
+
onPointerLeave(event) {
|
|
408
|
+
if (event.defaultPrevented)
|
|
409
|
+
return;
|
|
410
|
+
if (event.currentTarget === getActiveElement())
|
|
411
|
+
this.contentContext.onItemLeave?.();
|
|
377
412
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
selectViaInteraction() {
|
|
384
|
-
if (!this.disabled) {
|
|
385
|
-
this.selected = true;
|
|
386
|
-
this.onSelectionChange.emit(new RdxSelectItemChange(this));
|
|
413
|
+
onPointerMove(event) {
|
|
414
|
+
if (event.defaultPrevented)
|
|
415
|
+
return;
|
|
416
|
+
if (this.disabled()) {
|
|
417
|
+
this.contentContext.onItemLeave?.();
|
|
387
418
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
this.selectViaInteraction();
|
|
393
|
-
// Prevent the page from scrolling down and form submits.
|
|
394
|
-
event.preventDefault();
|
|
395
|
-
event.stopPropagation();
|
|
419
|
+
else {
|
|
420
|
+
// even though safari doesn't support this option, it's acceptable
|
|
421
|
+
// as it only means it might scroll a few pixels when using the pointer.
|
|
422
|
+
event.currentTarget?.focus({ preventScroll: true });
|
|
396
423
|
}
|
|
397
424
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
425
|
+
handleKeyDown(event) {
|
|
426
|
+
const keyEvent = event;
|
|
427
|
+
if (event.defaultPrevented)
|
|
428
|
+
return;
|
|
429
|
+
if (SELECTION_KEYS.includes(keyEvent.key))
|
|
430
|
+
this.handleSelectCustomEvent(keyEvent);
|
|
431
|
+
// prevent page scroll if using the space key to select an item
|
|
432
|
+
if (keyEvent.key === ' ')
|
|
433
|
+
event.preventDefault();
|
|
406
434
|
}
|
|
407
|
-
|
|
408
|
-
if (
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
435
|
+
async handleSelectCustomEvent(event) {
|
|
436
|
+
if (event.defaultPrevented)
|
|
437
|
+
return;
|
|
438
|
+
const eventDetail = { originalEvent: event, value: this.value() };
|
|
439
|
+
handleAndDispatchCustomEvent(this.SELECT_SELECT, async (event) => {
|
|
440
|
+
if (event.defaultPrevented)
|
|
441
|
+
return;
|
|
442
|
+
if (!this.disabled()) {
|
|
443
|
+
this.rootContext.onValueChange(this.value());
|
|
444
|
+
if (!this.rootContext.multiple())
|
|
445
|
+
this.rootContext.onOpenChange(false);
|
|
446
|
+
}
|
|
447
|
+
}, eventDetail);
|
|
412
448
|
}
|
|
413
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
414
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
449
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItem, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
450
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxSelectItem, isStandalone: true, selector: "[rdxSelectItem]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, textValue: { classPropertyName: "textValue", publicName: "textValue", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "option" }, listeners: { "focus": "isFocused.set(true)", "blur": "isFocused.set(false)", "pointerdown": "onPointerDown($event)", "pointerup": "onPointerUp($event)", "pointerleave": "onPointerLeave($event)", "pointermove": "onPointerMove($event)", "keydown": "handleKeyDown($event)" }, properties: { "attr.tabindex": "disabled() ? undefined : -1", "attr.aria-selected": "isSelected() ? \"checked\" : \"unchecked\"", "attr.data-state": "isSelected() ? \"checked\" : \"unchecked\"", "attr.data-highlighted": "isFocused() ? \"\" : undefined" } }, providers: [provideSelectItemContext(context)], hostDirectives: [{ directive: i3.RdxCollectionItem, inputs: ["value", "value"] }], ngImport: i0 }); }
|
|
415
451
|
}
|
|
416
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
452
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItem, decorators: [{
|
|
417
453
|
type: Directive,
|
|
418
454
|
args: [{
|
|
419
455
|
selector: '[rdxSelectItem]',
|
|
420
|
-
|
|
421
|
-
|
|
456
|
+
providers: [provideSelectItemContext(context)],
|
|
457
|
+
hostDirectives: [
|
|
458
|
+
{
|
|
459
|
+
directive: RdxCollectionItem,
|
|
460
|
+
inputs: ['value']
|
|
461
|
+
}
|
|
462
|
+
],
|
|
422
463
|
host: {
|
|
423
|
-
|
|
424
|
-
'[attr.
|
|
425
|
-
'[attr.aria-selected]': '
|
|
426
|
-
'[attr.data-
|
|
427
|
-
'[attr.data-highlighted]': '
|
|
428
|
-
'
|
|
429
|
-
'(
|
|
430
|
-
'(
|
|
431
|
-
'(
|
|
432
|
-
'(
|
|
464
|
+
role: 'option',
|
|
465
|
+
'[attr.tabindex]': 'disabled() ? undefined : -1',
|
|
466
|
+
'[attr.aria-selected]': 'isSelected() ? "checked" : "unchecked"',
|
|
467
|
+
'[attr.data-state]': 'isSelected() ? "checked" : "unchecked"',
|
|
468
|
+
'[attr.data-highlighted]': 'isFocused() ? "" : undefined',
|
|
469
|
+
'(focus)': 'isFocused.set(true)',
|
|
470
|
+
'(blur)': 'isFocused.set(false)',
|
|
471
|
+
'(pointerdown)': 'onPointerDown($event)',
|
|
472
|
+
'(pointerup)': 'onPointerUp($event)',
|
|
473
|
+
'(pointerleave)': 'onPointerLeave($event)',
|
|
474
|
+
'(pointermove)': 'onPointerMove($event)',
|
|
475
|
+
'(keydown)': 'handleKeyDown($event)'
|
|
433
476
|
}
|
|
434
477
|
}]
|
|
435
|
-
}],
|
|
436
|
-
type: Input
|
|
437
|
-
}], textValue: [{
|
|
438
|
-
type: Input
|
|
439
|
-
}], disabled: [{
|
|
440
|
-
type: Input,
|
|
441
|
-
args: [{ transform: booleanAttribute }]
|
|
442
|
-
}] } });
|
|
478
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], textValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "textValue", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
443
479
|
|
|
444
|
-
class
|
|
480
|
+
class RdxSelectItemIndicator {
|
|
445
481
|
constructor() {
|
|
446
|
-
this.
|
|
447
|
-
this.dir = inject(Directionality, { optional: true });
|
|
448
|
-
this.select = inject(RdxSelectComponent);
|
|
449
|
-
this.highlighted = new Subject();
|
|
450
|
-
this.highlighted.pipe(startWith(null), pairwise()).subscribe(([prev, item]) => {
|
|
451
|
-
if (prev) {
|
|
452
|
-
prev.highlighted = false;
|
|
453
|
-
}
|
|
454
|
-
if (item) {
|
|
455
|
-
item.highlighted = true;
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
initKeyManager() {
|
|
460
|
-
return new ActiveDescendantKeyManager(this.options)
|
|
461
|
-
.withTypeAhead()
|
|
462
|
-
.withVerticalOrientation()
|
|
463
|
-
.withHorizontalOrientation(this.dir?.value ?? 'ltr');
|
|
482
|
+
this.itemContext = injectSelectItemContext();
|
|
464
483
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: RdxSelectContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
469
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.3", type: RdxSelectContentDirective, isStandalone: true, selector: "[rdxSelectContent]", host: { listeners: { "keydown": "keyManager.onKeydown($event)" }, properties: { "attr.role": "\"listbox\"", "attr.data-state": "select.open ? 'open': 'closed'", "attr.data-side": "true", "attr.data-align": "true" } }, queries: [{ propertyName: "options", predicate: RdxSelectItemDirective, descendants: true }], exportAs: ["rdxSelectContent"], ngImport: i0 }); }
|
|
484
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItemIndicator, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
485
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectItemIndicator, isStandalone: true, selector: "[rdxSelectItemIndicator]", host: { properties: { "attr.aria-hidden": "true", "hidden": "!itemContext.isSelected()" } }, ngImport: i0 }); }
|
|
470
486
|
}
|
|
471
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
487
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItemIndicator, decorators: [{
|
|
472
488
|
type: Directive,
|
|
473
489
|
args: [{
|
|
474
|
-
selector: '[
|
|
475
|
-
standalone: true,
|
|
476
|
-
exportAs: 'rdxSelectContent',
|
|
490
|
+
selector: '[rdxSelectItemIndicator]',
|
|
477
491
|
host: {
|
|
478
|
-
'[attr.
|
|
479
|
-
'[
|
|
480
|
-
'[attr.data-side]': 'true',
|
|
481
|
-
'[attr.data-align]': 'true',
|
|
482
|
-
'(keydown)': 'keyManager.onKeydown($event)'
|
|
492
|
+
'[attr.aria-hidden]': 'true',
|
|
493
|
+
'[hidden]': '!itemContext.isSelected()'
|
|
483
494
|
}
|
|
484
495
|
}]
|
|
485
|
-
}]
|
|
486
|
-
type: ContentChildren,
|
|
487
|
-
args: [RdxSelectItemDirective, { descendants: true }]
|
|
488
|
-
}] } });
|
|
496
|
+
}] });
|
|
489
497
|
|
|
490
|
-
class
|
|
491
|
-
|
|
492
|
-
|
|
498
|
+
class RdxSelectItemText {
|
|
499
|
+
constructor() {
|
|
500
|
+
this.elementRef = inject((ElementRef));
|
|
501
|
+
this.rootContext = injectSelectRootContext();
|
|
502
|
+
this.contentContext = injectSelectContentContext();
|
|
503
|
+
this.itemContext = injectSelectItemContext();
|
|
504
|
+
this.optionProps = computed(() => {
|
|
505
|
+
return {
|
|
506
|
+
value: this.itemContext.value(),
|
|
507
|
+
disabled: this.itemContext.disabled(),
|
|
508
|
+
textContent: this.elementRef.nativeElement.textContent ?? this.itemContext.value()?.toString() ?? ''
|
|
509
|
+
};
|
|
510
|
+
}, ...(ngDevMode ? [{ debugName: "optionProps" }] : /* istanbul ignore next */ []));
|
|
511
|
+
afterNextRender(() => {
|
|
512
|
+
this.itemContext.onItemTextChange(this.elementRef.nativeElement);
|
|
513
|
+
this.contentContext.itemTextRefCallback(this.elementRef.nativeElement, this.itemContext.value(), this.itemContext.disabled());
|
|
514
|
+
this.rootContext.onOptionAdd(this.optionProps);
|
|
515
|
+
});
|
|
516
|
+
const destroyRef = inject(DestroyRef);
|
|
517
|
+
destroyRef.onDestroy(() => {
|
|
518
|
+
this.rootContext.onOptionRemove(this.optionProps);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItemText, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
522
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectItemText, isStandalone: true, selector: "[rdxSelectItemText]", host: { properties: { "id": "itemContext.textId" } }, ngImport: i0 }); }
|
|
493
523
|
}
|
|
494
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
524
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItemText, decorators: [{
|
|
495
525
|
type: Directive,
|
|
496
526
|
args: [{
|
|
497
|
-
selector: '[
|
|
498
|
-
standalone: true,
|
|
499
|
-
exportAs: 'rdxSelectGroup',
|
|
527
|
+
selector: '[rdxSelectItemText]',
|
|
500
528
|
host: {
|
|
501
|
-
'[
|
|
529
|
+
'[id]': 'itemContext.textId'
|
|
502
530
|
}
|
|
503
531
|
}]
|
|
532
|
+
}], ctorParameters: () => [] });
|
|
533
|
+
|
|
534
|
+
class RdxSelectLabel {
|
|
535
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectLabel, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
536
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectLabel, isStandalone: true, selector: "[rdxSelectLabel]", ngImport: i0 }); }
|
|
537
|
+
}
|
|
538
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectLabel, decorators: [{
|
|
539
|
+
type: Directive,
|
|
540
|
+
args: [{
|
|
541
|
+
selector: '[rdxSelectLabel]',
|
|
542
|
+
host: {}
|
|
543
|
+
}]
|
|
504
544
|
}] });
|
|
505
545
|
|
|
506
|
-
class
|
|
507
|
-
|
|
508
|
-
|
|
546
|
+
class RdxSelectPopperPositionContent {
|
|
547
|
+
constructor() {
|
|
548
|
+
this.rootContext = injectSelectRootContext();
|
|
549
|
+
}
|
|
550
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPopperPositionContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
551
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectPopperPositionContent, isStandalone: true, selector: "[rdxSelectPopperPositionContent]", host: { attributes: { "role": "listbox" }, properties: { "id": "rootContext.contentId" } }, hostDirectives: [{ directive: i1.RdxPopperContent }], ngImport: i0 }); }
|
|
509
552
|
}
|
|
510
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
553
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPopperPositionContent, decorators: [{
|
|
511
554
|
type: Directive,
|
|
512
555
|
args: [{
|
|
513
|
-
selector: '[
|
|
514
|
-
|
|
515
|
-
exportAs: 'rdxSelectIcon',
|
|
556
|
+
selector: '[rdxSelectPopperPositionContent]',
|
|
557
|
+
hostDirectives: [RdxPopperContent],
|
|
516
558
|
host: {
|
|
517
|
-
|
|
559
|
+
role: 'listbox',
|
|
560
|
+
'[id]': 'rootContext.contentId'
|
|
518
561
|
}
|
|
519
562
|
}]
|
|
520
563
|
}] });
|
|
521
564
|
|
|
522
|
-
class
|
|
565
|
+
class RdxSelectPopperPositionWrapper {
|
|
523
566
|
constructor() {
|
|
524
|
-
|
|
567
|
+
/**
|
|
568
|
+
* The preferred side of the anchor to render against when open.
|
|
569
|
+
* Will be reversed when collisions occur and avoidCollisions is enabled.
|
|
570
|
+
*/
|
|
571
|
+
this.side = input('bottom', ...(ngDevMode ? [{ debugName: "side" }] : /* istanbul ignore next */ []));
|
|
572
|
+
/**
|
|
573
|
+
* The distance in pixels from the anchor.
|
|
574
|
+
*/
|
|
575
|
+
this.sideOffset = input(0, { ...(ngDevMode ? { debugName: "sideOffset" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
576
|
+
/**
|
|
577
|
+
* The preferred alignment against the anchor. May change when collisions occur.
|
|
578
|
+
*/
|
|
579
|
+
this.align = input('start', ...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
|
|
580
|
+
/**
|
|
581
|
+
* An offset in pixels from the `start` or `end` alignment options.
|
|
582
|
+
*/
|
|
583
|
+
this.alignOffset = input(0, { ...(ngDevMode ? { debugName: "alignOffset" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
584
|
+
/**
|
|
585
|
+
* The padding between the arrow and the edges of the content.
|
|
586
|
+
* If your content has border-radius, this will prevent it from overflowing the corners.
|
|
587
|
+
*/
|
|
588
|
+
this.arrowPadding = input(0, { ...(ngDevMode ? { debugName: "arrowPadding" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
589
|
+
/**
|
|
590
|
+
* When `true`, overrides the `side` and `align` preferences to prevent collisions with boundary edges.
|
|
591
|
+
*/
|
|
592
|
+
this.avoidCollisions = input(true, { ...(ngDevMode ? { debugName: "avoidCollisions" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
593
|
+
/**
|
|
594
|
+
* The element used as the collision boundary.
|
|
595
|
+
* By default this is the viewport, though you can provide additional element(s) to be included in this check.
|
|
596
|
+
*/
|
|
597
|
+
this.collisionBoundary = input(...(ngDevMode ? [undefined, { debugName: "collisionBoundary" }] : /* istanbul ignore next */ []));
|
|
598
|
+
/**
|
|
599
|
+
* The distance in pixels from the boundary edges where collision detection should occur.
|
|
600
|
+
* Accepts a number (same for all sides), or a partial padding object, for example: `{ top: 20, left: 20 }`.
|
|
601
|
+
*/
|
|
602
|
+
this.collisionPadding = input(0, ...(ngDevMode ? [{ debugName: "collisionPadding" }] : /* istanbul ignore next */ []));
|
|
603
|
+
/**
|
|
604
|
+
* The sticky behavior on the `align` axis.
|
|
605
|
+
* - `partial` will keep the content in the boundary as long as the trigger is at least partially in the boundary
|
|
606
|
+
* - `always` will keep the content in the boundary regardless.
|
|
607
|
+
*/
|
|
608
|
+
this.sticky = input('partial', ...(ngDevMode ? [{ debugName: "sticky" }] : /* istanbul ignore next */ []));
|
|
609
|
+
/**
|
|
610
|
+
* Whether to hide the content when the trigger becomes fully occluded.
|
|
611
|
+
*/
|
|
612
|
+
this.hideWhenDetached = input(false, { ...(ngDevMode ? { debugName: "hideWhenDetached" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
613
|
+
/**
|
|
614
|
+
* Whether to update the position of the floating element on every animation frame if required.
|
|
615
|
+
*/
|
|
616
|
+
this.updatePositionStrategy = input('always', ...(ngDevMode ? [{ debugName: "updatePositionStrategy" }] : /* istanbul ignore next */ []));
|
|
617
|
+
/**
|
|
618
|
+
* Emits when the element is placed.
|
|
619
|
+
*/
|
|
620
|
+
this.placed = outputFromObservable(outputToObservable(inject(RdxPopperContentWrapper).placed));
|
|
525
621
|
}
|
|
526
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
527
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
622
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPopperPositionWrapper, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
623
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxSelectPopperPositionWrapper, isStandalone: true, selector: "[rdxSelectPopperPositionWrapper]", inputs: { side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, sideOffset: { classPropertyName: "sideOffset", publicName: "sideOffset", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null }, alignOffset: { classPropertyName: "alignOffset", publicName: "alignOffset", isSignal: true, isRequired: false, transformFunction: null }, arrowPadding: { classPropertyName: "arrowPadding", publicName: "arrowPadding", isSignal: true, isRequired: false, transformFunction: null }, avoidCollisions: { classPropertyName: "avoidCollisions", publicName: "avoidCollisions", isSignal: true, isRequired: false, transformFunction: null }, collisionBoundary: { classPropertyName: "collisionBoundary", publicName: "collisionBoundary", isSignal: true, isRequired: false, transformFunction: null }, collisionPadding: { classPropertyName: "collisionPadding", publicName: "collisionPadding", isSignal: true, isRequired: false, transformFunction: null }, sticky: { classPropertyName: "sticky", publicName: "sticky", isSignal: true, isRequired: false, transformFunction: null }, hideWhenDetached: { classPropertyName: "hideWhenDetached", publicName: "hideWhenDetached", isSignal: true, isRequired: false, transformFunction: null }, updatePositionStrategy: { classPropertyName: "updatePositionStrategy", publicName: "updatePositionStrategy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { placed: "placed" }, host: { properties: { "style": "{\n 'boxSizing': 'border-box',\n '--radix-tooltip-content-transform-origin': 'var(--radix-popper-transform-origin)',\n '--radix-tooltip-content-available-width': 'var(--radix-popper-available-width)',\n '--radix-tooltip-content-available-height': 'var(--radix-popper-available-height)',\n '--radix-tooltip-trigger-width': 'var(--radix-popper-anchor-width)',\n '--radix-tooltip-trigger-height': 'var(--radix-popper-anchor-height)',\n }" } }, providers: [
|
|
624
|
+
{
|
|
625
|
+
provide: RDX_SELECT_POSITIONER_TOKEN,
|
|
626
|
+
useExisting: forwardRef(() => RdxSelectPopperPositionWrapper)
|
|
627
|
+
}
|
|
628
|
+
], hostDirectives: [{ directive: i1.RdxPopperContentWrapper, inputs: ["side", "side", "sideOffset", "sideOffset", "align", "align", "alignOffset", "alignOffset", "arrowPadding", "arrowPadding", "avoidCollisions", "avoidCollisions", "collisionBoundary", "collisionBoundary", "collisionPadding", "collisionPadding", "sticky", "sticky", "hideWhenDetached", "hideWhenDetached", "updatePositionStrategy", "updatePositionStrategy"] }], ngImport: i0 }); }
|
|
528
629
|
}
|
|
529
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
630
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPopperPositionWrapper, decorators: [{
|
|
530
631
|
type: Directive,
|
|
531
632
|
args: [{
|
|
532
|
-
selector: '[
|
|
533
|
-
|
|
534
|
-
|
|
633
|
+
selector: '[rdxSelectPopperPositionWrapper]',
|
|
634
|
+
providers: [
|
|
635
|
+
{
|
|
636
|
+
provide: RDX_SELECT_POSITIONER_TOKEN,
|
|
637
|
+
useExisting: forwardRef(() => RdxSelectPopperPositionWrapper)
|
|
638
|
+
}
|
|
639
|
+
],
|
|
640
|
+
hostDirectives: [
|
|
641
|
+
{
|
|
642
|
+
directive: RdxPopperContentWrapper,
|
|
643
|
+
inputs: [
|
|
644
|
+
'side',
|
|
645
|
+
'sideOffset',
|
|
646
|
+
'align',
|
|
647
|
+
'alignOffset',
|
|
648
|
+
'arrowPadding',
|
|
649
|
+
'avoidCollisions',
|
|
650
|
+
'collisionBoundary',
|
|
651
|
+
'collisionPadding',
|
|
652
|
+
'sticky',
|
|
653
|
+
'hideWhenDetached',
|
|
654
|
+
'updatePositionStrategy'
|
|
655
|
+
]
|
|
656
|
+
}
|
|
657
|
+
],
|
|
535
658
|
host: {
|
|
536
|
-
|
|
537
|
-
'[style
|
|
659
|
+
// re-namespace exposed content custom properties
|
|
660
|
+
'[style]': `{
|
|
661
|
+
'boxSizing': 'border-box',
|
|
662
|
+
'--radix-tooltip-content-transform-origin': 'var(--radix-popper-transform-origin)',
|
|
663
|
+
'--radix-tooltip-content-available-width': 'var(--radix-popper-available-width)',
|
|
664
|
+
'--radix-tooltip-content-available-height': 'var(--radix-popper-available-height)',
|
|
665
|
+
'--radix-tooltip-trigger-width': 'var(--radix-popper-anchor-width)',
|
|
666
|
+
'--radix-tooltip-trigger-height': 'var(--radix-popper-anchor-height)',
|
|
667
|
+
}`
|
|
538
668
|
}
|
|
539
669
|
}]
|
|
540
|
-
}] });
|
|
670
|
+
}], propDecorators: { side: [{ type: i0.Input, args: [{ isSignal: true, alias: "side", required: false }] }], sideOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "sideOffset", required: false }] }], align: [{ type: i0.Input, args: [{ isSignal: true, alias: "align", required: false }] }], alignOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "alignOffset", required: false }] }], arrowPadding: [{ type: i0.Input, args: [{ isSignal: true, alias: "arrowPadding", required: false }] }], avoidCollisions: [{ type: i0.Input, args: [{ isSignal: true, alias: "avoidCollisions", required: false }] }], collisionBoundary: [{ type: i0.Input, args: [{ isSignal: true, alias: "collisionBoundary", required: false }] }], collisionPadding: [{ type: i0.Input, args: [{ isSignal: true, alias: "collisionPadding", required: false }] }], sticky: [{ type: i0.Input, args: [{ isSignal: true, alias: "sticky", required: false }] }], hideWhenDetached: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideWhenDetached", required: false }] }], updatePositionStrategy: [{ type: i0.Input, args: [{ isSignal: true, alias: "updatePositionStrategy", required: false }] }], placed: [{ type: i0.Output, args: ["placed"] }] } });
|
|
671
|
+
|
|
672
|
+
class RdxSelectPortal {
|
|
673
|
+
constructor() {
|
|
674
|
+
/**
|
|
675
|
+
* Optional container to portal the content into. Defaults to `document.body` when not set.
|
|
676
|
+
*/
|
|
677
|
+
this.container = input(...(ngDevMode ? [undefined, { debugName: "container" }] : /* istanbul ignore next */ []));
|
|
678
|
+
}
|
|
679
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPortal, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
680
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxSelectPortal, isStandalone: true, selector: "[rdxSelectPortal]", inputs: { container: { classPropertyName: "container", publicName: "container", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: i1$2.RdxPortal, inputs: ["container", "container"] }], ngImport: i0 }); }
|
|
681
|
+
}
|
|
682
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPortal, decorators: [{
|
|
683
|
+
type: Directive,
|
|
684
|
+
args: [{
|
|
685
|
+
selector: '[rdxSelectPortal]',
|
|
686
|
+
hostDirectives: [
|
|
687
|
+
{
|
|
688
|
+
directive: RdxPortal,
|
|
689
|
+
inputs: ['container']
|
|
690
|
+
}
|
|
691
|
+
]
|
|
692
|
+
}]
|
|
693
|
+
}], propDecorators: { container: [{ type: i0.Input, args: [{ isSignal: true, alias: "container", required: false }] }] } });
|
|
541
694
|
|
|
542
|
-
class
|
|
543
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
544
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
695
|
+
class RdxSelectPortalPresence {
|
|
696
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPortalPresence, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
697
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectPortalPresence, isStandalone: true, selector: "ng-template[rdxSelectPortalPresence]", providers: [
|
|
698
|
+
provideRdxPresenceContext(() => {
|
|
699
|
+
const context = injectSelectRootContext();
|
|
700
|
+
return { present: context.open };
|
|
701
|
+
})
|
|
702
|
+
], hostDirectives: [{ directive: i1$3.RdxPresenceDirective }], ngImport: i0 }); }
|
|
545
703
|
}
|
|
546
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
704
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPortalPresence, decorators: [{
|
|
547
705
|
type: Directive,
|
|
548
706
|
args: [{
|
|
549
|
-
selector: '[
|
|
550
|
-
|
|
551
|
-
|
|
707
|
+
selector: 'ng-template[rdxSelectPortalPresence]',
|
|
708
|
+
hostDirectives: [RdxPresenceDirective],
|
|
709
|
+
providers: [
|
|
710
|
+
provideRdxPresenceContext(() => {
|
|
711
|
+
const context = injectSelectRootContext();
|
|
712
|
+
return { present: context.open };
|
|
713
|
+
})
|
|
714
|
+
]
|
|
552
715
|
}]
|
|
553
716
|
}] });
|
|
554
717
|
|
|
555
|
-
class
|
|
556
|
-
|
|
557
|
-
|
|
718
|
+
class RdxSelectTrigger {
|
|
719
|
+
constructor() {
|
|
720
|
+
this.rootContext = injectSelectRootContext();
|
|
721
|
+
this.elementRef = inject(ElementRef);
|
|
722
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
723
|
+
this.isDisabled = computed(() => this.rootContext.disabled() || this.disabled(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
|
|
724
|
+
afterNextRender(() => {
|
|
725
|
+
this.rootContext.onTriggerChange(this.elementRef);
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
handleOpen() {
|
|
729
|
+
if (!this.isDisabled()) {
|
|
730
|
+
this.rootContext.onOpenChange(true);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
handlePointerOpen(event) {
|
|
734
|
+
const pointerEvent = event;
|
|
735
|
+
this.handleOpen();
|
|
736
|
+
this.rootContext.triggerPointerDownPosRef.set({
|
|
737
|
+
x: Math.round(pointerEvent.pageX),
|
|
738
|
+
y: Math.round(pointerEvent.pageY)
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
onClickHandler(event) {
|
|
742
|
+
// Whilst browsers generally have no issue focusing the trigger when clicking
|
|
743
|
+
// on a label, Safari seems to struggle with the fact that there's no `onClick`.
|
|
744
|
+
// We force `focus` in this case. Note: this doesn't create any other side-effect
|
|
745
|
+
// because we are preventing default in `onPointerDown` so effectively
|
|
746
|
+
// this only runs for a label 'click'
|
|
747
|
+
event?.currentTarget?.focus();
|
|
748
|
+
}
|
|
749
|
+
onPointerDown(event) {
|
|
750
|
+
const pointerEvent = event;
|
|
751
|
+
if (pointerEvent.pointerType === 'touch')
|
|
752
|
+
return event.preventDefault();
|
|
753
|
+
// prevent implicit pointer capture
|
|
754
|
+
// https://www.w3.org/TR/pointerevents3/#implicit-pointer-capture
|
|
755
|
+
const target = event.target;
|
|
756
|
+
if (target.hasPointerCapture(pointerEvent.pointerId)) {
|
|
757
|
+
target.releasePointerCapture(pointerEvent.pointerId);
|
|
758
|
+
}
|
|
759
|
+
// only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
|
|
760
|
+
// but not when the control key is pressed (avoiding MacOS right click)
|
|
761
|
+
if (pointerEvent.button === 0 && pointerEvent.ctrlKey === false) {
|
|
762
|
+
this.handlePointerOpen(event);
|
|
763
|
+
// prevent trigger from stealing focus from the active item after opening.
|
|
764
|
+
event.preventDefault();
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
onPointerUp(event) {
|
|
768
|
+
const pointerEvent = event;
|
|
769
|
+
event.preventDefault();
|
|
770
|
+
// Only open on pointer up when using touch devices
|
|
771
|
+
if (pointerEvent.pointerType === 'touch')
|
|
772
|
+
this.handlePointerOpen(event);
|
|
773
|
+
}
|
|
774
|
+
onKeydown(event) {
|
|
775
|
+
const keyEvent = event;
|
|
776
|
+
if (OPEN_KEYS.includes(keyEvent.key)) {
|
|
777
|
+
this.handleOpen();
|
|
778
|
+
event.preventDefault();
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
782
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxSelectTrigger, isStandalone: true, selector: "button[rdxSelectTrigger]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "combobox", "type": "button" }, listeners: { "click": "onClickHandler($event)", "pointerdown": "onPointerDown($event)", "pointerup": "onPointerUp($event)", "keydown": "onKeydown($event)" }, properties: { "attr.disabled": "isDisabled() ? \"\" : undefined", "dir": "rootContext.dir()", "attr.data-state": "rootContext.open() ? \"open\" : \"closed\"", "attr.data-disabled": "isDisabled() ? \"\" : undefined" } }, hostDirectives: [{ directive: i1.RdxPopperAnchor }], ngImport: i0 }); }
|
|
558
783
|
}
|
|
559
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
784
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectTrigger, decorators: [{
|
|
560
785
|
type: Directive,
|
|
561
786
|
args: [{
|
|
562
|
-
selector: '[
|
|
563
|
-
|
|
564
|
-
exportAs: 'rdxSelectSeparator',
|
|
787
|
+
selector: 'button[rdxSelectTrigger]',
|
|
788
|
+
hostDirectives: [RdxPopperAnchor],
|
|
565
789
|
host: {
|
|
566
|
-
|
|
790
|
+
role: 'combobox',
|
|
791
|
+
type: 'button',
|
|
792
|
+
'[attr.disabled]': 'isDisabled() ? "" : undefined',
|
|
793
|
+
'[dir]': 'rootContext.dir()',
|
|
794
|
+
'[attr.data-state]': 'rootContext.open() ? "open" : "closed"',
|
|
795
|
+
'[attr.data-disabled]': 'isDisabled() ? "" : undefined',
|
|
796
|
+
'(click)': 'onClickHandler($event)',
|
|
797
|
+
'(pointerdown)': 'onPointerDown($event)',
|
|
798
|
+
'(pointerup)': 'onPointerUp($event)',
|
|
799
|
+
'(keydown)': 'onKeydown($event)'
|
|
567
800
|
}
|
|
568
801
|
}]
|
|
569
|
-
}] });
|
|
802
|
+
}], ctorParameters: () => [], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
570
803
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
RdxSelectLabelDirective,
|
|
599
|
-
RdxSelectComponent,
|
|
600
|
-
RdxSelectSeparatorDirective,
|
|
601
|
-
RdxSelectTriggerDirective,
|
|
602
|
-
RdxSelectValueDirective,
|
|
603
|
-
RdxSelectIconDirective] }); }
|
|
604
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: RdxSelectModule, imports: [RdxSelectComponent] }); }
|
|
804
|
+
class RdxSelectValue {
|
|
805
|
+
constructor() {
|
|
806
|
+
this.rootContext = injectSelectRootContext();
|
|
807
|
+
this.elementRef = inject(ElementRef);
|
|
808
|
+
this.placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
809
|
+
this.slotText = computed(() => {
|
|
810
|
+
return this.selectedLabel().length ? this.selectedLabel().join(', ') : this.placeholder();
|
|
811
|
+
}, ...(ngDevMode ? [{ debugName: "slotText" }] : /* istanbul ignore next */ []));
|
|
812
|
+
this.selectedLabel = computed(() => {
|
|
813
|
+
// eslint-disable-next-line no-useless-assignment
|
|
814
|
+
let list = [];
|
|
815
|
+
const options = Array.from(this.rootContext.optionsSet());
|
|
816
|
+
const getOption = (value) => options.find((option) => valueComparator(value, option.value, this.rootContext.by()));
|
|
817
|
+
if (Array.isArray(this.rootContext.value())) {
|
|
818
|
+
list = Array(this.rootContext.value()).map((value) => getOption(value)?.textContent ?? '');
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
list = [getOption(this.rootContext.value())?.textContent ?? ''];
|
|
822
|
+
}
|
|
823
|
+
return list.filter(Boolean);
|
|
824
|
+
}, ...(ngDevMode ? [{ debugName: "selectedLabel" }] : /* istanbul ignore next */ []));
|
|
825
|
+
afterNextRender(() => {
|
|
826
|
+
this.rootContext.valueElement.set(this.elementRef.nativeElement);
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectValue, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
830
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxSelectValue, isStandalone: true, selector: "span[rdxSelectValue]", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.pointer-events": "\"none\"" } }, exportAs: ["rdxSelectedValue"], ngImport: i0 }); }
|
|
605
831
|
}
|
|
606
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
607
|
-
type:
|
|
832
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectValue, decorators: [{
|
|
833
|
+
type: Directive,
|
|
608
834
|
args: [{
|
|
609
|
-
|
|
610
|
-
|
|
835
|
+
selector: 'span[rdxSelectValue]',
|
|
836
|
+
exportAs: 'rdxSelectedValue',
|
|
837
|
+
host: {
|
|
838
|
+
'[style.pointer-events]': '"none"'
|
|
839
|
+
}
|
|
611
840
|
}]
|
|
612
|
-
}] });
|
|
841
|
+
}], ctorParameters: () => [], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }] } });
|
|
842
|
+
|
|
843
|
+
class RdxSelectViewport {
|
|
844
|
+
constructor() {
|
|
845
|
+
this.contentContext = injectSelectContentContext();
|
|
846
|
+
this.elementRef = inject((ElementRef));
|
|
847
|
+
this.prevScrollTopRef = signal(0, ...(ngDevMode ? [{ debugName: "prevScrollTopRef" }] : /* istanbul ignore next */ []));
|
|
848
|
+
afterNextRender(() => {
|
|
849
|
+
this.contentContext?.onViewportChange(this.elementRef.nativeElement);
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
handleScroll(event) {
|
|
853
|
+
const viewport = event.currentTarget;
|
|
854
|
+
this.prevScrollTopRef.set(viewport.scrollTop);
|
|
855
|
+
}
|
|
856
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectViewport, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
857
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectViewport, isStandalone: true, selector: "[rdxSelectViewport]", host: { attributes: { "role": "presentation" }, listeners: { "scroll": "handleScroll($event)" }, properties: { "attr.data-rdx-select-viewport": "\"\"", "style": "{\n position: 'relative',\n flex: 1,\n overflow: 'hidden auto',\n scrollbarWidth: 'none'\n }" } }, ngImport: i0 }); }
|
|
858
|
+
}
|
|
859
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectViewport, decorators: [{
|
|
860
|
+
type: Directive,
|
|
861
|
+
args: [{
|
|
862
|
+
selector: '[rdxSelectViewport]',
|
|
863
|
+
host: {
|
|
864
|
+
role: 'presentation',
|
|
865
|
+
'[attr.data-rdx-select-viewport]': '""',
|
|
866
|
+
'[style]': `{
|
|
867
|
+
position: 'relative',
|
|
868
|
+
flex: 1,
|
|
869
|
+
overflow: 'hidden auto',
|
|
870
|
+
scrollbarWidth: 'none'
|
|
871
|
+
}`,
|
|
872
|
+
'(scroll)': 'handleScroll($event)'
|
|
873
|
+
}
|
|
874
|
+
}]
|
|
875
|
+
}], ctorParameters: () => [] });
|
|
876
|
+
|
|
877
|
+
const _importsSelect = [
|
|
878
|
+
RdxSelectRoot,
|
|
879
|
+
RdxSelectPortal,
|
|
880
|
+
RdxSelectTrigger,
|
|
881
|
+
RdxSelectValue,
|
|
882
|
+
RdxSelectContent,
|
|
883
|
+
RdxSelectViewport,
|
|
884
|
+
RdxSelectItemIndicator,
|
|
885
|
+
RdxSelectItem,
|
|
886
|
+
RdxSelectItemText,
|
|
887
|
+
RdxSelectLabel,
|
|
888
|
+
RdxSelectGroup,
|
|
889
|
+
RdxSelectPopperPositionContent,
|
|
890
|
+
RdxSelectPopperPositionWrapper,
|
|
891
|
+
RdxSelectPortalPresence
|
|
892
|
+
];
|
|
613
893
|
|
|
614
894
|
/**
|
|
615
895
|
* Generated bundle index. Do not edit.
|
|
616
896
|
*/
|
|
617
897
|
|
|
618
|
-
export {
|
|
898
|
+
export { CONTENT_MARGIN, OPEN_KEYS, RDX_SELECT_POSITIONER_TOKEN, RdxSelectContent, RdxSelectGroup, RdxSelectItem, RdxSelectItemIndicator, RdxSelectItemText, RdxSelectLabel, RdxSelectPopperPositionContent, RdxSelectPopperPositionWrapper, RdxSelectPortal, RdxSelectPortalPresence, RdxSelectRoot, RdxSelectTrigger, RdxSelectValue, RdxSelectViewport, SELECTION_KEYS, _importsSelect, compare, focusFirst, injectSelectContentContext, injectSelectItemContext, injectSelectRootContext, provideSelectContentContext, provideSelectItemContext, provideSelectRootContext, shouldShowPlaceholder, valueComparator };
|
|
619
899
|
//# sourceMappingURL=radix-ng-primitives-select.mjs.map
|