intelicoreact 0.1.34 → 0.1.37
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 +896 -0
- package/dist/Atomic/FormElements/InputMask/InputMask.scss +138 -0
- package/dist/Atomic/FormElements/InputMask/InputMask.stories.js +247 -0
- package/dist/Atomic/FormElements/InputMask/functions.js +45 -0
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +53 -23
- package/dist/Atomic/FormElements/NumericInput/NumericInput.stories.js +25 -5
- package/dist/Functions/fieldValueFormatters.js +18 -12
- package/package.json +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
.input-mask_wrapper {
|
|
2
|
+
outline: none;
|
|
3
|
+
display: block;
|
|
4
|
+
// width: fit-content;
|
|
5
|
+
width: 250px;
|
|
6
|
+
|
|
7
|
+
.input-mask{
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
align-items: center;
|
|
11
|
+
border: 1px solid #e2e5ec;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
background-color: #fff;
|
|
14
|
+
border-radius: 4px;
|
|
15
|
+
padding:8px;
|
|
16
|
+
cursor: text;
|
|
17
|
+
width: 100%;
|
|
18
|
+
|
|
19
|
+
&_focus{
|
|
20
|
+
border-color: #6b81dd;
|
|
21
|
+
filter: drop-shadow(0px 0px 4px rgba(93, 120, 255, 0.5));
|
|
22
|
+
|
|
23
|
+
.input-mask_value {
|
|
24
|
+
opacity: 1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&_error,
|
|
29
|
+
&_blink-error{
|
|
30
|
+
border-color: #dd6b6b;
|
|
31
|
+
filter: drop-shadow(0px 0px 4px rgba(255, 93, 93, 0.5));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&_icon{
|
|
35
|
+
height: 16px;
|
|
36
|
+
width: 16px;
|
|
37
|
+
position: relative;
|
|
38
|
+
|
|
39
|
+
&--left{
|
|
40
|
+
margin-right: 4px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&--right{
|
|
44
|
+
margin-left: 4px;
|
|
45
|
+
right: 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&_hint{
|
|
50
|
+
display: flex;
|
|
51
|
+
text-align: center;
|
|
52
|
+
align-items: center;
|
|
53
|
+
|
|
54
|
+
& .hint__text_right{
|
|
55
|
+
top: 50%;
|
|
56
|
+
left: 24px;
|
|
57
|
+
transform: translateY(-50%);
|
|
58
|
+
|
|
59
|
+
&::before{
|
|
60
|
+
top: calc(50% - 4px);
|
|
61
|
+
left: -3px;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
& .hint__text_left{
|
|
66
|
+
top: 50%;
|
|
67
|
+
right: 32px;
|
|
68
|
+
transform: translateY(-50%);
|
|
69
|
+
|
|
70
|
+
&::before{
|
|
71
|
+
top: calc(50% - 4px);
|
|
72
|
+
right: -3px;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&--left{
|
|
77
|
+
margin-right: 4px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&--right{
|
|
81
|
+
margin-left: 4px;
|
|
82
|
+
right: 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&_clear{
|
|
87
|
+
height: 16px;
|
|
88
|
+
width: 16px;
|
|
89
|
+
cursor: pointer!important;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&_value{
|
|
93
|
+
opacity: 0.6;
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
outline: none;
|
|
97
|
+
position: relative;
|
|
98
|
+
width: 100%;
|
|
99
|
+
|
|
100
|
+
&_item{
|
|
101
|
+
display: inline-flex;
|
|
102
|
+
min-width: 0;
|
|
103
|
+
font-size: 16px;
|
|
104
|
+
width: unset;
|
|
105
|
+
padding: 0;
|
|
106
|
+
margin: 0;
|
|
107
|
+
border: none;
|
|
108
|
+
outline: none;
|
|
109
|
+
|
|
110
|
+
&--letter{
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&_mask-char{
|
|
114
|
+
color: #9c9c9c;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&_value-char,
|
|
118
|
+
&_spec-char{
|
|
119
|
+
color: #333333;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&_spec-char{
|
|
123
|
+
text-align: center;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&:last-child{
|
|
127
|
+
max-width: 1px;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.input-mask_error-text{
|
|
134
|
+
font-size: 12px;
|
|
135
|
+
margin-top: 8px;
|
|
136
|
+
color:rgb(211, 82, 82);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
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
|
+
imitateTypingOnPaste: {
|
|
139
|
+
type: 'boolean',
|
|
140
|
+
description: '<b>Manual Input Simulation Mode</b> when called <b>Pasting Text Event</b>.',
|
|
141
|
+
default: false
|
|
142
|
+
},
|
|
143
|
+
imitateTypingOnPasteDelay: {
|
|
144
|
+
type: 'number',
|
|
145
|
+
description: '<b>Delay Time</b> for <b>Manual Input Simulation Mode</b> when called <b>Pasting Text Event</b>.',
|
|
146
|
+
default: 100
|
|
147
|
+
},
|
|
148
|
+
showHint: {
|
|
149
|
+
type: 'boolean',
|
|
150
|
+
description: 'Turn <b>On/Off</b> Input Hint.',
|
|
151
|
+
default: false
|
|
152
|
+
},
|
|
153
|
+
hintText: {
|
|
154
|
+
type: 'string',
|
|
155
|
+
description: 'Input Hint Text.',
|
|
156
|
+
default: ''
|
|
157
|
+
},
|
|
158
|
+
hintClassName: {
|
|
159
|
+
type: 'string',
|
|
160
|
+
description: 'ClassName for Input Hint.',
|
|
161
|
+
default: ''
|
|
162
|
+
},
|
|
163
|
+
isHintLeft: {
|
|
164
|
+
type: 'boolean',
|
|
165
|
+
default: false,
|
|
166
|
+
description: 'Display Input Hint on Left Side.'
|
|
167
|
+
},
|
|
168
|
+
isHintRight: {
|
|
169
|
+
type: 'boolean',
|
|
170
|
+
default: true,
|
|
171
|
+
description: 'Display Input Hint on Right Side.'
|
|
172
|
+
},
|
|
173
|
+
hintPosition: {
|
|
174
|
+
type: 'string',
|
|
175
|
+
description: 'Position of <b>Input Hint Text</b>',
|
|
176
|
+
default: 'right'
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
exports.default = _default;
|
|
181
|
+
|
|
182
|
+
var Template = function Template(args) {
|
|
183
|
+
var _useState = (0, _react.useState)(''),
|
|
184
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
185
|
+
value = _useState2[0],
|
|
186
|
+
setValue = _useState2[1];
|
|
187
|
+
|
|
188
|
+
var _useState3 = (0, _react.useState)(''),
|
|
189
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
190
|
+
clearValue = _useState4[0],
|
|
191
|
+
setClearValue = _useState4[1];
|
|
192
|
+
|
|
193
|
+
var ref = (0, _react.useRef)(null);
|
|
194
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
195
|
+
style: {
|
|
196
|
+
fontSize: "24px",
|
|
197
|
+
fontWeight: '200'
|
|
198
|
+
}
|
|
199
|
+
}, "Value: ", value), /*#__PURE__*/_react.default.createElement("div", {
|
|
200
|
+
style: {
|
|
201
|
+
fontSize: "24px",
|
|
202
|
+
fontWeight: '200'
|
|
203
|
+
}
|
|
204
|
+
}, "Clear Value: ", clearValue)), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_InputMask.default, (0, _extends2.default)({}, args, {
|
|
205
|
+
value: value,
|
|
206
|
+
onChange: function onChange(v, cv) {
|
|
207
|
+
setValue(v);
|
|
208
|
+
setClearValue(cv);
|
|
209
|
+
}
|
|
210
|
+
})));
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
var InputMaskTemplate = Template.bind({});
|
|
214
|
+
exports.InputMaskTemplate = InputMaskTemplate;
|
|
215
|
+
InputMaskTemplate.args = {
|
|
216
|
+
maskPattern: 'DDDD DDDD DDDD DDDD',
|
|
217
|
+
maskPatternPlaceholder: 'xxxx xxxx xxxx xxxx',
|
|
218
|
+
usePatternPlaceholder: false,
|
|
219
|
+
maskPlaceholder: '_',
|
|
220
|
+
maskDigitPlaceholder: '',
|
|
221
|
+
maskLetterPlaceholder: '',
|
|
222
|
+
isCaseSensitive: false,
|
|
223
|
+
adaptTextCase: false,
|
|
224
|
+
icon: /*#__PURE__*/_react.default.createElement(_reactFeather.Type, null),
|
|
225
|
+
showIcon: false,
|
|
226
|
+
isIconLeft: true,
|
|
227
|
+
isIconRight: false,
|
|
228
|
+
isClearable: true,
|
|
229
|
+
value: '',
|
|
230
|
+
onChange: function onChange() {},
|
|
231
|
+
blinkErrors: false,
|
|
232
|
+
blinkDuration: 100,
|
|
233
|
+
showNativeErrors: true,
|
|
234
|
+
errors: {},
|
|
235
|
+
onFocus: function onFocus() {},
|
|
236
|
+
onBlur: function onBlur() {},
|
|
237
|
+
className: '',
|
|
238
|
+
isFocusedDefault: false,
|
|
239
|
+
imitateTypingOnPaste: false,
|
|
240
|
+
imitateTypingOnPasteDelay: 100,
|
|
241
|
+
showHint: false,
|
|
242
|
+
hintText: 'Hint Text',
|
|
243
|
+
hintClassName: '',
|
|
244
|
+
isHintRight: true,
|
|
245
|
+
isHintLeft: false,
|
|
246
|
+
hintPosition: 'right'
|
|
247
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.selectElementContents = exports.copyToClipboard = exports.resetSelectionText = exports.getSelectionText = void 0;
|
|
7
|
+
|
|
8
|
+
var getSelectionText = function getSelectionText() {
|
|
9
|
+
var text = "";
|
|
10
|
+
|
|
11
|
+
if (window.getSelection) {
|
|
12
|
+
text = window.getSelection().toString();
|
|
13
|
+
} else if (document.selection && document.selection.type != "Control") {
|
|
14
|
+
text = document.selection.createRange().text;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return text.replace(/\n/g, '');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.getSelectionText = getSelectionText;
|
|
21
|
+
|
|
22
|
+
var resetSelectionText = function resetSelectionText() {
|
|
23
|
+
if (window.getSelection) {
|
|
24
|
+
window.getSelection().removeAllRanges();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.resetSelectionText = resetSelectionText;
|
|
29
|
+
|
|
30
|
+
var copyToClipboard = function copyToClipboard(str) {
|
|
31
|
+
if (navigator && navigator.clipboard && navigator.clipboard.writeText) return navigator.clipboard.writeText(str);
|
|
32
|
+
return Promise.reject('The Clipboard API is not available.');
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.copyToClipboard = copyToClipboard;
|
|
36
|
+
|
|
37
|
+
var selectElementContents = function selectElementContents(el) {
|
|
38
|
+
var range = document.createRange();
|
|
39
|
+
range.selectNodeContents(el);
|
|
40
|
+
var sel = window.getSelection();
|
|
41
|
+
sel.removeAllRanges();
|
|
42
|
+
sel.addRange(range);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.selectElementContents = selectElementContents;
|
|
@@ -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
|
};
|