@snack-uikit/fields 0.48.6 → 0.48.7

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.48.7 (2025-07-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **PDS-2451:** unable input 0 into field time ([9a29bbf](https://github.com/cloud-ru-tech/snack-uikit/commit/9a29bbf94f5ecebf111b4f2909047248d40dc390))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 0.48.6 (2025-07-07)
7
18
 
8
19
  ### Only dependencies have been changed
@@ -127,7 +127,8 @@ function useDateField(_ref) {
127
127
  if (slotKey) {
128
128
  const value = getSlot(slotKey);
129
129
  const {
130
- max
130
+ max,
131
+ min
131
132
  } = slotsInfo[slotKey];
132
133
  const numberValue = Number(value) || 0;
133
134
  if (e.key === 'ArrowRight') {
@@ -151,31 +152,36 @@ function useDateField(_ref) {
151
152
  }
152
153
  }
153
154
  if (/^\d+$/.test(e.key)) {
155
+ const digit = Number(e.key);
154
156
  const slotValue = parseInt(numberValue.toString() + e.key, 10) || 0;
155
157
  const valueLength = slotValue.toString().length;
156
158
  const maxLength = max.toString().length;
159
+ const isTheLastInput = value.match(/^0+$/) && maxLength === 2 && digit === 0;
157
160
  if (valueLength < maxLength) {
158
- slotValue && updateSlot(slotKey, slotValue);
161
+ if (slotValue || slotValue >= min) {
162
+ updateSlot(slotKey, slotValue);
163
+ if (isTheLastInput) checkInputAndGoNext(slotKey);
164
+ }
159
165
  if (slotValue * 10 > max) {
160
166
  checkInputAndGoNext(slotKey);
161
167
  }
162
168
  } else if (valueLength > maxLength) {
163
- if (Number(e.key) * 10 > max) {
169
+ if (digit * 10 > max) {
164
170
  updateSlot(slotKey, e.key);
165
171
  checkInputAndGoNext(slotKey);
166
- } else {
167
- Number(e.key) && updateSlot(slotKey, e.key);
172
+ } else if (digit || digit >= min) {
173
+ updateSlot(slotKey, e.key);
168
174
  }
169
175
  } else {
170
176
  if (slotValue <= max) {
171
177
  updateSlot(slotKey, slotValue);
172
178
  checkInputAndGoNext(slotKey);
173
179
  } else {
174
- if (Number(e.key) * 10 > max) {
180
+ if (digit * 10 > max) {
175
181
  updateSlot(slotKey, e.key);
176
182
  checkInputAndGoNext(slotKey);
177
- } else {
178
- Number(e.key) && updateSlot(slotKey, e.key);
183
+ } else if (digit || digit >= min) {
184
+ updateSlot(slotKey, e.key);
179
185
  }
180
186
  }
181
187
  }
@@ -93,7 +93,7 @@ export function useDateField({ inputRef, onChange, readonly, locale = DEFAULT_LO
93
93
  const slotKey = getSlotKeyFromIndex(clickIndex);
94
94
  if (slotKey) {
95
95
  const value = getSlot(slotKey);
96
- const { max } = slotsInfo[slotKey];
96
+ const { max, min } = slotsInfo[slotKey];
97
97
  const numberValue = Number(value) || 0;
98
98
  if (e.key === 'ArrowRight') {
99
99
  if (isAllSelected() || slotKey === slotOrder[slotOrder.length - 1]) {
@@ -117,22 +117,28 @@ export function useDateField({ inputRef, onChange, readonly, locale = DEFAULT_LO
117
117
  }
118
118
  }
119
119
  if (/^\d+$/.test(e.key)) {
120
+ const digit = Number(e.key);
120
121
  const slotValue = parseInt(numberValue.toString() + e.key, 10) || 0;
121
122
  const valueLength = slotValue.toString().length;
122
123
  const maxLength = max.toString().length;
124
+ const isTheLastInput = value.match(/^0+$/) && maxLength === 2 && digit === 0;
123
125
  if (valueLength < maxLength) {
124
- slotValue && updateSlot(slotKey, slotValue);
126
+ if (slotValue || slotValue >= min) {
127
+ updateSlot(slotKey, slotValue);
128
+ if (isTheLastInput)
129
+ checkInputAndGoNext(slotKey);
130
+ }
125
131
  if (slotValue * 10 > max) {
126
132
  checkInputAndGoNext(slotKey);
127
133
  }
128
134
  }
129
135
  else if (valueLength > maxLength) {
130
- if (Number(e.key) * 10 > max) {
136
+ if (digit * 10 > max) {
131
137
  updateSlot(slotKey, e.key);
132
138
  checkInputAndGoNext(slotKey);
133
139
  }
134
- else {
135
- Number(e.key) && updateSlot(slotKey, e.key);
140
+ else if (digit || digit >= min) {
141
+ updateSlot(slotKey, e.key);
136
142
  }
137
143
  }
138
144
  else {
@@ -141,12 +147,12 @@ export function useDateField({ inputRef, onChange, readonly, locale = DEFAULT_LO
141
147
  checkInputAndGoNext(slotKey);
142
148
  }
143
149
  else {
144
- if (Number(e.key) * 10 > max) {
150
+ if (digit * 10 > max) {
145
151
  updateSlot(slotKey, e.key);
146
152
  checkInputAndGoNext(slotKey);
147
153
  }
148
- else {
149
- Number(e.key) && updateSlot(slotKey, e.key);
154
+ else if (digit || digit >= min) {
155
+ updateSlot(slotKey, e.key);
150
156
  }
151
157
  }
152
158
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Fields",
7
- "version": "0.48.6",
7
+ "version": "0.48.7",
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": "9c9cc64e6c8016b01773e9a3a7233729eafc727c"
68
+ "gitHead": "56f9a5ac82a5fd5ad670711182829b625bb3ecd4"
69
69
  }
@@ -170,7 +170,7 @@ export function useDateField({
170
170
 
171
171
  if (slotKey) {
172
172
  const value = getSlot(slotKey);
173
- const { max } = slotsInfo[slotKey];
173
+ const { max, min } = slotsInfo[slotKey];
174
174
 
175
175
  const numberValue = Number(value) || 0;
176
176
 
@@ -198,34 +198,39 @@ export function useDateField({
198
198
  }
199
199
 
200
200
  if (/^\d+$/.test(e.key)) {
201
+ const digit = Number(e.key);
201
202
  const slotValue = parseInt(numberValue.toString() + e.key, 10) || 0;
202
203
 
203
204
  const valueLength = slotValue.toString().length;
204
205
  const maxLength = max.toString().length;
206
+ const isTheLastInput = value.match(/^0+$/) && maxLength === 2 && digit === 0;
205
207
 
206
208
  if (valueLength < maxLength) {
207
- slotValue && updateSlot(slotKey, slotValue);
209
+ if (slotValue || slotValue >= min) {
210
+ updateSlot(slotKey, slotValue);
211
+ if (isTheLastInput) checkInputAndGoNext(slotKey);
212
+ }
208
213
 
209
214
  if (slotValue * 10 > max) {
210
215
  checkInputAndGoNext(slotKey);
211
216
  }
212
217
  } else if (valueLength > maxLength) {
213
- if (Number(e.key) * 10 > max) {
218
+ if (digit * 10 > max) {
214
219
  updateSlot(slotKey, e.key);
215
220
  checkInputAndGoNext(slotKey);
216
- } else {
217
- Number(e.key) && updateSlot(slotKey, e.key);
221
+ } else if (digit || digit >= min) {
222
+ updateSlot(slotKey, e.key);
218
223
  }
219
224
  } else {
220
225
  if (slotValue <= max) {
221
226
  updateSlot(slotKey, slotValue);
222
227
  checkInputAndGoNext(slotKey);
223
228
  } else {
224
- if (Number(e.key) * 10 > max) {
229
+ if (digit * 10 > max) {
225
230
  updateSlot(slotKey, e.key);
226
231
  checkInputAndGoNext(slotKey);
227
- } else {
228
- Number(e.key) && updateSlot(slotKey, e.key);
232
+ } else if (digit || digit >= min) {
233
+ updateSlot(slotKey, e.key);
229
234
  }
230
235
  }
231
236
  }