@radix-ng/primitives 0.16.0 → 0.18.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.
Files changed (203) hide show
  1. package/checkbox/src/checkbox-input.directive.d.ts +2 -1
  2. package/compodoc/documentation.json +7419 -2200
  3. package/esm2022/accordion/index.mjs +4 -4
  4. package/esm2022/accordion/src/accordion-content.directive.mjs +3 -3
  5. package/esm2022/accordion/src/accordion-header.directive.mjs +3 -3
  6. package/esm2022/accordion/src/accordion-item.directive.mjs +3 -3
  7. package/esm2022/accordion/src/accordion-root.directive.mjs +3 -3
  8. package/esm2022/accordion/src/accordion-trigger.directive.mjs +3 -3
  9. package/esm2022/alert-dialog/index.mjs +4 -4
  10. package/esm2022/alert-dialog/src/alert-dialog-cancel.directive.mjs +3 -3
  11. package/esm2022/alert-dialog/src/alert-dialog-content.directive.mjs +3 -3
  12. package/esm2022/alert-dialog/src/alert-dialog-root.directive.mjs +3 -3
  13. package/esm2022/alert-dialog/src/alert-dialog-title.directive.mjs +3 -3
  14. package/esm2022/alert-dialog/src/alert-dialog-trigger.directive.mjs +3 -3
  15. package/esm2022/alert-dialog/src/alert-dialog.service.mjs +3 -3
  16. package/esm2022/aspect-ratio/src/aspect-ratio.directive.mjs +3 -3
  17. package/esm2022/avatar/src/avatar-fallback.directive.mjs +3 -3
  18. package/esm2022/avatar/src/avatar-image.directive.mjs +3 -3
  19. package/esm2022/avatar/src/avatar-root.directive.mjs +3 -3
  20. package/esm2022/checkbox/src/checkbox-button.directive.mjs +3 -3
  21. package/esm2022/checkbox/src/checkbox-indicator.directive.mjs +3 -3
  22. package/esm2022/checkbox/src/checkbox-input.directive.mjs +7 -4
  23. package/esm2022/checkbox/src/checkbox.directive.mjs +3 -3
  24. package/esm2022/collapsible/src/collapsible-content.directive.mjs +3 -3
  25. package/esm2022/collapsible/src/collapsible-root.directive.mjs +3 -3
  26. package/esm2022/collapsible/src/collapsible-trigger.directive.mjs +3 -3
  27. package/esm2022/context-menu/index.mjs +4 -4
  28. package/esm2022/context-menu/src/context-menu-content.directive.mjs +3 -3
  29. package/esm2022/context-menu/src/context-menu-item-checkbox.directive.mjs +3 -3
  30. package/esm2022/context-menu/src/context-menu-item-indicator.directive.mjs +3 -3
  31. package/esm2022/context-menu/src/context-menu-item-radio-group.directive.mjs +3 -3
  32. package/esm2022/context-menu/src/context-menu-item-radio.directive.mjs +3 -3
  33. package/esm2022/context-menu/src/context-menu-item-selectable.mjs +3 -3
  34. package/esm2022/context-menu/src/context-menu-item.directive.mjs +3 -3
  35. package/esm2022/context-menu/src/context-menu-label.directive.mjs +3 -3
  36. package/esm2022/context-menu/src/context-menu-separator.directive.mjs +3 -3
  37. package/esm2022/context-menu/src/context-menu-trigger.directive.mjs +3 -3
  38. package/esm2022/core/src/auto-focus.directive.mjs +3 -3
  39. package/esm2022/dialog/index.mjs +4 -4
  40. package/esm2022/dialog/src/dialog-close.directive.mjs +3 -3
  41. package/esm2022/dialog/src/dialog-content.directive.mjs +3 -3
  42. package/esm2022/dialog/src/dialog-description.directive.mjs +3 -3
  43. package/esm2022/dialog/src/dialog-dismiss.directive.mjs +3 -3
  44. package/esm2022/dialog/src/dialog-title.directive.mjs +3 -3
  45. package/esm2022/dialog/src/dialog-trigger.directive.mjs +3 -3
  46. package/esm2022/dialog/src/dialog.service.mjs +3 -3
  47. package/esm2022/dropdown-menu/index.mjs +4 -4
  48. package/esm2022/dropdown-menu/src/dropdown-menu-content.directive.mjs +3 -3
  49. package/esm2022/dropdown-menu/src/dropdown-menu-item-checkbox.directive.mjs +3 -3
  50. package/esm2022/dropdown-menu/src/dropdown-menu-item-indicator.directive.mjs +3 -3
  51. package/esm2022/dropdown-menu/src/dropdown-menu-item-radio-group.directive.mjs +3 -3
  52. package/esm2022/dropdown-menu/src/dropdown-menu-item-radio.directive.mjs +3 -3
  53. package/esm2022/dropdown-menu/src/dropdown-menu-item-selectable.mjs +3 -3
  54. package/esm2022/dropdown-menu/src/dropdown-menu-item.directive.mjs +3 -3
  55. package/esm2022/dropdown-menu/src/dropdown-menu-label.directive.mjs +3 -3
  56. package/esm2022/dropdown-menu/src/dropdown-menu-separator.directive.mjs +3 -3
  57. package/esm2022/dropdown-menu/src/dropdown-menu-trigger.directive.mjs +3 -3
  58. package/esm2022/label/src/label.directive.mjs +3 -3
  59. package/esm2022/menu/index.mjs +4 -4
  60. package/esm2022/menu/src/menu-content.directive.mjs +3 -3
  61. package/esm2022/menu/src/menu-directive.mjs +3 -3
  62. package/esm2022/menu/src/menu-group.directive.mjs +3 -3
  63. package/esm2022/menu/src/menu-item.directive.mjs +3 -3
  64. package/esm2022/menu/src/menu-label.directive.mjs +3 -3
  65. package/esm2022/menu/src/menu-separator.directive.mjs +3 -3
  66. package/esm2022/menubar/index.mjs +4 -4
  67. package/esm2022/menubar/src/menubar-content.directive.mjs +3 -3
  68. package/esm2022/menubar/src/menubar-item-checkbox.directive.mjs +3 -3
  69. package/esm2022/menubar/src/menubar-item-indicator.directive.mjs +3 -3
  70. package/esm2022/menubar/src/menubar-item-radio.directive.mjs +3 -3
  71. package/esm2022/menubar/src/menubar-item.directive.mjs +3 -3
  72. package/esm2022/menubar/src/menubar-radio-group.directive.mjs +3 -3
  73. package/esm2022/menubar/src/menubar-root.directive.mjs +3 -3
  74. package/esm2022/menubar/src/menubar-separator.directive.mjs +3 -3
  75. package/esm2022/menubar/src/menubar-trigger.directive.mjs +3 -3
  76. package/esm2022/progress/index.mjs +4 -4
  77. package/esm2022/progress/src/progress-indicator.directive.mjs +3 -3
  78. package/esm2022/progress/src/progress-root.directive.mjs +3 -3
  79. package/esm2022/radio/src/radio-indicator.directive.mjs +3 -3
  80. package/esm2022/radio/src/radio-item.directive.mjs +3 -3
  81. package/esm2022/radio/src/radio-root.directive.mjs +3 -3
  82. package/esm2022/select/index.mjs +65 -0
  83. package/esm2022/select/radix-ng-primitives-select.mjs +5 -0
  84. package/esm2022/select/src/select-content.directive.mjs +53 -0
  85. package/esm2022/select/src/select-group.directive.mjs +18 -0
  86. package/esm2022/select/src/select-icon.directive.mjs +18 -0
  87. package/esm2022/select/src/select-item-indicator.directive.mjs +23 -0
  88. package/esm2022/select/src/select-item.directive.mjs +116 -0
  89. package/esm2022/select/src/select-label.directive.mjs +15 -0
  90. package/esm2022/select/src/select-separator.directive.mjs +18 -0
  91. package/esm2022/select/src/select-trigger.directive.mjs +38 -0
  92. package/esm2022/select/src/select-value.directive.mjs +21 -0
  93. package/esm2022/select/src/select.component.mjs +234 -0
  94. package/esm2022/separator/src/separator.directive.mjs +3 -3
  95. package/esm2022/slider/index.mjs +28 -0
  96. package/esm2022/slider/radix-ng-primitives-slider.mjs +5 -0
  97. package/esm2022/slider/src/slider-horizontal.component.mjs +117 -0
  98. package/esm2022/slider/src/slider-impl.directive.mjs +89 -0
  99. package/esm2022/slider/src/slider-orientation-context.service.mjs +28 -0
  100. package/esm2022/slider/src/slider-range.component.mjs +41 -0
  101. package/esm2022/slider/src/slider-root.component.mjs +207 -0
  102. package/esm2022/slider/src/slider-thumb-impl.directive.mjs +102 -0
  103. package/esm2022/slider/src/slider-thumb.component.mjs +22 -0
  104. package/esm2022/slider/src/slider-track.component.mjs +27 -0
  105. package/esm2022/slider/src/slider-vertical.component.mjs +117 -0
  106. package/esm2022/slider/src/utils.mjs +94 -0
  107. package/esm2022/switch/index.mjs +4 -4
  108. package/esm2022/switch/src/switch-input.directive.mjs +3 -3
  109. package/esm2022/switch/src/switch-root.directive.mjs +3 -3
  110. package/esm2022/switch/src/switch-thumb.directive.mjs +3 -3
  111. package/esm2022/tabs/index.mjs +4 -4
  112. package/esm2022/tabs/src/tabs-content.directive.mjs +3 -3
  113. package/esm2022/tabs/src/tabs-context.service.mjs +3 -3
  114. package/esm2022/tabs/src/tabs-list.directive.mjs +3 -3
  115. package/esm2022/tabs/src/tabs-root.directive.mjs +3 -3
  116. package/esm2022/tabs/src/tabs-trigger.directive.mjs +3 -3
  117. package/esm2022/toggle/src/toggle-input.directive.mjs +3 -3
  118. package/esm2022/toggle/src/toggle.directive.mjs +3 -3
  119. package/esm2022/toggle-group/src/toggle-group-item.directive.mjs +3 -3
  120. package/esm2022/toggle-group/src/toggle-group-multiple.directive.mjs +3 -3
  121. package/esm2022/toggle-group/src/toggle-group.directive.mjs +3 -3
  122. package/esm2022/tooltip/index.mjs +41 -0
  123. package/esm2022/tooltip/radix-ng-primitives-tooltip.mjs +5 -0
  124. package/esm2022/tooltip/src/get-content-position.mjs +31 -0
  125. package/esm2022/tooltip/src/tooltip-arrow.directive.mjs +92 -0
  126. package/esm2022/tooltip/src/tooltip-arrow.token.mjs +3 -0
  127. package/esm2022/tooltip/src/tooltip-content-attributes.directive.mjs +24 -0
  128. package/esm2022/tooltip/src/tooltip-content.directive.mjs +48 -0
  129. package/esm2022/tooltip/src/tooltip-content.token.mjs +3 -0
  130. package/esm2022/tooltip/src/tooltip-root.directive.mjs +288 -0
  131. package/esm2022/tooltip/src/tooltip-trigger.directive.mjs +70 -0
  132. package/esm2022/tooltip/src/tooltip.config.mjs +18 -0
  133. package/esm2022/tooltip/src/tooltip.constants.mjs +84 -0
  134. package/esm2022/tooltip/src/tooltip.types.mjs +14 -0
  135. package/esm2022/visually-hidden/src/visually-hidden-input-bubble.directive.mjs +3 -3
  136. package/esm2022/visually-hidden/src/visually-hidden-input.directive.mjs +3 -3
  137. package/esm2022/visually-hidden/src/visually-hidden.directive.mjs +3 -3
  138. package/fesm2022/radix-ng-primitives-accordion.mjs +19 -19
  139. package/fesm2022/radix-ng-primitives-alert-dialog.mjs +22 -22
  140. package/fesm2022/radix-ng-primitives-aspect-ratio.mjs +3 -3
  141. package/fesm2022/radix-ng-primitives-avatar.mjs +9 -9
  142. package/fesm2022/radix-ng-primitives-checkbox.mjs +15 -12
  143. package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
  144. package/fesm2022/radix-ng-primitives-collapsible.mjs +9 -9
  145. package/fesm2022/radix-ng-primitives-context-menu.mjs +34 -34
  146. package/fesm2022/radix-ng-primitives-core.mjs +3 -3
  147. package/fesm2022/radix-ng-primitives-dialog.mjs +25 -25
  148. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +34 -34
  149. package/fesm2022/radix-ng-primitives-label.mjs +3 -3
  150. package/fesm2022/radix-ng-primitives-menu.mjs +22 -22
  151. package/fesm2022/radix-ng-primitives-menubar.mjs +31 -31
  152. package/fesm2022/radix-ng-primitives-progress.mjs +10 -10
  153. package/fesm2022/radix-ng-primitives-radio.mjs +9 -9
  154. package/fesm2022/radix-ng-primitives-select.mjs +572 -0
  155. package/fesm2022/radix-ng-primitives-select.mjs.map +1 -0
  156. package/fesm2022/radix-ng-primitives-separator.mjs +3 -3
  157. package/fesm2022/radix-ng-primitives-slider.mjs +830 -0
  158. package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -0
  159. package/fesm2022/radix-ng-primitives-switch.mjs +13 -13
  160. package/fesm2022/radix-ng-primitives-tabs.mjs +19 -19
  161. package/fesm2022/radix-ng-primitives-toggle-group.mjs +9 -9
  162. package/fesm2022/radix-ng-primitives-toggle.mjs +6 -6
  163. package/fesm2022/radix-ng-primitives-tooltip.mjs +684 -0
  164. package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -0
  165. package/fesm2022/radix-ng-primitives-visually-hidden.mjs +9 -9
  166. package/package.json +19 -1
  167. package/select/README.md +1 -0
  168. package/select/index.d.ts +26 -0
  169. package/select/src/select-content.directive.d.ts +20 -0
  170. package/select/src/select-group.directive.d.ts +5 -0
  171. package/select/src/select-icon.directive.d.ts +5 -0
  172. package/select/src/select-item-indicator.directive.d.ts +7 -0
  173. package/select/src/select-item.directive.d.ts +47 -0
  174. package/select/src/select-label.directive.d.ts +5 -0
  175. package/select/src/select-separator.directive.d.ts +5 -0
  176. package/select/src/select-trigger.directive.d.ts +11 -0
  177. package/select/src/select-value.directive.d.ts +8 -0
  178. package/select/src/select.component.d.ts +81 -0
  179. package/slider/README.md +1 -0
  180. package/slider/index.d.ts +18 -0
  181. package/slider/src/slider-horizontal.component.d.ts +29 -0
  182. package/slider/src/slider-impl.directive.d.ts +18 -0
  183. package/slider/src/slider-orientation-context.service.d.ts +14 -0
  184. package/slider/src/slider-range.component.d.ts +13 -0
  185. package/slider/src/slider-root.component.d.ts +47 -0
  186. package/slider/src/slider-thumb-impl.directive.d.ts +26 -0
  187. package/slider/src/slider-thumb.component.d.ts +6 -0
  188. package/slider/src/slider-track.component.d.ts +7 -0
  189. package/slider/src/slider-vertical.component.d.ts +29 -0
  190. package/slider/src/utils.d.ts +52 -0
  191. package/tooltip/README.md +1 -0
  192. package/tooltip/index.d.ts +17 -0
  193. package/tooltip/src/get-content-position.d.ts +3 -0
  194. package/tooltip/src/tooltip-arrow.directive.d.ts +25 -0
  195. package/tooltip/src/tooltip-arrow.token.d.ts +3 -0
  196. package/tooltip/src/tooltip-content-attributes.directive.d.ts +8 -0
  197. package/tooltip/src/tooltip-content.directive.d.ts +36 -0
  198. package/tooltip/src/tooltip-content.token.d.ts +3 -0
  199. package/tooltip/src/tooltip-root.directive.d.ts +103 -0
  200. package/tooltip/src/tooltip-trigger.directive.d.ts +26 -0
  201. package/tooltip/src/tooltip.config.d.ts +6 -0
  202. package/tooltip/src/tooltip.constants.d.ts +9 -0
  203. package/tooltip/src/tooltip.types.d.ts +18 -0
