intelicoreact 0.1.33 → 0.1.36
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/dist/Atomic/FormElements/DateTime/DateTime.js +35 -10
- package/dist/Atomic/FormElements/DateTime/DateTime.scss +11 -5
- package/dist/Atomic/FormElements/DateTime/DateTime.stories.js +19 -2
- package/dist/Atomic/FormElements/DateTime/partial/AnyOuterClass.scss +9 -0
- package/dist/Atomic/FormElements/DoubleString/DoubleString.js +5 -3
- package/dist/Atomic/FormElements/DoubleString/DoubleString.scss +11 -6
- package/dist/Atomic/FormElements/DoubleString/DoubleString.stories.js +13 -1
- package/dist/Atomic/FormElements/DoubleString/partial/AnyOuterClass.scss +16 -0
- package/dist/Atomic/FormElements/Input/Input.js +10 -29
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.scss +1 -3
- package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +58 -0
- package/dist/Atomic/FormElements/InputMask/InputMask.js +615 -0
- package/dist/Atomic/FormElements/InputMask/InputMask.scss +111 -0
- package/dist/Atomic/FormElements/InputMask/InputMask.stories.js +199 -0
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +53 -23
- package/dist/Atomic/FormElements/NumericInput/NumericInput.stories.js +25 -5
- package/dist/Atomic/FormElements/RangeList/RangeList.js +18 -17
- package/dist/Atomic/FormElements/RangeList/RangeList.stories.js +18 -12
- package/dist/Functions/fieldValueFormatters.js +18 -12
- package/dist/Molecular/SwitcherRangeList/SwitcherRangeList.js +2 -2
- package/dist/Molecular/SwitcherRangeList/SwitcherRangeList.stories.js +4 -4
- package/package.json +1 -1
- package/dist/Atomic/FormElements/RangeList/partial/temp.js +0 -150
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
.unselectable {
|
|
2
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
3
|
+
-webkit-user-select: none; /* Safari */
|
|
4
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
5
|
+
-moz-user-select: none; /* Firefox */
|
|
6
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
7
|
+
user-select: none; /* Non-prefixed version, currently
|
|
8
|
+
supported by Chrome and Opera */
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.input-mask_wrapper {
|
|
12
|
+
outline: none;
|
|
13
|
+
display: block;
|
|
14
|
+
width: 250px;
|
|
15
|
+
|
|
16
|
+
.input-mask{
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
justify-content: space-between;
|
|
19
|
+
align-items: center;
|
|
20
|
+
border: 1px solid #e2e5ec;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
background-color: #fff;
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
padding:8px;
|
|
25
|
+
cursor: text;
|
|
26
|
+
width: 100%;
|
|
27
|
+
|
|
28
|
+
&_focus{
|
|
29
|
+
border-color: #6b81dd;
|
|
30
|
+
filter: drop-shadow(0px 0px 4px rgba(93, 120, 255, 0.5));
|
|
31
|
+
|
|
32
|
+
.input-mask_value {
|
|
33
|
+
opacity: 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&_error,
|
|
38
|
+
&_blink-error{
|
|
39
|
+
border-color: #dd6b6b;
|
|
40
|
+
filter: drop-shadow(0px 0px 4px rgba(255, 93, 93, 0.5));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&_icon{
|
|
44
|
+
height: 16px;
|
|
45
|
+
width: 16px;
|
|
46
|
+
position: relative;
|
|
47
|
+
|
|
48
|
+
&--left{
|
|
49
|
+
margin-right: 4px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&--right{
|
|
53
|
+
margin-left: 4px;
|
|
54
|
+
right: 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&_clear{
|
|
59
|
+
height: 16px;
|
|
60
|
+
width: 16px;
|
|
61
|
+
cursor: pointer!important;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&_value{
|
|
65
|
+
opacity: 0.6;
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
outline: none;
|
|
69
|
+
position: relative;
|
|
70
|
+
width: 100%;
|
|
71
|
+
|
|
72
|
+
&_item{
|
|
73
|
+
@extend .unselectable;
|
|
74
|
+
display: inline-flex;
|
|
75
|
+
min-width: 0;
|
|
76
|
+
font-size: 16px;
|
|
77
|
+
width: unset;
|
|
78
|
+
padding: 0;
|
|
79
|
+
margin: 0;
|
|
80
|
+
border: none;
|
|
81
|
+
outline: none;
|
|
82
|
+
|
|
83
|
+
&--letter{
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&_mask-char{
|
|
87
|
+
color: #9c9c9c;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&_value-char,
|
|
91
|
+
&_spec-char{
|
|
92
|
+
color: #333333;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&_spec-char{
|
|
96
|
+
text-align: center;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&:last-child{
|
|
100
|
+
max-width: 1px;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.input-mask_error-text{
|
|
107
|
+
font-size: 12px;
|
|
108
|
+
margin-top: 8px;
|
|
109
|
+
color:rgb(211, 82, 82);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.InputMaskTemplate = exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _reactFeather = require("react-feather");
|
|
19
|
+
|
|
20
|
+
var _InputMask = _interopRequireDefault(require("./InputMask"));
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
global.lng = 'en';
|
|
27
|
+
var _default = {
|
|
28
|
+
title: 'Form Elements/Input Mask',
|
|
29
|
+
component: _InputMask.default,
|
|
30
|
+
argTypes: {
|
|
31
|
+
maskPattern: {
|
|
32
|
+
title: 'Mask Pattern',
|
|
33
|
+
description: '<b>"D"</b> - Digit.<br/><b>"L"</b> or <b>"l"</b> - Letter.'
|
|
34
|
+
},
|
|
35
|
+
maskPatternPlaceholder: {
|
|
36
|
+
title: 'Pattern Placeholder',
|
|
37
|
+
description: 'Fine-tuning the mask character.<br/>Works if <b>"usePatternPlaceholder"</b> is <b>ENABLED</b>.'
|
|
38
|
+
},
|
|
39
|
+
usePatternPlaceholder: {
|
|
40
|
+
title: 'Pattern Placeholder',
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
default: false,
|
|
43
|
+
description: 'Turn <b>On/Off</b> use of <b>"maskPatternPlaceholder"</b>'
|
|
44
|
+
},
|
|
45
|
+
maskPlaceholder: {
|
|
46
|
+
title: 'Mask Placeholder',
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'General Mask Char.<br/>Uses if <b>"usePatternPlaceholder"</b> is <b>Turned Off</b> or Specialized Mask Char is not recieved.'
|
|
49
|
+
},
|
|
50
|
+
maskDigitPlaceholder: {
|
|
51
|
+
title: 'Specialized Mask Placeholder for Digit Char',
|
|
52
|
+
description: 'Specialized Mask Placeholder for <b>Digit</b>.'
|
|
53
|
+
},
|
|
54
|
+
maskLetterPlaceholder: {
|
|
55
|
+
title: 'Specialized Mask Placeholder for Letter Char',
|
|
56
|
+
description: 'Specialized Mask Placeholder for <b>Letter</b>.'
|
|
57
|
+
},
|
|
58
|
+
isCaseSensitive: {
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
default: false,
|
|
61
|
+
description: 'Turn <b>On/Off</b> use of <b>Case Sensitive Mode</b>.'
|
|
62
|
+
},
|
|
63
|
+
adaptTextCase: {
|
|
64
|
+
type: 'boolean',
|
|
65
|
+
default: false,
|
|
66
|
+
description: 'Turn <b>On/Off</b> use of <b>Auto Text Case Adapt</b>.'
|
|
67
|
+
},
|
|
68
|
+
icon: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
description: 'Icon for Input.<br/>Will works only if <b>"showIcon"</b> is <b>ENABLED</b>.'
|
|
71
|
+
},
|
|
72
|
+
showIcon: {
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
default: false,
|
|
75
|
+
description: 'Turn <b>On/Off</b> Icon Display.'
|
|
76
|
+
},
|
|
77
|
+
isIconLeft: {
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
default: false,
|
|
80
|
+
description: 'Display Icon on Left Side.'
|
|
81
|
+
},
|
|
82
|
+
isIconRight: {
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
default: false,
|
|
85
|
+
description: 'Display Icon on Right Side.'
|
|
86
|
+
},
|
|
87
|
+
isClearable: {
|
|
88
|
+
type: 'boolean',
|
|
89
|
+
default: false,
|
|
90
|
+
description: 'Display Clear Button and Enable Clearable Possibility.'
|
|
91
|
+
},
|
|
92
|
+
value: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'Input Value',
|
|
95
|
+
default: ''
|
|
96
|
+
},
|
|
97
|
+
onChange: {
|
|
98
|
+
type: 'function',
|
|
99
|
+
description: 'Callback Function for Handle <b>Input Value Change</b>'
|
|
100
|
+
},
|
|
101
|
+
blinkErrors: {
|
|
102
|
+
type: 'boolean',
|
|
103
|
+
default: true,
|
|
104
|
+
description: 'Turn <b>On/Off</b> Blinking Error Mode.'
|
|
105
|
+
},
|
|
106
|
+
blinkDuration: {
|
|
107
|
+
type: 'number',
|
|
108
|
+
description: 'Duration of <b>Error Blink</b> in <b>ms</b>.',
|
|
109
|
+
default: 100
|
|
110
|
+
},
|
|
111
|
+
showNativeErrors: {
|
|
112
|
+
type: 'boolean',
|
|
113
|
+
default: true,
|
|
114
|
+
description: 'Turn <b>On/Off</b> Display of Native Event Errors.'
|
|
115
|
+
},
|
|
116
|
+
errors: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
description: "Errors Descriptions: <br/>\n\n {\n onlyLetter: 'Type letter',\n onlyDigit: 'Type digit',\n onlyUpperCase: 'Type letter in UpperCase',\n onlyLowerCase: 'Type letter in LowerCase',\n default: null\n }\n"
|
|
119
|
+
},
|
|
120
|
+
onFocus: {
|
|
121
|
+
type: 'function',
|
|
122
|
+
description: 'Callback Function for Handle <b>Input Focus</b>'
|
|
123
|
+
},
|
|
124
|
+
onBlur: {
|
|
125
|
+
type: 'function',
|
|
126
|
+
description: 'Callback Function for Handle <b>Input Blur</b>'
|
|
127
|
+
},
|
|
128
|
+
className: {
|
|
129
|
+
type: 'string',
|
|
130
|
+
description: 'ClassName For Input Mask Wrapper',
|
|
131
|
+
default: ''
|
|
132
|
+
},
|
|
133
|
+
isFocusedDefault: {
|
|
134
|
+
type: 'boolean',
|
|
135
|
+
description: 'Set Autofocus On Render',
|
|
136
|
+
default: false
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
exports.default = _default;
|
|
141
|
+
|
|
142
|
+
var Template = function Template(args) {
|
|
143
|
+
var _useState = (0, _react.useState)(''),
|
|
144
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
145
|
+
value = _useState2[0],
|
|
146
|
+
setValue = _useState2[1];
|
|
147
|
+
|
|
148
|
+
var _useState3 = (0, _react.useState)(''),
|
|
149
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
150
|
+
clearValue = _useState4[0],
|
|
151
|
+
setClearValue = _useState4[1];
|
|
152
|
+
|
|
153
|
+
var ref = (0, _react.useRef)(null);
|
|
154
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
155
|
+
style: {
|
|
156
|
+
fontSize: "24px",
|
|
157
|
+
fontWeight: '200'
|
|
158
|
+
}
|
|
159
|
+
}, "Value: ", value), /*#__PURE__*/_react.default.createElement("div", {
|
|
160
|
+
style: {
|
|
161
|
+
fontSize: "24px",
|
|
162
|
+
fontWeight: '200'
|
|
163
|
+
}
|
|
164
|
+
}, "Clear Value: ", clearValue)), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_InputMask.default, (0, _extends2.default)({}, args, {
|
|
165
|
+
value: value,
|
|
166
|
+
onChange: function onChange(v, cv) {
|
|
167
|
+
setValue(v);
|
|
168
|
+
setClearValue(cv);
|
|
169
|
+
}
|
|
170
|
+
})));
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
var InputMaskTemplate = Template.bind({});
|
|
174
|
+
exports.InputMaskTemplate = InputMaskTemplate;
|
|
175
|
+
InputMaskTemplate.args = {
|
|
176
|
+
maskPattern: 'DDD DDD DDDD | LLL ll',
|
|
177
|
+
maskPatternPlaceholder: 'XXX xxx XXXX | AAA aa',
|
|
178
|
+
usePatternPlaceholder: false,
|
|
179
|
+
maskPlaceholder: '_',
|
|
180
|
+
maskDigitPlaceholder: '',
|
|
181
|
+
maskLetterPlaceholder: '',
|
|
182
|
+
isCaseSensitive: false,
|
|
183
|
+
adaptTextCase: false,
|
|
184
|
+
icon: /*#__PURE__*/_react.default.createElement(_reactFeather.Type, null),
|
|
185
|
+
showIcon: false,
|
|
186
|
+
isIconLeft: true,
|
|
187
|
+
isIconRight: false,
|
|
188
|
+
isClearable: false,
|
|
189
|
+
value: '',
|
|
190
|
+
onChange: function onChange() {},
|
|
191
|
+
blinkErrors: false,
|
|
192
|
+
blinkDuration: 100,
|
|
193
|
+
showNativeErrors: true,
|
|
194
|
+
errors: {},
|
|
195
|
+
onFocus: function onFocus() {},
|
|
196
|
+
onBlur: function onBlur() {},
|
|
197
|
+
className: '',
|
|
198
|
+
isFocusedDefault: false
|
|
199
|
+
};
|
|
@@ -41,8 +41,7 @@ var timerOutside;
|
|
|
41
41
|
var timerFocus;
|
|
42
42
|
|
|
43
43
|
var NumericInput = function NumericInput(_ref) {
|
|
44
|
-
var
|
|
45
|
-
disabled = _ref.disabled,
|
|
44
|
+
var disabled = _ref.disabled,
|
|
46
45
|
withDelete = _ref.withDelete,
|
|
47
46
|
_ref$numStep = _ref.numStep,
|
|
48
47
|
numStep = _ref$numStep === void 0 ? 1 : _ref$numStep,
|
|
@@ -52,9 +51,16 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
52
51
|
value = _ref.value,
|
|
53
52
|
placeholder = _ref.placeholder,
|
|
54
53
|
className = _ref.className,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
_ref$onChange = _ref.onChange,
|
|
55
|
+
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
56
|
+
_ref$onBlur = _ref.onBlur,
|
|
57
|
+
onBlur = _ref$onBlur === void 0 ? function () {} : _ref$onBlur,
|
|
58
|
+
_ref$onFocus = _ref.onFocus,
|
|
59
|
+
onFocus = _ref$onFocus === void 0 ? function () {} : _ref$onFocus,
|
|
60
|
+
_ref$onKeyUp = _ref.onKeyUp,
|
|
61
|
+
onKeyUp = _ref$onKeyUp === void 0 ? function () {} : _ref$onKeyUp,
|
|
62
|
+
_ref$onKeyDown = _ref.onKeyDown,
|
|
63
|
+
onKeyDown = _ref$onKeyDown === void 0 ? function () {} : _ref$onKeyDown,
|
|
58
64
|
mask = _ref.mask,
|
|
59
65
|
maskChar = _ref.maskChar,
|
|
60
66
|
formatChars = _ref.formatChars,
|
|
@@ -72,7 +78,7 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
72
78
|
var decRef = (0, _react.useRef)(null);
|
|
73
79
|
var incRef = (0, _react.useRef)(null);
|
|
74
80
|
var wrapRef = (0, _react.useRef)(null);
|
|
75
|
-
var previousValueRef = (0, _react.useRef)(value); // STATES
|
|
81
|
+
var previousValueRef = (0, _react.useRef)(value || min || ''); // STATES
|
|
76
82
|
|
|
77
83
|
var _useState = (0, _react.useState)(value || min || ''),
|
|
78
84
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -107,8 +113,16 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
107
113
|
var _useState13 = (0, _react.useState)(false),
|
|
108
114
|
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
109
115
|
isToHighlightError = _useState14[0],
|
|
110
|
-
setIsToHighlightError = _useState14[1];
|
|
116
|
+
setIsToHighlightError = _useState14[1];
|
|
111
117
|
|
|
118
|
+
var _useState15 = (0, _react.useState)(value || min || ''),
|
|
119
|
+
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
|
120
|
+
prevValue = _useState16[0],
|
|
121
|
+
setPreviousValue = _useState16[1];
|
|
122
|
+
|
|
123
|
+
var formatedValue = (0, _react.useMemo)(function () {
|
|
124
|
+
return isFocused ? (0, _fieldValueFormatters.formatToRemoveComa)(inputValue) : (0, _fieldValueFormatters.formatToAddBitDepthPoints)(inputValue);
|
|
125
|
+
}, [inputValue, isFocused]); // HANDLES
|
|
112
126
|
|
|
113
127
|
var handle = {
|
|
114
128
|
change: function change(e) {
|
|
@@ -144,36 +158,48 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
144
158
|
setEditing(false);
|
|
145
159
|
if (onBlur) onBlur(e);
|
|
146
160
|
},
|
|
161
|
+
keyDown: function keyDown(e) {
|
|
162
|
+
var _e$target;
|
|
163
|
+
|
|
164
|
+
setPreviousValue(e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
|
|
165
|
+
onKeyDown(e.keyCode, e);
|
|
166
|
+
},
|
|
147
167
|
keyUp: function keyUp(e) {
|
|
148
168
|
if (!isNotBlinkErrors) {
|
|
149
|
-
var _previousValueRef$cur;
|
|
150
|
-
|
|
151
169
|
var changedValue = '' + (value !== null && value !== void 0 ? value : '');
|
|
152
|
-
var previousValue = '' +
|
|
153
|
-
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
170
|
+
var previousValue = '' + prevValue;
|
|
171
|
+
var short = previousValue.length <= changedValue.length ? previousValue : changedValue;
|
|
172
|
+
var long = previousValue.length > changedValue.length ? previousValue : changedValue;
|
|
173
|
+
var infoAboutDifferencesSameness = short.split('').reduce(function (acc, symbol, idx) {
|
|
174
|
+
if (acc.countOn && symbol === long[idx]) acc.same.push(symbol);else {
|
|
175
|
+
acc.countOn = false;
|
|
176
|
+
acc.differences.push([idx, symbol]);
|
|
177
|
+
}
|
|
178
|
+
return acc;
|
|
179
|
+
}, {
|
|
180
|
+
same: [],
|
|
181
|
+
countOn: true,
|
|
182
|
+
differences: []
|
|
183
|
+
});
|
|
184
|
+
var samePart = infoAboutDifferencesSameness.same.join('');
|
|
185
|
+
var differencesLength = infoAboutDifferencesSameness.differences.length;
|
|
186
|
+
var currentSet = changedValue.replace(samePart, '');
|
|
187
|
+
if (!_index.KEYBOARD_SERVICE_KEYS.includes(e.key) && changedValue === previousValue) setIsAttemptToChange(!(!differencesLength && e.key === currentSet));
|
|
160
188
|
}
|
|
161
189
|
|
|
162
190
|
if (onKeyUp) onKeyUp(e.keyCode, e.target.value);
|
|
163
191
|
},
|
|
164
192
|
decrement: function decrement(e) {
|
|
165
|
-
handle.change(intMemoVal - +numStep);
|
|
193
|
+
handle.change(+intMemoVal - +numStep);
|
|
166
194
|
},
|
|
167
195
|
increment: function increment(e) {
|
|
168
|
-
handle.change(intMemoVal + +numStep);
|
|
196
|
+
handle.change(+intMemoVal + +numStep);
|
|
169
197
|
}
|
|
170
198
|
}; //Check Outside Click
|
|
171
199
|
|
|
172
200
|
(0, _react.useEffect)(function () {
|
|
173
201
|
var handleClickOutside = function handleClickOutside(event) {
|
|
174
|
-
if (!wrapRef.current.contains(event.target))
|
|
175
|
-
setIsFocused(false);
|
|
176
|
-
}
|
|
202
|
+
if (!wrapRef.current.contains(event.target)) setIsFocused(false);
|
|
177
203
|
};
|
|
178
204
|
|
|
179
205
|
document.addEventListener('mousedown', handleClickOutside, true);
|
|
@@ -189,7 +215,10 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
189
215
|
setIsToHighlightError(false);
|
|
190
216
|
}, blinkTime || DEFAULT_BLINK_TIME);
|
|
191
217
|
}
|
|
192
|
-
}, [isAttemptToChange]);
|
|
218
|
+
}, [isAttemptToChange]);
|
|
219
|
+
(0, _react.useEffect)(function () {
|
|
220
|
+
if (value && value !== inputValue) setInputValue(value);
|
|
221
|
+
}, [value]); //On Input Value Change
|
|
193
222
|
|
|
194
223
|
(0, _react.useEffect)(function () {
|
|
195
224
|
if (inputValue !== value) setIsFocused(true);
|
|
@@ -242,6 +271,7 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
242
271
|
onBlur: function onBlur() {
|
|
243
272
|
return setEditing(false);
|
|
244
273
|
},
|
|
274
|
+
onKeyDown: handle.keyDown,
|
|
245
275
|
onKeyUp: handle.keyUp,
|
|
246
276
|
min: min,
|
|
247
277
|
max: max
|
|
@@ -85,17 +85,37 @@ var _default = {
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
exports.default = _default;
|
|
88
|
+
var buttonStyles = {
|
|
89
|
+
border: 'solid 1px #000',
|
|
90
|
+
padding: '5px',
|
|
91
|
+
margin: '20px 0'
|
|
92
|
+
};
|
|
88
93
|
|
|
89
94
|
var Template = function Template(args) {
|
|
90
|
-
var _useState = (0, _react.useState)(
|
|
95
|
+
var _useState = (0, _react.useState)(),
|
|
91
96
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
92
97
|
value = _useState2[0],
|
|
93
98
|
setValue = _useState2[1];
|
|
94
99
|
|
|
95
|
-
|
|
100
|
+
var _useState3 = (0, _react.useState)(false),
|
|
101
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
102
|
+
isDsiabled = _useState4[0],
|
|
103
|
+
setIsDisabled = _useState4[1];
|
|
104
|
+
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_NumericInput.default, (0, _extends2.default)({}, args, {
|
|
96
106
|
value: value,
|
|
97
|
-
onChange: setValue
|
|
98
|
-
|
|
107
|
+
onChange: setValue,
|
|
108
|
+
disabled: isDsiabled
|
|
109
|
+
})), /*#__PURE__*/_react.default.createElement("button", {
|
|
110
|
+
style: buttonStyles,
|
|
111
|
+
onClick: function onClick() {
|
|
112
|
+
setIsDisabled(true);
|
|
113
|
+
setTimeout(function () {
|
|
114
|
+
setValue('500');
|
|
115
|
+
setIsDisabled(false);
|
|
116
|
+
}, 1000);
|
|
117
|
+
}
|
|
118
|
+
}, "start timeout"));
|
|
99
119
|
};
|
|
100
120
|
|
|
101
121
|
var NumericInputTemplate = Template.bind({});
|
|
@@ -111,7 +131,7 @@ NumericInputTemplate.args = {
|
|
|
111
131
|
numStep: 100,
|
|
112
132
|
min: '0',
|
|
113
133
|
max: '15000',
|
|
114
|
-
symbolsLimit:
|
|
134
|
+
symbolsLimit: 6,
|
|
115
135
|
placeholder: 'Placeholder' // icon: <User />
|
|
116
136
|
|
|
117
137
|
};
|
|
@@ -48,7 +48,7 @@ var RangeList = function RangeList(props) {
|
|
|
48
48
|
_props$value = props.value,
|
|
49
49
|
value = _props$value === void 0 ? [] : _props$value,
|
|
50
50
|
disabled = props.disabled,
|
|
51
|
-
|
|
51
|
+
validateErrors = props.validateErrors,
|
|
52
52
|
onChange = props.onChange,
|
|
53
53
|
isFloatValues = props.isFloatValues,
|
|
54
54
|
decimalPlaces = props.decimalPlaces,
|
|
@@ -67,6 +67,11 @@ var RangeList = function RangeList(props) {
|
|
|
67
67
|
innerError = _useState4[0],
|
|
68
68
|
setInnerError = _useState4[1];
|
|
69
69
|
|
|
70
|
+
var _useState5 = (0, _react.useState)(''),
|
|
71
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
72
|
+
outerError = _useState6[0],
|
|
73
|
+
setOuterError = _useState6[1];
|
|
74
|
+
|
|
70
75
|
var inputFromRef = (0, _react.useRef)(null);
|
|
71
76
|
var inputToRef = (0, _react.useRef)(null);
|
|
72
77
|
var isValidRange = !!(state !== null && state !== void 0 && state.from && state !== null && state !== void 0 && state.to && +(state === null || state === void 0 ? void 0 : state.from) <= +(state === null || state === void 0 ? void 0 : state.to));
|
|
@@ -75,13 +80,14 @@ var RangeList = function RangeList(props) {
|
|
|
75
80
|
return setState(_objectSpread(_objectSpread({}, state), {}, (0, _defineProperty2.default)({}, prop, val)));
|
|
76
81
|
},
|
|
77
82
|
addRange: function addRange() {
|
|
78
|
-
var
|
|
83
|
+
var _validateErrors;
|
|
79
84
|
|
|
80
|
-
if (isValidRange && ((
|
|
85
|
+
if (isValidRange && ((_validateErrors = !(validateErrors !== null && validateErrors !== void 0 && validateErrors(+state.from, +state.to))) !== null && _validateErrors !== void 0 ? _validateErrors : true)) {
|
|
81
86
|
onChange((0, _operations.addRangeDefault)(+state.from, +state.to, value, isFloatValues ? decimalPlaces : null));
|
|
82
87
|
setState(DEFAULT_STATE);
|
|
83
88
|
setInnerError('');
|
|
84
|
-
|
|
89
|
+
setOuterError('');
|
|
90
|
+
} else if (!isValidRange) setInnerError(defaultErrorText);else if (validateErrors) setOuterError(validateErrors(+state.from, +state.to));
|
|
85
91
|
},
|
|
86
92
|
removeRange: function removeRange(index) {
|
|
87
93
|
return onChange(value.filter(function (item, idx) {
|
|
@@ -93,18 +99,19 @@ var RangeList = function RangeList(props) {
|
|
|
93
99
|
|
|
94
100
|
if (!(state !== null && state !== void 0 && state.from) && !(state !== null && state !== void 0 && state.to)) {
|
|
95
101
|
setInnerError('');
|
|
102
|
+
setOuterError('');
|
|
96
103
|
return e;
|
|
97
104
|
} else if (!state[oppositeKey]) {
|
|
98
105
|
var mustToFocus = key === 'from' ? inputToRef.current : inputFromRef.current;
|
|
99
106
|
mustToFocus.focus();
|
|
100
|
-
} else if (!isValidRange)
|
|
107
|
+
} else if (!isValidRange) {
|
|
108
|
+
setInnerError(defaultErrorText);
|
|
109
|
+
if (validateErrors) setOuterError(validateErrors(+state.from, +state.to));
|
|
110
|
+
} else {
|
|
101
111
|
setInnerError('');
|
|
102
|
-
|
|
112
|
+
if (validateErrors) setOuterError(validateErrors(+state.from, +state.to));
|
|
103
113
|
}
|
|
104
114
|
},
|
|
105
|
-
onFocus: function onFocus() {
|
|
106
|
-
return setInnerError('');
|
|
107
|
-
},
|
|
108
115
|
onKeyUpFromInput: function onKeyUpFromInput(code) {
|
|
109
116
|
if (code === 13) {
|
|
110
117
|
if (isValidRange) inputFromRef.current.blur();else if (!state.to) inputToRef.current.focus();else if (state.from) inputFromRef.current.select();
|
|
@@ -135,9 +142,6 @@ var RangeList = function RangeList(props) {
|
|
|
135
142
|
type: 'int'
|
|
136
143
|
},
|
|
137
144
|
value: state.from,
|
|
138
|
-
onFocus: function onFocus() {
|
|
139
|
-
return handle.onFocus();
|
|
140
|
-
},
|
|
141
145
|
onBlur: function onBlur(e) {
|
|
142
146
|
return handle.rangeValidation(e, 'from');
|
|
143
147
|
},
|
|
@@ -158,9 +162,6 @@ var RangeList = function RangeList(props) {
|
|
|
158
162
|
type: 'int'
|
|
159
163
|
},
|
|
160
164
|
value: state.to,
|
|
161
|
-
onFocus: function onFocus() {
|
|
162
|
-
return handle.onFocus();
|
|
163
|
-
},
|
|
164
165
|
onBlur: function onBlur(e) {
|
|
165
166
|
return handle.rangeValidation(e, 'to');
|
|
166
167
|
},
|
|
@@ -174,9 +175,9 @@ var RangeList = function RangeList(props) {
|
|
|
174
175
|
className: "".concat(RC, "__cell-button")
|
|
175
176
|
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
176
177
|
onClick: handle.addRange
|
|
177
|
-
}, "Add"))), (innerError || error) && /*#__PURE__*/_react.default.createElement("span", {
|
|
178
|
+
}, "Add"))), (innerError || outerError || error) && /*#__PURE__*/_react.default.createElement("span", {
|
|
178
179
|
className: "".concat(RC, "__error")
|
|
179
|
-
}, error ||
|
|
180
|
+
}, innerError || error || outerError), !(value !== null && value !== void 0 && value.length) && /*#__PURE__*/_react.default.createElement("div", {
|
|
180
181
|
className: (0, _classnames.default)("".concat(RC, "__row"), "".concat(RC, "__values"), "".concat(RC, "__null-value"))
|
|
181
182
|
}, NULL_VALUE_TEXT), value.map(function (row, idx) {
|
|
182
183
|
return /*#__PURE__*/_react.default.createElement(_RangeListRow.default, (0, _extends2.default)({
|
|
@@ -21,7 +21,7 @@ var _RangeList = _interopRequireDefault(require("./RangeList"));
|
|
|
21
21
|
|
|
22
22
|
require("./partial/AnyOuterClass.scss");
|
|
23
23
|
|
|
24
|
-
var _excluded = ["includeOuterStyles", "
|
|
24
|
+
var _excluded = ["includeOuterStyles", "isAddValidateErrorsForExamle", "isUseErrorsState", "isUseInitialValues", "initialValues"];
|
|
25
25
|
|
|
26
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
27
|
|
|
@@ -41,7 +41,8 @@ var rootStyles = {
|
|
|
41
41
|
|
|
42
42
|
var Template = function Template(args) {
|
|
43
43
|
var includeOuterStyles = args.includeOuterStyles,
|
|
44
|
-
|
|
44
|
+
isAddValidateErrorsForExamle = args.isAddValidateErrorsForExamle,
|
|
45
|
+
isUseErrorsState = args.isUseErrorsState,
|
|
45
46
|
isUseInitialValues = args.isUseInitialValues,
|
|
46
47
|
initialValues = args.initialValues,
|
|
47
48
|
restArgs = (0, _objectWithoutProperties2.default)(args, _excluded);
|
|
@@ -56,14 +57,18 @@ var Template = function Template(args) {
|
|
|
56
57
|
error = _useState4[0],
|
|
57
58
|
setError = _useState4[1];
|
|
58
59
|
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
var getValidate = function getValidate(isUseState) {
|
|
61
|
+
return function (from, to) {
|
|
62
|
+
var errorText = '18 is the minimum allowed value';
|
|
63
|
+
|
|
64
|
+
if (+from < 18) {
|
|
65
|
+
if (isUseState) setError(errorText);
|
|
66
|
+
return errorText;
|
|
67
|
+
} else {
|
|
68
|
+
if (isUseState) setError('');
|
|
69
|
+
return '';
|
|
70
|
+
}
|
|
71
|
+
};
|
|
67
72
|
};
|
|
68
73
|
|
|
69
74
|
(0, _react.useEffect)(function () {
|
|
@@ -79,7 +84,7 @@ var Template = function Template(args) {
|
|
|
79
84
|
return setValue(val);
|
|
80
85
|
},
|
|
81
86
|
error: error,
|
|
82
|
-
|
|
87
|
+
validateErrors: isAddValidateErrorsForExamle ? getValidate(isUseErrorsState) : null
|
|
83
88
|
})));
|
|
84
89
|
};
|
|
85
90
|
|
|
@@ -87,7 +92,8 @@ var RangeListTemplate = Template.bind({});
|
|
|
87
92
|
exports.RangeListTemplate = RangeListTemplate;
|
|
88
93
|
RangeListTemplate.args = {
|
|
89
94
|
includeOuterStyles: false,
|
|
90
|
-
|
|
95
|
+
isAddValidateErrorsForExamle: true,
|
|
96
|
+
isUseErrorsState: false,
|
|
91
97
|
disabled: false,
|
|
92
98
|
isFloatValues: false,
|
|
93
99
|
decimalPlaces: 2,
|