@alfalab/core-components-time-input 1.1.2 → 2.0.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/Component.d.ts +3 -3
- package/Component.js +1 -1
- package/cssm/Component.d.ts +3 -3
- package/cssm/Component.js +1 -1
- package/esm/Component.d.ts +3 -3
- package/esm/Component.js +1 -1
- package/esm/utils/format.js +10 -6
- package/modern/Component.d.ts +3 -3
- package/modern/Component.js +1 -1
- package/package.json +3 -3
- package/utils/format.js +6 -10
package/Component.d.ts
CHANGED
|
@@ -20,11 +20,11 @@ type TimeInputProps = Omit<InputProps, 'onChange'> & {
|
|
|
20
20
|
value: string;
|
|
21
21
|
}) => void;
|
|
22
22
|
};
|
|
23
|
-
declare const TimeInput: React.ForwardRefExoticComponent<
|
|
23
|
+
declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
|
|
24
24
|
/**
|
|
25
25
|
* Обработчик изменения значения
|
|
26
26
|
*/
|
|
27
|
-
onChange?: ((event:
|
|
27
|
+
onChange?: ((event: ChangeEvent<HTMLInputElement>, payload: {
|
|
28
28
|
hours: number;
|
|
29
29
|
mins: number;
|
|
30
30
|
value: string;
|
|
@@ -32,7 +32,7 @@ declare const TimeInput: React.ForwardRefExoticComponent<Pick<InputProps, "class
|
|
|
32
32
|
/**
|
|
33
33
|
* Обработчик окончания ввода
|
|
34
34
|
*/
|
|
35
|
-
onComplete?: ((event:
|
|
35
|
+
onComplete?: ((event: ChangeEvent<HTMLInputElement>, payload: {
|
|
36
36
|
hours: number;
|
|
37
37
|
mins: number;
|
|
38
38
|
value: string;
|
package/Component.js
CHANGED
|
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/******************************************************************************
|
|
14
14
|
Copyright (c) Microsoft Corporation.
|
|
15
15
|
|
|
16
16
|
Permission to use, copy, modify, and/or distribute this software for any
|
package/cssm/Component.d.ts
CHANGED
|
@@ -20,11 +20,11 @@ type TimeInputProps = Omit<InputProps, 'onChange'> & {
|
|
|
20
20
|
value: string;
|
|
21
21
|
}) => void;
|
|
22
22
|
};
|
|
23
|
-
declare const TimeInput: React.ForwardRefExoticComponent<
|
|
23
|
+
declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
|
|
24
24
|
/**
|
|
25
25
|
* Обработчик изменения значения
|
|
26
26
|
*/
|
|
27
|
-
onChange?: ((event:
|
|
27
|
+
onChange?: ((event: ChangeEvent<HTMLInputElement>, payload: {
|
|
28
28
|
hours: number;
|
|
29
29
|
mins: number;
|
|
30
30
|
value: string;
|
|
@@ -32,7 +32,7 @@ declare const TimeInput: React.ForwardRefExoticComponent<Pick<InputProps, "class
|
|
|
32
32
|
/**
|
|
33
33
|
* Обработчик окончания ввода
|
|
34
34
|
*/
|
|
35
|
-
onComplete?: ((event:
|
|
35
|
+
onComplete?: ((event: ChangeEvent<HTMLInputElement>, payload: {
|
|
36
36
|
hours: number;
|
|
37
37
|
mins: number;
|
|
38
38
|
value: string;
|
package/cssm/Component.js
CHANGED
|
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/******************************************************************************
|
|
14
14
|
Copyright (c) Microsoft Corporation.
|
|
15
15
|
|
|
16
16
|
Permission to use, copy, modify, and/or distribute this software for any
|
package/esm/Component.d.ts
CHANGED
|
@@ -20,11 +20,11 @@ type TimeInputProps = Omit<InputProps, 'onChange'> & {
|
|
|
20
20
|
value: string;
|
|
21
21
|
}) => void;
|
|
22
22
|
};
|
|
23
|
-
declare const TimeInput: React.ForwardRefExoticComponent<
|
|
23
|
+
declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
|
|
24
24
|
/**
|
|
25
25
|
* Обработчик изменения значения
|
|
26
26
|
*/
|
|
27
|
-
onChange?: ((event:
|
|
27
|
+
onChange?: ((event: ChangeEvent<HTMLInputElement>, payload: {
|
|
28
28
|
hours: number;
|
|
29
29
|
mins: number;
|
|
30
30
|
value: string;
|
|
@@ -32,7 +32,7 @@ declare const TimeInput: React.ForwardRefExoticComponent<Pick<InputProps, "class
|
|
|
32
32
|
/**
|
|
33
33
|
* Обработчик окончания ввода
|
|
34
34
|
*/
|
|
35
|
-
onComplete?: ((event:
|
|
35
|
+
onComplete?: ((event: ChangeEvent<HTMLInputElement>, payload: {
|
|
36
36
|
hours: number;
|
|
37
37
|
mins: number;
|
|
38
38
|
value: string;
|
package/esm/Component.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { Input } from '@alfalab/core-components-input/esm';
|
|
3
3
|
import { format, isCompleteTimeInput, isValidInputValue } from './utils/format.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
7
7
|
|
|
8
8
|
Permission to use, copy, modify, and/or distribute this software for any
|
package/esm/utils/format.js
CHANGED
|
@@ -13,11 +13,15 @@ var isValidTimeFormat = function (value) {
|
|
|
13
13
|
}
|
|
14
14
|
return true;
|
|
15
15
|
};
|
|
16
|
-
var isValidInputValue = function (inputValue) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
var isValidInputValue = function (inputValue) {
|
|
17
|
+
return !inputValue || (isCompleteTimeInput(inputValue) && isValidTimeFormat(inputValue));
|
|
18
|
+
};
|
|
19
|
+
var format = function (value) {
|
|
20
|
+
return value
|
|
21
|
+
.replace(/^(\d\d)(\d)$/, '$1:$2') // 123 => 12:3
|
|
22
|
+
.replace(/^(\d\d)(\d\d)/, '$1:$2') // 12345 => 12:45 (если вместо двоеточия введена цифра, она обратно заменяется на двоеточие)
|
|
23
|
+
.replace(/^(\d):(\d\d)(\d)/, '$1:$2') // 1:234 => 1:23
|
|
24
|
+
.replace(/\:$/, '');
|
|
25
|
+
}; // 12: => 12 || : => void
|
|
22
26
|
|
|
23
27
|
export { DATE_MASK, format, isCompleteTimeInput, isValidInputValue, isValidTimeFormat };
|
package/modern/Component.d.ts
CHANGED
|
@@ -20,11 +20,11 @@ type TimeInputProps = Omit<InputProps, 'onChange'> & {
|
|
|
20
20
|
value: string;
|
|
21
21
|
}) => void;
|
|
22
22
|
};
|
|
23
|
-
declare const TimeInput: React.ForwardRefExoticComponent<
|
|
23
|
+
declare const TimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
|
|
24
24
|
/**
|
|
25
25
|
* Обработчик изменения значения
|
|
26
26
|
*/
|
|
27
|
-
onChange?: ((event:
|
|
27
|
+
onChange?: ((event: ChangeEvent<HTMLInputElement>, payload: {
|
|
28
28
|
hours: number;
|
|
29
29
|
mins: number;
|
|
30
30
|
value: string;
|
|
@@ -32,7 +32,7 @@ declare const TimeInput: React.ForwardRefExoticComponent<Pick<InputProps, "class
|
|
|
32
32
|
/**
|
|
33
33
|
* Обработчик окончания ввода
|
|
34
34
|
*/
|
|
35
|
-
onComplete?: ((event:
|
|
35
|
+
onComplete?: ((event: ChangeEvent<HTMLInputElement>, payload: {
|
|
36
36
|
hours: number;
|
|
37
37
|
mins: number;
|
|
38
38
|
value: string;
|
package/modern/Component.js
CHANGED
|
@@ -37,7 +37,7 @@ const TimeInput = React.forwardRef(({ defaultValue = '', value: propValue, onCha
|
|
|
37
37
|
const handleClearClick = () => {
|
|
38
38
|
setValue('');
|
|
39
39
|
};
|
|
40
|
-
return (React.createElement(Input,
|
|
40
|
+
return (React.createElement(Input, { ...restProps, ref: ref, value: value, className: className, onChange: handleChange, onClear: handleClearClick }));
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
export { TimeInput };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-time-input",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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": "^
|
|
19
|
-
"@alfalab/core-components-icon-button": "^
|
|
18
|
+
"@alfalab/core-components-input": "^11.0.0",
|
|
19
|
+
"@alfalab/core-components-icon-button": "^6.0.0"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/utils/format.js
CHANGED
|
@@ -17,16 +17,12 @@ var isValidTimeFormat = function (value) {
|
|
|
17
17
|
}
|
|
18
18
|
return true;
|
|
19
19
|
};
|
|
20
|
-
var isValidInputValue = function (inputValue) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
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
|
|
30
26
|
|
|
31
27
|
exports.DATE_MASK = DATE_MASK;
|
|
32
28
|
exports.format = format;
|