@umbraco-ui/uui-range-slider 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +24 -10
- package/lib/uui-range-slider.element.d.ts +0 -2
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -30,18 +30,21 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
33
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
33
34
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
34
35
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
35
|
-
var _UUIRangeSliderElement_instances, transferValueToInternalValues_fn;
|
|
36
|
+
var _UUIRangeSliderElement_instances, transferValueToInternalValues_fn, _onKeyDown;
|
|
36
37
|
const Z_INDEX = {
|
|
37
38
|
TOP: 3,
|
|
38
|
-
CENTER: 2
|
|
39
|
-
BACK: 1
|
|
40
|
-
};
|
|
39
|
+
CENTER: 2};
|
|
41
40
|
const THUMB_SIZE = 18;
|
|
42
41
|
const TRACK_HEIGHT = 3;
|
|
43
42
|
const TRACK_PADDING = 12;
|
|
44
43
|
const STEP_MIN_WIDTH = 24;
|
|
44
|
+
const CountDecimalPlaces = (num) => {
|
|
45
|
+
const decimalIndex = num.toString().indexOf(".");
|
|
46
|
+
return decimalIndex >= 0 ? num.toString().length - decimalIndex - 1 : 0;
|
|
47
|
+
};
|
|
45
48
|
let UUIRangeSliderElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
46
49
|
/** Constructor and Validator */
|
|
47
50
|
constructor() {
|
|
@@ -65,11 +68,11 @@ let UUIRangeSliderElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
65
68
|
this._lowValuePercentStart = 0;
|
|
66
69
|
this._highValuePercentEnd = 100;
|
|
67
70
|
/** Events */
|
|
68
|
-
this
|
|
71
|
+
__privateAdd(this, _onKeyDown, (e) => {
|
|
69
72
|
if (e.key == "Enter") {
|
|
70
73
|
this.submit();
|
|
71
74
|
}
|
|
72
|
-
};
|
|
75
|
+
});
|
|
73
76
|
/** Touch Event */
|
|
74
77
|
this._onTouchStart = (e) => {
|
|
75
78
|
if (this.disabled) return;
|
|
@@ -134,7 +137,7 @@ let UUIRangeSliderElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
134
137
|
window.removeEventListener("mouseup", this._onMouseUp);
|
|
135
138
|
window.removeEventListener("mousemove", this._onMouseMove);
|
|
136
139
|
};
|
|
137
|
-
this.addEventListener("
|
|
140
|
+
this.addEventListener("keydown", __privateGet(this, _onKeyDown));
|
|
138
141
|
this.addEventListener("mousedown", this._onMouseDown);
|
|
139
142
|
this.addEventListener("touchstart", this._onTouchStart);
|
|
140
143
|
window.addEventListener("resize", () => {
|
|
@@ -393,8 +396,16 @@ let UUIRangeSliderElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
393
396
|
}
|
|
394
397
|
_renderThumbValues() {
|
|
395
398
|
return html`<div class="thumb-values">
|
|
396
|
-
<span
|
|
397
|
-
|
|
399
|
+
<span
|
|
400
|
+
><span
|
|
401
|
+
>${this._lowInputValue.toFixed(CountDecimalPlaces(this._step))}</span
|
|
402
|
+
></span
|
|
403
|
+
>
|
|
404
|
+
<span
|
|
405
|
+
><span
|
|
406
|
+
>${this._highInputValue.toFixed(CountDecimalPlaces(this._step))}</span
|
|
407
|
+
></span
|
|
408
|
+
>
|
|
398
409
|
</div>`;
|
|
399
410
|
}
|
|
400
411
|
_renderSteps() {
|
|
@@ -415,7 +426,9 @@ let UUIRangeSliderElement = class extends UUIFormControlMixin(LitElement, "") {
|
|
|
415
426
|
_renderStepValues(stepAmount) {
|
|
416
427
|
if (this.hideStepValues || stepAmount > 20) return;
|
|
417
428
|
let index = 0;
|
|
418
|
-
const stepValues = new Array(stepAmount + 1).fill(this._step).map(
|
|
429
|
+
const stepValues = new Array(stepAmount + 1).fill(this._step).map(
|
|
430
|
+
(step) => (this._min + step * index++).toFixed(CountDecimalPlaces(this._step))
|
|
431
|
+
);
|
|
419
432
|
return html`<div class="step-values">
|
|
420
433
|
${stepValues.map((value) => html`<span><span>${value}</span></span>`)}
|
|
421
434
|
</div>`;
|
|
@@ -483,6 +496,7 @@ transferValueToInternalValues_fn = function() {
|
|
|
483
496
|
this._updateInnerColor();
|
|
484
497
|
this.requestUpdate();
|
|
485
498
|
};
|
|
499
|
+
_onKeyDown = new WeakMap();
|
|
486
500
|
UUIRangeSliderElement.formAssociated = true;
|
|
487
501
|
/** Style */
|
|
488
502
|
UUIRangeSliderElement.styles = [
|
|
@@ -117,8 +117,6 @@ export declare class UUIRangeSliderElement extends UUIRangeSliderElement_base {
|
|
|
117
117
|
private _runPropertiesChecks;
|
|
118
118
|
private _updateInnerColor;
|
|
119
119
|
private _getClickedValue;
|
|
120
|
-
/** Events */
|
|
121
|
-
private _onKeypress;
|
|
122
120
|
/** Touch Event */
|
|
123
121
|
private _onTouchStart;
|
|
124
122
|
private _onTouchMove;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umbraco-ui/uui-range-slider",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Umbraco",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"custom-elements.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@umbraco-ui/uui-base": "1.
|
|
33
|
+
"@umbraco-ui/uui-base": "1.12.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "npm run analyze && tsc --build && rollup -c rollup.config.js",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"homepage": "https://uui.umbraco.com/?path=/story/uui-range-slider",
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "0ac5219b2765bf6c90fe4943a6620b46a7fced4e"
|
|
45
45
|
}
|