@alfalab/core-components-time-input 2.2.58 → 3.0.0-snapshot-6a9d3fc

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 (61) hide show
  1. package/Component.d.ts +4 -7
  2. package/Component.js +5 -4
  3. package/Component.js.map +1 -0
  4. package/cssm/Component.d.ts +4 -7
  5. package/cssm/Component.js +7 -6
  6. package/cssm/Component.js.map +1 -0
  7. package/cssm/index.d.ts +2 -2
  8. package/cssm/index.js +3 -2
  9. package/cssm/index.js.map +1 -0
  10. package/cssm/utils/format.d.ts +5 -6
  11. package/cssm/utils/format.js +1 -0
  12. package/cssm/utils/format.js.map +1 -0
  13. package/cssm/utils/index.d.ts +1 -1
  14. package/cssm/utils/index.js +7 -6
  15. package/cssm/utils/index.js.map +1 -0
  16. package/esm/Component.d.ts +4 -7
  17. package/esm/Component.js +1 -0
  18. package/esm/Component.js.map +1 -0
  19. package/esm/index.d.ts +2 -2
  20. package/esm/index.js +1 -0
  21. package/esm/index.js.map +1 -0
  22. package/esm/utils/format.d.ts +5 -6
  23. package/esm/utils/format.js +1 -0
  24. package/esm/utils/format.js.map +1 -0
  25. package/esm/utils/index.d.ts +1 -1
  26. package/esm/utils/index.js +1 -0
  27. package/esm/utils/index.js.map +1 -0
  28. package/index.d.ts +2 -2
  29. package/index.js +3 -2
  30. package/index.js.map +1 -0
  31. package/modern/Component.d.ts +4 -7
  32. package/modern/Component.js +1 -0
  33. package/modern/Component.js.map +1 -0
  34. package/modern/index.d.ts +2 -2
  35. package/modern/index.js +1 -0
  36. package/modern/index.js.map +1 -0
  37. package/modern/utils/format.d.ts +5 -6
  38. package/modern/utils/format.js +1 -0
  39. package/modern/utils/format.js.map +1 -0
  40. package/modern/utils/index.d.ts +1 -1
  41. package/modern/utils/index.js +1 -0
  42. package/modern/utils/index.js.map +1 -0
  43. package/moderncssm/Component.d.ts +4 -7
  44. package/moderncssm/Component.js +1 -0
  45. package/moderncssm/Component.js.map +1 -0
  46. package/moderncssm/index.d.ts +2 -2
  47. package/moderncssm/index.js +1 -0
  48. package/moderncssm/index.js.map +1 -0
  49. package/moderncssm/utils/format.d.ts +5 -6
  50. package/moderncssm/utils/format.js +1 -0
  51. package/moderncssm/utils/format.js.map +1 -0
  52. package/moderncssm/utils/index.d.ts +1 -1
  53. package/moderncssm/utils/index.js +1 -0
  54. package/moderncssm/utils/index.js.map +1 -0
  55. package/package.json +4 -4
  56. package/utils/format.d.ts +5 -6
  57. package/utils/format.js +1 -0
  58. package/utils/format.js.map +1 -0
  59. package/utils/index.d.ts +1 -1
  60. package/utils/index.js +7 -6
  61. package/utils/index.js.map +1 -0
package/Component.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent } from "react";
4
- import { InputProps } from "@alfalab/core-components-input";
5
- type TimeInputProps = Omit<InputProps, 'onChange'> & {
1
+ import React, { ChangeEvent } from 'react';
2
+ import { InputProps } from '@alfalab/core-components-input';
3
+ export declare type TimeInputProps = Omit<InputProps, 'onChange'> & {
6
4
  /**
7
5
  * Обработчик изменения значения
8
6
  */
@@ -24,7 +22,7 @@ type TimeInputProps = Omit<InputProps, 'onChange'> & {
24
22
  * @deprecated
25
23
  * use UniversalDateInput instead
26
24
  */
27
- declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
25
+ export declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
28
26
  /**
29
27
  * Обработчик изменения значения
30
28
  */
@@ -42,4 +40,3 @@ declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onCha
42
40
  value: string;
43
41
  }) => void) | undefined;
44
42
  } & React.RefAttributes<HTMLInputElement>>;
45
- export { TimeInputProps, TimeInput };
package/Component.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib = require('tslib');
6
6
  var React = require('react');
7
7
  var coreComponentsInput = require('@alfalab/core-components-input');
8
- var utils_format = require('./utils/format.js');
8
+ var format = require('./utils/format.js');
9
9
 
10
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
11
 
