@momentum-design/components 0.110.0 → 0.110.2
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/dist/browser/index.js +709 -405
- package/dist/browser/index.js.map +4 -4
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/slider/slider.component.d.ts +154 -37
- package/dist/components/slider/slider.component.js +489 -90
- package/dist/components/slider/slider.constants.d.ts +14 -1
- package/dist/components/slider/slider.constants.js +14 -1
- package/dist/components/slider/slider.styles.js +195 -1
- package/dist/components/slider/slider.types.d.ts +8 -1
- package/dist/components/slider/slider.types.js +0 -1
- package/dist/custom-elements.json +927 -658
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +3 -3
- package/dist/react/slider/index.d.ts +34 -4
- package/dist/react/slider/index.js +31 -4
- package/dist/utils/styles/index.d.ts +2 -1
- package/dist/utils/styles/index.js +5 -5
- package/package.json +1 -1
@@ -1,21 +1,66 @@
|
|
1
|
-
import { CSSResult } from 'lit';
|
1
|
+
import type { CSSResult, PropertyValueMap } from 'lit';
|
2
2
|
import { Component } from '../../models';
|
3
3
|
/**
|
4
|
-
*
|
4
|
+
* Slider component is used to select a value or range of values from within a defined range.
|
5
|
+
* It provides a visual representation of the current value(s) and allows users to adjust the value(s) by dragging the thumb(s) along the track.
|
6
|
+
* It can be used as a single slider or a range slider. This is set by the boolean attribute `range`
|
7
|
+
* If the step value is more than 1, tick marks are shown to represent the steps between the min and max values. The slider thumb will snap to the nearest tick mark.
|
5
8
|
*
|
6
9
|
* @tagname mdc-slider
|
7
10
|
*
|
8
|
-
* @
|
11
|
+
* @dependency mdc-icon
|
9
12
|
*
|
10
|
-
* @
|
13
|
+
* @csspart slider-tooltip - The tooltip of the slider
|
14
|
+
* @csspart slider-track - The track of the slider
|
15
|
+
* @csspart slider-wrapper - The wrapper around the slider input(s)
|
16
|
+
* @csspart slider-ticks - The container for the tick marks
|
17
|
+
* @csspart slider-tick - The individual tick marks
|
18
|
+
* @csspart slider-input - The input element of the slider
|
19
|
+
* @csspart slider-label - The label of the slider
|
20
|
+
*
|
21
|
+
* @event input - Fired when the slider value changes
|
22
|
+
* @event change - Fired when the slider value is committed
|
23
|
+
*
|
24
|
+
* @cssproperty --mdc-slider-thumb-color - The color of the slider thumb
|
25
|
+
* @cssproperty --mdc-slider-thumb-border-color - The color of the slider thumb border
|
26
|
+
* @cssproperty --mdc-slider-thumb-size - The size of the slider thumb
|
27
|
+
* @cssproperty --mdc-slider-input-size - The height of the slider input
|
28
|
+
* @cssproperty --mdc-slider-tick-size - The size of the slider tick marks
|
29
|
+
* @cssproperty --mdc-slider-track-height - The height of the slider track
|
30
|
+
* @cssproperty --mdc-slider-tick-color - The color of the slider tick marks
|
31
|
+
* @cssproperty --mdc-slider-progress-color - The color of the slider progress
|
32
|
+
* @cssproperty --mdc-slider-track-color - The color of the slider track
|
33
|
+
* @cssproperty --mdc-slider-tooltip-left - The left position of the slider tooltip
|
34
|
+
* @cssproperty --mdc-slider-tick-left - The left position of the slider tick marks
|
11
35
|
*/
|
12
36
|
declare class Slider extends Component {
|
13
37
|
/**
|
14
|
-
*
|
38
|
+
* Internal state to track if the slider thumb is focused (single value)
|
39
|
+
* @internal
|
40
|
+
*/
|
41
|
+
private thumbFocused;
|
42
|
+
/**
|
43
|
+
* @internal
|
44
|
+
*/
|
45
|
+
private thumbHovered;
|
46
|
+
/**
|
47
|
+
* Indicates whether it is a range slider. When true, the slider displays two handles for selecting a range of values.
|
48
|
+
* When false, the slider displays a single handle for selecting a single value.
|
49
|
+
* @default false
|
15
50
|
*/
|
16
51
|
range: boolean;
|
17
52
|
/**
|
18
|
-
*
|
53
|
+
* The slider minimum value.
|
54
|
+
* @default 0
|
55
|
+
*/
|
56
|
+
min: number;
|
57
|
+
/**
|
58
|
+
* The slider maximum value.
|
59
|
+
* @default 100
|
60
|
+
*/
|
61
|
+
max: number;
|
62
|
+
/**
|
63
|
+
* Whether the slider is disabled. When true, the slider cannot be interacted with.
|
19
64
|
*/
|
20
65
|
disabled?: boolean;
|
21
66
|
/**
|
@@ -30,14 +75,6 @@ declare class Slider extends Component {
|
|
30
75
|
* Icon that represents the maximum value; ex: speaker with full volume.
|
31
76
|
*/
|
32
77
|
trailingIcon?: string;
|
33
|
-
/**
|
34
|
-
* The slider minimum value.
|
35
|
-
*/
|
36
|
-
min: number;
|
37
|
-
/**
|
38
|
-
* The slider maximum value.
|
39
|
-
*/
|
40
|
-
max: number;
|
41
78
|
/**
|
42
79
|
* The slider value displayed when range is false.
|
43
80
|
*/
|
@@ -51,7 +88,8 @@ declare class Slider extends Component {
|
|
51
88
|
*/
|
52
89
|
valueEnd?: number;
|
53
90
|
/**
|
54
|
-
* The step between values.
|
91
|
+
* The step between values. If defined and greater than 1, we will show tick marks and the stepper will snap to the nearest tick mark.
|
92
|
+
* @default 1
|
55
93
|
*/
|
56
94
|
step: number;
|
57
95
|
/**
|
@@ -67,53 +105,132 @@ declare class Slider extends Component {
|
|
67
105
|
*/
|
68
106
|
labelEnd?: string;
|
69
107
|
/**
|
70
|
-
* An optional label for the slider's value displayed when range is false; if not set, the label is the value itself.
|
108
|
+
* An optional label for the slider's value displayed when range is false; if not set, the label is the 'value' itself.
|
71
109
|
*/
|
72
|
-
valueLabel
|
110
|
+
valueLabel?: string;
|
73
111
|
/**
|
74
|
-
* An optional label for the slider's start value displayed when range is true; if not set, the label is the valueStart itself.
|
112
|
+
* An optional label for the slider's start value displayed when range is true; if not set, the label is the 'valueStart' itself.
|
75
113
|
*/
|
76
|
-
valueLabelStart
|
114
|
+
valueLabelStart?: string;
|
77
115
|
/**
|
78
|
-
* An optional label for the slider's end value displayed when range is true; if not set, the label is the valueEnd itself.
|
116
|
+
* An optional label for the slider's end value displayed when range is true; if not set, the label is the 'valueEnd' itself.
|
79
117
|
*/
|
80
|
-
valueLabelEnd
|
118
|
+
valueLabelEnd?: string;
|
81
119
|
/**
|
82
|
-
*
|
120
|
+
* Name attribute for the slider (single value).
|
83
121
|
*/
|
84
|
-
|
122
|
+
name?: string;
|
85
123
|
/**
|
86
|
-
*
|
124
|
+
* Name attribute for the slider's start handle when range is true.
|
125
|
+
*/
|
126
|
+
nameStart?: string;
|
127
|
+
/**
|
128
|
+
* Name attribute for the slider's end handle when range is true.
|
129
|
+
*/
|
130
|
+
nameEnd?: string;
|
131
|
+
/**
|
132
|
+
* Aria label for the slider's handle displayed when range is false.
|
133
|
+
*/
|
134
|
+
dataAriaLabel?: string;
|
135
|
+
/**
|
136
|
+
* Aria label for the slider's start handle displayed when range is true.
|
87
137
|
*/
|
88
|
-
|
138
|
+
startAriaLabel?: string;
|
89
139
|
/**
|
90
140
|
* Aria label for the slider's end handle displayed when range is true.
|
91
141
|
*/
|
92
|
-
|
142
|
+
endAriaLabel?: string;
|
143
|
+
/**
|
144
|
+
* Aria value text for the slider's value displayed when range is false.
|
145
|
+
*/
|
146
|
+
dataAriaValuetext?: string;
|
147
|
+
/**
|
148
|
+
* Aria value text for the slider's start value displayed when range is true.
|
149
|
+
*/
|
150
|
+
startAriaValuetext?: string;
|
93
151
|
/**
|
94
152
|
* Aria value text for the slider's end value displayed when range is true.
|
95
153
|
*/
|
96
|
-
|
154
|
+
endAriaValueText?: string;
|
97
155
|
/**
|
98
|
-
*
|
156
|
+
* Targets all the input components with type='range'
|
157
|
+
* @internal
|
99
158
|
*/
|
100
|
-
|
159
|
+
protected inputElements: HTMLInputElement[];
|
160
|
+
constructor();
|
161
|
+
protected updated(changedProperties: PropertyValueMap<Slider>): void;
|
101
162
|
/**
|
102
|
-
*
|
163
|
+
* Prevents default behavior for mouse and keyboard events.
|
164
|
+
* This prevents user interaction with the slider when it is soft-disabled.
|
165
|
+
* @param e - The event to prevent.
|
103
166
|
*/
|
104
|
-
|
167
|
+
private preventChange;
|
105
168
|
/**
|
106
|
-
*
|
169
|
+
* Sets the soft-disabled state for the slider.
|
170
|
+
* Applies the appropriate ARIA attributes.
|
107
171
|
*/
|
108
|
-
|
172
|
+
private setSoftDisabled;
|
109
173
|
/**
|
110
|
-
*
|
174
|
+
* Initializes the range slider by setting default values for the start and end handles.
|
175
|
+
* Updates the slider's input elements to reflect the current values.
|
111
176
|
*/
|
112
|
-
|
177
|
+
private initializeRangeSlider;
|
113
178
|
/**
|
114
|
-
*
|
179
|
+
* Handles input changes for either the start or end thumb of the range slider.
|
180
|
+
* Ensures thumbs do not cross over each other.
|
181
|
+
* @param thumbIndex - 0 for start thumb, 1 for end thumb.
|
182
|
+
*/
|
183
|
+
private handleInput;
|
184
|
+
/**
|
185
|
+
* Renders an icon element.
|
186
|
+
* @param icon - The name of the icon to render.
|
187
|
+
* @param part - The part attribute for the icon element.
|
188
|
+
* @returns The icon element or null.
|
189
|
+
*/
|
190
|
+
private iconTemplate;
|
191
|
+
/**
|
192
|
+
* Renders a visual representation of tooltip element and places it exactly above the slider thumb.
|
193
|
+
* @param label - The label to display in the tooltip.
|
194
|
+
* @param source - The source of the tooltip (e.g., 'start' or 'end').
|
195
|
+
* @returns The tooltip element.
|
196
|
+
*/
|
197
|
+
private tooltipTemplate;
|
198
|
+
/**
|
199
|
+
* Updates the styling of the slider track.
|
200
|
+
* The progress value is calculated and updated using appropriate tokens
|
201
|
+
* In a range slider, both thumbs are considered.
|
202
|
+
* The track is filled between the two thumbs.
|
203
|
+
*/
|
204
|
+
updateTrackStyling(): void;
|
205
|
+
/**
|
206
|
+
* Handles the input event for the single value slider.
|
207
|
+
* @param e - The input event.
|
208
|
+
*/
|
209
|
+
onInput(e: Event): void;
|
210
|
+
/**
|
211
|
+
* Handles the change event for the single value slider.
|
212
|
+
* @param e - The change event.
|
213
|
+
*/
|
214
|
+
onChange(e: Event): void;
|
215
|
+
/**
|
216
|
+
* Handles the change event for the start thumb of the range slider.
|
217
|
+
* @param e - The change event.
|
218
|
+
*/
|
219
|
+
onChangeStart(e: Event): void;
|
220
|
+
/**
|
221
|
+
* Handles the change event for the end thumb of the range slider.
|
222
|
+
* @param e - The change event.
|
223
|
+
*/
|
224
|
+
onChangeEnd(e: Event): void;
|
225
|
+
/**
|
226
|
+
* Get the styles for the tick marks.
|
227
|
+
* Since the ticks are placed above the slider, we need to hide the tick that is placed exactly where the slider thumb is.
|
228
|
+
* Based on this condition, it renders the styles appropriately.
|
229
|
+
* @param tick - The tick value.
|
230
|
+
* @returns The styles for the tick mark.
|
115
231
|
*/
|
116
|
-
|
232
|
+
getTickStyles(tick: number): string;
|
233
|
+
private renderTicks;
|
117
234
|
render(): import("lit-html").TemplateResult<1>;
|
118
235
|
static styles: Array<CSSResult>;
|
119
236
|
}
|