@@ -0,0 +1,830 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, EventEmitter, Directive, Output, input, booleanAttribute, viewChild, signal, Component, Input, Injectable, numberAttribute, model, computed, ElementRef, NgModule } from '@angular/core';
3
+ import { NgIf, NgTemplateOutlet } 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.isMounted = signal(false);
676
+ this.thumbIndex = computed(() => {
677
+ const thumbElement = this.elementRef.nativeElement;
678
+ const index = this.rootContext.thumbElements.indexOf(thumbElement);
679
+ return index >= 0 ? index : null;
680
+ });
681
+ this.value = computed(() => {
682
+ const index = this.thumbIndex();
683
+ if (index === null)
684
+ return undefined;
685
+ return this.rootContext.modelValue()?.[index];
686
+ });
687
+ this.percent = computed(() => {
688
+ const val = this.value();
689
+ if (val === undefined)
690
+ return 0;
691
+ return convertValueToPercentage(val, this.rootContext.min(), this.rootContext.max());
692
+ });
693
+ this.transform = computed(() => {
694
+ const percent = this.percent();
695
+ const offset = this.thumbInBoundsOffset();
696
+ return `calc(${percent}% + ${offset}px)`;
697
+ });
698
+ this.orientationSize = signal(0);
699
+ this.thumbInBoundsOffset = computed(() => {
700
+ const context = this.rootContext.orientationContext.context;
701
+ const size = this.orientationSize();
702
+ const percent = this.percent();
703
+ const direction = context.direction;
704
+ return size ? getThumbInBoundsOffset(size, percent, direction) : 0;
705
+ });
706
+ this.combinedStyles = computed(() => {
707
+ const context = this.rootContext.orientationContext.context;
708
+ const startEdge = context.startEdge;
709
+ const percent = this.percent();
710
+ const offset = this.thumbInBoundsOffset();
711
+ return {
712
+ position: 'absolute',
713
+ transform: 'var(--rdx-slider-thumb-transform)',
714
+ display: (this.isMounted() && this.value()) === false ? 'none' : undefined,
715
+ [startEdge]: `calc(${percent}% + ${offset}px)`
716
+ };
717
+ });
718
+ }
719
+ onFocus() {
720
+ if (this.thumbIndex() !== null) {
721
+ this.rootContext.valueIndexToChange.set(this.thumbIndex());
722
+ }
723
+ }
724
+ ngOnInit() {
725
+ const thumbElement = this.elementRef.nativeElement;
726
+ this.rootContext.thumbElements.push(thumbElement);
727
+ this.resizeObserver = new ResizeObserver(() => {
728
+ const rect = thumbElement.getBoundingClientRect();
729
+ const context = this.rootContext.orientationContext.context;
730
+ const size = context.size === 'width' ? rect.width : rect.height;
731
+ this.orientationSize.set(size);
732
+ });
733
+ this.resizeObserver.observe(thumbElement);
734
+ this.isMounted.set(true);
735
+ }
736
+ ngOnDestroy() {
737
+ const thumbElement = this.elementRef.nativeElement;
738
+ const index = this.rootContext.thumbElements.indexOf(thumbElement);
739
+ if (index >= 0)
740
+ this.rootContext.thumbElements.splice(index, 1);
741
+ if (this.resizeObserver) {
742
+ this.resizeObserver.unobserve(thumbElement);
743
+ }
744
+ this.isMounted.set(false);
745
+ }
746
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderThumbImplDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
747
+ 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 }); }
748
+ }
749
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderThumbImplDirective, decorators: [{
750
+ type: Directive,
751
+ args: [{
752
+ selector: '[rdxSliderThumbImpl]',
753
+ standalone: true,
754
+ host: {
755
+ role: 'slider',
756
+ '[tabindex]': 'rootContext.disabled() ? undefined : 0',
757
+ '[attr.aria-valuenow]': 'rootContext.modelValue()',
758
+ '[attr.aria-valuemin]': 'rootContext.min()',
759
+ '[attr.aria-valuemax]': 'rootContext.max()',
760
+ '[attr.aria-orientation]': 'rootContext.orientation()',
761
+ '[attr.data-orientation]': 'rootContext.orientation()',
762
+ '[attr.data-disabled]': 'rootContext.disabled() ? "" : undefined',
763
+ '[style]': 'combinedStyles()',
764
+ '(focus)': 'onFocus()'
765
+ }
766
+ }]
767
+ }] });
768
+
769
+ class RdxSliderThumbComponent {
770
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderThumbComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
771
+ 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: `
772
+ <ng-content />
773
+ `, isInline: true }); }
774
+ }
775
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderThumbComponent, decorators: [{
776
+ type: Component,
777
+ args: [{
778
+ selector: 'rdx-slider-thumb',
779
+ standalone: true,
780
+ hostDirectives: [RdxSliderThumbImplDirective],
781
+ template: `
782
+ <ng-content />
783
+ `
784
+ }]
785
+ }] });
786
+
787
+ class RdxSliderTrackComponent {
788
+ constructor() {
789
+ this.rootContext = inject(RdxSliderRootComponent);
790
+ }
791
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderTrackComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
792
+ 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: `
793
+ <ng-content />
794
+ `, isInline: true }); }
795
+ }
796
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderTrackComponent, decorators: [{
797
+ type: Component,
798
+ args: [{
799
+ selector: 'rdx-slider-track',
800
+ standalone: true,
801
+ host: {
802
+ '[attr.data-disabled]': "rootContext.disabled() ? '' : undefined",
803
+ '[attr.data-orientation]': 'rootContext.orientation()'
804
+ },
805
+ template: `
806
+ <ng-content />
807
+ `
808
+ }]
809
+ }] });
810
+
811
+ const _imports = [RdxSliderRootComponent, RdxSliderTrackComponent, RdxSliderRangeComponent, RdxSliderThumbComponent];
812
+ class RdxSliderModule {
813
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
814
+ 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] }); }
815
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderModule }); }
816
+ }
817
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxSliderModule, decorators: [{
818
+ type: NgModule,
819
+ args: [{
820
+ imports: [..._imports],
821
+ exports: [..._imports]
822
+ }]
823
+ }] });
824
+
825
+ /**
826
+ * Generated bundle index. Do not edit.
827
+ */
828
+
829
+ export { RdxSliderHorizontalComponent, RdxSliderImplDirective, RdxSliderModule, RdxSliderRangeComponent, RdxSliderRootComponent, RdxSliderThumbComponent, RdxSliderThumbImplDirective, RdxSliderTrackComponent, RdxSliderVerticalComponent };
830
+ //# sourceMappingURL=radix-ng-primitives-slider.mjs.map