@radix-ng/primitives 1.0.0-beta.3 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/fesm2022/radix-ng-primitives-accordion.mjs +5 -3
- package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs +3 -2
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-autocomplete.mjs +617 -659
- package/fesm2022/radix-ng-primitives-autocomplete.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-calendar.mjs +5 -3
- package/fesm2022/radix-ng-primitives-calendar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-checkbox.mjs +33 -18
- package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-combobox.mjs +1305 -572
- package/fesm2022/radix-ng-primitives-combobox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-config.mjs +13 -4
- package/fesm2022/radix-ng-primitives-config.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-context-menu.mjs +51 -10
- package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +1352 -64
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-date-field.mjs +5 -3
- package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dialog.mjs +290 -120
- package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-direction-provider.mjs +70 -0
- package/fesm2022/radix-ng-primitives-direction-provider.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +519 -184
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-drawer.mjs +3 -3
- package/fesm2022/radix-ng-primitives-drawer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-editable.mjs +12 -7
- package/fesm2022/radix-ng-primitives-editable.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-field.mjs +3 -2
- package/fesm2022/radix-ng-primitives-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-floating-focus-manager.mjs +803 -0
- package/fesm2022/radix-ng-primitives-floating-focus-manager.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-focus-scope.mjs +305 -70
- package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menu.mjs +893 -289
- package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menubar.mjs +32 -4
- package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs +144 -159
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-number-field.mjs +7 -2
- package/fesm2022/radix-ng-primitives-number-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popover.mjs +284 -212
- package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popper.mjs +94 -51
- package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-presence.mjs +1 -1
- package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-preview-card.mjs +141 -173
- package/fesm2022/radix-ng-primitives-preview-card.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-radio.mjs +19 -14
- package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-roving-focus.mjs +4 -2
- package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-scroll-area.mjs +5 -4
- package/fesm2022/radix-ng-primitives-scroll-area.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-select.mjs +241 -164
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-slider.mjs +262 -29
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-stepper.mjs +16 -10
- package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +10 -5
- package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tabs.mjs +15 -10
- package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-time-field.mjs +5 -3
- package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toast.mjs +15 -36
- package/fesm2022/radix-ng-primitives-toast.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +14 -7
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +12 -6
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toolbar.mjs +5 -3
- package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tooltip.mjs +251 -143
- package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
- package/package.json +10 -1
- package/types/radix-ng-primitives-accordion.d.ts +4 -3
- package/types/radix-ng-primitives-autocomplete.d.ts +217 -152
- package/types/radix-ng-primitives-calendar.d.ts +5 -3
- package/types/radix-ng-primitives-checkbox.d.ts +27 -15
- package/types/radix-ng-primitives-combobox.d.ts +672 -283
- package/types/radix-ng-primitives-config.d.ts +1 -1
- package/types/radix-ng-primitives-context-menu.d.ts +15 -5
- package/types/radix-ng-primitives-core.d.ts +764 -14
- package/types/radix-ng-primitives-date-field.d.ts +3 -2
- package/types/radix-ng-primitives-dialog.d.ts +88 -32
- package/types/radix-ng-primitives-direction-provider.d.ts +41 -0
- package/types/radix-ng-primitives-dismissable-layer.d.ts +147 -99
- package/types/radix-ng-primitives-editable.d.ts +11 -5
- package/types/radix-ng-primitives-field.d.ts +1 -0
- package/types/radix-ng-primitives-floating-focus-manager.d.ts +272 -0
- package/types/radix-ng-primitives-focus-scope.d.ts +132 -1
- package/types/radix-ng-primitives-menu.d.ts +192 -103
- package/types/radix-ng-primitives-navigation-menu.d.ts +37 -75
- package/types/radix-ng-primitives-number-field.d.ts +8 -3
- package/types/radix-ng-primitives-popover.d.ts +71 -92
- package/types/radix-ng-primitives-popper.d.ts +39 -9
- package/types/radix-ng-primitives-preview-card.d.ts +39 -72
- package/types/radix-ng-primitives-radio.d.ts +13 -6
- package/types/radix-ng-primitives-roving-focus.d.ts +7 -6
- package/types/radix-ng-primitives-scroll-area.d.ts +2 -2
- package/types/radix-ng-primitives-select.d.ts +142 -109
- package/types/radix-ng-primitives-slider.d.ts +64 -12
- package/types/radix-ng-primitives-stepper.d.ts +15 -7
- package/types/radix-ng-primitives-switch.d.ts +10 -4
- package/types/radix-ng-primitives-tabs.d.ts +12 -6
- package/types/radix-ng-primitives-time-field.d.ts +3 -2
- package/types/radix-ng-primitives-toast.d.ts +7 -7
- package/types/radix-ng-primitives-toggle-group.d.ts +15 -8
- package/types/radix-ng-primitives-toggle.d.ts +10 -3
- package/types/radix-ng-primitives-toolbar.d.ts +3 -2
- package/types/radix-ng-primitives-tooltip.d.ts +61 -80
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, DestroyRef, Directive, computed, input, numberAttribute, booleanAttribute, model, output, signal, NgModule } from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, DestroyRef, Directive, computed, input, numberAttribute, booleanAttribute, model, output, signal, afterNextRender, afterRenderEffect, untracked, NgModule } from '@angular/core';
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
4
|
import * as i1 from '@radix-ng/primitives/core';
|
|
5
|
-
import { createContext, clamp, injectControlValueAccessor, injectId, RdxControlValueAccessor } from '@radix-ng/primitives/core';
|
|
5
|
+
import { createContext, clamp, injectControlValueAccessor, injectDocument, injectId, createCancelableChangeEventDetails, RdxControlValueAccessor } from '@radix-ng/primitives/core';
|
|
6
6
|
export { clamp } from '@radix-ng/primitives/core';
|
|
7
|
+
import { injectDirection } from '@radix-ng/primitives/direction-provider';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* The Slider context exposes the root directive instance to every child part.
|
|
@@ -33,6 +34,20 @@ function getMidpoint(element) {
|
|
|
33
34
|
const rect = element.getBoundingClientRect();
|
|
34
35
|
return { x: (rect.left + rect.right) / 2, y: (rect.top + rect.bottom) / 2 };
|
|
35
36
|
}
|
|
37
|
+
/** Calculates the control-relative percent for an edge-aligned thumb. */
|
|
38
|
+
function getInsetThumbPositionPercent(control, thumb, thumbValuePercent, vertical) {
|
|
39
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
40
|
+
const controlRect = control.getBoundingClientRect();
|
|
41
|
+
const side = vertical ? 'height' : 'width';
|
|
42
|
+
const controlSide = controlRect[side];
|
|
43
|
+
if (!(controlSide > 0)) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const controlSize = controlSide - thumbRect[side];
|
|
47
|
+
const thumbOffsetFromControlEdge = thumbRect[side] / 2 + (controlSize * thumbValuePercent) / 100;
|
|
48
|
+
const nextPosition = (thumbOffsetFromControlEdge / controlSide) * 100;
|
|
49
|
+
return Number.isFinite(nextPosition) ? nextPosition : undefined;
|
|
50
|
+
}
|
|
36
51
|
/** Converts an array of values into clamped 0–100 percentages. */
|
|
37
52
|
function valueArrayToPercentages(values, min, max) {
|
|
38
53
|
return values.map((value) => clamp(valueToPercent(value, min, max), 0, 100));
|
|
@@ -303,11 +318,22 @@ class RdxSliderControl {
|
|
|
303
318
|
this.styles = null;
|
|
304
319
|
this.moveCount = 0;
|
|
305
320
|
this.currentInteractionValue = null;
|
|
321
|
+
this.touchId = null;
|
|
322
|
+
this.insetThumbOffset = 0;
|
|
323
|
+
this.onTouchStart = (event) => this.handleTouchStart(event);
|
|
306
324
|
this.onMove = (event) => this.handleMove(event);
|
|
307
325
|
this.onUp = (event) => this.handleUp(event);
|
|
308
326
|
this.onCancel = (event) => this.handleUp(event);
|
|
309
|
-
this.
|
|
310
|
-
|
|
327
|
+
this.onTouchMove = (event) => this.handleMove(event);
|
|
328
|
+
this.onTouchEnd = (event) => this.handleUp(event);
|
|
329
|
+
const control = this.elementRef.nativeElement;
|
|
330
|
+
this.root.controlRef.set(control);
|
|
331
|
+
control.style.setProperty('touch-action', 'none');
|
|
332
|
+
control.addEventListener('touchstart', this.onTouchStart, { passive: true });
|
|
333
|
+
inject(DestroyRef).onDestroy(() => {
|
|
334
|
+
control.removeEventListener('touchstart', this.onTouchStart);
|
|
335
|
+
this.stopListening();
|
|
336
|
+
});
|
|
311
337
|
}
|
|
312
338
|
onPointerDown(event) {
|
|
313
339
|
const control = this.elementRef.nativeElement;
|
|
@@ -318,11 +344,16 @@ class RdxSliderControl {
|
|
|
318
344
|
if (!target) {
|
|
319
345
|
return;
|
|
320
346
|
}
|
|
347
|
+
if (this.isTargetDisabledThumb(target)) {
|
|
348
|
+
this.root.resetPressedThumb();
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
321
351
|
// Suppress the nested range input's native click-to-set and drag so the
|
|
322
352
|
// control fully owns pointer interaction (otherwise releasing on a thumb
|
|
323
353
|
// fires a native change that snaps the value to the press point inside
|
|
324
354
|
// the thumb-sized input). Focus is restored manually via focusThumb.
|
|
325
355
|
event.preventDefault();
|
|
356
|
+
this.touchId = null;
|
|
326
357
|
this.styles = this.document.defaultView?.getComputedStyle(control) ?? null;
|
|
327
358
|
this.startPressing({ x: event.clientX, y: event.clientY });
|
|
328
359
|
const finger = this.getFingerState({ x: event.clientX, y: event.clientY });
|
|
@@ -332,7 +363,7 @@ class RdxSliderControl {
|
|
|
332
363
|
this.root.setDragging(true);
|
|
333
364
|
// Pressing directly on a thumb sets a center offset; only a rail press changes value on down.
|
|
334
365
|
if (this.root.pressedThumbCenterOffset == null) {
|
|
335
|
-
this.setValueFromPointer(finger, 'track-press');
|
|
366
|
+
this.setValueFromPointer(finger, 'track-press', event);
|
|
336
367
|
}
|
|
337
368
|
this.root.focusThumb(finger.thumbIndex);
|
|
338
369
|
control.setPointerCapture(event.pointerId);
|
|
@@ -341,13 +372,50 @@ class RdxSliderControl {
|
|
|
341
372
|
this.document.addEventListener('pointerup', this.onUp, { once: true });
|
|
342
373
|
this.document.addEventListener('pointercancel', this.onCancel, { once: true });
|
|
343
374
|
}
|
|
375
|
+
handleTouchStart(event) {
|
|
376
|
+
if (this.root.isDisabled()) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
const touch = event.changedTouches[0];
|
|
380
|
+
if (!touch) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (this.isTargetDisabledThumb(event.target)) {
|
|
384
|
+
this.root.resetPressedThumb();
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
this.touchId = touch.identifier;
|
|
388
|
+
this.styles = this.document.defaultView?.getComputedStyle(this.elementRef.nativeElement) ?? null;
|
|
389
|
+
const fingerCoords = this.getFingerCoords(event);
|
|
390
|
+
if (fingerCoords == null) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
this.startPressing(fingerCoords);
|
|
394
|
+
const finger = this.getFingerState(fingerCoords);
|
|
395
|
+
if (finger == null) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
this.root.focusThumb(finger.thumbIndex);
|
|
399
|
+
const applied = this.setValueFromPointer(finger, 'track-press', event);
|
|
400
|
+
if (applied && finger.didSwap) {
|
|
401
|
+
this.root.focusThumb(finger.thumbIndex);
|
|
402
|
+
}
|
|
403
|
+
this.moveCount = 0;
|
|
404
|
+
this.document.addEventListener('touchmove', this.onTouchMove, { passive: true });
|
|
405
|
+
this.document.addEventListener('touchend', this.onTouchEnd, { passive: true, once: true });
|
|
406
|
+
this.document.addEventListener('touchcancel', this.onTouchEnd, { passive: true, once: true });
|
|
407
|
+
}
|
|
344
408
|
handleMove(event) {
|
|
409
|
+
const fingerCoords = this.getFingerCoords(event);
|
|
410
|
+
if (fingerCoords == null) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
345
413
|
this.moveCount += 1;
|
|
346
|
-
if (event.buttons === 0) {
|
|
414
|
+
if ('buttons' in event && event.buttons === 0) {
|
|
347
415
|
this.handleUp(event);
|
|
348
416
|
return;
|
|
349
417
|
}
|
|
350
|
-
const finger = this.getFingerState(
|
|
418
|
+
const finger = this.getFingerState(fingerCoords);
|
|
351
419
|
if (finger == null) {
|
|
352
420
|
return;
|
|
353
421
|
}
|
|
@@ -355,7 +423,7 @@ class RdxSliderControl {
|
|
|
355
423
|
if (!this.root.dragging() && this.moveCount > INTENTIONAL_DRAG_COUNT_THRESHOLD) {
|
|
356
424
|
this.root.setDragging(true);
|
|
357
425
|
}
|
|
358
|
-
const applied = this.setValueFromPointer(finger, 'drag');
|
|
426
|
+
const applied = this.setValueFromPointer(finger, 'drag', event);
|
|
359
427
|
if (applied && finger.didSwap) {
|
|
360
428
|
this.root.focusThumb(finger.thumbIndex);
|
|
361
429
|
}
|
|
@@ -367,13 +435,14 @@ class RdxSliderControl {
|
|
|
367
435
|
this.root.pressedThumbCenterOffset = null;
|
|
368
436
|
this.root.pressedInput = null;
|
|
369
437
|
if (this.currentInteractionValue != null) {
|
|
370
|
-
this.root.commitValue();
|
|
438
|
+
this.root.commitValue(event);
|
|
371
439
|
}
|
|
372
440
|
const control = this.elementRef.nativeElement;
|
|
373
|
-
if (control.hasPointerCapture?.(event.pointerId)) {
|
|
441
|
+
if ('pointerId' in event && control.hasPointerCapture?.(event.pointerId)) {
|
|
374
442
|
control.releasePointerCapture(event.pointerId);
|
|
375
443
|
}
|
|
376
444
|
this.root.resetPressedThumb();
|
|
445
|
+
this.touchId = null;
|
|
377
446
|
this.root.pressedValues = null;
|
|
378
447
|
this.currentInteractionValue = null;
|
|
379
448
|
this.stopListening();
|
|
@@ -382,6 +451,31 @@ class RdxSliderControl {
|
|
|
382
451
|
this.document.removeEventListener('pointermove', this.onMove);
|
|
383
452
|
this.document.removeEventListener('pointerup', this.onUp);
|
|
384
453
|
this.document.removeEventListener('pointercancel', this.onCancel);
|
|
454
|
+
this.document.removeEventListener('touchmove', this.onTouchMove);
|
|
455
|
+
this.document.removeEventListener('touchend', this.onTouchEnd);
|
|
456
|
+
this.document.removeEventListener('touchcancel', this.onTouchEnd);
|
|
457
|
+
}
|
|
458
|
+
getFingerCoords(event) {
|
|
459
|
+
if ('changedTouches' in event) {
|
|
460
|
+
if (this.touchId == null) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
for (let i = 0; i < event.changedTouches.length; i += 1) {
|
|
464
|
+
const touch = event.changedTouches[i];
|
|
465
|
+
if (touch.identifier === this.touchId) {
|
|
466
|
+
return { x: touch.clientX, y: touch.clientY };
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
return { x: event.clientX, y: event.clientY };
|
|
472
|
+
}
|
|
473
|
+
isTargetDisabledThumb(target) {
|
|
474
|
+
const NodeCtor = this.elementRef.nativeElement.ownerDocument.defaultView?.Node;
|
|
475
|
+
if (!NodeCtor || !(target instanceof NodeCtor)) {
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
return this.root.thumbList().some((thumb) => thumb.disabled() && thumb.element.contains(target));
|
|
385
479
|
}
|
|
386
480
|
startPressing(finger) {
|
|
387
481
|
const values = this.root.values();
|
|
@@ -423,10 +517,18 @@ class RdxSliderControl {
|
|
|
423
517
|
this.root.pressedThumbIndex = closestThumbIndex;
|
|
424
518
|
this.root.pressedInput = this.root.thumbList()[closestThumbIndex]?.inputElement ?? null;
|
|
425
519
|
}
|
|
520
|
+
this.insetThumbOffset = 0;
|
|
521
|
+
if (this.root.inset()) {
|
|
522
|
+
const thumb = this.root.thumbList()[closestThumbIndex]?.element;
|
|
523
|
+
if (thumb) {
|
|
524
|
+
const rect = thumb.getBoundingClientRect();
|
|
525
|
+
this.insetThumbOffset = (this.root.orientation() === 'vertical' ? rect.height : rect.width) / 2;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
426
528
|
}
|
|
427
|
-
setValueFromPointer(finger, reason) {
|
|
529
|
+
setValueFromPointer(finger, reason, event) {
|
|
428
530
|
const nextValues = Array.isArray(finger.value) ? finger.value : [finger.value];
|
|
429
|
-
const applied = this.root.setValue(nextValues, reason);
|
|
531
|
+
const applied = this.root.setValue(nextValues, reason, event, finger.thumbIndex);
|
|
430
532
|
if (applied) {
|
|
431
533
|
this.currentInteractionValue = finger.value;
|
|
432
534
|
if (finger.didSwap) {
|
|
@@ -452,7 +554,7 @@ class RdxSliderControl {
|
|
|
452
554
|
}
|
|
453
555
|
const { width, height, bottom, left, right } = control.getBoundingClientRect();
|
|
454
556
|
const controlOffset = getControlOffset(this.styles, vertical, rtl);
|
|
455
|
-
const controlSize = (vertical ? height : width) - controlOffset.start - controlOffset.end;
|
|
557
|
+
const controlSize = (vertical ? height : width) - controlOffset.start - controlOffset.end - this.insetThumbOffset * 2;
|
|
456
558
|
// A collapsed/unmeasurable track would divide by zero and yield NaN values.
|
|
457
559
|
if (!(controlSize > 0)) {
|
|
458
560
|
return null;
|
|
@@ -463,7 +565,7 @@ class RdxSliderControl {
|
|
|
463
565
|
const valueSize = vertical
|
|
464
566
|
? bottom - fingerY - controlOffset.end
|
|
465
567
|
: (rtl ? right - fingerX : fingerX - left) - controlOffset.start;
|
|
466
|
-
const valueRescaled = clamp(valueSize / controlSize, 0, 1);
|
|
568
|
+
const valueRescaled = clamp((valueSize - this.insetThumbOffset) / controlSize, 0, 1);
|
|
467
569
|
let newValue = (max - min) * valueRescaled + min;
|
|
468
570
|
newValue = roundValueToStep(newValue, step, min);
|
|
469
571
|
newValue = clamp(newValue, min, max);
|
|
@@ -503,6 +605,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
503
605
|
}]
|
|
504
606
|
}], ctorParameters: () => [] });
|
|
505
607
|
|
|
608
|
+
function getInsetStyles(vertical, range, start, end) {
|
|
609
|
+
const startEdge = vertical ? 'bottom' : 'inset-inline-start';
|
|
610
|
+
const mainSide = vertical ? 'height' : 'width';
|
|
611
|
+
const crossSide = vertical ? 'width' : 'height';
|
|
612
|
+
const styles = {
|
|
613
|
+
position: vertical ? 'absolute' : 'relative',
|
|
614
|
+
[crossSide]: 'inherit'
|
|
615
|
+
};
|
|
616
|
+
if (start === undefined || (range && end === undefined)) {
|
|
617
|
+
styles['visibility'] = 'hidden';
|
|
618
|
+
}
|
|
619
|
+
if (!range) {
|
|
620
|
+
styles[startEdge] = 0;
|
|
621
|
+
styles[mainSide] = `${start ?? 0}%`;
|
|
622
|
+
return styles;
|
|
623
|
+
}
|
|
624
|
+
styles[startEdge] = `${start ?? 0}%`;
|
|
625
|
+
styles[mainSide] = `${(end ?? 0) - (start ?? 0)}%`;
|
|
626
|
+
return styles;
|
|
627
|
+
}
|
|
506
628
|
/**
|
|
507
629
|
* Visualises the portion of the track between the slider's minimum (or the first
|
|
508
630
|
* thumb in a range) and the active value.
|
|
@@ -518,11 +640,16 @@ class RdxSliderIndicator {
|
|
|
518
640
|
const values = this.root.values();
|
|
519
641
|
const min = this.root.min();
|
|
520
642
|
const max = this.root.max();
|
|
643
|
+
const inset = this.root.inset();
|
|
521
644
|
const startEdge = vertical ? 'bottom' : 'inset-inline-start';
|
|
522
645
|
const mainSide = vertical ? 'height' : 'width';
|
|
523
646
|
const crossSide = vertical ? 'width' : 'height';
|
|
524
647
|
const start = valueToPercent(values[0], min, max);
|
|
525
648
|
const end = valueToPercent(values[values.length - 1], min, max);
|
|
649
|
+
if (inset) {
|
|
650
|
+
const [startPosition, endPosition] = this.root.indicatorPosition();
|
|
651
|
+
return getInsetStyles(vertical, range, startPosition, endPosition);
|
|
652
|
+
}
|
|
526
653
|
const styles = {
|
|
527
654
|
position: vertical ? 'absolute' : 'relative',
|
|
528
655
|
[crossSide]: 'inherit'
|
|
@@ -566,6 +693,21 @@ function sortByDomOrder(list) {
|
|
|
566
693
|
return 0;
|
|
567
694
|
});
|
|
568
695
|
}
|
|
696
|
+
function cloneChangeEventWithTarget(event, value, name) {
|
|
697
|
+
const EventCtor = event.constructor;
|
|
698
|
+
let clonedEvent;
|
|
699
|
+
try {
|
|
700
|
+
clonedEvent = new EventCtor(event.type, event);
|
|
701
|
+
}
|
|
702
|
+
catch {
|
|
703
|
+
clonedEvent = new Event(event.type, event);
|
|
704
|
+
}
|
|
705
|
+
Object.defineProperty(clonedEvent, 'target', {
|
|
706
|
+
writable: true,
|
|
707
|
+
value: { value, name }
|
|
708
|
+
});
|
|
709
|
+
return clonedEvent;
|
|
710
|
+
}
|
|
569
711
|
/**
|
|
570
712
|
* Groups all parts of the slider and owns its state, value-change logic and
|
|
571
713
|
* thumb registration. A single directive drives both orientations — there are no
|
|
@@ -577,6 +719,7 @@ class RdxSliderRoot {
|
|
|
577
719
|
constructor() {
|
|
578
720
|
/** @ignore */
|
|
579
721
|
this.cva = injectControlValueAccessor();
|
|
722
|
+
this.document = injectDocument();
|
|
580
723
|
this.id = input(injectId('rdx-slider-'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
581
724
|
/**
|
|
582
725
|
* The minimum value of the slider.
|
|
@@ -612,12 +755,20 @@ class RdxSliderRoot {
|
|
|
612
755
|
* The reading direction. Mirrors the horizontal axis when set to `'rtl'`.
|
|
613
756
|
* @default 'ltr'
|
|
614
757
|
*/
|
|
615
|
-
this.
|
|
758
|
+
this.dirInput = input(undefined, { ...(ngDevMode ? { debugName: "dirInput" } : /* istanbul ignore next */ {}), alias: 'dir' });
|
|
759
|
+
this.dir = injectDirection(this.dirInput);
|
|
616
760
|
/**
|
|
617
761
|
* How thumbs behave when they meet in a range slider.
|
|
618
762
|
* @default 'push'
|
|
619
763
|
*/
|
|
620
764
|
this.thumbCollisionBehavior = input('push', ...(ngDevMode ? [{ debugName: "thumbCollisionBehavior" }] : /* istanbul ignore next */ []));
|
|
765
|
+
/**
|
|
766
|
+
* How the thumbs align with the control when the value is at min/max.
|
|
767
|
+
* `center` aligns the thumb center to the control edge; `edge`/`edge-client-only`
|
|
768
|
+
* inset thumbs so their outer edge aligns to the control edge.
|
|
769
|
+
* @default 'center'
|
|
770
|
+
*/
|
|
771
|
+
this.thumbAlignment = input('center', ...(ngDevMode ? [{ debugName: "thumbAlignment" }] : /* istanbul ignore next */ []));
|
|
621
772
|
/** Options forwarded to `Intl.NumberFormat` when displaying and announcing values. */
|
|
622
773
|
this.format = input(...(ngDevMode ? [undefined, { debugName: "format" }] : /* istanbul ignore next */ []));
|
|
623
774
|
/** Locale used for value formatting. */
|
|
@@ -648,6 +799,8 @@ class RdxSliderRoot {
|
|
|
648
799
|
this.lastUsedThumbIndex = signal(-1, ...(ngDevMode ? [{ debugName: "lastUsedThumbIndex" }] : /* istanbul ignore next */ []));
|
|
649
800
|
/** @ignore Whether a pointer drag is in progress. */
|
|
650
801
|
this.dragging = signal(false, ...(ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []));
|
|
802
|
+
/** @ignore Edge-aligned thumb/indicator positions, in control-relative percentages. */
|
|
803
|
+
this.indicatorPosition = signal([undefined, undefined], ...(ngDevMode ? [{ debugName: "indicatorPosition" }] : /* istanbul ignore next */ []));
|
|
651
804
|
/** @ignore Pointer-drag scratch state (not reactive). */
|
|
652
805
|
this.pressedThumbIndex = -1;
|
|
653
806
|
/** @ignore */
|
|
@@ -660,6 +813,10 @@ class RdxSliderRoot {
|
|
|
660
813
|
this.lastChangeReason = 'none';
|
|
661
814
|
/** @ignore */
|
|
662
815
|
this.isDisabled = computed(() => !!this.cva.disabled(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
|
|
816
|
+
/** @ignore */
|
|
817
|
+
this.inset = computed(() => this.thumbAlignment() !== 'center', ...(ngDevMode ? [{ debugName: "inset" }] : /* istanbul ignore next */ []));
|
|
818
|
+
/** @ignore */
|
|
819
|
+
this.renderBeforeHydration = computed(() => this.thumbAlignment() === 'edge', ...(ngDevMode ? [{ debugName: "renderBeforeHydration" }] : /* istanbul ignore next */ []));
|
|
663
820
|
/** @ignore The current value source (controlled value, else default, else min). */
|
|
664
821
|
this.currentRaw = computed(() => this.cva.value() ?? this.defaultValue() ?? this.min(), ...(ngDevMode ? [{ debugName: "currentRaw" }] : /* istanbul ignore next */ []));
|
|
665
822
|
/** Whether the slider has multiple thumbs (the value is an array). */
|
|
@@ -700,6 +857,18 @@ class RdxSliderRoot {
|
|
|
700
857
|
this.thumbList()[index]?.inputElement?.focus({ preventScroll: true });
|
|
701
858
|
}
|
|
702
859
|
/** @ignore */
|
|
860
|
+
setIndicatorPosition(index, position) {
|
|
861
|
+
this.indicatorPosition.update(([start, end]) => {
|
|
862
|
+
if (index === 0) {
|
|
863
|
+
return [position, end];
|
|
864
|
+
}
|
|
865
|
+
if (index === this.values().length - 1) {
|
|
866
|
+
return [start, position];
|
|
867
|
+
}
|
|
868
|
+
return [start, end];
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
/** @ignore */
|
|
703
872
|
formatValue(value) {
|
|
704
873
|
return formatNumber(value, this.locale(), this.format());
|
|
705
874
|
}
|
|
@@ -716,21 +885,29 @@ class RdxSliderRoot {
|
|
|
716
885
|
* Applies a new full set of values, preserving the single/range value shape.
|
|
717
886
|
* Returns `false` when the value did not change.
|
|
718
887
|
*/
|
|
719
|
-
setValue(nextValues, reason) {
|
|
888
|
+
setValue(nextValues, reason, event, activeThumbIndex = -1) {
|
|
720
889
|
const next = this.range() ? nextValues : nextValues[0];
|
|
721
890
|
const current = this.outputValue();
|
|
722
891
|
const hasNaN = Array.isArray(next) ? next.some((v) => Number.isNaN(v)) : Number.isNaN(next);
|
|
723
892
|
if (hasNaN || areValuesEqual(next, current)) {
|
|
724
893
|
return false;
|
|
725
894
|
}
|
|
895
|
+
const trigger = event?.currentTarget instanceof HTMLElement ? event.currentTarget : undefined;
|
|
896
|
+
const changeEvent = cloneChangeEventWithTarget(event ?? new Event('slider.value-change'), next, this.name());
|
|
897
|
+
const { eventDetails: baseEventDetails } = createCancelableChangeEventDetails(reason, changeEvent, trigger);
|
|
898
|
+
const eventDetails = Object.assign(baseEventDetails, { activeThumbIndex });
|
|
899
|
+
this.onValueChange.emit({ value: next, eventDetails });
|
|
900
|
+
if (eventDetails.isCanceled()) {
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
726
903
|
this.lastChangeReason = reason;
|
|
904
|
+
this.lastChangeEvent = eventDetails.event;
|
|
727
905
|
this.value.set(next);
|
|
728
906
|
this.cva.setValue(next);
|
|
729
|
-
this.onValueChange.emit(next);
|
|
730
907
|
return true;
|
|
731
908
|
}
|
|
732
909
|
/** @ignore Keyboard / native input path: clamps to neighbours, commits immediately. */
|
|
733
|
-
handleInputChange(valueInput, index, reason = 'keyboard') {
|
|
910
|
+
handleInputChange(valueInput, index, reason = 'keyboard', event) {
|
|
734
911
|
if (this.isDisabled()) {
|
|
735
912
|
return;
|
|
736
913
|
}
|
|
@@ -739,15 +916,24 @@ class RdxSliderRoot {
|
|
|
739
916
|
return;
|
|
740
917
|
}
|
|
741
918
|
const arr = Array.isArray(result) ? result : [result];
|
|
742
|
-
const applied = this.setValue(arr, reason);
|
|
919
|
+
const applied = this.setValue(arr, reason, event, index);
|
|
743
920
|
this.cva.markAsTouched();
|
|
744
921
|
if (applied) {
|
|
745
|
-
this.
|
|
922
|
+
this.commitValue(event, reason);
|
|
746
923
|
}
|
|
747
924
|
}
|
|
748
925
|
/** @ignore Emits the committed value at the end of a pointer drag. */
|
|
749
|
-
commitValue() {
|
|
750
|
-
this.
|
|
926
|
+
commitValue(event, reason = this.lastChangeReason) {
|
|
927
|
+
const commitEvent = event ?? this.lastChangeEvent ?? new Event('slider.value-commit');
|
|
928
|
+
const trigger = commitEvent.currentTarget instanceof HTMLElement ? commitEvent.currentTarget : undefined;
|
|
929
|
+
this.onValueCommitted.emit({
|
|
930
|
+
value: this.outputValue(),
|
|
931
|
+
eventDetails: {
|
|
932
|
+
reason,
|
|
933
|
+
event: commitEvent,
|
|
934
|
+
trigger
|
|
935
|
+
}
|
|
936
|
+
});
|
|
751
937
|
}
|
|
752
938
|
/** @ignore */
|
|
753
939
|
markAsTouched() {
|
|
@@ -763,8 +949,12 @@ class RdxSliderRoot {
|
|
|
763
949
|
this.pressedThumbCenterOffset = null;
|
|
764
950
|
this.pressedInput = null;
|
|
765
951
|
}
|
|
952
|
+
/** @ignore */
|
|
953
|
+
getOwnerWindow() {
|
|
954
|
+
return this.document.defaultView ?? undefined;
|
|
955
|
+
}
|
|
766
956
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSliderRoot, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
767
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxSliderRoot, isStandalone: true, selector: "div[rdxSliderRoot]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, 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 }, largeStep: { classPropertyName: "largeStep", publicName: "largeStep", isSignal: true, isRequired: false, transformFunction: null }, minStepsBetweenValues: { classPropertyName: "minStepsBetweenValues", publicName: "minStepsBetweenValues", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null },
|
|
957
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxSliderRoot, isStandalone: true, selector: "div[rdxSliderRoot]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, 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 }, largeStep: { classPropertyName: "largeStep", publicName: "largeStep", isSignal: true, isRequired: false, transformFunction: null }, minStepsBetweenValues: { classPropertyName: "minStepsBetweenValues", publicName: "minStepsBetweenValues", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, dirInput: { classPropertyName: "dirInput", publicName: "dir", isSignal: true, isRequired: false, transformFunction: null }, thumbCollisionBehavior: { classPropertyName: "thumbCollisionBehavior", publicName: "thumbCollisionBehavior", isSignal: true, isRequired: false, transformFunction: null }, thumbAlignment: { classPropertyName: "thumbAlignment", publicName: "thumbAlignment", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, defaultValue: { classPropertyName: "defaultValue", publicName: "defaultValue", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", onValueChange: "onValueChange", onValueCommitted: "onValueCommitted" }, host: { attributes: { "role": "group" }, properties: { "id": "id()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.dir": "dir()", "attr.data-orientation": "orientation()", "attr.data-disabled": "isDisabled() ? \"\" : undefined", "attr.data-dragging": "dragging() ? \"\" : undefined" } }, providers: [provideSliderRootContext(() => inject(RdxSliderRoot))], exportAs: ["rdxSliderRoot"], hostDirectives: [{ directive: i1.RdxControlValueAccessor, inputs: ["value", "value", "disabled", "disabled"] }], ngImport: i0 }); }
|
|
768
958
|
}
|
|
769
959
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxSliderRoot, decorators: [{
|
|
770
960
|
type: Directive,
|
|
@@ -788,7 +978,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
788
978
|
'[attr.data-dragging]': 'dragging() ? "" : undefined'
|
|
789
979
|
}
|
|
790
980
|
}]
|
|
791
|
-
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], largeStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "largeStep", required: false }] }], minStepsBetweenValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "minStepsBetweenValues", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }],
|
|
981
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], largeStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "largeStep", required: false }] }], minStepsBetweenValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "minStepsBetweenValues", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], dirInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "dir", required: false }] }], thumbCollisionBehavior: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbCollisionBehavior", required: false }] }], thumbAlignment: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbAlignment", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], form: [{ type: i0.Input, args: [{ isSignal: true, alias: "form", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], defaultValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultValue", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], onValueChange: [{ type: i0.Output, args: ["onValueChange"] }], onValueCommitted: [{ type: i0.Output, args: ["onValueCommitted"] }] } });
|
|
792
982
|
|
|
793
983
|
/**
|
|
794
984
|
* A draggable handle. Render one per value; place an `input[rdxSliderThumbInput]`
|
|
@@ -817,12 +1007,15 @@ class RdxSliderThumb {
|
|
|
817
1007
|
const value = this.value();
|
|
818
1008
|
return value === undefined ? NaN : valueToPercent(value, this.root.min(), this.root.max());
|
|
819
1009
|
}, ...(ngDevMode ? [{ debugName: "percent" }] : /* istanbul ignore next */ []));
|
|
1010
|
+
this.insetPosition = signal(undefined, ...(ngDevMode ? [{ debugName: "insetPosition" }] : /* istanbul ignore next */ []));
|
|
820
1011
|
this.thumbStyle = computed(() => {
|
|
821
1012
|
const vertical = this.root.orientation() === 'vertical';
|
|
822
1013
|
const rtl = this.root.dir() === 'rtl';
|
|
823
1014
|
const startEdge = vertical ? 'bottom' : 'inset-inline-start';
|
|
824
1015
|
const crossOffset = vertical ? 'left' : 'top';
|
|
825
1016
|
const percent = this.percent();
|
|
1017
|
+
const inset = this.root.inset();
|
|
1018
|
+
const position = this.insetPosition();
|
|
826
1019
|
if (!Number.isFinite(percent)) {
|
|
827
1020
|
return { position: 'absolute', visibility: 'hidden' };
|
|
828
1021
|
}
|
|
@@ -841,10 +1034,13 @@ class RdxSliderThumb {
|
|
|
841
1034
|
}
|
|
842
1035
|
const style = {
|
|
843
1036
|
position: 'absolute',
|
|
844
|
-
[startEdge]: `${percent}%`,
|
|
1037
|
+
[startEdge]: inset ? `${position ?? 0}%` : `${percent}%`,
|
|
845
1038
|
[crossOffset]: '50%',
|
|
846
1039
|
translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`
|
|
847
1040
|
};
|
|
1041
|
+
if (inset && position === undefined) {
|
|
1042
|
+
style['visibility'] = 'hidden';
|
|
1043
|
+
}
|
|
848
1044
|
if (zIndex !== undefined) {
|
|
849
1045
|
style['z-index'] = zIndex;
|
|
850
1046
|
}
|
|
@@ -853,7 +1049,44 @@ class RdxSliderThumb {
|
|
|
853
1049
|
// Registration is DOM-order sorted on the root and reads no inputs, so the constructor
|
|
854
1050
|
// (where the host element already exists) is the right place; cleanup goes via DestroyRef.
|
|
855
1051
|
this.root.registerThumb(this);
|
|
856
|
-
inject(DestroyRef)
|
|
1052
|
+
const destroyRef = inject(DestroyRef);
|
|
1053
|
+
destroyRef.onDestroy(() => this.root.unregisterThumb(this));
|
|
1054
|
+
afterNextRender(() => {
|
|
1055
|
+
const win = this.root.getOwnerWindow();
|
|
1056
|
+
const ResizeObserverCtor = win
|
|
1057
|
+
?.ResizeObserver;
|
|
1058
|
+
if (!ResizeObserverCtor) {
|
|
1059
|
+
this.updateInsetPosition();
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
const observer = new ResizeObserverCtor(() => this.updateInsetPosition());
|
|
1063
|
+
const control = this.root.controlRef();
|
|
1064
|
+
if (control) {
|
|
1065
|
+
observer.observe(control);
|
|
1066
|
+
}
|
|
1067
|
+
observer.observe(this.element);
|
|
1068
|
+
destroyRef.onDestroy(() => observer.disconnect());
|
|
1069
|
+
});
|
|
1070
|
+
afterRenderEffect(() => {
|
|
1071
|
+
this.root.inset();
|
|
1072
|
+
this.percent();
|
|
1073
|
+
this.index();
|
|
1074
|
+
this.root.values();
|
|
1075
|
+
untracked(() => queueMicrotask(() => this.updateInsetPosition()));
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
updateInsetPosition() {
|
|
1079
|
+
if (!this.root.inset()) {
|
|
1080
|
+
this.insetPosition.set(undefined);
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
const control = this.root.controlRef();
|
|
1084
|
+
if (!control) {
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
const position = getInsetThumbPositionPercent(control, this.element, this.percent(), this.root.orientation() === 'vertical');
|
|
1088
|
+
this.insetPosition.set(position);
|
|
1089
|
+
this.root.setIndicatorPosition(this.index(), position);
|
|
857
1090
|
}
|
|
858
1091
|
onPointerDown(event) {
|
|
859
1092
|
if (this.disabled()) {
|
|
@@ -918,7 +1151,7 @@ class RdxSliderThumbInput {
|
|
|
918
1151
|
onChange(event) {
|
|
919
1152
|
const value = event.target.valueAsNumber;
|
|
920
1153
|
if (!Number.isNaN(value)) {
|
|
921
|
-
this.root.handleInputChange(value, this.thumb.index(), 'input');
|
|
1154
|
+
this.root.handleInputChange(value, this.thumb.index(), 'input-change', event);
|
|
922
1155
|
}
|
|
923
1156
|
}
|
|
924
1157
|
onFocus() {
|
|
@@ -981,7 +1214,7 @@ class RdxSliderThumbInput {
|
|
|
981
1214
|
break;
|
|
982
1215
|
}
|
|
983
1216
|
if (newValue !== null) {
|
|
984
|
-
this.root.handleInputChange(newValue, index, 'keyboard');
|
|
1217
|
+
this.root.handleInputChange(newValue, index, 'keyboard', event);
|
|
985
1218
|
event.preventDefault();
|
|
986
1219
|
}
|
|
987
1220
|
}
|
|
@@ -1113,5 +1346,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
1113
1346
|
* Generated bundle index. Do not edit.
|
|
1114
1347
|
*/
|
|
1115
1348
|
|
|
1116
|
-
export { ALL_KEYS, ARROW_KEYS, COMPOSITE_KEYS, RdxSliderControl, RdxSliderIndicator, RdxSliderModule, RdxSliderRoot, RdxSliderThumb, RdxSliderThumbInput, RdxSliderTrack, RdxSliderValue, areValuesEqual, asc, formatNumber, getControlOffset, getDecimalPrecision, getDefaultAriaValueText, getMidpoint, getNewValue, getPushedThumbValues, getSliderValue, injectSliderRootContext, provideSliderRootContext, replaceArrayItemAtIndex, resolveThumbCollision, roundValueToStep, validateMinimumDistance, valueArrayToPercentages, valueToPercent };
|
|
1349
|
+
export { ALL_KEYS, ARROW_KEYS, COMPOSITE_KEYS, RdxSliderControl, RdxSliderIndicator, RdxSliderModule, RdxSliderRoot, RdxSliderThumb, RdxSliderThumbInput, RdxSliderTrack, RdxSliderValue, areValuesEqual, asc, formatNumber, getControlOffset, getDecimalPrecision, getDefaultAriaValueText, getInsetThumbPositionPercent, getMidpoint, getNewValue, getPushedThumbValues, getSliderValue, injectSliderRootContext, provideSliderRootContext, replaceArrayItemAtIndex, resolveThumbCollision, roundValueToStep, validateMinimumDistance, valueArrayToPercentages, valueToPercent };
|
|
1117
1350
|
//# sourceMappingURL=radix-ng-primitives-slider.mjs.map
|