@@ -32,15 +32,15 @@ var TimeInput = React__default.default.forwardRef(function (_a, ref) {
32
32
  if (colon && colon.length > 1) {
33
33
  return;
34
34
  }
35
- var formattedValue = utils_format.format(newValue);
35
+ var formattedValue = format.format(newValue);
36
36
  var formattedValueArr = formattedValue.split(':');
37
37
  var hours = Number(formattedValueArr[0]);
38
38
  var mins = Number(formattedValueArr[1]);
39
39
  setValue(formattedValue);
40
40
  if (onChange)
41
41
  onChange(event, { hours: hours, mins: mins, value: formattedValue });
42
- if (utils_format.isCompleteTimeInput(formattedValue)) {
43
- var valid = formattedValue.length > 0 && utils_format.isValidInputValue(formattedValue);
42
+ if (format.isCompleteTimeInput(formattedValue)) {
43
+ var valid = formattedValue.length > 0 && format.isValidInputValue(formattedValue);
44
44
  if (!valid)
45
45
  return;
46
46
  if (onComplete) {
@@ -55,3 +55,4 @@ var TimeInput = React__default.default.forwardRef(function (_a, ref) {
55
55
  });
56
56
 
57
57
  exports.TimeInput = TimeInput;
58
+ //# sourceMappingURL=Component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Component.js","sources":["src/Component.tsx"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nimport React, { ChangeEvent, useState } from 'react';\n\nimport { Input, InputProps } from '@alfalab/core-components-input';\n\nimport { format, isCompleteTimeInput, isValidInputValue } from './utils';\n\nexport type TimeInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n};\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const TimeInput = React.forwardRef<HTMLInputElement, TimeInputProps>(\n (\n { defaultValue = '', value: propValue, onChange, onComplete, className, ...restProps },\n ref,\n ) => {\n const [value, setValue] = useState(propValue || defaultValue);\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n\n if (newValue.length > 5) return;\n\n // Позволяем вводить только цифры и двоеточия\n if (/[^\\d:]/.test(newValue)) {\n return;\n }\n\n const colon = newValue.match(/\\:/g);\n\n // Не даем вводить больше, чем одно двоеточие\n if (colon && colon.length > 1) {\n return;\n }\n\n const formattedValue = format(newValue);\n\n const formattedValueArr = formattedValue.split(':');\n const hours = Number(formattedValueArr[0]);\n const mins = Number(formattedValueArr[1]);\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { hours, mins, value: formattedValue });\n\n if (isCompleteTimeInput(formattedValue)) {\n const valid = formattedValue.length > 0 && isValidInputValue(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) {\n onComplete(event, { hours, mins, value: formattedValue });\n }\n }\n };\n\n const handleClearClick = () => {\n setValue('');\n };\n\n return (\n <Input\n {...restProps}\n ref={ref}\n value={value}\n className={className}\n onChange={handleChange}\n onClear={handleClearClick}\n />\n );\n },\n);\n"],"names":["React","__rest","useState","format","isCompleteTimeInput","isValidInputValue","Input","__assign"],"mappings":";;;;;;;;;;;;;AAAA;AA0BA;;;AAGG;AACU,IAAA,SAAS,GAAGA,sBAAK,CAAC,UAAU,CACrC,UACI,EAAsF,EACtF,GAAG,EAAA;IADD,IAAA,EAAA,GAAA,EAAA,CAAA,YAAiB,EAAjB,YAAY,GAAA,EAAA,KAAA,MAAA,GAAG,EAAE,GAAA,EAAA,EAAS,SAAS,GAAA,EAAA,CAAA,KAAA,EAAE,QAAQ,cAAA,EAAE,UAAU,gBAAA,EAAE,SAAS,eAAA,EAAK,SAAS,GAApFC,YAAA,CAAA,EAAA,EAAA,CAAA,cAAA,EAAA,OAAA,EAAA,UAAA,EAAA,YAAA,EAAA,WAAA,CAAsF,CAAF;AAG9E,IAAA,IAAA,EAAoB,GAAAC,cAAQ,CAAC,SAAS,IAAI,YAAY,CAAC,EAAtD,KAAK,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,QAAQ,QAAuC;IAE7D,IAAM,YAAY,GAAG,UAAC,KAAoC,EAAA;AAC9C,QAAA,IAAO,QAAQ,GAAK,KAAK,CAAC,MAAM,MAAjB;AAEvB,QAAA,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE;;AAGzB,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACzB;AACH;QAED,IAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;;AAGnC,QAAA,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B;AACH;AAED,QAAA,IAAM,cAAc,GAAGC,aAAM,CAAC,QAAQ,CAAC;QAEvC,IAAM,iBAAiB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;QACnD,IAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAEzC,QAAQ,CAAC,cAAc,CAAC;AAExB,QAAA,IAAI,QAAQ;AAAE,YAAA,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAA,KAAA,EAAE,IAAI,EAAA,IAAA,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAErE,QAAA,IAAIC,0BAAmB,CAAC,cAAc,CAAC,EAAE;AACrC,YAAA,IAAM,KAAK,GAAG,cAAc,CAAC,MAAM,GAAG,CAAC,IAAIC,wBAAiB,CAAC,cAAc,CAAC;AAE5E,YAAA,IAAI,CAAC,KAAK;gBAAE;AAEZ,YAAA,IAAI,UAAU,EAAE;AACZ,gBAAA,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAA,KAAA,EAAE,IAAI,EAAA,IAAA,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAC5D;AACJ;AACL,KAAC;AAED,IAAA,IAAM,gBAAgB,GAAG,YAAA;QACrB,QAAQ,CAAC,EAAE,CAAC;AAChB,KAAC;IAED,QACIL,sBAAC,CAAA,aAAA,CAAAM,yBAAK,EACEC,cAAA,CAAA,EAAA,EAAA,SAAS,EACb,EAAA,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,gBAAgB,EAC3B,CAAA,CAAA;AAEV,CAAC;;;;"}
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent } from "react";
4
- import { InputProps } from "@alfalab/core-components-input";
5
- type TimeInputProps = Omit<InputProps, 'onChange'> & {
1
+ import React, { ChangeEvent } from 'react';
2
+ import { InputProps } from '@alfalab/core-components-input';
3
+ export declare type TimeInputProps = Omit<InputProps, 'onChange'> & {
6
4
  /**
7
5
  * Обработчик изменения значения
8
6
  */
@@ -24,7 +22,7 @@ type TimeInputProps = Omit<InputProps, 'onChange'> & {
24
22
  * @deprecated
25
23
  * use UniversalDateInput instead
26
24
  */
27
- declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
25
+ export declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
28
26
  /**
29
27
  * Обработчик изменения значения
30
28
  */
@@ -42,4 +40,3 @@ declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onCha
42
40
  value: string;
43
41
  }) => void) | undefined;
44
42
  } & React.RefAttributes<HTMLInputElement>>;
45
- export { TimeInputProps, TimeInput };
package/cssm/Component.js CHANGED
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
6
  var React = require('react');
7
- var coreComponentsInput = require('@alfalab/core-components-input/cssm');
8
- var utils_format = require('./utils/format.js');
7
+ var cssm = require('@alfalab/core-components-input/cssm');
8
+ var format = require('./utils/format.js');
9
9
 
10
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
11
 
@@ -32,15 +32,15 @@ var TimeInput = React__default.default.forwardRef(function (_a, ref) {
32
32
  if (colon && colon.length > 1) {
33
33
  return;
34
34
  }
35
- var formattedValue = utils_format.format(newValue);
35
+ var formattedValue = format.format(newValue);
36
36
  var formattedValueArr = formattedValue.split(':');
37
37
  var hours = Number(formattedValueArr[0]);
38
38
  var mins = Number(formattedValueArr[1]);
39
39
  setValue(formattedValue);
40
40
  if (onChange)
41
41
  onChange(event, { hours: hours, mins: mins, value: formattedValue });
42
- if (utils_format.isCompleteTimeInput(formattedValue)) {
43
- var valid = formattedValue.length > 0 && utils_format.isValidInputValue(formattedValue);
42
+ if (format.isCompleteTimeInput(formattedValue)) {
43
+ var valid = formattedValue.length > 0 && format.isValidInputValue(formattedValue);
44
44
  if (!valid)
45
45
  return;
46
46
  if (onComplete) {
@@ -51,7 +51,8 @@ var TimeInput = React__default.default.forwardRef(function (_a, ref) {
51
51
  var handleClearClick = function () {
52
52
  setValue('');
53
53
  };
54
- return (React__default.default.createElement(coreComponentsInput.Input, tslib.__assign({}, restProps, { ref: ref, value: value, className: className, onChange: handleChange, onClear: handleClearClick })));
54
+ return (React__default.default.createElement(cssm.Input, tslib.__assign({}, restProps, { ref: ref, value: value, className: className, onChange: handleChange, onClear: handleClearClick })));
55
55
  });
56
56
 
57
57
  exports.TimeInput = TimeInput;
58
+ //# sourceMappingURL=Component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nimport React, { ChangeEvent, useState } from 'react';\n\nimport { Input, InputProps } from '@alfalab/core-components-input';\n\nimport { format, isCompleteTimeInput, isValidInputValue } from './utils';\n\nexport type TimeInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n};\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const TimeInput = React.forwardRef<HTMLInputElement, TimeInputProps>(\n (\n { defaultValue = '', value: propValue, onChange, onComplete, className, ...restProps },\n ref,\n ) => {\n const [value, setValue] = useState(propValue || defaultValue);\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n\n if (newValue.length > 5) return;\n\n // Позволяем вводить только цифры и двоеточия\n if (/[^\\d:]/.test(newValue)) {\n return;\n }\n\n const colon = newValue.match(/\\:/g);\n\n // Не даем вводить больше, чем одно двоеточие\n if (colon && colon.length > 1) {\n return;\n }\n\n const formattedValue = format(newValue);\n\n const formattedValueArr = formattedValue.split(':');\n const hours = Number(formattedValueArr[0]);\n const mins = Number(formattedValueArr[1]);\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { hours, mins, value: formattedValue });\n\n if (isCompleteTimeInput(formattedValue)) {\n const valid = formattedValue.length > 0 && isValidInputValue(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) {\n onComplete(event, { hours, mins, value: formattedValue });\n }\n }\n };\n\n const handleClearClick = () => {\n setValue('');\n };\n\n return (\n <Input\n {...restProps}\n ref={ref}\n value={value}\n className={className}\n onChange={handleChange}\n onClear={handleClearClick}\n />\n );\n },\n);\n"],"names":["React","__rest","useState","format","isCompleteTimeInput","isValidInputValue","Input","__assign"],"mappings":";;;;;;;;;;;;;AAAA;AA0BA;;;AAGG;AACU,IAAA,SAAS,GAAGA,sBAAK,CAAC,UAAU,CACrC,UACI,EAAsF,EACtF,GAAG,EAAA;IADD,IAAA,EAAA,GAAA,EAAA,CAAA,YAAiB,EAAjB,YAAY,GAAA,EAAA,KAAA,MAAA,GAAG,EAAE,GAAA,EAAA,EAAS,SAAS,GAAA,EAAA,CAAA,KAAA,EAAE,QAAQ,cAAA,EAAE,UAAU,gBAAA,EAAE,SAAS,eAAA,EAAK,SAAS,GAApFC,YAAA,CAAA,EAAA,EAAA,CAAA,cAAA,EAAA,OAAA,EAAA,UAAA,EAAA,YAAA,EAAA,WAAA,CAAsF,CAAF;AAG9E,IAAA,IAAA,EAAoB,GAAAC,cAAQ,CAAC,SAAS,IAAI,YAAY,CAAC,EAAtD,KAAK,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,QAAQ,QAAuC;IAE7D,IAAM,YAAY,GAAG,UAAC,KAAoC,EAAA;AAC9C,QAAA,IAAO,QAAQ,GAAK,KAAK,CAAC,MAAM,MAAjB;AAEvB,QAAA,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE;;AAGzB,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACzB;AACH;QAED,IAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;;AAGnC,QAAA,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B;AACH;AAED,QAAA,IAAM,cAAc,GAAGC,aAAM,CAAC,QAAQ,CAAC;QAEvC,IAAM,iBAAiB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;QACnD,IAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAEzC,QAAQ,CAAC,cAAc,CAAC;AAExB,QAAA,IAAI,QAAQ;AAAE,YAAA,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAA,KAAA,EAAE,IAAI,EAAA,IAAA,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAErE,QAAA,IAAIC,0BAAmB,CAAC,cAAc,CAAC,EAAE;AACrC,YAAA,IAAM,KAAK,GAAG,cAAc,CAAC,MAAM,GAAG,CAAC,IAAIC,wBAAiB,CAAC,cAAc,CAAC;AAE5E,YAAA,IAAI,CAAC,KAAK;gBAAE;AAEZ,YAAA,IAAI,UAAU,EAAE;AACZ,gBAAA,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAA,KAAA,EAAE,IAAI,EAAA,IAAA,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAC5D;AACJ;AACL,KAAC;AAED,IAAA,IAAM,gBAAgB,GAAG,YAAA;QACrB,QAAQ,CAAC,EAAE,CAAC;AAChB,KAAC;IAED,QACIL,sBAAC,CAAA,aAAA,CAAAM,UAAK,EACEC,cAAA,CAAA,EAAA,EAAA,SAAS,EACb,EAAA,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,gBAAgB,EAC3B,CAAA,CAAA;AAEV,CAAC;;;;"}
package/cssm/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./Component";
2
- export { isValidInputValue } from "./utils/index";
1
+ export * from './Component';
2
+ export { isValidInputValue } from './utils';
package/cssm/index.js CHANGED
@@ -3,9 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var Component = require('./Component.js');
6
- var utils_format = require('./utils/format.js');
6
+ var format = require('./utils/format.js');
7
7
 
8
8
 
9
9
 
10
10
  exports.TimeInput = Component.TimeInput;
11
- exports.isValidInputValue = utils_format.isValidInputValue;
11
+ exports.isValidInputValue = format.isValidInputValue;
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -1,6 +1,5 @@
1
- declare const DATE_MASK: (string | RegExp)[];
2
- declare const isCompleteTimeInput: (input: string) => boolean;
3
- declare const isValidTimeFormat: (value: string) => boolean;
4
- declare const isValidInputValue: (inputValue?: string) => boolean;
5
- declare const format: (value: string) => string;
6
- export { DATE_MASK, isCompleteTimeInput, isValidTimeFormat, isValidInputValue, format };
1
+ export declare const DATE_MASK: (string | RegExp)[];
2
+ export declare const isCompleteTimeInput: (input: string) => boolean;
3
+ export declare const isValidTimeFormat: (value: string) => boolean;
4
+ export declare const isValidInputValue: (inputValue?: string) => boolean;
5
+ export declare const format: (value: string) => string;
@@ -33,3 +33,4 @@ exports.format = format;
33
33
  exports.isCompleteTimeInput = isCompleteTimeInput;
34
34
  exports.isValidInputValue = isValidInputValue;
35
35
  exports.isValidTimeFormat = isValidTimeFormat;
36
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sources":["../../src/utils/format.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nexport const DATE_MASK = [/\\d/, /\\d/, ':', /\\d/, /\\d/];\n\nexport const isCompleteTimeInput = (input: string) => input.length === DATE_MASK.length;\n\nexport const isValidTimeFormat = (value: string): boolean => {\n const timeArr = value.split(':');\n const hours = timeArr[0];\n const mins = timeArr[1];\n\n if (hours.length !== 2 || Number(hours) > 23) {\n return false;\n }\n\n if (mins.length !== 2 || Number(mins) > 59) {\n return false;\n }\n\n return true;\n};\n\nexport const isValidInputValue = (inputValue?: string) =>\n !inputValue || (isCompleteTimeInput(inputValue) && isValidTimeFormat(inputValue));\n\nexport const format = (value: string): string =>\n value\n .replace(/^(\\d\\d)(\\d)$/, '$1:$2') // 123 => 12:3\n .replace(/^(\\d\\d)(\\d\\d)/, '$1:$2') // 12345 => 12:45 (если вместо двоеточия введена цифра, она обратно заменяется на двоеточие)\n .replace(/^(\\d):(\\d\\d)(\\d)/, '$1:$2') // 1:234 => 1:23\n .replace(/\\:$/, ''); // 12: => 12 || : => void\n"],"names":[],"mappings":";;;;AAAA;AAEO,IAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;AAExC,IAAA,mBAAmB,GAAG,UAAC,KAAa,EAAK,EAAA,OAAA,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,CAAA;AAEhF,IAAM,iBAAiB,GAAG,UAAC,KAAa,EAAA;IAC3C,IAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAChC,IAAA,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC;AACxB,IAAA,IAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;AAEvB,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE;AAC1C,QAAA,OAAO,KAAK;AACf;AAED,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE;AACxC,QAAA,OAAO,KAAK;AACf;AAED,IAAA,OAAO,IAAI;AACf;AAEO,IAAM,iBAAiB,GAAG,UAAC,UAAmB,EAAA;AACjD,IAAA,OAAA,CAAC,UAAU,KAAK,mBAAmB,CAAC,UAAU,CAAC,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAAjF;AAEG,IAAM,MAAM,GAAG,UAAC,KAAa,EAAA;AAChC,IAAA,OAAA;AACK,SAAA,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC;AAChC,SAAA,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC;AACjC,SAAA,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC;AACpC,SAAA,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAJvB,EAIwB;;;;;;;;"}
@@ -1 +1 @@
1
- export * from "./format";
1
+ export * from './format';
@@ -2,12 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var utils_format = require('./format.js');
5
+ var format = require('./format.js');
6
6
 
7
7
 
8
8
 
9
- exports.DATE_MASK = utils_format.DATE_MASK;
10
- exports.format = utils_format.format;
11
- exports.isCompleteTimeInput = utils_format.isCompleteTimeInput;
12
- exports.isValidInputValue = utils_format.isValidInputValue;
13
- exports.isValidTimeFormat = utils_format.isValidTimeFormat;
9
+ exports.DATE_MASK = format.DATE_MASK;
10
+ exports.format = format.format;
11
+ exports.isCompleteTimeInput = format.isCompleteTimeInput;
12
+ exports.isValidInputValue = format.isValidInputValue;
13
+ exports.isValidTimeFormat = format.isValidTimeFormat;
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent } from "react";
4
- import { InputProps } from "@alfalab/core-components-input";
5
- type TimeInputProps = Omit<InputProps, 'onChange'> & {
1
+ import React, { ChangeEvent } from 'react';
2
+ import { InputProps } from '@alfalab/core-components-input';
3
+ export declare type TimeInputProps = Omit<InputProps, 'onChange'> & {
6
4
  /**
7
5
  * Обработчик изменения значения
8
6
  */
@@ -24,7 +22,7 @@ type TimeInputProps = Omit<InputProps, 'onChange'> & {
24
22
  * @deprecated
25
23
  * use UniversalDateInput instead
26
24
  */
27
- declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
25
+ export declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
28
26
  /**
29
27
  * Обработчик изменения значения
30
28
  */
@@ -42,4 +40,3 @@ declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onCha
42
40
  value: string;
43
41
  }) => void) | undefined;
44
42
  } & React.RefAttributes<HTMLInputElement>>;
45
- export { TimeInputProps, TimeInput };
package/esm/Component.js CHANGED
@@ -47,3 +47,4 @@ var TimeInput = React.forwardRef(function (_a, ref) {
47
47
  });
48
48
 
49
49
  export { TimeInput };
50
+ //# sourceMappingURL=Component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nimport React, { ChangeEvent, useState } from 'react';\n\nimport { Input, InputProps } from '@alfalab/core-components-input';\n\nimport { format, isCompleteTimeInput, isValidInputValue } from './utils';\n\nexport type TimeInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n};\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const TimeInput = React.forwardRef<HTMLInputElement, TimeInputProps>(\n (\n { defaultValue = '', value: propValue, onChange, onComplete, className, ...restProps },\n ref,\n ) => {\n const [value, setValue] = useState(propValue || defaultValue);\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n\n if (newValue.length > 5) return;\n\n // Позволяем вводить только цифры и двоеточия\n if (/[^\\d:]/.test(newValue)) {\n return;\n }\n\n const colon = newValue.match(/\\:/g);\n\n // Не даем вводить больше, чем одно двоеточие\n if (colon && colon.length > 1) {\n return;\n }\n\n const formattedValue = format(newValue);\n\n const formattedValueArr = formattedValue.split(':');\n const hours = Number(formattedValueArr[0]);\n const mins = Number(formattedValueArr[1]);\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { hours, mins, value: formattedValue });\n\n if (isCompleteTimeInput(formattedValue)) {\n const valid = formattedValue.length > 0 && isValidInputValue(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) {\n onComplete(event, { hours, mins, value: formattedValue });\n }\n }\n };\n\n const handleClearClick = () => {\n setValue('');\n };\n\n return (\n <Input\n {...restProps}\n ref={ref}\n value={value}\n className={className}\n onChange={handleChange}\n onClear={handleClearClick}\n />\n );\n },\n);\n"],"names":[],"mappings":";;;;;AAAA;AA0BA;;;AAGG;AACU,IAAA,SAAS,GAAG,KAAK,CAAC,UAAU,CACrC,UACI,EAAsF,EACtF,GAAG,EAAA;IADD,IAAA,EAAA,GAAA,EAAA,CAAA,YAAiB,EAAjB,YAAY,GAAA,EAAA,KAAA,MAAA,GAAG,EAAE,GAAA,EAAA,EAAS,SAAS,GAAA,EAAA,CAAA,KAAA,EAAE,QAAQ,cAAA,EAAE,UAAU,gBAAA,EAAE,SAAS,eAAA,EAAK,SAAS,GAApF,MAAA,CAAA,EAAA,EAAA,CAAA,cAAA,EAAA,OAAA,EAAA,UAAA,EAAA,YAAA,EAAA,WAAA,CAAsF,CAAF;AAG9E,IAAA,IAAA,EAAoB,GAAA,QAAQ,CAAC,SAAS,IAAI,YAAY,CAAC,EAAtD,KAAK,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,QAAQ,QAAuC;IAE7D,IAAM,YAAY,GAAG,UAAC,KAAoC,EAAA;AAC9C,QAAA,IAAO,QAAQ,GAAK,KAAK,CAAC,MAAM,MAAjB;AAEvB,QAAA,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE;;AAGzB,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACzB;AACH;QAED,IAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;;AAGnC,QAAA,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B;AACH;AAED,QAAA,IAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;QAEvC,IAAM,iBAAiB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;QACnD,IAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAEzC,QAAQ,CAAC,cAAc,CAAC;AAExB,QAAA,IAAI,QAAQ;AAAE,YAAA,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAA,KAAA,EAAE,IAAI,EAAA,IAAA,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAErE,QAAA,IAAI,mBAAmB,CAAC,cAAc,CAAC,EAAE;AACrC,YAAA,IAAM,KAAK,GAAG,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,iBAAiB,CAAC,cAAc,CAAC;AAE5E,YAAA,IAAI,CAAC,KAAK;gBAAE;AAEZ,YAAA,IAAI,UAAU,EAAE;AACZ,gBAAA,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAA,KAAA,EAAE,IAAI,EAAA,IAAA,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAC5D;AACJ;AACL,KAAC;AAED,IAAA,IAAM,gBAAgB,GAAG,YAAA;QACrB,QAAQ,CAAC,EAAE,CAAC;AAChB,KAAC;IAED,QACI,KAAC,CAAA,aAAA,CAAA,KAAK,EACE,QAAA,CAAA,EAAA,EAAA,SAAS,EACb,EAAA,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,gBAAgB,EAC3B,CAAA,CAAA;AAEV,CAAC;;;;"}
package/esm/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./Component";
2
- export { isValidInputValue } from "./utils/index";
1
+ export * from './Component';
2
+ export { isValidInputValue } from './utils';
package/esm/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { TimeInput } from './Component.js';
2
2
  export { isValidInputValue } from './utils/format.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,6 +1,5 @@
1
- declare const DATE_MASK: (string | RegExp)[];
2
- declare const isCompleteTimeInput: (input: string) => boolean;
3
- declare const isValidTimeFormat: (value: string) => boolean;
4
- declare const isValidInputValue: (inputValue?: string) => boolean;
5
- declare const format: (value: string) => string;
6
- export { DATE_MASK, isCompleteTimeInput, isValidTimeFormat, isValidInputValue, format };
1
+ export declare const DATE_MASK: (string | RegExp)[];
2
+ export declare const isCompleteTimeInput: (input: string) => boolean;
3
+ export declare const isValidTimeFormat: (value: string) => boolean;
4
+ export declare const isValidInputValue: (inputValue?: string) => boolean;
5
+ export declare const format: (value: string) => string;
@@ -25,3 +25,4 @@ var format = function (value) {
25
25
  }; // 12: => 12 || : => void
26
26
 
27
27
  export { DATE_MASK, format, isCompleteTimeInput, isValidInputValue, isValidTimeFormat };
28
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sources":["../../src/utils/format.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nexport const DATE_MASK = [/\\d/, /\\d/, ':', /\\d/, /\\d/];\n\nexport const isCompleteTimeInput = (input: string) => input.length === DATE_MASK.length;\n\nexport const isValidTimeFormat = (value: string): boolean => {\n const timeArr = value.split(':');\n const hours = timeArr[0];\n const mins = timeArr[1];\n\n if (hours.length !== 2 || Number(hours) > 23) {\n return false;\n }\n\n if (mins.length !== 2 || Number(mins) > 59) {\n return false;\n }\n\n return true;\n};\n\nexport const isValidInputValue = (inputValue?: string) =>\n !inputValue || (isCompleteTimeInput(inputValue) && isValidTimeFormat(inputValue));\n\nexport const format = (value: string): string =>\n value\n .replace(/^(\\d\\d)(\\d)$/, '$1:$2') // 123 => 12:3\n .replace(/^(\\d\\d)(\\d\\d)/, '$1:$2') // 12345 => 12:45 (если вместо двоеточия введена цифра, она обратно заменяется на двоеточие)\n .replace(/^(\\d):(\\d\\d)(\\d)/, '$1:$2') // 1:234 => 1:23\n .replace(/\\:$/, ''); // 12: => 12 || : => void\n"],"names":[],"mappings":"AAAA;AAEO,IAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;AAExC,IAAA,mBAAmB,GAAG,UAAC,KAAa,EAAK,EAAA,OAAA,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,CAAA;AAEhF,IAAM,iBAAiB,GAAG,UAAC,KAAa,EAAA;IAC3C,IAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAChC,IAAA,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC;AACxB,IAAA,IAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;AAEvB,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE;AAC1C,QAAA,OAAO,KAAK;AACf;AAED,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE;AACxC,QAAA,OAAO,KAAK;AACf;AAED,IAAA,OAAO,IAAI;AACf;AAEO,IAAM,iBAAiB,GAAG,UAAC,UAAmB,EAAA;AACjD,IAAA,OAAA,CAAC,UAAU,KAAK,mBAAmB,CAAC,UAAU,CAAC,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAAjF;AAEG,IAAM,MAAM,GAAG,UAAC,KAAa,EAAA;AAChC,IAAA,OAAA;AACK,SAAA,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC;AAChC,SAAA,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC;AACjC,SAAA,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC;AACpC,SAAA,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAJvB,EAIwB;;;;"}
@@ -1 +1 @@
1
- export * from "./format";
1
+ export * from './format';
@@ -1 +1,2 @@
1
1
  export { DATE_MASK, format, isCompleteTimeInput, isValidInputValue, isValidTimeFormat } from './format.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./Component";
2
- export { isValidInputValue } from "./utils/index";
1
+ export * from './Component';
2
+ export { isValidInputValue } from './utils';
package/index.js CHANGED
@@ -3,9 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var Component = require('./Component.js');
6
- var utils_format = require('./utils/format.js');
6
+ var format = require('./utils/format.js');
7
7
 
8
8
 
9
9
 
10
10
  exports.TimeInput = Component.TimeInput;
11
- exports.isValidInputValue = utils_format.isValidInputValue;
11
+ exports.isValidInputValue = format.isValidInputValue;
12
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent } from "react";
4
- import { InputProps } from "@alfalab/core-components-input";
5
- type TimeInputProps = Omit<InputProps, 'onChange'> & {
1
+ import React, { ChangeEvent } from 'react';
2
+ import { InputProps } from '@alfalab/core-components-input';
3
+ export declare type TimeInputProps = Omit<InputProps, 'onChange'> & {
6
4
  /**
7
5
  * Обработчик изменения значения
8
6
  */
@@ -24,7 +22,7 @@ type TimeInputProps = Omit<InputProps, 'onChange'> & {
24
22
  * @deprecated
25
23
  * use UniversalDateInput instead
26
24
  */
27
- declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
25
+ export declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
28
26
  /**
29
27
  * Обработчик изменения значения
30
28
  */
@@ -42,4 +40,3 @@ declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onCha
42
40
  value: string;
43
41
  }) => void) | undefined;
44
42
  } & React.RefAttributes<HTMLInputElement>>;
45
- export { TimeInputProps, TimeInput };
@@ -45,3 +45,4 @@ const TimeInput = React.forwardRef(({ defaultValue = '', value: propValue, onCha
45
45
  });
46
46
 
47
47
  export { TimeInput };
48
+ //# sourceMappingURL=Component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nimport React, { ChangeEvent, useState } from 'react';\n\nimport { Input, InputProps } from '@alfalab/core-components-input';\n\nimport { format, isCompleteTimeInput, isValidInputValue } from './utils';\n\nexport type TimeInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n};\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const TimeInput = React.forwardRef<HTMLInputElement, TimeInputProps>(\n (\n { defaultValue = '', value: propValue, onChange, onComplete, className, ...restProps },\n ref,\n ) => {\n const [value, setValue] = useState(propValue || defaultValue);\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n\n if (newValue.length > 5) return;\n\n // Позволяем вводить только цифры и двоеточия\n if (/[^\\d:]/.test(newValue)) {\n return;\n }\n\n const colon = newValue.match(/\\:/g);\n\n // Не даем вводить больше, чем одно двоеточие\n if (colon && colon.length > 1) {\n return;\n }\n\n const formattedValue = format(newValue);\n\n const formattedValueArr = formattedValue.split(':');\n const hours = Number(formattedValueArr[0]);\n const mins = Number(formattedValueArr[1]);\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { hours, mins, value: formattedValue });\n\n if (isCompleteTimeInput(formattedValue)) {\n const valid = formattedValue.length > 0 && isValidInputValue(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) {\n onComplete(event, { hours, mins, value: formattedValue });\n }\n }\n };\n\n const handleClearClick = () => {\n setValue('');\n };\n\n return (\n <Input\n {...restProps}\n ref={ref}\n value={value}\n className={className}\n onChange={handleChange}\n onClear={handleClearClick}\n />\n );\n },\n);\n"],"names":[],"mappings":";;;;AAAA;AA0BA;;;AAGG;AACI,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CACrC,CACI,EAAE,YAAY,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EACtF,GAAG,KACH;AACA,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,SAAS,IAAI,YAAY,CAAC;AAE7D,IAAA,MAAM,YAAY,GAAG,CAAC,KAAoC,KAAI;QAC1D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,MAAM;AAExC,QAAA,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE;;AAGzB,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACzB;AACH;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;;AAGnC,QAAA,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B;AACH;AAED,QAAA,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;QAEvC,MAAM,iBAAiB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAEzC,QAAQ,CAAC,cAAc,CAAC;AAExB,QAAA,IAAI,QAAQ;AAAE,YAAA,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAErE,QAAA,IAAI,mBAAmB,CAAC,cAAc,CAAC,EAAE;AACrC,YAAA,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,iBAAiB,CAAC,cAAc,CAAC;AAE5E,YAAA,IAAI,CAAC,KAAK;gBAAE;AAEZ,YAAA,IAAI,UAAU,EAAE;AACZ,gBAAA,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAC5D;AACJ;AACL,KAAC;IAED,MAAM,gBAAgB,GAAG,MAAK;QAC1B,QAAQ,CAAC,EAAE,CAAC;AAChB,KAAC;IAED,QACI,KAAC,CAAA,aAAA,CAAA,KAAK,EACE,EAAA,GAAA,SAAS,EACb,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,gBAAgB,EAC3B,CAAA;AAEV,CAAC;;;;"}
package/modern/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./Component";
2
- export { isValidInputValue } from "./utils/index";
1
+ export * from './Component';
2
+ export { isValidInputValue } from './utils';
package/modern/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { TimeInput } from './Component.js';
2
2
  export { isValidInputValue } from './utils/format.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,6 +1,5 @@
1
- declare const DATE_MASK: (string | RegExp)[];
2
- declare const isCompleteTimeInput: (input: string) => boolean;
3
- declare const isValidTimeFormat: (value: string) => boolean;
4
- declare const isValidInputValue: (inputValue?: string) => boolean;
5
- declare const format: (value: string) => string;
6
- export { DATE_MASK, isCompleteTimeInput, isValidTimeFormat, isValidInputValue, format };
1
+ export declare const DATE_MASK: (string | RegExp)[];
2
+ export declare const isCompleteTimeInput: (input: string) => boolean;
3
+ export declare const isValidTimeFormat: (value: string) => boolean;
4
+ export declare const isValidInputValue: (inputValue?: string) => boolean;
5
+ export declare const format: (value: string) => string;
@@ -21,3 +21,4 @@ const format = (value) => value
21
21
  .replace(/\:$/, ''); // 12: => 12 || : => void
22
22
 
23
23
  export { DATE_MASK, format, isCompleteTimeInput, isValidInputValue, isValidTimeFormat };
24
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sources":["../../src/utils/format.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nexport const DATE_MASK = [/\\d/, /\\d/, ':', /\\d/, /\\d/];\n\nexport const isCompleteTimeInput = (input: string) => input.length === DATE_MASK.length;\n\nexport const isValidTimeFormat = (value: string): boolean => {\n const timeArr = value.split(':');\n const hours = timeArr[0];\n const mins = timeArr[1];\n\n if (hours.length !== 2 || Number(hours) > 23) {\n return false;\n }\n\n if (mins.length !== 2 || Number(mins) > 59) {\n return false;\n }\n\n return true;\n};\n\nexport const isValidInputValue = (inputValue?: string) =>\n !inputValue || (isCompleteTimeInput(inputValue) && isValidTimeFormat(inputValue));\n\nexport const format = (value: string): string =>\n value\n .replace(/^(\\d\\d)(\\d)$/, '$1:$2') // 123 => 12:3\n .replace(/^(\\d\\d)(\\d\\d)/, '$1:$2') // 12345 => 12:45 (если вместо двоеточия введена цифра, она обратно заменяется на двоеточие)\n .replace(/^(\\d):(\\d\\d)(\\d)/, '$1:$2') // 1:234 => 1:23\n .replace(/\\:$/, ''); // 12: => 12 || : => void\n"],"names":[],"mappings":"AAAA;AAEO,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;AAExC,MAAA,mBAAmB,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC;AAEpE,MAAA,iBAAiB,GAAG,CAAC,KAAa,KAAa;IACxD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAChC,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC;AACxB,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;AAEvB,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE;AAC1C,QAAA,OAAO,KAAK;AACf;AAED,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE;AACxC,QAAA,OAAO,KAAK;AACf;AAED,IAAA,OAAO,IAAI;AACf;MAEa,iBAAiB,GAAG,CAAC,UAAmB,KACjD,CAAC,UAAU,KAAK,mBAAmB,CAAC,UAAU,CAAC,IAAI,iBAAiB,CAAC,UAAU,CAAC;MAEvE,MAAM,GAAG,CAAC,KAAa,KAChC;AACK,KAAA,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC;AAChC,KAAA,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC;AACjC,KAAA,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC;AACpC,KAAA,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE;;;;"}
@@ -1 +1 @@
1
- export * from "./format";
1
+ export * from './format';
@@ -1 +1,2 @@
1
1
  export { DATE_MASK, format, isCompleteTimeInput, isValidInputValue, isValidTimeFormat } from './format.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent } from "react";
4
- import { InputProps } from "@alfalab/core-components-input";
5
- type TimeInputProps = Omit<InputProps, 'onChange'> & {
1
+ import React, { ChangeEvent } from 'react';
2
+ import { InputProps } from '@alfalab/core-components-input';
3
+ export declare type TimeInputProps = Omit<InputProps, 'onChange'> & {
6
4
  /**
7
5
  * Обработчик изменения значения
8
6
  */
@@ -24,7 +22,7 @@ type TimeInputProps = Omit<InputProps, 'onChange'> & {
24
22
  * @deprecated
25
23
  * use UniversalDateInput instead
26
24
  */
27
- declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
25
+ export declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
28
26
  /**
29
27
  * Обработчик изменения значения
30
28
  */
@@ -42,4 +40,3 @@ declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onCha
42
40
  value: string;
43
41
  }) => void) | undefined;
44
42
  } & React.RefAttributes<HTMLInputElement>>;
45
- export { TimeInputProps, TimeInput };
@@ -45,3 +45,4 @@ const TimeInput = React.forwardRef(({ defaultValue = '', value: propValue, onCha
45
45
  });
46
46
 
47
47
  export { TimeInput };
48
+ //# sourceMappingURL=Component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nimport React, { ChangeEvent, useState } from 'react';\n\nimport { Input, InputProps } from '@alfalab/core-components-input';\n\nimport { format, isCompleteTimeInput, isValidInputValue } from './utils';\n\nexport type TimeInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { hours: number; mins: number; value: string },\n ) => void;\n};\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const TimeInput = React.forwardRef<HTMLInputElement, TimeInputProps>(\n (\n { defaultValue = '', value: propValue, onChange, onComplete, className, ...restProps },\n ref,\n ) => {\n const [value, setValue] = useState(propValue || defaultValue);\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n\n if (newValue.length > 5) return;\n\n // Позволяем вводить только цифры и двоеточия\n if (/[^\\d:]/.test(newValue)) {\n return;\n }\n\n const colon = newValue.match(/\\:/g);\n\n // Не даем вводить больше, чем одно двоеточие\n if (colon && colon.length > 1) {\n return;\n }\n\n const formattedValue = format(newValue);\n\n const formattedValueArr = formattedValue.split(':');\n const hours = Number(formattedValueArr[0]);\n const mins = Number(formattedValueArr[1]);\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { hours, mins, value: formattedValue });\n\n if (isCompleteTimeInput(formattedValue)) {\n const valid = formattedValue.length > 0 && isValidInputValue(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) {\n onComplete(event, { hours, mins, value: formattedValue });\n }\n }\n };\n\n const handleClearClick = () => {\n setValue('');\n };\n\n return (\n <Input\n {...restProps}\n ref={ref}\n value={value}\n className={className}\n onChange={handleChange}\n onClear={handleClearClick}\n />\n );\n },\n);\n"],"names":[],"mappings":";;;;AAAA;AA0BA;;;AAGG;AACI,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CACrC,CACI,EAAE,YAAY,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EACtF,GAAG,KACH;AACA,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,SAAS,IAAI,YAAY,CAAC;AAE7D,IAAA,MAAM,YAAY,GAAG,CAAC,KAAoC,KAAI;QAC1D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,MAAM;AAExC,QAAA,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE;;AAGzB,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACzB;AACH;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;;AAGnC,QAAA,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B;AACH;AAED,QAAA,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;QAEvC,MAAM,iBAAiB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAEzC,QAAQ,CAAC,cAAc,CAAC;AAExB,QAAA,IAAI,QAAQ;AAAE,YAAA,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAErE,QAAA,IAAI,mBAAmB,CAAC,cAAc,CAAC,EAAE;AACrC,YAAA,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,iBAAiB,CAAC,cAAc,CAAC;AAE5E,YAAA,IAAI,CAAC,KAAK;gBAAE;AAEZ,YAAA,IAAI,UAAU,EAAE;AACZ,gBAAA,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AAC5D;AACJ;AACL,KAAC;IAED,MAAM,gBAAgB,GAAG,MAAK;QAC1B,QAAQ,CAAC,EAAE,CAAC;AAChB,KAAC;IAED,QACI,KAAC,CAAA,aAAA,CAAA,KAAK,EACE,EAAA,GAAA,SAAS,EACb,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,gBAAgB,EAC3B,CAAA;AAEV,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- export * from "./Component";
2
- export { isValidInputValue } from "./utils/index";
1
+ export * from './Component';
2
+ export { isValidInputValue } from './utils';
@@ -1,2 +1,3 @@
1
1
  export { TimeInput } from './Component.js';
2
2
  export { isValidInputValue } from './utils/format.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,6 +1,5 @@
1
- declare const DATE_MASK: (string | RegExp)[];
2
- declare const isCompleteTimeInput: (input: string) => boolean;
3
- declare const isValidTimeFormat: (value: string) => boolean;
4
- declare const isValidInputValue: (inputValue?: string) => boolean;
5
- declare const format: (value: string) => string;
6
- export { DATE_MASK, isCompleteTimeInput, isValidTimeFormat, isValidInputValue, format };
1
+ export declare const DATE_MASK: (string | RegExp)[];
2
+ export declare const isCompleteTimeInput: (input: string) => boolean;
3
+ export declare const isValidTimeFormat: (value: string) => boolean;
4
+ export declare const isValidInputValue: (inputValue?: string) => boolean;
5
+ export declare const format: (value: string) => string;
@@ -21,3 +21,4 @@ const format = (value) => value
21
21
  .replace(/\:$/, ''); // 12: => 12 || : => void
22
22
 
23
23
  export { DATE_MASK, format, isCompleteTimeInput, isValidInputValue, isValidTimeFormat };
24
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sources":["../../src/utils/format.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nexport const DATE_MASK = [/\\d/, /\\d/, ':', /\\d/, /\\d/];\n\nexport const isCompleteTimeInput = (input: string) => input.length === DATE_MASK.length;\n\nexport const isValidTimeFormat = (value: string): boolean => {\n const timeArr = value.split(':');\n const hours = timeArr[0];\n const mins = timeArr[1];\n\n if (hours.length !== 2 || Number(hours) > 23) {\n return false;\n }\n\n if (mins.length !== 2 || Number(mins) > 59) {\n return false;\n }\n\n return true;\n};\n\nexport const isValidInputValue = (inputValue?: string) =>\n !inputValue || (isCompleteTimeInput(inputValue) && isValidTimeFormat(inputValue));\n\nexport const format = (value: string): string =>\n value\n .replace(/^(\\d\\d)(\\d)$/, '$1:$2') // 123 => 12:3\n .replace(/^(\\d\\d)(\\d\\d)/, '$1:$2') // 12345 => 12:45 (если вместо двоеточия введена цифра, она обратно заменяется на двоеточие)\n .replace(/^(\\d):(\\d\\d)(\\d)/, '$1:$2') // 1:234 => 1:23\n .replace(/\\:$/, ''); // 12: => 12 || : => void\n"],"names":[],"mappings":"AAAA;AAEO,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;AAExC,MAAA,mBAAmB,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC;AAEpE,MAAA,iBAAiB,GAAG,CAAC,KAAa,KAAa;IACxD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAChC,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC;AACxB,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;AAEvB,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE;AAC1C,QAAA,OAAO,KAAK;AACf;AAED,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE;AACxC,QAAA,OAAO,KAAK;AACf;AAED,IAAA,OAAO,IAAI;AACf;MAEa,iBAAiB,GAAG,CAAC,UAAmB,KACjD,CAAC,UAAU,KAAK,mBAAmB,CAAC,UAAU,CAAC,IAAI,iBAAiB,CAAC,UAAU,CAAC;MAEvE,MAAM,GAAG,CAAC,KAAa,KAChC;AACK,KAAA,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC;AAChC,KAAA,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC;AACjC,KAAA,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC;AACpC,KAAA,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE;;;;"}
@@ -1 +1 @@
1
- export * from "./format";
1
+ export * from './format';
@@ -1 +1,2 @@
1
1
  export { DATE_MASK, format, isCompleteTimeInput, isValidInputValue, isValidTimeFormat } from './format.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-time-input",
3
- "version": "2.2.58",
3
+ "version": "3.0.0-snapshot-6a9d3fc",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -16,9 +16,9 @@
16
16
  "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
17
17
  },
18
18
  "dependencies": {
19
- "@alfalab/core-components-input": "^15.6.2",
19
+ "@alfalab/core-components-input": "16.0.0-snapshot-6a9d3fc",
20
20
  "tslib": "^2.4.0"
21
21
  },
22
- "themesVersion": "13.7.4",
23
- "varsVersion": "9.20.1"
22
+ "themesVersion": "14.0.0-snapshot-6a9d3fc",
23
+ "varsVersion": "10.0.0-snapshot-6a9d3fc"
24
24
  }
package/utils/format.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- declare const DATE_MASK: (string | RegExp)[];
2
- declare const isCompleteTimeInput: (input: string) => boolean;
3
- declare const isValidTimeFormat: (value: string) => boolean;
4
- declare const isValidInputValue: (inputValue?: string) => boolean;
5
- declare const format: (value: string) => string;
6
- export { DATE_MASK, isCompleteTimeInput, isValidTimeFormat, isValidInputValue, format };
1
+ export declare const DATE_MASK: (string | RegExp)[];
2
+ export declare const isCompleteTimeInput: (input: string) => boolean;
3
+ export declare const isValidTimeFormat: (value: string) => boolean;
4
+ export declare const isValidInputValue: (inputValue?: string) => boolean;
5
+ export declare const format: (value: string) => string;
package/utils/format.js CHANGED
@@ -33,3 +33,4 @@ exports.format = format;
33
33
  exports.isCompleteTimeInput = isCompleteTimeInput;
34
34
  exports.isValidInputValue = isValidInputValue;
35
35
  exports.isValidTimeFormat = isValidTimeFormat;
36
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sources":["../src/utils/format.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nexport const DATE_MASK = [/\\d/, /\\d/, ':', /\\d/, /\\d/];\n\nexport const isCompleteTimeInput = (input: string) => input.length === DATE_MASK.length;\n\nexport const isValidTimeFormat = (value: string): boolean => {\n const timeArr = value.split(':');\n const hours = timeArr[0];\n const mins = timeArr[1];\n\n if (hours.length !== 2 || Number(hours) > 23) {\n return false;\n }\n\n if (mins.length !== 2 || Number(mins) > 59) {\n return false;\n }\n\n return true;\n};\n\nexport const isValidInputValue = (inputValue?: string) =>\n !inputValue || (isCompleteTimeInput(inputValue) && isValidTimeFormat(inputValue));\n\nexport const format = (value: string): string =>\n value\n .replace(/^(\\d\\d)(\\d)$/, '$1:$2') // 123 => 12:3\n .replace(/^(\\d\\d)(\\d\\d)/, '$1:$2') // 12345 => 12:45 (если вместо двоеточия введена цифра, она обратно заменяется на двоеточие)\n .replace(/^(\\d):(\\d\\d)(\\d)/, '$1:$2') // 1:234 => 1:23\n .replace(/\\:$/, ''); // 12: => 12 || : => void\n"],"names":[],"mappings":";;;;AAAA;AAEO,IAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;AAExC,IAAA,mBAAmB,GAAG,UAAC,KAAa,EAAK,EAAA,OAAA,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,CAAA;AAEhF,IAAM,iBAAiB,GAAG,UAAC,KAAa,EAAA;IAC3C,IAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAChC,IAAA,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC;AACxB,IAAA,IAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;AAEvB,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE;AAC1C,QAAA,OAAO,KAAK;AACf;AAED,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE;AACxC,QAAA,OAAO,KAAK;AACf;AAED,IAAA,OAAO,IAAI;AACf;AAEO,IAAM,iBAAiB,GAAG,UAAC,UAAmB,EAAA;AACjD,IAAA,OAAA,CAAC,UAAU,KAAK,mBAAmB,CAAC,UAAU,CAAC,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAAjF;AAEG,IAAM,MAAM,GAAG,UAAC,KAAa,EAAA;AAChC,IAAA,OAAA;AACK,SAAA,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC;AAChC,SAAA,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC;AACjC,SAAA,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC;AACpC,SAAA,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAJvB,EAIwB;;;;;;;;"}
package/utils/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./format";
1
+ export * from './format';
package/utils/index.js CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var utils_format = require('./format.js');
5
+ var format = require('./format.js');
6
6
 
7
7
 
8
8
 
9
- exports.DATE_MASK = utils_format.DATE_MASK;
10
- exports.format = utils_format.format;
11
- exports.isCompleteTimeInput = utils_format.isCompleteTimeInput;
12
- exports.isValidInputValue = utils_format.isValidInputValue;
13
- exports.isValidTimeFormat = utils_format.isValidTimeFormat;
9
+ exports.DATE_MASK = format.DATE_MASK;
10
+ exports.format = format.format;
11
+ exports.isCompleteTimeInput = format.isCompleteTimeInput;
12
+ exports.isValidInputValue = format.isValidInputValue;
13
+ exports.isValidTimeFormat = format.isValidTimeFormat;
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}