@radix-ng/primitives 0.17.0 → 0.18.1
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/compodoc/documentation.json +5304 -1427
- package/esm2022/select/src/select-trigger.directive.mjs +3 -3
- package/esm2022/select/src/select-value.directive.mjs +4 -9
- package/esm2022/select/src/select.component.mjs +6 -5
- package/esm2022/slider/index.mjs +28 -0
- package/esm2022/slider/radix-ng-primitives-slider.mjs +5 -0
- package/esm2022/slider/src/slider-horizontal.component.mjs +117 -0
- package/esm2022/slider/src/slider-impl.directive.mjs +89 -0
- package/esm2022/slider/src/slider-orientation-context.service.mjs +28 -0
- package/esm2022/slider/src/slider-range.component.mjs +41 -0
- package/esm2022/slider/src/slider-root.component.mjs +207 -0
- package/esm2022/slider/src/slider-thumb-impl.directive.mjs +106 -0
- package/esm2022/slider/src/slider-thumb.component.mjs +22 -0
- package/esm2022/slider/src/slider-track.component.mjs +27 -0
- package/esm2022/slider/src/slider-vertical.component.mjs +117 -0
- package/esm2022/slider/src/utils.mjs +94 -0
- package/esm2022/tooltip/index.mjs +41 -0
- package/esm2022/tooltip/radix-ng-primitives-tooltip.mjs +5 -0
- package/esm2022/tooltip/src/get-content-position.mjs +31 -0
- package/esm2022/tooltip/src/tooltip-arrow.directive.mjs +92 -0
- package/esm2022/tooltip/src/tooltip-arrow.token.mjs +3 -0
- package/esm2022/tooltip/src/tooltip-content-attributes.directive.mjs +24 -0
- package/esm2022/tooltip/src/tooltip-content.directive.mjs +48 -0
- package/esm2022/tooltip/src/tooltip-content.token.mjs +3 -0
- package/esm2022/tooltip/src/tooltip-root.directive.mjs +288 -0
- package/esm2022/tooltip/src/tooltip-trigger.directive.mjs +70 -0
- package/esm2022/tooltip/src/tooltip.config.mjs +18 -0
- package/esm2022/tooltip/src/tooltip.constants.mjs +84 -0
- package/esm2022/tooltip/src/tooltip.types.mjs +14 -0
- package/fesm2022/radix-ng-primitives-select.mjs +10 -14
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-slider.mjs +833 -0
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-tooltip.mjs +684 -0
- package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -0
- package/package.json +13 -1
- package/slider/README.md +1 -0
- package/slider/index.d.ts +18 -0
- package/slider/src/slider-horizontal.component.d.ts +29 -0
- package/slider/src/slider-impl.directive.d.ts +18 -0
- package/slider/src/slider-orientation-context.service.d.ts +14 -0
- package/slider/src/slider-range.component.d.ts +13 -0
- package/slider/src/slider-root.component.d.ts +47 -0
- package/slider/src/slider-thumb-impl.directive.d.ts +27 -0
- package/slider/src/slider-thumb.component.d.ts +6 -0
- package/slider/src/slider-track.component.d.ts +7 -0
- package/slider/src/slider-vertical.component.d.ts +29 -0
- package/slider/src/utils.d.ts +52 -0
- package/tooltip/README.md +1 -0
- package/tooltip/index.d.ts +17 -0
- package/tooltip/src/get-content-position.d.ts +3 -0
- package/tooltip/src/tooltip-arrow.directive.d.ts +25 -0
- package/tooltip/src/tooltip-arrow.token.d.ts +3 -0
- package/tooltip/src/tooltip-content-attributes.directive.d.ts +8 -0
- package/tooltip/src/tooltip-content.directive.d.ts +36 -0
- package/tooltip/src/tooltip-content.token.d.ts +3 -0
- package/tooltip/src/tooltip-root.directive.d.ts +103 -0
- package/tooltip/src/tooltip-trigger.directive.d.ts +26 -0
- package/tooltip/src/tooltip.config.d.ts +6 -0
- package/tooltip/src/tooltip.constants.d.ts +9 -0
- package/tooltip/src/tooltip.types.d.ts +18 -0
@@ -0,0 +1,833 @@
|
|
1
|
+
import * as i0 from '@angular/core';
|
2
|
+
import { inject, EventEmitter, Directive, Output, input, booleanAttribute, viewChild, signal, Component, Input, Injectable, numberAttribute, model, computed, ElementRef, PLATFORM_ID, NgModule } from '@angular/core';
|
3
|
+
import { NgIf, NgTemplateOutlet, isPlatformBrowser } from '@angular/common';
|
4
|
+
|
5
|
+
// https://github.com/tmcw-up-for-adoption/simple-linear-scale/blob/master/index.js
|
6
|
+
function linearScale(input, output) {
|
7
|
+
return (value) => {
|
8
|
+
if (input[0] === input[1] || output[0] === output[1])
|
9
|
+
return output[0];
|
10
|
+
const ratio = (output[1] - output[0]) / (input[1] - input[0]);
|
11
|
+
return output[0] + ratio * (value - input[0]);
|
12
|
+
};
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* Verifies the minimum steps between all values is greater than or equal
|
16
|
+
* to the expected minimum steps.
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
* // returns false
|
20
|
+
* hasMinStepsBetweenValues([1,2,3], 2);
|
21
|
+
*
|
22
|
+
* @example
|
23
|
+
* // returns true
|
24
|
+
* hasMinStepsBetweenValues([1,2,3], 1);
|
25
|
+
*/
|
26
|
+
function hasMinStepsBetweenValues(values, minStepsBetweenValues) {
|
27
|
+
if (minStepsBetweenValues > 0) {
|
28
|
+
const stepsBetweenValues = getStepsBetweenValues(values);
|
29
|
+
const actualMinStepsBetweenValues = Math.min(...stepsBetweenValues);
|
30
|
+
return actualMinStepsBetweenValues >= minStepsBetweenValues;
|
31
|
+
}
|
32
|
+
return true;
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
* Given a `values` array and a `nextValue`, determine which value in
|
36
|
+
* the array is closest to `nextValue` and return its index.
|
37
|
+
*
|
38
|
+
* @example
|
39
|
+
* // returns 1
|
40
|
+
* getClosestValueIndex([10, 30], 25);
|
41
|
+
*/
|
42
|
+
function getClosestValueIndex(values, nextValue) {
|
43
|
+
if (values.length === 1)
|
44
|
+
return 0;
|
45
|
+
const distances = values.map((value) => Math.abs(value - nextValue));
|
46
|
+
const closestDistance = Math.min(...distances);
|
47
|
+
return distances.indexOf(closestDistance);
|
48
|
+
}
|
49
|
+
/**
|
50
|
+
* Gets an array of steps between each value.
|
51
|
+
*
|
52
|
+
* @example
|
53
|
+
* // returns [1, 9]
|
54
|
+
* getStepsBetweenValues([10, 11, 20]);
|
55
|
+
*/
|
56
|
+
function getStepsBetweenValues(values) {
|
57
|
+
return values.slice(0, -1).map((value, index) => values[index + 1] - value);
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* Offsets the thumb centre point while sliding to ensure it remains
|
61
|
+
* within the bounds of the slider when reaching the edges
|
62
|
+
*/
|
63
|
+
function getThumbInBoundsOffset(width, left, direction) {
|
64
|
+
const halfWidth = width / 2;
|
65
|
+
const halfPercent = 50;
|
66
|
+
const offset = linearScale([0, halfPercent], [0, halfWidth]);
|
67
|
+
return (halfWidth - offset(left) * direction) * direction;
|
68
|
+
}
|
69
|
+
function convertValueToPercentage(value, min, max) {
|
70
|
+
const maxSteps = max - min;
|
71
|
+
const percentPerStep = 100 / maxSteps;
|
72
|
+
const percentage = percentPerStep * (value - min);
|
73
|
+
return clamp(percentage, 0, 100);
|
74
|
+
}
|
75
|
+
function getDecimalCount(value) {
|
76
|
+
return (String(value).split('.')[1] || '').length;
|
77
|
+
}
|
78
|
+
function roundValue(value, decimalCount) {
|
79
|
+
const rounder = 10 ** decimalCount;
|
80
|
+
return Math.round(value * rounder) / rounder;
|
81
|
+
}
|
82
|
+
function getNextSortedValues(prevValues = [], nextValue, atIndex) {
|
83
|
+
const nextValues = [...prevValues];
|
84
|
+
nextValues[atIndex] = nextValue;
|
85
|
+
return nextValues.sort((a, b) => a - b);
|
86
|
+
}
|
87
|
+
const PAGE_KEYS = ['PageUp', 'PageDown'];
|
88
|
+
const ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
89
|
+
const BACK_KEYS = {
|
90
|
+
'from-left': ['Home', 'PageDown', 'ArrowDown', 'ArrowLeft'],
|
91
|
+
'from-right': ['Home', 'PageDown', 'ArrowDown', 'ArrowRight'],
|
92
|
+
'from-bottom': ['Home', 'PageDown', 'ArrowDown', 'ArrowLeft'],
|
93
|
+
'from-top': ['Home', 'PageDown', 'ArrowUp', 'ArrowLeft']
|
94
|
+
};
|
95
|
+
function clamp(value, min = Number.NEGATIVE_INFINITY, max = Number.POSITIVE_INFINITY) {
|
96
|
+
return Math.min(Math.max(value, min), max);
|
97
|
+
}
|
98
|
+
|
99
|
+
class RdxSliderImplDirective {
|
100
|
+
constructor() {
|
101
|
+
this.rootContext = inject(RdxSliderRootComponent);
|
102
|
+
this.slideStart = new EventEmitter();
|
103
|
+
this.slideMove = new EventEmitter();
|
104
|
+
this.slideEnd = new EventEmitter();
|
105
|
+
this.homeKeyDown = new EventEmitter();
|
106
|
+
this.endKeyDown = new EventEmitter();
|
107
|
+
this.stepKeyDown = new EventEmitter();
|
108
|
+
}
|
109
|
+
onKeyDown(event) {
|
110
|
+
if (event.key === 'Home') {
|
111
|
+
this.homeKeyDown.emit(event);
|
112
|
+
// Prevent scrolling to page start
|
113
|
+
event.preventDefault();
|
114
|
+
}
|
115
|
+
else if (event.key === 'End') {
|
116
|
+
this.endKeyDown.emit(event);
|
117
|
+
// Prevent scrolling to page end
|
118
|
+
event.preventDefault();
|
119
|
+
}
|
120
|
+
else if (PAGE_KEYS.concat(ARROW_KEYS).includes(event.key)) {
|
121
|
+
this.stepKeyDown.emit(event);
|
122
|
+
// Prevent scrolling for directional key presses
|
123
|
+
event.preventDefault();
|
124
|
+
}
|
125
|
+
}
|
126
|
+
onPointerDown(event) {
|
127
|
+
const target = event.target;
|
128
|
+
target.setPointerCapture(event.pointerId);
|
129
|
+
// Prevent browser focus behaviour because we focus a thumb manually when values change.
|
130
|
+
event.preventDefault();
|
131
|
+
// Touch devices have a delay before focusing so won't focus if touch immediately moves
|
132
|
+
// away from target (sliding). We want thumb to focus regardless.
|
133
|
+
if (this.rootContext.thumbElements.includes(target)) {
|
134
|
+
target.focus();
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
this.slideStart.emit(event);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
onPointerMove(event) {
|
141
|
+
const target = event.target;
|
142
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
143
|
+
this.slideMove.emit(event);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
onPointerUp(event) {
|
147
|
+
const target = event.target;
|
148
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
149
|
+
target.releasePointerCapture(event.pointerId);
|
150
|
+
this.slideEnd.emit(event);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderImplDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
154
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxSliderImplDirective, isStandalone: true, selector: "[rdxSliderImpl]", outputs: { slideStart: "slideStart", slideMove: "slideMove", slideEnd: "slideEnd", homeKeyDown: "homeKeyDown", endKeyDown: "endKeyDown", stepKeyDown: "stepKeyDown" }, host: { attributes: { "role": "slider", "tabindex": "0" }, listeners: { "keydown": "onKeyDown($event)", "pointerdown": "onPointerDown($event)", "pointermove": "onPointerMove($event)", "pointerup": "onPointerUp($event)" } }, ngImport: i0 }); }
|
155
|
+
}
|
156
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderImplDirective, decorators: [{
|
157
|
+
type: Directive,
|
158
|
+
args: [{
|
159
|
+
selector: '[rdxSliderImpl]',
|
160
|
+
standalone: true,
|
161
|
+
host: {
|
162
|
+
role: 'slider',
|
163
|
+
tabindex: '0',
|
164
|
+
'(keydown)': 'onKeyDown($event)',
|
165
|
+
'(pointerdown)': 'onPointerDown($event)',
|
166
|
+
'(pointermove)': 'onPointerMove($event)',
|
167
|
+
'(pointerup)': 'onPointerUp($event)'
|
168
|
+
}
|
169
|
+
}]
|
170
|
+
}], propDecorators: { slideStart: [{
|
171
|
+
type: Output
|
172
|
+
}], slideMove: [{
|
173
|
+
type: Output
|
174
|
+
}], slideEnd: [{
|
175
|
+
type: Output
|
176
|
+
}], homeKeyDown: [{
|
177
|
+
type: Output
|
178
|
+
}], endKeyDown: [{
|
179
|
+
type: Output
|
180
|
+
}], stepKeyDown: [{
|
181
|
+
type: Output
|
182
|
+
}] } });
|
183
|
+
|
184
|
+
class RdxSliderHorizontalComponent {
|
185
|
+
constructor() {
|
186
|
+
this.rootContext = inject(RdxSliderRootComponent);
|
187
|
+
this.dir = 'ltr';
|
188
|
+
this.inverted = input(false, { transform: booleanAttribute });
|
189
|
+
this.min = 0;
|
190
|
+
this.max = 100;
|
191
|
+
this.className = '';
|
192
|
+
this.slideStart = new EventEmitter();
|
193
|
+
this.slideMove = new EventEmitter();
|
194
|
+
this.slideEnd = new EventEmitter();
|
195
|
+
this.stepKeyDown = new EventEmitter();
|
196
|
+
this.endKeyDown = new EventEmitter();
|
197
|
+
this.homeKeyDown = new EventEmitter();
|
198
|
+
this.sliderElement = viewChild('sliderElement');
|
199
|
+
this.rect = signal(undefined);
|
200
|
+
}
|
201
|
+
onSlideStart(event) {
|
202
|
+
const value = this.getValueFromPointer(event.clientX);
|
203
|
+
this.slideStart.emit(value);
|
204
|
+
}
|
205
|
+
onSlideMove(event) {
|
206
|
+
const value = this.getValueFromPointer(event.clientX);
|
207
|
+
this.slideMove.emit(value);
|
208
|
+
}
|
209
|
+
onSlideEnd() {
|
210
|
+
this.rect.set(undefined);
|
211
|
+
this.slideEnd.emit();
|
212
|
+
}
|
213
|
+
onStepKeyDown(event) {
|
214
|
+
const slideDirection = this.rootContext.isSlidingFromLeft() ? 'from-left' : 'from-right';
|
215
|
+
const isBackKey = BACK_KEYS[slideDirection].includes(event.key);
|
216
|
+
this.stepKeyDown.emit({ event, direction: isBackKey ? -1 : 1 });
|
217
|
+
}
|
218
|
+
getValueFromPointer(pointerPosition) {
|
219
|
+
this.rect.set(this.sliderElement()?.nativeElement.getBoundingClientRect());
|
220
|
+
const rect = this.rect();
|
221
|
+
if (!rect)
|
222
|
+
return 0;
|
223
|
+
const input = [0, rect.width];
|
224
|
+
const output = this.rootContext.isSlidingFromLeft()
|
225
|
+
? [this.min, this.max]
|
226
|
+
: [this.max, this.min];
|
227
|
+
const value = linearScale(input, output);
|
228
|
+
this.rect.set(rect);
|
229
|
+
return value(pointerPosition - rect.left);
|
230
|
+
}
|
231
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderHorizontalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
232
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.2.11", type: RdxSliderHorizontalComponent, isStandalone: true, selector: "rdx-slider-horizontal", inputs: { dir: { classPropertyName: "dir", publicName: "dir", isSignal: false, isRequired: false, transformFunction: null }, inverted: { classPropertyName: "inverted", publicName: "inverted", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: false, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: false, isRequired: false, transformFunction: null }, className: { classPropertyName: "className", publicName: "className", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { slideStart: "slideStart", slideMove: "slideMove", slideEnd: "slideEnd", stepKeyDown: "stepKeyDown", endKeyDown: "endKeyDown", homeKeyDown: "homeKeyDown" }, viewQueries: [{ propertyName: "sliderElement", first: true, predicate: ["sliderElement"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
233
|
+
<span
|
234
|
+
#sliderElement
|
235
|
+
[class]="className"
|
236
|
+
[attr.data-orientation]="'horizontal'"
|
237
|
+
[style]="{ '--rdx-slider-thumb-transform': 'translateX(-50%)' }"
|
238
|
+
(slideStart)="onSlideStart($event)"
|
239
|
+
(slideMove)="onSlideMove($event)"
|
240
|
+
(slideEnd)="onSlideEnd()"
|
241
|
+
(stepKeyDown)="onStepKeyDown($event)"
|
242
|
+
(endKeyDown)="endKeyDown.emit($event)"
|
243
|
+
(homeKeyDown)="homeKeyDown.emit($event)"
|
244
|
+
rdxSliderImpl
|
245
|
+
>
|
246
|
+
<ng-content />
|
247
|
+
</span>
|
248
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: RdxSliderImplDirective, selector: "[rdxSliderImpl]", outputs: ["slideStart", "slideMove", "slideEnd", "homeKeyDown", "endKeyDown", "stepKeyDown"] }] }); }
|
249
|
+
}
|
250
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderHorizontalComponent, decorators: [{
|
251
|
+
type: Component,
|
252
|
+
args: [{
|
253
|
+
selector: 'rdx-slider-horizontal',
|
254
|
+
standalone: true,
|
255
|
+
imports: [RdxSliderImplDirective],
|
256
|
+
template: `
|
257
|
+
<span
|
258
|
+
#sliderElement
|
259
|
+
[class]="className"
|
260
|
+
[attr.data-orientation]="'horizontal'"
|
261
|
+
[style]="{ '--rdx-slider-thumb-transform': 'translateX(-50%)' }"
|
262
|
+
(slideStart)="onSlideStart($event)"
|
263
|
+
(slideMove)="onSlideMove($event)"
|
264
|
+
(slideEnd)="onSlideEnd()"
|
265
|
+
(stepKeyDown)="onStepKeyDown($event)"
|
266
|
+
(endKeyDown)="endKeyDown.emit($event)"
|
267
|
+
(homeKeyDown)="homeKeyDown.emit($event)"
|
268
|
+
rdxSliderImpl
|
269
|
+
>
|
270
|
+
<ng-content />
|
271
|
+
</span>
|
272
|
+
`
|
273
|
+
}]
|
274
|
+
}], propDecorators: { dir: [{
|
275
|
+
type: Input
|
276
|
+
}], min: [{
|
277
|
+
type: Input
|
278
|
+
}], max: [{
|
279
|
+
type: Input
|
280
|
+
}], className: [{
|
281
|
+
type: Input
|
282
|
+
}], slideStart: [{
|
283
|
+
type: Output
|
284
|
+
}], slideMove: [{
|
285
|
+
type: Output
|
286
|
+
}], slideEnd: [{
|
287
|
+
type: Output
|
288
|
+
}], stepKeyDown: [{
|
289
|
+
type: Output
|
290
|
+
}], endKeyDown: [{
|
291
|
+
type: Output
|
292
|
+
}], homeKeyDown: [{
|
293
|
+
type: Output
|
294
|
+
}] } });
|
295
|
+
|
296
|
+
class RdxSliderOrientationContextService {
|
297
|
+
constructor() {
|
298
|
+
this.contextSignal = signal({
|
299
|
+
startEdge: 'left',
|
300
|
+
endEdge: 'right',
|
301
|
+
direction: 1,
|
302
|
+
size: 'width'
|
303
|
+
});
|
304
|
+
}
|
305
|
+
get context() {
|
306
|
+
return this.contextSignal();
|
307
|
+
}
|
308
|
+
updateContext(context) {
|
309
|
+
this.contextSignal.update((current) => ({
|
310
|
+
...current,
|
311
|
+
...context
|
312
|
+
}));
|
313
|
+
}
|
314
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderOrientationContextService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
315
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderOrientationContextService, providedIn: 'root' }); }
|
316
|
+
}
|
317
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderOrientationContextService, decorators: [{
|
318
|
+
type: Injectable,
|
319
|
+
args: [{ providedIn: 'root' }]
|
320
|
+
}] });
|
321
|
+
|
322
|
+
class RdxSliderVerticalComponent {
|
323
|
+
constructor() {
|
324
|
+
this.rootContext = inject(RdxSliderRootComponent);
|
325
|
+
this.dir = 'ltr';
|
326
|
+
this.inverted = input(false, { transform: booleanAttribute });
|
327
|
+
this.min = 0;
|
328
|
+
this.max = 100;
|
329
|
+
this.className = '';
|
330
|
+
this.slideStart = new EventEmitter();
|
331
|
+
this.slideMove = new EventEmitter();
|
332
|
+
this.slideEnd = new EventEmitter();
|
333
|
+
this.stepKeyDown = new EventEmitter();
|
334
|
+
this.endKeyDown = new EventEmitter();
|
335
|
+
this.homeKeyDown = new EventEmitter();
|
336
|
+
this.sliderElement = viewChild('sliderElement');
|
337
|
+
this.rect = signal(undefined);
|
338
|
+
}
|
339
|
+
onSlideStart(event) {
|
340
|
+
const value = this.getValueFromPointer(event.clientY);
|
341
|
+
this.slideStart.emit(value);
|
342
|
+
}
|
343
|
+
onSlideMove(event) {
|
344
|
+
const value = this.getValueFromPointer(event.clientY);
|
345
|
+
this.slideMove.emit(value);
|
346
|
+
}
|
347
|
+
onSlideEnd() {
|
348
|
+
this.rect.set(undefined);
|
349
|
+
this.slideEnd.emit();
|
350
|
+
}
|
351
|
+
onStepKeyDown(event) {
|
352
|
+
const slideDirection = this.rootContext.isSlidingFromBottom() ? 'from-bottom' : 'from-top';
|
353
|
+
const isBackKey = BACK_KEYS[slideDirection].includes(event.key);
|
354
|
+
this.stepKeyDown.emit({ event, direction: isBackKey ? -1 : 1 });
|
355
|
+
}
|
356
|
+
getValueFromPointer(pointerPosition) {
|
357
|
+
this.rect.set(this.sliderElement()?.nativeElement.getBoundingClientRect());
|
358
|
+
const rect = this.rect();
|
359
|
+
if (!rect)
|
360
|
+
return 0;
|
361
|
+
const input = [0, rect.height];
|
362
|
+
const output = this.rootContext.isSlidingFromBottom()
|
363
|
+
? [this.max, this.min]
|
364
|
+
: [this.min, this.max];
|
365
|
+
const value = linearScale(input, output);
|
366
|
+
this.rect.set(rect);
|
367
|
+
return value(pointerPosition - rect.top);
|
368
|
+
}
|
369
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderVerticalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
370
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.2.11", type: RdxSliderVerticalComponent, isStandalone: true, selector: "rdx-slider-vertical", inputs: { dir: { classPropertyName: "dir", publicName: "dir", isSignal: false, isRequired: false, transformFunction: null }, inverted: { classPropertyName: "inverted", publicName: "inverted", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: false, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: false, isRequired: false, transformFunction: null }, className: { classPropertyName: "className", publicName: "className", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { slideStart: "slideStart", slideMove: "slideMove", slideEnd: "slideEnd", stepKeyDown: "stepKeyDown", endKeyDown: "endKeyDown", homeKeyDown: "homeKeyDown" }, viewQueries: [{ propertyName: "sliderElement", first: true, predicate: ["sliderElement"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
371
|
+
<span
|
372
|
+
#sliderElement
|
373
|
+
[class]="className"
|
374
|
+
[attr.data-orientation]="'vertical'"
|
375
|
+
[style]="{ '--rdx-slider-thumb-transform': 'translateY(-50%)' }"
|
376
|
+
(slideStart)="onSlideStart($event)"
|
377
|
+
(slideMove)="onSlideMove($event)"
|
378
|
+
(slideEnd)="onSlideEnd()"
|
379
|
+
(stepKeyDown)="onStepKeyDown($event)"
|
380
|
+
(endKeyDown)="endKeyDown.emit($event)"
|
381
|
+
(homeKeyDown)="homeKeyDown.emit($event)"
|
382
|
+
rdxSliderImpl
|
383
|
+
>
|
384
|
+
<ng-content />
|
385
|
+
</span>
|
386
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: RdxSliderImplDirective, selector: "[rdxSliderImpl]", outputs: ["slideStart", "slideMove", "slideEnd", "homeKeyDown", "endKeyDown", "stepKeyDown"] }] }); }
|
387
|
+
}
|
388
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderVerticalComponent, decorators: [{
|
389
|
+
type: Component,
|
390
|
+
args: [{
|
391
|
+
selector: 'rdx-slider-vertical',
|
392
|
+
standalone: true,
|
393
|
+
imports: [RdxSliderImplDirective],
|
394
|
+
template: `
|
395
|
+
<span
|
396
|
+
#sliderElement
|
397
|
+
[class]="className"
|
398
|
+
[attr.data-orientation]="'vertical'"
|
399
|
+
[style]="{ '--rdx-slider-thumb-transform': 'translateY(-50%)' }"
|
400
|
+
(slideStart)="onSlideStart($event)"
|
401
|
+
(slideMove)="onSlideMove($event)"
|
402
|
+
(slideEnd)="onSlideEnd()"
|
403
|
+
(stepKeyDown)="onStepKeyDown($event)"
|
404
|
+
(endKeyDown)="endKeyDown.emit($event)"
|
405
|
+
(homeKeyDown)="homeKeyDown.emit($event)"
|
406
|
+
rdxSliderImpl
|
407
|
+
>
|
408
|
+
<ng-content />
|
409
|
+
</span>
|
410
|
+
`
|
411
|
+
}]
|
412
|
+
}], propDecorators: { dir: [{
|
413
|
+
type: Input
|
414
|
+
}], min: [{
|
415
|
+
type: Input
|
416
|
+
}], max: [{
|
417
|
+
type: Input
|
418
|
+
}], className: [{
|
419
|
+
type: Input
|
420
|
+
}], slideStart: [{
|
421
|
+
type: Output
|
422
|
+
}], slideMove: [{
|
423
|
+
type: Output
|
424
|
+
}], slideEnd: [{
|
425
|
+
type: Output
|
426
|
+
}], stepKeyDown: [{
|
427
|
+
type: Output
|
428
|
+
}], endKeyDown: [{
|
429
|
+
type: Output
|
430
|
+
}], homeKeyDown: [{
|
431
|
+
type: Output
|
432
|
+
}] } });
|
433
|
+
|
434
|
+
class RdxSliderRootComponent {
|
435
|
+
constructor() {
|
436
|
+
/** @ignore */
|
437
|
+
this.orientationContext = inject(RdxSliderOrientationContextService);
|
438
|
+
this.min = input(0, { transform: numberAttribute });
|
439
|
+
this.max = input(100, { transform: numberAttribute });
|
440
|
+
this.step = input(1, { transform: numberAttribute });
|
441
|
+
this.minStepsBetweenThumbs = input(0, { transform: numberAttribute });
|
442
|
+
this.orientation = input('horizontal');
|
443
|
+
this.disabled = input(false, { transform: booleanAttribute });
|
444
|
+
this.inverted = input(false, { transform: booleanAttribute });
|
445
|
+
this.dir = input('ltr');
|
446
|
+
this.className = '';
|
447
|
+
this.valueChange = new EventEmitter();
|
448
|
+
this.valueCommit = new EventEmitter();
|
449
|
+
this.modelValue = model([0]);
|
450
|
+
/** @ignore */
|
451
|
+
this.valueIndexToChange = model(0);
|
452
|
+
/** @ignore */
|
453
|
+
this.valuesBeforeSlideStart = model([]);
|
454
|
+
this.isSlidingFromLeft = computed(() => (this.dir() === 'ltr' && !this.inverted()) || (this.dir() !== 'ltr' && this.inverted()));
|
455
|
+
this.isSlidingFromBottom = computed(() => !this.inverted());
|
456
|
+
/** @ignore */
|
457
|
+
this.thumbElements = [];
|
458
|
+
}
|
459
|
+
/** @ignore */
|
460
|
+
ngOnInit() {
|
461
|
+
const isHorizontal = this.orientation() === 'horizontal';
|
462
|
+
if (isHorizontal) {
|
463
|
+
this.orientationContext.updateContext({
|
464
|
+
direction: this.isSlidingFromLeft() ? 1 : -1,
|
465
|
+
size: 'width',
|
466
|
+
startEdge: this.isSlidingFromLeft() ? 'left' : 'right',
|
467
|
+
endEdge: this.isSlidingFromLeft() ? 'right' : 'left'
|
468
|
+
});
|
469
|
+
}
|
470
|
+
else {
|
471
|
+
this.orientationContext.updateContext({
|
472
|
+
direction: this.isSlidingFromBottom() ? -1 : 1,
|
473
|
+
size: 'height',
|
474
|
+
startEdge: this.isSlidingFromBottom() ? 'bottom' : 'top',
|
475
|
+
endEdge: this.isSlidingFromBottom() ? 'top' : 'bottom'
|
476
|
+
});
|
477
|
+
}
|
478
|
+
}
|
479
|
+
/** @ignore */
|
480
|
+
onPointerDown() {
|
481
|
+
this.valuesBeforeSlideStart.set([...this.modelValue()]);
|
482
|
+
}
|
483
|
+
/** @ignore */
|
484
|
+
handleSlideStart(value) {
|
485
|
+
const closestIndex = getClosestValueIndex(this.modelValue(), value);
|
486
|
+
this.updateValues(value, closestIndex);
|
487
|
+
}
|
488
|
+
/** @ignore */
|
489
|
+
handleSlideMove(value) {
|
490
|
+
this.updateValues(value, this.valueIndexToChange());
|
491
|
+
}
|
492
|
+
/** @ignore */
|
493
|
+
handleSlideEnd() {
|
494
|
+
const prevValue = this.valuesBeforeSlideStart()[this.valueIndexToChange()];
|
495
|
+
const nextValue = this.modelValue()[this.valueIndexToChange()];
|
496
|
+
const hasChanged = nextValue !== prevValue;
|
497
|
+
if (hasChanged) {
|
498
|
+
this.valueCommit.emit([...this.modelValue()]);
|
499
|
+
}
|
500
|
+
}
|
501
|
+
/** @ignore */
|
502
|
+
handleStepKeyDown(event) {
|
503
|
+
const stepInDirection = this.step() * event.direction;
|
504
|
+
const atIndex = this.valueIndexToChange();
|
505
|
+
const currentValue = this.modelValue()[atIndex];
|
506
|
+
this.updateValues(currentValue + stepInDirection, atIndex, true);
|
507
|
+
}
|
508
|
+
/** @ignore */
|
509
|
+
updateValues(value, atIndex, commit = false) {
|
510
|
+
const decimalCount = getDecimalCount(this.step());
|
511
|
+
const snapToStep = roundValue(Math.round((value - this.min()) / this.step()) * this.step() + this.min(), decimalCount);
|
512
|
+
const nextValue = clamp(snapToStep, this.min(), this.max());
|
513
|
+
const nextValues = getNextSortedValues(this.modelValue(), nextValue, atIndex);
|
514
|
+
if (hasMinStepsBetweenValues(nextValues, this.minStepsBetweenThumbs() * this.step())) {
|
515
|
+
this.valueIndexToChange.set(nextValues.indexOf(nextValue));
|
516
|
+
const hasChanged = String(nextValues) !== String(this.modelValue());
|
517
|
+
if (hasChanged) {
|
518
|
+
this.modelValue.set(nextValues);
|
519
|
+
this.valueChange.emit([...this.modelValue()]);
|
520
|
+
this.thumbElements[this.valueIndexToChange()]?.focus();
|
521
|
+
if (commit) {
|
522
|
+
this.valueCommit.emit([...this.modelValue()]);
|
523
|
+
}
|
524
|
+
}
|
525
|
+
}
|
526
|
+
}
|
527
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderRootComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
528
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.11", type: RdxSliderRootComponent, isStandalone: true, selector: "rdx-slider", inputs: { min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, minStepsBetweenThumbs: { classPropertyName: "minStepsBetweenThumbs", publicName: "minStepsBetweenThumbs", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, inverted: { classPropertyName: "inverted", publicName: "inverted", isSignal: true, isRequired: false, transformFunction: null }, dir: { classPropertyName: "dir", publicName: "dir", isSignal: true, isRequired: false, transformFunction: null }, className: { classPropertyName: "className", publicName: "className", isSignal: false, isRequired: false, transformFunction: null }, modelValue: { classPropertyName: "modelValue", publicName: "modelValue", isSignal: true, isRequired: false, transformFunction: null }, valueIndexToChange: { classPropertyName: "valueIndexToChange", publicName: "valueIndexToChange", isSignal: true, isRequired: false, transformFunction: null }, valuesBeforeSlideStart: { classPropertyName: "valuesBeforeSlideStart", publicName: "valuesBeforeSlideStart", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", valueCommit: "valueCommit", modelValue: "modelValueChange", valueIndexToChange: "valueIndexToChangeChange", valuesBeforeSlideStart: "valuesBeforeSlideStartChange" }, ngImport: i0, template: `
|
529
|
+
<ng-template #transclude><ng-content /></ng-template>
|
530
|
+
|
531
|
+
<ng-container *ngIf="orientation() === 'horizontal'">
|
532
|
+
<rdx-slider-horizontal
|
533
|
+
[className]="className"
|
534
|
+
[min]="min()"
|
535
|
+
[max]="max()"
|
536
|
+
[dir]="dir()"
|
537
|
+
[inverted]="inverted()"
|
538
|
+
[attr.aria-disabled]="disabled()"
|
539
|
+
[attr.data-disabled]="disabled() ? '' : undefined"
|
540
|
+
(pointerdown)="onPointerDown()"
|
541
|
+
(slideStart)="handleSlideStart($event)"
|
542
|
+
(slideMove)="handleSlideMove($event)"
|
543
|
+
(slideEnd)="handleSlideEnd()"
|
544
|
+
(homeKeyDown)="updateValues(min(), 0, true)"
|
545
|
+
(endKeyDown)="updateValues(max(), modelValue().length - 1, true)"
|
546
|
+
(stepKeyDown)="handleStepKeyDown($event)"
|
547
|
+
>
|
548
|
+
<ng-container *ngTemplateOutlet="transclude" />
|
549
|
+
</rdx-slider-horizontal>
|
550
|
+
</ng-container>
|
551
|
+
|
552
|
+
<ng-container *ngIf="orientation() === 'vertical'">
|
553
|
+
<rdx-slider-vertical
|
554
|
+
[className]="className"
|
555
|
+
[min]="min()"
|
556
|
+
[max]="max()"
|
557
|
+
[dir]="dir()"
|
558
|
+
[inverted]="inverted()"
|
559
|
+
[attr.aria-disabled]="disabled()"
|
560
|
+
[attr.data-disabled]="disabled() ? '' : undefined"
|
561
|
+
(pointerdown)="onPointerDown()"
|
562
|
+
(slideStart)="handleSlideStart($event)"
|
563
|
+
(slideMove)="handleSlideMove($event)"
|
564
|
+
(slideEnd)="handleSlideEnd()"
|
565
|
+
(homeKeyDown)="updateValues(min(), 0, true)"
|
566
|
+
(endKeyDown)="updateValues(max(), modelValue().length - 1, true)"
|
567
|
+
(stepKeyDown)="handleStepKeyDown($event)"
|
568
|
+
>
|
569
|
+
<ng-container *ngTemplateOutlet="transclude" />
|
570
|
+
</rdx-slider-vertical>
|
571
|
+
</ng-container>
|
572
|
+
`, isInline: true, dependencies: [{ kind: "component", type: RdxSliderHorizontalComponent, selector: "rdx-slider-horizontal", inputs: ["dir", "inverted", "min", "max", "className"], outputs: ["slideStart", "slideMove", "slideEnd", "stepKeyDown", "endKeyDown", "homeKeyDown"] }, { kind: "component", type: RdxSliderVerticalComponent, selector: "rdx-slider-vertical", inputs: ["dir", "inverted", "min", "max", "className"], outputs: ["slideStart", "slideMove", "slideEnd", "stepKeyDown", "endKeyDown", "homeKeyDown"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
573
|
+
}
|
574
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderRootComponent, decorators: [{
|
575
|
+
type: Component,
|
576
|
+
args: [{
|
577
|
+
selector: 'rdx-slider',
|
578
|
+
standalone: true,
|
579
|
+
imports: [RdxSliderHorizontalComponent, RdxSliderVerticalComponent, NgIf, NgTemplateOutlet],
|
580
|
+
template: `
|
581
|
+
<ng-template #transclude><ng-content /></ng-template>
|
582
|
+
|
583
|
+
<ng-container *ngIf="orientation() === 'horizontal'">
|
584
|
+
<rdx-slider-horizontal
|
585
|
+
[className]="className"
|
586
|
+
[min]="min()"
|
587
|
+
[max]="max()"
|
588
|
+
[dir]="dir()"
|
589
|
+
[inverted]="inverted()"
|
590
|
+
[attr.aria-disabled]="disabled()"
|
591
|
+
[attr.data-disabled]="disabled() ? '' : undefined"
|
592
|
+
(pointerdown)="onPointerDown()"
|
593
|
+
(slideStart)="handleSlideStart($event)"
|
594
|
+
(slideMove)="handleSlideMove($event)"
|
595
|
+
(slideEnd)="handleSlideEnd()"
|
596
|
+
(homeKeyDown)="updateValues(min(), 0, true)"
|
597
|
+
(endKeyDown)="updateValues(max(), modelValue().length - 1, true)"
|
598
|
+
(stepKeyDown)="handleStepKeyDown($event)"
|
599
|
+
>
|
600
|
+
<ng-container *ngTemplateOutlet="transclude" />
|
601
|
+
</rdx-slider-horizontal>
|
602
|
+
</ng-container>
|
603
|
+
|
604
|
+
<ng-container *ngIf="orientation() === 'vertical'">
|
605
|
+
<rdx-slider-vertical
|
606
|
+
[className]="className"
|
607
|
+
[min]="min()"
|
608
|
+
[max]="max()"
|
609
|
+
[dir]="dir()"
|
610
|
+
[inverted]="inverted()"
|
611
|
+
[attr.aria-disabled]="disabled()"
|
612
|
+
[attr.data-disabled]="disabled() ? '' : undefined"
|
613
|
+
(pointerdown)="onPointerDown()"
|
614
|
+
(slideStart)="handleSlideStart($event)"
|
615
|
+
(slideMove)="handleSlideMove($event)"
|
616
|
+
(slideEnd)="handleSlideEnd()"
|
617
|
+
(homeKeyDown)="updateValues(min(), 0, true)"
|
618
|
+
(endKeyDown)="updateValues(max(), modelValue().length - 1, true)"
|
619
|
+
(stepKeyDown)="handleStepKeyDown($event)"
|
620
|
+
>
|
621
|
+
<ng-container *ngTemplateOutlet="transclude" />
|
622
|
+
</rdx-slider-vertical>
|
623
|
+
</ng-container>
|
624
|
+
`
|
625
|
+
}]
|
626
|
+
}], propDecorators: { className: [{
|
627
|
+
type: Input
|
628
|
+
}], valueChange: [{
|
629
|
+
type: Output
|
630
|
+
}], valueCommit: [{
|
631
|
+
type: Output
|
632
|
+
}] } });
|
633
|
+
|
634
|
+
class RdxSliderRangeComponent {
|
635
|
+
constructor() {
|
636
|
+
this.rootContext = inject(RdxSliderRootComponent);
|
637
|
+
this.percentages = computed(() => this.rootContext
|
638
|
+
.modelValue()
|
639
|
+
?.map((value) => convertValueToPercentage(value, this.rootContext.min(), this.rootContext.max())));
|
640
|
+
this.offsetStart = computed(() => (this.rootContext.modelValue().length > 1 ? Math.min(...this.percentages()) : 0));
|
641
|
+
this.offsetEnd = computed(() => 100 - Math.max(...this.percentages()));
|
642
|
+
this.rangeStyles = computed(() => {
|
643
|
+
const context = this.rootContext.orientationContext.context;
|
644
|
+
return {
|
645
|
+
[context.startEdge]: `${this.offsetStart()}%`,
|
646
|
+
[context.endEdge]: `${this.offsetEnd()}%`
|
647
|
+
};
|
648
|
+
});
|
649
|
+
}
|
650
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderRangeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
651
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.11", type: RdxSliderRangeComponent, isStandalone: true, selector: "rdx-slider-range", host: { properties: { "attr.data-disabled": "rootContext.disabled() ? \"\" : undefined", "attr.data-orientation": "rootContext.orientation()", "style": "rangeStyles()" } }, ngImport: i0, template: `
|
652
|
+
<ng-content />
|
653
|
+
`, isInline: true }); }
|
654
|
+
}
|
655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderRangeComponent, decorators: [{
|
656
|
+
type: Component,
|
657
|
+
args: [{
|
658
|
+
selector: 'rdx-slider-range',
|
659
|
+
standalone: true,
|
660
|
+
host: {
|
661
|
+
'[attr.data-disabled]': 'rootContext.disabled() ? "" : undefined',
|
662
|
+
'[attr.data-orientation]': 'rootContext.orientation()',
|
663
|
+
'[style]': 'rangeStyles()'
|
664
|
+
},
|
665
|
+
template: `
|
666
|
+
<ng-content />
|
667
|
+
`
|
668
|
+
}]
|
669
|
+
}] });
|
670
|
+
|
671
|
+
class RdxSliderThumbImplDirective {
|
672
|
+
constructor() {
|
673
|
+
this.rootContext = inject(RdxSliderRootComponent);
|
674
|
+
this.elementRef = inject(ElementRef);
|
675
|
+
this.platformId = inject(PLATFORM_ID);
|
676
|
+
this.isMounted = signal(false);
|
677
|
+
this.thumbIndex = computed(() => {
|
678
|
+
const thumbElement = this.elementRef.nativeElement;
|
679
|
+
const index = this.rootContext.thumbElements.indexOf(thumbElement);
|
680
|
+
return index >= 0 ? index : null;
|
681
|
+
});
|
682
|
+
this.value = computed(() => {
|
683
|
+
const index = this.thumbIndex();
|
684
|
+
if (index === null)
|
685
|
+
return undefined;
|
686
|
+
return this.rootContext.modelValue()?.[index];
|
687
|
+
});
|
688
|
+
this.percent = computed(() => {
|
689
|
+
const val = this.value();
|
690
|
+
if (val === undefined)
|
691
|
+
return 0;
|
692
|
+
return convertValueToPercentage(val, this.rootContext.min(), this.rootContext.max());
|
693
|
+
});
|
694
|
+
this.transform = computed(() => {
|
695
|
+
const percent = this.percent();
|
696
|
+
const offset = this.thumbInBoundsOffset();
|
697
|
+
return `calc(${percent}% + ${offset}px)`;
|
698
|
+
});
|
699
|
+
this.orientationSize = signal(0);
|
700
|
+
this.thumbInBoundsOffset = computed(() => {
|
701
|
+
const context = this.rootContext.orientationContext.context;
|
702
|
+
const size = this.orientationSize();
|
703
|
+
const percent = this.percent();
|
704
|
+
const direction = context.direction;
|
705
|
+
return size ? getThumbInBoundsOffset(size, percent, direction) : 0;
|
706
|
+
});
|
707
|
+
this.combinedStyles = computed(() => {
|
708
|
+
const context = this.rootContext.orientationContext.context;
|
709
|
+
const startEdge = context.startEdge;
|
710
|
+
const percent = this.percent();
|
711
|
+
const offset = this.thumbInBoundsOffset();
|
712
|
+
return {
|
713
|
+
position: 'absolute',
|
714
|
+
transform: 'var(--rdx-slider-thumb-transform)',
|
715
|
+
display: (this.isMounted() && this.value()) === false ? 'none' : undefined,
|
716
|
+
[startEdge]: `calc(${percent}% + ${offset}px)`
|
717
|
+
};
|
718
|
+
});
|
719
|
+
}
|
720
|
+
onFocus() {
|
721
|
+
if (this.thumbIndex() !== null) {
|
722
|
+
this.rootContext.valueIndexToChange.set(this.thumbIndex());
|
723
|
+
}
|
724
|
+
}
|
725
|
+
ngOnInit() {
|
726
|
+
if (isPlatformBrowser(this.platformId)) {
|
727
|
+
const thumbElement = this.elementRef.nativeElement;
|
728
|
+
this.rootContext.thumbElements.push(thumbElement);
|
729
|
+
this.resizeObserver = new ResizeObserver(() => {
|
730
|
+
const rect = thumbElement.getBoundingClientRect();
|
731
|
+
const context = this.rootContext.orientationContext.context;
|
732
|
+
const size = context.size === 'width' ? rect.width : rect.height;
|
733
|
+
this.orientationSize.set(size);
|
734
|
+
});
|
735
|
+
this.resizeObserver.observe(thumbElement);
|
736
|
+
this.isMounted.set(true);
|
737
|
+
}
|
738
|
+
}
|
739
|
+
ngOnDestroy() {
|
740
|
+
const thumbElement = this.elementRef.nativeElement;
|
741
|
+
const index = this.rootContext.thumbElements.indexOf(thumbElement);
|
742
|
+
if (index >= 0)
|
743
|
+
this.rootContext.thumbElements.splice(index, 1);
|
744
|
+
if (this.resizeObserver) {
|
745
|
+
this.resizeObserver.unobserve(thumbElement);
|
746
|
+
}
|
747
|
+
this.isMounted.set(false);
|
748
|
+
}
|
749
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderThumbImplDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
750
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxSliderThumbImplDirective, isStandalone: true, selector: "[rdxSliderThumbImpl]", host: { attributes: { "role": "slider" }, listeners: { "focus": "onFocus()" }, properties: { "tabindex": "rootContext.disabled() ? undefined : 0", "attr.aria-valuenow": "rootContext.modelValue()", "attr.aria-valuemin": "rootContext.min()", "attr.aria-valuemax": "rootContext.max()", "attr.aria-orientation": "rootContext.orientation()", "attr.data-orientation": "rootContext.orientation()", "attr.data-disabled": "rootContext.disabled() ? \"\" : undefined", "style": "combinedStyles()" } }, ngImport: i0 }); }
|
751
|
+
}
|
752
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderThumbImplDirective, decorators: [{
|
753
|
+
type: Directive,
|
754
|
+
args: [{
|
755
|
+
selector: '[rdxSliderThumbImpl]',
|
756
|
+
standalone: true,
|
757
|
+
host: {
|
758
|
+
role: 'slider',
|
759
|
+
'[tabindex]': 'rootContext.disabled() ? undefined : 0',
|
760
|
+
'[attr.aria-valuenow]': 'rootContext.modelValue()',
|
761
|
+
'[attr.aria-valuemin]': 'rootContext.min()',
|
762
|
+
'[attr.aria-valuemax]': 'rootContext.max()',
|
763
|
+
'[attr.aria-orientation]': 'rootContext.orientation()',
|
764
|
+
'[attr.data-orientation]': 'rootContext.orientation()',
|
765
|
+
'[attr.data-disabled]': 'rootContext.disabled() ? "" : undefined',
|
766
|
+
'[style]': 'combinedStyles()',
|
767
|
+
'(focus)': 'onFocus()'
|
768
|
+
}
|
769
|
+
}]
|
770
|
+
}] });
|
771
|
+
|
772
|
+
class RdxSliderThumbComponent {
|
773
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderThumbComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
774
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.11", type: RdxSliderThumbComponent, isStandalone: true, selector: "rdx-slider-thumb", hostDirectives: [{ directive: RdxSliderThumbImplDirective }], ngImport: i0, template: `
|
775
|
+
<ng-content />
|
776
|
+
`, isInline: true }); }
|
777
|
+
}
|
778
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderThumbComponent, decorators: [{
|
779
|
+
type: Component,
|
780
|
+
args: [{
|
781
|
+
selector: 'rdx-slider-thumb',
|
782
|
+
standalone: true,
|
783
|
+
hostDirectives: [RdxSliderThumbImplDirective],
|
784
|
+
template: `
|
785
|
+
<ng-content />
|
786
|
+
`
|
787
|
+
}]
|
788
|
+
}] });
|
789
|
+
|
790
|
+
class RdxSliderTrackComponent {
|
791
|
+
constructor() {
|
792
|
+
this.rootContext = inject(RdxSliderRootComponent);
|
793
|
+
}
|
794
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderTrackComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
795
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.11", type: RdxSliderTrackComponent, isStandalone: true, selector: "rdx-slider-track", host: { properties: { "attr.data-disabled": "rootContext.disabled() ? '' : undefined", "attr.data-orientation": "rootContext.orientation()" } }, ngImport: i0, template: `
|
796
|
+
<ng-content />
|
797
|
+
`, isInline: true }); }
|
798
|
+
}
|
799
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderTrackComponent, decorators: [{
|
800
|
+
type: Component,
|
801
|
+
args: [{
|
802
|
+
selector: 'rdx-slider-track',
|
803
|
+
standalone: true,
|
804
|
+
host: {
|
805
|
+
'[attr.data-disabled]': "rootContext.disabled() ? '' : undefined",
|
806
|
+
'[attr.data-orientation]': 'rootContext.orientation()'
|
807
|
+
},
|
808
|
+
template: `
|
809
|
+
<ng-content />
|
810
|
+
`
|
811
|
+
}]
|
812
|
+
}] });
|
813
|
+
|
814
|
+
const _imports = [RdxSliderRootComponent, RdxSliderTrackComponent, RdxSliderRangeComponent, RdxSliderThumbComponent];
|
815
|
+
class RdxSliderModule {
|
816
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
817
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderModule, imports: [RdxSliderRootComponent, RdxSliderTrackComponent, RdxSliderRangeComponent, RdxSliderThumbComponent], exports: [RdxSliderRootComponent, RdxSliderTrackComponent, RdxSliderRangeComponent, RdxSliderThumbComponent] }); }
|
818
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderModule }); }
|
819
|
+
}
|
820
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderModule, decorators: [{
|
821
|
+
type: NgModule,
|
822
|
+
args: [{
|
823
|
+
imports: [..._imports],
|
824
|
+
exports: [..._imports]
|
825
|
+
}]
|
826
|
+
}] });
|
827
|
+
|
828
|
+
/**
|
829
|
+
* Generated bundle index. Do not edit.
|
830
|
+
*/
|
831
|
+
|
832
|
+
export { RdxSliderHorizontalComponent, RdxSliderImplDirective, RdxSliderModule, RdxSliderRangeComponent, RdxSliderRootComponent, RdxSliderThumbComponent, RdxSliderThumbImplDirective, RdxSliderTrackComponent, RdxSliderVerticalComponent };
|
833
|
+
//# sourceMappingURL=radix-ng-primitives-slider.mjs.map
|