@salutejs/plasma-new-hope 0.388.0 → 0.388.1-dev.0
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/dist/css/cjs/components/TimePicker/TimePicker.js +19 -0
- package/dist/css/cjs/components/TimePicker/utils/index.js +14 -7
- package/dist/css/es/components/TimePicker/TimePicker.js +19 -0
- package/dist/css/es/components/TimePicker/utils/index.js +14 -7
- package/dist/emotion/cjs/components/TimePicker/TimePicker.js +19 -2
- package/dist/emotion/cjs/components/TimePicker/utils/index.js +9 -7
- package/dist/emotion/es/components/TimePicker/TimePicker.js +19 -2
- package/dist/emotion/es/components/TimePicker/utils/index.js +9 -7
- package/dist/styled-components/cjs/components/TimePicker/TimePicker.js +19 -2
- package/dist/styled-components/cjs/components/TimePicker/utils/index.js +9 -7
- package/dist/styled-components/es/components/TimePicker/TimePicker.js +19 -2
- package/dist/styled-components/es/components/TimePicker/utils/index.js +9 -7
- package/package.json +6 -6
- package/types/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/types/components/TimePicker/utils/index.d.ts.map +1 -1
|
@@ -245,6 +245,14 @@ var timePickerRoot = function timePickerRoot(Root) {
|
|
|
245
245
|
var handleInputChange = function handleInputChange(event) {
|
|
246
246
|
var input = event.target.value;
|
|
247
247
|
var cursorPos = event.target.selectionStart;
|
|
248
|
+
|
|
249
|
+
// Мобильные клавиатуры могут удалять разделитель без события keydown.
|
|
250
|
+
if (cursorPos !== null && displayValue[cursorPos] === index.delimiter && displayValue === "".concat(input.slice(0, cursorPos)).concat(index.delimiter).concat(input.slice(cursorPos))) {
|
|
251
|
+
var isForwardDeletion = event.nativeEvent.inputType === 'deleteContentForward';
|
|
252
|
+
var deletionIndex = isForwardDeletion ? cursorPos : Math.max(0, cursorPos - 1);
|
|
253
|
+
input = isForwardDeletion ? "".concat(input.slice(0, cursorPos)).concat(index.delimiter).concat(input.slice(cursorPos + 1)) : "".concat(input.slice(0, deletionIndex)).concat(index.delimiter).concat(input.slice(cursorPos));
|
|
254
|
+
cursorPos = isForwardDeletion ? cursorPos + 1 : deletionIndex;
|
|
255
|
+
}
|
|
248
256
|
var parsed = hasTimeFormat ? index.processTimeInput12(input, format, cursorPos, meridiem$1) : _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, index.processTimeInput(input, format, cursorPos)), {}, {
|
|
249
257
|
displayString: null
|
|
250
258
|
});
|
|
@@ -285,6 +293,17 @@ var timePickerRoot = function timePickerRoot(Root) {
|
|
|
285
293
|
});
|
|
286
294
|
};
|
|
287
295
|
var handleKeyDown = function handleKeyDown(event) {
|
|
296
|
+
var input = event.currentTarget;
|
|
297
|
+
var selectionStart = input.selectionStart,
|
|
298
|
+
selectionEnd = input.selectionEnd;
|
|
299
|
+
if (selectionStart !== null && selectionStart === selectionEnd) {
|
|
300
|
+
if (event.key === 'Backspace' && input.value[selectionStart - 1] === index.delimiter) {
|
|
301
|
+
input.setSelectionRange(selectionStart - 1, selectionStart - 1);
|
|
302
|
+
}
|
|
303
|
+
if (event.key === 'Delete' && input.value[selectionStart] === index.delimiter) {
|
|
304
|
+
input.setSelectionRange(selectionStart + 1, selectionStart + 1);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
288
307
|
if (event.key === 'Enter' && !isInnerOpen) {
|
|
289
308
|
event.preventDefault();
|
|
290
309
|
setIsInnerOpen(true);
|
|
@@ -73,7 +73,9 @@ var parseTimeSegments = function parseTimeSegments(input, format) {
|
|
|
73
73
|
return normalizeTimeSegment('HH', segment);
|
|
74
74
|
};
|
|
75
75
|
var explicitMeridiem = (_input$match = input.match(/(?:^|[^a-z])(AM|PM)\s*$/i)) === null || _input$match === void 0 ? void 0 : _input$match[1].toUpperCase();
|
|
76
|
-
var
|
|
76
|
+
var inputSegments = input.split(delimiter).map(function (segment) {
|
|
77
|
+
return segment.replace(/\D/g, '');
|
|
78
|
+
});
|
|
77
79
|
var tokens = format.split(delimiter);
|
|
78
80
|
var values = {
|
|
79
81
|
hh: null,
|
|
@@ -81,11 +83,13 @@ var parseTimeSegments = function parseTimeSegments(input, format) {
|
|
|
81
83
|
ss: null
|
|
82
84
|
};
|
|
83
85
|
var segments = [];
|
|
84
|
-
var
|
|
86
|
+
var remainingDigits = '';
|
|
85
87
|
var meridiem;
|
|
86
|
-
tokens.forEach(function (token) {
|
|
87
|
-
var
|
|
88
|
-
|
|
88
|
+
tokens.forEach(function (token, index) {
|
|
89
|
+
var _inputSegments$index;
|
|
90
|
+
var digits = "".concat(remainingDigits).concat((_inputSegments$index = inputSegments[index]) !== null && _inputSegments$index !== void 0 ? _inputSegments$index : '');
|
|
91
|
+
var segmentDigits = digits.slice(0, 2);
|
|
92
|
+
remainingDigits = digits.slice(2);
|
|
89
93
|
var normalized = token === 'HH' ? normalizeHours(segmentDigits) : normalizeTimeSegment(token, segmentDigits);
|
|
90
94
|
if (token === 'HH') {
|
|
91
95
|
meridiem = normalized.meridiem;
|
|
@@ -93,10 +97,13 @@ var parseTimeSegments = function parseTimeSegments(input, format) {
|
|
|
93
97
|
values[token.toLowerCase()] = normalized.value;
|
|
94
98
|
segments.push(normalized.text);
|
|
95
99
|
});
|
|
100
|
+
var text = segments.map(function (segment, index) {
|
|
101
|
+
return index < tokens.length - 1 && (segment.length === 2 || segments.slice(index + 1).some(Boolean)) ? "".concat(segment).concat(delimiter) : segment;
|
|
102
|
+
}).join('');
|
|
96
103
|
return {
|
|
97
104
|
values: values,
|
|
98
105
|
segments: segments,
|
|
99
|
-
text:
|
|
106
|
+
text: text,
|
|
100
107
|
meridiem: explicitMeridiem !== null && explicitMeridiem !== void 0 ? explicitMeridiem : meridiem
|
|
101
108
|
};
|
|
102
109
|
};
|
|
@@ -214,7 +221,7 @@ var processTimeInput12 = function processTimeInput12(input, format, cursorPositi
|
|
|
214
221
|
innerSegments[0] = values.hh.toString().padStart(2, '0');
|
|
215
222
|
}
|
|
216
223
|
return {
|
|
217
|
-
innerString: innerSegments.
|
|
224
|
+
innerString: innerSegments.slice(0, text.split(delimiter).length).join(delimiter),
|
|
218
225
|
displayString: text,
|
|
219
226
|
values: values,
|
|
220
227
|
newCursorPosition: getCursorPosition(cursorPosition !== null && cursorPosition !== void 0 ? cursorPosition : 0, input.length, text.length)
|
|
@@ -236,6 +236,14 @@ var timePickerRoot = function timePickerRoot(Root) {
|
|
|
236
236
|
var handleInputChange = function handleInputChange(event) {
|
|
237
237
|
var input = event.target.value;
|
|
238
238
|
var cursorPos = event.target.selectionStart;
|
|
239
|
+
|
|
240
|
+
// Мобильные клавиатуры могут удалять разделитель без события keydown.
|
|
241
|
+
if (cursorPos !== null && displayValue[cursorPos] === delimiter && displayValue === "".concat(input.slice(0, cursorPos)).concat(delimiter).concat(input.slice(cursorPos))) {
|
|
242
|
+
var isForwardDeletion = event.nativeEvent.inputType === 'deleteContentForward';
|
|
243
|
+
var deletionIndex = isForwardDeletion ? cursorPos : Math.max(0, cursorPos - 1);
|
|
244
|
+
input = isForwardDeletion ? "".concat(input.slice(0, cursorPos)).concat(delimiter).concat(input.slice(cursorPos + 1)) : "".concat(input.slice(0, deletionIndex)).concat(delimiter).concat(input.slice(cursorPos));
|
|
245
|
+
cursorPos = isForwardDeletion ? cursorPos + 1 : deletionIndex;
|
|
246
|
+
}
|
|
239
247
|
var parsed = hasTimeFormat ? processTimeInput12(input, format, cursorPos, meridiem) : _objectSpread2(_objectSpread2({}, processTimeInput(input, format, cursorPos)), {}, {
|
|
240
248
|
displayString: null
|
|
241
249
|
});
|
|
@@ -276,6 +284,17 @@ var timePickerRoot = function timePickerRoot(Root) {
|
|
|
276
284
|
});
|
|
277
285
|
};
|
|
278
286
|
var handleKeyDown = function handleKeyDown(event) {
|
|
287
|
+
var input = event.currentTarget;
|
|
288
|
+
var selectionStart = input.selectionStart,
|
|
289
|
+
selectionEnd = input.selectionEnd;
|
|
290
|
+
if (selectionStart !== null && selectionStart === selectionEnd) {
|
|
291
|
+
if (event.key === 'Backspace' && input.value[selectionStart - 1] === delimiter) {
|
|
292
|
+
input.setSelectionRange(selectionStart - 1, selectionStart - 1);
|
|
293
|
+
}
|
|
294
|
+
if (event.key === 'Delete' && input.value[selectionStart] === delimiter) {
|
|
295
|
+
input.setSelectionRange(selectionStart + 1, selectionStart + 1);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
279
298
|
if (event.key === 'Enter' && !isInnerOpen) {
|
|
280
299
|
event.preventDefault();
|
|
281
300
|
setIsInnerOpen(true);
|
|
@@ -69,7 +69,9 @@ var parseTimeSegments = function parseTimeSegments(input, format) {
|
|
|
69
69
|
return normalizeTimeSegment('HH', segment);
|
|
70
70
|
};
|
|
71
71
|
var explicitMeridiem = (_input$match = input.match(/(?:^|[^a-z])(AM|PM)\s*$/i)) === null || _input$match === void 0 ? void 0 : _input$match[1].toUpperCase();
|
|
72
|
-
var
|
|
72
|
+
var inputSegments = input.split(delimiter).map(function (segment) {
|
|
73
|
+
return segment.replace(/\D/g, '');
|
|
74
|
+
});
|
|
73
75
|
var tokens = format.split(delimiter);
|
|
74
76
|
var values = {
|
|
75
77
|
hh: null,
|
|
@@ -77,11 +79,13 @@ var parseTimeSegments = function parseTimeSegments(input, format) {
|
|
|
77
79
|
ss: null
|
|
78
80
|
};
|
|
79
81
|
var segments = [];
|
|
80
|
-
var
|
|
82
|
+
var remainingDigits = '';
|
|
81
83
|
var meridiem;
|
|
82
|
-
tokens.forEach(function (token) {
|
|
83
|
-
var
|
|
84
|
-
|
|
84
|
+
tokens.forEach(function (token, index) {
|
|
85
|
+
var _inputSegments$index;
|
|
86
|
+
var digits = "".concat(remainingDigits).concat((_inputSegments$index = inputSegments[index]) !== null && _inputSegments$index !== void 0 ? _inputSegments$index : '');
|
|
87
|
+
var segmentDigits = digits.slice(0, 2);
|
|
88
|
+
remainingDigits = digits.slice(2);
|
|
85
89
|
var normalized = token === 'HH' ? normalizeHours(segmentDigits) : normalizeTimeSegment(token, segmentDigits);
|
|
86
90
|
if (token === 'HH') {
|
|
87
91
|
meridiem = normalized.meridiem;
|
|
@@ -89,10 +93,13 @@ var parseTimeSegments = function parseTimeSegments(input, format) {
|
|
|
89
93
|
values[token.toLowerCase()] = normalized.value;
|
|
90
94
|
segments.push(normalized.text);
|
|
91
95
|
});
|
|
96
|
+
var text = segments.map(function (segment, index) {
|
|
97
|
+
return index < tokens.length - 1 && (segment.length === 2 || segments.slice(index + 1).some(Boolean)) ? "".concat(segment).concat(delimiter) : segment;
|
|
98
|
+
}).join('');
|
|
92
99
|
return {
|
|
93
100
|
values: values,
|
|
94
101
|
segments: segments,
|
|
95
|
-
text:
|
|
102
|
+
text: text,
|
|
96
103
|
meridiem: explicitMeridiem !== null && explicitMeridiem !== void 0 ? explicitMeridiem : meridiem
|
|
97
104
|
};
|
|
98
105
|
};
|
|
@@ -210,7 +217,7 @@ var processTimeInput12 = function processTimeInput12(input, format, cursorPositi
|
|
|
210
217
|
innerSegments[0] = values.hh.toString().padStart(2, '0');
|
|
211
218
|
}
|
|
212
219
|
return {
|
|
213
|
-
innerString: innerSegments.
|
|
220
|
+
innerString: innerSegments.slice(0, text.split(delimiter).length).join(delimiter),
|
|
214
221
|
displayString: text,
|
|
215
222
|
values: values,
|
|
216
223
|
newCursorPosition: getCursorPosition(cursorPosition !== null && cursorPosition !== void 0 ? cursorPosition : 0, input.length, text.length)
|
|
@@ -214,8 +214,15 @@ const timePickerRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ className
|
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
216
|
const handleInputChange = (event)=>{
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
let input = event.target.value;
|
|
218
|
+
let cursorPos = event.target.selectionStart;
|
|
219
|
+
// Мобильные клавиатуры могут удалять разделитель без события keydown.
|
|
220
|
+
if (cursorPos !== null && displayValue[cursorPos] === _utils2.delimiter && displayValue === `${input.slice(0, cursorPos)}${_utils2.delimiter}${input.slice(cursorPos)}`) {
|
|
221
|
+
const isForwardDeletion = event.nativeEvent.inputType === 'deleteContentForward';
|
|
222
|
+
const deletionIndex = isForwardDeletion ? cursorPos : Math.max(0, cursorPos - 1);
|
|
223
|
+
input = isForwardDeletion ? `${input.slice(0, cursorPos)}${_utils2.delimiter}${input.slice(cursorPos + 1)}` : `${input.slice(0, deletionIndex)}${_utils2.delimiter}${input.slice(cursorPos)}`;
|
|
224
|
+
cursorPos = isForwardDeletion ? cursorPos + 1 : deletionIndex;
|
|
225
|
+
}
|
|
219
226
|
const parsed = hasTimeFormat ? (0, _utils2.processTimeInput12)(input, format, cursorPos, meridiem) : {
|
|
220
227
|
...(0, _utils2.processTimeInput)(input, format, cursorPos),
|
|
221
228
|
displayString: null
|
|
@@ -255,6 +262,16 @@ const timePickerRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ className
|
|
|
255
262
|
});
|
|
256
263
|
};
|
|
257
264
|
const handleKeyDown = (event)=>{
|
|
265
|
+
const input = event.currentTarget;
|
|
266
|
+
const { selectionStart, selectionEnd } = input;
|
|
267
|
+
if (selectionStart !== null && selectionStart === selectionEnd) {
|
|
268
|
+
if (event.key === 'Backspace' && input.value[selectionStart - 1] === _utils2.delimiter) {
|
|
269
|
+
input.setSelectionRange(selectionStart - 1, selectionStart - 1);
|
|
270
|
+
}
|
|
271
|
+
if (event.key === 'Delete' && input.value[selectionStart] === _utils2.delimiter) {
|
|
272
|
+
input.setSelectionRange(selectionStart + 1, selectionStart + 1);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
258
275
|
if (event.key === 'Enter' && !isInnerOpen) {
|
|
259
276
|
event.preventDefault();
|
|
260
277
|
setIsInnerOpen(true);
|
|
@@ -104,7 +104,7 @@ const normalizeTimeSegment = (type, input)=>{
|
|
|
104
104
|
};
|
|
105
105
|
const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeTimeSegment('HH', segment))=>{
|
|
106
106
|
const explicitMeridiem = input.match(/(?:^|[^a-z])(AM|PM)\s*$/i)?.[1].toUpperCase();
|
|
107
|
-
const
|
|
107
|
+
const inputSegments = input.split(delimiter).map((segment)=>segment.replace(/\D/g, ''));
|
|
108
108
|
const tokens = format.split(delimiter);
|
|
109
109
|
const values = {
|
|
110
110
|
hh: null,
|
|
@@ -112,11 +112,12 @@ const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeT
|
|
|
112
112
|
ss: null
|
|
113
113
|
};
|
|
114
114
|
const segments = [];
|
|
115
|
-
let
|
|
115
|
+
let remainingDigits = '';
|
|
116
116
|
let meridiem;
|
|
117
|
-
tokens.forEach((token)=>{
|
|
118
|
-
const
|
|
119
|
-
|
|
117
|
+
tokens.forEach((token, index)=>{
|
|
118
|
+
const digits = `${remainingDigits}${inputSegments[index] ?? ''}`;
|
|
119
|
+
const segmentDigits = digits.slice(0, 2);
|
|
120
|
+
remainingDigits = digits.slice(2);
|
|
120
121
|
const normalized = token === 'HH' ? normalizeHours(segmentDigits) : normalizeTimeSegment(token, segmentDigits);
|
|
121
122
|
if (token === 'HH') {
|
|
122
123
|
meridiem = normalized.meridiem;
|
|
@@ -124,10 +125,11 @@ const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeT
|
|
|
124
125
|
values[token.toLowerCase()] = normalized.value;
|
|
125
126
|
segments.push(normalized.text);
|
|
126
127
|
});
|
|
128
|
+
const text = segments.map((segment, index)=>index < tokens.length - 1 && (segment.length === 2 || segments.slice(index + 1).some(Boolean)) ? `${segment}${delimiter}` : segment).join('');
|
|
127
129
|
return {
|
|
128
130
|
values,
|
|
129
131
|
segments,
|
|
130
|
-
text
|
|
132
|
+
text,
|
|
131
133
|
meridiem: explicitMeridiem ?? meridiem
|
|
132
134
|
};
|
|
133
135
|
};
|
|
@@ -215,7 +217,7 @@ const processTimeInput12 = (input, format, cursorPosition, currentMeridiem)=>{
|
|
|
215
217
|
innerSegments[0] = values.hh.toString().padStart(2, '0');
|
|
216
218
|
}
|
|
217
219
|
return {
|
|
218
|
-
innerString: innerSegments.
|
|
220
|
+
innerString: innerSegments.slice(0, text.split(delimiter).length).join(delimiter),
|
|
219
221
|
displayString: text,
|
|
220
222
|
values,
|
|
221
223
|
newCursorPosition: getCursorPosition(cursorPosition ?? 0, input.length, text.length)
|
|
@@ -150,8 +150,15 @@ export const timePickerRoot = (Root)=>/*#__PURE__*/ forwardRef(({ className, //
|
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
152
|
const handleInputChange = (event)=>{
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
let input = event.target.value;
|
|
154
|
+
let cursorPos = event.target.selectionStart;
|
|
155
|
+
// Мобильные клавиатуры могут удалять разделитель без события keydown.
|
|
156
|
+
if (cursorPos !== null && displayValue[cursorPos] === delimiter && displayValue === `${input.slice(0, cursorPos)}${delimiter}${input.slice(cursorPos)}`) {
|
|
157
|
+
const isForwardDeletion = event.nativeEvent.inputType === 'deleteContentForward';
|
|
158
|
+
const deletionIndex = isForwardDeletion ? cursorPos : Math.max(0, cursorPos - 1);
|
|
159
|
+
input = isForwardDeletion ? `${input.slice(0, cursorPos)}${delimiter}${input.slice(cursorPos + 1)}` : `${input.slice(0, deletionIndex)}${delimiter}${input.slice(cursorPos)}`;
|
|
160
|
+
cursorPos = isForwardDeletion ? cursorPos + 1 : deletionIndex;
|
|
161
|
+
}
|
|
155
162
|
const parsed = hasTimeFormat ? processTimeInput12(input, format, cursorPos, meridiem) : {
|
|
156
163
|
...processTimeInput(input, format, cursorPos),
|
|
157
164
|
displayString: null
|
|
@@ -191,6 +198,16 @@ export const timePickerRoot = (Root)=>/*#__PURE__*/ forwardRef(({ className, //
|
|
|
191
198
|
});
|
|
192
199
|
};
|
|
193
200
|
const handleKeyDown = (event)=>{
|
|
201
|
+
const input = event.currentTarget;
|
|
202
|
+
const { selectionStart, selectionEnd } = input;
|
|
203
|
+
if (selectionStart !== null && selectionStart === selectionEnd) {
|
|
204
|
+
if (event.key === 'Backspace' && input.value[selectionStart - 1] === delimiter) {
|
|
205
|
+
input.setSelectionRange(selectionStart - 1, selectionStart - 1);
|
|
206
|
+
}
|
|
207
|
+
if (event.key === 'Delete' && input.value[selectionStart] === delimiter) {
|
|
208
|
+
input.setSelectionRange(selectionStart + 1, selectionStart + 1);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
194
211
|
if (event.key === 'Enter' && !isInnerOpen) {
|
|
195
212
|
event.preventDefault();
|
|
196
213
|
setIsInnerOpen(true);
|
|
@@ -68,7 +68,7 @@ export const normalizeTimeSegment = (type, input)=>{
|
|
|
68
68
|
};
|
|
69
69
|
const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeTimeSegment('HH', segment))=>{
|
|
70
70
|
const explicitMeridiem = input.match(/(?:^|[^a-z])(AM|PM)\s*$/i)?.[1].toUpperCase();
|
|
71
|
-
const
|
|
71
|
+
const inputSegments = input.split(delimiter).map((segment)=>segment.replace(/\D/g, ''));
|
|
72
72
|
const tokens = format.split(delimiter);
|
|
73
73
|
const values = {
|
|
74
74
|
hh: null,
|
|
@@ -76,11 +76,12 @@ const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeT
|
|
|
76
76
|
ss: null
|
|
77
77
|
};
|
|
78
78
|
const segments = [];
|
|
79
|
-
let
|
|
79
|
+
let remainingDigits = '';
|
|
80
80
|
let meridiem;
|
|
81
|
-
tokens.forEach((token)=>{
|
|
82
|
-
const
|
|
83
|
-
|
|
81
|
+
tokens.forEach((token, index)=>{
|
|
82
|
+
const digits = `${remainingDigits}${inputSegments[index] ?? ''}`;
|
|
83
|
+
const segmentDigits = digits.slice(0, 2);
|
|
84
|
+
remainingDigits = digits.slice(2);
|
|
84
85
|
const normalized = token === 'HH' ? normalizeHours(segmentDigits) : normalizeTimeSegment(token, segmentDigits);
|
|
85
86
|
if (token === 'HH') {
|
|
86
87
|
meridiem = normalized.meridiem;
|
|
@@ -88,10 +89,11 @@ const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeT
|
|
|
88
89
|
values[token.toLowerCase()] = normalized.value;
|
|
89
90
|
segments.push(normalized.text);
|
|
90
91
|
});
|
|
92
|
+
const text = segments.map((segment, index)=>index < tokens.length - 1 && (segment.length === 2 || segments.slice(index + 1).some(Boolean)) ? `${segment}${delimiter}` : segment).join('');
|
|
91
93
|
return {
|
|
92
94
|
values,
|
|
93
95
|
segments,
|
|
94
|
-
text
|
|
96
|
+
text,
|
|
95
97
|
meridiem: explicitMeridiem ?? meridiem
|
|
96
98
|
};
|
|
97
99
|
};
|
|
@@ -188,7 +190,7 @@ export const processTimeInput = (input, format, cursorPosition)=>{
|
|
|
188
190
|
innerSegments[0] = values.hh.toString().padStart(2, '0');
|
|
189
191
|
}
|
|
190
192
|
return {
|
|
191
|
-
innerString: innerSegments.
|
|
193
|
+
innerString: innerSegments.slice(0, text.split(delimiter).length).join(delimiter),
|
|
192
194
|
displayString: text,
|
|
193
195
|
values,
|
|
194
196
|
newCursorPosition: getCursorPosition(cursorPosition ?? 0, input.length, text.length)
|
|
@@ -214,8 +214,15 @@ const timePickerRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ className
|
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
216
|
const handleInputChange = (event)=>{
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
let input = event.target.value;
|
|
218
|
+
let cursorPos = event.target.selectionStart;
|
|
219
|
+
// Мобильные клавиатуры могут удалять разделитель без события keydown.
|
|
220
|
+
if (cursorPos !== null && displayValue[cursorPos] === _utils2.delimiter && displayValue === `${input.slice(0, cursorPos)}${_utils2.delimiter}${input.slice(cursorPos)}`) {
|
|
221
|
+
const isForwardDeletion = event.nativeEvent.inputType === 'deleteContentForward';
|
|
222
|
+
const deletionIndex = isForwardDeletion ? cursorPos : Math.max(0, cursorPos - 1);
|
|
223
|
+
input = isForwardDeletion ? `${input.slice(0, cursorPos)}${_utils2.delimiter}${input.slice(cursorPos + 1)}` : `${input.slice(0, deletionIndex)}${_utils2.delimiter}${input.slice(cursorPos)}`;
|
|
224
|
+
cursorPos = isForwardDeletion ? cursorPos + 1 : deletionIndex;
|
|
225
|
+
}
|
|
219
226
|
const parsed = hasTimeFormat ? (0, _utils2.processTimeInput12)(input, format, cursorPos, meridiem) : {
|
|
220
227
|
...(0, _utils2.processTimeInput)(input, format, cursorPos),
|
|
221
228
|
displayString: null
|
|
@@ -255,6 +262,16 @@ const timePickerRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ className
|
|
|
255
262
|
});
|
|
256
263
|
};
|
|
257
264
|
const handleKeyDown = (event)=>{
|
|
265
|
+
const input = event.currentTarget;
|
|
266
|
+
const { selectionStart, selectionEnd } = input;
|
|
267
|
+
if (selectionStart !== null && selectionStart === selectionEnd) {
|
|
268
|
+
if (event.key === 'Backspace' && input.value[selectionStart - 1] === _utils2.delimiter) {
|
|
269
|
+
input.setSelectionRange(selectionStart - 1, selectionStart - 1);
|
|
270
|
+
}
|
|
271
|
+
if (event.key === 'Delete' && input.value[selectionStart] === _utils2.delimiter) {
|
|
272
|
+
input.setSelectionRange(selectionStart + 1, selectionStart + 1);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
258
275
|
if (event.key === 'Enter' && !isInnerOpen) {
|
|
259
276
|
event.preventDefault();
|
|
260
277
|
setIsInnerOpen(true);
|
|
@@ -104,7 +104,7 @@ const normalizeTimeSegment = (type, input)=>{
|
|
|
104
104
|
};
|
|
105
105
|
const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeTimeSegment('HH', segment))=>{
|
|
106
106
|
const explicitMeridiem = input.match(/(?:^|[^a-z])(AM|PM)\s*$/i)?.[1].toUpperCase();
|
|
107
|
-
const
|
|
107
|
+
const inputSegments = input.split(delimiter).map((segment)=>segment.replace(/\D/g, ''));
|
|
108
108
|
const tokens = format.split(delimiter);
|
|
109
109
|
const values = {
|
|
110
110
|
hh: null,
|
|
@@ -112,11 +112,12 @@ const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeT
|
|
|
112
112
|
ss: null
|
|
113
113
|
};
|
|
114
114
|
const segments = [];
|
|
115
|
-
let
|
|
115
|
+
let remainingDigits = '';
|
|
116
116
|
let meridiem;
|
|
117
|
-
tokens.forEach((token)=>{
|
|
118
|
-
const
|
|
119
|
-
|
|
117
|
+
tokens.forEach((token, index)=>{
|
|
118
|
+
const digits = `${remainingDigits}${inputSegments[index] ?? ''}`;
|
|
119
|
+
const segmentDigits = digits.slice(0, 2);
|
|
120
|
+
remainingDigits = digits.slice(2);
|
|
120
121
|
const normalized = token === 'HH' ? normalizeHours(segmentDigits) : normalizeTimeSegment(token, segmentDigits);
|
|
121
122
|
if (token === 'HH') {
|
|
122
123
|
meridiem = normalized.meridiem;
|
|
@@ -124,10 +125,11 @@ const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeT
|
|
|
124
125
|
values[token.toLowerCase()] = normalized.value;
|
|
125
126
|
segments.push(normalized.text);
|
|
126
127
|
});
|
|
128
|
+
const text = segments.map((segment, index)=>index < tokens.length - 1 && (segment.length === 2 || segments.slice(index + 1).some(Boolean)) ? `${segment}${delimiter}` : segment).join('');
|
|
127
129
|
return {
|
|
128
130
|
values,
|
|
129
131
|
segments,
|
|
130
|
-
text
|
|
132
|
+
text,
|
|
131
133
|
meridiem: explicitMeridiem ?? meridiem
|
|
132
134
|
};
|
|
133
135
|
};
|
|
@@ -215,7 +217,7 @@ const processTimeInput12 = (input, format, cursorPosition, currentMeridiem)=>{
|
|
|
215
217
|
innerSegments[0] = values.hh.toString().padStart(2, '0');
|
|
216
218
|
}
|
|
217
219
|
return {
|
|
218
|
-
innerString: innerSegments.
|
|
220
|
+
innerString: innerSegments.slice(0, text.split(delimiter).length).join(delimiter),
|
|
219
221
|
displayString: text,
|
|
220
222
|
values,
|
|
221
223
|
newCursorPosition: getCursorPosition(cursorPosition ?? 0, input.length, text.length)
|
|
@@ -150,8 +150,15 @@ export const timePickerRoot = (Root)=>/*#__PURE__*/ forwardRef(({ className, //
|
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
152
|
const handleInputChange = (event)=>{
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
let input = event.target.value;
|
|
154
|
+
let cursorPos = event.target.selectionStart;
|
|
155
|
+
// Мобильные клавиатуры могут удалять разделитель без события keydown.
|
|
156
|
+
if (cursorPos !== null && displayValue[cursorPos] === delimiter && displayValue === `${input.slice(0, cursorPos)}${delimiter}${input.slice(cursorPos)}`) {
|
|
157
|
+
const isForwardDeletion = event.nativeEvent.inputType === 'deleteContentForward';
|
|
158
|
+
const deletionIndex = isForwardDeletion ? cursorPos : Math.max(0, cursorPos - 1);
|
|
159
|
+
input = isForwardDeletion ? `${input.slice(0, cursorPos)}${delimiter}${input.slice(cursorPos + 1)}` : `${input.slice(0, deletionIndex)}${delimiter}${input.slice(cursorPos)}`;
|
|
160
|
+
cursorPos = isForwardDeletion ? cursorPos + 1 : deletionIndex;
|
|
161
|
+
}
|
|
155
162
|
const parsed = hasTimeFormat ? processTimeInput12(input, format, cursorPos, meridiem) : {
|
|
156
163
|
...processTimeInput(input, format, cursorPos),
|
|
157
164
|
displayString: null
|
|
@@ -191,6 +198,16 @@ export const timePickerRoot = (Root)=>/*#__PURE__*/ forwardRef(({ className, //
|
|
|
191
198
|
});
|
|
192
199
|
};
|
|
193
200
|
const handleKeyDown = (event)=>{
|
|
201
|
+
const input = event.currentTarget;
|
|
202
|
+
const { selectionStart, selectionEnd } = input;
|
|
203
|
+
if (selectionStart !== null && selectionStart === selectionEnd) {
|
|
204
|
+
if (event.key === 'Backspace' && input.value[selectionStart - 1] === delimiter) {
|
|
205
|
+
input.setSelectionRange(selectionStart - 1, selectionStart - 1);
|
|
206
|
+
}
|
|
207
|
+
if (event.key === 'Delete' && input.value[selectionStart] === delimiter) {
|
|
208
|
+
input.setSelectionRange(selectionStart + 1, selectionStart + 1);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
194
211
|
if (event.key === 'Enter' && !isInnerOpen) {
|
|
195
212
|
event.preventDefault();
|
|
196
213
|
setIsInnerOpen(true);
|
|
@@ -68,7 +68,7 @@ export const normalizeTimeSegment = (type, input)=>{
|
|
|
68
68
|
};
|
|
69
69
|
const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeTimeSegment('HH', segment))=>{
|
|
70
70
|
const explicitMeridiem = input.match(/(?:^|[^a-z])(AM|PM)\s*$/i)?.[1].toUpperCase();
|
|
71
|
-
const
|
|
71
|
+
const inputSegments = input.split(delimiter).map((segment)=>segment.replace(/\D/g, ''));
|
|
72
72
|
const tokens = format.split(delimiter);
|
|
73
73
|
const values = {
|
|
74
74
|
hh: null,
|
|
@@ -76,11 +76,12 @@ const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeT
|
|
|
76
76
|
ss: null
|
|
77
77
|
};
|
|
78
78
|
const segments = [];
|
|
79
|
-
let
|
|
79
|
+
let remainingDigits = '';
|
|
80
80
|
let meridiem;
|
|
81
|
-
tokens.forEach((token)=>{
|
|
82
|
-
const
|
|
83
|
-
|
|
81
|
+
tokens.forEach((token, index)=>{
|
|
82
|
+
const digits = `${remainingDigits}${inputSegments[index] ?? ''}`;
|
|
83
|
+
const segmentDigits = digits.slice(0, 2);
|
|
84
|
+
remainingDigits = digits.slice(2);
|
|
84
85
|
const normalized = token === 'HH' ? normalizeHours(segmentDigits) : normalizeTimeSegment(token, segmentDigits);
|
|
85
86
|
if (token === 'HH') {
|
|
86
87
|
meridiem = normalized.meridiem;
|
|
@@ -88,10 +89,11 @@ const parseTimeSegments = (input, format, normalizeHours = (segment)=>normalizeT
|
|
|
88
89
|
values[token.toLowerCase()] = normalized.value;
|
|
89
90
|
segments.push(normalized.text);
|
|
90
91
|
});
|
|
92
|
+
const text = segments.map((segment, index)=>index < tokens.length - 1 && (segment.length === 2 || segments.slice(index + 1).some(Boolean)) ? `${segment}${delimiter}` : segment).join('');
|
|
91
93
|
return {
|
|
92
94
|
values,
|
|
93
95
|
segments,
|
|
94
|
-
text
|
|
96
|
+
text,
|
|
95
97
|
meridiem: explicitMeridiem ?? meridiem
|
|
96
98
|
};
|
|
97
99
|
};
|
|
@@ -188,7 +190,7 @@ export const processTimeInput = (input, format, cursorPosition)=>{
|
|
|
188
190
|
innerSegments[0] = values.hh.toString().padStart(2, '0');
|
|
189
191
|
}
|
|
190
192
|
return {
|
|
191
|
-
innerString: innerSegments.
|
|
193
|
+
innerString: innerSegments.slice(0, text.split(delimiter).length).join(delimiter),
|
|
192
194
|
displayString: text,
|
|
193
195
|
values,
|
|
194
196
|
newCursorPosition: getCursorPosition(cursorPosition ?? 0, input.length, text.length)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
|
3
|
-
"version": "0.388.0",
|
|
3
|
+
"version": "0.388.1-dev.0",
|
|
4
4
|
"description": "Salute Design System blueprint",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -97,9 +97,9 @@
|
|
|
97
97
|
"@rollup/plugin-babel": "^6.0.4",
|
|
98
98
|
"@rollup/plugin-commonjs": "^25.0.4",
|
|
99
99
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
100
|
-
"@salutejs/plasma-cy-utils": "0.
|
|
101
|
-
"@salutejs/plasma-sb-utils": "0.251.0",
|
|
102
|
-
"@salutejs/plasma-themes": "0.
|
|
100
|
+
"@salutejs/plasma-cy-utils": "0.179.0-dev.0",
|
|
101
|
+
"@salutejs/plasma-sb-utils": "0.251.1-dev.0",
|
|
102
|
+
"@salutejs/plasma-themes": "0.70.0-dev.0",
|
|
103
103
|
"@types/lodash": "^4.14.191",
|
|
104
104
|
"@types/lodash.chunk": "4.2.9",
|
|
105
105
|
"@types/lodash.throttle": "4.1.6",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"@linaria/react": "5.0.3",
|
|
131
131
|
"@popperjs/core": "2.11.8",
|
|
132
132
|
"@salutejs/input-core": "2.2.0",
|
|
133
|
-
"@salutejs/plasma-typo": "0.
|
|
133
|
+
"@salutejs/plasma-typo": "0.60.0-dev.0",
|
|
134
134
|
"@salutejs/react-maskinput": "3.4.0",
|
|
135
135
|
"@tanstack/react-table": "8.21.2",
|
|
136
136
|
"@tanstack/react-virtual": "3.13.2",
|
|
@@ -153,5 +153,5 @@
|
|
|
153
153
|
"sideEffects": [
|
|
154
154
|
"*.css"
|
|
155
155
|
],
|
|
156
|
-
"gitHead": "
|
|
156
|
+
"gitHead": "ed4c47d66e4b9e902ba7b56c72b5df1da7230489"
|
|
157
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimePicker.d.ts","sourceRoot":"","sources":["../../../src/components/TimePicker/TimePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAGvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQ7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAoBrD,eAAO,MAAM,cAAc,SACjB,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,cAAc,GAAG,UAAU,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"TimePicker.d.ts","sourceRoot":"","sources":["../../../src/components/TimePicker/TimePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAGvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQ7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAoBrD,eAAO,MAAM,cAAc,SACjB,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,cAAc,GAAG,UAAU,CAAC,CAAC,6FAke7F,CAAC;AAEN,eAAO,MAAM,gBAAgB;;;mBApenB,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,cAAc,GAAG,UAAU,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmgBjG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/TimePicker/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACvB;AAED,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B,eAAO,MAAM,KAAK,WAAY,MAAM,yBAAkB,MAAM,EAE3D,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,IAAI,GAAG,IAAI,GAAG,IAAI,SAAS,MAAM,KAAG,iBA8D9E,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/TimePicker/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACvB;AAED,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B,eAAO,MAAM,KAAK,WAAY,MAAM,yBAAkB,MAAM,EAE3D,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,IAAI,GAAG,IAAI,GAAG,IAAI,SAAS,MAAM,KAAG,iBA8D9E,CAAC;AAqDF,eAAO,MAAM,gBAAgB,UAClB,MAAM,UACL,OAAO,GAAG,UAAU,kBACZ,MAAM,GAAG,IAAI,KAC9B;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAC;IAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;CAQ7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,eAAgB,MAAM,KAAG,QAI9D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,eAAgB,MAAM,KAAG,MAenD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,UAAW,MAAM,KAAG,iBAyBtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,UACpB,MAAM,UACL,OAAO,GAAG,UAAU,kBACZ,MAAM,GAAG,IAAI,mBACZ,QAAQ,KAC1B;IACC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAoBpC,CAAC"}
|