@vaadin/slider 25.1.0-alpha7 → 25.1.0-alpha9
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/custom-elements.json +28 -0
- package/package.json +11 -10
- package/src/styles/vaadin-slider-base-styles.js +1 -1
- package/src/vaadin-range-slider.d.ts +2 -0
- package/src/vaadin-range-slider.js +2 -0
- package/src/vaadin-slider-mixin.js +14 -2
- package/src/vaadin-slider.d.ts +2 -0
- package/src/vaadin-slider.js +2 -0
- package/web-types.json +180 -180
- package/web-types.lit.json +73 -73
package/custom-elements.json
CHANGED
|
@@ -249,6 +249,20 @@
|
|
|
249
249
|
"module": "src/vaadin-slider-mixin.js"
|
|
250
250
|
}
|
|
251
251
|
},
|
|
252
|
+
{
|
|
253
|
+
"type": {
|
|
254
|
+
"text": "CustomEvent"
|
|
255
|
+
},
|
|
256
|
+
"description": "Fired when the `invalid` property changes.",
|
|
257
|
+
"name": "invalid-changed"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"type": {
|
|
261
|
+
"text": "CustomEvent"
|
|
262
|
+
},
|
|
263
|
+
"description": "Fired whenever the field is validated.",
|
|
264
|
+
"name": "validated"
|
|
265
|
+
},
|
|
252
266
|
{
|
|
253
267
|
"type": {
|
|
254
268
|
"text": "CustomEvent"
|
|
@@ -1450,6 +1464,20 @@
|
|
|
1450
1464
|
"module": "src/vaadin-slider-mixin.js"
|
|
1451
1465
|
}
|
|
1452
1466
|
},
|
|
1467
|
+
{
|
|
1468
|
+
"type": {
|
|
1469
|
+
"text": "CustomEvent"
|
|
1470
|
+
},
|
|
1471
|
+
"description": "Fired when the `invalid` property changes.",
|
|
1472
|
+
"name": "invalid-changed"
|
|
1473
|
+
},
|
|
1474
|
+
{
|
|
1475
|
+
"type": {
|
|
1476
|
+
"text": "CustomEvent"
|
|
1477
|
+
},
|
|
1478
|
+
"description": "Fired whenever the field is validated.",
|
|
1479
|
+
"name": "validated"
|
|
1480
|
+
},
|
|
1453
1481
|
{
|
|
1454
1482
|
"type": {
|
|
1455
1483
|
"text": "CustomEvent"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/slider",
|
|
3
|
-
"version": "25.1.0-
|
|
3
|
+
"version": "25.1.0-alpha9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,23 +35,24 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/a11y-base": "25.1.0-
|
|
39
|
-
"@vaadin/component-base": "25.1.0-
|
|
40
|
-
"@vaadin/field-base": "25.1.0-
|
|
41
|
-
"@vaadin/overlay": "25.1.0-
|
|
42
|
-
"@vaadin/vaadin-themable-mixin": "25.1.0-
|
|
38
|
+
"@vaadin/a11y-base": "25.1.0-alpha9",
|
|
39
|
+
"@vaadin/component-base": "25.1.0-alpha9",
|
|
40
|
+
"@vaadin/field-base": "25.1.0-alpha9",
|
|
41
|
+
"@vaadin/overlay": "25.1.0-alpha9",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "25.1.0-alpha9",
|
|
43
43
|
"lit": "^3.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@vaadin/
|
|
47
|
-
"@vaadin/
|
|
46
|
+
"@vaadin/aura": "25.1.0-alpha9",
|
|
47
|
+
"@vaadin/chai-plugins": "25.1.0-alpha9",
|
|
48
|
+
"@vaadin/test-runner-commands": "25.1.0-alpha9",
|
|
48
49
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
49
|
-
"@vaadin/vaadin-lumo-styles": "25.1.0-
|
|
50
|
+
"@vaadin/vaadin-lumo-styles": "25.1.0-alpha9"
|
|
50
51
|
},
|
|
51
52
|
"customElements": "custom-elements.json",
|
|
52
53
|
"web-types": [
|
|
53
54
|
"web-types.json",
|
|
54
55
|
"web-types.lit.json"
|
|
55
56
|
],
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "ef432311376ba3dac4233cb23d393a49a425e0a4"
|
|
57
58
|
}
|
|
@@ -95,7 +95,6 @@ export const sliderStyles = css`
|
|
|
95
95
|
border: var(--vaadin-slider-thumb-border-width, 1px) solid
|
|
96
96
|
var(--vaadin-slider-thumb-border-color, var(--vaadin-text-color));
|
|
97
97
|
border-radius: var(--vaadin-slider-thumb-border-radius, var(--vaadin-radius-l));
|
|
98
|
-
touch-action: none;
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
:host([readonly]) [part='track-fill'] {
|
|
@@ -114,6 +113,7 @@ export const sliderStyles = css`
|
|
|
114
113
|
outline: 0;
|
|
115
114
|
-webkit-tap-highlight-color: transparent;
|
|
116
115
|
cursor: inherit;
|
|
116
|
+
touch-action: none;
|
|
117
117
|
z-index: 999;
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -150,7 +150,9 @@ export interface RangeSliderEventMap extends HTMLElementEventMap, RangeSliderCus
|
|
|
150
150
|
*
|
|
151
151
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
152
152
|
* @fires {Event} input - Fired when the slider value changes during user interaction.
|
|
153
|
+
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
153
154
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
155
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
154
156
|
*/
|
|
155
157
|
declare class RangeSlider extends FieldMixin(SliderMixin(FocusMixin(ThemableMixin(ElementMixin(HTMLElement))))) {
|
|
156
158
|
/**
|
|
@@ -119,7 +119,9 @@ import { SliderMixin } from './vaadin-slider-mixin.js';
|
|
|
119
119
|
*
|
|
120
120
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
121
121
|
* @fires {Event} input - Fired when the slider value changes during user interaction.
|
|
122
|
+
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
122
123
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
124
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
123
125
|
*
|
|
124
126
|
* @customElement vaadin-range-slider
|
|
125
127
|
* @extends HTMLElement
|
|
@@ -158,17 +158,26 @@ export const SliderMixin = (superClass) =>
|
|
|
158
158
|
|
|
159
159
|
const safeValue = Math.min(Math.max(value, minValue), maxValue);
|
|
160
160
|
|
|
161
|
+
// Round to step precision to avoid floating-point artifacts.
|
|
162
|
+
const precision = this.__getStepPrecision(step);
|
|
163
|
+
|
|
161
164
|
const offset = safeValue - minValue;
|
|
162
165
|
const nearestOffset = Math.round(offset / step) * step;
|
|
163
|
-
const nearestValue = minValue + nearestOffset;
|
|
166
|
+
const nearestValue = parseFloat((minValue + nearestOffset).toFixed(precision));
|
|
164
167
|
|
|
165
168
|
// Ensure the last value matching step is used below the max limit.
|
|
166
169
|
// Example: max = 100, step = 1.5 - force maximum allowed value to 99.
|
|
167
|
-
const newValue = nearestValue <= maxValue ? nearestValue : nearestValue - step;
|
|
170
|
+
const newValue = nearestValue <= maxValue ? nearestValue : parseFloat((nearestValue - step).toFixed(precision));
|
|
168
171
|
|
|
169
172
|
this.__value = fullValue.with(index, newValue);
|
|
170
173
|
}
|
|
171
174
|
|
|
175
|
+
/** @private */
|
|
176
|
+
__getStepPrecision(step) {
|
|
177
|
+
const afterDecimal = String(step).split('.')[1];
|
|
178
|
+
return afterDecimal ? afterDecimal.length : 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
172
181
|
/**
|
|
173
182
|
* @return {{ min: number, max: number, step: number}}
|
|
174
183
|
* @private
|
|
@@ -188,6 +197,9 @@ export const SliderMixin = (superClass) =>
|
|
|
188
197
|
*/
|
|
189
198
|
__getPercentFromValue(value) {
|
|
190
199
|
const { min, max } = this.__getConstraints();
|
|
200
|
+
if (max <= min) {
|
|
201
|
+
return 0;
|
|
202
|
+
}
|
|
191
203
|
const safeValue = Math.min(Math.max(value, min), max);
|
|
192
204
|
return (safeValue - min) / (max - min);
|
|
193
205
|
}
|
package/src/vaadin-slider.d.ts
CHANGED
|
@@ -145,7 +145,9 @@ export interface SliderEventMap extends HTMLElementEventMap, SliderCustomEventMa
|
|
|
145
145
|
*
|
|
146
146
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
147
147
|
* @fires {Event} input - Fired when the slider value changes during user interaction.
|
|
148
|
+
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
148
149
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
150
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
149
151
|
*/
|
|
150
152
|
declare class Slider extends FieldMixin(SliderMixin(FocusMixin(ThemableMixin(ElementMixin(HTMLElement))))) {
|
|
151
153
|
/**
|
package/src/vaadin-slider.js
CHANGED
|
@@ -114,7 +114,9 @@ import { SliderMixin } from './vaadin-slider-mixin.js';
|
|
|
114
114
|
*
|
|
115
115
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
116
116
|
* @fires {Event} input - Fired when the slider value changes during user interaction.
|
|
117
|
+
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
117
118
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
119
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
118
120
|
*
|
|
119
121
|
* @customElement vaadin-slider
|
|
120
122
|
* @extends HTMLElement
|