@nanahoshi/mona-ui 0.1.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 +25 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +590 -0
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +220 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +225 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +497 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +1569 -0
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +453 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +200 -0
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +853 -0
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +923 -0
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +495 -0
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +686 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +642 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +485 -0
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +132 -0
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +460 -0
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +659 -0
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +828 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +523 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +615 -0
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -0
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1400 -0
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +245 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +170 -0
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +680 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-B9SQH5N-.mjs +105 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DlLwcCFT.mjs +42 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-Dgea-O0X.mjs +130 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-toggle.component-DIUutx9s.mjs +773 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DRHycGIh.mjs +240 -0
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C3eZIaJK.mjs +5374 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +87 -0
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +154 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1356 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2263 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +379 -0
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +630 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +527 -0
- package/fesm2022/nanahoshi-mona-ui-list.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +966 -0
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +641 -0
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +536 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +597 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +790 -0
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +83 -0
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +325 -0
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1559 -0
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1321 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +294 -0
- package/fesm2022/nanahoshi-mona-ui-query.mjs +175 -0
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +565 -0
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1049 -0
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +636 -0
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +843 -0
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +537 -0
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +308 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +664 -0
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +111 -0
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +369 -0
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +314 -0
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +450 -0
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +723 -0
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +716 -0
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1329 -0
- package/fesm2022/nanahoshi-mona-ui.mjs +9 -0
- package/package.json +289 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +223 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +642 -0
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +70 -0
- package/types/nanahoshi-mona-ui-button-group.d.ts +77 -0
- package/types/nanahoshi-mona-ui-button.d.ts +111 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +262 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +133 -0
- package/types/nanahoshi-mona-ui-chip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +113 -0
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +201 -0
- package/types/nanahoshi-mona-ui-color-palette.d.ts +102 -0
- package/types/nanahoshi-mona-ui-color-picker.d.ts +156 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +232 -0
- package/types/nanahoshi-mona-ui-common.d.ts +386 -0
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +129 -0
- package/types/nanahoshi-mona-ui-date-input.d.ts +60 -0
- package/types/nanahoshi-mona-ui-date-picker.d.ts +177 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +199 -0
- package/types/nanahoshi-mona-ui-dialog.d.ts +261 -0
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +159 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +219 -0
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +176 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +113 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +87 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +68 -0
- package/types/nanahoshi-mona-ui-filter.d.ts +115 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +1114 -0
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +25 -0
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +28 -0
- package/types/nanahoshi-mona-ui-internal-list.d.ts +269 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +391 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +136 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +225 -0
- package/types/nanahoshi-mona-ui-list-view.d.ts +188 -0
- package/types/nanahoshi-mona-ui-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +198 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +247 -0
- package/types/nanahoshi-mona-ui-notification.d.ts +106 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +161 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +238 -0
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -0
- package/types/nanahoshi-mona-ui-popover.d.ts +130 -0
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +412 -0
- package/types/nanahoshi-mona-ui-popup.d.ts +485 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +139 -0
- package/types/nanahoshi-mona-ui-query.d.ts +89 -0
- package/types/nanahoshi-mona-ui-radio-button.d.ts +128 -0
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +166 -0
- package/types/nanahoshi-mona-ui-slider.d.ts +305 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +182 -0
- package/types/nanahoshi-mona-ui-splitter.d.ts +70 -0
- package/types/nanahoshi-mona-ui-stepper.d.ts +173 -0
- package/types/nanahoshi-mona-ui-switch.d.ts +125 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +158 -0
- package/types/nanahoshi-mona-ui-text-area.d.ts +42 -0
- package/types/nanahoshi-mona-ui-text-box.d.ts +164 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +23 -0
- package/types/nanahoshi-mona-ui-time-picker.d.ts +184 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +143 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-tree-view.d.ts +274 -0
- package/types/nanahoshi-mona-ui-window.d.ts +295 -0
- package/types/nanahoshi-mona-ui.d.ts +2 -0
|
@@ -0,0 +1,1049 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, ElementRef, Directive, Pipe, DestroyRef, signal, viewChildren, NgZone, computed, contentChild, TemplateRef, input, output, afterNextRender, viewChild, model, Component } from '@angular/core';
|
|
4
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
+
import { fromEvent, tap, filter, switchMap, takeUntil } from 'rxjs';
|
|
6
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
7
|
+
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { cva } from 'class-variance-authority';
|
|
9
|
+
|
|
10
|
+
class SliderTickDirective {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.host = inject(ElementRef);
|
|
13
|
+
}
|
|
14
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderTickDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
15
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SliderTickDirective, isStandalone: true, selector: "span[monaSliderTick]", ngImport: i0 }); }
|
|
16
|
+
}
|
|
17
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderTickDirective, decorators: [{
|
|
18
|
+
type: Directive,
|
|
19
|
+
args: [{
|
|
20
|
+
selector: "span[monaSliderTick]"
|
|
21
|
+
}]
|
|
22
|
+
}] });
|
|
23
|
+
|
|
24
|
+
const valueToPosition = (value, min, max) => {
|
|
25
|
+
if (value <= min) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
if (value >= max) {
|
|
29
|
+
return 100;
|
|
30
|
+
}
|
|
31
|
+
if (max === min) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
return ((value - min) / (max - min)) * 100;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
class LabelStylePipe {
|
|
38
|
+
transform(tick, args) {
|
|
39
|
+
const styles = {};
|
|
40
|
+
const { labelPosition, min, max, orientation } = args;
|
|
41
|
+
const valuePosition = valueToPosition(tick.value, min, max);
|
|
42
|
+
if (orientation === "horizontal") {
|
|
43
|
+
styles.left = `${valuePosition}%`;
|
|
44
|
+
styles[labelPosition === "before" ? "bottom" : "top"] = "100%";
|
|
45
|
+
styles.transform = "translateX(-50%)";
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
styles.bottom = `${valuePosition}%`;
|
|
49
|
+
styles[labelPosition === "before" ? "right" : "left"] = "100%";
|
|
50
|
+
styles.transform = "translateY(50%)";
|
|
51
|
+
}
|
|
52
|
+
return styles;
|
|
53
|
+
}
|
|
54
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LabelStylePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
55
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: LabelStylePipe, isStandalone: true, name: "labelStyle" }); }
|
|
56
|
+
}
|
|
57
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: LabelStylePipe, decorators: [{
|
|
58
|
+
type: Pipe,
|
|
59
|
+
args: [{
|
|
60
|
+
name: "labelStyle"
|
|
61
|
+
}]
|
|
62
|
+
}] });
|
|
63
|
+
|
|
64
|
+
class TickStylePipe {
|
|
65
|
+
transform(tick, args) {
|
|
66
|
+
const { largeTickStep, min, max, orientation, smallTickStep } = args;
|
|
67
|
+
const position = valueToPosition(tick.value, min, max);
|
|
68
|
+
const height = this.getHeight(tick, smallTickStep, largeTickStep, orientation);
|
|
69
|
+
const width = this.getWidth(tick, smallTickStep, largeTickStep, orientation);
|
|
70
|
+
if (orientation === "horizontal") {
|
|
71
|
+
return {
|
|
72
|
+
position: "absolute",
|
|
73
|
+
left: `${position}%`,
|
|
74
|
+
top: "50%",
|
|
75
|
+
transform: "translateX(-50%) translateY(-50%) translateZ(0)",
|
|
76
|
+
width: "1px",
|
|
77
|
+
height: `${height}px`,
|
|
78
|
+
backfaceVisibility: "hidden",
|
|
79
|
+
willChange: "transform"
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return {
|
|
84
|
+
position: "absolute",
|
|
85
|
+
bottom: `${position}%`,
|
|
86
|
+
left: "50%",
|
|
87
|
+
transform: "translateX(-50%) translateY(50%) translateZ(0)",
|
|
88
|
+
width: `${width}px`,
|
|
89
|
+
height: "1px",
|
|
90
|
+
backfaceVisibility: "hidden"
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
getHeight(tick, smallStep, largeStep, orientation) {
|
|
95
|
+
if (orientation === "vertical") {
|
|
96
|
+
return 8;
|
|
97
|
+
}
|
|
98
|
+
if (smallStep === 1 && largeStep === null) {
|
|
99
|
+
return 16;
|
|
100
|
+
}
|
|
101
|
+
if (smallStep === 1 && largeStep !== null) {
|
|
102
|
+
return tick.index % largeStep !== 0 ? 16 : 24;
|
|
103
|
+
}
|
|
104
|
+
if (smallStep > 1 && largeStep === null) {
|
|
105
|
+
return tick.index % smallStep !== 0 ? 0 : 16;
|
|
106
|
+
}
|
|
107
|
+
if (smallStep > 1 && largeStep !== null) {
|
|
108
|
+
return tick.index % smallStep !== 0 ? 0 : tick.index % largeStep !== 0 ? 16 : 24;
|
|
109
|
+
}
|
|
110
|
+
return 8;
|
|
111
|
+
}
|
|
112
|
+
getWidth(tick, smallStep, largeStep, orientation) {
|
|
113
|
+
if (orientation === "vertical") {
|
|
114
|
+
if (smallStep === 1) {
|
|
115
|
+
return 16; // Default width for vertical orientation with no step
|
|
116
|
+
}
|
|
117
|
+
return tick.index % smallStep !== 0 ? 0 : 16;
|
|
118
|
+
}
|
|
119
|
+
return 8; // Default width for horizontal orientation
|
|
120
|
+
}
|
|
121
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TickStylePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
122
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: TickStylePipe, isStandalone: true, name: "tickStyle" }); }
|
|
123
|
+
}
|
|
124
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TickStylePipe, decorators: [{
|
|
125
|
+
type: Pipe,
|
|
126
|
+
args: [{
|
|
127
|
+
name: "tickStyle"
|
|
128
|
+
}]
|
|
129
|
+
}] });
|
|
130
|
+
|
|
131
|
+
class SliderHandleTemplateDirective {
|
|
132
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderHandleTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
133
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SliderHandleTemplateDirective, isStandalone: true, selector: "ng-template[monaSliderHandleTemplate]", ngImport: i0 }); }
|
|
134
|
+
}
|
|
135
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderHandleTemplateDirective, decorators: [{
|
|
136
|
+
type: Directive,
|
|
137
|
+
args: [{
|
|
138
|
+
selector: "ng-template[monaSliderHandleTemplate]"
|
|
139
|
+
}]
|
|
140
|
+
}] });
|
|
141
|
+
|
|
142
|
+
class SliderTickValueTemplateDirective {
|
|
143
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderTickValueTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
144
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SliderTickValueTemplateDirective, isStandalone: true, selector: "ng-template[monaSliderTickValueTemplate]", ngImport: i0 }); }
|
|
145
|
+
}
|
|
146
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderTickValueTemplateDirective, decorators: [{
|
|
147
|
+
type: Directive,
|
|
148
|
+
args: [{
|
|
149
|
+
selector: "ng-template[monaSliderTickValueTemplate]"
|
|
150
|
+
}]
|
|
151
|
+
}] });
|
|
152
|
+
|
|
153
|
+
const sliderBaseVariants = cva(`
|
|
154
|
+
flex relative select-none
|
|
155
|
+
|
|
156
|
+
data-[orientation="horizontal"]:h-6
|
|
157
|
+
data-[orientation="horizontal"]:w-full
|
|
158
|
+
data-[orientation="horizontal"]:min-w-[200px]
|
|
159
|
+
data-[orientation="horizontal"]:items-center
|
|
160
|
+
|
|
161
|
+
data-[orientation="vertical"]:w-6
|
|
162
|
+
data-[orientation="vertical"]:h-[200px]
|
|
163
|
+
data-[orientation="vertical"]:justify-center
|
|
164
|
+
|
|
165
|
+
data-[disabled="true"]:pointer-events-none
|
|
166
|
+
data-[disabled="true"]:opacity-50
|
|
167
|
+
data-[disabled="true"]:cursor-not-allowed
|
|
168
|
+
`);
|
|
169
|
+
const sliderTrackVariants = cva(`
|
|
170
|
+
relative z-2 cursor-pointer
|
|
171
|
+
border border-input-border
|
|
172
|
+
bg-background
|
|
173
|
+
|
|
174
|
+
data-[orientation="horizontal"]:w-full
|
|
175
|
+
data-[orientation="horizontal"]:h-1.5
|
|
176
|
+
|
|
177
|
+
data-[orientation="vertical"]:h-full
|
|
178
|
+
data-[orientation="vertical"]:w-1.5
|
|
179
|
+
|
|
180
|
+
`);
|
|
181
|
+
const sliderSelectionVariants = cva(`
|
|
182
|
+
absolute
|
|
183
|
+
bg-primary border-none
|
|
184
|
+
|
|
185
|
+
ease-out duration-200
|
|
186
|
+
|
|
187
|
+
data-[orientation="horizontal"]:top-0
|
|
188
|
+
data-[orientation="horizontal"]:bottom-0
|
|
189
|
+
data-[orientation="horizontal"]:transition-[left,right]
|
|
190
|
+
data-[orientation="horizontal"]:data-[dragging="true"]:transition-none
|
|
191
|
+
|
|
192
|
+
data-[orientation="vertical"]:left-0
|
|
193
|
+
data-[orientation="vertical"]:right-0
|
|
194
|
+
data-[orientation="vertical"]:transition-[top,bottom]
|
|
195
|
+
data-[orientation="vertical"]:data-[dragging="true"]:transition-none
|
|
196
|
+
`);
|
|
197
|
+
const sliderTickListVariants = cva(`
|
|
198
|
+
absolute
|
|
199
|
+
|
|
200
|
+
data-[orientation="horizontal"]:w-full
|
|
201
|
+
data-[orientation="horizontal"]:h-6
|
|
202
|
+
data-[orientation="horizontal"]:top-0
|
|
203
|
+
data-[orientation="horizontal"]:left-0
|
|
204
|
+
|
|
205
|
+
data-[orientation="vertical"]:w-6
|
|
206
|
+
data-[orientation="vertical"]:h-full
|
|
207
|
+
data-[orientation="vertical"]:top-0
|
|
208
|
+
data-[orientation="vertical"]:left-0
|
|
209
|
+
`);
|
|
210
|
+
const sliderTickVariants = cva(`
|
|
211
|
+
cursor-pointer
|
|
212
|
+
bg-input-border
|
|
213
|
+
brightness-75
|
|
214
|
+
`);
|
|
215
|
+
const sliderTickLabelListVariants = cva(`
|
|
216
|
+
absolute
|
|
217
|
+
w-full h-full
|
|
218
|
+
select-none
|
|
219
|
+
`);
|
|
220
|
+
const sliderTickLabelVariants = cva(`
|
|
221
|
+
absolute flex
|
|
222
|
+
items-center justify-center
|
|
223
|
+
|
|
224
|
+
text-xs/[1.667]
|
|
225
|
+
text-foreground
|
|
226
|
+
|
|
227
|
+
data-[orientation="vertical"]:w-4.25
|
|
228
|
+
data-[orientation="vertical"]:h-auto
|
|
229
|
+
`);
|
|
230
|
+
const sliderHandleVariants = cva(`
|
|
231
|
+
absolute z-2 flex items-center justify-center
|
|
232
|
+
w-4.25 h-4.25
|
|
233
|
+
cursor-pointer
|
|
234
|
+
outline-none
|
|
235
|
+
bg-primary border border-border
|
|
236
|
+
|
|
237
|
+
ease-out duration-200
|
|
238
|
+
|
|
239
|
+
data-[orientation="horizontal"]:translate-x-[-50%]
|
|
240
|
+
data-[orientation="horizontal"]:transition-[left]
|
|
241
|
+
data-[orientation="horizontal"]:data-[dragging="true"]:transition-none
|
|
242
|
+
|
|
243
|
+
data-[orientation="vertical"]:translate-y-[50%]
|
|
244
|
+
data-[orientation="vertical"]:transition-[bottom]
|
|
245
|
+
data-[orientation="vertical"]:data-[dragging="true"]:transition-none
|
|
246
|
+
|
|
247
|
+
data-[focused="true"]:ring-2
|
|
248
|
+
data-[focused="true"]:ring-primary/40
|
|
249
|
+
|
|
250
|
+
data-[invalid="true"]:border-error
|
|
251
|
+
data-[invalid="true"]:ring-2 data-[invalid="true"]:ring-error/40
|
|
252
|
+
`, {
|
|
253
|
+
variants: {
|
|
254
|
+
rounded: {
|
|
255
|
+
full: "rounded-full",
|
|
256
|
+
large: "rounded-lg",
|
|
257
|
+
medium: "rounded-md",
|
|
258
|
+
none: "rounded-none",
|
|
259
|
+
small: "rounded-sm"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const sliderBaseThemeVariants = (theme) => {
|
|
265
|
+
switch (theme) {
|
|
266
|
+
case "mona":
|
|
267
|
+
return sliderBaseVariants;
|
|
268
|
+
default:
|
|
269
|
+
return sliderBaseVariants; // Default to Mona styles
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
const sliderTrackThemeVariants = (theme) => {
|
|
273
|
+
switch (theme) {
|
|
274
|
+
case "mona":
|
|
275
|
+
return sliderTrackVariants;
|
|
276
|
+
default:
|
|
277
|
+
return sliderTrackVariants; // Default to Mona styles
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
const sliderSelectionThemeVariants = (theme) => {
|
|
281
|
+
switch (theme) {
|
|
282
|
+
case "mona":
|
|
283
|
+
return sliderSelectionVariants;
|
|
284
|
+
default:
|
|
285
|
+
return sliderSelectionVariants; // Default to Mona styles
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
const sliderTickListThemeVariants = (theme) => {
|
|
289
|
+
switch (theme) {
|
|
290
|
+
case "mona":
|
|
291
|
+
return sliderTickListVariants;
|
|
292
|
+
default:
|
|
293
|
+
return sliderTickListVariants; // Default to Mona styles
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
const sliderTickThemeVariants = (theme) => {
|
|
297
|
+
switch (theme) {
|
|
298
|
+
case "mona":
|
|
299
|
+
return sliderTickVariants;
|
|
300
|
+
default:
|
|
301
|
+
return sliderTickVariants; // Default to Mona styles
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
const sliderTickLabelListThemeVariants = (theme) => {
|
|
305
|
+
switch (theme) {
|
|
306
|
+
case "mona":
|
|
307
|
+
return sliderTickLabelListVariants;
|
|
308
|
+
default:
|
|
309
|
+
return sliderTickLabelListVariants; // Default to Mona styles
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
const sliderTickLabelThemeVariants = (theme) => {
|
|
313
|
+
switch (theme) {
|
|
314
|
+
case "mona":
|
|
315
|
+
return sliderTickLabelVariants;
|
|
316
|
+
default:
|
|
317
|
+
return sliderTickLabelVariants; // Default to Mona styles
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const sliderHandleThemeVariants = (theme) => {
|
|
321
|
+
switch (theme) {
|
|
322
|
+
case "mona":
|
|
323
|
+
return sliderHandleVariants;
|
|
324
|
+
default:
|
|
325
|
+
return sliderHandleVariants; // Default to Mona styles
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
class SliderBaseComponent {
|
|
330
|
+
#themeService;
|
|
331
|
+
constructor() {
|
|
332
|
+
this.#themeService = inject(ThemeService);
|
|
333
|
+
this.destroyRef = inject(DestroyRef);
|
|
334
|
+
this.dragging = signal(false, /* @ts-ignore */
|
|
335
|
+
...(ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []));
|
|
336
|
+
this.hostElementRef = inject(ElementRef);
|
|
337
|
+
this.tickElements = viewChildren(SliderTickDirective, /* @ts-ignore */
|
|
338
|
+
...(ngDevMode ? [{ debugName: "tickElements" }] : /* istanbul ignore next */ []));
|
|
339
|
+
this.zone = inject(NgZone);
|
|
340
|
+
this.baseClasses = computed(() => sliderBaseThemeVariants(this.#themeService.theme())(), /* @ts-ignore */
|
|
341
|
+
...(ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []));
|
|
342
|
+
this.effectiveDisabled = computed(() => this.disabled(), /* @ts-ignore */
|
|
343
|
+
...(ngDevMode ? [{ debugName: "effectiveDisabled" }] : /* istanbul ignore next */ []));
|
|
344
|
+
this.handleTemplate = contentChild(SliderHandleTemplateDirective, { ...(ngDevMode ? { debugName: "handleTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
345
|
+
this.handleTemplateStyles = computed(() => {
|
|
346
|
+
const template = this.handleTemplate();
|
|
347
|
+
if (!template) {
|
|
348
|
+
return {};
|
|
349
|
+
}
|
|
350
|
+
return { background: "transparent", border: "none", boxShadow: "none" };
|
|
351
|
+
}, /* @ts-ignore */
|
|
352
|
+
...(ngDevMode ? [{ debugName: "handleTemplateStyles" }] : /* istanbul ignore next */ []));
|
|
353
|
+
this.labelStyleArgs = computed(() => {
|
|
354
|
+
const labelPosition = this.labelPosition();
|
|
355
|
+
const max = this.maxValue();
|
|
356
|
+
const min = this.minValue();
|
|
357
|
+
const orientation = this.orientation();
|
|
358
|
+
const tickCount = this.labelTicks().length;
|
|
359
|
+
return { labelPosition, max, min, orientation, tickCount };
|
|
360
|
+
}, /* @ts-ignore */
|
|
361
|
+
...(ngDevMode ? [{ debugName: "labelStyleArgs" }] : /* istanbul ignore next */ []));
|
|
362
|
+
this.labelTicks = computed(() => {
|
|
363
|
+
const allTicks = this.ticks();
|
|
364
|
+
if (allTicks.length === 0) {
|
|
365
|
+
return [];
|
|
366
|
+
}
|
|
367
|
+
const tickStep = this.labelStep();
|
|
368
|
+
const lastTick = allTicks[allTicks.length - 1];
|
|
369
|
+
const labels = allTicks.filter(t => t.index % tickStep === 0);
|
|
370
|
+
if (labels.length === 0 || labels[labels.length - 1].value !== lastTick.value) {
|
|
371
|
+
labels.push(lastTick);
|
|
372
|
+
}
|
|
373
|
+
if (labels.length >= 2) {
|
|
374
|
+
const penultimate = labels[labels.length - 2];
|
|
375
|
+
const last = labels[labels.length - 1];
|
|
376
|
+
const penultimatePos = valueToPosition(penultimate.value, this.minValue(), this.maxValue());
|
|
377
|
+
const lastPos = valueToPosition(last.value, this.minValue(), this.maxValue());
|
|
378
|
+
if (this.step() !== 1 && lastPos - penultimatePos < 4) {
|
|
379
|
+
labels.splice(labels.length - 2, 1);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return labels;
|
|
383
|
+
}, /* @ts-ignore */
|
|
384
|
+
...(ngDevMode ? [{ debugName: "labelTicks" }] : /* istanbul ignore next */ []));
|
|
385
|
+
this.renderTicks = computed(() => {
|
|
386
|
+
const ticks = this.ticks();
|
|
387
|
+
if (this.orientation() === "vertical") {
|
|
388
|
+
return ticks.slice().reverse();
|
|
389
|
+
}
|
|
390
|
+
return ticks;
|
|
391
|
+
}, /* @ts-ignore */
|
|
392
|
+
...(ngDevMode ? [{ debugName: "renderTicks" }] : /* istanbul ignore next */ []));
|
|
393
|
+
this.selectionBackgroundStyle = computed(() => {
|
|
394
|
+
const bg = this.selectionBackground();
|
|
395
|
+
if (!bg) {
|
|
396
|
+
return {};
|
|
397
|
+
}
|
|
398
|
+
return typeof bg === "string" ? { background: bg } : bg;
|
|
399
|
+
}, /* @ts-ignore */
|
|
400
|
+
...(ngDevMode ? [{ debugName: "selectionBackgroundStyle" }] : /* istanbul ignore next */ []));
|
|
401
|
+
this.selectionClasses = computed(() => sliderSelectionThemeVariants(this.#themeService.theme())(), /* @ts-ignore */
|
|
402
|
+
...(ngDevMode ? [{ debugName: "selectionClasses" }] : /* istanbul ignore next */ []));
|
|
403
|
+
this.sliderHandleClasses = computed(() => {
|
|
404
|
+
const rounded = this.rounded();
|
|
405
|
+
const handleClasses = this.handleClasses();
|
|
406
|
+
const variants = sliderHandleThemeVariants(this.#themeService.theme())({ rounded });
|
|
407
|
+
return twMerge(variants ?? "", Array.isArray(handleClasses) ? handleClasses.join(" ") : handleClasses);
|
|
408
|
+
}, /* @ts-ignore */
|
|
409
|
+
...(ngDevMode ? [{ debugName: "sliderHandleClasses" }] : /* istanbul ignore next */ []));
|
|
410
|
+
this.sliderTrackSize = computed(() => {
|
|
411
|
+
const trackSize = this.trackSize();
|
|
412
|
+
if (trackSize == null || trackSize === "") {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
if (typeof trackSize === "number") {
|
|
416
|
+
return `${trackSize}px`;
|
|
417
|
+
}
|
|
418
|
+
const number = Number(trackSize);
|
|
419
|
+
if (isNaN(number)) {
|
|
420
|
+
return trackSize;
|
|
421
|
+
}
|
|
422
|
+
return `${number}px`;
|
|
423
|
+
}, /* @ts-ignore */
|
|
424
|
+
...(ngDevMode ? [{ debugName: "sliderTrackSize" }] : /* istanbul ignore next */ []));
|
|
425
|
+
this.tickClasses = computed(() => sliderTickThemeVariants(this.#themeService.theme())(), /* @ts-ignore */
|
|
426
|
+
...(ngDevMode ? [{ debugName: "tickClasses" }] : /* istanbul ignore next */ []));
|
|
427
|
+
this.tickLabelClasses = computed(() => sliderTickLabelThemeVariants(this.#themeService.theme())(), /* @ts-ignore */
|
|
428
|
+
...(ngDevMode ? [{ debugName: "tickLabelClasses" }] : /* istanbul ignore next */ []));
|
|
429
|
+
this.tickLabelListClasses = computed(() => sliderTickLabelListThemeVariants(this.#themeService.theme())(), /* @ts-ignore */
|
|
430
|
+
...(ngDevMode ? [{ debugName: "tickLabelListClasses" }] : /* istanbul ignore next */ []));
|
|
431
|
+
this.tickListClasses = computed(() => sliderTickListThemeVariants(this.#themeService.theme())(), /* @ts-ignore */
|
|
432
|
+
...(ngDevMode ? [{ debugName: "tickListClasses" }] : /* istanbul ignore next */ []));
|
|
433
|
+
this.tickStyleArgs = computed(() => {
|
|
434
|
+
const largeTickStep = this.largeTickStep();
|
|
435
|
+
const max = this.maxValue();
|
|
436
|
+
const min = this.minValue();
|
|
437
|
+
const orientation = this.orientation();
|
|
438
|
+
const smallTickStep = this.smallTickStep();
|
|
439
|
+
return { largeTickStep, max, min, orientation, smallTickStep };
|
|
440
|
+
}, /* @ts-ignore */
|
|
441
|
+
...(ngDevMode ? [{ debugName: "tickStyleArgs" }] : /* istanbul ignore next */ []));
|
|
442
|
+
this.tickValueTemplate = contentChild(SliderTickValueTemplateDirective, { ...(ngDevMode ? { debugName: "tickValueTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
443
|
+
this.ticks = computed(() => {
|
|
444
|
+
const min = this.minValue();
|
|
445
|
+
const max = this.maxValue();
|
|
446
|
+
const step = this.step();
|
|
447
|
+
const ticks = [];
|
|
448
|
+
const count = Math.floor((max - min) / step);
|
|
449
|
+
for (let i = 0; i <= count; i++) {
|
|
450
|
+
const value = min + i * step;
|
|
451
|
+
ticks.push({ index: i, value });
|
|
452
|
+
}
|
|
453
|
+
if (ticks.length === 0 || ticks[ticks.length - 1].value < max) {
|
|
454
|
+
ticks.push({ index: ticks.length, value: max });
|
|
455
|
+
}
|
|
456
|
+
return ticks;
|
|
457
|
+
}, /* @ts-ignore */
|
|
458
|
+
...(ngDevMode ? [{ debugName: "ticks" }] : /* istanbul ignore next */ []));
|
|
459
|
+
this.trackBackgroundStyle = computed(() => {
|
|
460
|
+
const bg = this.trackBackground();
|
|
461
|
+
if (!bg) {
|
|
462
|
+
return {};
|
|
463
|
+
}
|
|
464
|
+
return typeof bg === "string" ? { background: bg } : bg;
|
|
465
|
+
}, /* @ts-ignore */
|
|
466
|
+
...(ngDevMode ? [{ debugName: "trackBackgroundStyle" }] : /* istanbul ignore next */ []));
|
|
467
|
+
this.trackClasses = computed(() => sliderTrackThemeVariants(this.#themeService.theme())(), /* @ts-ignore */
|
|
468
|
+
...(ngDevMode ? [{ debugName: "trackClasses" }] : /* istanbul ignore next */ []));
|
|
469
|
+
/**
|
|
470
|
+
* @description Human-readable override for the `aria-valuenow` announcement. Pass a function that receives the current value and returns the string to announce.
|
|
471
|
+
* @default null
|
|
472
|
+
*/
|
|
473
|
+
this.ariaValueText = input(null, /* @ts-ignore */
|
|
474
|
+
...(ngDevMode ? [{ debugName: "ariaValueText" }] : /* istanbul ignore next */ []));
|
|
475
|
+
/**
|
|
476
|
+
* @description Renders the component with reduced visual emphasis and removes pointer interaction.
|
|
477
|
+
* @default false
|
|
478
|
+
*/
|
|
479
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
480
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
481
|
+
/**
|
|
482
|
+
* @description Additional CSS classes to apply to the slider handle.
|
|
483
|
+
* @default []
|
|
484
|
+
*/
|
|
485
|
+
this.handleClasses = input([], /* @ts-ignore */
|
|
486
|
+
...(ngDevMode ? [{ debugName: "handleClasses" }] : /* istanbul ignore next */ []));
|
|
487
|
+
/**
|
|
488
|
+
* @description Additional inline styles to apply to the slider handle.
|
|
489
|
+
* @default {}
|
|
490
|
+
*/
|
|
491
|
+
this.handleStyles = input({}, /* @ts-ignore */
|
|
492
|
+
...(ngDevMode ? [{ debugName: "handleStyles" }] : /* istanbul ignore next */ []));
|
|
493
|
+
/**
|
|
494
|
+
* @description Marks the control as invalid for form validation purposes, reflecting `aria-invalid` on the handle element.
|
|
495
|
+
* @default false
|
|
496
|
+
*/
|
|
497
|
+
this.invalid = input(false, /* @ts-ignore */
|
|
498
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
499
|
+
/**
|
|
500
|
+
* @description Position of the label relative to the component.
|
|
501
|
+
* @default "after"
|
|
502
|
+
*/
|
|
503
|
+
this.labelPosition = input("after", /* @ts-ignore */
|
|
504
|
+
...(ngDevMode ? [{ debugName: "labelPosition" }] : /* istanbul ignore next */ []));
|
|
505
|
+
/**
|
|
506
|
+
* @description Controls which tick labels are shown — only every n<sup>th</sup> label is rendered.
|
|
507
|
+
* @default 1
|
|
508
|
+
*/
|
|
509
|
+
this.labelStep = input(1, /* @ts-ignore */
|
|
510
|
+
...(ngDevMode ? [{ debugName: "labelStep" }] : /* istanbul ignore next */ []));
|
|
511
|
+
/**
|
|
512
|
+
* @description Controls which ticks render at large size — only every n<sup>th</sup> tick is enlarged. Pass `null` to disable large ticks.
|
|
513
|
+
* @default null
|
|
514
|
+
*/
|
|
515
|
+
this.largeTickStep = input(null, /* @ts-ignore */
|
|
516
|
+
...(ngDevMode ? [{ debugName: "largeTickStep" }] : /* istanbul ignore next */ []));
|
|
517
|
+
/**
|
|
518
|
+
* @description Upper bound of the value range. Must be greater than `minValue`.
|
|
519
|
+
* @default 10
|
|
520
|
+
*/
|
|
521
|
+
this.maxValue = input(10, /* @ts-ignore */
|
|
522
|
+
...(ngDevMode ? [{ debugName: "maxValue" }] : /* istanbul ignore next */ []));
|
|
523
|
+
/**
|
|
524
|
+
* @description Lower bound of the value range.
|
|
525
|
+
* @default 0
|
|
526
|
+
*/
|
|
527
|
+
this.minValue = input(0, /* @ts-ignore */
|
|
528
|
+
...(ngDevMode ? [{ debugName: "minValue" }] : /* istanbul ignore next */ []));
|
|
529
|
+
/**
|
|
530
|
+
* @description Layout orientation of the component.
|
|
531
|
+
* @default "horizontal"
|
|
532
|
+
*/
|
|
533
|
+
this.orientation = input("horizontal", /* @ts-ignore */
|
|
534
|
+
...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
535
|
+
/**
|
|
536
|
+
* @description Border-radius preset applied to the slider handle.
|
|
537
|
+
* @default "full"
|
|
538
|
+
*/
|
|
539
|
+
this.rounded = input("full", /* @ts-ignore */
|
|
540
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
541
|
+
/**
|
|
542
|
+
* @description Background color of the filled selection area between the minimum and the current value. Accepts a CSS color string or a `CSSStyleDeclaration` partial.
|
|
543
|
+
* @default null
|
|
544
|
+
*/
|
|
545
|
+
this.selectionBackground = input(null, /* @ts-ignore */
|
|
546
|
+
...(ngDevMode ? [{ debugName: "selectionBackground" }] : /* istanbul ignore next */ []));
|
|
547
|
+
/**
|
|
548
|
+
* @description Multiplier applied to the step when the user holds Shift while pressing an arrow key.
|
|
549
|
+
* @default 10
|
|
550
|
+
*/
|
|
551
|
+
this.shiftMultiplier = input(10, /* @ts-ignore */
|
|
552
|
+
...(ngDevMode ? [{ debugName: "shiftMultiplier" }] : /* istanbul ignore next */ []));
|
|
553
|
+
/**
|
|
554
|
+
* @description Displays value labels alongside tick marks. Only takes effect when `showTicks` is `true`.
|
|
555
|
+
* @default false
|
|
556
|
+
*/
|
|
557
|
+
this.showLabels = input(false, /* @ts-ignore */
|
|
558
|
+
...(ngDevMode ? [{ debugName: "showLabels" }] : /* istanbul ignore next */ []));
|
|
559
|
+
/**
|
|
560
|
+
* @description Displays tick marks at each step position along the track.
|
|
561
|
+
* @default false
|
|
562
|
+
*/
|
|
563
|
+
this.showTicks = input(false, /* @ts-ignore */
|
|
564
|
+
...(ngDevMode ? [{ debugName: "showTicks" }] : /* istanbul ignore next */ []));
|
|
565
|
+
/**
|
|
566
|
+
* @description Controls how many ticks are visible — only every n<sup>th</sup> tick is rendered.
|
|
567
|
+
* @default 1
|
|
568
|
+
*/
|
|
569
|
+
this.smallTickStep = input(1, { ...(ngDevMode ? { debugName: "smallTickStep" } : /* istanbul ignore next */ {}), transform: (value) => Math.max(value, 1) });
|
|
570
|
+
/**
|
|
571
|
+
* @description Increment applied when the value changes via keyboard navigation.
|
|
572
|
+
* @default 1
|
|
573
|
+
*/
|
|
574
|
+
this.step = input(1, { ...(ngDevMode ? { debugName: "step" } : /* istanbul ignore next */ {}), transform: (value) => (value <= 0 ? 1 : value) });
|
|
575
|
+
/**
|
|
576
|
+
* @description Emitted when the slider loses focus or its value changes via keyboard navigation.
|
|
577
|
+
*/
|
|
578
|
+
this.touch = output();
|
|
579
|
+
/**
|
|
580
|
+
* @description Background color of the unfilled track portion. Accepts a CSS color string or a `CSSStyleDeclaration` partial.
|
|
581
|
+
* @default null
|
|
582
|
+
*/
|
|
583
|
+
this.trackBackground = input(null, /* @ts-ignore */
|
|
584
|
+
...(ngDevMode ? [{ debugName: "trackBackground" }] : /* istanbul ignore next */ []));
|
|
585
|
+
/**
|
|
586
|
+
* @description Width (vertical orientation) or height (horizontal orientation) of the track. Accepts a pixel number or any CSS length string.
|
|
587
|
+
* @default undefined
|
|
588
|
+
*/
|
|
589
|
+
this.trackSize = input(/* @ts-ignore */
|
|
590
|
+
...(ngDevMode ? [undefined, { debugName: "trackSize" }] : /* istanbul ignore next */ []));
|
|
591
|
+
afterNextRender({
|
|
592
|
+
read: () => this.zone.runOutsideAngular(() => this.setSubscriptions())
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
calculateNewValue(currentValue, event) {
|
|
596
|
+
const min = this.minValue();
|
|
597
|
+
const max = this.maxValue();
|
|
598
|
+
const step = this.step();
|
|
599
|
+
let newValue = currentValue;
|
|
600
|
+
switch (event.key) {
|
|
601
|
+
case "ArrowLeft":
|
|
602
|
+
case "ArrowDown":
|
|
603
|
+
newValue = currentValue - (event.shiftKey ? step * this.shiftMultiplier() : step);
|
|
604
|
+
break;
|
|
605
|
+
case "ArrowRight":
|
|
606
|
+
case "ArrowUp":
|
|
607
|
+
newValue = currentValue + (event.shiftKey ? step * this.shiftMultiplier() : step);
|
|
608
|
+
break;
|
|
609
|
+
case "Home":
|
|
610
|
+
newValue = min;
|
|
611
|
+
break;
|
|
612
|
+
case "End":
|
|
613
|
+
newValue = max;
|
|
614
|
+
break;
|
|
615
|
+
case "PageDown":
|
|
616
|
+
newValue = currentValue - (max - min) * 0.1;
|
|
617
|
+
break;
|
|
618
|
+
case "PageUp":
|
|
619
|
+
newValue = currentValue + (max - min) * 0.1;
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
return this.snapValue(newValue);
|
|
623
|
+
}
|
|
624
|
+
clampValue(value) {
|
|
625
|
+
return Math.max(this.minValue(), Math.min(this.maxValue(), value));
|
|
626
|
+
}
|
|
627
|
+
findClosestTickElement(event) {
|
|
628
|
+
const elements = this.tickElements().map(tick => tick.host.nativeElement);
|
|
629
|
+
let maxDistance = Number.MAX_VALUE;
|
|
630
|
+
let index = 0;
|
|
631
|
+
for (const [ex, element] of elements.entries()) {
|
|
632
|
+
const rect = element.getBoundingClientRect();
|
|
633
|
+
const distance = Math.sqrt(Math.pow(rect.left - event.clientX, 2) + Math.pow(rect.top - event.clientY, 2));
|
|
634
|
+
if (distance < maxDistance) {
|
|
635
|
+
maxDistance = distance;
|
|
636
|
+
index = ex;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return elements[index];
|
|
640
|
+
}
|
|
641
|
+
getValueFromPointerEvent(event) {
|
|
642
|
+
if (this.showTicks()) {
|
|
643
|
+
const tick = this.findClosestTickElement(event);
|
|
644
|
+
const valueStr = tick.getAttribute("data-value");
|
|
645
|
+
return valueStr ? Number(valueStr) : this.minValue();
|
|
646
|
+
}
|
|
647
|
+
const containerRect = this.hostElementRef.nativeElement.getBoundingClientRect();
|
|
648
|
+
let normalizedHandlePos;
|
|
649
|
+
if (this.orientation() === "horizontal") {
|
|
650
|
+
const handlePos = event.clientX - containerRect.left;
|
|
651
|
+
normalizedHandlePos = (handlePos / containerRect.width) * 100;
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
const handlePos = event.clientY - containerRect.top;
|
|
655
|
+
normalizedHandlePos = 100 - (handlePos / containerRect.height) * 100;
|
|
656
|
+
}
|
|
657
|
+
normalizedHandlePos = Math.max(0, Math.min(normalizedHandlePos, 100));
|
|
658
|
+
return this.getValueFromPosition(normalizedHandlePos);
|
|
659
|
+
}
|
|
660
|
+
getValueFromPosition(position) {
|
|
661
|
+
const min = this.minValue();
|
|
662
|
+
const max = this.maxValue();
|
|
663
|
+
if (position >= 100) {
|
|
664
|
+
return max;
|
|
665
|
+
}
|
|
666
|
+
if (position <= 0) {
|
|
667
|
+
return min;
|
|
668
|
+
}
|
|
669
|
+
const range = max - min;
|
|
670
|
+
const rawValue = min + (position / 100) * range;
|
|
671
|
+
return this.snapValue(rawValue);
|
|
672
|
+
}
|
|
673
|
+
isNavigationKey(event) {
|
|
674
|
+
return ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End", "PageUp", "PageDown"].includes(event.key);
|
|
675
|
+
}
|
|
676
|
+
positionFromValue(value) {
|
|
677
|
+
return valueToPosition(value, this.minValue(), this.maxValue());
|
|
678
|
+
}
|
|
679
|
+
snapValue(value) {
|
|
680
|
+
const min = this.minValue();
|
|
681
|
+
const step = this.step();
|
|
682
|
+
const clampedValue = this.clampValue(value);
|
|
683
|
+
const snappedValue = Math.round((clampedValue - min) / step) * step + min;
|
|
684
|
+
return this.clampValue(snappedValue);
|
|
685
|
+
}
|
|
686
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
687
|
+
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 }], viewQueries: [{ propertyName: "tickElements", predicate: SliderTickDirective, descendants: true, isSignal: true }], ngImport: i0 }); }
|
|
688
|
+
}
|
|
689
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderBaseComponent, decorators: [{
|
|
690
|
+
type: Directive
|
|
691
|
+
}], ctorParameters: () => [], propDecorators: { tickElements: [{ type: i0.ViewChildren, args: [i0.forwardRef(() => SliderTickDirective), { isSignal: true }] }], handleTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SliderHandleTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], tickValueTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SliderTickValueTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], 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 }] }], 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"] }], trackBackground: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackBackground", required: false }] }], trackSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackSize", required: false }] }] } });
|
|
692
|
+
|
|
693
|
+
class SliderComponent extends SliderBaseComponent {
|
|
694
|
+
constructor() {
|
|
695
|
+
super(...arguments);
|
|
696
|
+
this.handleFocused = signal(false, /* @ts-ignore */
|
|
697
|
+
...(ngDevMode ? [{ debugName: "handleFocused" }] : /* istanbul ignore next */ []));
|
|
698
|
+
this.handlePosition = computed(() => this.positionFromValue(this.normalizedValue()), /* @ts-ignore */
|
|
699
|
+
...(ngDevMode ? [{ debugName: "handlePosition" }] : /* istanbul ignore next */ []));
|
|
700
|
+
this.handleStyle = computed(() => ({
|
|
701
|
+
...this.handleTemplateStyles(),
|
|
702
|
+
...this.handleStyles()
|
|
703
|
+
}), /* @ts-ignore */
|
|
704
|
+
...(ngDevMode ? [{ debugName: "handleStyle" }] : /* istanbul ignore next */ []));
|
|
705
|
+
this.normalizedValue = computed(() => this.snapValue(this.value()), /* @ts-ignore */
|
|
706
|
+
...(ngDevMode ? [{ debugName: "normalizedValue" }] : /* istanbul ignore next */ []));
|
|
707
|
+
this.selectionLeft = computed(() => 0, /* @ts-ignore */
|
|
708
|
+
...(ngDevMode ? [{ debugName: "selectionLeft" }] : /* istanbul ignore next */ []));
|
|
709
|
+
this.selectionRight = computed(() => this.handlePosition(), /* @ts-ignore */
|
|
710
|
+
...(ngDevMode ? [{ debugName: "selectionRight" }] : /* istanbul ignore next */ []));
|
|
711
|
+
this.sliderHandle = viewChild.required("sliderHandle", /* @ts-ignore */
|
|
712
|
+
...(ngDevMode ? [{ debugName: "sliderHandle" }] : /* istanbul ignore next */ []));
|
|
713
|
+
/**
|
|
714
|
+
* @description Accessible name for the host element. Describe what the component represents.
|
|
715
|
+
* When empty, assistive technology announces the role without a label.
|
|
716
|
+
* @default "Slider value"
|
|
717
|
+
*/
|
|
718
|
+
this.ariaLabel = input("Slider value", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
719
|
+
/**
|
|
720
|
+
* @description ID of an external element that provides the accessible name for the host element.
|
|
721
|
+
* @default null
|
|
722
|
+
*/
|
|
723
|
+
this.ariaLabelledBy = input(null, { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
724
|
+
/**
|
|
725
|
+
* @description Current value. Values outside `[minValue, maxValue]` are clamped before rendering.
|
|
726
|
+
* @default 0
|
|
727
|
+
*/
|
|
728
|
+
this.value = model(0, /* @ts-ignore */
|
|
729
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
730
|
+
}
|
|
731
|
+
focus(options) {
|
|
732
|
+
if (!this.effectiveDisabled()) {
|
|
733
|
+
this.sliderHandle().nativeElement.focus(options);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
handleHandleMove(event) {
|
|
737
|
+
this.updateValue(this.getValueFromPointerEvent(event));
|
|
738
|
+
}
|
|
739
|
+
setSubscriptions() {
|
|
740
|
+
this.setClickSubscription();
|
|
741
|
+
this.setKeydownSubscription();
|
|
742
|
+
this.setPointerMoveSubscription();
|
|
743
|
+
this.setFocusSubscription();
|
|
744
|
+
}
|
|
745
|
+
setClickSubscription() {
|
|
746
|
+
fromEvent(this.hostElementRef.nativeElement, "click")
|
|
747
|
+
.pipe(takeUntilDestroyed(this.destroyRef), tap(() => this.dragging.set(false)), filter(() => !this.effectiveDisabled()))
|
|
748
|
+
.subscribe((event) => this.handleHandleMove(event));
|
|
749
|
+
}
|
|
750
|
+
setFocusSubscription() {
|
|
751
|
+
fromEvent(this.sliderHandle().nativeElement, "focus")
|
|
752
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
753
|
+
.subscribe(() => this.zone.run(() => this.handleFocused.set(true)));
|
|
754
|
+
fromEvent(this.sliderHandle().nativeElement, "blur")
|
|
755
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
756
|
+
.subscribe(() => {
|
|
757
|
+
this.zone.run(() => {
|
|
758
|
+
this.handleFocused.set(false);
|
|
759
|
+
this.touch.emit();
|
|
760
|
+
});
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
setKeydownSubscription() {
|
|
764
|
+
fromEvent(this.sliderHandle().nativeElement, "keydown")
|
|
765
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.effectiveDisabled()), filter(event => this.isNavigationKey(event)), tap(event => {
|
|
766
|
+
event.preventDefault();
|
|
767
|
+
event.stopPropagation();
|
|
768
|
+
}))
|
|
769
|
+
.subscribe(event => this.updateValue(this.calculateNewValue(this.normalizedValue(), event)));
|
|
770
|
+
}
|
|
771
|
+
setPointerMoveSubscription() {
|
|
772
|
+
const pointerMove$ = fromEvent(document, "pointermove");
|
|
773
|
+
const pointerUp$ = fromEvent(document, "pointerup");
|
|
774
|
+
fromEvent(this.sliderHandle().nativeElement, "pointerdown")
|
|
775
|
+
.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))))))))
|
|
776
|
+
.subscribe();
|
|
777
|
+
}
|
|
778
|
+
updateValue(value) {
|
|
779
|
+
const nextValue = this.snapValue(value);
|
|
780
|
+
if (nextValue === this.normalizedValue()) {
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
this.zone.run(() => {
|
|
784
|
+
this.value.set(nextValue);
|
|
785
|
+
this.touch.emit();
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
789
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SliderComponent, isStandalone: true, selector: "mona-slider", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { listeners: { "focus": "focus()" }, properties: { "class": "baseClasses()", "class.mona-slider": "true", "attr.data-disabled": "effectiveDisabled() || null", "attr.data-orientation": "orientation()" } }, viewQueries: [{ propertyName: "sliderHandle", first: true, predicate: ["sliderHandle"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div\r\n [class]=\"trackClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [style.height]=\"orientation() === 'horizontal' ? sliderTrackSize() : undefined\"\r\n [style.width]=\"orientation() === 'vertical' ? sliderTrackSize() : undefined\"\r\n [style]=\"trackBackgroundStyle()\">\r\n <div\r\n [class]=\"selectionClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? selectionLeft() : undefined\"\r\n [style.right.%]=\"orientation() === 'horizontal' ? 100 - selectionRight() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? selectionLeft() : undefined\"\r\n [style.top.%]=\"orientation() === 'vertical' ? 100 - selectionRight() : undefined\"\r\n [style]=\"selectionBackgroundStyle()\"></div>\r\n</div>\r\n@if (showTicks()) {\r\n <div [class]=\"tickListClasses()\" [attr.data-orientation]=\"orientation()\">\r\n @for (tick of renderTicks(); track tick.index) {\r\n <span\r\n [class]=\"tickClasses()\"\r\n [style]=\"tick | tickStyle: tickStyleArgs()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-value]=\"tick.value\"\r\n monaSliderTick>\r\n </span>\r\n }\r\n </div>\r\n}\r\n@if (showTicks() && showLabels()) {\r\n <div\r\n [class]=\"tickLabelListClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-label-position]=\"labelPosition()\">\r\n @for (tick of labelTicks(); track tick.index) {\r\n <span\r\n [class]=\"tickLabelClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [style]=\"tick | labelStyle: labelStyleArgs()\">\r\n @if (!tickValueTemplate()) {\r\n <span>{{ tick.value }}</span>\r\n } @else {\r\n <span>\r\n <ng-container\r\n *ngTemplateOutlet=\"\r\n tickValueTemplate() ?? null;\r\n context: { $implicit: tick.value }\r\n \"></ng-container>\r\n </span>\r\n }\r\n </span>\r\n }\r\n </div>\r\n}\r\n<div\r\n [class]=\"sliderHandleClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [attr.data-focused]=\"handleFocused()\"\r\n [style]=\"handleStyle()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? handlePosition() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? handlePosition() : undefined\"\r\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\r\n [attr.role]=\"'slider'\"\r\n [attr.aria-valuemin]=\"minValue()\"\r\n [attr.aria-valuemax]=\"maxValue()\"\r\n [attr.aria-valuenow]=\"normalizedValue()\"\r\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()) : null\"\r\n [attr.aria-orientation]=\"orientation()\"\r\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\r\n [attr.aria-invalid]=\"invalid() || null\"\r\n [attr.data-invalid]=\"invalid() || null\"\r\n [attr.aria-label]=\"ariaLabel()\"\r\n [attr.aria-labelledby]=\"ariaLabelledBy()\"\r\n #sliderHandle>\r\n @if (handleTemplate()) {\r\n <ng-container\r\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue() }\"></ng-container>\r\n }\r\n</div>\r\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: SliderTickDirective, selector: "span[monaSliderTick]" }, { kind: "pipe", type: LabelStylePipe, name: "labelStyle" }, { kind: "pipe", type: TickStylePipe, name: "tickStyle" }] }); }
|
|
790
|
+
}
|
|
791
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SliderComponent, decorators: [{
|
|
792
|
+
type: Component,
|
|
793
|
+
args: [{ selector: "mona-slider", imports: [NgTemplateOutlet, SliderTickDirective, LabelStylePipe, TickStylePipe], host: {
|
|
794
|
+
"[class]": "baseClasses()",
|
|
795
|
+
"[class.mona-slider]": "true",
|
|
796
|
+
"[attr.data-disabled]": "effectiveDisabled() || null",
|
|
797
|
+
"[attr.data-orientation]": "orientation()",
|
|
798
|
+
"(focus)": "focus()"
|
|
799
|
+
}, template: "<div\r\n [class]=\"trackClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [style.height]=\"orientation() === 'horizontal' ? sliderTrackSize() : undefined\"\r\n [style.width]=\"orientation() === 'vertical' ? sliderTrackSize() : undefined\"\r\n [style]=\"trackBackgroundStyle()\">\r\n <div\r\n [class]=\"selectionClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? selectionLeft() : undefined\"\r\n [style.right.%]=\"orientation() === 'horizontal' ? 100 - selectionRight() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? selectionLeft() : undefined\"\r\n [style.top.%]=\"orientation() === 'vertical' ? 100 - selectionRight() : undefined\"\r\n [style]=\"selectionBackgroundStyle()\"></div>\r\n</div>\r\n@if (showTicks()) {\r\n <div [class]=\"tickListClasses()\" [attr.data-orientation]=\"orientation()\">\r\n @for (tick of renderTicks(); track tick.index) {\r\n <span\r\n [class]=\"tickClasses()\"\r\n [style]=\"tick | tickStyle: tickStyleArgs()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-value]=\"tick.value\"\r\n monaSliderTick>\r\n </span>\r\n }\r\n </div>\r\n}\r\n@if (showTicks() && showLabels()) {\r\n <div\r\n [class]=\"tickLabelListClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-label-position]=\"labelPosition()\">\r\n @for (tick of labelTicks(); track tick.index) {\r\n <span\r\n [class]=\"tickLabelClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [style]=\"tick | labelStyle: labelStyleArgs()\">\r\n @if (!tickValueTemplate()) {\r\n <span>{{ tick.value }}</span>\r\n } @else {\r\n <span>\r\n <ng-container\r\n *ngTemplateOutlet=\"\r\n tickValueTemplate() ?? null;\r\n context: { $implicit: tick.value }\r\n \"></ng-container>\r\n </span>\r\n }\r\n </span>\r\n }\r\n </div>\r\n}\r\n<div\r\n [class]=\"sliderHandleClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [attr.data-focused]=\"handleFocused()\"\r\n [style]=\"handleStyle()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? handlePosition() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? handlePosition() : undefined\"\r\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\r\n [attr.role]=\"'slider'\"\r\n [attr.aria-valuemin]=\"minValue()\"\r\n [attr.aria-valuemax]=\"maxValue()\"\r\n [attr.aria-valuenow]=\"normalizedValue()\"\r\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()) : null\"\r\n [attr.aria-orientation]=\"orientation()\"\r\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\r\n [attr.aria-invalid]=\"invalid() || null\"\r\n [attr.data-invalid]=\"invalid() || null\"\r\n [attr.aria-label]=\"ariaLabel()\"\r\n [attr.aria-labelledby]=\"ariaLabelledBy()\"\r\n #sliderHandle>\r\n @if (handleTemplate()) {\r\n <ng-container\r\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue() }\"></ng-container>\r\n }\r\n</div>\r\n" }]
|
|
800
|
+
}], propDecorators: { sliderHandle: [{ type: i0.ViewChild, args: ["sliderHandle", { isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
801
|
+
|
|
802
|
+
class RangeSliderComponent extends SliderBaseComponent {
|
|
803
|
+
constructor() {
|
|
804
|
+
super(...arguments);
|
|
805
|
+
this.handlePositions = computed(() => [
|
|
806
|
+
this.positionFromValue(this.normalizedValue()[0]),
|
|
807
|
+
this.positionFromValue(this.normalizedValue()[1])
|
|
808
|
+
], /* @ts-ignore */
|
|
809
|
+
...(ngDevMode ? [{ debugName: "handlePositions" }] : /* istanbul ignore next */ []));
|
|
810
|
+
this.handlesOverlap = computed(() => {
|
|
811
|
+
const values = this.normalizedValue();
|
|
812
|
+
return values[0] === values[1];
|
|
813
|
+
}, /* @ts-ignore */
|
|
814
|
+
...(ngDevMode ? [{ debugName: "handlesOverlap" }] : /* istanbul ignore next */ []));
|
|
815
|
+
this.normalizedValue = computed(() => {
|
|
816
|
+
const value = this.value();
|
|
817
|
+
const minValue = this.snapValue(value[0]);
|
|
818
|
+
const maxValue = this.snapValue(value[1]);
|
|
819
|
+
return [Math.min(minValue, maxValue), Math.max(minValue, maxValue)];
|
|
820
|
+
}, /* @ts-ignore */
|
|
821
|
+
...(ngDevMode ? [{ debugName: "normalizedValue" }] : /* istanbul ignore next */ []));
|
|
822
|
+
this.primaryHandleFocused = signal(false, /* @ts-ignore */
|
|
823
|
+
...(ngDevMode ? [{ debugName: "primaryHandleFocused" }] : /* istanbul ignore next */ []));
|
|
824
|
+
this.primaryHandlePosition = computed(() => this.handlePositions()[0], /* @ts-ignore */
|
|
825
|
+
...(ngDevMode ? [{ debugName: "primaryHandlePosition" }] : /* istanbul ignore next */ []));
|
|
826
|
+
this.primaryHandleStyle = computed(() => {
|
|
827
|
+
const style = { ...this.handleTemplateStyles(), ...this.handleStyles() };
|
|
828
|
+
if (this.handlesOverlap()) {
|
|
829
|
+
return { ...style, zIndex: this.secondaryHandleOnTop() ? "1" : "2" };
|
|
830
|
+
}
|
|
831
|
+
return style;
|
|
832
|
+
}, /* @ts-ignore */
|
|
833
|
+
...(ngDevMode ? [{ debugName: "primaryHandleStyle" }] : /* istanbul ignore next */ []));
|
|
834
|
+
this.secondaryHandleFocused = signal(false, /* @ts-ignore */
|
|
835
|
+
...(ngDevMode ? [{ debugName: "secondaryHandleFocused" }] : /* istanbul ignore next */ []));
|
|
836
|
+
this.secondaryHandleOnTop = signal(true, /* @ts-ignore */
|
|
837
|
+
...(ngDevMode ? [{ debugName: "secondaryHandleOnTop" }] : /* istanbul ignore next */ []));
|
|
838
|
+
this.secondaryHandlePosition = computed(() => this.handlePositions()[1], /* @ts-ignore */
|
|
839
|
+
...(ngDevMode ? [{ debugName: "secondaryHandlePosition" }] : /* istanbul ignore next */ []));
|
|
840
|
+
this.secondaryHandleStyle = computed(() => {
|
|
841
|
+
const style = { ...this.handleTemplateStyles(), ...this.handleStyles() };
|
|
842
|
+
if (this.handlesOverlap()) {
|
|
843
|
+
return { ...style, zIndex: this.secondaryHandleOnTop() ? "2" : "1" };
|
|
844
|
+
}
|
|
845
|
+
return style;
|
|
846
|
+
}, /* @ts-ignore */
|
|
847
|
+
...(ngDevMode ? [{ debugName: "secondaryHandleStyle" }] : /* istanbul ignore next */ []));
|
|
848
|
+
this.secondarySliderHandle = viewChild.required("secondarySliderHandle", /* @ts-ignore */
|
|
849
|
+
...(ngDevMode ? [{ debugName: "secondarySliderHandle" }] : /* istanbul ignore next */ []));
|
|
850
|
+
this.selectionLeft = computed(() => this.handlePositions()[0], /* @ts-ignore */
|
|
851
|
+
...(ngDevMode ? [{ debugName: "selectionLeft" }] : /* istanbul ignore next */ []));
|
|
852
|
+
this.selectionRight = computed(() => this.handlePositions()[1], /* @ts-ignore */
|
|
853
|
+
...(ngDevMode ? [{ debugName: "selectionRight" }] : /* istanbul ignore next */ []));
|
|
854
|
+
this.sliderHandle = viewChild.required("sliderHandle", /* @ts-ignore */
|
|
855
|
+
...(ngDevMode ? [{ debugName: "sliderHandle" }] : /* istanbul ignore next */ []));
|
|
856
|
+
/**
|
|
857
|
+
* @description Accessible name for the upper-value (secondary) handle.
|
|
858
|
+
* @default "Maximum value"
|
|
859
|
+
*/
|
|
860
|
+
this.ariaLabelEnd = input("Maximum value", { ...(ngDevMode ? { debugName: "ariaLabelEnd" } : /* istanbul ignore next */ {}), alias: "aria-label-end" });
|
|
861
|
+
/**
|
|
862
|
+
* @description Accessible name for the lower-value (primary) handle.
|
|
863
|
+
* @default "Minimum value"
|
|
864
|
+
*/
|
|
865
|
+
this.ariaLabelStart = input("Minimum value", { ...(ngDevMode ? { debugName: "ariaLabelStart" } : /* istanbul ignore next */ {}), alias: "aria-label-start" });
|
|
866
|
+
/**
|
|
867
|
+
* @description Selected range as `[minimum, maximum]`.
|
|
868
|
+
* Values outside `[minValue, maxValue]` are clamped; the tuple is always sorted, so index 0 ≤ index 1.
|
|
869
|
+
* @default [0, 10]
|
|
870
|
+
*/
|
|
871
|
+
this.value = model([0, 10], /* @ts-ignore */
|
|
872
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
873
|
+
}
|
|
874
|
+
focus(options) {
|
|
875
|
+
if (!this.effectiveDisabled()) {
|
|
876
|
+
this.sliderHandle().nativeElement.focus(options);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
handleHandleMove(event, isSecondary = false) {
|
|
880
|
+
this.updateRangedValue(this.getValueFromPointerEvent(event), isSecondary, true);
|
|
881
|
+
}
|
|
882
|
+
setSubscriptions() {
|
|
883
|
+
this.setClickSubscription();
|
|
884
|
+
this.setKeydownSubscription();
|
|
885
|
+
this.setPointerMoveSubscription();
|
|
886
|
+
this.setFocusSubscription();
|
|
887
|
+
}
|
|
888
|
+
getClosestHandle(event) {
|
|
889
|
+
const currentValues = this.normalizedValue();
|
|
890
|
+
if (currentValues[0] === currentValues[1]) {
|
|
891
|
+
const containerRect = this.hostElementRef.nativeElement.getBoundingClientRect();
|
|
892
|
+
let normalizedClickPos;
|
|
893
|
+
if (this.orientation() === "horizontal") {
|
|
894
|
+
const clickPos = event.clientX - containerRect.left;
|
|
895
|
+
normalizedClickPos = (clickPos / containerRect.width) * 100;
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
const clickPos = event.clientY - containerRect.top;
|
|
899
|
+
normalizedClickPos = 100 - (clickPos / containerRect.height) * 100;
|
|
900
|
+
}
|
|
901
|
+
const clickValue = this.getValueFromPosition(normalizedClickPos);
|
|
902
|
+
return clickValue > currentValues[0];
|
|
903
|
+
}
|
|
904
|
+
const primaryRect = this.sliderHandle().nativeElement.getBoundingClientRect();
|
|
905
|
+
const secondaryRect = this.secondarySliderHandle().nativeElement.getBoundingClientRect();
|
|
906
|
+
const primaryDistance = Math.sqrt(Math.pow(primaryRect.left + primaryRect.width / 2 - event.clientX, 2) +
|
|
907
|
+
Math.pow(primaryRect.top + primaryRect.height / 2 - event.clientY, 2));
|
|
908
|
+
const secondaryDistance = Math.sqrt(Math.pow(secondaryRect.left + secondaryRect.width / 2 - event.clientX, 2) +
|
|
909
|
+
Math.pow(secondaryRect.top + secondaryRect.height / 2 - event.clientY, 2));
|
|
910
|
+
return secondaryDistance < primaryDistance;
|
|
911
|
+
}
|
|
912
|
+
setClickSubscription() {
|
|
913
|
+
fromEvent(this.hostElementRef.nativeElement, "click")
|
|
914
|
+
.pipe(takeUntilDestroyed(this.destroyRef), tap(() => this.dragging.set(false)), filter(() => !this.effectiveDisabled()))
|
|
915
|
+
.subscribe((event) => {
|
|
916
|
+
const isSecondary = this.getClosestHandle(event);
|
|
917
|
+
this.handleHandleMove(event, isSecondary);
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
setFocusSubscription() {
|
|
921
|
+
fromEvent(this.sliderHandle().nativeElement, "focus")
|
|
922
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
923
|
+
.subscribe(() => {
|
|
924
|
+
this.zone.run(() => {
|
|
925
|
+
this.primaryHandleFocused.set(true);
|
|
926
|
+
this.secondaryHandleFocused.set(false);
|
|
927
|
+
});
|
|
928
|
+
});
|
|
929
|
+
fromEvent(this.sliderHandle().nativeElement, "blur")
|
|
930
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
931
|
+
.subscribe(() => {
|
|
932
|
+
this.zone.run(() => {
|
|
933
|
+
this.primaryHandleFocused.set(false);
|
|
934
|
+
this.touch.emit();
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
fromEvent(this.secondarySliderHandle().nativeElement, "focus")
|
|
938
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
939
|
+
.subscribe(() => {
|
|
940
|
+
this.zone.run(() => {
|
|
941
|
+
this.secondaryHandleFocused.set(true);
|
|
942
|
+
this.primaryHandleFocused.set(false);
|
|
943
|
+
});
|
|
944
|
+
});
|
|
945
|
+
fromEvent(this.secondarySliderHandle().nativeElement, "blur")
|
|
946
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
947
|
+
.subscribe(() => {
|
|
948
|
+
this.zone.run(() => {
|
|
949
|
+
this.secondaryHandleFocused.set(false);
|
|
950
|
+
this.touch.emit();
|
|
951
|
+
});
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
setKeydownSubscription() {
|
|
955
|
+
fromEvent(this.sliderHandle().nativeElement, "keydown")
|
|
956
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.effectiveDisabled()), filter(event => this.isNavigationKey(event)), tap(event => {
|
|
957
|
+
event.preventDefault();
|
|
958
|
+
event.stopPropagation();
|
|
959
|
+
}))
|
|
960
|
+
.subscribe(event => {
|
|
961
|
+
const newValue = this.calculateNewValue(this.normalizedValue()[0], event);
|
|
962
|
+
this.updateRangedValue(newValue, false, false);
|
|
963
|
+
});
|
|
964
|
+
fromEvent(this.secondarySliderHandle().nativeElement, "keydown")
|
|
965
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter(() => !this.effectiveDisabled()), filter(event => this.isNavigationKey(event)), tap(event => {
|
|
966
|
+
event.preventDefault();
|
|
967
|
+
event.stopPropagation();
|
|
968
|
+
}))
|
|
969
|
+
.subscribe(event => {
|
|
970
|
+
const newValue = this.calculateNewValue(this.normalizedValue()[1], event);
|
|
971
|
+
this.updateRangedValue(newValue, true, false);
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
setPointerMoveSubscription() {
|
|
975
|
+
const pointerMove$ = fromEvent(document, "pointermove");
|
|
976
|
+
const pointerUp$ = fromEvent(document, "pointerup");
|
|
977
|
+
fromEvent(this.sliderHandle().nativeElement, "pointerdown")
|
|
978
|
+
.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))))))))
|
|
979
|
+
.subscribe();
|
|
980
|
+
fromEvent(this.secondarySliderHandle().nativeElement, "pointerdown")
|
|
981
|
+
.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))))))))
|
|
982
|
+
.subscribe();
|
|
983
|
+
}
|
|
984
|
+
updateRangedValue(value, isSecondary, isDragging = false) {
|
|
985
|
+
const currentValues = this.normalizedValue();
|
|
986
|
+
const currentMinValue = currentValues[0];
|
|
987
|
+
const currentMaxValue = currentValues[1];
|
|
988
|
+
let newMinValue = currentMinValue;
|
|
989
|
+
let newMaxValue = currentMaxValue;
|
|
990
|
+
if (isSecondary) {
|
|
991
|
+
if (isDragging && value < currentMinValue) {
|
|
992
|
+
newMinValue = value;
|
|
993
|
+
newMaxValue = value;
|
|
994
|
+
this.secondaryHandleOnTop.set(true);
|
|
995
|
+
}
|
|
996
|
+
else {
|
|
997
|
+
newMaxValue = Math.max(value, currentMinValue);
|
|
998
|
+
if (newMaxValue === currentMinValue) {
|
|
999
|
+
this.secondaryHandleOnTop.set(true);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
else {
|
|
1004
|
+
if (isDragging && value > currentMaxValue) {
|
|
1005
|
+
newMinValue = value;
|
|
1006
|
+
newMaxValue = value;
|
|
1007
|
+
this.secondaryHandleOnTop.set(false);
|
|
1008
|
+
}
|
|
1009
|
+
else {
|
|
1010
|
+
newMinValue = Math.min(value, currentMaxValue);
|
|
1011
|
+
if (newMinValue === currentMaxValue) {
|
|
1012
|
+
this.secondaryHandleOnTop.set(false);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
newMinValue = this.snapValue(newMinValue);
|
|
1017
|
+
newMaxValue = this.snapValue(newMaxValue);
|
|
1018
|
+
if (newMinValue === currentMinValue && newMaxValue === currentMaxValue) {
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
this.zone.run(() => {
|
|
1022
|
+
this.value.set([newMinValue, newMaxValue]);
|
|
1023
|
+
this.touch.emit();
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RangeSliderComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
1027
|
+
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: { listeners: { "focus": "focus()" }, properties: { "class": "baseClasses()", "class.mona-slider": "true", "attr.data-disabled": "effectiveDisabled()", "attr.data-orientation": "orientation()" } }, 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\r\n [class]=\"trackClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [style.height]=\"orientation() === 'horizontal' ? sliderTrackSize() : undefined\"\r\n [style.width]=\"orientation() === 'vertical' ? sliderTrackSize() : undefined\"\r\n [style]=\"trackBackgroundStyle()\">\r\n <div\r\n [class]=\"selectionClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? selectionLeft() : undefined\"\r\n [style.right.%]=\"orientation() === 'horizontal' ? 100 - selectionRight() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? selectionLeft() : undefined\"\r\n [style.top.%]=\"orientation() === 'vertical' ? 100 - selectionRight() : undefined\"\r\n [style]=\"selectionBackgroundStyle()\"></div>\r\n</div>\r\n@if (showTicks()) {\r\n <div [class]=\"tickListClasses()\" [attr.data-orientation]=\"orientation()\">\r\n @for (tick of renderTicks(); track tick.index) {\r\n <span\r\n [class]=\"tickClasses()\"\r\n [style]=\"tick | tickStyle: tickStyleArgs()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-value]=\"tick.value\"\r\n monaSliderTick>\r\n </span>\r\n }\r\n </div>\r\n}\r\n@if (showTicks() && showLabels()) {\r\n <div\r\n [class]=\"tickLabelListClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-label-position]=\"labelPosition()\">\r\n @for (tick of labelTicks(); track tick.index) {\r\n <span\r\n [class]=\"tickLabelClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [style]=\"tick | labelStyle: labelStyleArgs()\">\r\n @if (!tickValueTemplate()) {\r\n <span>{{ tick.value }}</span>\r\n } @else {\r\n <span>\r\n <ng-container\r\n *ngTemplateOutlet=\"\r\n tickValueTemplate() ?? null;\r\n context: { $implicit: tick.value }\r\n \"></ng-container>\r\n </span>\r\n }\r\n </span>\r\n }\r\n </div>\r\n}\r\n<div\r\n [class]=\"sliderHandleClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [attr.data-focused]=\"primaryHandleFocused()\"\r\n [style]=\"primaryHandleStyle()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? primaryHandlePosition() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? primaryHandlePosition() : undefined\"\r\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\r\n [attr.role]=\"'slider'\"\r\n [attr.aria-valuemin]=\"minValue()\"\r\n [attr.aria-valuemax]=\"maxValue()\"\r\n [attr.aria-valuenow]=\"normalizedValue()[0]\"\r\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()[0]) : null\"\r\n [attr.aria-orientation]=\"orientation()\"\r\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\r\n [attr.aria-invalid]=\"invalid() || null\"\r\n [attr.data-invalid]=\"invalid() || null\"\r\n [attr.aria-label]=\"ariaLabelStart()\"\r\n #sliderHandle>\r\n @if (handleTemplate()) {\r\n <ng-container\r\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue()[0] }\"></ng-container>\r\n }\r\n</div>\r\n<div\r\n [class]=\"sliderHandleClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [attr.data-focused]=\"secondaryHandleFocused()\"\r\n [style]=\"secondaryHandleStyle()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? secondaryHandlePosition() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? secondaryHandlePosition() : undefined\"\r\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\r\n [attr.role]=\"'slider'\"\r\n [attr.aria-valuemin]=\"minValue()\"\r\n [attr.aria-valuemax]=\"maxValue()\"\r\n [attr.aria-valuenow]=\"normalizedValue()[1]\"\r\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()[1]) : null\"\r\n [attr.aria-orientation]=\"orientation()\"\r\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\r\n [attr.aria-invalid]=\"invalid() || null\"\r\n [attr.data-invalid]=\"invalid() || null\"\r\n [attr.aria-label]=\"ariaLabelEnd()\"\r\n #secondarySliderHandle>\r\n @if (handleTemplate()) {\r\n <ng-container\r\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue()[1] }\"></ng-container>\r\n }\r\n</div>\r\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: SliderTickDirective, selector: "span[monaSliderTick]" }, { kind: "pipe", type: LabelStylePipe, name: "labelStyle" }, { kind: "pipe", type: TickStylePipe, name: "tickStyle" }] }); }
|
|
1028
|
+
}
|
|
1029
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RangeSliderComponent, decorators: [{
|
|
1030
|
+
type: Component,
|
|
1031
|
+
args: [{ selector: "mona-range-slider", imports: [NgTemplateOutlet, SliderTickDirective, LabelStylePipe, TickStylePipe], host: {
|
|
1032
|
+
"[class]": "baseClasses()",
|
|
1033
|
+
"[class.mona-slider]": "true",
|
|
1034
|
+
"[attr.data-disabled]": "effectiveDisabled()",
|
|
1035
|
+
"[attr.data-orientation]": "orientation()",
|
|
1036
|
+
"(focus)": "focus()"
|
|
1037
|
+
}, template: "<div\r\n [class]=\"trackClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [style.height]=\"orientation() === 'horizontal' ? sliderTrackSize() : undefined\"\r\n [style.width]=\"orientation() === 'vertical' ? sliderTrackSize() : undefined\"\r\n [style]=\"trackBackgroundStyle()\">\r\n <div\r\n [class]=\"selectionClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? selectionLeft() : undefined\"\r\n [style.right.%]=\"orientation() === 'horizontal' ? 100 - selectionRight() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? selectionLeft() : undefined\"\r\n [style.top.%]=\"orientation() === 'vertical' ? 100 - selectionRight() : undefined\"\r\n [style]=\"selectionBackgroundStyle()\"></div>\r\n</div>\r\n@if (showTicks()) {\r\n <div [class]=\"tickListClasses()\" [attr.data-orientation]=\"orientation()\">\r\n @for (tick of renderTicks(); track tick.index) {\r\n <span\r\n [class]=\"tickClasses()\"\r\n [style]=\"tick | tickStyle: tickStyleArgs()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-value]=\"tick.value\"\r\n monaSliderTick>\r\n </span>\r\n }\r\n </div>\r\n}\r\n@if (showTicks() && showLabels()) {\r\n <div\r\n [class]=\"tickLabelListClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-label-position]=\"labelPosition()\">\r\n @for (tick of labelTicks(); track tick.index) {\r\n <span\r\n [class]=\"tickLabelClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [style]=\"tick | labelStyle: labelStyleArgs()\">\r\n @if (!tickValueTemplate()) {\r\n <span>{{ tick.value }}</span>\r\n } @else {\r\n <span>\r\n <ng-container\r\n *ngTemplateOutlet=\"\r\n tickValueTemplate() ?? null;\r\n context: { $implicit: tick.value }\r\n \"></ng-container>\r\n </span>\r\n }\r\n </span>\r\n }\r\n </div>\r\n}\r\n<div\r\n [class]=\"sliderHandleClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [attr.data-focused]=\"primaryHandleFocused()\"\r\n [style]=\"primaryHandleStyle()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? primaryHandlePosition() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? primaryHandlePosition() : undefined\"\r\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\r\n [attr.role]=\"'slider'\"\r\n [attr.aria-valuemin]=\"minValue()\"\r\n [attr.aria-valuemax]=\"maxValue()\"\r\n [attr.aria-valuenow]=\"normalizedValue()[0]\"\r\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()[0]) : null\"\r\n [attr.aria-orientation]=\"orientation()\"\r\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\r\n [attr.aria-invalid]=\"invalid() || null\"\r\n [attr.data-invalid]=\"invalid() || null\"\r\n [attr.aria-label]=\"ariaLabelStart()\"\r\n #sliderHandle>\r\n @if (handleTemplate()) {\r\n <ng-container\r\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue()[0] }\"></ng-container>\r\n }\r\n</div>\r\n<div\r\n [class]=\"sliderHandleClasses()\"\r\n [attr.data-orientation]=\"orientation()\"\r\n [attr.data-dragging]=\"dragging()\"\r\n [attr.data-focused]=\"secondaryHandleFocused()\"\r\n [style]=\"secondaryHandleStyle()\"\r\n [style.left.%]=\"orientation() === 'horizontal' ? secondaryHandlePosition() : undefined\"\r\n [style.bottom.%]=\"orientation() === 'vertical' ? secondaryHandlePosition() : undefined\"\r\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\r\n [attr.role]=\"'slider'\"\r\n [attr.aria-valuemin]=\"minValue()\"\r\n [attr.aria-valuemax]=\"maxValue()\"\r\n [attr.aria-valuenow]=\"normalizedValue()[1]\"\r\n [attr.aria-valuetext]=\"ariaValueText() ? ariaValueText()!(normalizedValue()[1]) : null\"\r\n [attr.aria-orientation]=\"orientation()\"\r\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\r\n [attr.aria-invalid]=\"invalid() || null\"\r\n [attr.data-invalid]=\"invalid() || null\"\r\n [attr.aria-label]=\"ariaLabelEnd()\"\r\n #secondarySliderHandle>\r\n @if (handleTemplate()) {\r\n <ng-container\r\n *ngTemplateOutlet=\"handleTemplate() ?? null; context: { $implicit: normalizedValue()[1] }\"></ng-container>\r\n }\r\n</div>\r\n" }]
|
|
1038
|
+
}], 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"] }] } });
|
|
1039
|
+
|
|
1040
|
+
/*
|
|
1041
|
+
* Public API Surface of @nanahoshi/mona-ui/slider
|
|
1042
|
+
*/
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* Generated bundle index. Do not edit.
|
|
1046
|
+
*/
|
|
1047
|
+
|
|
1048
|
+
export { RangeSliderComponent, SliderComponent, SliderHandleTemplateDirective, SliderTickValueTemplateDirective };
|
|
1049
|
+
//# sourceMappingURL=nanahoshi-mona-ui-slider.mjs.map
|