@limetech/lime-elements 39.10.2 → 39.10.4
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/CHANGELOG.md +16 -0
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-breadcrumbs_7.cjs.entry.js +51 -3
- package/dist/cjs/limel-dialog.cjs.entry.js +86 -2
- package/dist/cjs/limel-markdown.cjs.entry.js +1 -1
- package/dist/cjs/limel-portal_3.cjs.entry.js +3 -3
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +2 -2
- package/dist/cjs/limel-slider.cjs.entry.js +44 -1494
- package/dist/cjs/limel-snackbar.cjs.entry.js +2 -2
- package/dist/cjs/limel-split-button.cjs.entry.js +2 -2
- package/dist/cjs/limel-switch.cjs.entry.js +1 -1
- package/dist/cjs/limel-tab-bar.cjs.entry.js +2 -2
- package/dist/cjs/limel-tab-panel.cjs.entry.js +1 -1
- package/dist/cjs/limel-table.cjs.entry.js +3 -3
- package/dist/cjs/limel-text-editor-link-menu.cjs.entry.js +3 -3
- package/dist/cjs/limel-text-editor.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/markdown/markdown.css +13 -9
- package/dist/collection/components/slider/slider.css +215 -642
- package/dist/collection/components/slider/slider.js +45 -165
- package/dist/collection/components/snackbar/snackbar.js +2 -2
- package/dist/collection/components/spinner/spinner.js +1 -1
- package/dist/collection/components/split-button/split-button.js +2 -2
- package/dist/collection/components/switch/switch.js +1 -1
- package/dist/collection/components/tab-bar/tab-bar.js +2 -2
- package/dist/collection/components/tab-panel/tab-panel.js +1 -1
- package/dist/collection/components/table/table.js +3 -3
- package/dist/collection/components/text-editor/link-menu/editor-link-menu.js +3 -3
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.css +13 -9
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js +1 -1
- package/dist/collection/components/text-editor/text-editor.js +1 -1
- package/dist/collection/components/tooltip/tooltip-content.js +1 -1
- package/dist/collection/components/tooltip/tooltip.js +2 -2
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-breadcrumbs_7.entry.js +50 -2
- package/dist/esm/limel-dialog.entry.js +85 -1
- package/dist/esm/limel-markdown.entry.js +1 -1
- package/dist/esm/limel-portal_3.entry.js +3 -3
- package/dist/esm/limel-prosemirror-adapter.entry.js +2 -2
- package/dist/esm/limel-slider.entry.js +45 -1495
- package/dist/esm/limel-snackbar.entry.js +2 -2
- package/dist/esm/limel-split-button.entry.js +2 -2
- package/dist/esm/limel-switch.entry.js +1 -1
- package/dist/esm/limel-tab-bar.entry.js +2 -2
- package/dist/esm/limel-tab-panel.entry.js +1 -1
- package/dist/esm/limel-table.entry.js +3 -3
- package/dist/esm/limel-text-editor-link-menu.entry.js +3 -3
- package/dist/esm/limel-text-editor.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-17e1d911.entry.js → p-2906606d.entry.js} +1 -1
- package/dist/lime-elements/{p-30e54f05.entry.js → p-2b1eda20.entry.js} +3 -3
- package/dist/lime-elements/{p-889a05e4.entry.js → p-3d724fc2.entry.js} +1 -1
- package/dist/lime-elements/{p-6ff3fac4.entry.js → p-3f188493.entry.js} +1 -1
- package/dist/lime-elements/{p-8e3cc9b0.entry.js → p-4e1b8c0a.entry.js} +1 -1
- package/dist/lime-elements/{p-a243b8e2.entry.js → p-730a05e3.entry.js} +1 -1
- package/dist/lime-elements/p-73623bb5.entry.js +1 -0
- package/dist/lime-elements/{p-77f42eff.entry.js → p-8203eea8.entry.js} +1 -1
- package/dist/lime-elements/{p-a44dfaa1.entry.js → p-89b35965.entry.js} +1 -1
- package/dist/lime-elements/{p-9abfb8ba.entry.js → p-9aa07388.entry.js} +1 -1
- package/dist/lime-elements/{p-9d629f5f.entry.js → p-c308e2a5.entry.js} +55 -10
- package/dist/lime-elements/{p-c9591213.entry.js → p-de203f64.entry.js} +1 -1
- package/dist/lime-elements/p-faceccc0.entry.js +1 -0
- package/dist/lime-elements/{p-12646794.entry.js → p-fe993f80.entry.js} +1 -1
- package/dist/types/components/slider/slider.d.ts +6 -24
- package/dist/types/components.d.ts +4 -0
- package/package.json +1 -1
- package/dist/cjs/animationframe-ChtL6ouH.js +0 -88
- package/dist/cjs/util-BOQp7lfZ.js +0 -52
- package/dist/esm/animationframe-BDw7dT4x.js +0 -86
- package/dist/esm/util-Dx8swykg.js +0 -50
- package/dist/lime-elements/p-23c1033d.entry.js +0 -45
- package/dist/lime-elements/p-BDw7dT4x.js +0 -23
- package/dist/lime-elements/p-Dx8swykg.js +0 -23
- package/dist/lime-elements/p-a861f56c.entry.js +0 -1
|
@@ -2,1335 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index-BjHIBY-I.js');
|
|
4
4
|
var randomString = require('./random-string-BTzDB2ee.js');
|
|
5
|
-
var ponyfill = require('./ponyfill-BgIFyUG5.js');
|
|
6
|
-
var component = require('./component-y8swlNNR.js');
|
|
7
|
-
var animationframe = require('./animationframe-ChtL6ouH.js');
|
|
8
|
-
var util = require('./util-BOQp7lfZ.js');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @license
|
|
12
|
-
* Copyright 2020 Google Inc.
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
* furnished to do so, subject to the following conditions:
|
|
20
|
-
*
|
|
21
|
-
* The above copyright notice and this permission notice shall be included in
|
|
22
|
-
* all copies or substantial portions of the Software.
|
|
23
|
-
*
|
|
24
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
30
|
-
* THE SOFTWARE.
|
|
31
|
-
*/
|
|
32
|
-
/** Slider element classes. */
|
|
33
|
-
var cssClasses = {
|
|
34
|
-
DISABLED: 'mdc-slider--disabled',
|
|
35
|
-
DISCRETE: 'mdc-slider--discrete',
|
|
36
|
-
INPUT: 'mdc-slider__input',
|
|
37
|
-
RANGE: 'mdc-slider--range',
|
|
38
|
-
THUMB: 'mdc-slider__thumb',
|
|
39
|
-
// Applied when thumb is in the focused state.
|
|
40
|
-
THUMB_FOCUSED: 'mdc-slider__thumb--focused',
|
|
41
|
-
THUMB_KNOB: 'mdc-slider__thumb-knob',
|
|
42
|
-
// Class added to the top thumb (for overlapping thumbs in range slider).
|
|
43
|
-
THUMB_TOP: 'mdc-slider__thumb--top',
|
|
44
|
-
THUMB_WITH_INDICATOR: 'mdc-slider__thumb--with-indicator',
|
|
45
|
-
TICK_MARKS: 'mdc-slider--tick-marks',
|
|
46
|
-
TICK_MARKS_CONTAINER: 'mdc-slider__tick-marks',
|
|
47
|
-
TICK_MARK_ACTIVE: 'mdc-slider__tick-mark--active',
|
|
48
|
-
TICK_MARK_INACTIVE: 'mdc-slider__tick-mark--inactive',
|
|
49
|
-
TRACK: 'mdc-slider__track',
|
|
50
|
-
// The active track fill element that will be scaled as the value changes.
|
|
51
|
-
TRACK_ACTIVE: 'mdc-slider__track--active_fill',
|
|
52
|
-
VALUE_INDICATOR_TEXT: 'mdc-slider__value-indicator-text',
|
|
53
|
-
};
|
|
54
|
-
/** Slider numbers. */
|
|
55
|
-
var numbers = {
|
|
56
|
-
// Default step size.
|
|
57
|
-
STEP_SIZE: 1,
|
|
58
|
-
// Minimum absolute difference between clientX of move event / down event
|
|
59
|
-
// for which to update thumb, in the case of overlapping thumbs.
|
|
60
|
-
// This is needed to reduce chances of choosing the thumb based on
|
|
61
|
-
// pointer jitter.
|
|
62
|
-
THUMB_UPDATE_MIN_PX: 5,
|
|
63
|
-
};
|
|
64
|
-
/** Slider attributes. */
|
|
65
|
-
var attributes = {
|
|
66
|
-
ARIA_VALUETEXT: 'aria-valuetext',
|
|
67
|
-
INPUT_DISABLED: 'disabled',
|
|
68
|
-
INPUT_MIN: 'min',
|
|
69
|
-
INPUT_MAX: 'max',
|
|
70
|
-
INPUT_VALUE: 'value',
|
|
71
|
-
INPUT_STEP: 'step',
|
|
72
|
-
};
|
|
73
|
-
/** Slider events. */
|
|
74
|
-
var events = {
|
|
75
|
-
CHANGE: 'MDCSlider:change',
|
|
76
|
-
INPUT: 'MDCSlider:input',
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @license
|
|
81
|
-
* Copyright 2020 Google Inc.
|
|
82
|
-
*
|
|
83
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
84
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
85
|
-
* in the Software without restriction, including without limitation the rights
|
|
86
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
87
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
88
|
-
* furnished to do so, subject to the following conditions:
|
|
89
|
-
*
|
|
90
|
-
* The above copyright notice and this permission notice shall be included in
|
|
91
|
-
* all copies or substantial portions of the Software.
|
|
92
|
-
*
|
|
93
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
94
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
95
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
96
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
97
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
98
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
99
|
-
* THE SOFTWARE.
|
|
100
|
-
*/
|
|
101
|
-
/** Tick mark enum, for discrete sliders. */
|
|
102
|
-
var TickMark;
|
|
103
|
-
(function (TickMark) {
|
|
104
|
-
TickMark[TickMark["ACTIVE"] = 0] = "ACTIVE";
|
|
105
|
-
TickMark[TickMark["INACTIVE"] = 1] = "INACTIVE";
|
|
106
|
-
})(TickMark || (TickMark = {}));
|
|
107
|
-
/**
|
|
108
|
-
* Thumb types: range slider has two thumbs (START, END) whereas single point
|
|
109
|
-
* slider only has one thumb (END).
|
|
110
|
-
*/
|
|
111
|
-
var Thumb;
|
|
112
|
-
(function (Thumb) {
|
|
113
|
-
// Thumb at start of slider (e.g. in LTR mode, left thumb on range slider).
|
|
114
|
-
Thumb[Thumb["START"] = 1] = "START";
|
|
115
|
-
// Thumb at end of slider (e.g. in LTR mode, right thumb on range slider,
|
|
116
|
-
// or only thumb on single point slider).
|
|
117
|
-
Thumb[Thumb["END"] = 2] = "END";
|
|
118
|
-
})(Thumb || (Thumb = {}));
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @license
|
|
122
|
-
* Copyright 2020 Google Inc.
|
|
123
|
-
*
|
|
124
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
125
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
126
|
-
* in the Software without restriction, including without limitation the rights
|
|
127
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
128
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
129
|
-
* furnished to do so, subject to the following conditions:
|
|
130
|
-
*
|
|
131
|
-
* The above copyright notice and this permission notice shall be included in
|
|
132
|
-
* all copies or substantial portions of the Software.
|
|
133
|
-
*
|
|
134
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
135
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
136
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
137
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
138
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
139
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
140
|
-
* THE SOFTWARE.
|
|
141
|
-
*/
|
|
142
|
-
var AnimationKeys;
|
|
143
|
-
(function (AnimationKeys) {
|
|
144
|
-
AnimationKeys["SLIDER_UPDATE"] = "slider_update";
|
|
145
|
-
})(AnimationKeys || (AnimationKeys = {}));
|
|
146
|
-
// Accessing `window` without a `typeof` check will throw on Node environments.
|
|
147
|
-
var HAS_WINDOW = typeof window !== 'undefined';
|
|
148
|
-
/**
|
|
149
|
-
* Foundation class for slider. Responsibilities include:
|
|
150
|
-
* - Updating slider values (internal state and DOM updates) based on client
|
|
151
|
-
* 'x' position.
|
|
152
|
-
* - Updating DOM after slider property updates (e.g. min, max).
|
|
153
|
-
*/
|
|
154
|
-
var MDCSliderFoundation = /** @class */ (function (_super) {
|
|
155
|
-
ponyfill.__extends(MDCSliderFoundation, _super);
|
|
156
|
-
function MDCSliderFoundation(adapter) {
|
|
157
|
-
var _this = _super.call(this, ponyfill.__assign(ponyfill.__assign({}, MDCSliderFoundation.defaultAdapter), adapter)) || this;
|
|
158
|
-
// Whether the initial styles (to position the thumb, before component
|
|
159
|
-
// initialization) have been removed.
|
|
160
|
-
_this.initialStylesRemoved = false;
|
|
161
|
-
_this.isDisabled = false;
|
|
162
|
-
_this.isDiscrete = false;
|
|
163
|
-
_this.step = numbers.STEP_SIZE;
|
|
164
|
-
_this.hasTickMarks = false;
|
|
165
|
-
// The following properties are only set for range sliders.
|
|
166
|
-
_this.isRange = false;
|
|
167
|
-
// Tracks the thumb being moved across a slider pointer interaction (down,
|
|
168
|
-
// move event).
|
|
169
|
-
_this.thumb = null;
|
|
170
|
-
// `clientX` from the most recent down event. Used in subsequent move
|
|
171
|
-
// events to determine which thumb to move (in the case of
|
|
172
|
-
// overlapping thumbs).
|
|
173
|
-
_this.downEventClientX = null;
|
|
174
|
-
// Width of the start thumb knob.
|
|
175
|
-
_this.startThumbKnobWidth = 0;
|
|
176
|
-
// Width of the end thumb knob.
|
|
177
|
-
_this.endThumbKnobWidth = 0;
|
|
178
|
-
_this.animFrame = new animationframe.AnimationFrame();
|
|
179
|
-
return _this;
|
|
180
|
-
}
|
|
181
|
-
Object.defineProperty(MDCSliderFoundation, "defaultAdapter", {
|
|
182
|
-
get: function () {
|
|
183
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same
|
|
184
|
-
// order as the adapter interface.
|
|
185
|
-
return {
|
|
186
|
-
hasClass: function () { return false; },
|
|
187
|
-
addClass: function () { return undefined; },
|
|
188
|
-
removeClass: function () { return undefined; },
|
|
189
|
-
addThumbClass: function () { return undefined; },
|
|
190
|
-
removeThumbClass: function () { return undefined; },
|
|
191
|
-
getAttribute: function () { return null; },
|
|
192
|
-
getInputValue: function () { return ''; },
|
|
193
|
-
setInputValue: function () { return undefined; },
|
|
194
|
-
getInputAttribute: function () { return null; },
|
|
195
|
-
setInputAttribute: function () { return null; },
|
|
196
|
-
removeInputAttribute: function () { return null; },
|
|
197
|
-
focusInput: function () { return undefined; },
|
|
198
|
-
isInputFocused: function () { return false; },
|
|
199
|
-
getThumbKnobWidth: function () { return 0; },
|
|
200
|
-
getThumbBoundingClientRect: function () {
|
|
201
|
-
return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 });
|
|
202
|
-
},
|
|
203
|
-
getBoundingClientRect: function () {
|
|
204
|
-
return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 });
|
|
205
|
-
},
|
|
206
|
-
isRTL: function () { return false; },
|
|
207
|
-
setThumbStyleProperty: function () { return undefined; },
|
|
208
|
-
removeThumbStyleProperty: function () { return undefined; },
|
|
209
|
-
setTrackActiveStyleProperty: function () { return undefined; },
|
|
210
|
-
removeTrackActiveStyleProperty: function () { return undefined; },
|
|
211
|
-
setValueIndicatorText: function () { return undefined; },
|
|
212
|
-
getValueToAriaValueTextFn: function () { return null; },
|
|
213
|
-
updateTickMarks: function () { return undefined; },
|
|
214
|
-
setPointerCapture: function () { return undefined; },
|
|
215
|
-
emitChangeEvent: function () { return undefined; },
|
|
216
|
-
emitInputEvent: function () { return undefined; },
|
|
217
|
-
emitDragStartEvent: function () { return undefined; },
|
|
218
|
-
emitDragEndEvent: function () { return undefined; },
|
|
219
|
-
registerEventHandler: function () { return undefined; },
|
|
220
|
-
deregisterEventHandler: function () { return undefined; },
|
|
221
|
-
registerThumbEventHandler: function () { return undefined; },
|
|
222
|
-
deregisterThumbEventHandler: function () { return undefined; },
|
|
223
|
-
registerInputEventHandler: function () { return undefined; },
|
|
224
|
-
deregisterInputEventHandler: function () { return undefined; },
|
|
225
|
-
registerBodyEventHandler: function () { return undefined; },
|
|
226
|
-
deregisterBodyEventHandler: function () { return undefined; },
|
|
227
|
-
registerWindowEventHandler: function () { return undefined; },
|
|
228
|
-
deregisterWindowEventHandler: function () { return undefined; },
|
|
229
|
-
};
|
|
230
|
-
// tslint:enable:object-literal-sort-keys
|
|
231
|
-
},
|
|
232
|
-
enumerable: false,
|
|
233
|
-
configurable: true
|
|
234
|
-
});
|
|
235
|
-
MDCSliderFoundation.prototype.init = function () {
|
|
236
|
-
var _this = this;
|
|
237
|
-
this.isDisabled = this.adapter.hasClass(cssClasses.DISABLED);
|
|
238
|
-
this.isDiscrete = this.adapter.hasClass(cssClasses.DISCRETE);
|
|
239
|
-
this.hasTickMarks = this.adapter.hasClass(cssClasses.TICK_MARKS);
|
|
240
|
-
this.isRange = this.adapter.hasClass(cssClasses.RANGE);
|
|
241
|
-
var min = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(attributes.INPUT_MIN, this.isRange ? Thumb.START : Thumb.END), attributes.INPUT_MIN);
|
|
242
|
-
var max = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(attributes.INPUT_MAX, Thumb.END), attributes.INPUT_MAX);
|
|
243
|
-
var value = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(attributes.INPUT_VALUE, Thumb.END), attributes.INPUT_VALUE);
|
|
244
|
-
var valueStart = this.isRange ?
|
|
245
|
-
this.convertAttributeValueToNumber(this.adapter.getInputAttribute(attributes.INPUT_VALUE, Thumb.START), attributes.INPUT_VALUE) :
|
|
246
|
-
min;
|
|
247
|
-
var stepAttr = this.adapter.getInputAttribute(attributes.INPUT_STEP, Thumb.END);
|
|
248
|
-
var step = stepAttr ?
|
|
249
|
-
this.convertAttributeValueToNumber(stepAttr, attributes.INPUT_STEP) :
|
|
250
|
-
this.step;
|
|
251
|
-
this.validateProperties({ min: min, max: max, value: value, valueStart: valueStart, step: step });
|
|
252
|
-
this.min = min;
|
|
253
|
-
this.max = max;
|
|
254
|
-
this.value = value;
|
|
255
|
-
this.valueStart = valueStart;
|
|
256
|
-
this.step = step;
|
|
257
|
-
this.numDecimalPlaces = getNumDecimalPlaces(this.step);
|
|
258
|
-
this.valueBeforeDownEvent = value;
|
|
259
|
-
this.valueStartBeforeDownEvent = valueStart;
|
|
260
|
-
this.mousedownOrTouchstartListener =
|
|
261
|
-
this.handleMousedownOrTouchstart.bind(this);
|
|
262
|
-
this.moveListener = this.handleMove.bind(this);
|
|
263
|
-
this.pointerdownListener = this.handlePointerdown.bind(this);
|
|
264
|
-
this.pointerupListener = this.handlePointerup.bind(this);
|
|
265
|
-
this.thumbMouseenterListener = this.handleThumbMouseenter.bind(this);
|
|
266
|
-
this.thumbMouseleaveListener = this.handleThumbMouseleave.bind(this);
|
|
267
|
-
this.inputStartChangeListener = function () {
|
|
268
|
-
_this.handleInputChange(Thumb.START);
|
|
269
|
-
};
|
|
270
|
-
this.inputEndChangeListener = function () {
|
|
271
|
-
_this.handleInputChange(Thumb.END);
|
|
272
|
-
};
|
|
273
|
-
this.inputStartFocusListener = function () {
|
|
274
|
-
_this.handleInputFocus(Thumb.START);
|
|
275
|
-
};
|
|
276
|
-
this.inputEndFocusListener = function () {
|
|
277
|
-
_this.handleInputFocus(Thumb.END);
|
|
278
|
-
};
|
|
279
|
-
this.inputStartBlurListener = function () {
|
|
280
|
-
_this.handleInputBlur(Thumb.START);
|
|
281
|
-
};
|
|
282
|
-
this.inputEndBlurListener = function () {
|
|
283
|
-
_this.handleInputBlur(Thumb.END);
|
|
284
|
-
};
|
|
285
|
-
this.resizeListener = this.handleResize.bind(this);
|
|
286
|
-
this.registerEventHandlers();
|
|
287
|
-
};
|
|
288
|
-
MDCSliderFoundation.prototype.destroy = function () {
|
|
289
|
-
this.deregisterEventHandlers();
|
|
290
|
-
};
|
|
291
|
-
MDCSliderFoundation.prototype.setMin = function (value) {
|
|
292
|
-
this.min = value;
|
|
293
|
-
if (!this.isRange) {
|
|
294
|
-
this.valueStart = value;
|
|
295
|
-
}
|
|
296
|
-
this.updateUI();
|
|
297
|
-
};
|
|
298
|
-
MDCSliderFoundation.prototype.setMax = function (value) {
|
|
299
|
-
this.max = value;
|
|
300
|
-
this.updateUI();
|
|
301
|
-
};
|
|
302
|
-
MDCSliderFoundation.prototype.getMin = function () {
|
|
303
|
-
return this.min;
|
|
304
|
-
};
|
|
305
|
-
MDCSliderFoundation.prototype.getMax = function () {
|
|
306
|
-
return this.max;
|
|
307
|
-
};
|
|
308
|
-
/**
|
|
309
|
-
* - For single point sliders, returns the thumb value.
|
|
310
|
-
* - For range (two-thumb) sliders, returns the end thumb's value.
|
|
311
|
-
*/
|
|
312
|
-
MDCSliderFoundation.prototype.getValue = function () {
|
|
313
|
-
return this.value;
|
|
314
|
-
};
|
|
315
|
-
/**
|
|
316
|
-
* - For single point sliders, sets the thumb value.
|
|
317
|
-
* - For range (two-thumb) sliders, sets the end thumb's value.
|
|
318
|
-
*/
|
|
319
|
-
MDCSliderFoundation.prototype.setValue = function (value) {
|
|
320
|
-
if (this.isRange && value < this.valueStart) {
|
|
321
|
-
throw new Error("end thumb value (" + value + ") must be >= start thumb " +
|
|
322
|
-
("value (" + this.valueStart + ")"));
|
|
323
|
-
}
|
|
324
|
-
this.updateValue(value, Thumb.END);
|
|
325
|
-
};
|
|
326
|
-
/**
|
|
327
|
-
* Only applicable for range sliders.
|
|
328
|
-
* @return The start thumb's value.
|
|
329
|
-
*/
|
|
330
|
-
MDCSliderFoundation.prototype.getValueStart = function () {
|
|
331
|
-
if (!this.isRange) {
|
|
332
|
-
throw new Error('`valueStart` is only applicable for range sliders.');
|
|
333
|
-
}
|
|
334
|
-
return this.valueStart;
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* Only applicable for range sliders. Sets the start thumb's value.
|
|
338
|
-
*/
|
|
339
|
-
MDCSliderFoundation.prototype.setValueStart = function (valueStart) {
|
|
340
|
-
if (!this.isRange) {
|
|
341
|
-
throw new Error('`valueStart` is only applicable for range sliders.');
|
|
342
|
-
}
|
|
343
|
-
if (this.isRange && valueStart > this.value) {
|
|
344
|
-
throw new Error("start thumb value (" + valueStart + ") must be <= end thumb " +
|
|
345
|
-
("value (" + this.value + ")"));
|
|
346
|
-
}
|
|
347
|
-
this.updateValue(valueStart, Thumb.START);
|
|
348
|
-
};
|
|
349
|
-
MDCSliderFoundation.prototype.setStep = function (value) {
|
|
350
|
-
this.step = value;
|
|
351
|
-
this.numDecimalPlaces = getNumDecimalPlaces(value);
|
|
352
|
-
this.updateUI();
|
|
353
|
-
};
|
|
354
|
-
MDCSliderFoundation.prototype.setIsDiscrete = function (value) {
|
|
355
|
-
this.isDiscrete = value;
|
|
356
|
-
this.updateValueIndicatorUI();
|
|
357
|
-
this.updateTickMarksUI();
|
|
358
|
-
};
|
|
359
|
-
MDCSliderFoundation.prototype.getStep = function () {
|
|
360
|
-
return this.step;
|
|
361
|
-
};
|
|
362
|
-
MDCSliderFoundation.prototype.setHasTickMarks = function (value) {
|
|
363
|
-
this.hasTickMarks = value;
|
|
364
|
-
this.updateTickMarksUI();
|
|
365
|
-
};
|
|
366
|
-
MDCSliderFoundation.prototype.getDisabled = function () {
|
|
367
|
-
return this.isDisabled;
|
|
368
|
-
};
|
|
369
|
-
/**
|
|
370
|
-
* Sets disabled state, including updating styles and thumb tabindex.
|
|
371
|
-
*/
|
|
372
|
-
MDCSliderFoundation.prototype.setDisabled = function (disabled) {
|
|
373
|
-
this.isDisabled = disabled;
|
|
374
|
-
if (disabled) {
|
|
375
|
-
this.adapter.addClass(cssClasses.DISABLED);
|
|
376
|
-
if (this.isRange) {
|
|
377
|
-
this.adapter.setInputAttribute(attributes.INPUT_DISABLED, '', Thumb.START);
|
|
378
|
-
}
|
|
379
|
-
this.adapter.setInputAttribute(attributes.INPUT_DISABLED, '', Thumb.END);
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
this.adapter.removeClass(cssClasses.DISABLED);
|
|
383
|
-
if (this.isRange) {
|
|
384
|
-
this.adapter.removeInputAttribute(attributes.INPUT_DISABLED, Thumb.START);
|
|
385
|
-
}
|
|
386
|
-
this.adapter.removeInputAttribute(attributes.INPUT_DISABLED, Thumb.END);
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
/** @return Whether the slider is a range slider. */
|
|
390
|
-
MDCSliderFoundation.prototype.getIsRange = function () {
|
|
391
|
-
return this.isRange;
|
|
392
|
-
};
|
|
393
|
-
/**
|
|
394
|
-
* - Syncs slider boundingClientRect with the current DOM.
|
|
395
|
-
* - Updates UI based on internal state.
|
|
396
|
-
*/
|
|
397
|
-
MDCSliderFoundation.prototype.layout = function (_a) {
|
|
398
|
-
var _b = _a === void 0 ? {} : _a, skipUpdateUI = _b.skipUpdateUI;
|
|
399
|
-
this.rect = this.adapter.getBoundingClientRect();
|
|
400
|
-
if (this.isRange) {
|
|
401
|
-
this.startThumbKnobWidth = this.adapter.getThumbKnobWidth(Thumb.START);
|
|
402
|
-
this.endThumbKnobWidth = this.adapter.getThumbKnobWidth(Thumb.END);
|
|
403
|
-
}
|
|
404
|
-
if (!skipUpdateUI) {
|
|
405
|
-
this.updateUI();
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
/** Handles resize events on the window. */
|
|
409
|
-
MDCSliderFoundation.prototype.handleResize = function () {
|
|
410
|
-
this.layout();
|
|
411
|
-
};
|
|
412
|
-
/**
|
|
413
|
-
* Handles pointer down events on the slider root element.
|
|
414
|
-
*/
|
|
415
|
-
MDCSliderFoundation.prototype.handleDown = function (event) {
|
|
416
|
-
if (this.isDisabled)
|
|
417
|
-
return;
|
|
418
|
-
this.valueStartBeforeDownEvent = this.valueStart;
|
|
419
|
-
this.valueBeforeDownEvent = this.value;
|
|
420
|
-
var clientX = event.clientX != null ?
|
|
421
|
-
event.clientX :
|
|
422
|
-
event.targetTouches[0].clientX;
|
|
423
|
-
this.downEventClientX = clientX;
|
|
424
|
-
var value = this.mapClientXOnSliderScale(clientX);
|
|
425
|
-
this.thumb = this.getThumbFromDownEvent(clientX, value);
|
|
426
|
-
if (this.thumb === null)
|
|
427
|
-
return;
|
|
428
|
-
this.handleDragStart(event, value, this.thumb);
|
|
429
|
-
this.updateValue(value, this.thumb, { emitInputEvent: true });
|
|
430
|
-
};
|
|
431
|
-
/**
|
|
432
|
-
* Handles pointer move events on the slider root element.
|
|
433
|
-
*/
|
|
434
|
-
MDCSliderFoundation.prototype.handleMove = function (event) {
|
|
435
|
-
if (this.isDisabled)
|
|
436
|
-
return;
|
|
437
|
-
// Prevent scrolling.
|
|
438
|
-
event.preventDefault();
|
|
439
|
-
var clientX = event.clientX != null ?
|
|
440
|
-
event.clientX :
|
|
441
|
-
event.targetTouches[0].clientX;
|
|
442
|
-
var dragAlreadyStarted = this.thumb != null;
|
|
443
|
-
this.thumb = this.getThumbFromMoveEvent(clientX);
|
|
444
|
-
if (this.thumb === null)
|
|
445
|
-
return;
|
|
446
|
-
var value = this.mapClientXOnSliderScale(clientX);
|
|
447
|
-
if (!dragAlreadyStarted) {
|
|
448
|
-
this.handleDragStart(event, value, this.thumb);
|
|
449
|
-
this.adapter.emitDragStartEvent(value, this.thumb);
|
|
450
|
-
}
|
|
451
|
-
this.updateValue(value, this.thumb, { emitInputEvent: true });
|
|
452
|
-
};
|
|
453
|
-
/**
|
|
454
|
-
* Handles pointer up events on the slider root element.
|
|
455
|
-
*/
|
|
456
|
-
MDCSliderFoundation.prototype.handleUp = function () {
|
|
457
|
-
if (this.isDisabled || this.thumb === null)
|
|
458
|
-
return;
|
|
459
|
-
var oldValue = this.thumb === Thumb.START ?
|
|
460
|
-
this.valueStartBeforeDownEvent :
|
|
461
|
-
this.valueBeforeDownEvent;
|
|
462
|
-
var newValue = this.thumb === Thumb.START ? this.valueStart : this.value;
|
|
463
|
-
if (oldValue !== newValue) {
|
|
464
|
-
this.adapter.emitChangeEvent(newValue, this.thumb);
|
|
465
|
-
}
|
|
466
|
-
this.adapter.emitDragEndEvent(newValue, this.thumb);
|
|
467
|
-
this.thumb = null;
|
|
468
|
-
};
|
|
469
|
-
/**
|
|
470
|
-
* For range, discrete slider, shows the value indicator on both thumbs.
|
|
471
|
-
*/
|
|
472
|
-
MDCSliderFoundation.prototype.handleThumbMouseenter = function () {
|
|
473
|
-
if (!this.isDiscrete || !this.isRange)
|
|
474
|
-
return;
|
|
475
|
-
this.adapter.addThumbClass(cssClasses.THUMB_WITH_INDICATOR, Thumb.START);
|
|
476
|
-
this.adapter.addThumbClass(cssClasses.THUMB_WITH_INDICATOR, Thumb.END);
|
|
477
|
-
};
|
|
478
|
-
/**
|
|
479
|
-
* For range, discrete slider, hides the value indicator on both thumbs.
|
|
480
|
-
*/
|
|
481
|
-
MDCSliderFoundation.prototype.handleThumbMouseleave = function () {
|
|
482
|
-
if (!this.isDiscrete || !this.isRange)
|
|
483
|
-
return;
|
|
484
|
-
if (this.adapter.isInputFocused(Thumb.START) ||
|
|
485
|
-
this.adapter.isInputFocused(Thumb.END)) {
|
|
486
|
-
// Leave value indicator shown if either input is focused.
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
this.adapter.removeThumbClass(cssClasses.THUMB_WITH_INDICATOR, Thumb.START);
|
|
490
|
-
this.adapter.removeThumbClass(cssClasses.THUMB_WITH_INDICATOR, Thumb.END);
|
|
491
|
-
};
|
|
492
|
-
MDCSliderFoundation.prototype.handleMousedownOrTouchstart = function (event) {
|
|
493
|
-
var _this = this;
|
|
494
|
-
var moveEventType = event.type === 'mousedown' ? 'mousemove' : 'touchmove';
|
|
495
|
-
// After a down event on the slider root, listen for move events on
|
|
496
|
-
// body (so the slider value is updated for events outside of the
|
|
497
|
-
// slider root).
|
|
498
|
-
this.adapter.registerBodyEventHandler(moveEventType, this.moveListener);
|
|
499
|
-
var upHandler = function () {
|
|
500
|
-
_this.handleUp();
|
|
501
|
-
// Once the drag is finished (up event on body), remove the move
|
|
502
|
-
// handler.
|
|
503
|
-
_this.adapter.deregisterBodyEventHandler(moveEventType, _this.moveListener);
|
|
504
|
-
// Also stop listening for subsequent up events.
|
|
505
|
-
_this.adapter.deregisterEventHandler('mouseup', upHandler);
|
|
506
|
-
_this.adapter.deregisterEventHandler('touchend', upHandler);
|
|
507
|
-
};
|
|
508
|
-
this.adapter.registerBodyEventHandler('mouseup', upHandler);
|
|
509
|
-
this.adapter.registerBodyEventHandler('touchend', upHandler);
|
|
510
|
-
this.handleDown(event);
|
|
511
|
-
};
|
|
512
|
-
MDCSliderFoundation.prototype.handlePointerdown = function (event) {
|
|
513
|
-
this.adapter.setPointerCapture(event.pointerId);
|
|
514
|
-
this.adapter.registerEventHandler('pointermove', this.moveListener);
|
|
515
|
-
this.handleDown(event);
|
|
516
|
-
};
|
|
517
|
-
/**
|
|
518
|
-
* Handles input `change` event by setting internal slider value to match
|
|
519
|
-
* input's new value.
|
|
520
|
-
*/
|
|
521
|
-
MDCSliderFoundation.prototype.handleInputChange = function (thumb) {
|
|
522
|
-
var value = Number(this.adapter.getInputValue(thumb));
|
|
523
|
-
if (thumb === Thumb.START) {
|
|
524
|
-
this.setValueStart(value);
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
this.setValue(value);
|
|
528
|
-
}
|
|
529
|
-
this.adapter.emitChangeEvent(thumb === Thumb.START ? this.valueStart : this.value, thumb);
|
|
530
|
-
this.adapter.emitInputEvent(thumb === Thumb.START ? this.valueStart : this.value, thumb);
|
|
531
|
-
};
|
|
532
|
-
/** Shows activated state and value indicator on thumb(s). */
|
|
533
|
-
MDCSliderFoundation.prototype.handleInputFocus = function (thumb) {
|
|
534
|
-
this.adapter.addThumbClass(cssClasses.THUMB_FOCUSED, thumb);
|
|
535
|
-
if (!this.isDiscrete)
|
|
536
|
-
return;
|
|
537
|
-
this.adapter.addThumbClass(cssClasses.THUMB_WITH_INDICATOR, thumb);
|
|
538
|
-
if (this.isRange) {
|
|
539
|
-
var otherThumb = thumb === Thumb.START ? Thumb.END : Thumb.START;
|
|
540
|
-
this.adapter.addThumbClass(cssClasses.THUMB_WITH_INDICATOR, otherThumb);
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
/** Removes activated state and value indicator from thumb(s). */
|
|
544
|
-
MDCSliderFoundation.prototype.handleInputBlur = function (thumb) {
|
|
545
|
-
this.adapter.removeThumbClass(cssClasses.THUMB_FOCUSED, thumb);
|
|
546
|
-
if (!this.isDiscrete)
|
|
547
|
-
return;
|
|
548
|
-
this.adapter.removeThumbClass(cssClasses.THUMB_WITH_INDICATOR, thumb);
|
|
549
|
-
if (this.isRange) {
|
|
550
|
-
var otherThumb = thumb === Thumb.START ? Thumb.END : Thumb.START;
|
|
551
|
-
this.adapter.removeThumbClass(cssClasses.THUMB_WITH_INDICATOR, otherThumb);
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
/**
|
|
555
|
-
* Emits custom dragStart event, along with focusing the underlying input.
|
|
556
|
-
*/
|
|
557
|
-
MDCSliderFoundation.prototype.handleDragStart = function (event, value, thumb) {
|
|
558
|
-
this.adapter.emitDragStartEvent(value, thumb);
|
|
559
|
-
this.adapter.focusInput(thumb);
|
|
560
|
-
// Prevent the input (that we just focused) from losing focus.
|
|
561
|
-
event.preventDefault();
|
|
562
|
-
};
|
|
563
|
-
/**
|
|
564
|
-
* @return The thumb to be moved based on initial down event.
|
|
565
|
-
*/
|
|
566
|
-
MDCSliderFoundation.prototype.getThumbFromDownEvent = function (clientX, value) {
|
|
567
|
-
// For single point slider, thumb to be moved is always the END (only)
|
|
568
|
-
// thumb.
|
|
569
|
-
if (!this.isRange)
|
|
570
|
-
return Thumb.END;
|
|
571
|
-
// Check if event press point is in the bounds of any thumb.
|
|
572
|
-
var thumbStartRect = this.adapter.getThumbBoundingClientRect(Thumb.START);
|
|
573
|
-
var thumbEndRect = this.adapter.getThumbBoundingClientRect(Thumb.END);
|
|
574
|
-
var inThumbStartBounds = clientX >= thumbStartRect.left && clientX <= thumbStartRect.right;
|
|
575
|
-
var inThumbEndBounds = clientX >= thumbEndRect.left && clientX <= thumbEndRect.right;
|
|
576
|
-
if (inThumbStartBounds && inThumbEndBounds) {
|
|
577
|
-
// Thumbs overlapping. Thumb to be moved cannot be determined yet.
|
|
578
|
-
return null;
|
|
579
|
-
}
|
|
580
|
-
// If press is in bounds for either thumb on down event, that's the thumb
|
|
581
|
-
// to be moved.
|
|
582
|
-
if (inThumbStartBounds) {
|
|
583
|
-
return Thumb.START;
|
|
584
|
-
}
|
|
585
|
-
if (inThumbEndBounds) {
|
|
586
|
-
return Thumb.END;
|
|
587
|
-
}
|
|
588
|
-
// For presses outside the range, return whichever thumb is closer.
|
|
589
|
-
if (value < this.valueStart) {
|
|
590
|
-
return Thumb.START;
|
|
591
|
-
}
|
|
592
|
-
if (value > this.value) {
|
|
593
|
-
return Thumb.END;
|
|
594
|
-
}
|
|
595
|
-
// For presses inside the range, return whichever thumb is closer.
|
|
596
|
-
return (value - this.valueStart <= this.value - value) ? Thumb.START :
|
|
597
|
-
Thumb.END;
|
|
598
|
-
};
|
|
599
|
-
/**
|
|
600
|
-
* @return The thumb to be moved based on move event (based on drag
|
|
601
|
-
* direction from original down event). Only applicable if thumbs
|
|
602
|
-
* were overlapping in the down event.
|
|
603
|
-
*/
|
|
604
|
-
MDCSliderFoundation.prototype.getThumbFromMoveEvent = function (clientX) {
|
|
605
|
-
// Thumb has already been chosen.
|
|
606
|
-
if (this.thumb !== null)
|
|
607
|
-
return this.thumb;
|
|
608
|
-
if (this.downEventClientX === null) {
|
|
609
|
-
throw new Error('`downEventClientX` is null after move event.');
|
|
610
|
-
}
|
|
611
|
-
var moveDistanceUnderThreshold = Math.abs(this.downEventClientX - clientX) < numbers.THUMB_UPDATE_MIN_PX;
|
|
612
|
-
if (moveDistanceUnderThreshold)
|
|
613
|
-
return this.thumb;
|
|
614
|
-
var draggedThumbToLeft = clientX < this.downEventClientX;
|
|
615
|
-
if (draggedThumbToLeft) {
|
|
616
|
-
return this.adapter.isRTL() ? Thumb.END : Thumb.START;
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
return this.adapter.isRTL() ? Thumb.START : Thumb.END;
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
/**
|
|
623
|
-
* Updates UI based on internal state.
|
|
624
|
-
* @param thumb Thumb whose value is being updated. If undefined, UI is
|
|
625
|
-
* updated for both thumbs based on current internal state.
|
|
626
|
-
*/
|
|
627
|
-
MDCSliderFoundation.prototype.updateUI = function (thumb) {
|
|
628
|
-
this.updateThumbAndInputAttributes(thumb);
|
|
629
|
-
this.updateThumbAndTrackUI(thumb);
|
|
630
|
-
this.updateValueIndicatorUI(thumb);
|
|
631
|
-
this.updateTickMarksUI();
|
|
632
|
-
};
|
|
633
|
-
/**
|
|
634
|
-
* Updates thumb and input attributes based on current value.
|
|
635
|
-
* @param thumb Thumb whose aria attributes to update.
|
|
636
|
-
*/
|
|
637
|
-
MDCSliderFoundation.prototype.updateThumbAndInputAttributes = function (thumb) {
|
|
638
|
-
if (!thumb)
|
|
639
|
-
return;
|
|
640
|
-
var value = this.isRange && thumb === Thumb.START ? this.valueStart : this.value;
|
|
641
|
-
var valueStr = String(value);
|
|
642
|
-
this.adapter.setInputAttribute(attributes.INPUT_VALUE, valueStr, thumb);
|
|
643
|
-
if (this.isRange && thumb === Thumb.START) {
|
|
644
|
-
this.adapter.setInputAttribute(attributes.INPUT_MIN, valueStr, Thumb.END);
|
|
645
|
-
}
|
|
646
|
-
else if (this.isRange && thumb === Thumb.END) {
|
|
647
|
-
this.adapter.setInputAttribute(attributes.INPUT_MAX, valueStr, Thumb.START);
|
|
648
|
-
}
|
|
649
|
-
// Sync attribute with property.
|
|
650
|
-
if (this.adapter.getInputValue(thumb) !== valueStr) {
|
|
651
|
-
this.adapter.setInputValue(valueStr, thumb);
|
|
652
|
-
}
|
|
653
|
-
var valueToAriaValueTextFn = this.adapter.getValueToAriaValueTextFn();
|
|
654
|
-
if (valueToAriaValueTextFn) {
|
|
655
|
-
this.adapter.setInputAttribute(attributes.ARIA_VALUETEXT, valueToAriaValueTextFn(value), thumb);
|
|
656
|
-
}
|
|
657
|
-
};
|
|
658
|
-
/**
|
|
659
|
-
* Updates value indicator UI based on current value.
|
|
660
|
-
* @param thumb Thumb whose value indicator to update. If undefined, all
|
|
661
|
-
* thumbs' value indicators are updated.
|
|
662
|
-
*/
|
|
663
|
-
MDCSliderFoundation.prototype.updateValueIndicatorUI = function (thumb) {
|
|
664
|
-
if (!this.isDiscrete)
|
|
665
|
-
return;
|
|
666
|
-
var value = this.isRange && thumb === Thumb.START ? this.valueStart : this.value;
|
|
667
|
-
this.adapter.setValueIndicatorText(value, thumb === Thumb.START ? Thumb.START : Thumb.END);
|
|
668
|
-
if (!thumb && this.isRange) {
|
|
669
|
-
this.adapter.setValueIndicatorText(this.valueStart, Thumb.START);
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
/**
|
|
673
|
-
* Updates tick marks UI within slider, based on current min, max, and step.
|
|
674
|
-
*/
|
|
675
|
-
MDCSliderFoundation.prototype.updateTickMarksUI = function () {
|
|
676
|
-
if (!this.isDiscrete || !this.hasTickMarks)
|
|
677
|
-
return;
|
|
678
|
-
var numTickMarksInactiveStart = (this.valueStart - this.min) / this.step;
|
|
679
|
-
var numTickMarksActive = (this.value - this.valueStart) / this.step + 1;
|
|
680
|
-
var numTickMarksInactiveEnd = (this.max - this.value) / this.step;
|
|
681
|
-
var tickMarksInactiveStart = Array.from({ length: numTickMarksInactiveStart })
|
|
682
|
-
.fill(TickMark.INACTIVE);
|
|
683
|
-
var tickMarksActive = Array.from({ length: numTickMarksActive })
|
|
684
|
-
.fill(TickMark.ACTIVE);
|
|
685
|
-
var tickMarksInactiveEnd = Array.from({ length: numTickMarksInactiveEnd })
|
|
686
|
-
.fill(TickMark.INACTIVE);
|
|
687
|
-
this.adapter.updateTickMarks(tickMarksInactiveStart.concat(tickMarksActive)
|
|
688
|
-
.concat(tickMarksInactiveEnd));
|
|
689
|
-
};
|
|
690
|
-
/** Maps clientX to a value on the slider scale. */
|
|
691
|
-
MDCSliderFoundation.prototype.mapClientXOnSliderScale = function (clientX) {
|
|
692
|
-
var xPos = clientX - this.rect.left;
|
|
693
|
-
var pctComplete = xPos / this.rect.width;
|
|
694
|
-
if (this.adapter.isRTL()) {
|
|
695
|
-
pctComplete = 1 - pctComplete;
|
|
696
|
-
}
|
|
697
|
-
// Fit the percentage complete between the range [min,max]
|
|
698
|
-
// by remapping from [0, 1] to [min, min+(max-min)].
|
|
699
|
-
var value = this.min + pctComplete * (this.max - this.min);
|
|
700
|
-
if (value === this.max || value === this.min) {
|
|
701
|
-
return value;
|
|
702
|
-
}
|
|
703
|
-
return Number(this.quantize(value).toFixed(this.numDecimalPlaces));
|
|
704
|
-
};
|
|
705
|
-
/** Calculates the quantized value based on step value. */
|
|
706
|
-
MDCSliderFoundation.prototype.quantize = function (value) {
|
|
707
|
-
var numSteps = Math.round((value - this.min) / this.step);
|
|
708
|
-
return this.min + numSteps * this.step;
|
|
709
|
-
};
|
|
710
|
-
/**
|
|
711
|
-
* Updates slider value (internal state and UI) based on the given value.
|
|
712
|
-
*/
|
|
713
|
-
MDCSliderFoundation.prototype.updateValue = function (value, thumb, _a) {
|
|
714
|
-
var _b = _a === void 0 ? {} : _a, emitInputEvent = _b.emitInputEvent;
|
|
715
|
-
value = this.clampValue(value, thumb);
|
|
716
|
-
if (this.isRange && thumb === Thumb.START) {
|
|
717
|
-
// Exit early if current value is the same as the new value.
|
|
718
|
-
if (this.valueStart === value)
|
|
719
|
-
return;
|
|
720
|
-
this.valueStart = value;
|
|
721
|
-
}
|
|
722
|
-
else {
|
|
723
|
-
// Exit early if current value is the same as the new value.
|
|
724
|
-
if (this.value === value)
|
|
725
|
-
return;
|
|
726
|
-
this.value = value;
|
|
727
|
-
}
|
|
728
|
-
this.updateUI(thumb);
|
|
729
|
-
if (emitInputEvent) {
|
|
730
|
-
this.adapter.emitInputEvent(thumb === Thumb.START ? this.valueStart : this.value, thumb);
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
/**
|
|
734
|
-
* Clamps the given value for the given thumb based on slider properties:
|
|
735
|
-
* - Restricts value within [min, max].
|
|
736
|
-
* - If range slider, clamp start value <= end value, and
|
|
737
|
-
* end value >= start value.
|
|
738
|
-
*/
|
|
739
|
-
MDCSliderFoundation.prototype.clampValue = function (value, thumb) {
|
|
740
|
-
// Clamp value to [min, max] range.
|
|
741
|
-
value = Math.min(Math.max(value, this.min), this.max);
|
|
742
|
-
var thumbStartMovedPastThumbEnd = this.isRange && thumb === Thumb.START && value > this.value;
|
|
743
|
-
if (thumbStartMovedPastThumbEnd) {
|
|
744
|
-
return this.value;
|
|
745
|
-
}
|
|
746
|
-
var thumbEndMovedPastThumbStart = this.isRange && thumb === Thumb.END && value < this.valueStart;
|
|
747
|
-
if (thumbEndMovedPastThumbStart) {
|
|
748
|
-
return this.valueStart;
|
|
749
|
-
}
|
|
750
|
-
return value;
|
|
751
|
-
};
|
|
752
|
-
/**
|
|
753
|
-
* Updates the active track and thumb style properties to reflect current
|
|
754
|
-
* value.
|
|
755
|
-
*/
|
|
756
|
-
MDCSliderFoundation.prototype.updateThumbAndTrackUI = function (thumb) {
|
|
757
|
-
var _this = this;
|
|
758
|
-
var _a = this, max = _a.max, min = _a.min;
|
|
759
|
-
var pctComplete = (this.value - this.valueStart) / (max - min);
|
|
760
|
-
var rangePx = pctComplete * this.rect.width;
|
|
761
|
-
var isRtl = this.adapter.isRTL();
|
|
762
|
-
var transformProp = HAS_WINDOW ? util.getCorrectPropertyName(window, 'transform') : 'transform';
|
|
763
|
-
if (this.isRange) {
|
|
764
|
-
var thumbLeftPos_1 = this.adapter.isRTL() ?
|
|
765
|
-
(max - this.value) / (max - min) * this.rect.width :
|
|
766
|
-
(this.valueStart - min) / (max - min) * this.rect.width;
|
|
767
|
-
var thumbRightPos_1 = thumbLeftPos_1 + rangePx;
|
|
768
|
-
this.animFrame.request(AnimationKeys.SLIDER_UPDATE, function () {
|
|
769
|
-
// Set active track styles, accounting for animation direction by
|
|
770
|
-
// setting `transform-origin`.
|
|
771
|
-
var trackAnimatesFromRight = (!isRtl && thumb === Thumb.START) ||
|
|
772
|
-
(isRtl && thumb !== Thumb.START);
|
|
773
|
-
if (trackAnimatesFromRight) {
|
|
774
|
-
_this.adapter.setTrackActiveStyleProperty('transform-origin', 'right');
|
|
775
|
-
_this.adapter.setTrackActiveStyleProperty('left', 'unset');
|
|
776
|
-
_this.adapter.setTrackActiveStyleProperty('right', _this.rect.width - thumbRightPos_1 + "px");
|
|
777
|
-
}
|
|
778
|
-
else {
|
|
779
|
-
_this.adapter.setTrackActiveStyleProperty('transform-origin', 'left');
|
|
780
|
-
_this.adapter.setTrackActiveStyleProperty('right', 'unset');
|
|
781
|
-
_this.adapter.setTrackActiveStyleProperty('left', thumbLeftPos_1 + "px");
|
|
782
|
-
}
|
|
783
|
-
_this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
|
|
784
|
-
// Set thumb styles.
|
|
785
|
-
var thumbStartPos = isRtl ? thumbRightPos_1 : thumbLeftPos_1;
|
|
786
|
-
var thumbEndPos = _this.adapter.isRTL() ? thumbLeftPos_1 : thumbRightPos_1;
|
|
787
|
-
if (thumb === Thumb.START || !thumb || !_this.initialStylesRemoved) {
|
|
788
|
-
_this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", Thumb.START);
|
|
789
|
-
}
|
|
790
|
-
if (thumb === Thumb.END || !thumb || !_this.initialStylesRemoved) {
|
|
791
|
-
_this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbEndPos + "px)", Thumb.END);
|
|
792
|
-
}
|
|
793
|
-
_this.removeInitialStyles(isRtl);
|
|
794
|
-
_this.updateOverlappingThumbsUI(thumbStartPos, thumbEndPos, thumb);
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
else {
|
|
798
|
-
this.animFrame.request(AnimationKeys.SLIDER_UPDATE, function () {
|
|
799
|
-
var thumbStartPos = isRtl ? _this.rect.width - rangePx : rangePx;
|
|
800
|
-
_this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", Thumb.END);
|
|
801
|
-
_this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
|
|
802
|
-
_this.removeInitialStyles(isRtl);
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
/**
|
|
807
|
-
* Removes initial inline styles if not already removed. `left:<...>%`
|
|
808
|
-
* inline styles can be added to position the thumb correctly before JS
|
|
809
|
-
* initialization. However, they need to be removed before the JS starts
|
|
810
|
-
* positioning the thumb. This is because the JS uses
|
|
811
|
-
* `transform:translateX(<...>)px` (for performance reasons) to position
|
|
812
|
-
* the thumb (which is not possible for initial styles since we need the
|
|
813
|
-
* bounding rect measurements).
|
|
814
|
-
*/
|
|
815
|
-
MDCSliderFoundation.prototype.removeInitialStyles = function (isRtl) {
|
|
816
|
-
if (this.initialStylesRemoved)
|
|
817
|
-
return;
|
|
818
|
-
// Remove thumb position properties that were added for initial render.
|
|
819
|
-
var position = isRtl ? 'right' : 'left';
|
|
820
|
-
this.adapter.removeThumbStyleProperty(position, Thumb.END);
|
|
821
|
-
if (this.isRange) {
|
|
822
|
-
this.adapter.removeThumbStyleProperty(position, Thumb.START);
|
|
823
|
-
}
|
|
824
|
-
this.initialStylesRemoved = true;
|
|
825
|
-
this.resetTrackAndThumbAnimation();
|
|
826
|
-
};
|
|
827
|
-
/**
|
|
828
|
-
* Resets track/thumb animation to prevent animation when adding
|
|
829
|
-
* `transform` styles to thumb initially.
|
|
830
|
-
*/
|
|
831
|
-
MDCSliderFoundation.prototype.resetTrackAndThumbAnimation = function () {
|
|
832
|
-
var _this = this;
|
|
833
|
-
if (!this.isDiscrete)
|
|
834
|
-
return;
|
|
835
|
-
// Set transition properties to default (no animation), so that the
|
|
836
|
-
// newly added `transform` styles do not animate thumb/track from
|
|
837
|
-
// their default positions.
|
|
838
|
-
var transitionProp = HAS_WINDOW ?
|
|
839
|
-
util.getCorrectPropertyName(window, 'transition') :
|
|
840
|
-
'transition';
|
|
841
|
-
var transitionDefault = 'all 0s ease 0s';
|
|
842
|
-
this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, Thumb.END);
|
|
843
|
-
if (this.isRange) {
|
|
844
|
-
this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, Thumb.START);
|
|
845
|
-
}
|
|
846
|
-
this.adapter.setTrackActiveStyleProperty(transitionProp, transitionDefault);
|
|
847
|
-
// In the next frame, remove the transition inline styles we just
|
|
848
|
-
// added, such that any animations added in the CSS can now take effect.
|
|
849
|
-
requestAnimationFrame(function () {
|
|
850
|
-
_this.adapter.removeThumbStyleProperty(transitionProp, Thumb.END);
|
|
851
|
-
_this.adapter.removeTrackActiveStyleProperty(transitionProp);
|
|
852
|
-
if (_this.isRange) {
|
|
853
|
-
_this.adapter.removeThumbStyleProperty(transitionProp, Thumb.START);
|
|
854
|
-
}
|
|
855
|
-
});
|
|
856
|
-
};
|
|
857
|
-
/**
|
|
858
|
-
* Adds THUMB_TOP class to active thumb if thumb knobs overlap; otherwise
|
|
859
|
-
* removes THUMB_TOP class from both thumbs.
|
|
860
|
-
* @param thumb Thumb that is active (being moved).
|
|
861
|
-
*/
|
|
862
|
-
MDCSliderFoundation.prototype.updateOverlappingThumbsUI = function (thumbStartPos, thumbEndPos, thumb) {
|
|
863
|
-
var thumbsOverlap = false;
|
|
864
|
-
if (this.adapter.isRTL()) {
|
|
865
|
-
var startThumbLeftEdge = thumbStartPos - this.startThumbKnobWidth / 2;
|
|
866
|
-
var endThumbRightEdge = thumbEndPos + this.endThumbKnobWidth / 2;
|
|
867
|
-
thumbsOverlap = endThumbRightEdge >= startThumbLeftEdge;
|
|
868
|
-
}
|
|
869
|
-
else {
|
|
870
|
-
var startThumbRightEdge = thumbStartPos + this.startThumbKnobWidth / 2;
|
|
871
|
-
var endThumbLeftEdge = thumbEndPos - this.endThumbKnobWidth / 2;
|
|
872
|
-
thumbsOverlap = startThumbRightEdge >= endThumbLeftEdge;
|
|
873
|
-
}
|
|
874
|
-
if (thumbsOverlap) {
|
|
875
|
-
this.adapter.addThumbClass(cssClasses.THUMB_TOP,
|
|
876
|
-
// If no thumb was dragged (in the case of initial layout), end
|
|
877
|
-
// thumb is on top by default.
|
|
878
|
-
thumb || Thumb.END);
|
|
879
|
-
this.adapter.removeThumbClass(cssClasses.THUMB_TOP, thumb === Thumb.START ? Thumb.END : Thumb.START);
|
|
880
|
-
}
|
|
881
|
-
else {
|
|
882
|
-
this.adapter.removeThumbClass(cssClasses.THUMB_TOP, Thumb.START);
|
|
883
|
-
this.adapter.removeThumbClass(cssClasses.THUMB_TOP, Thumb.END);
|
|
884
|
-
}
|
|
885
|
-
};
|
|
886
|
-
/**
|
|
887
|
-
* Converts attribute value to a number, e.g. '100' => 100. Throws errors
|
|
888
|
-
* for invalid values.
|
|
889
|
-
* @param attributeValue Attribute value, e.g. 100.
|
|
890
|
-
* @param attributeName Attribute name, e.g. `aria-valuemax`.
|
|
891
|
-
*/
|
|
892
|
-
MDCSliderFoundation.prototype.convertAttributeValueToNumber = function (attributeValue, attributeName) {
|
|
893
|
-
if (attributeValue === null) {
|
|
894
|
-
throw new Error("MDCSliderFoundation: `" + attributeName + "` must be non-null.");
|
|
895
|
-
}
|
|
896
|
-
var value = Number(attributeValue);
|
|
897
|
-
if (isNaN(value)) {
|
|
898
|
-
throw new Error("MDCSliderFoundation: `" + attributeName + "` value is " +
|
|
899
|
-
("`" + attributeValue + "`, but must be a number."));
|
|
900
|
-
}
|
|
901
|
-
return value;
|
|
902
|
-
};
|
|
903
|
-
/** Checks that the given properties are valid slider values. */
|
|
904
|
-
MDCSliderFoundation.prototype.validateProperties = function (_a) {
|
|
905
|
-
var min = _a.min, max = _a.max, value = _a.value, valueStart = _a.valueStart, step = _a.step;
|
|
906
|
-
if (min >= max) {
|
|
907
|
-
throw new Error("MDCSliderFoundation: min must be strictly less than max. " +
|
|
908
|
-
("Current: [min: " + min + ", max: " + max + "]"));
|
|
909
|
-
}
|
|
910
|
-
if (step <= 0) {
|
|
911
|
-
throw new Error("MDCSliderFoundation: step must be a positive number. " +
|
|
912
|
-
("Current step: " + this.step));
|
|
913
|
-
}
|
|
914
|
-
if (this.isRange) {
|
|
915
|
-
if (value < min || value > max || valueStart < min || valueStart > max) {
|
|
916
|
-
throw new Error("MDCSliderFoundation: values must be in [min, max] range. " +
|
|
917
|
-
("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
|
|
918
|
-
}
|
|
919
|
-
if (valueStart > value) {
|
|
920
|
-
throw new Error("MDCSliderFoundation: start value must be <= end value. " +
|
|
921
|
-
("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
|
|
922
|
-
}
|
|
923
|
-
var numStepsValueStartFromMin = (valueStart - min) / step;
|
|
924
|
-
var numStepsValueFromMin = (value - min) / step;
|
|
925
|
-
if ((numStepsValueStartFromMin % 1) !== 0 ||
|
|
926
|
-
(numStepsValueFromMin % 1) !== 0) {
|
|
927
|
-
throw new Error("MDCSliderFoundation: Slider values must be valid based on the " +
|
|
928
|
-
("step value. Current values: [start value: " + valueStart + ", ") +
|
|
929
|
-
("end value: " + value + "]"));
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
else { // Single point slider.
|
|
933
|
-
if (value < min || value > max) {
|
|
934
|
-
throw new Error("MDCSliderFoundation: value must be in [min, max] range. " +
|
|
935
|
-
("Current value: " + value));
|
|
936
|
-
}
|
|
937
|
-
var numStepsValueFromMin = (value - min) / step;
|
|
938
|
-
if ((numStepsValueFromMin % 1) !== 0) {
|
|
939
|
-
throw new Error("MDCSliderFoundation: Slider value must be valid based on the " +
|
|
940
|
-
("step value. Current value: " + value));
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
};
|
|
944
|
-
MDCSliderFoundation.prototype.registerEventHandlers = function () {
|
|
945
|
-
this.adapter.registerWindowEventHandler('resize', this.resizeListener);
|
|
946
|
-
if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
|
|
947
|
-
// If supported, use pointer events API with #setPointerCapture.
|
|
948
|
-
this.adapter.registerEventHandler('pointerdown', this.pointerdownListener);
|
|
949
|
-
this.adapter.registerEventHandler('pointerup', this.pointerupListener);
|
|
950
|
-
}
|
|
951
|
-
else {
|
|
952
|
-
// Otherwise, fall back to mousedown/touchstart events.
|
|
953
|
-
this.adapter.registerEventHandler('mousedown', this.mousedownOrTouchstartListener);
|
|
954
|
-
this.adapter.registerEventHandler('touchstart', this.mousedownOrTouchstartListener);
|
|
955
|
-
}
|
|
956
|
-
if (this.isRange) {
|
|
957
|
-
this.adapter.registerThumbEventHandler(Thumb.START, 'mouseenter', this.thumbMouseenterListener);
|
|
958
|
-
this.adapter.registerThumbEventHandler(Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
|
|
959
|
-
this.adapter.registerInputEventHandler(Thumb.START, 'change', this.inputStartChangeListener);
|
|
960
|
-
this.adapter.registerInputEventHandler(Thumb.START, 'focus', this.inputStartFocusListener);
|
|
961
|
-
this.adapter.registerInputEventHandler(Thumb.START, 'blur', this.inputStartBlurListener);
|
|
962
|
-
}
|
|
963
|
-
this.adapter.registerThumbEventHandler(Thumb.END, 'mouseenter', this.thumbMouseenterListener);
|
|
964
|
-
this.adapter.registerThumbEventHandler(Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
|
|
965
|
-
this.adapter.registerInputEventHandler(Thumb.END, 'change', this.inputEndChangeListener);
|
|
966
|
-
this.adapter.registerInputEventHandler(Thumb.END, 'focus', this.inputEndFocusListener);
|
|
967
|
-
this.adapter.registerInputEventHandler(Thumb.END, 'blur', this.inputEndBlurListener);
|
|
968
|
-
};
|
|
969
|
-
MDCSliderFoundation.prototype.deregisterEventHandlers = function () {
|
|
970
|
-
this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
|
|
971
|
-
if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
|
|
972
|
-
this.adapter.deregisterEventHandler('pointerdown', this.pointerdownListener);
|
|
973
|
-
this.adapter.deregisterEventHandler('pointerup', this.pointerupListener);
|
|
974
|
-
}
|
|
975
|
-
else {
|
|
976
|
-
this.adapter.deregisterEventHandler('mousedown', this.mousedownOrTouchstartListener);
|
|
977
|
-
this.adapter.deregisterEventHandler('touchstart', this.mousedownOrTouchstartListener);
|
|
978
|
-
}
|
|
979
|
-
if (this.isRange) {
|
|
980
|
-
this.adapter.deregisterThumbEventHandler(Thumb.START, 'mouseenter', this.thumbMouseenterListener);
|
|
981
|
-
this.adapter.deregisterThumbEventHandler(Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
|
|
982
|
-
this.adapter.deregisterInputEventHandler(Thumb.START, 'change', this.inputStartChangeListener);
|
|
983
|
-
this.adapter.deregisterInputEventHandler(Thumb.START, 'focus', this.inputStartFocusListener);
|
|
984
|
-
this.adapter.deregisterInputEventHandler(Thumb.START, 'blur', this.inputStartBlurListener);
|
|
985
|
-
}
|
|
986
|
-
this.adapter.deregisterThumbEventHandler(Thumb.END, 'mouseenter', this.thumbMouseenterListener);
|
|
987
|
-
this.adapter.deregisterThumbEventHandler(Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
|
|
988
|
-
this.adapter.deregisterInputEventHandler(Thumb.END, 'change', this.inputEndChangeListener);
|
|
989
|
-
this.adapter.deregisterInputEventHandler(Thumb.END, 'focus', this.inputEndFocusListener);
|
|
990
|
-
this.adapter.deregisterInputEventHandler(Thumb.END, 'blur', this.inputEndBlurListener);
|
|
991
|
-
};
|
|
992
|
-
MDCSliderFoundation.prototype.handlePointerup = function () {
|
|
993
|
-
this.handleUp();
|
|
994
|
-
this.adapter.deregisterEventHandler('pointermove', this.moveListener);
|
|
995
|
-
};
|
|
996
|
-
MDCSliderFoundation.SUPPORTS_POINTER_EVENTS = HAS_WINDOW && Boolean(window.PointerEvent) &&
|
|
997
|
-
// #setPointerCapture is buggy on iOS, so we can't use pointer events
|
|
998
|
-
// until the following bug is fixed:
|
|
999
|
-
// https://bugs.webkit.org/show_bug.cgi?id=220196
|
|
1000
|
-
!isIOS();
|
|
1001
|
-
return MDCSliderFoundation;
|
|
1002
|
-
}(ponyfill.MDCFoundation));
|
|
1003
|
-
function isIOS() {
|
|
1004
|
-
// Source:
|
|
1005
|
-
// https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
|
|
1006
|
-
return [
|
|
1007
|
-
'iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone',
|
|
1008
|
-
'iPod'
|
|
1009
|
-
].includes(navigator.platform)
|
|
1010
|
-
// iPad on iOS 13 detection
|
|
1011
|
-
|| (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* Given a number, returns the number of digits that appear after the
|
|
1015
|
-
* decimal point.
|
|
1016
|
-
* See
|
|
1017
|
-
* https://stackoverflow.com/questions/9539513/is-there-a-reliable-way-in-javascript-to-obtain-the-number-of-decimal-places-of
|
|
1018
|
-
*/
|
|
1019
|
-
function getNumDecimalPlaces(n) {
|
|
1020
|
-
// Pull out the fraction and the exponent.
|
|
1021
|
-
var match = /(?:\.(\d+))?(?:[eE]([+\-]?\d+))?$/.exec(String(n));
|
|
1022
|
-
// NaN or Infinity or integer.
|
|
1023
|
-
// We arbitrarily decide that Infinity is integral.
|
|
1024
|
-
if (!match)
|
|
1025
|
-
return 0;
|
|
1026
|
-
var fraction = match[1] || ''; // E.g. 1.234e-2 => 234
|
|
1027
|
-
var exponent = match[2] || 0; // E.g. 1.234e-2 => -2
|
|
1028
|
-
// Count the number of digits in the fraction and subtract the
|
|
1029
|
-
// exponent to simulate moving the decimal point left by exponent places.
|
|
1030
|
-
// 1.234e+2 has 1 fraction digit and '234'.length - 2 == 1
|
|
1031
|
-
// 1.234e-2 has 5 fraction digit and '234'.length - -2 == 5
|
|
1032
|
-
return Math.max(0, // lower limit
|
|
1033
|
-
(fraction === '0' ? 0 : fraction.length) - Number(exponent));
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
/**
|
|
1037
|
-
* @license
|
|
1038
|
-
* Copyright 2020 Google Inc.
|
|
1039
|
-
*
|
|
1040
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1041
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
1042
|
-
* in the Software without restriction, including without limitation the rights
|
|
1043
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1044
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
1045
|
-
* furnished to do so, subject to the following conditions:
|
|
1046
|
-
*
|
|
1047
|
-
* The above copyright notice and this permission notice shall be included in
|
|
1048
|
-
* all copies or substantial portions of the Software.
|
|
1049
|
-
*
|
|
1050
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1051
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1052
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1053
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1054
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1055
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1056
|
-
* THE SOFTWARE.
|
|
1057
|
-
*/
|
|
1058
|
-
/** Vanilla JS implementation of slider component. */
|
|
1059
|
-
var MDCSlider = /** @class */ (function (_super) {
|
|
1060
|
-
ponyfill.__extends(MDCSlider, _super);
|
|
1061
|
-
function MDCSlider() {
|
|
1062
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1063
|
-
_this.skipInitialUIUpdate = false;
|
|
1064
|
-
// Function that maps a slider value to the value of the `aria-valuetext`
|
|
1065
|
-
// attribute on the thumb element.
|
|
1066
|
-
_this.valueToAriaValueTextFn = null;
|
|
1067
|
-
return _this;
|
|
1068
|
-
}
|
|
1069
|
-
MDCSlider.attachTo = function (root, options) {
|
|
1070
|
-
if (options === void 0) { options = {}; }
|
|
1071
|
-
return new MDCSlider(root, undefined, options);
|
|
1072
|
-
};
|
|
1073
|
-
MDCSlider.prototype.getDefaultFoundation = function () {
|
|
1074
|
-
var _this = this;
|
|
1075
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same
|
|
1076
|
-
// order as the adapter interface.
|
|
1077
|
-
var adapter = {
|
|
1078
|
-
hasClass: function (className) { return _this.root.classList.contains(className); },
|
|
1079
|
-
addClass: function (className) {
|
|
1080
|
-
_this.root.classList.add(className);
|
|
1081
|
-
},
|
|
1082
|
-
removeClass: function (className) {
|
|
1083
|
-
_this.root.classList.remove(className);
|
|
1084
|
-
},
|
|
1085
|
-
addThumbClass: function (className, thumb) {
|
|
1086
|
-
_this.getThumbEl(thumb).classList.add(className);
|
|
1087
|
-
},
|
|
1088
|
-
removeThumbClass: function (className, thumb) {
|
|
1089
|
-
_this.getThumbEl(thumb).classList.remove(className);
|
|
1090
|
-
},
|
|
1091
|
-
getAttribute: function (attribute) { return _this.root.getAttribute(attribute); },
|
|
1092
|
-
getInputValue: function (thumb) { return _this.getInput(thumb).value; },
|
|
1093
|
-
setInputValue: function (value, thumb) {
|
|
1094
|
-
_this.getInput(thumb).value = value;
|
|
1095
|
-
},
|
|
1096
|
-
getInputAttribute: function (attribute, thumb) {
|
|
1097
|
-
return _this.getInput(thumb).getAttribute(attribute);
|
|
1098
|
-
},
|
|
1099
|
-
setInputAttribute: function (attribute, value, thumb) {
|
|
1100
|
-
_this.getInput(thumb).setAttribute(attribute, value);
|
|
1101
|
-
},
|
|
1102
|
-
removeInputAttribute: function (attribute, thumb) {
|
|
1103
|
-
_this.getInput(thumb).removeAttribute(attribute);
|
|
1104
|
-
},
|
|
1105
|
-
focusInput: function (thumb) {
|
|
1106
|
-
_this.getInput(thumb).focus();
|
|
1107
|
-
},
|
|
1108
|
-
isInputFocused: function (thumb) {
|
|
1109
|
-
return _this.getInput(thumb) === document.activeElement;
|
|
1110
|
-
},
|
|
1111
|
-
getThumbKnobWidth: function (thumb) {
|
|
1112
|
-
return _this.getThumbEl(thumb)
|
|
1113
|
-
.querySelector("." + cssClasses.THUMB_KNOB)
|
|
1114
|
-
.getBoundingClientRect()
|
|
1115
|
-
.width;
|
|
1116
|
-
},
|
|
1117
|
-
getThumbBoundingClientRect: function (thumb) {
|
|
1118
|
-
return _this.getThumbEl(thumb).getBoundingClientRect();
|
|
1119
|
-
},
|
|
1120
|
-
getBoundingClientRect: function () { return _this.root.getBoundingClientRect(); },
|
|
1121
|
-
isRTL: function () { return getComputedStyle(_this.root).direction === 'rtl'; },
|
|
1122
|
-
setThumbStyleProperty: function (propertyName, value, thumb) {
|
|
1123
|
-
_this.getThumbEl(thumb).style.setProperty(propertyName, value);
|
|
1124
|
-
},
|
|
1125
|
-
removeThumbStyleProperty: function (propertyName, thumb) {
|
|
1126
|
-
_this.getThumbEl(thumb).style.removeProperty(propertyName);
|
|
1127
|
-
},
|
|
1128
|
-
setTrackActiveStyleProperty: function (propertyName, value) {
|
|
1129
|
-
_this.trackActive.style.setProperty(propertyName, value);
|
|
1130
|
-
},
|
|
1131
|
-
removeTrackActiveStyleProperty: function (propertyName) {
|
|
1132
|
-
_this.trackActive.style.removeProperty(propertyName);
|
|
1133
|
-
},
|
|
1134
|
-
setValueIndicatorText: function (value, thumb) {
|
|
1135
|
-
var valueIndicatorEl = _this.getThumbEl(thumb).querySelector("." + cssClasses.VALUE_INDICATOR_TEXT);
|
|
1136
|
-
valueIndicatorEl.textContent = String(value);
|
|
1137
|
-
},
|
|
1138
|
-
getValueToAriaValueTextFn: function () { return _this.valueToAriaValueTextFn; },
|
|
1139
|
-
updateTickMarks: function (tickMarks) {
|
|
1140
|
-
var tickMarksContainer = _this.root.querySelector("." + cssClasses.TICK_MARKS_CONTAINER);
|
|
1141
|
-
if (!tickMarksContainer) {
|
|
1142
|
-
tickMarksContainer = document.createElement('div');
|
|
1143
|
-
tickMarksContainer.classList.add(cssClasses.TICK_MARKS_CONTAINER);
|
|
1144
|
-
var track = _this.root.querySelector("." + cssClasses.TRACK);
|
|
1145
|
-
track.appendChild(tickMarksContainer);
|
|
1146
|
-
}
|
|
1147
|
-
if (tickMarks.length !== tickMarksContainer.children.length) {
|
|
1148
|
-
while (tickMarksContainer.firstChild) {
|
|
1149
|
-
tickMarksContainer.removeChild(tickMarksContainer.firstChild);
|
|
1150
|
-
}
|
|
1151
|
-
_this.addTickMarks(tickMarksContainer, tickMarks);
|
|
1152
|
-
}
|
|
1153
|
-
else {
|
|
1154
|
-
_this.updateTickMarks(tickMarksContainer, tickMarks);
|
|
1155
|
-
}
|
|
1156
|
-
},
|
|
1157
|
-
setPointerCapture: function (pointerId) {
|
|
1158
|
-
_this.root.setPointerCapture(pointerId);
|
|
1159
|
-
},
|
|
1160
|
-
emitChangeEvent: function (value, thumb) {
|
|
1161
|
-
_this.emit(events.CHANGE, { value: value, thumb: thumb });
|
|
1162
|
-
},
|
|
1163
|
-
emitInputEvent: function (value, thumb) {
|
|
1164
|
-
_this.emit(events.INPUT, { value: value, thumb: thumb });
|
|
1165
|
-
},
|
|
1166
|
-
emitDragStartEvent: function (_, thumb) {
|
|
1167
|
-
// Emitting event is not yet implemented. See issue:
|
|
1168
|
-
// https://github.com/material-components/material-components-web/issues/6448
|
|
1169
|
-
_this.getRipple(thumb).activate();
|
|
1170
|
-
},
|
|
1171
|
-
emitDragEndEvent: function (_, thumb) {
|
|
1172
|
-
// Emitting event is not yet implemented. See issue:
|
|
1173
|
-
// https://github.com/material-components/material-components-web/issues/6448
|
|
1174
|
-
_this.getRipple(thumb).deactivate();
|
|
1175
|
-
},
|
|
1176
|
-
registerEventHandler: function (evtType, handler) {
|
|
1177
|
-
_this.listen(evtType, handler);
|
|
1178
|
-
},
|
|
1179
|
-
deregisterEventHandler: function (evtType, handler) {
|
|
1180
|
-
_this.unlisten(evtType, handler);
|
|
1181
|
-
},
|
|
1182
|
-
registerThumbEventHandler: function (thumb, evtType, handler) {
|
|
1183
|
-
_this.getThumbEl(thumb).addEventListener(evtType, handler);
|
|
1184
|
-
},
|
|
1185
|
-
deregisterThumbEventHandler: function (thumb, evtType, handler) {
|
|
1186
|
-
_this.getThumbEl(thumb).removeEventListener(evtType, handler);
|
|
1187
|
-
},
|
|
1188
|
-
registerInputEventHandler: function (thumb, evtType, handler) {
|
|
1189
|
-
_this.getInput(thumb).addEventListener(evtType, handler);
|
|
1190
|
-
},
|
|
1191
|
-
deregisterInputEventHandler: function (thumb, evtType, handler) {
|
|
1192
|
-
_this.getInput(thumb).removeEventListener(evtType, handler);
|
|
1193
|
-
},
|
|
1194
|
-
registerBodyEventHandler: function (evtType, handler) {
|
|
1195
|
-
document.body.addEventListener(evtType, handler);
|
|
1196
|
-
},
|
|
1197
|
-
deregisterBodyEventHandler: function (evtType, handler) {
|
|
1198
|
-
document.body.removeEventListener(evtType, handler);
|
|
1199
|
-
},
|
|
1200
|
-
registerWindowEventHandler: function (evtType, handler) {
|
|
1201
|
-
window.addEventListener(evtType, handler);
|
|
1202
|
-
},
|
|
1203
|
-
deregisterWindowEventHandler: function (evtType, handler) {
|
|
1204
|
-
window.removeEventListener(evtType, handler);
|
|
1205
|
-
},
|
|
1206
|
-
// tslint:enable:object-literal-sort-keys
|
|
1207
|
-
};
|
|
1208
|
-
return new MDCSliderFoundation(adapter);
|
|
1209
|
-
};
|
|
1210
|
-
/**
|
|
1211
|
-
* Initializes component, with the following options:
|
|
1212
|
-
* - `skipInitialUIUpdate`: Whether to skip updating the UI when initially
|
|
1213
|
-
* syncing with the DOM. This should be enabled when the slider position
|
|
1214
|
-
* is set before component initialization.
|
|
1215
|
-
*/
|
|
1216
|
-
MDCSlider.prototype.initialize = function (_a) {
|
|
1217
|
-
var _b = _a === void 0 ? {} : _a, skipInitialUIUpdate = _b.skipInitialUIUpdate;
|
|
1218
|
-
this.inputs =
|
|
1219
|
-
[].slice.call(this.root.querySelectorAll("." + cssClasses.INPUT));
|
|
1220
|
-
this.thumbs =
|
|
1221
|
-
[].slice.call(this.root.querySelectorAll("." + cssClasses.THUMB));
|
|
1222
|
-
this.trackActive =
|
|
1223
|
-
this.root.querySelector("." + cssClasses.TRACK_ACTIVE);
|
|
1224
|
-
this.ripples = this.createRipples();
|
|
1225
|
-
if (skipInitialUIUpdate) {
|
|
1226
|
-
this.skipInitialUIUpdate = true;
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
MDCSlider.prototype.initialSyncWithDOM = function () {
|
|
1230
|
-
this.foundation.layout({ skipUpdateUI: this.skipInitialUIUpdate });
|
|
1231
|
-
};
|
|
1232
|
-
/** Redraws UI based on DOM (e.g. element dimensions, RTL). */
|
|
1233
|
-
MDCSlider.prototype.layout = function () {
|
|
1234
|
-
this.foundation.layout();
|
|
1235
|
-
};
|
|
1236
|
-
MDCSlider.prototype.getValueStart = function () {
|
|
1237
|
-
return this.foundation.getValueStart();
|
|
1238
|
-
};
|
|
1239
|
-
MDCSlider.prototype.setValueStart = function (valueStart) {
|
|
1240
|
-
this.foundation.setValueStart(valueStart);
|
|
1241
|
-
};
|
|
1242
|
-
MDCSlider.prototype.getValue = function () {
|
|
1243
|
-
return this.foundation.getValue();
|
|
1244
|
-
};
|
|
1245
|
-
MDCSlider.prototype.setValue = function (value) {
|
|
1246
|
-
this.foundation.setValue(value);
|
|
1247
|
-
};
|
|
1248
|
-
/** @return Slider disabled state. */
|
|
1249
|
-
MDCSlider.prototype.getDisabled = function () {
|
|
1250
|
-
return this.foundation.getDisabled();
|
|
1251
|
-
};
|
|
1252
|
-
/** Sets slider disabled state. */
|
|
1253
|
-
MDCSlider.prototype.setDisabled = function (disabled) {
|
|
1254
|
-
this.foundation.setDisabled(disabled);
|
|
1255
|
-
};
|
|
1256
|
-
/**
|
|
1257
|
-
* Sets a function that maps the slider value to the value of the
|
|
1258
|
-
* `aria-valuetext` attribute on the thumb element.
|
|
1259
|
-
*/
|
|
1260
|
-
MDCSlider.prototype.setValueToAriaValueTextFn = function (mapFn) {
|
|
1261
|
-
this.valueToAriaValueTextFn = mapFn;
|
|
1262
|
-
};
|
|
1263
|
-
MDCSlider.prototype.getThumbEl = function (thumb) {
|
|
1264
|
-
return thumb === Thumb.END ? this.thumbs[this.thumbs.length - 1] :
|
|
1265
|
-
this.thumbs[0];
|
|
1266
|
-
};
|
|
1267
|
-
MDCSlider.prototype.getInput = function (thumb) {
|
|
1268
|
-
return thumb === Thumb.END ? this.inputs[this.inputs.length - 1] :
|
|
1269
|
-
this.inputs[0];
|
|
1270
|
-
};
|
|
1271
|
-
MDCSlider.prototype.getRipple = function (thumb) {
|
|
1272
|
-
return thumb === Thumb.END ? this.ripples[this.ripples.length - 1] :
|
|
1273
|
-
this.ripples[0];
|
|
1274
|
-
};
|
|
1275
|
-
/** Adds tick mark elements to the given container. */
|
|
1276
|
-
MDCSlider.prototype.addTickMarks = function (tickMarkContainer, tickMarks) {
|
|
1277
|
-
var fragment = document.createDocumentFragment();
|
|
1278
|
-
for (var i = 0; i < tickMarks.length; i++) {
|
|
1279
|
-
var div = document.createElement('div');
|
|
1280
|
-
var tickMarkClass = tickMarks[i] === TickMark.ACTIVE ?
|
|
1281
|
-
cssClasses.TICK_MARK_ACTIVE :
|
|
1282
|
-
cssClasses.TICK_MARK_INACTIVE;
|
|
1283
|
-
div.classList.add(tickMarkClass);
|
|
1284
|
-
fragment.appendChild(div);
|
|
1285
|
-
}
|
|
1286
|
-
tickMarkContainer.appendChild(fragment);
|
|
1287
|
-
};
|
|
1288
|
-
/** Updates tick mark elements' classes in the given container. */
|
|
1289
|
-
MDCSlider.prototype.updateTickMarks = function (tickMarkContainer, tickMarks) {
|
|
1290
|
-
var tickMarkEls = Array.from(tickMarkContainer.children);
|
|
1291
|
-
for (var i = 0; i < tickMarkEls.length; i++) {
|
|
1292
|
-
if (tickMarks[i] === TickMark.ACTIVE) {
|
|
1293
|
-
tickMarkEls[i].classList.add(cssClasses.TICK_MARK_ACTIVE);
|
|
1294
|
-
tickMarkEls[i].classList.remove(cssClasses.TICK_MARK_INACTIVE);
|
|
1295
|
-
}
|
|
1296
|
-
else {
|
|
1297
|
-
tickMarkEls[i].classList.add(cssClasses.TICK_MARK_INACTIVE);
|
|
1298
|
-
tickMarkEls[i].classList.remove(cssClasses.TICK_MARK_ACTIVE);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
};
|
|
1302
|
-
/** Initializes thumb ripples. */
|
|
1303
|
-
MDCSlider.prototype.createRipples = function () {
|
|
1304
|
-
var ripples = [];
|
|
1305
|
-
var rippleSurfaces = [].slice.call(this.root.querySelectorAll("." + cssClasses.THUMB));
|
|
1306
|
-
var _loop_1 = function (i) {
|
|
1307
|
-
var rippleSurface = rippleSurfaces[i];
|
|
1308
|
-
// Use the corresponding input as the focus source for the ripple (i.e.
|
|
1309
|
-
// when the input is focused, the ripple is in the focused state).
|
|
1310
|
-
var input = this_1.inputs[i];
|
|
1311
|
-
var adapter = ponyfill.__assign(ponyfill.__assign({}, component.MDCRipple.createAdapter(this_1)), { addClass: function (className) {
|
|
1312
|
-
rippleSurface.classList.add(className);
|
|
1313
|
-
}, computeBoundingRect: function () { return rippleSurface.getBoundingClientRect(); }, deregisterInteractionHandler: function (evtType, handler) {
|
|
1314
|
-
input.removeEventListener(evtType, handler);
|
|
1315
|
-
}, isSurfaceActive: function () { return ponyfill.matches(input, ':active'); }, isUnbounded: function () { return true; }, registerInteractionHandler: function (evtType, handler) {
|
|
1316
|
-
input.addEventListener(evtType, handler, component.applyPassive());
|
|
1317
|
-
}, removeClass: function (className) {
|
|
1318
|
-
rippleSurface.classList.remove(className);
|
|
1319
|
-
}, updateCssVariable: function (varName, value) {
|
|
1320
|
-
rippleSurface.style.setProperty(varName, value);
|
|
1321
|
-
} });
|
|
1322
|
-
var ripple = new component.MDCRipple(rippleSurface, new component.MDCRippleFoundation(adapter));
|
|
1323
|
-
ripple.unbounded = true;
|
|
1324
|
-
ripples.push(ripple);
|
|
1325
|
-
};
|
|
1326
|
-
var this_1 = this;
|
|
1327
|
-
for (var i = 0; i < rippleSurfaces.length; i++) {
|
|
1328
|
-
_loop_1(i);
|
|
1329
|
-
}
|
|
1330
|
-
return ripples;
|
|
1331
|
-
};
|
|
1332
|
-
return MDCSlider;
|
|
1333
|
-
}(ponyfill.MDCComponent));
|
|
1334
5
|
|
|
1335
6
|
/**
|
|
1336
7
|
*
|
|
@@ -1379,11 +50,12 @@ function getPercentageClass(value) {
|
|
|
1379
50
|
return 'percent-90-100';
|
|
1380
51
|
}
|
|
1381
52
|
|
|
1382
|
-
const sliderCss = () => `@charset "UTF-8";.mdc-slider__track--active_fill,.mdc-slider__track--inactive,.mdc-slider__thumb-knob{transition:background-color 0.5s ease}:host(.displays-percentage-colors[readonly]){--mdc-theme-on-surface:var(--lime-primary-color)}:host(.displays-percentage-colors.percent-0){--lime-primary-color:var(--color-percent--0)}:host(.displays-percentage-colors.percent-0-10){--lime-primary-color:var(--color-percent--0to10)}:host(.displays-percentage-colors.percent-10-20){--lime-primary-color:var(--color-percent--10to20)}:host(.displays-percentage-colors.percent-20-30){--lime-primary-color:var(--color-percent--20to30)}:host(.displays-percentage-colors.percent-30-40){--lime-primary-color:var(--color-percent--30to40)}:host(.displays-percentage-colors.percent-40-50){--lime-primary-color:var(--color-percent--40to50)}:host(.displays-percentage-colors.percent-50-60){--lime-primary-color:var(--color-percent--50to60)}:host(.displays-percentage-colors.percent-60-70){--lime-primary-color:var(--color-percent--60to70)}:host(.displays-percentage-colors.percent-70-80){--lime-primary-color:var(--color-percent--70to80)}:host(.displays-percentage-colors.percent-80-90){--lime-primary-color:var(--color-percent--80to90)}:host(.displays-percentage-colors.percent-90-100){--lime-primary-color:var(--color-percent--90to100)}:host(.displays-percentage-colors.percent-30-40) .mdc-slider__value-indicator-text,:host(.displays-percentage-colors.percent-40-50) .mdc-slider__value-indicator-text,:host(.displays-percentage-colors.percent-70-80) .mdc-slider__value-indicator-text{color:rgb(var(--color-gray-darker))}:host(.displays-percentage-colors.percent-30-40) .mdc-slider--disabled .mdc-slider__value-indicator-text,:host(.displays-percentage-colors.percent-40-50) .mdc-slider--disabled .mdc-slider__value-indicator-text,:host(.displays-percentage-colors.percent-70-80) .mdc-slider--disabled .mdc-slider__value-indicator-text{color:rgb(var(--contrast-100))}:host(.displays-percentage-colors.percent-50-60) .mdc-slider__value-indicator-text,:host(.displays-percentage-colors.percent-60-70) .mdc-slider__value-indicator-text{color:rgb(var(--color-gray-dark))}:host(.displays-percentage-colors.percent-50-60) .mdc-slider--disabled .mdc-slider__value-indicator-text,:host(.displays-percentage-colors.percent-60-70) .mdc-slider--disabled .mdc-slider__value-indicator-text{color:rgb(var(--contrast-100))}:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled{opacity:1}:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__track,:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__track--active,:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__track--inactive,:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__value-indicator{height:1rem;border-radius:1rem}:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__track--active{top:0}:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__value-indicator{transition:all 0s;transform:translateY(1.75rem)}:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__thumb-knob{opacity:0}:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__track--active_fill,:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__thumb-knob{background-color:var(--lime-primary-color, var(--limel-theme-primary-color))}:host(limel-slider.readonly) .mdc-slider.mdc-slider--disabled .mdc-slider__track--active_fill{border-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.mdc-slider:not(.mdc-slider--disabled) .mdc-slider__thumb-knob:before,.mdc-slider:not(.mdc-slider--disabled) .mdc-slider__thumb-knob:after{transition:all 0.2s ease 0.2s;content:"";display:block;position:absolute;top:0;bottom:0;margin:auto;opacity:0;width:0;height:0;border:0.25rem solid transparent;border-top-color:rgba(var(--contrast-1400), 0.6)}.mdc-slider:not(.mdc-slider--disabled) .mdc-slider__thumb-knob:before{left:-1.25rem;transform:rotate(90deg)}.mdc-slider:not(.mdc-slider--disabled) .mdc-slider__thumb-knob:after{right:-1.25rem;transform:rotate(-90deg)}.mdc-slider:not(.mdc-slider--disabled) .mdc-slider__thumb-knob:hover:before{opacity:0.8;left:-1.75rem}.mdc-slider:not(.mdc-slider--disabled) .mdc-slider__thumb-knob:hover:after{opacity:0.8;right:-1.75rem}.mdc-slider .mdc-slider__thumb{top:-0.25rem}.mdc-slider .mdc-slider__value-indicator-container{z-index:1}.mdc-slider .mdc-slider__value-indicator{transition:transform 0.2s ease-out;opacity:1;transform:scale(1) translateY(2rem);border-radius:1.25rem;padding:0 0.5rem;height:1.5rem}.mdc-slider .mdc-slider__value-indicator:before{border-top-color:transparent}.mdc-slider .mdc-slider__value-indicator-text{color:rgb(var(--color-white))}.mdc-slider .mdc-ripple-upgraded--foreground-activation .mdc-slider__value-indicator{transform:scale(1.5) translateY(0);box-shadow:var(--shadow-depth-16)}.mdc-slider .mdc-ripple-upgraded--foreground-activation .mdc-slider__value-indicator:before{border-top-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.mdc-slider:not(.mdc-slider--disabled) .mdc-slider__value-indicator{box-shadow:var(--button-shadow-normal)}.mdc-slider:not(.mdc-slider--disabled) .mdc-slider__value-indicator,:host(limel-slider[readonly]) .mdc-slider__value-indicator{background-color:var(--lime-primary-color, var(--limel-theme-primary-color))}:host(limel-slider:focus),:host(limel-slider:focus-visible),:host(limel-slider:focus-within){--limel-h-l-grid-template-rows-transition-speed:0.46s;--limel-h-l-grid-template-rows:1fr}:host(limel-slider){--limel-h-l-grid-template-rows-transition-speed:0.3s;--limel-h-l-grid-template-rows:0fr}:host(limel-slider:focus) limel-helper-line,:host(limel-slider:focus-visible) limel-helper-line,:host(limel-slider:focus-within) limel-helper-line,:host(limel-slider:hover) limel-helper-line{will-change:grid-template-rows}limel-helper-line{order:3}@keyframes mdc-ripple-fg-radius-in{from{animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1)}to{transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}}@keyframes mdc-ripple-fg-opacity-in{from{animation-timing-function:linear;opacity:0}to{opacity:var(--mdc-ripple-fg-opacity, 0)}}@keyframes mdc-ripple-fg-opacity-out{from{animation-timing-function:linear;opacity:var(--mdc-ripple-fg-opacity, 0)}to{opacity:0}}.mdc-slider__thumb{--mdc-ripple-fg-size:0;--mdc-ripple-left:0;--mdc-ripple-top:0;--mdc-ripple-fg-scale:1;--mdc-ripple-fg-translate-end:0;--mdc-ripple-fg-translate-start:0;-webkit-tap-highlight-color:rgba(0, 0, 0, 0);will-change:transform, opacity}.mdc-slider__thumb::before,.mdc-slider__thumb::after{position:absolute;border-radius:50%;opacity:0;pointer-events:none;content:""}.mdc-slider__thumb::before{transition:opacity 15ms linear, background-color 15ms linear;z-index:1;z-index:var(--mdc-ripple-z-index, 1)}.mdc-slider__thumb::after{z-index:0;z-index:var(--mdc-ripple-z-index, 0)}.mdc-slider__thumb.mdc-ripple-upgraded::before{transform:scale(var(--mdc-ripple-fg-scale, 1))}.mdc-slider__thumb.mdc-ripple-upgraded::after{top:0;left:0;transform:scale(0);transform-origin:center center}.mdc-slider__thumb.mdc-ripple-upgraded--unbounded::after{top:var(--mdc-ripple-top, 0);left:var(--mdc-ripple-left, 0)}.mdc-slider__thumb.mdc-ripple-upgraded--foreground-activation::after{animation:mdc-ripple-fg-radius-in 225ms forwards, mdc-ripple-fg-opacity-in 75ms forwards}.mdc-slider__thumb.mdc-ripple-upgraded--foreground-deactivation::after{animation:mdc-ripple-fg-opacity-out 150ms;transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}.mdc-slider__thumb::before,.mdc-slider__thumb::after{top:calc(50% - 50%);left:calc(50% - 50%);width:100%;height:100%}.mdc-slider__thumb.mdc-ripple-upgraded::before,.mdc-slider__thumb.mdc-ripple-upgraded::after{top:var(--mdc-ripple-top, calc(50% - 50%));left:var(--mdc-ripple-left, calc(50% - 50%));width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-slider__thumb.mdc-ripple-upgraded::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-slider__thumb::before,.mdc-slider__thumb::after{background-color:#6200ee;background-color:var(--mdc-ripple-color, var(--mdc-theme-primary, #6200ee))}.mdc-slider__thumb:hover::before,.mdc-slider__thumb.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-slider__thumb.mdc-ripple-upgraded--background-focused::before,.mdc-slider__thumb:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-slider__thumb:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-slider__thumb:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-slider__thumb.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-slider .mdc-slider__track{height:4px;position:absolute;top:50%;transform:translateY(-50%);width:100%}.mdc-slider .mdc-slider__track--active,.mdc-slider .mdc-slider__track--inactive{display:flex;height:100%;position:absolute;width:100%}.mdc-slider .mdc-slider__track--active{border-radius:3px;height:6px;overflow:hidden;top:-1px}.mdc-slider .mdc-slider__track--active_fill{border-top:6px solid;box-sizing:border-box;height:100%;width:100%;position:relative;-webkit-transform-origin:left;transform-origin:left}[dir=rtl] .mdc-slider .mdc-slider__track--active_fill,.mdc-slider .mdc-slider__track--active_fill[dir=rtl]{-webkit-transform-origin:right;transform-origin:right;}.mdc-slider .mdc-slider__track--inactive::before{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid transparent;border-radius:inherit;content:"";pointer-events:none}.mdc-slider .mdc-slider__track--inactive{border-radius:2px;height:4px;left:0;top:0}.mdc-slider .mdc-slider__track--active_fill{border-color:#6200ee;border-color:var(--mdc-theme-primary, #6200ee)}.mdc-slider.mdc-slider--disabled .mdc-slider__track--active_fill{border-color:#000;border-color:var(--mdc-theme-on-surface, #000)}.mdc-slider .mdc-slider__track--inactive{background-color:#6200ee;background-color:var(--mdc-theme-primary, #6200ee);opacity:0.24}.mdc-slider.mdc-slider--disabled .mdc-slider__track--inactive{background-color:#000;background-color:var(--mdc-theme-on-surface, #000);opacity:0.24}.mdc-slider .mdc-slider__value-indicator-container{bottom:44px;left:50%;pointer-events:none;position:absolute;transform:translateX(-50%)}.mdc-slider .mdc-slider__value-indicator{transition:transform 100ms 0ms cubic-bezier(0.4, 0, 1, 1);align-items:center;border-radius:4px;display:flex;height:32px;padding:0 12px;transform:scale(0);transform-origin:bottom}.mdc-slider .mdc-slider__value-indicator::before{border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid;bottom:-5px;content:"";height:0;left:50%;position:absolute;transform:translateX(-50%);width:0}.mdc-slider .mdc-slider__value-indicator::after{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid transparent;border-radius:inherit;content:"";pointer-events:none}.mdc-slider .mdc-slider__thumb--with-indicator .mdc-slider__value-indicator-container{pointer-events:auto}.mdc-slider .mdc-slider__thumb--with-indicator .mdc-slider__value-indicator{transition:transform 100ms 0ms cubic-bezier(0, 0, 0.2, 1);transform:scale(1)}@media (prefers-reduced-motion){.mdc-slider .mdc-slider__value-indicator,.mdc-slider .mdc-slider__thumb--with-indicator .mdc-slider__value-indicator{transition:none}}.mdc-slider .mdc-slider__value-indicator-text{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:Roboto, sans-serif;font-family:var(--mdc-typography-subtitle2-font-family, var(--mdc-typography-font-family, Roboto, sans-serif));font-size:0.875rem;font-size:var(--mdc-typography-subtitle2-font-size, 0.875rem);line-height:1.375rem;line-height:var(--mdc-typography-subtitle2-line-height, 1.375rem);font-weight:500;font-weight:var(--mdc-typography-subtitle2-font-weight, 500);letter-spacing:0.0071428571em;letter-spacing:var(--mdc-typography-subtitle2-letter-spacing, 0.0071428571em);text-decoration:inherit;text-decoration:var(--mdc-typography-subtitle2-text-decoration, inherit);text-transform:inherit;text-transform:var(--mdc-typography-subtitle2-text-transform, inherit)}.mdc-slider .mdc-slider__value-indicator{background-color:#000;opacity:0.6}.mdc-slider .mdc-slider__value-indicator::before{border-top-color:#000}.mdc-slider .mdc-slider__value-indicator{color:#fff;color:var(--mdc-theme-on-primary, #fff)}.mdc-slider .mdc-slider__thumb{display:flex;height:48px;left:-24px;outline:none;position:absolute;user-select:none;width:48px}.mdc-slider .mdc-slider__thumb--top{z-index:1}.mdc-slider .mdc-slider__thumb--top .mdc-slider__thumb-knob,.mdc-slider .mdc-slider__thumb--top.mdc-slider__thumb:hover .mdc-slider__thumb-knob,.mdc-slider .mdc-slider__thumb--top.mdc-slider__thumb--focused .mdc-slider__thumb-knob{border-style:solid;border-width:1px;box-sizing:content-box}.mdc-slider .mdc-slider__thumb-knob{box-shadow:0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);border:10px solid;border-radius:50%;box-sizing:border-box;height:20px;left:50%;position:absolute;top:50%;transform:translate(-50%, -50%);width:20px}.mdc-slider .mdc-slider__thumb-knob{background-color:#6200ee;background-color:var(--mdc-theme-primary, #6200ee);border-color:#6200ee;border-color:var(--mdc-theme-primary, #6200ee)}.mdc-slider .mdc-slider__thumb--top .mdc-slider__thumb-knob,.mdc-slider .mdc-slider__thumb--top.mdc-slider__thumb:hover .mdc-slider__thumb-knob,.mdc-slider .mdc-slider__thumb--top.mdc-slider__thumb--focused .mdc-slider__thumb-knob{border-color:#fff}.mdc-slider.mdc-slider--disabled .mdc-slider__thumb-knob{background-color:#000;background-color:var(--mdc-theme-on-surface, #000);border-color:#000;border-color:var(--mdc-theme-on-surface, #000)}.mdc-slider.mdc-slider--disabled .mdc-slider__thumb--top .mdc-slider__thumb-knob,.mdc-slider.mdc-slider--disabled .mdc-slider__thumb--top.mdc-slider__thumb:hover .mdc-slider__thumb-knob,.mdc-slider.mdc-slider--disabled .mdc-slider__thumb--top.mdc-slider__thumb--focused .mdc-slider__thumb-knob{border-color:#fff}.mdc-slider .mdc-slider__thumb::before,.mdc-slider .mdc-slider__thumb::after{background-color:#6200ee;background-color:var(--mdc-ripple-color, var(--mdc-theme-primary, #6200ee))}.mdc-slider .mdc-slider__thumb:hover::before,.mdc-slider .mdc-slider__thumb.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-slider .mdc-slider__thumb.mdc-ripple-upgraded--background-focused::before,.mdc-slider .mdc-slider__thumb:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-slider .mdc-slider__thumb:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-slider .mdc-slider__thumb:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-slider .mdc-slider__thumb.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-slider .mdc-slider__tick-marks{align-items:center;box-sizing:border-box;display:flex;height:100%;justify-content:space-between;padding:0 1px;position:absolute;width:100%}.mdc-slider .mdc-slider__tick-mark--active,.mdc-slider .mdc-slider__tick-mark--inactive{border-radius:50%;height:2px;width:2px}.mdc-slider .mdc-slider__tick-mark--active{background-color:#fff;background-color:var(--mdc-theme-on-primary, #fff);opacity:0.6}.mdc-slider.mdc-slider--disabled .mdc-slider__tick-mark--active{background-color:#fff;background-color:var(--mdc-theme-on-primary, #fff);opacity:0.6}.mdc-slider .mdc-slider__tick-mark--inactive{background-color:#6200ee;background-color:var(--mdc-theme-primary, #6200ee);opacity:0.6}.mdc-slider.mdc-slider--disabled .mdc-slider__tick-mark--inactive{background-color:#000;background-color:var(--mdc-theme-on-surface, #000);opacity:0.6}.mdc-slider{cursor:pointer;height:48px;margin:0 24px;position:relative;touch-action:pan-y}.mdc-slider.mdc-slider--disabled{opacity:0.38;cursor:auto}.mdc-slider.mdc-slider--disabled .mdc-slider__thumb{pointer-events:none}.mdc-slider--discrete .mdc-slider__thumb,.mdc-slider--discrete .mdc-slider__track--active_fill{transition:transform 80ms ease}@media (prefers-reduced-motion){.mdc-slider--discrete .mdc-slider__thumb,.mdc-slider--discrete .mdc-slider__track--active_fill{transition:none}}.mdc-slider__input{cursor:pointer;left:0;margin:0;height:100%;opacity:0;pointer-events:none;position:absolute;top:0;width:100%}:host(limel-slider){isolation:isolate;position:relative;display:flex;flex-direction:column}:host(limel-slider:not([invalid]):not([invalid=true])) .limel-notched-outline,:host(limel-slider[disabled]:not([disabled=false])) .limel-notched-outline{--limel-notched-outline-border-color:transparent;--limel-notched-outline-background-color:transparent}div[slot=content]{display:flex;flex-direction:column;width:100%;padding:0 0.25rem}.mdc-slider{height:2.5rem;margin:0 0.75rem}.mdc-slider .mdc-slider__track--inactive{background-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.mdc-slider .mdc-slider__track--active_fill{border-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.mdc-slider .mdc-slider__thumb-knob{border-color:var(--lime-primary-color, var(--limel-theme-primary-color));background-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.mdc-slider .mdc-slider__value-indicator-text{font-size:var(--limel-theme-default-small-font-size)}.mdc-slider .mdc-slider__value-indicator-text{font-family:inherit}.slider__content-range-container{display:flex;order:2;justify-content:space-between;margin:0 auto;margin-top:-0.75rem;width:100%}.slider__content-min-label,.slider__content-max-label{line-height:1;transition:opacity 0.2s ease;opacity:0.7;font-size:0.75rem;color:rgba(var(--contrast-1200), 1)}.mdc-slider__track:before,.mdc-slider__track:after{content:"";display:inline-block;position:absolute;top:0;bottom:0;margin:auto;width:0.375rem;height:0.375rem;border-radius:50%;background-color:rgba(var(--contrast-700), 0.6)}.mdc-slider__track:before{left:-0.75rem}.mdc-slider__track:after{right:-0.75rem}`;
|
|
53
|
+
const sliderCss = () => `@charset "UTF-8";:host([displays-percentage-colors].percent-0){--lime-primary-color:var(--color-percent--0)}:host([displays-percentage-colors].percent-0-10){--lime-primary-color:var(--color-percent--0to10)}:host([displays-percentage-colors].percent-10-20){--lime-primary-color:var(--color-percent--10to20)}:host([displays-percentage-colors].percent-20-30){--lime-primary-color:var(--color-percent--20to30)}:host([displays-percentage-colors].percent-30-40){--lime-primary-color:var(--color-percent--30to40)}:host([displays-percentage-colors].percent-40-50){--lime-primary-color:var(--color-percent--40to50)}:host([displays-percentage-colors].percent-50-60){--lime-primary-color:var(--color-percent--50to60)}:host([displays-percentage-colors].percent-60-70){--lime-primary-color:var(--color-percent--60to70)}:host([displays-percentage-colors].percent-70-80){--lime-primary-color:var(--color-percent--70to80)}:host([displays-percentage-colors].percent-80-90){--lime-primary-color:var(--color-percent--80to90)}:host([displays-percentage-colors].percent-90-100){--lime-primary-color:var(--color-percent--90to100)}:host([displays-percentage-colors].percent-30-40) .indicator,:host([displays-percentage-colors].percent-40-50) .indicator,:host([displays-percentage-colors].percent-70-80) .indicator{color:rgb(var(--color-gray-darker))}:host([displays-percentage-colors].percent-50-60) .indicator,:host([displays-percentage-colors].percent-60-70) .indicator{color:rgb(var(--color-gray-dark))}:host([readonly]:not([readonly=false])) input[type=range]{cursor:default}:host([readonly]:not([readonly=false])) .track,:host([readonly]:not([readonly=false])) .active,:host([readonly]:not([readonly=false])) .indicator{height:0.75rem}:host([readonly]:not([readonly=false])) .indicator{box-shadow:none}:host([readonly]:not([readonly=false])) .knob{opacity:0}:host([readonly]:not([readonly=false])) .active{background-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.thumb{position:absolute;left:calc(var(--slider-fraction) * 100%);top:0;bottom:0;width:0;z-index:1}.knob{transition:border-color 0.5s ease;position:absolute;top:50%;left:0;transform:translate3d(-50%, -50%, 0);width:1.25rem;height:1.25rem;border-radius:50%;border:0.5rem solid;border-color:var(--lime-primary-color, var(--limel-theme-primary-color));background-color:rgb(var(--contrast-100))}.knob:before,.knob:after{transition:all 0.2s ease 0.2s;content:"";display:block;position:absolute;top:0;bottom:0;margin:auto;width:0;height:0;border:0.375rem solid transparent}:host([disabled]:not([disabled=false])) .knob:before,:host([disabled]:not([disabled=false])) .knob:after{content:none}.knob:before{opacity:calc(var(--slider-fraction) * 100);left:-1rem;transform:rotate(90deg)}.knob:after{opacity:calc((1 - var(--slider-fraction)) * 100);right:-1rem;transform:rotate(-90deg)}.slider:hover .knob,.slider:has(input[type=range]:active) .knob,.slider:has(input[type=range]:focus) .knob{box-shadow:var(--button-shadow-normal)}.slider:hover .knob:before,.slider:has(input[type=range]:active) .knob:before,.slider:has(input[type=range]:focus) .knob:before{left:-1.5rem;border-top-color:rgb(var(--contrast-1400), 0.5)}.slider:hover .knob:after,.slider:has(input[type=range]:active) .knob:after,.slider:has(input[type=range]:focus) .knob:after{right:-1.5rem;border-top-color:rgb(var(--contrast-1400), 0.5)}.indicator{user-select:none;position:absolute;left:0;top:50%;z-index:1;transform:translate3d(-50%, -50%, 0);transform-origin:bottom center;transition:transform 0.2s ease-out, box-shadow 0.2s ease-out, background-color 0.5s ease;border-radius:1.25rem;padding:0 0.375rem;height:1.25rem;display:flex;align-items:center;white-space:nowrap;color:rgb(var(--color-white));font-size:0.6875rem;background-color:var(--lime-primary-color, var(--limel-theme-primary-color));box-shadow:var(--button-shadow-normal)}:host(:not([disabled]):not([readonly])) input[type=range]:active~.thumb .indicator,:host(:not([disabled]):not([readonly])) input[type=range]:focus~.thumb .indicator{transform:translate3d(-50%, calc(-100% - 0.75rem), 0) scale(1.25);box-shadow:var(--shadow-depth-16)}*,*:before,*:after{box-sizing:border-box;min-width:0;min-height:0}:host(limel-slider){box-sizing:border-box;isolation:isolate;position:relative;display:flex;flex-direction:column}:host(limel-slider:not([invalid]):not([invalid=true])) .limel-notched-outline,:host(limel-slider[disabled]:not([disabled=false])) .limel-notched-outline{--limel-notched-outline-border-color:transparent;--limel-notched-outline-background-color:transparent}div[slot=content]{display:flex;flex-direction:column;width:100%;padding:0 0.25rem}.slider{position:relative;height:2.5rem;margin:0 0.75rem}input[type=range]{position:absolute;width:100%;height:100%;opacity:0;cursor:pointer;z-index:2;margin:0;appearance:none}:host([disabled]:not([disabled=false])) input[type=range]{cursor:not-allowed}:host([disabled]:not([disabled=false])) .track .active{opacity:0.5}:host([disabled]:not([disabled=false])) .indicator{border-radius:0.125rem;box-shadow:var(--button-shadow-pressed)}.track{transition:background-color 0.5s ease;display:flex;align-items:center;justify-content:space-between;position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);height:0.5rem;border-radius:1rem;background-color:rgba(var(--contrast-700), 0.6)}.track:before,.track:after{content:"";display:inline-block;position:absolute;top:0;bottom:0;margin:auto;width:0.375rem;height:0.375rem;border-radius:50%;background-color:rgba(var(--contrast-700), 0.6)}.track:before{left:-0.75rem}.track:after{right:-0.75rem}.track .active{transition:background-color 0.5s ease;position:absolute;height:100%;width:calc(var(--slider-fraction) * 100%);border-radius:inherit;background-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.step-dot{transform:translateX(-50%);border-radius:50%;height:0.25rem;width:0.25rem;background-color:rgb(var(--contrast-100), 0.6)}.step-dot:first-of-type,.step-dot:last-of-type{opacity:0}.range-labels{display:flex;justify-content:space-between;margin-top:-0.75rem;width:100%}.range-labels .min,.range-labels .max{line-height:1;font-size:0.75rem;color:var(--limel-notched-outline-label-color, rgb(var(--contrast-1200)))}:host(limel-slider:focus),:host(limel-slider:focus-visible),:host(limel-slider:focus-within){--limel-h-l-grid-template-rows-transition-speed:0.46s;--limel-h-l-grid-template-rows:1fr}:host(limel-slider){--limel-h-l-grid-template-rows-transition-speed:0.3s;--limel-h-l-grid-template-rows:0fr}:host(limel-slider:focus) limel-helper-line,:host(limel-slider:focus-visible) limel-helper-line,:host(limel-slider:focus-within) limel-helper-line,:host(limel-slider:hover) limel-helper-line{will-change:grid-template-rows}`;
|
|
1383
54
|
|
|
1384
55
|
const DEFAULT_FACTOR = 1;
|
|
1385
56
|
const DEFAULT_MAX_VALUE = 100;
|
|
1386
57
|
const DEFAULT_MIN_VALUE = 0;
|
|
58
|
+
const MAX_VISIBLE_STEP_DOTS = 20;
|
|
1387
59
|
const Slider = class {
|
|
1388
60
|
constructor(hostRef) {
|
|
1389
61
|
index.registerInstance(this, hostRef);
|
|
@@ -1434,24 +106,16 @@ const Slider = class {
|
|
|
1434
106
|
* The minimum value allowed
|
|
1435
107
|
*/
|
|
1436
108
|
this.valuemin = DEFAULT_MIN_VALUE;
|
|
1437
|
-
this.
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
this.renderSliderInput = (inputProps) => {
|
|
1448
|
-
return (index.h("input", Object.assign({ class: "mdc-slider__input", type: "range", min: this.multiplyByFactor(this.valuemin), max: this.multiplyByFactor(this.valuemax), value: this.multiplyByFactor(this.value), name: "volume", "aria-labelledby": this.labelId, "aria-describedby": this.helperText ? this.helperTextId : undefined, "aria-controls": this.helperText ? this.helperTextId : undefined }, inputProps)));
|
|
1449
|
-
};
|
|
1450
|
-
this.renderTrack = () => {
|
|
1451
|
-
return (index.h("div", { class: "mdc-slider__track" }, index.h("div", { class: "mdc-slider__track--inactive" }), index.h("div", { class: "mdc-slider__track--active" }, index.h("div", { class: "mdc-slider__track--active_fill" }))));
|
|
1452
|
-
};
|
|
1453
|
-
this.renderThumb = () => {
|
|
1454
|
-
return (index.h("div", { class: "mdc-slider__thumb" }, index.h("div", { class: "mdc-slider__value-indicator-container", "aria-hidden": "true" }, index.h("div", { class: "mdc-slider__value-indicator" }, index.h("span", { class: "mdc-slider__value-indicator-text" }, this.multiplyByFactor(this.value)))), index.h("div", { class: "mdc-slider__thumb-knob" })));
|
|
109
|
+
this.renderStepDots = (min, max) => {
|
|
110
|
+
if (!this.step) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const step = this.multiplyByFactor(this.step);
|
|
114
|
+
const count = Math.floor((max - min) / step) + 1;
|
|
115
|
+
if (count > MAX_VISIBLE_STEP_DOTS) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
return Array.from({ length: count }, () => index.h("span", { class: "step-dot" }));
|
|
1455
119
|
};
|
|
1456
120
|
this.renderHelperLine = () => {
|
|
1457
121
|
if (!this.helperText) {
|
|
@@ -1459,97 +123,31 @@ const Slider = class {
|
|
|
1459
123
|
}
|
|
1460
124
|
return (index.h("limel-helper-line", { helperText: this.helperText, helperTextId: this.helperTextId, invalid: this.invalid }));
|
|
1461
125
|
};
|
|
1462
|
-
this.
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
(
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
So we add the attribute right before initializing MDCSlider. /Ads
|
|
1474
|
-
*/
|
|
1475
|
-
inputElement.setAttribute('value', `${this.multiplyByFactor(value)}`);
|
|
1476
|
-
/*
|
|
1477
|
-
When creating the `mdcSlider` component, its important that the value set in
|
|
1478
|
-
the input field obeys the range and the step size.
|
|
1479
|
-
|
|
1480
|
-
The MDCSlider will throw an exception unless the value in the input element
|
|
1481
|
-
is dividible by the step value and is in the provided range.
|
|
1482
|
-
If an exception occurs, this component will crash and it will be impossible to change
|
|
1483
|
-
its value.
|
|
1484
|
-
The logic below ensures that the component will render even though the
|
|
1485
|
-
provided value is wrong.
|
|
1486
|
-
This could be considered wrong, but it at least fixes so that it's possible
|
|
1487
|
-
to change the value from the UI.
|
|
1488
|
-
*/
|
|
1489
|
-
const greaterThanOrEqualMin = value >= this.valuemin;
|
|
1490
|
-
const lessThanOrEqualMax = value <= this.valuemax;
|
|
1491
|
-
if (!greaterThanOrEqualMin) {
|
|
1492
|
-
const newMin = this.multiplyByFactor(value);
|
|
1493
|
-
inputElement.setAttribute('min', `${newMin}`);
|
|
1494
|
-
}
|
|
1495
|
-
if (!lessThanOrEqualMax) {
|
|
1496
|
-
const newMax = this.multiplyByFactor(value);
|
|
1497
|
-
inputElement.setAttribute('max', `${newMax}`);
|
|
1498
|
-
}
|
|
1499
|
-
if (this.step) {
|
|
1500
|
-
const step = this.multiplyByFactor(this.step);
|
|
1501
|
-
const scaledValue = this.multiplyByFactor(value);
|
|
1502
|
-
if (!this.isMultipleOfStep(scaledValue, step)) {
|
|
1503
|
-
const roundedValue = this.roundToStep(scaledValue, step);
|
|
1504
|
-
inputElement.setAttribute('value', `${roundedValue}`);
|
|
1505
|
-
}
|
|
1506
|
-
inputElement.setAttribute('step', `${step}`);
|
|
1507
|
-
}
|
|
1508
|
-
this.createMDCSlider();
|
|
1509
|
-
};
|
|
1510
|
-
this.reCreateSliderWithStep = () => {
|
|
1511
|
-
const inputElement = this.getInputElement();
|
|
1512
|
-
const step = `${this.multiplyByFactor(this.step)}`;
|
|
1513
|
-
inputElement.setAttribute('step', step);
|
|
1514
|
-
this.destroyMDCSlider();
|
|
1515
|
-
this.createMDCSlider();
|
|
1516
|
-
};
|
|
1517
|
-
this.createMDCSlider = () => {
|
|
1518
|
-
const element = this.getRootElement();
|
|
1519
|
-
this.mdcSlider = new MDCSlider(element);
|
|
1520
|
-
this.mdcSlider.listen('MDCSlider:change', this.changeHandler);
|
|
1521
|
-
this.mdcSlider.listen('MDCSlider:input', this.inputHandler);
|
|
1522
|
-
};
|
|
1523
|
-
this.changeHandler = (event) => {
|
|
1524
|
-
let value = event.detail.value;
|
|
126
|
+
this.handleInput = (event) => {
|
|
127
|
+
event.stopPropagation();
|
|
128
|
+
const input = event.target;
|
|
129
|
+
const value = Number(input.value);
|
|
130
|
+
this.displayValue = value;
|
|
131
|
+
this.setPercentageClass(value / this.factor);
|
|
132
|
+
};
|
|
133
|
+
this.handleChange = (event) => {
|
|
134
|
+
event.stopPropagation();
|
|
135
|
+
const input = event.target;
|
|
136
|
+
let value = Number(input.value);
|
|
1525
137
|
const step = this.multiplyByFactor(this.step);
|
|
1526
138
|
if (!this.isMultipleOfStep(value, step)) {
|
|
1527
139
|
value = this.roundToStep(value, step);
|
|
1528
140
|
}
|
|
1529
141
|
this.change.emit(value / this.factor);
|
|
1530
142
|
};
|
|
1531
|
-
this.inputHandler = (event) => {
|
|
1532
|
-
this.setPercentageClass(event.detail.value / this.factor);
|
|
1533
|
-
};
|
|
1534
143
|
this.getContainerClassList = () => {
|
|
144
|
+
if (!this.percentageClass) {
|
|
145
|
+
return {};
|
|
146
|
+
}
|
|
1535
147
|
return {
|
|
1536
148
|
[this.percentageClass]: true,
|
|
1537
|
-
'displays-percentage-colors': this.displaysPercentageColors,
|
|
1538
|
-
disabled: this.disabled || this.readonly,
|
|
1539
|
-
readonly: this.readonly,
|
|
1540
149
|
};
|
|
1541
150
|
};
|
|
1542
|
-
this.resizeObserverCallback = () => {
|
|
1543
|
-
var _a;
|
|
1544
|
-
(_a = this.mdcSlider) === null || _a === void 0 ? void 0 : _a.layout();
|
|
1545
|
-
};
|
|
1546
|
-
this.updateDisabledState = () => {
|
|
1547
|
-
var _a;
|
|
1548
|
-
if (!this.mdcSlider) {
|
|
1549
|
-
return;
|
|
1550
|
-
}
|
|
1551
|
-
(_a = this.mdcSlider) === null || _a === void 0 ? void 0 : _a.setDisabled(this.disabled || this.readonly);
|
|
1552
|
-
};
|
|
1553
151
|
this.multiplyByFactor = (value) => {
|
|
1554
152
|
return Math.round(value * this.factor);
|
|
1555
153
|
};
|
|
@@ -1560,6 +158,14 @@ const Slider = class {
|
|
|
1560
158
|
}
|
|
1561
159
|
return value;
|
|
1562
160
|
};
|
|
161
|
+
this.getFraction = () => {
|
|
162
|
+
const min = this.multiplyByFactor(this.valuemin);
|
|
163
|
+
const max = this.multiplyByFactor(this.valuemax);
|
|
164
|
+
if (max === min) {
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
return Math.max(0, Math.min(1, (this.displayValue - min) / (max - min)));
|
|
168
|
+
};
|
|
1563
169
|
this.setPercentageClass = (value) => {
|
|
1564
170
|
this.percentageClass = getPercentageClass((value - this.valuemin) / (this.valuemax - this.valuemin));
|
|
1565
171
|
};
|
|
@@ -1572,45 +178,17 @@ const Slider = class {
|
|
|
1572
178
|
this.roundToStep = (value, step) => {
|
|
1573
179
|
return Math.round(value / step) * step;
|
|
1574
180
|
};
|
|
1575
|
-
this.getRootElement = () => {
|
|
1576
|
-
return this.rootElement.shadowRoot.querySelector('.mdc-slider');
|
|
1577
|
-
};
|
|
1578
|
-
this.getInputElement = () => {
|
|
1579
|
-
const element = this.getRootElement();
|
|
1580
|
-
if (!element) {
|
|
1581
|
-
return;
|
|
1582
|
-
}
|
|
1583
|
-
return element.querySelector('input');
|
|
1584
|
-
};
|
|
1585
|
-
this.isStepConfigured = () => {
|
|
1586
|
-
if (!this.step) {
|
|
1587
|
-
return true;
|
|
1588
|
-
}
|
|
1589
|
-
const input = this.getInputElement();
|
|
1590
|
-
if (!input) {
|
|
1591
|
-
return true;
|
|
1592
|
-
}
|
|
1593
|
-
return input.hasAttribute('step');
|
|
1594
|
-
};
|
|
1595
181
|
this.labelId = randomString.createRandomString();
|
|
1596
182
|
this.helperTextId = randomString.createRandomString();
|
|
1597
183
|
}
|
|
1598
|
-
connectedCallback() {
|
|
1599
|
-
this.initialize();
|
|
1600
|
-
this.observer = new ResizeObserver(this.resizeObserverCallback);
|
|
1601
|
-
this.observer.observe(this.rootElement);
|
|
1602
|
-
}
|
|
1603
184
|
componentWillLoad() {
|
|
1604
|
-
this.
|
|
1605
|
-
|
|
1606
|
-
componentDidLoad() {
|
|
1607
|
-
this.initialize();
|
|
1608
|
-
}
|
|
1609
|
-
disconnectedCallback() {
|
|
1610
|
-
this.destroyMDCSlider();
|
|
1611
|
-
this.observer.disconnect();
|
|
185
|
+
this.displayValue = this.multiplyByFactor(this.getValue());
|
|
186
|
+
this.setPercentageClass(this.getValue());
|
|
1612
187
|
}
|
|
1613
188
|
render() {
|
|
189
|
+
const min = this.multiplyByFactor(this.valuemin);
|
|
190
|
+
const max = this.multiplyByFactor(this.valuemax);
|
|
191
|
+
const fraction = this.getFraction();
|
|
1614
192
|
const inputProps = {};
|
|
1615
193
|
if (this.step) {
|
|
1616
194
|
inputProps.step = this.multiplyByFactor(this.step);
|
|
@@ -1618,43 +196,15 @@ const Slider = class {
|
|
|
1618
196
|
if (this.disabled || this.readonly) {
|
|
1619
197
|
inputProps.disabled = true;
|
|
1620
198
|
}
|
|
1621
|
-
return (index.h(index.Host, { key: '
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
this.updateDisabledState();
|
|
1625
|
-
}
|
|
1626
|
-
watchReadonly() {
|
|
1627
|
-
this.updateDisabledState();
|
|
199
|
+
return (index.h(index.Host, { key: 'fa9695563f078bdab1707422cad3aaef2610e592', class: this.getContainerClassList() }, index.h("limel-notched-outline", { key: '8b71ef15e9544a6b346248217c2c2fa8acbba6e7', labelId: this.labelId, label: this.label, required: this.required, invalid: this.invalid, disabled: this.disabled, readonly: this.readonly, hasValue: !!this.value, hasFloatingLabel: true }, index.h("div", { key: '0327cf7d5295bb1d56e2e34b8dca15cfc3e15c0d', slot: "content" }, index.h("div", { key: '83fade77119ba9fa1d24ae8fdcd54317648918b3', class: "slider", style: { '--slider-fraction': `${fraction}` } }, index.h("input", Object.assign({ key: '5181430787abe75b4556923e31ebe8520df977e9', type: "range", min: min, max: max, value: this.displayValue, "aria-labelledby": this.labelId, "aria-describedby": this.helperText
|
|
200
|
+
? this.helperTextId
|
|
201
|
+
: undefined, onInput: this.handleInput, onChange: this.handleChange }, inputProps)), index.h("div", { key: '6ee95d718f1d01e92adcf9592882ed1d32e4ba67', class: "track" }, index.h("div", { key: 'bba420e41501990bdeb1326e59e6eff57000848d', class: "active" }), this.renderStepDots(min, max)), index.h("div", { key: '46e5a45adbda4e1a650d01408c3d228f1c6be68d', class: "thumb" }, index.h("div", { key: 'eeba995f52ff3291e2e7818528b05c7c1dec1b32', class: "knob" }), index.h("div", { key: 'd0321459ed22c6870d939da54df43fe2bfef6333', class: "indicator", "aria-hidden": "true" }, this.displayValue))), index.h("div", { key: 'bcc4449d7605343fd64f4b89b50c8e5d665f6937', class: "range-labels" }, index.h("span", { key: '301c78b1640551fe814ad3b2768bb40f9b682b39', class: "min" }, this.multiplyByFactor(this.valuemin), this.unit), index.h("span", { key: '7f8d741f63030b6f8e88231e5215448b815bf3ca', class: "max" }, this.multiplyByFactor(this.valuemax), this.unit)))), this.renderHelperLine()));
|
|
1628
202
|
}
|
|
1629
203
|
watchValue() {
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
}
|
|
1633
|
-
const value = this.multiplyByFactor(this.getValue());
|
|
1634
|
-
this.mdcSlider.setValue(value);
|
|
1635
|
-
if (this.isStepConfigured()) {
|
|
1636
|
-
return;
|
|
1637
|
-
}
|
|
1638
|
-
const step = this.multiplyByFactor(this.step);
|
|
1639
|
-
if (!this.isMultipleOfStep(value, step)) {
|
|
1640
|
-
return;
|
|
1641
|
-
}
|
|
1642
|
-
this.reCreateSliderWithStep();
|
|
1643
|
-
}
|
|
1644
|
-
destroyMDCSlider() {
|
|
1645
|
-
this.mdcSlider.unlisten('MDCSlider:change', this.changeHandler);
|
|
1646
|
-
this.mdcSlider.unlisten('MDCSlider:input', this.inputHandler);
|
|
1647
|
-
this.mdcSlider.destroy();
|
|
1648
|
-
this.mdcSlider = undefined;
|
|
204
|
+
this.displayValue = this.multiplyByFactor(this.getValue());
|
|
205
|
+
this.setPercentageClass(this.getValue());
|
|
1649
206
|
}
|
|
1650
|
-
get rootElement() { return index.getElement(this); }
|
|
1651
207
|
static get watchers() { return {
|
|
1652
|
-
"disabled": [{
|
|
1653
|
-
"watchDisabled": 0
|
|
1654
|
-
}],
|
|
1655
|
-
"readonly": [{
|
|
1656
|
-
"watchReadonly": 0
|
|
1657
|
-
}],
|
|
1658
208
|
"value": [{
|
|
1659
209
|
"watchValue": 0
|
|
1660
210
|
}]
|