@vaadin/slider 25.1.0-alpha7 → 25.1.0-alpha8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/slider",
3
- "version": "25.1.0-alpha7",
3
+ "version": "25.1.0-alpha8",
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-alpha7",
39
- "@vaadin/component-base": "25.1.0-alpha7",
40
- "@vaadin/field-base": "25.1.0-alpha7",
41
- "@vaadin/overlay": "25.1.0-alpha7",
42
- "@vaadin/vaadin-themable-mixin": "25.1.0-alpha7",
38
+ "@vaadin/a11y-base": "25.1.0-alpha8",
39
+ "@vaadin/component-base": "25.1.0-alpha8",
40
+ "@vaadin/field-base": "25.1.0-alpha8",
41
+ "@vaadin/overlay": "25.1.0-alpha8",
42
+ "@vaadin/vaadin-themable-mixin": "25.1.0-alpha8",
43
43
  "lit": "^3.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@vaadin/chai-plugins": "25.1.0-alpha7",
47
- "@vaadin/test-runner-commands": "25.1.0-alpha7",
46
+ "@vaadin/aura": "25.1.0-alpha8",
47
+ "@vaadin/chai-plugins": "25.1.0-alpha8",
48
+ "@vaadin/test-runner-commands": "25.1.0-alpha8",
48
49
  "@vaadin/testing-helpers": "^2.0.0",
49
- "@vaadin/vaadin-lumo-styles": "25.1.0-alpha7"
50
+ "@vaadin/vaadin-lumo-styles": "25.1.0-alpha8"
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": "98c586125f769c8fefd307536965293668fda81d"
57
+ "gitHead": "810590c9c7682a9326c9352df795b5ea4891a71f"
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
 
@@ -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/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/slider",
4
- "version": "25.1.0-alpha7",
4
+ "version": "25.1.0-alpha8",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/slider",
4
- "version": "25.1.0-alpha7",
4
+ "version": "25.1.0-alpha8",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {