@alfalab/core-components-date-input 2.1.5 → 2.3.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/CHANGELOG.md CHANGED
@@ -3,6 +3,49 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.3.0](https://github.com/core-ds/core-components/compare/@alfalab/core-components-date-input@2.2.2...@alfalab/core-components-date-input@2.3.0) (2022-06-28)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **pure-cell:** fix stories ([#113](https://github.com/core-ds/core-components/issues/113)) ([01f6138](https://github.com/core-ds/core-components/commit/01f6138615b1b7268510e012c314650c084c9ef0))
12
+
13
+
14
+ ### Features
15
+
16
+ * circumflexus retrieval ([#57](https://github.com/core-ds/core-components/issues/57)) ([3820da8](https://github.com/core-ds/core-components/commit/3820da818bcdcbee6904c648b3e29c3c828fe202))
17
+
18
+
19
+
20
+
21
+
22
+ ## [2.2.2](https://github.com/core-ds/core-components/compare/@alfalab/core-components-date-input@2.2.1...@alfalab/core-components-date-input@2.2.2) (2022-06-23)
23
+
24
+ **Note:** Version bump only for package @alfalab/core-components-date-input
25
+
26
+
27
+
28
+
29
+
30
+ ## [2.2.1](https://github.com/core-ds/core-components/compare/@alfalab/core-components-date-input@2.2.0...@alfalab/core-components-date-input@2.2.1) (2022-06-20)
31
+
32
+ **Note:** Version bump only for package @alfalab/core-components-date-input
33
+
34
+
35
+
36
+
37
+
38
+ # [2.2.0](https://github.com/core-ds/core-components/compare/@alfalab/core-components-date-input@2.1.5...@alfalab/core-components-date-input@2.2.0) (2022-06-03)
39
+
40
+
41
+ ### Features
42
+
43
+ * **date-input:** removed date validation ([#69](https://github.com/core-ds/core-components/issues/69)) ([ca56ec9](https://github.com/core-ds/core-components/commit/ca56ec97db0d966233bd4312fdddabd59ed427ae))
44
+
45
+
46
+
47
+
48
+
6
49
  # [2.1.0](https://github.com/core-ds/core-components/compare/@alfalab/core-components-date-input@2.0.0...@alfalab/core-components-date-input@2.1.0) (2022-03-04)
7
50
 
8
51
 
package/dist/Component.js CHANGED
@@ -55,7 +55,7 @@ function __rest(s, e) {
55
55
  return t;
56
56
  }
57
57
 
58
- var styles = {"nativeInput":"date-input__nativeInput_1msxi"};
58
+ var styles = {"nativeInput":"date-input__nativeInput_aj9op"};
59
59
  require('./index.css')
60
60
 
61
61
  var DateInput = React.forwardRef(function (_a, ref) {
@@ -63,14 +63,6 @@ var DateInput = React.forwardRef(function (_a, ref) {
63
63
  var inputRef = React.useRef(null);
64
64
  var _d = React.useState(false), shouldRenderNative = _d[0], setShouldRenderNative = _d[1];
65
65
  var _e = React.useState(propValue || defaultValue), value = _e[0], setValue = _e[1];
66
- var _f = React.useState(!utils_format.isValid(propValue)), stateError = _f[0], setStateError = _f[1];
67
- var handleValueValidity = React.useCallback(function (inputValue) {
68
- // Валидируем незаполненное значение только если инпут не в фокусе (блюр, либо установка значения снаружи)
69
- var validateIncomplete = inputRef.current && document.activeElement !== inputRef.current;
70
- if (!inputValue || validateIncomplete || inputValue.length >= utils_format.DATE_MASK.length) {
71
- setStateError(!utils_format.isValid(inputValue));
72
- }
73
- }, []);
74
66
  var handleChange = React.useCallback(function (event) {
75
67
  var newValue = event.target.value;
76
68
  // Позволяем вводить только цифры и точки
@@ -106,10 +98,9 @@ var DateInput = React.forwardRef(function (_a, ref) {
106
98
  onChange(event, { date: newDate, value: newValue });
107
99
  }, [onComplete, onChange]);
108
100
  var handleBlur = React.useCallback(function (event) {
109
- handleValueValidity(value);
110
101
  if (onBlur)
111
102
  onBlur(event);
112
- }, [handleValueValidity, onBlur, value]);
103
+ }, [onBlur]);
113
104
  React.useEffect(function () {
114
105
  if (mobileMode === 'native' && utils_nativeSupports.isInputDateSupported()) {
115
106
  setShouldRenderNative(true);
@@ -121,10 +112,7 @@ var DateInput = React.forwardRef(function (_a, ref) {
121
112
  }
122
113
  // eslint-disable-next-line react-hooks/exhaustive-deps
123
114
  }, [propValue]);
124
- React.useEffect(function () {
125
- handleValueValidity(value);
126
- }, [handleValueValidity, value]);
127
- return (React__default['default'].createElement(coreComponentsInput.Input, __assign({}, restProps, { ref: mergeRefs__default['default']([ref, inputRef]), value: value, inputMode: 'decimal', pattern: '[0-9\\.]*', onChange: handleChange, onBlur: handleBlur, placeholder: '\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413', error: error || stateError, rightAddons: React__default['default'].createElement(React__default['default'].Fragment, null,
115
+ return (React__default['default'].createElement(coreComponentsInput.Input, __assign({}, restProps, { ref: mergeRefs__default['default']([ref, inputRef]), value: value, inputMode: 'decimal', pattern: '[0-9\\.]*', onChange: handleChange, onBlur: handleBlur, placeholder: '\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413', error: error, rightAddons: React__default['default'].createElement(React__default['default'].Fragment, null,
128
116
  rightAddons,
129
117
  shouldRenderNative && (React__default['default'].createElement("input", { type: 'date', ref: ref, defaultValue: defaultValue, onChange: handleNativeInputChange, className: styles.nativeInput }))) })));
130
118
  });
@@ -62,14 +62,6 @@ var DateInput = React.forwardRef(function (_a, ref) {
62
62
  var inputRef = React.useRef(null);
63
63
  var _d = React.useState(false), shouldRenderNative = _d[0], setShouldRenderNative = _d[1];
64
64
  var _e = React.useState(propValue || defaultValue), value = _e[0], setValue = _e[1];
65
- var _f = React.useState(!utils_format.isValid(propValue)), stateError = _f[0], setStateError = _f[1];
66
- var handleValueValidity = React.useCallback(function (inputValue) {
67
- // Валидируем незаполненное значение только если инпут не в фокусе (блюр, либо установка значения снаружи)
68
- var validateIncomplete = inputRef.current && document.activeElement !== inputRef.current;
69
- if (!inputValue || validateIncomplete || inputValue.length >= utils_format.DATE_MASK.length) {
70
- setStateError(!utils_format.isValid(inputValue));
71
- }
72
- }, []);
73
65
  var handleChange = React.useCallback(function (event) {
74
66
  var newValue = event.target.value;
75
67
  // Позволяем вводить только цифры и точки
@@ -105,10 +97,9 @@ var DateInput = React.forwardRef(function (_a, ref) {
105
97
  onChange(event, { date: newDate, value: newValue });
106
98
  }, [onComplete, onChange]);
107
99
  var handleBlur = React.useCallback(function (event) {
108
- handleValueValidity(value);
109
100
  if (onBlur)
110
101
  onBlur(event);
111
- }, [handleValueValidity, onBlur, value]);
102
+ }, [onBlur]);
112
103
  React.useEffect(function () {
113
104
  if (mobileMode === 'native' && utils_nativeSupports.isInputDateSupported()) {
114
105
  setShouldRenderNative(true);
@@ -120,10 +111,7 @@ var DateInput = React.forwardRef(function (_a, ref) {
120
111
  }
121
112
  // eslint-disable-next-line react-hooks/exhaustive-deps
122
113
  }, [propValue]);
123
- React.useEffect(function () {
124
- handleValueValidity(value);
125
- }, [handleValueValidity, value]);
126
- return (React__default['default'].createElement(coreComponentsInput.Input, __assign({}, restProps, { ref: mergeRefs__default['default']([ref, inputRef]), value: value, inputMode: 'decimal', pattern: '[0-9\\.]*', onChange: handleChange, onBlur: handleBlur, placeholder: '\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413', error: error || stateError, rightAddons: React__default['default'].createElement(React__default['default'].Fragment, null,
114
+ return (React__default['default'].createElement(coreComponentsInput.Input, __assign({}, restProps, { ref: mergeRefs__default['default']([ref, inputRef]), value: value, inputMode: 'decimal', pattern: '[0-9\\.]*', onChange: handleChange, onBlur: handleBlur, placeholder: '\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413', error: error, rightAddons: React__default['default'].createElement(React__default['default'].Fragment, null,
127
115
  rightAddons,
128
116
  shouldRenderNative && (React__default['default'].createElement("input", { type: 'date', ref: ref, defaultValue: defaultValue, onChange: handleNativeInputChange, className: styles__default['default'].nativeInput }))) })));
129
117
  });
@@ -4,7 +4,7 @@ import mergeRefs from 'react-merge-refs';
4
4
  import 'date-fns/parse';
5
5
  import 'date-fns/format';
6
6
  import 'date-fns/isValid';
7
- import { isValid, DATE_MASK, format, parseDateString, isCompleteDateInput, NATIVE_DATE_FORMAT, formatDate } from './utils/format.js';
7
+ import { format, parseDateString, isCompleteDateInput, isValid, NATIVE_DATE_FORMAT, formatDate } from './utils/format.js';
8
8
  import { isInputDateSupported } from './utils/native-supports.js';
9
9
 
10
10
  /*! *****************************************************************************
@@ -46,7 +46,7 @@ function __rest(s, e) {
46
46
  return t;
47
47
  }
48
48
 
49
- var styles = {"nativeInput":"date-input__nativeInput_1msxi"};
49
+ var styles = {"nativeInput":"date-input__nativeInput_aj9op"};
50
50
  require('./index.css')
51
51
 
52
52
  var DateInput = forwardRef(function (_a, ref) {
@@ -54,14 +54,6 @@ var DateInput = forwardRef(function (_a, ref) {
54
54
  var inputRef = useRef(null);
55
55
  var _d = useState(false), shouldRenderNative = _d[0], setShouldRenderNative = _d[1];
56
56
  var _e = useState(propValue || defaultValue), value = _e[0], setValue = _e[1];
57
- var _f = useState(!isValid(propValue)), stateError = _f[0], setStateError = _f[1];
58
- var handleValueValidity = useCallback(function (inputValue) {
59
- // Валидируем незаполненное значение только если инпут не в фокусе (блюр, либо установка значения снаружи)
60
- var validateIncomplete = inputRef.current && document.activeElement !== inputRef.current;
61
- if (!inputValue || validateIncomplete || inputValue.length >= DATE_MASK.length) {
62
- setStateError(!isValid(inputValue));
63
- }
64
- }, []);
65
57
  var handleChange = useCallback(function (event) {
66
58
  var newValue = event.target.value;
67
59
  // Позволяем вводить только цифры и точки
@@ -97,10 +89,9 @@ var DateInput = forwardRef(function (_a, ref) {
97
89
  onChange(event, { date: newDate, value: newValue });
98
90
  }, [onComplete, onChange]);
99
91
  var handleBlur = useCallback(function (event) {
100
- handleValueValidity(value);
101
92
  if (onBlur)
102
93
  onBlur(event);
103
- }, [handleValueValidity, onBlur, value]);
94
+ }, [onBlur]);
104
95
  useEffect(function () {
105
96
  if (mobileMode === 'native' && isInputDateSupported()) {
106
97
  setShouldRenderNative(true);
@@ -112,10 +103,7 @@ var DateInput = forwardRef(function (_a, ref) {
112
103
  }
113
104
  // eslint-disable-next-line react-hooks/exhaustive-deps
114
105
  }, [propValue]);
115
- useEffect(function () {
116
- handleValueValidity(value);
117
- }, [handleValueValidity, value]);
118
- return (React.createElement(Input, __assign({}, restProps, { ref: mergeRefs([ref, inputRef]), value: value, inputMode: 'decimal', pattern: '[0-9\\.]*', onChange: handleChange, onBlur: handleBlur, placeholder: '\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413', error: error || stateError, rightAddons: React.createElement(React.Fragment, null,
106
+ return (React.createElement(Input, __assign({}, restProps, { ref: mergeRefs([ref, inputRef]), value: value, inputMode: 'decimal', pattern: '[0-9\\.]*', onChange: handleChange, onBlur: handleBlur, placeholder: '\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413', error: error, rightAddons: React.createElement(React.Fragment, null,
119
107
  rightAddons,
120
108
  shouldRenderNative && (React.createElement("input", { type: 'date', ref: ref, defaultValue: defaultValue, onChange: handleNativeInputChange, className: styles.nativeInput }))) })));
121
109
  });
@@ -1,4 +1,4 @@
1
- /* hash: j1n08 */
1
+ /* hash: 1b4he */
2
2
  :root {
3
3
 
4
4
  /* Hard */
@@ -7,7 +7,7 @@
7
7
 
8
8
  /* Hard up */
9
9
  }
10
- .date-input__nativeInput_1msxi {
10
+ .date-input__nativeInput_aj9op {
11
11
  opacity: 0;
12
12
  position: absolute;
13
13
  top: 0;
@@ -18,9 +18,9 @@
18
18
  appearance: none;
19
19
  z-index: 1
20
20
  }
21
- .date-input__nativeInput_1msxi::-webkit-calendar-picker-indicator {
21
+ .date-input__nativeInput_aj9op::-webkit-calendar-picker-indicator {
22
22
  display: none;
23
23
  }
24
- .date-input__nativeInput_1msxi::-webkit-inner-spin-button {
24
+ .date-input__nativeInput_aj9op::-webkit-inner-spin-button {
25
25
  display: none;
26
26
  }
package/dist/index.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: j1n08 */
1
+ /* hash: 1b4he */
2
2
  :root {
3
3
 
4
4
  /* Hard */
@@ -7,7 +7,7 @@
7
7
 
8
8
  /* Hard up */
9
9
  }
10
- .date-input__nativeInput_1msxi {
10
+ .date-input__nativeInput_aj9op {
11
11
  opacity: 0;
12
12
  position: absolute;
13
13
  top: 0;
@@ -18,9 +18,9 @@
18
18
  appearance: none;
19
19
  z-index: 1
20
20
  }
21
- .date-input__nativeInput_1msxi::-webkit-calendar-picker-indicator {
21
+ .date-input__nativeInput_aj9op::-webkit-calendar-picker-indicator {
22
22
  display: none;
23
23
  }
24
- .date-input__nativeInput_1msxi::-webkit-inner-spin-button {
24
+ .date-input__nativeInput_aj9op::-webkit-inner-spin-button {
25
25
  display: none;
26
26
  }
@@ -4,24 +4,16 @@ import mergeRefs from 'react-merge-refs';
4
4
  import 'date-fns/parse';
5
5
  import 'date-fns/format';
6
6
  import 'date-fns/isValid';
7
- import { isValid, DATE_MASK, format, parseDateString, isCompleteDateInput, NATIVE_DATE_FORMAT, formatDate } from './utils/format.js';
7
+ import { format, parseDateString, isCompleteDateInput, isValid, NATIVE_DATE_FORMAT, formatDate } from './utils/format.js';
8
8
  import { isInputDateSupported } from './utils/native-supports.js';
9
9
 
10
- var styles = {"nativeInput":"date-input__nativeInput_1msxi"};
10
+ var styles = {"nativeInput":"date-input__nativeInput_aj9op"};
11
11
  require('./index.css')
12
12
 
13
13
  const DateInput = forwardRef(({ mobileMode = 'input', defaultValue = '', rightAddons, error, value: propValue, onBlur, onChange, onComplete, ...restProps }, ref) => {
14
14
  const inputRef = useRef(null);
15
15
  const [shouldRenderNative, setShouldRenderNative] = useState(false);
16
16
  const [value, setValue] = useState(propValue || defaultValue);
17
- const [stateError, setStateError] = useState(!isValid(propValue));
18
- const handleValueValidity = useCallback((inputValue) => {
19
- // Валидируем незаполненное значение только если инпут не в фокусе (блюр, либо установка значения снаружи)
20
- const validateIncomplete = inputRef.current && document.activeElement !== inputRef.current;
21
- if (!inputValue || validateIncomplete || inputValue.length >= DATE_MASK.length) {
22
- setStateError(!isValid(inputValue));
23
- }
24
- }, []);
25
17
  const handleChange = useCallback((event) => {
26
18
  const { value: newValue } = event.target;
27
19
  // Позволяем вводить только цифры и точки
@@ -57,10 +49,9 @@ const DateInput = forwardRef(({ mobileMode = 'input', defaultValue = '', rightAd
57
49
  onChange(event, { date: newDate, value: newValue });
58
50
  }, [onComplete, onChange]);
59
51
  const handleBlur = useCallback((event) => {
60
- handleValueValidity(value);
61
52
  if (onBlur)
62
53
  onBlur(event);
63
- }, [handleValueValidity, onBlur, value]);
54
+ }, [onBlur]);
64
55
  useEffect(() => {
65
56
  if (mobileMode === 'native' && isInputDateSupported()) {
66
57
  setShouldRenderNative(true);
@@ -72,10 +63,7 @@ const DateInput = forwardRef(({ mobileMode = 'input', defaultValue = '', rightAd
72
63
  }
73
64
  // eslint-disable-next-line react-hooks/exhaustive-deps
74
65
  }, [propValue]);
75
- useEffect(() => {
76
- handleValueValidity(value);
77
- }, [handleValueValidity, value]);
78
- return (React.createElement(Input, Object.assign({}, restProps, { ref: mergeRefs([ref, inputRef]), value: value, inputMode: 'decimal', pattern: '[0-9\\.]*', onChange: handleChange, onBlur: handleBlur, placeholder: '\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413', error: error || stateError, rightAddons: React.createElement(React.Fragment, null,
66
+ return (React.createElement(Input, Object.assign({}, restProps, { ref: mergeRefs([ref, inputRef]), value: value, inputMode: 'decimal', pattern: '[0-9\\.]*', onChange: handleChange, onBlur: handleBlur, placeholder: '\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413', error: error, rightAddons: React.createElement(React.Fragment, null,
79
67
  rightAddons,
80
68
  shouldRenderNative && (React.createElement("input", { type: 'date', ref: ref, defaultValue: defaultValue, onChange: handleNativeInputChange, className: styles.nativeInput }))) })));
81
69
  });
@@ -1,4 +1,4 @@
1
- /* hash: j1n08 */
1
+ /* hash: 1b4he */
2
2
  :root {
3
3
 
4
4
  /* Hard */
@@ -7,7 +7,7 @@
7
7
 
8
8
  /* Hard up */
9
9
  }
10
- .date-input__nativeInput_1msxi {
10
+ .date-input__nativeInput_aj9op {
11
11
  opacity: 0;
12
12
  position: absolute;
13
13
  top: 0;
@@ -18,9 +18,9 @@
18
18
  appearance: none;
19
19
  z-index: 1
20
20
  }
21
- .date-input__nativeInput_1msxi::-webkit-calendar-picker-indicator {
21
+ .date-input__nativeInput_aj9op::-webkit-calendar-picker-indicator {
22
22
  display: none;
23
23
  }
24
- .date-input__nativeInput_1msxi::-webkit-inner-spin-button {
24
+ .date-input__nativeInput_aj9op::-webkit-inner-spin-button {
25
25
  display: none;
26
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-date-input",
3
- "version": "2.1.5",
3
+ "version": "2.3.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -19,9 +19,9 @@
19
19
  "react": "^16.9.0 || ^17.0.1"
20
20
  },
21
21
  "dependencies": {
22
- "@alfalab/core-components-input": "^8.1.5",
23
- "date-fns": "2.16.1",
24
- "react-merge-refs": "1.1.0"
22
+ "@alfalab/core-components-input": "^8.2.0",
23
+ "date-fns": "^2.16.1",
24
+ "react-merge-refs": "^1.1.0"
25
25
  },
26
- "gitHead": "b44d81f1c42835fa6946c4bf15aee99abe2b4b96"
26
+ "gitHead": "dcd5c0c8e25b7c374ff9311505ccf738a82e22c0"
27
27
  }