@radix-ng/primitives 0.50.0 → 0.51.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 +41 -40
- package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs +22 -22
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-arrow.mjs +6 -6
- 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 +22 -22
- package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
- 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 +51 -41
- package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collapsible.mjs +28 -28
- package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collection.mjs +89 -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 +36 -36
- package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +33 -24
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-cropper.mjs +54 -53
- package/fesm2022/radix-ng-primitives-cropper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-date-field.mjs +48 -47
- package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dialog.mjs +34 -34
- package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +31 -33
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +41 -43
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-editable.mjs +20 -20
- package/fesm2022/radix-ng-primitives-editable.mjs.map +1 -1
- 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 +7 -7
- package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-hover-card.mjs +69 -77
- package/fesm2022/radix-ng-primitives-hover-card.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-label.mjs +7 -7
- package/fesm2022/radix-ng-primitives-label.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menu.mjs +65 -70
- package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menubar.mjs +31 -31
- package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs +113 -105
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-number-field.mjs +48 -47
- 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 +67 -71
- package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popper.mjs +61 -56
- package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-portal.mjs +7 -7
- package/fesm2022/radix-ng-primitives-portal.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-presence.mjs +4 -4
- package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-progress.mjs +16 -16
- package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-radio.mjs +38 -37
- package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-roving-focus.mjs +38 -34
- package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-select.mjs +41 -43
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-select2.mjs +897 -0
- package/fesm2022/radix-ng-primitives-select2.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-separator.mjs +11 -17
- package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-slider.mjs +88 -84
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-stepper.mjs +55 -53
- package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +22 -30
- package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tabs.mjs +38 -38
- package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-time-field.mjs +63 -78
- package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +24 -24
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +11 -11
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toolbar.mjs +31 -29
- package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tooltip.mjs +69 -77
- package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tooltip2.mjs +57 -62
- package/fesm2022/radix-ng-primitives-tooltip2.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs +31 -31
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives.mjs.map +1 -1
- package/package.json +63 -54
- package/select2/README.md +3 -0
- package/{accordion/index.d.ts → types/radix-ng-primitives-accordion.d.ts} +61 -60
- package/{calendar/index.d.ts → types/radix-ng-primitives-calendar.d.ts} +1 -1
- package/{checkbox/index.d.ts → types/radix-ng-primitives-checkbox.d.ts} +31 -27
- package/{collapsible/index.d.ts → types/radix-ng-primitives-collapsible.d.ts} +20 -19
- package/types/radix-ng-primitives-collection.d.ts +40 -0
- package/{core/index.d.ts → types/radix-ng-primitives-core.d.ts} +6 -2
- package/{cropper/index.d.ts → types/radix-ng-primitives-cropper.d.ts} +4 -3
- package/{date-field/index.d.ts → types/radix-ng-primitives-date-field.d.ts} +4 -4
- package/{dialog/index.d.ts → types/radix-ng-primitives-dialog.d.ts} +2 -1
- package/{hover-card/index.d.ts → types/radix-ng-primitives-hover-card.d.ts} +3 -4
- package/{menu/index.d.ts → types/radix-ng-primitives-menu.d.ts} +1 -1
- package/{navigation-menu/index.d.ts → types/radix-ng-primitives-navigation-menu.d.ts} +47 -46
- package/{number-field/index.d.ts → types/radix-ng-primitives-number-field.d.ts} +13 -12
- package/{popover/index.d.ts → types/radix-ng-primitives-popover.d.ts} +3 -4
- package/{popper/index.d.ts → types/radix-ng-primitives-popper.d.ts} +1 -0
- package/{progress/index.d.ts → types/radix-ng-primitives-progress.d.ts} +2 -1
- package/{radio/index.d.ts → types/radix-ng-primitives-radio.d.ts} +1 -1
- package/{roving-focus/index.d.ts → types/radix-ng-primitives-roving-focus.d.ts} +8 -6
- package/types/radix-ng-primitives-select2.d.ts +511 -0
- package/{slider/index.d.ts → types/radix-ng-primitives-slider.d.ts} +4 -4
- package/{stepper/index.d.ts → types/radix-ng-primitives-stepper.d.ts} +17 -16
- package/{switch/index.d.ts → types/radix-ng-primitives-switch.d.ts} +3 -2
- package/{tabs/index.d.ts → types/radix-ng-primitives-tabs.d.ts} +7 -6
- package/{time-field/index.d.ts → types/radix-ng-primitives-time-field.d.ts} +4 -4
- package/{toggle-group/index.d.ts → types/radix-ng-primitives-toggle-group.d.ts} +12 -11
- package/{tooltip/index.d.ts → types/radix-ng-primitives-tooltip.d.ts} +3 -4
- package/{tooltip2/index.d.ts → types/radix-ng-primitives-tooltip2.d.ts} +4 -4
- /package/{alert-dialog/index.d.ts → types/radix-ng-primitives-alert-dialog.d.ts} +0 -0
- /package/{arrow/index.d.ts → types/radix-ng-primitives-arrow.d.ts} +0 -0
- /package/{aspect-ratio/index.d.ts → types/radix-ng-primitives-aspect-ratio.d.ts} +0 -0
- /package/{avatar/index.d.ts → types/radix-ng-primitives-avatar.d.ts} +0 -0
- /package/{config/index.d.ts → types/radix-ng-primitives-config.d.ts} +0 -0
- /package/{context-menu/index.d.ts → types/radix-ng-primitives-context-menu.d.ts} +0 -0
- /package/{dismissable-layer/index.d.ts → types/radix-ng-primitives-dismissable-layer.d.ts} +0 -0
- /package/{dropdown-menu/index.d.ts → types/radix-ng-primitives-dropdown-menu.d.ts} +0 -0
- /package/{editable/index.d.ts → types/radix-ng-primitives-editable.d.ts} +0 -0
- /package/{focus-guards/index.d.ts → types/radix-ng-primitives-focus-guards.d.ts} +0 -0
- /package/{focus-scope/index.d.ts → types/radix-ng-primitives-focus-scope.d.ts} +0 -0
- /package/{label/index.d.ts → types/radix-ng-primitives-label.d.ts} +0 -0
- /package/{menubar/index.d.ts → types/radix-ng-primitives-menubar.d.ts} +0 -0
- /package/{pagination/index.d.ts → types/radix-ng-primitives-pagination.d.ts} +0 -0
- /package/{portal/index.d.ts → types/radix-ng-primitives-portal.d.ts} +0 -0
- /package/{presence/index.d.ts → types/radix-ng-primitives-presence.d.ts} +0 -0
- /package/{select/index.d.ts → types/radix-ng-primitives-select.d.ts} +0 -0
- /package/{separator/index.d.ts → types/radix-ng-primitives-separator.d.ts} +0 -0
- /package/{toggle/index.d.ts → types/radix-ng-primitives-toggle.d.ts} +0 -0
- /package/{toolbar/index.d.ts → types/radix-ng-primitives-toolbar.d.ts} +0 -0
- /package/{visually-hidden/index.d.ts → types/radix-ng-primitives-visually-hidden.d.ts} +0 -0
- /package/{index.d.ts → types/radix-ng-primitives.d.ts} +0 -0
|
@@ -0,0 +1,897 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
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 { useCollection, RdxCollectionProvider, RdxCollectionItem } from '@radix-ng/primitives/collection';
|
|
6
|
+
import { isEqual, getActiveElement, createContext, isNullish, _IdGenerator, 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';
|
|
17
|
+
|
|
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;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
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 {
|
|
96
|
+
constructor() {
|
|
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);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
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 }); }
|
|
146
|
+
}
|
|
147
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectRoot, decorators: [{
|
|
148
|
+
type: Directive,
|
|
149
|
+
args: [{
|
|
150
|
+
selector: '[rdxSelectRoot]',
|
|
151
|
+
exportAs: 'rdxSelectRoot',
|
|
152
|
+
providers: [provideSelectRootContext(context$2)],
|
|
153
|
+
hostDirectives: [RdxPopper]
|
|
154
|
+
}]
|
|
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 }] }] } });
|
|
156
|
+
|
|
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);
|
|
176
|
+
}
|
|
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.rootContext = injectSelectRootContext();
|
|
205
|
+
this.selectedItem = signal(undefined, ...(ngDevMode ? [{ debugName: "selectedItem" }] : /* istanbul ignore next */ []));
|
|
206
|
+
this.selectedItemText = signal(undefined, ...(ngDevMode ? [{ debugName: "selectedItemText" }] : /* istanbul ignore next */ []));
|
|
207
|
+
this.firstValidItemFoundRef = signal(false, ...(ngDevMode ? [{ debugName: "firstValidItemFoundRef" }] : /* istanbul ignore next */ []));
|
|
208
|
+
this.viewport = signal(undefined, ...(ngDevMode ? [{ debugName: "viewport" }] : /* istanbul ignore next */ []));
|
|
209
|
+
this.isPositioned = signal(false, ...(ngDevMode ? [{ debugName: "isPositioned" }] : /* istanbul ignore next */ []));
|
|
210
|
+
/**
|
|
211
|
+
* Event handler called when the escape key is down.
|
|
212
|
+
* Can be prevented.
|
|
213
|
+
*/
|
|
214
|
+
this.escapeKeyDown = outputFromObservable(outputToObservable(this.dismissableLayer.escapeKeyDown));
|
|
215
|
+
/**
|
|
216
|
+
* Event handler called when a `pointerdown` event happens outside of the `DismissableLayer`.
|
|
217
|
+
* Can be prevented.
|
|
218
|
+
*/
|
|
219
|
+
this.pointerDownOutside = outputFromObservable(outputToObservable(this.dismissableLayer.pointerDownOutside));
|
|
220
|
+
this.content = signal(null, ...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
221
|
+
const { getItems } = useCollection();
|
|
222
|
+
this.getItems = getItems;
|
|
223
|
+
this.dismissableLayer.focusOutside.subscribe((e) => e.preventDefault());
|
|
224
|
+
this.dismissableLayer.dismiss.subscribe(() => this.rootContext.onOpenChange(false));
|
|
225
|
+
const focusScope = inject(RdxFocusScope);
|
|
226
|
+
afterNextRender(() => {
|
|
227
|
+
focusScope.unmountAutoFocus.subscribe((event) => {
|
|
228
|
+
if (event.defaultPrevented)
|
|
229
|
+
return;
|
|
230
|
+
this.rootContext.triggerElement()?.focus({ preventScroll: true });
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
});
|
|
233
|
+
focusScope.mountAutoFocus.subscribe((event) => {
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
});
|
|
236
|
+
this.content.set(this.currentElement.nativeElement.firstElementChild);
|
|
237
|
+
});
|
|
238
|
+
effect((onCleanup) => {
|
|
239
|
+
if (!this.content())
|
|
240
|
+
return;
|
|
241
|
+
let pointerMoveDelta = { x: 0, y: 0 };
|
|
242
|
+
const handlePointerMove = (event) => {
|
|
243
|
+
pointerMoveDelta = {
|
|
244
|
+
x: Math.abs(Math.round(event.pageX) - (this.rootContext.triggerPointerDownPosRef()?.x ?? 0)),
|
|
245
|
+
y: Math.abs(Math.round(event.pageY) - (this.rootContext.triggerPointerDownPosRef()?.y ?? 0))
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
const handlePointerUp = (event) => {
|
|
249
|
+
// Prevent options from being untappable on touch devices
|
|
250
|
+
if (event.pointerType === 'touch')
|
|
251
|
+
return;
|
|
252
|
+
// If the pointer hasn't moved by a certain threshold then we prevent selecting item on `pointerup`.
|
|
253
|
+
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
|
|
254
|
+
event.preventDefault();
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
// otherwise, if the event was outside the content, close.
|
|
258
|
+
if (!this.content()?.contains(event.target))
|
|
259
|
+
this.rootContext.onOpenChange(false);
|
|
260
|
+
}
|
|
261
|
+
document.removeEventListener('pointermove', handlePointerMove);
|
|
262
|
+
this.rootContext.triggerPointerDownPosRef.set(null);
|
|
263
|
+
};
|
|
264
|
+
if (this.rootContext.triggerPointerDownPosRef() !== null) {
|
|
265
|
+
document.addEventListener('pointermove', handlePointerMove);
|
|
266
|
+
document.addEventListener('pointerup', handlePointerUp, {
|
|
267
|
+
capture: true,
|
|
268
|
+
once: true
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
onCleanup(() => {
|
|
272
|
+
document.removeEventListener('pointermove', handlePointerMove);
|
|
273
|
+
document.removeEventListener('pointerup', handlePointerUp, {
|
|
274
|
+
capture: true
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
focusSelectedItem() {
|
|
280
|
+
if (this.selectedItem() && this.content()) {
|
|
281
|
+
focusFirst([this.selectedItem(), this.content()]);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
handleKeyDown(event) {
|
|
285
|
+
const keyEvent = event;
|
|
286
|
+
// select should not be navigated using tab key so we prevent it
|
|
287
|
+
if (keyEvent.key === 'Tab')
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
if (['ArrowUp', 'ArrowDown', 'Home', 'End'].includes(keyEvent.key)) {
|
|
290
|
+
const collectionItems = this.getItems().map((i) => i.ref);
|
|
291
|
+
let candidateNodes = [...collectionItems];
|
|
292
|
+
if (['ArrowUp', 'End'].includes(keyEvent.key))
|
|
293
|
+
candidateNodes = candidateNodes.slice().reverse();
|
|
294
|
+
if (['ArrowUp', 'ArrowDown'].includes(keyEvent.key)) {
|
|
295
|
+
const currentElement = event.target;
|
|
296
|
+
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
297
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
298
|
+
}
|
|
299
|
+
setTimeout(() => focusFirst(candidateNodes));
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
304
|
+
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: [
|
|
305
|
+
provideSelectContentContext(context$1),
|
|
306
|
+
provideRdxDismissableLayerConfig(() => {
|
|
307
|
+
return {
|
|
308
|
+
disableOutsidePointerEvents: signal(true)
|
|
309
|
+
};
|
|
310
|
+
})
|
|
311
|
+
], 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 }); }
|
|
312
|
+
}
|
|
313
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectContent, decorators: [{
|
|
314
|
+
type: Directive,
|
|
315
|
+
args: [{
|
|
316
|
+
selector: '[rdxSelectContent]',
|
|
317
|
+
hostDirectives: [RdxFocusScope, RdxDismissableLayer, RdxCollectionProvider],
|
|
318
|
+
providers: [
|
|
319
|
+
provideSelectContentContext(context$1),
|
|
320
|
+
provideRdxDismissableLayerConfig(() => {
|
|
321
|
+
return {
|
|
322
|
+
disableOutsidePointerEvents: signal(true)
|
|
323
|
+
};
|
|
324
|
+
})
|
|
325
|
+
],
|
|
326
|
+
host: {
|
|
327
|
+
role: 'listbox',
|
|
328
|
+
'[attr.data-state]': 'rootContext.open() ? "open" : "closed"',
|
|
329
|
+
'[dir]': 'rootContext.dir()',
|
|
330
|
+
'(keydown)': 'handleKeyDown($event)',
|
|
331
|
+
'[style]': `{
|
|
332
|
+
display: 'flex',
|
|
333
|
+
flexDirection: 'column',
|
|
334
|
+
outline: 'none'
|
|
335
|
+
}`
|
|
336
|
+
}
|
|
337
|
+
}]
|
|
338
|
+
}], ctorParameters: () => [], propDecorators: { escapeKeyDown: [{ type: i0.Output, args: ["escapeKeyDown"] }], pointerDownOutside: [{ type: i0.Output, args: ["pointerDownOutside"] }], positioner: [{
|
|
339
|
+
type: ContentChild,
|
|
340
|
+
args: [RDX_SELECT_POSITIONER_TOKEN, { descendants: true }]
|
|
341
|
+
}] } });
|
|
342
|
+
|
|
343
|
+
class RdxSelectGroup {
|
|
344
|
+
constructor() {
|
|
345
|
+
this.id = inject(_IdGenerator).getId('rdx-select-group-');
|
|
346
|
+
}
|
|
347
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
348
|
+
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 }); }
|
|
349
|
+
}
|
|
350
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectGroup, decorators: [{
|
|
351
|
+
type: Directive,
|
|
352
|
+
args: [{
|
|
353
|
+
selector: '[rdxSelectGroup]',
|
|
354
|
+
exportAs: 'rdxSelectGroup',
|
|
355
|
+
host: {
|
|
356
|
+
role: 'group',
|
|
357
|
+
'[attr.aria-labelledby]': 'id'
|
|
358
|
+
}
|
|
359
|
+
}]
|
|
360
|
+
}] });
|
|
361
|
+
|
|
362
|
+
const context = () => {
|
|
363
|
+
const context = inject(RdxSelectItem);
|
|
364
|
+
return {
|
|
365
|
+
value: context.value,
|
|
366
|
+
disabled: context.disabled,
|
|
367
|
+
isSelected: context.isSelected,
|
|
368
|
+
textId: context.textId,
|
|
369
|
+
onItemTextChange: (node) => {
|
|
370
|
+
context.textValue$.set(((context.textValue$() || node.textContent) ?? '').trim());
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
const [injectSelectItemContext, provideSelectItemContext] = createContext('RdxSelectItemContext');
|
|
375
|
+
class RdxSelectItem {
|
|
376
|
+
constructor() {
|
|
377
|
+
this.rootContext = injectSelectRootContext();
|
|
378
|
+
this.contentContext = injectSelectContentContext();
|
|
379
|
+
this.currentElement = inject(ElementRef);
|
|
380
|
+
this.value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : /* istanbul ignore next */ []));
|
|
381
|
+
this.textValue = input('', ...(ngDevMode ? [{ debugName: "textValue" }] : /* istanbul ignore next */ []));
|
|
382
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
383
|
+
this.textValue$ = linkedSignal(this.textValue, ...(ngDevMode ? [{ debugName: "textValue$" }] : /* istanbul ignore next */ []));
|
|
384
|
+
this.isSelected = computed(() => valueComparator(this.rootContext.value(), this.value(), this.rootContext.by()), ...(ngDevMode ? [{ debugName: "isSelected" }] : /* istanbul ignore next */ []));
|
|
385
|
+
this.isFocused = signal(false, ...(ngDevMode ? [{ debugName: "isFocused" }] : /* istanbul ignore next */ []));
|
|
386
|
+
this.textId = inject(_IdGenerator).getId('rdx-select-item-text-');
|
|
387
|
+
this.afterNextRender = afterNextRender(() => {
|
|
388
|
+
this.contentContext.itemRefCallback(this.currentElement.nativeElement, this.value(), this.disabled());
|
|
389
|
+
});
|
|
390
|
+
this.SELECT_SELECT = 'select.select';
|
|
391
|
+
}
|
|
392
|
+
onPointerDown(event) {
|
|
393
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
394
|
+
}
|
|
395
|
+
onPointerUp(event) {
|
|
396
|
+
if (event.defaultPrevented)
|
|
397
|
+
return;
|
|
398
|
+
const eventDetail = { originalEvent: event, value: this.value() };
|
|
399
|
+
handleAndDispatchCustomEvent(this.SELECT_SELECT, async (event) => {
|
|
400
|
+
if (event.defaultPrevented)
|
|
401
|
+
return;
|
|
402
|
+
this.rootContext.onValueChange(this.value());
|
|
403
|
+
if (!this.rootContext.multiple()) {
|
|
404
|
+
this.rootContext.onOpenChange(false);
|
|
405
|
+
}
|
|
406
|
+
}, eventDetail);
|
|
407
|
+
}
|
|
408
|
+
onPointerLeave(event) {
|
|
409
|
+
if (event.defaultPrevented)
|
|
410
|
+
return;
|
|
411
|
+
if (event.currentTarget === getActiveElement())
|
|
412
|
+
this.contentContext.onItemLeave?.();
|
|
413
|
+
}
|
|
414
|
+
onPointerMove(event) {
|
|
415
|
+
if (event.defaultPrevented)
|
|
416
|
+
return;
|
|
417
|
+
if (this.disabled()) {
|
|
418
|
+
this.contentContext.onItemLeave?.();
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
// even though safari doesn't support this option, it's acceptable
|
|
422
|
+
// as it only means it might scroll a few pixels when using the pointer.
|
|
423
|
+
event.currentTarget?.focus({ preventScroll: true });
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
handleKeyDown(event) {
|
|
427
|
+
const keyEvent = event;
|
|
428
|
+
if (event.defaultPrevented)
|
|
429
|
+
return;
|
|
430
|
+
if (SELECTION_KEYS.includes(keyEvent.key))
|
|
431
|
+
this.handleSelectCustomEvent(keyEvent);
|
|
432
|
+
// prevent page scroll if using the space key to select an item
|
|
433
|
+
if (keyEvent.key === ' ')
|
|
434
|
+
event.preventDefault();
|
|
435
|
+
}
|
|
436
|
+
async handleSelectCustomEvent(event) {
|
|
437
|
+
if (event.defaultPrevented)
|
|
438
|
+
return;
|
|
439
|
+
const eventDetail = { originalEvent: event, value: this.value() };
|
|
440
|
+
handleAndDispatchCustomEvent(this.SELECT_SELECT, async (event) => {
|
|
441
|
+
if (event.defaultPrevented)
|
|
442
|
+
return;
|
|
443
|
+
if (!this.disabled()) {
|
|
444
|
+
this.rootContext.onValueChange(this.value());
|
|
445
|
+
if (!this.rootContext.multiple())
|
|
446
|
+
this.rootContext.onOpenChange(false);
|
|
447
|
+
}
|
|
448
|
+
}, eventDetail);
|
|
449
|
+
}
|
|
450
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItem, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
451
|
+
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 }); }
|
|
452
|
+
}
|
|
453
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItem, decorators: [{
|
|
454
|
+
type: Directive,
|
|
455
|
+
args: [{
|
|
456
|
+
selector: '[rdxSelectItem]',
|
|
457
|
+
providers: [provideSelectItemContext(context)],
|
|
458
|
+
hostDirectives: [
|
|
459
|
+
{
|
|
460
|
+
directive: RdxCollectionItem,
|
|
461
|
+
inputs: ['value']
|
|
462
|
+
}
|
|
463
|
+
],
|
|
464
|
+
host: {
|
|
465
|
+
role: 'option',
|
|
466
|
+
'[attr.tabindex]': 'disabled() ? undefined : -1',
|
|
467
|
+
'[attr.aria-selected]': 'isSelected() ? "checked" : "unchecked"',
|
|
468
|
+
'[attr.data-state]': 'isSelected() ? "checked" : "unchecked"',
|
|
469
|
+
'[attr.data-highlighted]': 'isFocused() ? "" : undefined',
|
|
470
|
+
'(focus)': 'isFocused.set(true)',
|
|
471
|
+
'(blur)': 'isFocused.set(false)',
|
|
472
|
+
'(pointerdown)': 'onPointerDown($event)',
|
|
473
|
+
'(pointerup)': 'onPointerUp($event)',
|
|
474
|
+
'(pointerleave)': 'onPointerLeave($event)',
|
|
475
|
+
'(pointermove)': 'onPointerMove($event)',
|
|
476
|
+
'(keydown)': 'handleKeyDown($event)'
|
|
477
|
+
}
|
|
478
|
+
}]
|
|
479
|
+
}], 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 }] }] } });
|
|
480
|
+
|
|
481
|
+
class RdxSelectItemIndicator {
|
|
482
|
+
constructor() {
|
|
483
|
+
this.itemContext = injectSelectItemContext();
|
|
484
|
+
}
|
|
485
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItemIndicator, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
486
|
+
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 }); }
|
|
487
|
+
}
|
|
488
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItemIndicator, decorators: [{
|
|
489
|
+
type: Directive,
|
|
490
|
+
args: [{
|
|
491
|
+
selector: '[rdxSelectItemIndicator]',
|
|
492
|
+
host: {
|
|
493
|
+
'[attr.aria-hidden]': 'true',
|
|
494
|
+
'[hidden]': '!itemContext.isSelected()'
|
|
495
|
+
}
|
|
496
|
+
}]
|
|
497
|
+
}] });
|
|
498
|
+
|
|
499
|
+
class RdxSelectItemText {
|
|
500
|
+
constructor() {
|
|
501
|
+
this.elementRef = inject((ElementRef));
|
|
502
|
+
this.rootContext = injectSelectRootContext();
|
|
503
|
+
this.contentContext = injectSelectContentContext();
|
|
504
|
+
this.itemContext = injectSelectItemContext();
|
|
505
|
+
this.optionProps = computed(() => {
|
|
506
|
+
return {
|
|
507
|
+
value: this.itemContext.value(),
|
|
508
|
+
disabled: this.itemContext.disabled(),
|
|
509
|
+
textContent: this.elementRef.nativeElement.textContent ?? this.itemContext.value()?.toString() ?? ''
|
|
510
|
+
};
|
|
511
|
+
}, ...(ngDevMode ? [{ debugName: "optionProps" }] : /* istanbul ignore next */ []));
|
|
512
|
+
afterNextRender(() => {
|
|
513
|
+
this.itemContext.onItemTextChange(this.elementRef.nativeElement);
|
|
514
|
+
this.contentContext.itemTextRefCallback(this.elementRef.nativeElement, this.itemContext.value(), this.itemContext.disabled());
|
|
515
|
+
this.rootContext.onOptionAdd(this.optionProps);
|
|
516
|
+
});
|
|
517
|
+
const destroyRef = inject(DestroyRef);
|
|
518
|
+
destroyRef.onDestroy(() => {
|
|
519
|
+
this.rootContext.onOptionRemove(this.optionProps);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItemText, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
523
|
+
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 }); }
|
|
524
|
+
}
|
|
525
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectItemText, decorators: [{
|
|
526
|
+
type: Directive,
|
|
527
|
+
args: [{
|
|
528
|
+
selector: '[rdxSelectItemText]',
|
|
529
|
+
host: {
|
|
530
|
+
'[id]': 'itemContext.textId'
|
|
531
|
+
}
|
|
532
|
+
}]
|
|
533
|
+
}], ctorParameters: () => [] });
|
|
534
|
+
|
|
535
|
+
class RdxSelectLabel {
|
|
536
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectLabel, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
537
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectLabel, isStandalone: true, selector: "[rdxSelectLabel]", ngImport: i0 }); }
|
|
538
|
+
}
|
|
539
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectLabel, decorators: [{
|
|
540
|
+
type: Directive,
|
|
541
|
+
args: [{
|
|
542
|
+
selector: '[rdxSelectLabel]',
|
|
543
|
+
host: {}
|
|
544
|
+
}]
|
|
545
|
+
}] });
|
|
546
|
+
|
|
547
|
+
class RdxSelectPopperPositionContent {
|
|
548
|
+
constructor() {
|
|
549
|
+
this.rootContext = injectSelectRootContext();
|
|
550
|
+
}
|
|
551
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPopperPositionContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
552
|
+
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 }); }
|
|
553
|
+
}
|
|
554
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPopperPositionContent, decorators: [{
|
|
555
|
+
type: Directive,
|
|
556
|
+
args: [{
|
|
557
|
+
selector: '[rdxSelectPopperPositionContent]',
|
|
558
|
+
hostDirectives: [RdxPopperContent],
|
|
559
|
+
host: {
|
|
560
|
+
role: 'listbox',
|
|
561
|
+
'[id]': 'rootContext.contentId'
|
|
562
|
+
}
|
|
563
|
+
}]
|
|
564
|
+
}] });
|
|
565
|
+
|
|
566
|
+
class RdxSelectPopperPositionWrapper {
|
|
567
|
+
constructor() {
|
|
568
|
+
/**
|
|
569
|
+
* The preferred side of the anchor to render against when open.
|
|
570
|
+
* Will be reversed when collisions occur and avoidCollisions is enabled.
|
|
571
|
+
*/
|
|
572
|
+
this.side = input('bottom', ...(ngDevMode ? [{ debugName: "side" }] : /* istanbul ignore next */ []));
|
|
573
|
+
/**
|
|
574
|
+
* The distance in pixels from the anchor.
|
|
575
|
+
*/
|
|
576
|
+
this.sideOffset = input(0, { ...(ngDevMode ? { debugName: "sideOffset" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
577
|
+
/**
|
|
578
|
+
* The preferred alignment against the anchor. May change when collisions occur.
|
|
579
|
+
*/
|
|
580
|
+
this.align = input('start', ...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
|
|
581
|
+
/**
|
|
582
|
+
* An offset in pixels from the `start` or `end` alignment options.
|
|
583
|
+
*/
|
|
584
|
+
this.alignOffset = input(0, { ...(ngDevMode ? { debugName: "alignOffset" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
585
|
+
/**
|
|
586
|
+
* The padding between the arrow and the edges of the content.
|
|
587
|
+
* If your content has border-radius, this will prevent it from overflowing the corners.
|
|
588
|
+
*/
|
|
589
|
+
this.arrowPadding = input(0, { ...(ngDevMode ? { debugName: "arrowPadding" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
590
|
+
/**
|
|
591
|
+
* When `true`, overrides the `side` and `align` preferences to prevent collisions with boundary edges.
|
|
592
|
+
*/
|
|
593
|
+
this.avoidCollisions = input(true, { ...(ngDevMode ? { debugName: "avoidCollisions" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
594
|
+
/**
|
|
595
|
+
* The element used as the collision boundary.
|
|
596
|
+
* By default this is the viewport, though you can provide additional element(s) to be included in this check.
|
|
597
|
+
*/
|
|
598
|
+
this.collisionBoundary = input(...(ngDevMode ? [undefined, { debugName: "collisionBoundary" }] : /* istanbul ignore next */ []));
|
|
599
|
+
/**
|
|
600
|
+
* The distance in pixels from the boundary edges where collision detection should occur.
|
|
601
|
+
* Accepts a number (same for all sides), or a partial padding object, for example: `{ top: 20, left: 20 }`.
|
|
602
|
+
*/
|
|
603
|
+
this.collisionPadding = input(0, ...(ngDevMode ? [{ debugName: "collisionPadding" }] : /* istanbul ignore next */ []));
|
|
604
|
+
/**
|
|
605
|
+
* The sticky behavior on the `align` axis.
|
|
606
|
+
* - `partial` will keep the content in the boundary as long as the trigger is at least partially in the boundary
|
|
607
|
+
* - `always` will keep the content in the boundary regardless.
|
|
608
|
+
*/
|
|
609
|
+
this.sticky = input('partial', ...(ngDevMode ? [{ debugName: "sticky" }] : /* istanbul ignore next */ []));
|
|
610
|
+
/**
|
|
611
|
+
* Whether to hide the content when the trigger becomes fully occluded.
|
|
612
|
+
*/
|
|
613
|
+
this.hideWhenDetached = input(false, { ...(ngDevMode ? { debugName: "hideWhenDetached" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
614
|
+
/**
|
|
615
|
+
* Whether to update the position of the floating element on every animation frame if required.
|
|
616
|
+
*/
|
|
617
|
+
this.updatePositionStrategy = input('always', ...(ngDevMode ? [{ debugName: "updatePositionStrategy" }] : /* istanbul ignore next */ []));
|
|
618
|
+
/**
|
|
619
|
+
* Emits when the element is placed.
|
|
620
|
+
*/
|
|
621
|
+
this.placed = outputFromObservable(outputToObservable(inject(RdxPopperContentWrapper).placed));
|
|
622
|
+
}
|
|
623
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPopperPositionWrapper, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
624
|
+
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: [
|
|
625
|
+
{
|
|
626
|
+
provide: RDX_SELECT_POSITIONER_TOKEN,
|
|
627
|
+
useExisting: forwardRef(() => RdxSelectPopperPositionWrapper)
|
|
628
|
+
}
|
|
629
|
+
], 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 }); }
|
|
630
|
+
}
|
|
631
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPopperPositionWrapper, decorators: [{
|
|
632
|
+
type: Directive,
|
|
633
|
+
args: [{
|
|
634
|
+
selector: '[rdxSelectPopperPositionWrapper]',
|
|
635
|
+
providers: [
|
|
636
|
+
{
|
|
637
|
+
provide: RDX_SELECT_POSITIONER_TOKEN,
|
|
638
|
+
useExisting: forwardRef(() => RdxSelectPopperPositionWrapper)
|
|
639
|
+
}
|
|
640
|
+
],
|
|
641
|
+
hostDirectives: [
|
|
642
|
+
{
|
|
643
|
+
directive: RdxPopperContentWrapper,
|
|
644
|
+
inputs: [
|
|
645
|
+
'side',
|
|
646
|
+
'sideOffset',
|
|
647
|
+
'align',
|
|
648
|
+
'alignOffset',
|
|
649
|
+
'arrowPadding',
|
|
650
|
+
'avoidCollisions',
|
|
651
|
+
'collisionBoundary',
|
|
652
|
+
'collisionPadding',
|
|
653
|
+
'sticky',
|
|
654
|
+
'hideWhenDetached',
|
|
655
|
+
'updatePositionStrategy'
|
|
656
|
+
]
|
|
657
|
+
}
|
|
658
|
+
],
|
|
659
|
+
host: {
|
|
660
|
+
// re-namespace exposed content custom properties
|
|
661
|
+
'[style]': `{
|
|
662
|
+
'boxSizing': 'border-box',
|
|
663
|
+
'--radix-tooltip-content-transform-origin': 'var(--radix-popper-transform-origin)',
|
|
664
|
+
'--radix-tooltip-content-available-width': 'var(--radix-popper-available-width)',
|
|
665
|
+
'--radix-tooltip-content-available-height': 'var(--radix-popper-available-height)',
|
|
666
|
+
'--radix-tooltip-trigger-width': 'var(--radix-popper-anchor-width)',
|
|
667
|
+
'--radix-tooltip-trigger-height': 'var(--radix-popper-anchor-height)',
|
|
668
|
+
}`
|
|
669
|
+
}
|
|
670
|
+
}]
|
|
671
|
+
}], 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"] }] } });
|
|
672
|
+
|
|
673
|
+
class RdxSelectPortal {
|
|
674
|
+
constructor() {
|
|
675
|
+
this.container = input.required(...(ngDevMode ? [{ debugName: "container" }] : /* istanbul ignore next */ []));
|
|
676
|
+
}
|
|
677
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPortal, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
678
|
+
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: true, transformFunction: null } }, hostDirectives: [{ directive: i1$2.RdxPortal, inputs: ["container", "container"] }], ngImport: i0 }); }
|
|
679
|
+
}
|
|
680
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPortal, decorators: [{
|
|
681
|
+
type: Directive,
|
|
682
|
+
args: [{
|
|
683
|
+
selector: '[rdxSelectPortal]',
|
|
684
|
+
hostDirectives: [
|
|
685
|
+
{
|
|
686
|
+
directive: RdxPortal,
|
|
687
|
+
inputs: ['container']
|
|
688
|
+
}
|
|
689
|
+
]
|
|
690
|
+
}]
|
|
691
|
+
}], propDecorators: { container: [{ type: i0.Input, args: [{ isSignal: true, alias: "container", required: true }] }] } });
|
|
692
|
+
|
|
693
|
+
class RdxSelectPortalPresence {
|
|
694
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPortalPresence, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
695
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxSelectPortalPresence, isStandalone: true, selector: "ng-template[rdxSelectPortalPresence]", providers: [
|
|
696
|
+
provideRdxPresenceContext(() => {
|
|
697
|
+
const context = injectSelectRootContext();
|
|
698
|
+
return { present: context.open };
|
|
699
|
+
})
|
|
700
|
+
], hostDirectives: [{ directive: i1$3.RdxPresenceDirective }], ngImport: i0 }); }
|
|
701
|
+
}
|
|
702
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectPortalPresence, decorators: [{
|
|
703
|
+
type: Directive,
|
|
704
|
+
args: [{
|
|
705
|
+
selector: 'ng-template[rdxSelectPortalPresence]',
|
|
706
|
+
hostDirectives: [RdxPresenceDirective],
|
|
707
|
+
providers: [
|
|
708
|
+
provideRdxPresenceContext(() => {
|
|
709
|
+
const context = injectSelectRootContext();
|
|
710
|
+
return { present: context.open };
|
|
711
|
+
})
|
|
712
|
+
]
|
|
713
|
+
}]
|
|
714
|
+
}] });
|
|
715
|
+
|
|
716
|
+
class RdxSelectTrigger {
|
|
717
|
+
constructor() {
|
|
718
|
+
this.rootContext = injectSelectRootContext();
|
|
719
|
+
this.elementRef = inject(ElementRef);
|
|
720
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
721
|
+
this.isDisabled = computed(() => this.rootContext.disabled() || this.disabled(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
|
|
722
|
+
afterNextRender(() => {
|
|
723
|
+
this.rootContext.onTriggerChange(this.elementRef);
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
handleOpen() {
|
|
727
|
+
if (!this.isDisabled()) {
|
|
728
|
+
this.rootContext.onOpenChange(true);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
handlePointerOpen(event) {
|
|
732
|
+
const pointerEvent = event;
|
|
733
|
+
this.handleOpen();
|
|
734
|
+
this.rootContext.triggerPointerDownPosRef.set({
|
|
735
|
+
x: Math.round(pointerEvent.pageX),
|
|
736
|
+
y: Math.round(pointerEvent.pageY)
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
onClickHandler(event) {
|
|
740
|
+
// Whilst browsers generally have no issue focusing the trigger when clicking
|
|
741
|
+
// on a label, Safari seems to struggle with the fact that there's no `onClick`.
|
|
742
|
+
// We force `focus` in this case. Note: this doesn't create any other side-effect
|
|
743
|
+
// because we are preventing default in `onPointerDown` so effectively
|
|
744
|
+
// this only runs for a label 'click'
|
|
745
|
+
event?.currentTarget?.focus();
|
|
746
|
+
}
|
|
747
|
+
onPointerDown(event) {
|
|
748
|
+
const pointerEvent = event;
|
|
749
|
+
if (pointerEvent.pointerType === 'touch')
|
|
750
|
+
return event.preventDefault();
|
|
751
|
+
// prevent implicit pointer capture
|
|
752
|
+
// https://www.w3.org/TR/pointerevents3/#implicit-pointer-capture
|
|
753
|
+
const target = event.target;
|
|
754
|
+
if (target.hasPointerCapture(pointerEvent.pointerId)) {
|
|
755
|
+
target.releasePointerCapture(pointerEvent.pointerId);
|
|
756
|
+
}
|
|
757
|
+
// only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
|
|
758
|
+
// but not when the control key is pressed (avoiding MacOS right click)
|
|
759
|
+
if (pointerEvent.button === 0 && pointerEvent.ctrlKey === false) {
|
|
760
|
+
this.handlePointerOpen(event);
|
|
761
|
+
// prevent trigger from stealing focus from the active item after opening.
|
|
762
|
+
event.preventDefault();
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
onPointerUp(event) {
|
|
766
|
+
const pointerEvent = event;
|
|
767
|
+
event.preventDefault();
|
|
768
|
+
// Only open on pointer up when using touch devices
|
|
769
|
+
if (pointerEvent.pointerType === 'touch')
|
|
770
|
+
this.handlePointerOpen(event);
|
|
771
|
+
}
|
|
772
|
+
onKeydown(event) {
|
|
773
|
+
const keyEvent = event;
|
|
774
|
+
if (OPEN_KEYS.includes(keyEvent.key)) {
|
|
775
|
+
this.handleOpen();
|
|
776
|
+
event.preventDefault();
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
780
|
+
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 }); }
|
|
781
|
+
}
|
|
782
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectTrigger, decorators: [{
|
|
783
|
+
type: Directive,
|
|
784
|
+
args: [{
|
|
785
|
+
selector: 'button[rdxSelectTrigger]',
|
|
786
|
+
hostDirectives: [RdxPopperAnchor],
|
|
787
|
+
host: {
|
|
788
|
+
role: 'combobox',
|
|
789
|
+
type: 'button',
|
|
790
|
+
'[attr.disabled]': 'isDisabled() ? "" : undefined',
|
|
791
|
+
'[dir]': 'rootContext.dir()',
|
|
792
|
+
'[attr.data-state]': 'rootContext.open() ? "open" : "closed"',
|
|
793
|
+
'[attr.data-disabled]': 'isDisabled() ? "" : undefined',
|
|
794
|
+
'(click)': 'onClickHandler($event)',
|
|
795
|
+
'(pointerdown)': 'onPointerDown($event)',
|
|
796
|
+
'(pointerup)': 'onPointerUp($event)',
|
|
797
|
+
'(keydown)': 'onKeydown($event)'
|
|
798
|
+
}
|
|
799
|
+
}]
|
|
800
|
+
}], ctorParameters: () => [], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
801
|
+
|
|
802
|
+
class RdxSelectValue {
|
|
803
|
+
constructor() {
|
|
804
|
+
this.rootContext = injectSelectRootContext();
|
|
805
|
+
this.elementRef = inject(ElementRef);
|
|
806
|
+
this.placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
807
|
+
this.slotText = computed(() => {
|
|
808
|
+
return this.selectedLabel().length ? this.selectedLabel().join(', ') : this.placeholder();
|
|
809
|
+
}, ...(ngDevMode ? [{ debugName: "slotText" }] : /* istanbul ignore next */ []));
|
|
810
|
+
this.selectedLabel = computed(() => {
|
|
811
|
+
// eslint-disable-next-line no-useless-assignment
|
|
812
|
+
let list = [];
|
|
813
|
+
const options = Array.from(this.rootContext.optionsSet());
|
|
814
|
+
const getOption = (value) => options.find((option) => valueComparator(value, option.value, this.rootContext.by()));
|
|
815
|
+
if (Array.isArray(this.rootContext.value())) {
|
|
816
|
+
list = Array(this.rootContext.value()).map((value) => getOption(value)?.textContent ?? '');
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
list = [getOption(this.rootContext.value())?.textContent ?? ''];
|
|
820
|
+
}
|
|
821
|
+
return list.filter(Boolean);
|
|
822
|
+
}, ...(ngDevMode ? [{ debugName: "selectedLabel" }] : /* istanbul ignore next */ []));
|
|
823
|
+
afterNextRender(() => {
|
|
824
|
+
this.rootContext.valueElement.set(this.elementRef.nativeElement);
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectValue, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
828
|
+
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 }); }
|
|
829
|
+
}
|
|
830
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectValue, decorators: [{
|
|
831
|
+
type: Directive,
|
|
832
|
+
args: [{
|
|
833
|
+
selector: 'span[rdxSelectValue]',
|
|
834
|
+
exportAs: 'rdxSelectedValue',
|
|
835
|
+
host: {
|
|
836
|
+
'[style.pointer-events]': '"none"'
|
|
837
|
+
}
|
|
838
|
+
}]
|
|
839
|
+
}], ctorParameters: () => [], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }] } });
|
|
840
|
+
|
|
841
|
+
class RdxSelectViewport {
|
|
842
|
+
constructor() {
|
|
843
|
+
this.contentContext = injectSelectContentContext();
|
|
844
|
+
this.elementRef = inject((ElementRef));
|
|
845
|
+
this.prevScrollTopRef = signal(0, ...(ngDevMode ? [{ debugName: "prevScrollTopRef" }] : /* istanbul ignore next */ []));
|
|
846
|
+
afterNextRender(() => {
|
|
847
|
+
this.contentContext?.onViewportChange(this.elementRef.nativeElement);
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
handleScroll(event) {
|
|
851
|
+
const viewport = event.currentTarget;
|
|
852
|
+
this.prevScrollTopRef.set(viewport.scrollTop);
|
|
853
|
+
}
|
|
854
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectViewport, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
855
|
+
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 }); }
|
|
856
|
+
}
|
|
857
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSelectViewport, decorators: [{
|
|
858
|
+
type: Directive,
|
|
859
|
+
args: [{
|
|
860
|
+
selector: '[rdxSelectViewport]',
|
|
861
|
+
host: {
|
|
862
|
+
role: 'presentation',
|
|
863
|
+
'[attr.data-rdx-select-viewport]': '""',
|
|
864
|
+
'[style]': `{
|
|
865
|
+
position: 'relative',
|
|
866
|
+
flex: 1,
|
|
867
|
+
overflow: 'hidden auto',
|
|
868
|
+
scrollbarWidth: 'none'
|
|
869
|
+
}`,
|
|
870
|
+
'(scroll)': 'handleScroll($event)'
|
|
871
|
+
}
|
|
872
|
+
}]
|
|
873
|
+
}], ctorParameters: () => [] });
|
|
874
|
+
|
|
875
|
+
const _importsSelect = [
|
|
876
|
+
RdxSelectRoot,
|
|
877
|
+
RdxSelectPortal,
|
|
878
|
+
RdxSelectTrigger,
|
|
879
|
+
RdxSelectValue,
|
|
880
|
+
RdxSelectContent,
|
|
881
|
+
RdxSelectViewport,
|
|
882
|
+
RdxSelectItemIndicator,
|
|
883
|
+
RdxSelectItem,
|
|
884
|
+
RdxSelectItemText,
|
|
885
|
+
RdxSelectLabel,
|
|
886
|
+
RdxSelectGroup,
|
|
887
|
+
RdxSelectPopperPositionContent,
|
|
888
|
+
RdxSelectPopperPositionWrapper,
|
|
889
|
+
RdxSelectPortalPresence
|
|
890
|
+
];
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Generated bundle index. Do not edit.
|
|
894
|
+
*/
|
|
895
|
+
|
|
896
|
+
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 };
|
|
897
|
+
//# sourceMappingURL=radix-ng-primitives-select2.mjs.map
|