@snack-uikit/fields 0.42.0 → 0.42.1
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 +11 -0
- package/dist/cjs/components/FieldSlider/FieldSlider.js +6 -6
- package/dist/cjs/components/FieldSlider/helpers/generateAllowedValues.js +1 -1
- package/dist/esm/components/FieldSlider/FieldSlider.js +6 -6
- package/dist/esm/components/FieldSlider/helpers/generateAllowedValues.js +1 -1
- package/package.json +2 -2
- package/src/components/FieldSlider/FieldSlider.tsx +6 -6
- package/src/components/FieldSlider/helpers/generateAllowedValues.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.42.1 (2025-05-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **PDS-2180:** added float support for slider field ([2c2986b](https://github.com/cloud-ru-tech/snack-uikit/commit/2c2986b1ac81034feb1cd38a7d9ea98188354007))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# 0.42.0 (2025-04-23)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -94,7 +94,7 @@ exports.FieldSlider = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
94
94
|
}, [marks]);
|
|
95
95
|
const hasMarksEqualToValues = (0, react_1.useMemo)(() => Object.keys(marks).every(key => key === getMarkValue(key)), [getMarkValue, marks]);
|
|
96
96
|
const onTextFieldChange = textFieldValue => {
|
|
97
|
-
const numValue =
|
|
97
|
+
const numValue = parseFloat(textFieldValue);
|
|
98
98
|
if (textFieldValue && Number.isNaN(numValue)) {
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
@@ -107,15 +107,15 @@ exports.FieldSlider = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
107
107
|
};
|
|
108
108
|
const allowedValues = Object.keys(marks).map(key => ({
|
|
109
109
|
key,
|
|
110
|
-
value:
|
|
110
|
+
value: parseFloat(String(getMarkValue(key)))
|
|
111
111
|
}));
|
|
112
112
|
const suitableEntry = allowedValues.find(entry => entry.value === textFieldNumValue);
|
|
113
113
|
if (suitableEntry) {
|
|
114
114
|
handleChange(suitableEntry.key);
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
|
-
const actualMin =
|
|
118
|
-
const actualMax =
|
|
117
|
+
const actualMin = parseFloat(String(getMarkValue(min)));
|
|
118
|
+
const actualMax = parseFloat(String(getMarkValue(max)));
|
|
119
119
|
if (textFieldNumValue < actualMin) {
|
|
120
120
|
handleChange(min);
|
|
121
121
|
return;
|
|
@@ -169,8 +169,8 @@ exports.FieldSlider = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
169
169
|
if (range) {
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
const parsedValue =
|
|
173
|
-
const actualMinByMark =
|
|
172
|
+
const parsedValue = parseFloat(textFieldInputValue);
|
|
173
|
+
const actualMinByMark = parseFloat(String(getMarkValue(min)));
|
|
174
174
|
const actualMin = Number.isNaN(actualMinByMark) ? min : actualMinByMark;
|
|
175
175
|
const textFieldNumValue = textFieldInputValue ? parsedValue : actualMin;
|
|
176
176
|
if (Number.isNaN(textFieldNumValue)) {
|
|
@@ -50,7 +50,7 @@ export const FieldSlider = forwardRef((_a, ref) => {
|
|
|
50
50
|
}, [marks]);
|
|
51
51
|
const hasMarksEqualToValues = useMemo(() => Object.keys(marks).every(key => key === getMarkValue(key)), [getMarkValue, marks]);
|
|
52
52
|
const onTextFieldChange = (textFieldValue) => {
|
|
53
|
-
const numValue =
|
|
53
|
+
const numValue = parseFloat(textFieldValue);
|
|
54
54
|
if (textFieldValue && Number.isNaN(numValue)) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
@@ -63,15 +63,15 @@ export const FieldSlider = forwardRef((_a, ref) => {
|
|
|
63
63
|
};
|
|
64
64
|
const allowedValues = Object.keys(marks).map(key => ({
|
|
65
65
|
key,
|
|
66
|
-
value:
|
|
66
|
+
value: parseFloat(String(getMarkValue(key))),
|
|
67
67
|
}));
|
|
68
68
|
const suitableEntry = allowedValues.find(entry => entry.value === textFieldNumValue);
|
|
69
69
|
if (suitableEntry) {
|
|
70
70
|
handleChange(suitableEntry.key);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
const actualMin =
|
|
74
|
-
const actualMax =
|
|
73
|
+
const actualMin = parseFloat(String(getMarkValue(min)));
|
|
74
|
+
const actualMax = parseFloat(String(getMarkValue(max)));
|
|
75
75
|
if (textFieldNumValue < actualMin) {
|
|
76
76
|
handleChange(min);
|
|
77
77
|
return;
|
|
@@ -119,8 +119,8 @@ export const FieldSlider = forwardRef((_a, ref) => {
|
|
|
119
119
|
if (range) {
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
-
const parsedValue =
|
|
123
|
-
const actualMinByMark =
|
|
122
|
+
const parsedValue = parseFloat(textFieldInputValue);
|
|
123
|
+
const actualMinByMark = parseFloat(String(getMarkValue(min)));
|
|
124
124
|
const actualMin = Number.isNaN(actualMinByMark) ? min : actualMinByMark;
|
|
125
125
|
const textFieldNumValue = textFieldInputValue ? parsedValue : actualMin;
|
|
126
126
|
if (Number.isNaN(textFieldNumValue)) {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Fields",
|
|
7
|
-
"version": "0.42.
|
|
7
|
+
"version": "0.42.1",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@snack-uikit/locale": "*"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "637f86200b41cf9c01d5f22fe6c6324fb2eb608f"
|
|
69
69
|
}
|
|
@@ -143,7 +143,7 @@ export const FieldSlider = forwardRef<HTMLInputElement, FieldSliderProps>(
|
|
|
143
143
|
);
|
|
144
144
|
|
|
145
145
|
const onTextFieldChange = (textFieldValue: string) => {
|
|
146
|
-
const numValue =
|
|
146
|
+
const numValue = parseFloat(textFieldValue);
|
|
147
147
|
|
|
148
148
|
if (textFieldValue && Number.isNaN(numValue)) {
|
|
149
149
|
return;
|
|
@@ -160,7 +160,7 @@ export const FieldSlider = forwardRef<HTMLInputElement, FieldSliderProps>(
|
|
|
160
160
|
|
|
161
161
|
const allowedValues = Object.keys(marks).map(key => ({
|
|
162
162
|
key,
|
|
163
|
-
value:
|
|
163
|
+
value: parseFloat(String(getMarkValue(key))),
|
|
164
164
|
}));
|
|
165
165
|
const suitableEntry = allowedValues.find(entry => entry.value === textFieldNumValue);
|
|
166
166
|
|
|
@@ -169,8 +169,8 @@ export const FieldSlider = forwardRef<HTMLInputElement, FieldSliderProps>(
|
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
const actualMin =
|
|
173
|
-
const actualMax =
|
|
172
|
+
const actualMin = parseFloat(String(getMarkValue(min)));
|
|
173
|
+
const actualMax = parseFloat(String(getMarkValue(max)));
|
|
174
174
|
|
|
175
175
|
if (textFieldNumValue < actualMin) {
|
|
176
176
|
handleChange(min);
|
|
@@ -230,8 +230,8 @@ export const FieldSlider = forwardRef<HTMLInputElement, FieldSliderProps>(
|
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
const parsedValue =
|
|
234
|
-
const actualMinByMark =
|
|
233
|
+
const parsedValue = parseFloat(textFieldInputValue);
|
|
234
|
+
const actualMinByMark = parseFloat(String(getMarkValue(min)));
|
|
235
235
|
const actualMin = Number.isNaN(actualMinByMark) ? min : actualMinByMark;
|
|
236
236
|
|
|
237
237
|
const textFieldNumValue = textFieldInputValue ? parsedValue : actualMin;
|