@alfalab/core-components-time-input 2.0.0 → 2.0.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.
Files changed (2) hide show
  1. package/package.json +2 -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.0.0",
3
+ "version": "2.0.1",
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.0.0",
18
+ "@alfalab/core-components-input": "^11.0.1",
19
19
  "@alfalab/core-components-icon-button": "^6.0.0"
20
20
  }
21
21
  }
package/utils/format.js CHANGED
@@ -17,12 +17,16 @@ var isValidTimeFormat = function (value) {
17
17
  }
18
18
  return true;
19
19
  };
20
- var isValidInputValue = function (inputValue) { return !inputValue || (isCompleteTimeInput(inputValue) && isValidTimeFormat(inputValue)); };
21
- var format = function (value) { return value
22
- .replace(/^(\d\d)(\d)$/, '$1:$2') // 123 => 12:3
23
- .replace(/^(\d\d)(\d\d)/, '$1:$2') // 12345 => 12:45 (если вместо двоеточия введена цифра, она обратно заменяется на двоеточие)
24
- .replace(/^(\d):(\d\d)(\d)/, '$1:$2') // 1:234 => 1:23
25
- .replace(/\:$/, ''); }; // 12: => 12 || : => void
20
+ var isValidInputValue = function (inputValue) {
21
+ return !inputValue || (isCompleteTimeInput(inputValue) && isValidTimeFormat(inputValue));
22
+ };
23
+ var format = function (value) {
24
+ return value
25
+ .replace(/^(\d\d)(\d)$/, '$1:$2') // 123 => 12:3
26
+ .replace(/^(\d\d)(\d\d)/, '$1:$2') // 12345 => 12:45 (если вместо двоеточия введена цифра, она обратно заменяется на двоеточие)
27
+ .replace(/^(\d):(\d\d)(\d)/, '$1:$2') // 1:234 => 1:23
28
+ .replace(/\:$/, '');
29
+ }; // 12: => 12 || : => void
26
30
 
27
31
  exports.DATE_MASK = DATE_MASK;
28
32
  exports.format = format;