@alfalab/core-components-time-input 2.1.1 → 2.1.2
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 +2 -2
- package/utils/format.js +10 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-time-input",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alfalab/core-components-input": "^11.1.
|
|
18
|
+
"@alfalab/core-components-input": "^11.1.2",
|
|
19
19
|
"@alfalab/core-components-icon-button": "^6.0.2"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/utils/format.js
CHANGED
|
@@ -15,12 +15,16 @@ var isValidTimeFormat = function (value) {
|
|
|
15
15
|
}
|
|
16
16
|
return true;
|
|
17
17
|
};
|
|
18
|
-
var isValidInputValue = function (inputValue) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
var isValidInputValue = function (inputValue) {
|
|
19
|
+
return !inputValue || (isCompleteTimeInput(inputValue) && isValidTimeFormat(inputValue));
|
|
20
|
+
};
|
|
21
|
+
var format = function (value) {
|
|
22
|
+
return value
|
|
23
|
+
.replace(/^(\d\d)(\d)$/, '$1:$2') // 123 => 12:3
|
|
24
|
+
.replace(/^(\d\d)(\d\d)/, '$1:$2') // 12345 => 12:45 (если вместо двоеточия введена цифра, она обратно заменяется на двоеточие)
|
|
25
|
+
.replace(/^(\d):(\d\d)(\d)/, '$1:$2') // 1:234 => 1:23
|
|
26
|
+
.replace(/\:$/, '');
|
|
27
|
+
}; // 12: => 12 || : => void
|
|
24
28
|
|
|
25
29
|
exports.DATE_MASK = DATE_MASK;
|
|
26
30
|
exports.format = format;
|