@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 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 = parseInt(textFieldValue);
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: parseInt(String(getMarkValue(key)))
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 = parseInt(String(getMarkValue(min)));
118
- const actualMax = parseInt(String(getMarkValue(max)));
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 = parseInt(textFieldInputValue);
173
- const actualMinByMark = parseInt(String(getMarkValue(min)));
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)) {
@@ -8,7 +8,7 @@ const generateAllowedValues = (min, max, step) => {
8
8
  const values = [];
9
9
  let current = min;
10
10
  while (current <= max) {
11
- values.push(current);
11
+ values.push(parseFloat(current.toFixed(10)));
12
12
  current += step;
13
13
  }
14
14
  return values;
@@ -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 = parseInt(textFieldValue);
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: parseInt(String(getMarkValue(key))),
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 = parseInt(String(getMarkValue(min)));
74
- const actualMax = parseInt(String(getMarkValue(max)));
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 = parseInt(textFieldInputValue);
123
- const actualMinByMark = parseInt(String(getMarkValue(min)));
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)) {
@@ -2,7 +2,7 @@ export const generateAllowedValues = (min, max, step) => {
2
2
  const values = [];
3
3
  let current = min;
4
4
  while (current <= max) {
5
- values.push(current);
5
+ values.push(parseFloat(current.toFixed(10)));
6
6
  current += step;
7
7
  }
8
8
  return values;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Fields",
7
- "version": "0.42.0",
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": "9786e3a2d1ef58fd4b1002d4bc69a61a70113acf"
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 = parseInt(textFieldValue);
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: parseInt(String(getMarkValue(key))),
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 = parseInt(String(getMarkValue(min)));
173
- const actualMax = parseInt(String(getMarkValue(max)));
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 = parseInt(textFieldInputValue);
234
- const actualMinByMark = parseInt(String(getMarkValue(min)));
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;
@@ -4,7 +4,7 @@ export const generateAllowedValues = (min: number, max: number, step: number): n
4
4
  let current = min;
5
5
 
6
6
  while (current <= max) {
7
- values.push(current);
7
+ values.push(parseFloat(current.toFixed(10)));
8
8
  current += step;
9
9
  }
10
10