@nanahoshi/mona-ui 0.24.10 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/chart/README.md +223 -77
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +11 -10
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +37 -20
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +239 -47
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +184 -31
- package/fesm2022/nanahoshi-mona-ui-button.mjs +47 -11
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +17 -13
- package/fesm2022/nanahoshi-mona-ui-card.mjs +54 -30
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +1909 -666
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +112 -31
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +131 -89
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +59 -19
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +118 -41
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +243 -212
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +155 -86
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +161 -131
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +12 -11
- package/fesm2022/nanahoshi-mona-ui-common.mjs +18 -1
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +25 -24
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +202 -33
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +31 -10
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1 -1
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs → nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs → nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs} +7 -7
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs} +27 -29
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +146 -5
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +7 -7
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +183 -47
- package/fesm2022/nanahoshi-mona-ui-label.mjs +111 -15
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +111 -5
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +100 -6
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +105 -5
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +14 -13
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +13 -12
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +192 -56
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +3 -1
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +60 -29
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +334 -37
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +84 -30
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +274 -108
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +127 -37
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +595 -170
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +323 -166
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +167 -82
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +3 -3
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +273 -165
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +219 -132
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +84 -32
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +337 -116
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +10 -12
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +21 -8
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +444 -88
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +15 -14
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +17 -3
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1 -1
- package/i18n/catalogs/en-US.messages.json +90 -5
- package/locales/ar-sa/ar-sa.messages.json +90 -5
- package/locales/de-de/de-de.messages.json +90 -5
- package/locales/es-es/es-es.messages.json +90 -5
- package/locales/fr-fr/fr-fr.messages.json +91 -6
- package/locales/id-id/id-id.messages.json +90 -5
- package/locales/it-it/it-it.messages.json +90 -5
- package/locales/ja-jp/ja-jp.messages.json +90 -5
- package/locales/ko-kr/ko-kr.messages.json +90 -5
- package/locales/pt-br/pt-br.messages.json +90 -5
- package/locales/ru-ru/ru-ru.messages.json +90 -5
- package/locales/tr-tr/tr-tr.messages.json +90 -5
- package/locales/zh-cn/zh-cn.messages.json +90 -5
- package/locales/zh-tw/zh-tw.messages.json +90 -5
- package/package.json +2 -1
- package/styles.css +156 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +18 -11
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +62 -14
- package/types/nanahoshi-mona-ui-button-group.d.ts +86 -16
- package/types/nanahoshi-mona-ui-button.d.ts +26 -3
- package/types/nanahoshi-mona-ui-calendar.d.ts +1 -0
- package/types/nanahoshi-mona-ui-card.d.ts +22 -6
- package/types/nanahoshi-mona-ui-chart.d.ts +519 -527
- package/types/nanahoshi-mona-ui-check-box.d.ts +54 -13
- package/types/nanahoshi-mona-ui-chip.d.ts +31 -18
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +21 -5
- package/types/nanahoshi-mona-ui-collapsible.d.ts +20 -11
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +62 -36
- package/types/nanahoshi-mona-ui-color-palette.d.ts +65 -27
- package/types/nanahoshi-mona-ui-color-picker.d.ts +64 -23
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-common.d.ts +28 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +1 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +51 -7
- package/types/nanahoshi-mona-ui-fieldset.d.ts +18 -4
- package/types/nanahoshi-mona-ui-grid.d.ts +0 -1
- package/types/nanahoshi-mona-ui-i18n.d.ts +130 -3
- package/types/nanahoshi-mona-ui-internal.d.ts +95 -14
- package/types/nanahoshi-mona-ui-label.d.ts +17 -2
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +85 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +1 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-otp-input.d.ts +49 -12
- package/types/nanahoshi-mona-ui-placeholder.d.ts +2 -1
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +21 -9
- package/types/nanahoshi-mona-ui-radio-button.d.ts +165 -20
- package/types/nanahoshi-mona-ui-rating.d.ts +21 -6
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +59 -27
- package/types/nanahoshi-mona-ui-segmented.d.ts +52 -24
- package/types/nanahoshi-mona-ui-sidebar.d.ts +104 -41
- package/types/nanahoshi-mona-ui-skeleton.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +99 -35
- package/types/nanahoshi-mona-ui-spinner.d.ts +9 -5
- package/types/nanahoshi-mona-ui-splitter.d.ts +31 -10
- package/types/nanahoshi-mona-ui-stepper.d.ts +58 -12
- package/types/nanahoshi-mona-ui-switch.d.ts +32 -10
- package/types/nanahoshi-mona-ui-tabs.d.ts +75 -20
- package/types/nanahoshi-mona-ui-text-area.d.ts +7 -7
- package/types/nanahoshi-mona-ui-text-box.d.ts +2 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +392 -15
- package/types/nanahoshi-mona-ui-time-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +1 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +7 -1
|
@@ -1,26 +1,12 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import {
|
|
3
|
+
import { Pipe, Directive, inject, DOCUMENT, computed, DestroyRef, signal, contentChild, TemplateRef, ElementRef, NgZone, input, booleanAttribute, output, afterNextRender, isDevMode, effect, viewChild, model, Component } from '@angular/core';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
-
import { fromEvent,
|
|
5
|
+
import { fromEvent, filter, tap, switchMap, merge, takeUntil } from 'rxjs';
|
|
6
|
+
import { themeRaisedSurfaceClasses, injectLabelAssociation, injectEffectiveDisabled, createElementControlId } from '@nanahoshi/mona-ui/internal';
|
|
6
7
|
import { twMerge } from 'tailwind-merge';
|
|
7
|
-
import { injectComponentDirection, MonaI18nService } from '@nanahoshi/mona-ui/i18n';
|
|
8
|
+
import { injectComponentDirection, MonaI18nService, formatNumber } from '@nanahoshi/mona-ui/i18n';
|
|
8
9
|
import { cva } from 'class-variance-authority';
|
|
9
|
-
import { themeRaisedSurfaceClasses } from '@nanahoshi/mona-ui/internal';
|
|
10
|
-
|
|
11
|
-
class SliderTickDirective {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.host = inject(ElementRef);
|
|
14
|
-
}
|
|
15
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderTickDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
16
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SliderTickDirective, isStandalone: true, selector: "span[monaSliderTick]", ngImport: i0 }); }
|
|
17
|
-
}
|
|
18
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderTickDirective, decorators: [{
|
|
19
|
-
type: Directive,
|
|
20
|
-
args: [{
|
|
21
|
-
selector: "span[monaSliderTick]"
|
|
22
|
-
}]
|
|
23
|
-
}] });
|
|
24
10
|
|
|
25
11
|
const valueToPosition = (value, min, max) => {
|
|
26
12
|
if (value <= min) {
|
|
@@ -153,6 +139,9 @@ const SLIDER_DEFAULT_MESSAGES = {
|
|
|
153
139
|
};
|
|
154
140
|
|
|
155
141
|
class SliderHandleTemplateDirective {
|
|
142
|
+
static ngTemplateContextGuard(_directive, _context) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
156
145
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderHandleTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
157
146
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SliderHandleTemplateDirective, isStandalone: true, selector: "ng-template[monaSliderHandleTemplate]", ngImport: i0 }); }
|
|
158
147
|
}
|
|
@@ -164,6 +153,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
164
153
|
}] });
|
|
165
154
|
|
|
166
155
|
class SliderTickValueTemplateDirective {
|
|
156
|
+
static ngTemplateContextGuard(_directive, _context) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
167
159
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderTickValueTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
168
160
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SliderTickValueTemplateDirective, isStandalone: true, selector: "ng-template[monaSliderTickValueTemplate]", ngImport: i0 }); }
|
|
169
161
|
}
|
|
@@ -189,11 +181,15 @@ const sliderBaseThemeVariants = cva(`
|
|
|
189
181
|
data-[disabled="true"]:pointer-events-none
|
|
190
182
|
data-[disabled="true"]:cursor-not-allowed
|
|
191
183
|
data-[disabled="true"]:opacity-50
|
|
184
|
+
|
|
185
|
+
data-[readonly="true"]:cursor-default
|
|
186
|
+
data-[readonly="true"]:[&_*]:cursor-default
|
|
192
187
|
`);
|
|
193
188
|
const sliderTrackThemeVariants = cva(`
|
|
194
189
|
relative z-2 cursor-pointer
|
|
195
190
|
overflow-hidden
|
|
196
191
|
bg-surface-muted text-foreground
|
|
192
|
+
border border-input-border
|
|
197
193
|
|
|
198
194
|
data-[orientation="horizontal"]:w-full
|
|
199
195
|
data-[orientation="horizontal"]:h-1.5
|
|
@@ -214,7 +210,8 @@ const sliderTrackThemeVariants = cva(`
|
|
|
214
210
|
});
|
|
215
211
|
const sliderSelectionThemeVariants = cva(`
|
|
216
212
|
absolute
|
|
217
|
-
bg-primary
|
|
213
|
+
bg-[var(--mona-indicator-color,var(--color-primary))]
|
|
214
|
+
forced-color-adjust-none forced-colors:bg-[Highlight]
|
|
218
215
|
border-none
|
|
219
216
|
transition duration-(--mona-motion-fast) ease-out
|
|
220
217
|
|
|
@@ -257,13 +254,14 @@ const sliderTickLabelThemeVariants = cva(`
|
|
|
257
254
|
const sliderHandleThemeVariants = cva(`
|
|
258
255
|
absolute z-2 flex items-center justify-center
|
|
259
256
|
h-4.25 w-4.25
|
|
260
|
-
cursor-pointer
|
|
257
|
+
cursor-pointer touch-none
|
|
258
|
+
before:absolute before:-inset-1 before:content-['']
|
|
261
259
|
${themeRaisedSurfaceClasses}
|
|
262
260
|
border border-(--mona-slider-handle-border-color) shadow-(--shadow-control)
|
|
263
|
-
outline-none
|
|
261
|
+
outline-none focus-visible:outline-hidden
|
|
264
262
|
transition duration-(--mona-motion-fast) ease-out
|
|
265
263
|
|
|
266
|
-
data-[orientation="horizontal"]:translate-x-[-50%] rtl:data-[orientation="horizontal"]:translate-x-[50%]
|
|
264
|
+
data-[orientation="horizontal"]:translate-x-[-50%] data-[rtl="true"]:data-[orientation="horizontal"]:translate-x-[50%]
|
|
267
265
|
data-[orientation="horizontal"]:transition-[left,right]
|
|
268
266
|
data-[orientation="horizontal"]:data-[dragging="true"]:transition-none
|
|
269
267
|
|
|
@@ -291,15 +289,49 @@ const sliderHandleThemeVariants = cva(`
|
|
|
291
289
|
}
|
|
292
290
|
});
|
|
293
291
|
|
|
292
|
+
/**
|
|
293
|
+
* @description Counts the decimal places a number is written with, including those of exponent notation such as `1e-7`.
|
|
294
|
+
*/
|
|
295
|
+
function decimalPlaces(value) {
|
|
296
|
+
if (!Number.isFinite(value)) {
|
|
297
|
+
return 0;
|
|
298
|
+
}
|
|
299
|
+
const [mantissa, exponent] = value.toString().split("e");
|
|
300
|
+
const decimals = mantissa.split(".")[1]?.length ?? 0;
|
|
301
|
+
return Math.max(0, decimals - Number(exponent ?? 0));
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* @description Rounds a number to a number of decimal places, which removes floating point noise such as
|
|
305
|
+
* `0.30000000000000004`.
|
|
306
|
+
*/
|
|
307
|
+
function roundToPlaces(value, places) {
|
|
308
|
+
return Number(value.toFixed(Math.min(places, 100)));
|
|
309
|
+
}
|
|
310
|
+
|
|
294
311
|
class SliderBaseComponent {
|
|
312
|
+
#document;
|
|
313
|
+
#label;
|
|
314
|
+
#stepPlaces;
|
|
295
315
|
constructor() {
|
|
316
|
+
this.#document = inject(DOCUMENT);
|
|
317
|
+
this.#label = injectLabelAssociation({
|
|
318
|
+
activate: () => this.focus(),
|
|
319
|
+
ariaLabel: () => this.ariaLabel(),
|
|
320
|
+
ariaLabelledBy: () => this.ariaLabelledBy()
|
|
321
|
+
});
|
|
322
|
+
this.#stepPlaces = computed(() => Math.max(decimalPlaces(this.step()), decimalPlaces(this.effectiveMin())), /* @ts-ignore */
|
|
323
|
+
...(ngDevMode ? [{ debugName: "#stepPlaces" }] : /* istanbul ignore next */ []));
|
|
296
324
|
this.baseClasses = computed(() => sliderBaseThemeVariants(), /* @ts-ignore */
|
|
297
325
|
...(ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []));
|
|
298
326
|
this.destroyRef = inject(DestroyRef);
|
|
327
|
+
this.direction = injectComponentDirection();
|
|
299
328
|
this.dragging = signal(false, /* @ts-ignore */
|
|
300
329
|
...(ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []));
|
|
301
|
-
this.effectiveDisabled =
|
|
302
|
-
|
|
330
|
+
this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
|
|
331
|
+
this.effectiveMax = computed(() => this.getMaxOverride() ?? this.maxValue(), /* @ts-ignore */
|
|
332
|
+
...(ngDevMode ? [{ debugName: "effectiveMax" }] : /* istanbul ignore next */ []));
|
|
333
|
+
this.effectiveMin = computed(() => this.getMinOverride() ?? this.minValue(), /* @ts-ignore */
|
|
334
|
+
...(ngDevMode ? [{ debugName: "effectiveMin" }] : /* istanbul ignore next */ []));
|
|
303
335
|
this.handleTemplate = contentChild(SliderHandleTemplateDirective, { ...(ngDevMode ? { debugName: "handleTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
304
336
|
this.handleTemplateStyles = computed(() => {
|
|
305
337
|
const template = this.handleTemplate();
|
|
@@ -309,16 +341,33 @@ class SliderBaseComponent {
|
|
|
309
341
|
return { background: "transparent", border: "none", boxShadow: "none" };
|
|
310
342
|
}, /* @ts-ignore */
|
|
311
343
|
...(ngDevMode ? [{ debugName: "handleTemplateStyles" }] : /* istanbul ignore next */ []));
|
|
312
|
-
this.
|
|
344
|
+
this.horizontalSelectionLeft = computed(() => {
|
|
345
|
+
if (this.orientation() !== "horizontal") {
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
348
|
+
return this.isRtl() ? 100 - this.selectionRight() : this.selectionLeft();
|
|
349
|
+
}, /* @ts-ignore */
|
|
350
|
+
...(ngDevMode ? [{ debugName: "horizontalSelectionLeft" }] : /* istanbul ignore next */ []));
|
|
351
|
+
this.horizontalSelectionRight = computed(() => {
|
|
352
|
+
if (this.orientation() !== "horizontal") {
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
355
|
+
return this.isRtl() ? this.selectionLeft() : 100 - this.selectionRight();
|
|
356
|
+
}, /* @ts-ignore */
|
|
357
|
+
...(ngDevMode ? [{ debugName: "horizontalSelectionRight" }] : /* istanbul ignore next */ []));
|
|
313
358
|
this.hostElementRef = inject(ElementRef);
|
|
314
359
|
this.i18n = inject(MonaI18nService);
|
|
360
|
+
this.interactionDisabled = computed(() => this.effectiveDisabled() || this.readonly(), /* @ts-ignore */
|
|
361
|
+
...(ngDevMode ? [{ debugName: "interactionDisabled" }] : /* istanbul ignore next */ []));
|
|
362
|
+
this.invalidState = computed(() => this.touched() && this.invalid(), /* @ts-ignore */
|
|
363
|
+
...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
|
|
315
364
|
this.isRtl = computed(() => this.direction() === "rtl", /* @ts-ignore */
|
|
316
365
|
...(ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []));
|
|
317
366
|
this.labelStyleArgs = computed(() => {
|
|
318
367
|
const direction = this.direction();
|
|
319
368
|
const labelPosition = this.labelPosition();
|
|
320
|
-
const max = this.
|
|
321
|
-
const min = this.
|
|
369
|
+
const max = this.effectiveMax();
|
|
370
|
+
const min = this.effectiveMin();
|
|
322
371
|
const orientation = this.orientation();
|
|
323
372
|
const tickCount = this.labelTicks().length;
|
|
324
373
|
return { direction, labelPosition, max, min, orientation, tickCount };
|
|
@@ -338,15 +387,20 @@ class SliderBaseComponent {
|
|
|
338
387
|
if (labels.length >= 2) {
|
|
339
388
|
const penultimate = labels[labels.length - 2];
|
|
340
389
|
const last = labels[labels.length - 1];
|
|
341
|
-
const penultimatePos = valueToPosition(penultimate.value, this.
|
|
342
|
-
const lastPos = valueToPosition(last.value, this.
|
|
390
|
+
const penultimatePos = valueToPosition(penultimate.value, this.effectiveMin(), this.effectiveMax());
|
|
391
|
+
const lastPos = valueToPosition(last.value, this.effectiveMin(), this.effectiveMax());
|
|
343
392
|
if (this.step() !== 1 && lastPos - penultimatePos < 4) {
|
|
344
393
|
labels.splice(labels.length - 2, 1);
|
|
345
394
|
}
|
|
346
395
|
}
|
|
347
|
-
|
|
396
|
+
const localeId = this.i18n.localeId();
|
|
397
|
+
return labels.map(tick => ({
|
|
398
|
+
...tick,
|
|
399
|
+
label: formatNumber(tick.value, localeId, { maximumFractionDigits: decimalPlaces(tick.value) })
|
|
400
|
+
}));
|
|
348
401
|
}, /* @ts-ignore */
|
|
349
402
|
...(ngDevMode ? [{ debugName: "labelTicks" }] : /* istanbul ignore next */ []));
|
|
403
|
+
this.labelledBy = this.#label.labelledBy;
|
|
350
404
|
this.renderTicks = computed(() => {
|
|
351
405
|
const ticks = this.ticks();
|
|
352
406
|
if (this.orientation() === "vertical") {
|
|
@@ -363,20 +417,6 @@ class SliderBaseComponent {
|
|
|
363
417
|
return typeof bg === "string" ? { background: bg } : bg;
|
|
364
418
|
}, /* @ts-ignore */
|
|
365
419
|
...(ngDevMode ? [{ debugName: "selectionBackgroundStyle" }] : /* istanbul ignore next */ []));
|
|
366
|
-
this.horizontalSelectionLeft = computed(() => {
|
|
367
|
-
if (this.orientation() !== "horizontal") {
|
|
368
|
-
return undefined;
|
|
369
|
-
}
|
|
370
|
-
return this.isRtl() ? 100 - this.selectionRight() : this.selectionLeft();
|
|
371
|
-
}, /* @ts-ignore */
|
|
372
|
-
...(ngDevMode ? [{ debugName: "horizontalSelectionLeft" }] : /* istanbul ignore next */ []));
|
|
373
|
-
this.horizontalSelectionRight = computed(() => {
|
|
374
|
-
if (this.orientation() !== "horizontal") {
|
|
375
|
-
return undefined;
|
|
376
|
-
}
|
|
377
|
-
return this.isRtl() ? this.selectionLeft() : 100 - this.selectionRight();
|
|
378
|
-
}, /* @ts-ignore */
|
|
379
|
-
...(ngDevMode ? [{ debugName: "horizontalSelectionRight" }] : /* istanbul ignore next */ []));
|
|
380
420
|
this.selectionClasses = computed(() => sliderSelectionThemeVariants(), /* @ts-ignore */
|
|
381
421
|
...(ngDevMode ? [{ debugName: "selectionClasses" }] : /* istanbul ignore next */ []));
|
|
382
422
|
this.sliderHandleClasses = computed(() => {
|
|
@@ -403,8 +443,6 @@ class SliderBaseComponent {
|
|
|
403
443
|
...(ngDevMode ? [{ debugName: "sliderTrackSize" }] : /* istanbul ignore next */ []));
|
|
404
444
|
this.tickClasses = computed(() => sliderTickThemeVariants(), /* @ts-ignore */
|
|
405
445
|
...(ngDevMode ? [{ debugName: "tickClasses" }] : /* istanbul ignore next */ []));
|
|
406
|
-
this.tickElements = viewChildren(SliderTickDirective, /* @ts-ignore */
|
|
407
|
-
...(ngDevMode ? [{ debugName: "tickElements" }] : /* istanbul ignore next */ []));
|
|
408
446
|
this.tickLabelClasses = computed(() => sliderTickLabelThemeVariants(), /* @ts-ignore */
|
|
409
447
|
...(ngDevMode ? [{ debugName: "tickLabelClasses" }] : /* istanbul ignore next */ []));
|
|
410
448
|
this.tickLabelListClasses = computed(() => sliderTickLabelListThemeVariants(), /* @ts-ignore */
|
|
@@ -414,8 +452,8 @@ class SliderBaseComponent {
|
|
|
414
452
|
this.tickStyleArgs = computed(() => {
|
|
415
453
|
const direction = this.direction();
|
|
416
454
|
const largeTickStep = this.largeTickStep();
|
|
417
|
-
const max = this.
|
|
418
|
-
const min = this.
|
|
455
|
+
const max = this.effectiveMax();
|
|
456
|
+
const min = this.effectiveMin();
|
|
419
457
|
const orientation = this.orientation();
|
|
420
458
|
const smallTickStep = this.smallTickStep();
|
|
421
459
|
return { direction, largeTickStep, max, min, orientation, smallTickStep };
|
|
@@ -423,14 +461,13 @@ class SliderBaseComponent {
|
|
|
423
461
|
...(ngDevMode ? [{ debugName: "tickStyleArgs" }] : /* istanbul ignore next */ []));
|
|
424
462
|
this.tickValueTemplate = contentChild(SliderTickValueTemplateDirective, { ...(ngDevMode ? { debugName: "tickValueTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
425
463
|
this.ticks = computed(() => {
|
|
426
|
-
const min = this.
|
|
427
|
-
const max = this.
|
|
464
|
+
const min = this.effectiveMin();
|
|
465
|
+
const max = this.effectiveMax();
|
|
428
466
|
const step = this.step();
|
|
429
467
|
const ticks = [];
|
|
430
|
-
const count =
|
|
468
|
+
const count = this.#stepCount();
|
|
431
469
|
for (let i = 0; i <= count; i++) {
|
|
432
|
-
|
|
433
|
-
ticks.push({ index: i, value });
|
|
470
|
+
ticks.push({ index: i, value: this.#roundToStep(min + i * step) });
|
|
434
471
|
}
|
|
435
472
|
if (ticks.length === 0 || ticks[ticks.length - 1].value < max) {
|
|
436
473
|
ticks.push({ index: ticks.length, value: max });
|
|
@@ -452,6 +489,23 @@ class SliderBaseComponent {
|
|
|
452
489
|
}, /* @ts-ignore */
|
|
453
490
|
...(ngDevMode ? [{ debugName: "trackClasses" }] : /* istanbul ignore next */ []));
|
|
454
491
|
this.zone = inject(NgZone);
|
|
492
|
+
/**
|
|
493
|
+
* @description Id of an element that describes the control, such as an error message. On a range slider it describes
|
|
494
|
+
* each handle.
|
|
495
|
+
* @default null
|
|
496
|
+
*/
|
|
497
|
+
this.ariaDescribedBy = input(null, { ...(ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {}), alias: "aria-describedby" });
|
|
498
|
+
/**
|
|
499
|
+
* @description Accessible name of the control. On a range slider it names the group holding both handles.
|
|
500
|
+
* @default null
|
|
501
|
+
*/
|
|
502
|
+
this.ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
503
|
+
/**
|
|
504
|
+
* @description Id of the element that labels the control. On a range slider each handle reads it before its own
|
|
505
|
+
* name.
|
|
506
|
+
* @default null
|
|
507
|
+
*/
|
|
508
|
+
this.ariaLabelledBy = input(null, { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
455
509
|
/**
|
|
456
510
|
* @description Human-readable override for the `aria-valuenow` announcement. Pass a function that receives the current value and returns the string to announce.
|
|
457
511
|
* @default null
|
|
@@ -462,8 +516,7 @@ class SliderBaseComponent {
|
|
|
462
516
|
* @description Renders the component with reduced visual emphasis and removes pointer interaction.
|
|
463
517
|
* @default false
|
|
464
518
|
*/
|
|
465
|
-
this.disabled = input(false, /*
|
|
466
|
-
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
519
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
467
520
|
/**
|
|
468
521
|
* @description Additional CSS classes to apply to the slider handle.
|
|
469
522
|
* @default []
|
|
@@ -477,11 +530,11 @@ class SliderBaseComponent {
|
|
|
477
530
|
this.handleStyles = input({}, /* @ts-ignore */
|
|
478
531
|
...(ngDevMode ? [{ debugName: "handleStyles" }] : /* istanbul ignore next */ []));
|
|
479
532
|
/**
|
|
480
|
-
* @description Marks the control as invalid for form validation purposes, reflecting `aria-invalid` on the handle
|
|
533
|
+
* @description Marks the control as invalid for form validation purposes, reflecting `aria-invalid` on the handle
|
|
534
|
+
* element once the control is touched.
|
|
481
535
|
* @default false
|
|
482
536
|
*/
|
|
483
|
-
this.invalid = input(false, /*
|
|
484
|
-
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
537
|
+
this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
485
538
|
/**
|
|
486
539
|
* @description Position of the label relative to the component.
|
|
487
540
|
* @default "after"
|
|
@@ -518,6 +571,12 @@ class SliderBaseComponent {
|
|
|
518
571
|
*/
|
|
519
572
|
this.orientation = input("horizontal", /* @ts-ignore */
|
|
520
573
|
...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
574
|
+
/**
|
|
575
|
+
* @description Prevents value changes while the control stays focusable and readable. When bound to a signal form
|
|
576
|
+
* field via `[formField]`, this is written by the `FormField` directive.
|
|
577
|
+
* @default false
|
|
578
|
+
*/
|
|
579
|
+
this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
521
580
|
/**
|
|
522
581
|
* @description Border-radius preset applied to the slider handle.
|
|
523
582
|
* @default "full"
|
|
@@ -540,28 +599,33 @@ class SliderBaseComponent {
|
|
|
540
599
|
* @description Displays value labels alongside tick marks. Only takes effect when `showTicks` is `true`.
|
|
541
600
|
* @default false
|
|
542
601
|
*/
|
|
543
|
-
this.showLabels = input(false, /*
|
|
544
|
-
...(ngDevMode ? [{ debugName: "showLabels" }] : /* istanbul ignore next */ []));
|
|
602
|
+
this.showLabels = input(false, { ...(ngDevMode ? { debugName: "showLabels" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
545
603
|
/**
|
|
546
604
|
* @description Displays tick marks at each step position along the track.
|
|
547
605
|
* @default false
|
|
548
606
|
*/
|
|
549
|
-
this.showTicks = input(false, /*
|
|
550
|
-
...(ngDevMode ? [{ debugName: "showTicks" }] : /* istanbul ignore next */ []));
|
|
607
|
+
this.showTicks = input(false, { ...(ngDevMode ? { debugName: "showTicks" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
551
608
|
/**
|
|
552
609
|
* @description Controls how many ticks are visible — only every n<sup>th</sup> tick is rendered.
|
|
553
610
|
* @default 1
|
|
554
611
|
*/
|
|
555
612
|
this.smallTickStep = input(1, { ...(ngDevMode ? { debugName: "smallTickStep" } : /* istanbul ignore next */ {}), transform: (value) => Math.max(value, 1) });
|
|
556
613
|
/**
|
|
557
|
-
* @description
|
|
614
|
+
* @description Distance between the values the control can take. `maxValue` can always be reached, even when it
|
|
615
|
+
* isn't a whole number of steps from `minValue`.
|
|
558
616
|
* @default 1
|
|
559
617
|
*/
|
|
560
618
|
this.step = input(1, { ...(ngDevMode ? { debugName: "step" } : /* istanbul ignore next */ {}), transform: (value) => (value <= 0 ? 1 : value) });
|
|
561
619
|
/**
|
|
562
|
-
* @description Emitted when
|
|
620
|
+
* @description Emitted when a handle loses focus. A click on the track moves focus to the handle first.
|
|
563
621
|
*/
|
|
564
622
|
this.touch = output();
|
|
623
|
+
/**
|
|
624
|
+
* @description Marks the slider as touched. Error styling requires both `invalid` and `touched` to be `true`.
|
|
625
|
+
* When bound to a signal form field via `[formField]`, this is written by the `FormField` directive.
|
|
626
|
+
* @default false
|
|
627
|
+
*/
|
|
628
|
+
this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
565
629
|
/**
|
|
566
630
|
* @description Background color of the unfilled track portion. Accepts a CSS color string or a `CSSStyleDeclaration` partial.
|
|
567
631
|
* @default null
|
|
@@ -577,23 +641,37 @@ class SliderBaseComponent {
|
|
|
577
641
|
afterNextRender({
|
|
578
642
|
read: () => this.zone.runOutsideAngular(() => this.setSubscriptions())
|
|
579
643
|
});
|
|
644
|
+
if (isDevMode()) {
|
|
645
|
+
this.#warnWhenMisconfigured();
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* @internal
|
|
650
|
+
*/
|
|
651
|
+
setLabelledBy(id) {
|
|
652
|
+
this.#label.setLabelledBy(id);
|
|
580
653
|
}
|
|
581
654
|
calculateNewValue(currentValue, event) {
|
|
582
|
-
const min = this.
|
|
583
|
-
const max = this.
|
|
655
|
+
const min = this.effectiveMin();
|
|
656
|
+
const max = this.effectiveMax();
|
|
584
657
|
const step = this.step();
|
|
585
658
|
const isRtl = this.isRtl();
|
|
659
|
+
const amount = event.shiftKey ? step * this.shiftMultiplier() : step;
|
|
660
|
+
const page = Math.max((max - min) * 0.1, step);
|
|
661
|
+
// Max can sit off the step grid, and stepping down from it lands on the last value of the grid.
|
|
662
|
+
const lastGridValue = this.#roundToStep(min + this.#stepCount() * step);
|
|
663
|
+
const decreaseFrom = currentValue > lastGridValue ? lastGridValue + step : currentValue;
|
|
586
664
|
const decreaseKey = isRtl ? "ArrowRight" : "ArrowLeft";
|
|
587
665
|
const increaseKey = isRtl ? "ArrowLeft" : "ArrowRight";
|
|
588
666
|
let newValue = currentValue;
|
|
589
667
|
switch (event.key) {
|
|
590
668
|
case decreaseKey:
|
|
591
669
|
case "ArrowDown":
|
|
592
|
-
newValue =
|
|
670
|
+
newValue = decreaseFrom - amount;
|
|
593
671
|
break;
|
|
594
672
|
case increaseKey:
|
|
595
673
|
case "ArrowUp":
|
|
596
|
-
newValue = currentValue +
|
|
674
|
+
newValue = currentValue + amount;
|
|
597
675
|
break;
|
|
598
676
|
case "Home":
|
|
599
677
|
newValue = min;
|
|
@@ -602,37 +680,24 @@ class SliderBaseComponent {
|
|
|
602
680
|
newValue = max;
|
|
603
681
|
break;
|
|
604
682
|
case "PageDown":
|
|
605
|
-
newValue =
|
|
683
|
+
newValue = decreaseFrom - page;
|
|
606
684
|
break;
|
|
607
685
|
case "PageUp":
|
|
608
|
-
newValue = currentValue +
|
|
686
|
+
newValue = currentValue + page;
|
|
609
687
|
break;
|
|
610
688
|
}
|
|
611
689
|
return this.snapValue(newValue);
|
|
612
690
|
}
|
|
613
691
|
clampValue(value) {
|
|
614
|
-
return Math.max(this.
|
|
692
|
+
return Math.max(this.effectiveMin(), Math.min(this.effectiveMax(), value));
|
|
615
693
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
const rect = element.getBoundingClientRect();
|
|
622
|
-
const distance = Math.sqrt(Math.pow(rect.left - event.clientX, 2) + Math.pow(rect.top - event.clientY, 2));
|
|
623
|
-
if (distance < maxDistance) {
|
|
624
|
-
maxDistance = distance;
|
|
625
|
-
index = ex;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
return elements[index];
|
|
694
|
+
getMaxOverride() {
|
|
695
|
+
return undefined;
|
|
696
|
+
}
|
|
697
|
+
getMinOverride() {
|
|
698
|
+
return undefined;
|
|
629
699
|
}
|
|
630
700
|
getValueFromPointerEvent(event) {
|
|
631
|
-
if (this.showTicks()) {
|
|
632
|
-
const tick = this.findClosestTickElement(event);
|
|
633
|
-
const valueStr = tick.getAttribute("data-value");
|
|
634
|
-
return valueStr ? Number(valueStr) : this.minValue();
|
|
635
|
-
}
|
|
636
701
|
const containerRect = this.hostElementRef.nativeElement.getBoundingClientRect();
|
|
637
702
|
let normalizedHandlePos;
|
|
638
703
|
if (this.orientation() === "horizontal") {
|
|
@@ -649,8 +714,8 @@ class SliderBaseComponent {
|
|
|
649
714
|
return this.getValueFromPosition(normalizedHandlePos);
|
|
650
715
|
}
|
|
651
716
|
getValueFromPosition(position) {
|
|
652
|
-
const min = this.
|
|
653
|
-
const max = this.
|
|
717
|
+
const min = this.effectiveMin();
|
|
718
|
+
const max = this.effectiveMax();
|
|
654
719
|
if (position >= 100) {
|
|
655
720
|
return max;
|
|
656
721
|
}
|
|
@@ -665,26 +730,74 @@ class SliderBaseComponent {
|
|
|
665
730
|
return ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End", "PageUp", "PageDown"].includes(event.key);
|
|
666
731
|
}
|
|
667
732
|
positionFromValue(value) {
|
|
668
|
-
return valueToPosition(value, this.
|
|
733
|
+
return valueToPosition(value, this.effectiveMin(), this.effectiveMax());
|
|
669
734
|
}
|
|
670
735
|
snapValue(value) {
|
|
671
|
-
const min = this.
|
|
736
|
+
const min = this.effectiveMin();
|
|
737
|
+
const max = this.effectiveMax();
|
|
738
|
+
if (Number.isNaN(value) || max <= min) {
|
|
739
|
+
return min;
|
|
740
|
+
}
|
|
672
741
|
const step = this.step();
|
|
673
742
|
const clampedValue = this.clampValue(value);
|
|
674
|
-
const snappedValue = Math.round((clampedValue - min) / step) * step + min;
|
|
675
|
-
|
|
743
|
+
const snappedValue = this.clampValue(this.#roundToStep(Math.round((clampedValue - min) / step) * step + min));
|
|
744
|
+
// Max counts as a value of the grid even when it's off it, as the last tick does.
|
|
745
|
+
return max - clampedValue < Math.abs(clampedValue - snappedValue) ? max : snappedValue;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Moves a value while the given handle is dragged with the primary button, one finger or a pen. The pointer is
|
|
749
|
+
* captured, so a release outside the page still ends the drag.
|
|
750
|
+
*/
|
|
751
|
+
trackHandleDrag(handle, startDrag) {
|
|
752
|
+
fromEvent(handle, "pointerdown")
|
|
753
|
+
.pipe(filter(event => event.button === 0 && event.isPrimary && !event.ctrlKey), filter(() => !this.dragging() && !this.interactionDisabled()), tap(event => {
|
|
754
|
+
this.zone.run(() => this.dragging.set(true));
|
|
755
|
+
handle.setPointerCapture?.(event.pointerId);
|
|
756
|
+
// A touch doesn't focus the element by itself, and touch only fires when focus leaves.
|
|
757
|
+
handle.focus({ preventScroll: true });
|
|
758
|
+
}), switchMap(down => {
|
|
759
|
+
const pointerEvents = (target, name) => fromEvent(target, name).pipe(filter(event => event.pointerId === down.pointerId));
|
|
760
|
+
const end$ = merge(pointerEvents(this.#document, "pointerup"), pointerEvents(this.#document, "pointercancel"), pointerEvents(handle, "lostpointercapture")).pipe(tap(() => this.zone.run(() => this.dragging.set(false))));
|
|
761
|
+
return pointerEvents(this.#document, "pointermove").pipe(tap(startDrag()), takeUntil(end$));
|
|
762
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
763
|
+
.subscribe();
|
|
764
|
+
}
|
|
765
|
+
#roundToStep(value) {
|
|
766
|
+
return roundToPlaces(value, this.#stepPlaces());
|
|
767
|
+
}
|
|
768
|
+
#stepCount() {
|
|
769
|
+
return Math.floor((this.effectiveMax() - this.effectiveMin()) / this.step());
|
|
770
|
+
}
|
|
771
|
+
#warnWhenMisconfigured() {
|
|
772
|
+
const host = this.hostElementRef.nativeElement;
|
|
773
|
+
let warnedAboutBounds = false;
|
|
774
|
+
let warnedAboutValue = false;
|
|
775
|
+
effect(() => {
|
|
776
|
+
if (!warnedAboutBounds && this.effectiveMin() >= this.effectiveMax()) {
|
|
777
|
+
warnedAboutBounds = true;
|
|
778
|
+
console.warn(`[Mona Slider] The minimum (${this.effectiveMin()}) must be lower than the maximum ` +
|
|
779
|
+
`(${this.effectiveMax()}).`, host);
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
effect(() => {
|
|
783
|
+
if (!warnedAboutValue && !this.valueIsShown()) {
|
|
784
|
+
warnedAboutValue = true;
|
|
785
|
+
console.warn("[Mona Slider] The value is out of range or off the step grid. The slider shows the nearest " +
|
|
786
|
+
"valid value, and the model keeps its own until the user changes it.", host);
|
|
787
|
+
}
|
|
788
|
+
});
|
|
676
789
|
}
|
|
677
790
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
678
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "22.0.6", type: SliderBaseComponent, isStandalone: true, inputs: { ariaValueText: { classPropertyName: "ariaValueText", publicName: "ariaValueText", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, handleClasses: { classPropertyName: "handleClasses", publicName: "handleClasses", isSignal: true, isRequired: false, transformFunction: null }, handleStyles: { classPropertyName: "handleStyles", publicName: "handleStyles", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, labelPosition: { classPropertyName: "labelPosition", publicName: "labelPosition", isSignal: true, isRequired: false, transformFunction: null }, labelStep: { classPropertyName: "labelStep", publicName: "labelStep", isSignal: true, isRequired: false, transformFunction: null }, largeTickStep: { classPropertyName: "largeTickStep", publicName: "largeTickStep", isSignal: true, isRequired: false, transformFunction: null }, maxValue: { classPropertyName: "maxValue", publicName: "maxValue", isSignal: true, isRequired: false, transformFunction: null }, minValue: { classPropertyName: "minValue", publicName: "minValue", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, selectionBackground: { classPropertyName: "selectionBackground", publicName: "selectionBackground", isSignal: true, isRequired: false, transformFunction: null }, shiftMultiplier: { classPropertyName: "shiftMultiplier", publicName: "shiftMultiplier", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, showTicks: { classPropertyName: "showTicks", publicName: "showTicks", isSignal: true, isRequired: false, transformFunction: null }, smallTickStep: { classPropertyName: "smallTickStep", publicName: "smallTickStep", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, trackBackground: { classPropertyName: "trackBackground", publicName: "trackBackground", isSignal: true, isRequired: false, transformFunction: null }, trackSize: { classPropertyName: "trackSize", publicName: "trackSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { touch: "touch" }, queries: [{ propertyName: "handleTemplate", first: true, predicate: SliderHandleTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "tickValueTemplate", first: true, predicate: SliderTickValueTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }],
|
|
791
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "22.0.6", type: SliderBaseComponent, isStandalone: true, inputs: { ariaDescribedBy: { classPropertyName: "ariaDescribedBy", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, ariaValueText: { classPropertyName: "ariaValueText", publicName: "ariaValueText", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, handleClasses: { classPropertyName: "handleClasses", publicName: "handleClasses", isSignal: true, isRequired: false, transformFunction: null }, handleStyles: { classPropertyName: "handleStyles", publicName: "handleStyles", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, labelPosition: { classPropertyName: "labelPosition", publicName: "labelPosition", isSignal: true, isRequired: false, transformFunction: null }, labelStep: { classPropertyName: "labelStep", publicName: "labelStep", isSignal: true, isRequired: false, transformFunction: null }, largeTickStep: { classPropertyName: "largeTickStep", publicName: "largeTickStep", isSignal: true, isRequired: false, transformFunction: null }, maxValue: { classPropertyName: "maxValue", publicName: "maxValue", isSignal: true, isRequired: false, transformFunction: null }, minValue: { classPropertyName: "minValue", publicName: "minValue", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, selectionBackground: { classPropertyName: "selectionBackground", publicName: "selectionBackground", isSignal: true, isRequired: false, transformFunction: null }, shiftMultiplier: { classPropertyName: "shiftMultiplier", publicName: "shiftMultiplier", isSignal: true, isRequired: false, transformFunction: null }, showLabels: { classPropertyName: "showLabels", publicName: "showLabels", isSignal: true, isRequired: false, transformFunction: null }, showTicks: { classPropertyName: "showTicks", publicName: "showTicks", isSignal: true, isRequired: false, transformFunction: null }, smallTickStep: { classPropertyName: "smallTickStep", publicName: "smallTickStep", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, trackBackground: { classPropertyName: "trackBackground", publicName: "trackBackground", isSignal: true, isRequired: false, transformFunction: null }, trackSize: { classPropertyName: "trackSize", publicName: "trackSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { touch: "touch" }, queries: [{ propertyName: "handleTemplate", first: true, predicate: SliderHandleTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "tickValueTemplate", first: true, predicate: SliderTickValueTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0 }); }
|
|
679
792
|
}
|
|
680
793
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderBaseComponent, decorators: [{
|
|
681
794
|
type: Directive
|
|
682
|
-
}], ctorParameters: () => [], propDecorators: { handleTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SliderHandleTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }],
|
|
795
|
+
}], ctorParameters: () => [], propDecorators: { handleTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SliderHandleTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], tickValueTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SliderTickValueTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], ariaDescribedBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-describedby", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], ariaValueText: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaValueText", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], handleClasses: [{ type: i0.Input, args: [{ isSignal: true, alias: "handleClasses", required: false }] }], handleStyles: [{ type: i0.Input, args: [{ isSignal: true, alias: "handleStyles", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], labelPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelPosition", required: false }] }], labelStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelStep", required: false }] }], largeTickStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "largeTickStep", required: false }] }], maxValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxValue", required: false }] }], minValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "minValue", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], selectionBackground: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionBackground", required: false }] }], shiftMultiplier: [{ type: i0.Input, args: [{ isSignal: true, alias: "shiftMultiplier", required: false }] }], showLabels: [{ type: i0.Input, args: [{ isSignal: true, alias: "showLabels", required: false }] }], showTicks: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTicks", required: false }] }], smallTickStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "smallTickStep", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], trackBackground: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackBackground", required: false }] }], trackSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackSize", required: false }] }] } });
|
|
683
796
|
|
|
684
797
|
class SliderComponent extends SliderBaseComponent {
|
|
685
798
|
constructor() {
|
|
686
799
|
super(...arguments);
|
|
687
|
-
this.computedAriaLabel = computed(() => this.ariaLabel() ?? this.messages().sliderValue, /* @ts-ignore */
|
|
800
|
+
this.computedAriaLabel = computed(() => this.ariaLabel() ?? (this.labelledBy() ? null : this.messages().sliderValue), /* @ts-ignore */
|
|
688
801
|
...(ngDevMode ? [{ debugName: "computedAriaLabel" }] : /* istanbul ignore next */ []));
|
|
689
802
|
this.handleFocused = signal(false, /* @ts-ignore */
|
|
690
803
|
...(ngDevMode ? [{ debugName: "handleFocused" }] : /* istanbul ignore next */ []));
|
|
@@ -704,19 +817,26 @@ class SliderComponent extends SliderBaseComponent {
|
|
|
704
817
|
...(ngDevMode ? [{ debugName: "selectionRight" }] : /* istanbul ignore next */ []));
|
|
705
818
|
this.sliderHandle = viewChild.required("sliderHandle", /* @ts-ignore */
|
|
706
819
|
...(ngDevMode ? [{ debugName: "sliderHandle" }] : /* istanbul ignore next */ []));
|
|
820
|
+
this.valueIsShown = computed(() => this.normalizedValue() === this.value(), /* @ts-ignore */
|
|
821
|
+
...(ngDevMode ? [{ debugName: "valueIsShown" }] : /* istanbul ignore next */ []));
|
|
707
822
|
/**
|
|
708
|
-
* @description
|
|
709
|
-
*
|
|
710
|
-
* @default
|
|
823
|
+
* @description Upper bound that wins over `maxValue`. When bound to a signal form field via `[formField]`, this is
|
|
824
|
+
* written from the field's `max` rule.
|
|
825
|
+
* @default undefined
|
|
711
826
|
*/
|
|
712
|
-
this.
|
|
827
|
+
this.max = input(undefined, /* @ts-ignore */
|
|
828
|
+
...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
713
829
|
/**
|
|
714
|
-
* @description
|
|
715
|
-
*
|
|
830
|
+
* @description Lower bound that wins over `minValue`. When bound to a signal form field via `[formField]`, this is
|
|
831
|
+
* written from the field's `min` rule.
|
|
832
|
+
* @default undefined
|
|
716
833
|
*/
|
|
717
|
-
this.
|
|
834
|
+
this.min = input(undefined, /* @ts-ignore */
|
|
835
|
+
...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
718
836
|
/**
|
|
719
|
-
* @description Current value.
|
|
837
|
+
* @description Current value. A value out of range or off the step grid is shown at the nearest valid value, and
|
|
838
|
+
* the model keeps its own until the user changes it, so a `maxValue` that loads late can't overwrite saved data. A
|
|
839
|
+
* development warning reports it.
|
|
720
840
|
* @default 0
|
|
721
841
|
*/
|
|
722
842
|
this.value = model(0, /* @ts-ignore */
|
|
@@ -727,6 +847,12 @@ class SliderComponent extends SliderBaseComponent {
|
|
|
727
847
|
this.sliderHandle().nativeElement.focus(options);
|
|
728
848
|
}
|
|
729
849
|
}
|
|
850
|
+
getMaxOverride() {
|
|
851
|
+
return this.max();
|
|
852
|
+
}
|
|
853
|
+
getMinOverride() {
|
|
854
|
+
return this.min();
|
|
855
|
+
}
|
|
730
856
|
handleHandleMove(event) {
|
|
731
857
|
this.updateValue(this.getValueFromPointerEvent(event));
|
|
732
858
|
}
|
|
@@ -738,8 +864,15 @@ class SliderComponent extends SliderBaseComponent {
|
|
|
738
864
|
}
|
|
739
865
|
setClickSubscription() {
|
|
740
866
|
fromEvent(this.hostElementRef.nativeElement, "click")
|
|
741
|
-
.pipe(takeUntilDestroyed(this.destroyRef), tap(() => this.dragging.set(false)), filter(() => !this.
|
|
742
|
-
.subscribe((event) =>
|
|
867
|
+
.pipe(takeUntilDestroyed(this.destroyRef), tap(() => this.dragging.set(false)), filter(() => !this.interactionDisabled()))
|
|
868
|
+
.subscribe((event) => {
|
|
869
|
+
const handle = this.sliderHandle().nativeElement;
|
|
870
|
+
// A drag ends with a click on the handle, and the drag has already placed the value.
|
|
871
|
+
if (!handle.contains(event.target)) {
|
|
872
|
+
this.handleHandleMove(event);
|
|
873
|
+
}
|
|
874
|
+
handle.focus({ preventScroll: true });
|
|
875
|
+
});
|
|
743
876
|
}
|
|
744
877
|
setFocusSubscription() {
|
|
745
878
|
fromEvent(this.sliderHandle().nativeElement, "focus")
|
|
@@ -756,42 +889,39 @@ class SliderComponent extends SliderBaseComponent {
|
|
|
756
889
|
}
|
|
757
890
|
setKeydownSubscription() {
|
|
758
891
|
fromEvent(this.sliderHandle().nativeElement, "keydown")
|
|
759
|
-
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.
|
|
892
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.interactionDisabled()), filter(event => this.isNavigationKey(event)), tap(event => {
|
|
760
893
|
event.preventDefault();
|
|
761
894
|
event.stopPropagation();
|
|
762
895
|
}))
|
|
763
896
|
.subscribe(event => this.updateValue(this.calculateNewValue(this.normalizedValue(), event)));
|
|
764
897
|
}
|
|
765
898
|
setPointerMoveSubscription() {
|
|
766
|
-
|
|
767
|
-
const pointerUp$ = fromEvent(document, "pointerup");
|
|
768
|
-
fromEvent(this.sliderHandle().nativeElement, "pointerdown")
|
|
769
|
-
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.effectiveDisabled()), tap(() => this.dragging.set(true)), switchMap(() => pointerMove$.pipe(tap((event) => this.handleHandleMove(event)), takeUntil(pointerUp$.pipe(tap(() => this.zone.run(() => this.dragging.set(false))))))))
|
|
770
|
-
.subscribe();
|
|
899
|
+
this.trackHandleDrag(this.sliderHandle().nativeElement, () => event => this.handleHandleMove(event));
|
|
771
900
|
}
|
|
772
901
|
updateValue(value) {
|
|
773
902
|
const nextValue = this.snapValue(value);
|
|
774
903
|
if (nextValue === this.normalizedValue()) {
|
|
775
904
|
return;
|
|
776
905
|
}
|
|
777
|
-
this.zone.run(() =>
|
|
778
|
-
this.value.set(nextValue);
|
|
779
|
-
this.touch.emit();
|
|
780
|
-
});
|
|
906
|
+
this.zone.run(() => this.value.set(nextValue));
|
|
781
907
|
}
|
|
782
908
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
783
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SliderComponent, isStandalone: true, selector: "mona-slider", inputs: {
|
|
909
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SliderComponent, isStandalone: true, selector: "mona-slider", inputs: { max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { properties: { "attr.aria-describedby": "null", "attr.aria-label": "null", "attr.aria-labelledby": "null", "class": "baseClasses()", "class.mona-slider": "true", "attr.data-disabled": "effectiveDisabled() || null", "attr.data-orientation": "orientation()", "attr.data-readonly": "readonly() || null" } }, viewQueries: [{ propertyName: "sliderHandle", first: true, predicate: ["sliderHandle"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div\n [class]=\"trackClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [style.height]=\"orientation() === 'horizontal' ? sliderTrackSize() : undefined\"\n [style.width]=\"orientation() === 'vertical' ? sliderTrackSize() : undefined\"\n [style]=\"trackBackgroundStyle()\">\n <div\n [class]=\"selectionClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [style.left.%]=\"horizontalSelectionLeft()\"\n [style.right.%]=\"horizontalSelectionRight()\"\n [style.bottom.%]=\"orientation() === 'vertical' ? selectionLeft() : undefined\"\n [style.top.%]=\"orientation() === 'vertical' ? 100 - selectionRight() : undefined\"\n [style]=\"selectionBackgroundStyle()\"></div>\n</div>\n@if (showTicks()) {\n <div [class]=\"tickListClasses()\" [attr.data-orientation]=\"orientation()\">\n @for (tick of renderTicks(); track tick.index) {\n <span\n [class]=\"tickClasses()\"\n [style]=\"tick | tickStyle: tickStyleArgs()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-value]=\"tick.value\"\n data-slider-tick>\n </span>\n }\n </div>\n}\n@if (showTicks() && showLabels()) {\n <div\n [class]=\"tickLabelListClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-label-position]=\"labelPosition()\">\n @for (tick of labelTicks(); track tick.index) {\n <span\n [class]=\"tickLabelClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [style]=\"tick | labelStyle: labelStyleArgs()\">\n @if (!tickValueTemplate()) {\n <span>{{ tick.label }}</span>\n } @else {\n <span>\n <ng-container\n *ngTemplateOutlet=\"\n tickValueTemplate() ?? null;\n context: { $implicit: tick.value }\n \"></ng-container>\n </span>\n }\n </span>\n }\n </div>\n}\n<div\n [class]=\"sliderHandleClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [attr.data-rtl]=\"isRtl() || null\"\n [attr.data-focused]=\"handleFocused()\"\n [style]=\"handleStyle()\"\n [style.left.%]=\"orientation() === 'horizontal' && !isRtl() ? handlePosition() : undefined\"\n [style.right.%]=\"orientation() === 'horizontal' && isRtl() ? handlePosition() : undefined\"\n [style.bottom.%]=\"orientation() === 'vertical' ? handlePosition() : undefined\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-valuemin]=\"effectiveMin()\"\n [attr.aria-valuemax]=\"effectiveMax()\"\n [attr.aria-valuenow]=\"normalizedValue()\"\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()) : null\"\n [attr.aria-orientation]=\"orientation()\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n [attr.aria-describedby]=\"ariaDescribedBy()\"\n [attr.aria-label]=\"computedAriaLabel()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n #sliderHandle>\n @if (handleTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue() }\"></ng-container>\n }\n</div>\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: LabelStylePipe, name: "labelStyle" }, { kind: "pipe", type: TickStylePipe, name: "tickStyle" }] }); }
|
|
784
910
|
}
|
|
785
911
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderComponent, decorators: [{
|
|
786
912
|
type: Component,
|
|
787
|
-
args: [{ selector: "mona-slider", imports: [NgTemplateOutlet,
|
|
913
|
+
args: [{ selector: "mona-slider", imports: [NgTemplateOutlet, LabelStylePipe, TickStylePipe], host: {
|
|
914
|
+
// The ARIA inputs are applied to the handle, so the host must not keep the static attributes.
|
|
915
|
+
"[attr.aria-describedby]": "null",
|
|
916
|
+
"[attr.aria-label]": "null",
|
|
917
|
+
"[attr.aria-labelledby]": "null",
|
|
788
918
|
"[class]": "baseClasses()",
|
|
789
919
|
"[class.mona-slider]": "true",
|
|
790
920
|
"[attr.data-disabled]": "effectiveDisabled() || null",
|
|
791
921
|
"[attr.data-orientation]": "orientation()",
|
|
792
|
-
"
|
|
793
|
-
}, template: "<div\n [class]=\"trackClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [style.height]=\"orientation() === 'horizontal' ? sliderTrackSize() : undefined\"\n [style.width]=\"orientation() === 'vertical' ? sliderTrackSize() : undefined\"\n [style]=\"trackBackgroundStyle()\">\n <div\n [class]=\"selectionClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [style.left.%]=\"horizontalSelectionLeft()\"\n [style.right.%]=\"horizontalSelectionRight()\"\n [style.bottom.%]=\"orientation() === 'vertical' ? selectionLeft() : undefined\"\n [style.top.%]=\"orientation() === 'vertical' ? 100 - selectionRight() : undefined\"\n [style]=\"selectionBackgroundStyle()\"></div>\n</div>\n@if (showTicks()) {\n <div [class]=\"tickListClasses()\" [attr.data-orientation]=\"orientation()\">\n @for (tick of renderTicks(); track tick.index) {\n <span\n [class]=\"tickClasses()\"\n [style]=\"tick | tickStyle: tickStyleArgs()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-value]=\"tick.value\"\n
|
|
794
|
-
}], propDecorators: { sliderHandle: [{ type: i0.ViewChild, args: ["sliderHandle", { isSignal: true }] }],
|
|
922
|
+
"[attr.data-readonly]": "readonly() || null"
|
|
923
|
+
}, template: "<div\n [class]=\"trackClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [style.height]=\"orientation() === 'horizontal' ? sliderTrackSize() : undefined\"\n [style.width]=\"orientation() === 'vertical' ? sliderTrackSize() : undefined\"\n [style]=\"trackBackgroundStyle()\">\n <div\n [class]=\"selectionClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [style.left.%]=\"horizontalSelectionLeft()\"\n [style.right.%]=\"horizontalSelectionRight()\"\n [style.bottom.%]=\"orientation() === 'vertical' ? selectionLeft() : undefined\"\n [style.top.%]=\"orientation() === 'vertical' ? 100 - selectionRight() : undefined\"\n [style]=\"selectionBackgroundStyle()\"></div>\n</div>\n@if (showTicks()) {\n <div [class]=\"tickListClasses()\" [attr.data-orientation]=\"orientation()\">\n @for (tick of renderTicks(); track tick.index) {\n <span\n [class]=\"tickClasses()\"\n [style]=\"tick | tickStyle: tickStyleArgs()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-value]=\"tick.value\"\n data-slider-tick>\n </span>\n }\n </div>\n}\n@if (showTicks() && showLabels()) {\n <div\n [class]=\"tickLabelListClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-label-position]=\"labelPosition()\">\n @for (tick of labelTicks(); track tick.index) {\n <span\n [class]=\"tickLabelClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [style]=\"tick | labelStyle: labelStyleArgs()\">\n @if (!tickValueTemplate()) {\n <span>{{ tick.label }}</span>\n } @else {\n <span>\n <ng-container\n *ngTemplateOutlet=\"\n tickValueTemplate() ?? null;\n context: { $implicit: tick.value }\n \"></ng-container>\n </span>\n }\n </span>\n }\n </div>\n}\n<div\n [class]=\"sliderHandleClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [attr.data-rtl]=\"isRtl() || null\"\n [attr.data-focused]=\"handleFocused()\"\n [style]=\"handleStyle()\"\n [style.left.%]=\"orientation() === 'horizontal' && !isRtl() ? handlePosition() : undefined\"\n [style.right.%]=\"orientation() === 'horizontal' && isRtl() ? handlePosition() : undefined\"\n [style.bottom.%]=\"orientation() === 'vertical' ? handlePosition() : undefined\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-valuemin]=\"effectiveMin()\"\n [attr.aria-valuemax]=\"effectiveMax()\"\n [attr.aria-valuenow]=\"normalizedValue()\"\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()) : null\"\n [attr.aria-orientation]=\"orientation()\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n [attr.aria-describedby]=\"ariaDescribedBy()\"\n [attr.aria-label]=\"computedAriaLabel()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n #sliderHandle>\n @if (handleTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue() }\"></ng-container>\n }\n</div>\n" }]
|
|
924
|
+
}], propDecorators: { sliderHandle: [{ type: i0.ViewChild, args: ["sliderHandle", { isSignal: true }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
795
925
|
|
|
796
926
|
class RangeSliderComponent extends SliderBaseComponent {
|
|
797
927
|
constructor() {
|
|
@@ -800,6 +930,13 @@ class RangeSliderComponent extends SliderBaseComponent {
|
|
|
800
930
|
...(ngDevMode ? [{ debugName: "computedAriaLabelEnd" }] : /* istanbul ignore next */ []));
|
|
801
931
|
this.computedAriaLabelStart = computed(() => this.ariaLabelStart() ?? this.messages().minimumValue, /* @ts-ignore */
|
|
802
932
|
...(ngDevMode ? [{ debugName: "computedAriaLabelStart" }] : /* istanbul ignore next */ []));
|
|
933
|
+
this.endHandleId = createElementControlId();
|
|
934
|
+
// Each handle reads the group's label and then its own, so two range sliders on a page sound different.
|
|
935
|
+
this.endLabelledBy = computed(() => {
|
|
936
|
+
const labelledBy = this.labelledBy();
|
|
937
|
+
return labelledBy ? `${labelledBy} ${this.endHandleId}` : null;
|
|
938
|
+
}, /* @ts-ignore */
|
|
939
|
+
...(ngDevMode ? [{ debugName: "endLabelledBy" }] : /* istanbul ignore next */ []));
|
|
803
940
|
this.handlePositions = computed(() => [
|
|
804
941
|
this.positionFromValue(this.normalizedValue()[0]),
|
|
805
942
|
this.positionFromValue(this.normalizedValue()[1])
|
|
@@ -852,6 +989,18 @@ class RangeSliderComponent extends SliderBaseComponent {
|
|
|
852
989
|
...(ngDevMode ? [{ debugName: "selectionRight" }] : /* istanbul ignore next */ []));
|
|
853
990
|
this.sliderHandle = viewChild.required("sliderHandle", /* @ts-ignore */
|
|
854
991
|
...(ngDevMode ? [{ debugName: "sliderHandle" }] : /* istanbul ignore next */ []));
|
|
992
|
+
this.startHandleId = createElementControlId();
|
|
993
|
+
this.startLabelledBy = computed(() => {
|
|
994
|
+
const labelledBy = this.labelledBy();
|
|
995
|
+
return labelledBy ? `${labelledBy} ${this.startHandleId}` : null;
|
|
996
|
+
}, /* @ts-ignore */
|
|
997
|
+
...(ngDevMode ? [{ debugName: "startLabelledBy" }] : /* istanbul ignore next */ []));
|
|
998
|
+
this.valueIsShown = computed(() => {
|
|
999
|
+
const [lower, upper] = this.normalizedValue();
|
|
1000
|
+
const [first, second] = this.value();
|
|
1001
|
+
return lower === first && upper === second;
|
|
1002
|
+
}, /* @ts-ignore */
|
|
1003
|
+
...(ngDevMode ? [{ debugName: "valueIsShown" }] : /* istanbul ignore next */ []));
|
|
855
1004
|
/**
|
|
856
1005
|
* @description Accessible name for the upper-value (secondary) handle.
|
|
857
1006
|
* @default null
|
|
@@ -864,7 +1013,8 @@ class RangeSliderComponent extends SliderBaseComponent {
|
|
|
864
1013
|
this.ariaLabelStart = input(null, { ...(ngDevMode ? { debugName: "ariaLabelStart" } : /* istanbul ignore next */ {}), alias: "aria-label-start" });
|
|
865
1014
|
/**
|
|
866
1015
|
* @description Selected range as `[minimum, maximum]`.
|
|
867
|
-
*
|
|
1016
|
+
* A value out of range, off the step grid or unsorted is shown at the nearest valid values, and the model keeps its
|
|
1017
|
+
* own until the user changes it. A development warning reports it.
|
|
868
1018
|
* @default [0, 10]
|
|
869
1019
|
*/
|
|
870
1020
|
this.value = model([0, 10], /* @ts-ignore */
|
|
@@ -876,7 +1026,7 @@ class RangeSliderComponent extends SliderBaseComponent {
|
|
|
876
1026
|
}
|
|
877
1027
|
}
|
|
878
1028
|
handleHandleMove(event, isSecondary = false) {
|
|
879
|
-
this.updateRangedValue(this.getValueFromPointerEvent(event), isSecondary
|
|
1029
|
+
this.updateRangedValue(this.getValueFromPointerEvent(event), isSecondary);
|
|
880
1030
|
}
|
|
881
1031
|
setSubscriptions() {
|
|
882
1032
|
this.setClickSubscription();
|
|
@@ -912,10 +1062,18 @@ class RangeSliderComponent extends SliderBaseComponent {
|
|
|
912
1062
|
}
|
|
913
1063
|
setClickSubscription() {
|
|
914
1064
|
fromEvent(this.hostElementRef.nativeElement, "click")
|
|
915
|
-
.pipe(takeUntilDestroyed(this.destroyRef), tap(() => this.dragging.set(false)), filter(() => !this.
|
|
1065
|
+
.pipe(takeUntilDestroyed(this.destroyRef), tap(() => this.dragging.set(false)), filter(() => !this.interactionDisabled()))
|
|
916
1066
|
.subscribe((event) => {
|
|
1067
|
+
const target = event.target;
|
|
1068
|
+
// A drag ends with a click on the handle, and moving the closest handle would move the other one.
|
|
1069
|
+
if (this.sliderHandle().nativeElement.contains(target) ||
|
|
1070
|
+
this.secondarySliderHandle().nativeElement.contains(target)) {
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
917
1073
|
const isSecondary = this.getClosestHandle(event);
|
|
918
1074
|
this.handleHandleMove(event, isSecondary);
|
|
1075
|
+
const handle = isSecondary ? this.secondarySliderHandle() : this.sliderHandle();
|
|
1076
|
+
handle.nativeElement.focus({ preventScroll: true });
|
|
919
1077
|
});
|
|
920
1078
|
}
|
|
921
1079
|
setFocusSubscription() {
|
|
@@ -954,88 +1112,87 @@ class RangeSliderComponent extends SliderBaseComponent {
|
|
|
954
1112
|
}
|
|
955
1113
|
setKeydownSubscription() {
|
|
956
1114
|
fromEvent(this.sliderHandle().nativeElement, "keydown")
|
|
957
|
-
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.
|
|
1115
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.interactionDisabled()), filter(event => this.isNavigationKey(event)), tap(event => {
|
|
958
1116
|
event.preventDefault();
|
|
959
1117
|
event.stopPropagation();
|
|
960
1118
|
}))
|
|
961
1119
|
.subscribe(event => {
|
|
962
1120
|
const newValue = this.calculateNewValue(this.normalizedValue()[0], event);
|
|
963
|
-
this.updateRangedValue(newValue, false
|
|
1121
|
+
this.updateRangedValue(newValue, false);
|
|
964
1122
|
});
|
|
965
1123
|
fromEvent(this.secondarySliderHandle().nativeElement, "keydown")
|
|
966
|
-
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.
|
|
1124
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.interactionDisabled()), filter(event => this.isNavigationKey(event)), tap(event => {
|
|
967
1125
|
event.preventDefault();
|
|
968
1126
|
event.stopPropagation();
|
|
969
1127
|
}))
|
|
970
1128
|
.subscribe(event => {
|
|
971
1129
|
const newValue = this.calculateNewValue(this.normalizedValue()[1], event);
|
|
972
|
-
this.updateRangedValue(newValue, true
|
|
1130
|
+
this.updateRangedValue(newValue, true);
|
|
973
1131
|
});
|
|
974
1132
|
}
|
|
975
1133
|
setPointerMoveSubscription() {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
fromEvent(this.sliderHandle().nativeElement, "pointerdown")
|
|
979
|
-
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.effectiveDisabled()), tap(() => this.dragging.set(true)), switchMap(() => pointerMove$.pipe(tap((event) => this.handleHandleMove(event, false)), takeUntil(pointerUp$.pipe(tap(() => this.zone.run(() => this.dragging.set(false))))))))
|
|
980
|
-
.subscribe();
|
|
981
|
-
fromEvent(this.secondarySliderHandle().nativeElement, "pointerdown")
|
|
982
|
-
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.effectiveDisabled()), tap(() => this.dragging.set(true)), switchMap(() => pointerMove$.pipe(tap((event) => this.handleHandleMove(event, true)), takeUntil(pointerUp$.pipe(tap(() => this.zone.run(() => this.dragging.set(false))))))))
|
|
983
|
-
.subscribe();
|
|
1134
|
+
this.trackRangeHandle(this.sliderHandle().nativeElement, false);
|
|
1135
|
+
this.trackRangeHandle(this.secondarySliderHandle().nativeElement, true);
|
|
984
1136
|
}
|
|
985
|
-
|
|
1137
|
+
trackRangeHandle(handle, startsSecondary) {
|
|
1138
|
+
this.trackHandleDrag(handle, () => {
|
|
1139
|
+
let isSecondary = startsSecondary;
|
|
1140
|
+
return event => {
|
|
1141
|
+
const value = this.getValueFromPointerEvent(event);
|
|
1142
|
+
const [lower, upper] = this.normalizedValue();
|
|
1143
|
+
// Handles stop at each other, so stacked ones are told apart by the way the pointer moves. Otherwise
|
|
1144
|
+
// the one on top could be stuck.
|
|
1145
|
+
if (lower === upper && value !== lower && isSecondary !== value > lower) {
|
|
1146
|
+
isSecondary = value > lower;
|
|
1147
|
+
const active = isSecondary ? this.secondarySliderHandle() : this.sliderHandle();
|
|
1148
|
+
active.nativeElement.focus({ preventScroll: true });
|
|
1149
|
+
}
|
|
1150
|
+
this.updateRangedValue(value, isSecondary);
|
|
1151
|
+
};
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
updateRangedValue(value, isSecondary) {
|
|
986
1155
|
const currentValues = this.normalizedValue();
|
|
987
1156
|
const currentMinValue = currentValues[0];
|
|
988
1157
|
const currentMaxValue = currentValues[1];
|
|
989
1158
|
let newMinValue = currentMinValue;
|
|
990
1159
|
let newMaxValue = currentMaxValue;
|
|
991
1160
|
if (isSecondary) {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
newMaxValue = value;
|
|
1161
|
+
newMaxValue = Math.max(value, currentMinValue);
|
|
1162
|
+
if (newMaxValue === currentMinValue) {
|
|
995
1163
|
this.secondaryHandleOnTop.set(true);
|
|
996
1164
|
}
|
|
997
|
-
else {
|
|
998
|
-
newMaxValue = Math.max(value, currentMinValue);
|
|
999
|
-
if (newMaxValue === currentMinValue) {
|
|
1000
|
-
this.secondaryHandleOnTop.set(true);
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
1165
|
}
|
|
1004
1166
|
else {
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
newMaxValue = value;
|
|
1167
|
+
newMinValue = Math.min(value, currentMaxValue);
|
|
1168
|
+
if (newMinValue === currentMaxValue) {
|
|
1008
1169
|
this.secondaryHandleOnTop.set(false);
|
|
1009
1170
|
}
|
|
1010
|
-
else {
|
|
1011
|
-
newMinValue = Math.min(value, currentMaxValue);
|
|
1012
|
-
if (newMinValue === currentMaxValue) {
|
|
1013
|
-
this.secondaryHandleOnTop.set(false);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
1171
|
}
|
|
1017
1172
|
newMinValue = this.snapValue(newMinValue);
|
|
1018
1173
|
newMaxValue = this.snapValue(newMaxValue);
|
|
1019
1174
|
if (newMinValue === currentMinValue && newMaxValue === currentMaxValue) {
|
|
1020
1175
|
return;
|
|
1021
1176
|
}
|
|
1022
|
-
this.zone.run(() =>
|
|
1023
|
-
this.value.set([newMinValue, newMaxValue]);
|
|
1024
|
-
this.touch.emit();
|
|
1025
|
-
});
|
|
1177
|
+
this.zone.run(() => this.value.set([newMinValue, newMaxValue]));
|
|
1026
1178
|
}
|
|
1027
1179
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RangeSliderComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
1028
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: RangeSliderComponent, isStandalone: true, selector: "mona-range-slider", inputs: { ariaLabelEnd: { classPropertyName: "ariaLabelEnd", publicName: "aria-label-end", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelStart: { classPropertyName: "ariaLabelStart", publicName: "aria-label-start", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: {
|
|
1180
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: RangeSliderComponent, isStandalone: true, selector: "mona-range-slider", inputs: { ariaLabelEnd: { classPropertyName: "ariaLabelEnd", publicName: "aria-label-end", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelStart: { classPropertyName: "ariaLabelStart", publicName: "aria-label-start", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { properties: { "attr.aria-describedby": "null", "class": "baseClasses()", "class.mona-slider": "true", "attr.data-disabled": "effectiveDisabled() || null", "attr.data-orientation": "orientation()", "attr.data-readonly": "readonly() || null", "attr.aria-label": "ariaLabel()", "attr.aria-labelledby": "labelledBy()", "attr.role": "'group'" } }, viewQueries: [{ propertyName: "secondarySliderHandle", first: true, predicate: ["secondarySliderHandle"], descendants: true, isSignal: true }, { propertyName: "sliderHandle", first: true, predicate: ["sliderHandle"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div\n [class]=\"trackClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [style.height]=\"orientation() === 'horizontal' ? sliderTrackSize() : undefined\"\n [style.width]=\"orientation() === 'vertical' ? sliderTrackSize() : undefined\"\n [style]=\"trackBackgroundStyle()\">\n <div\n [class]=\"selectionClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [style.left.%]=\"horizontalSelectionLeft()\"\n [style.right.%]=\"horizontalSelectionRight()\"\n [style.bottom.%]=\"orientation() === 'vertical' ? selectionLeft() : undefined\"\n [style.top.%]=\"orientation() === 'vertical' ? 100 - selectionRight() : undefined\"\n [style]=\"selectionBackgroundStyle()\"></div>\n</div>\n@if (showTicks()) {\n <div [class]=\"tickListClasses()\" [attr.data-orientation]=\"orientation()\">\n @for (tick of renderTicks(); track tick.index) {\n <span\n [class]=\"tickClasses()\"\n [style]=\"tick | tickStyle: tickStyleArgs()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-value]=\"tick.value\"\n data-slider-tick>\n </span>\n }\n </div>\n}\n@if (showTicks() && showLabels()) {\n <div\n [class]=\"tickLabelListClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-label-position]=\"labelPosition()\">\n @for (tick of labelTicks(); track tick.index) {\n <span\n [class]=\"tickLabelClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [style]=\"tick | labelStyle: labelStyleArgs()\">\n @if (!tickValueTemplate()) {\n <span>{{ tick.label }}</span>\n } @else {\n <span>\n <ng-container\n *ngTemplateOutlet=\"\n tickValueTemplate() ?? null;\n context: { $implicit: tick.value }\n \"></ng-container>\n </span>\n }\n </span>\n }\n </div>\n}\n<div\n [class]=\"sliderHandleClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [attr.data-rtl]=\"isRtl() || null\"\n [attr.data-focused]=\"primaryHandleFocused()\"\n [style]=\"primaryHandleStyle()\"\n [style.left.%]=\"orientation() === 'horizontal' && !isRtl() ? primaryHandlePosition() : undefined\"\n [style.right.%]=\"orientation() === 'horizontal' && isRtl() ? primaryHandlePosition() : undefined\"\n [style.bottom.%]=\"orientation() === 'vertical' ? primaryHandlePosition() : undefined\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-valuemin]=\"effectiveMin()\"\n [attr.aria-valuemax]=\"normalizedValue()[1]\"\n [attr.aria-valuenow]=\"normalizedValue()[0]\"\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()[0]) : null\"\n [attr.aria-orientation]=\"orientation()\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n [attr.aria-describedby]=\"ariaDescribedBy()\"\n [attr.aria-label]=\"computedAriaLabelStart()\"\n [attr.aria-labelledby]=\"startLabelledBy()\"\n [attr.id]=\"startHandleId\"\n #sliderHandle>\n @if (handleTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue()[0] }\"></ng-container>\n }\n</div>\n<div\n [class]=\"sliderHandleClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [attr.data-rtl]=\"isRtl() || null\"\n [attr.data-focused]=\"secondaryHandleFocused()\"\n [style]=\"secondaryHandleStyle()\"\n [style.left.%]=\"orientation() === 'horizontal' && !isRtl() ? secondaryHandlePosition() : undefined\"\n [style.right.%]=\"orientation() === 'horizontal' && isRtl() ? secondaryHandlePosition() : undefined\"\n [style.bottom.%]=\"orientation() === 'vertical' ? secondaryHandlePosition() : undefined\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-valuemin]=\"normalizedValue()[0]\"\n [attr.aria-valuemax]=\"effectiveMax()\"\n [attr.aria-valuenow]=\"normalizedValue()[1]\"\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()[1]) : null\"\n [attr.aria-orientation]=\"orientation()\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n [attr.aria-describedby]=\"ariaDescribedBy()\"\n [attr.aria-label]=\"computedAriaLabelEnd()\"\n [attr.aria-labelledby]=\"endLabelledBy()\"\n [attr.id]=\"endHandleId\"\n #secondarySliderHandle>\n @if (handleTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue()[1] }\"></ng-container>\n }\n</div>\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: LabelStylePipe, name: "labelStyle" }, { kind: "pipe", type: TickStylePipe, name: "tickStyle" }] }); }
|
|
1029
1181
|
}
|
|
1030
1182
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RangeSliderComponent, decorators: [{
|
|
1031
1183
|
type: Component,
|
|
1032
|
-
args: [{ selector: "mona-range-slider", imports: [NgTemplateOutlet,
|
|
1184
|
+
args: [{ selector: "mona-range-slider", imports: [NgTemplateOutlet, LabelStylePipe, TickStylePipe], host: {
|
|
1185
|
+
// The description is applied to the handles, so the host must not keep the static attribute.
|
|
1186
|
+
"[attr.aria-describedby]": "null",
|
|
1033
1187
|
"[class]": "baseClasses()",
|
|
1034
1188
|
"[class.mona-slider]": "true",
|
|
1035
|
-
"[attr.data-disabled]": "effectiveDisabled()",
|
|
1189
|
+
"[attr.data-disabled]": "effectiveDisabled() || null",
|
|
1036
1190
|
"[attr.data-orientation]": "orientation()",
|
|
1037
|
-
"
|
|
1038
|
-
|
|
1191
|
+
"[attr.data-readonly]": "readonly() || null",
|
|
1192
|
+
"[attr.aria-label]": "ariaLabel()",
|
|
1193
|
+
"[attr.aria-labelledby]": "labelledBy()",
|
|
1194
|
+
"[attr.role]": "'group'"
|
|
1195
|
+
}, template: "<div\n [class]=\"trackClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [style.height]=\"orientation() === 'horizontal' ? sliderTrackSize() : undefined\"\n [style.width]=\"orientation() === 'vertical' ? sliderTrackSize() : undefined\"\n [style]=\"trackBackgroundStyle()\">\n <div\n [class]=\"selectionClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [style.left.%]=\"horizontalSelectionLeft()\"\n [style.right.%]=\"horizontalSelectionRight()\"\n [style.bottom.%]=\"orientation() === 'vertical' ? selectionLeft() : undefined\"\n [style.top.%]=\"orientation() === 'vertical' ? 100 - selectionRight() : undefined\"\n [style]=\"selectionBackgroundStyle()\"></div>\n</div>\n@if (showTicks()) {\n <div [class]=\"tickListClasses()\" [attr.data-orientation]=\"orientation()\">\n @for (tick of renderTicks(); track tick.index) {\n <span\n [class]=\"tickClasses()\"\n [style]=\"tick | tickStyle: tickStyleArgs()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-value]=\"tick.value\"\n data-slider-tick>\n </span>\n }\n </div>\n}\n@if (showTicks() && showLabels()) {\n <div\n [class]=\"tickLabelListClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-label-position]=\"labelPosition()\">\n @for (tick of labelTicks(); track tick.index) {\n <span\n [class]=\"tickLabelClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [style]=\"tick | labelStyle: labelStyleArgs()\">\n @if (!tickValueTemplate()) {\n <span>{{ tick.label }}</span>\n } @else {\n <span>\n <ng-container\n *ngTemplateOutlet=\"\n tickValueTemplate() ?? null;\n context: { $implicit: tick.value }\n \"></ng-container>\n </span>\n }\n </span>\n }\n </div>\n}\n<div\n [class]=\"sliderHandleClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [attr.data-rtl]=\"isRtl() || null\"\n [attr.data-focused]=\"primaryHandleFocused()\"\n [style]=\"primaryHandleStyle()\"\n [style.left.%]=\"orientation() === 'horizontal' && !isRtl() ? primaryHandlePosition() : undefined\"\n [style.right.%]=\"orientation() === 'horizontal' && isRtl() ? primaryHandlePosition() : undefined\"\n [style.bottom.%]=\"orientation() === 'vertical' ? primaryHandlePosition() : undefined\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-valuemin]=\"effectiveMin()\"\n [attr.aria-valuemax]=\"normalizedValue()[1]\"\n [attr.aria-valuenow]=\"normalizedValue()[0]\"\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()[0]) : null\"\n [attr.aria-orientation]=\"orientation()\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n [attr.aria-describedby]=\"ariaDescribedBy()\"\n [attr.aria-label]=\"computedAriaLabelStart()\"\n [attr.aria-labelledby]=\"startLabelledBy()\"\n [attr.id]=\"startHandleId\"\n #sliderHandle>\n @if (handleTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue()[0] }\"></ng-container>\n }\n</div>\n<div\n [class]=\"sliderHandleClasses()\"\n [attr.data-orientation]=\"orientation()\"\n [attr.data-dragging]=\"dragging()\"\n [attr.data-rtl]=\"isRtl() || null\"\n [attr.data-focused]=\"secondaryHandleFocused()\"\n [style]=\"secondaryHandleStyle()\"\n [style.left.%]=\"orientation() === 'horizontal' && !isRtl() ? secondaryHandlePosition() : undefined\"\n [style.right.%]=\"orientation() === 'horizontal' && isRtl() ? secondaryHandlePosition() : undefined\"\n [style.bottom.%]=\"orientation() === 'vertical' ? secondaryHandlePosition() : undefined\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-valuemin]=\"normalizedValue()[0]\"\n [attr.aria-valuemax]=\"effectiveMax()\"\n [attr.aria-valuenow]=\"normalizedValue()[1]\"\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()[1]) : null\"\n [attr.aria-orientation]=\"orientation()\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.data-invalid]=\"invalidState() || null\"\n [attr.aria-describedby]=\"ariaDescribedBy()\"\n [attr.aria-label]=\"computedAriaLabelEnd()\"\n [attr.aria-labelledby]=\"endLabelledBy()\"\n [attr.id]=\"endHandleId\"\n #secondarySliderHandle>\n @if (handleTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue()[1] }\"></ng-container>\n }\n</div>\n" }]
|
|
1039
1196
|
}], propDecorators: { secondarySliderHandle: [{ type: i0.ViewChild, args: ["secondarySliderHandle", { isSignal: true }] }], sliderHandle: [{ type: i0.ViewChild, args: ["sliderHandle", { isSignal: true }] }], ariaLabelEnd: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label-end", required: false }] }], ariaLabelStart: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label-start", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
1040
1197
|
|
|
1041
1198
|
/*
|