intelicoreact 0.0.82 → 0.0.86
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/Input/Input.js +12 -8
- package/dist/Atomic/FormElements/Input/Input.stories.js +4 -0
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +34 -32
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +29 -19
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +124 -87
- package/dist/Atomic/FormElements/NumericInput/NumericInput.stories.js +6 -10
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +4 -4
- package/dist/Atomic/UI/Calendar/Calendar.js +6 -4
- package/dist/Atomic/UI/Calendar/Calendar.scss +19 -3
- package/dist/Functions/inputExecutor.js +1 -1
- package/package.json +2 -2
- package/src/Atomic/FormElements/Input/Input.js +13 -9
- package/src/Atomic/FormElements/Input/Input.stories.js +4 -0
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +19 -17
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +17 -14
- package/src/Atomic/FormElements/NumericInput/NumericInput.js +106 -64
- package/src/Atomic/FormElements/NumericInput/NumericInput.stories.js +6 -22
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +4 -4
- package/src/Atomic/UI/Calendar/Calendar.js +3 -3
- package/src/Atomic/UI/Calendar/Calendar.scss +19 -3
- package/src/Functions/inputExecutor.js +6 -15
|
@@ -425,7 +425,17 @@
|
|
|
425
425
|
// box-shadow: 0 0 3px 0 rgb(0 123 255 / 50%);
|
|
426
426
|
// }
|
|
427
427
|
// }
|
|
428
|
+
.calendar-header {
|
|
429
|
+
display: flex;
|
|
430
|
+
justify-content: center;
|
|
431
|
+
align-items: center;
|
|
428
432
|
|
|
433
|
+
&__prev,
|
|
434
|
+
&__next{
|
|
435
|
+
display: flex;
|
|
436
|
+
height: auto;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
429
439
|
.calendar {
|
|
430
440
|
background: #ffffff;
|
|
431
441
|
border: 1px solid #e2e5ec;
|
|
@@ -507,15 +517,21 @@
|
|
|
507
517
|
}
|
|
508
518
|
|
|
509
519
|
&-container {
|
|
510
|
-
width: 200px;
|
|
520
|
+
min-width: 200px;
|
|
521
|
+
position: relative;
|
|
522
|
+
.calendar {
|
|
523
|
+
position: absolute;
|
|
524
|
+
z-index: 9;
|
|
525
|
+
top: 100%;
|
|
526
|
+
padding: 10px 16px;
|
|
527
|
+
border: 1px solid var(--border-color);
|
|
528
|
+
}
|
|
511
529
|
}
|
|
512
530
|
|
|
513
531
|
&-dropdown {
|
|
514
532
|
appearance: none;
|
|
515
533
|
background-color: white;
|
|
516
534
|
cursor: pointer;
|
|
517
|
-
color: gray;
|
|
518
|
-
|
|
519
535
|
width: 100%;
|
|
520
536
|
height: 28px;
|
|
521
537
|
|
|
@@ -21,7 +21,7 @@ var formatInput = {
|
|
|
21
21
|
return isFraction ? intPart + value.slice(value.indexOf('.')) : intPart;
|
|
22
22
|
},
|
|
23
23
|
removeComma: function removeComma(value) {
|
|
24
|
-
return
|
|
24
|
+
return parseInt(value.toString().replace(/\,/g, ''));
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
onlyNumbers: function onlyNumbers(value) {
|
package/package.json
CHANGED
|
@@ -28,7 +28,8 @@ const Input = ({
|
|
|
28
28
|
error,
|
|
29
29
|
icon,
|
|
30
30
|
symbolsLimit,
|
|
31
|
-
blinkTime
|
|
31
|
+
blinkTime,
|
|
32
|
+
isFocusDefault = false
|
|
32
33
|
}) => {
|
|
33
34
|
const DEFAULT_BLINK_TIME = 100;
|
|
34
35
|
// STATES
|
|
@@ -62,20 +63,19 @@ const Input = ({
|
|
|
62
63
|
},
|
|
63
64
|
focus: (e) => {
|
|
64
65
|
setIsFocused(true);
|
|
65
|
-
if (isPriceInput && isOnlyNumber
|
|
66
|
-
onChange(removeComma(value));
|
|
66
|
+
if (isPriceInput && isOnlyNumber) onChange(removeComma(value));
|
|
67
67
|
|
|
68
68
|
if (onFocus) onFocus(e);
|
|
69
69
|
},
|
|
70
70
|
blur: (e) => {
|
|
71
71
|
setIsFocused(false);
|
|
72
72
|
setEditing(false);
|
|
73
|
-
if (
|
|
74
|
-
onChange(addCommas(value));
|
|
75
|
-
}
|
|
76
|
-
if (isTwoDigitAfterDot && !isPriceInput) {
|
|
73
|
+
if (isTwoDigitAfterDot) {
|
|
77
74
|
onChange(cutOffsingleDot(value));
|
|
78
75
|
}
|
|
76
|
+
if (isPriceInput && isOnlyNumber) {
|
|
77
|
+
onChange(addCommas(value));
|
|
78
|
+
}
|
|
79
79
|
if (onBlur) onBlur(e);
|
|
80
80
|
},
|
|
81
81
|
keyUp: (e) => {
|
|
@@ -94,7 +94,6 @@ const Input = ({
|
|
|
94
94
|
)
|
|
95
95
|
setIsAttemptToChange(true);
|
|
96
96
|
|
|
97
|
-
console.log(changedValue, previousValue);
|
|
98
97
|
if (KEYBOARD_SERVICE_KEYS.includes(e.key) || !currentSet)
|
|
99
98
|
previousValueRef.current = value;
|
|
100
99
|
else previousValueRef.current = previousValue + currentSet[0];
|
|
@@ -105,7 +104,7 @@ const Input = ({
|
|
|
105
104
|
};
|
|
106
105
|
|
|
107
106
|
function cutOffsingleDot(value) {
|
|
108
|
-
return value.slice(-1) === '.' ? value.slice(0, -1) : value;
|
|
107
|
+
return value.toString().slice(-1) === '.' ? value.slice(0, -1) : value;
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
useEffect(() => {
|
|
@@ -145,6 +144,11 @@ const Input = ({
|
|
|
145
144
|
}
|
|
146
145
|
}, [isAttemptToChange]);
|
|
147
146
|
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (inputRef?.current && typeof isFocusDefault === 'boolean')
|
|
149
|
+
setIsFocused(isFocusDefault);
|
|
150
|
+
}, [inputRef, isFocusDefault]);
|
|
151
|
+
|
|
148
152
|
return (
|
|
149
153
|
<div
|
|
150
154
|
className={cn(
|
|
@@ -29,6 +29,9 @@ export default {
|
|
|
29
29
|
isTwoDigitAfterDot: {
|
|
30
30
|
description: 'boolean - only two digits after dot'
|
|
31
31
|
},
|
|
32
|
+
isFocusDefault: {
|
|
33
|
+
description: 'boolean - if true, input will be focused on mount'
|
|
34
|
+
},
|
|
32
35
|
placeholder: {
|
|
33
36
|
description: 'text'
|
|
34
37
|
},
|
|
@@ -76,6 +79,7 @@ export const InputTemplate = Template.bind({});
|
|
|
76
79
|
|
|
77
80
|
InputTemplate.args = {
|
|
78
81
|
type: 'text',
|
|
82
|
+
isFocusDefault: false,
|
|
79
83
|
isOnlyNumber: false,
|
|
80
84
|
isOnlyString: false,
|
|
81
85
|
isPriceInput: false,
|
|
@@ -4,38 +4,40 @@ import InputMask from 'react-input-mask';
|
|
|
4
4
|
import Calendar from '../../UI/Calendar/Calendar';
|
|
5
5
|
import { useClickOutside } from '../../../Functions/useClickOutside';
|
|
6
6
|
|
|
7
|
-
const InputCalendar = ({
|
|
8
|
-
const [date, setDate] = useState(data);
|
|
9
|
-
const [inputValue, setInputValue] = useState(date);
|
|
7
|
+
const InputCalendar = ({ value, minDate, maxDate, onChange, className = '', placeholder = 'mm/dd/yyyy', mask = '99/99/9999' }) => {
|
|
10
8
|
const [isOpened, setIsOpened] = useState(false);
|
|
11
9
|
const calendarRef = useRef(null);
|
|
12
10
|
|
|
13
11
|
useClickOutside(calendarRef, () => setIsOpened(false));
|
|
14
12
|
|
|
15
|
-
const changeInputValue =
|
|
16
|
-
if (
|
|
17
|
-
setDate(moment(value).format('L'));
|
|
18
|
-
setInputValue(moment(value).format('L'));
|
|
19
|
-
} else {
|
|
20
|
-
setInputValue(value);
|
|
21
|
-
}
|
|
13
|
+
const changeInputValue = val => {
|
|
14
|
+
if (onChange) onChange(val);
|
|
22
15
|
};
|
|
23
16
|
|
|
24
|
-
const changeCalendarDay =
|
|
25
|
-
|
|
26
|
-
setInputValue(value);
|
|
17
|
+
const changeCalendarDay = val => {
|
|
18
|
+
if (onChange) onChange(val);
|
|
27
19
|
};
|
|
28
20
|
|
|
21
|
+
const getCalendarValue = (value) => {
|
|
22
|
+
const date = moment(value).format('L');
|
|
23
|
+
|
|
24
|
+
if(date !== "Invalid date") return date;
|
|
25
|
+
|
|
26
|
+
return moment(new Date()).format('L');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
29
|
return (
|
|
30
|
-
<div className=
|
|
30
|
+
<div className={`input__wrap calendar-container ${className}`} ref={calendarRef}>
|
|
31
31
|
<InputMask
|
|
32
|
-
mask=
|
|
33
|
-
|
|
32
|
+
mask={mask}
|
|
33
|
+
placeholder={placeholder}
|
|
34
|
+
value={value}
|
|
34
35
|
onChange={e => changeInputValue(e.target.value)}
|
|
35
36
|
className="calendar-dropdown"
|
|
36
37
|
onFocus={() => setIsOpened(!isOpened)}
|
|
37
38
|
/>
|
|
38
|
-
{
|
|
39
|
+
{console.log(value, getCalendarValue(value))}
|
|
40
|
+
{isOpened ? <Calendar date={getCalendarValue(value)} setDate={newDate => changeCalendarDay(newDate)} params={{ minDate, maxDate }} /> : null}
|
|
39
41
|
</div>
|
|
40
42
|
);
|
|
41
43
|
};
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { ref } from 'yup';
|
|
1
|
+
import React, { useState } from 'react';
|
|
3
2
|
import InputCalendar from './InputCalendar';
|
|
4
3
|
|
|
5
4
|
global.lng = 'en';
|
|
6
5
|
|
|
6
|
+
|
|
7
7
|
export default {
|
|
8
|
-
title: 'Form Elements/
|
|
8
|
+
title: 'Form Elements/Input Calendar',
|
|
9
9
|
component: InputCalendar,
|
|
10
|
+
argTypes: {
|
|
11
|
+
value: {
|
|
12
|
+
description: 'string (mm.dd.yyyy)'
|
|
13
|
+
},
|
|
14
|
+
}
|
|
10
15
|
};
|
|
11
16
|
|
|
12
|
-
const Template =
|
|
13
|
-
const
|
|
14
|
-
minDate: args?.minDate,
|
|
15
|
-
maxDate: args?.maxDate,
|
|
16
|
-
};
|
|
17
|
+
const Template = args => {
|
|
18
|
+
const [date, setDate] = useState('');
|
|
17
19
|
|
|
18
|
-
return <InputCalendar
|
|
20
|
+
return <InputCalendar {...args} value={date} onChange={val => setDate(val)} />;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
export const
|
|
23
|
+
export const CalendarTemplate = Template.bind({});
|
|
24
|
+
|
|
25
|
+
CalendarTemplate.args = {
|
|
26
|
+
value: '',
|
|
27
|
+
minDate: '10/14/2020',
|
|
28
|
+
maxDate: '10/14/2022',
|
|
22
29
|
|
|
23
|
-
Calendar.args = {
|
|
24
|
-
date: '10/14/2021',
|
|
25
|
-
minDate: '10/11/2021',
|
|
26
|
-
maxDate: '10/25/2021',
|
|
27
30
|
};
|
|
@@ -7,6 +7,9 @@ import { formatInput } from '../../../Functions/inputExecutor';
|
|
|
7
7
|
|
|
8
8
|
import './NumericInput.scss';
|
|
9
9
|
|
|
10
|
+
let timerOutside;
|
|
11
|
+
let timerFocus;
|
|
12
|
+
|
|
10
13
|
const NumericInput = ({
|
|
11
14
|
onChange,
|
|
12
15
|
disabled,
|
|
@@ -17,7 +20,6 @@ const NumericInput = ({
|
|
|
17
20
|
value,
|
|
18
21
|
placeholder,
|
|
19
22
|
className,
|
|
20
|
-
type = 'number',
|
|
21
23
|
onBlur,
|
|
22
24
|
onFocus,
|
|
23
25
|
onKeyUp,
|
|
@@ -29,21 +31,30 @@ const NumericInput = ({
|
|
|
29
31
|
symbolsLimit,
|
|
30
32
|
isNotBlinkErrors,
|
|
31
33
|
blinkTime,
|
|
32
|
-
isPriceInput
|
|
34
|
+
isPriceInput,
|
|
35
|
+
isFocusDefault = false
|
|
33
36
|
}) => {
|
|
34
37
|
const DEFAULT_BLINK_TIME = 200;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const [isEditing, setEditing] = useState(false);
|
|
38
|
+
|
|
39
|
+
//REFS
|
|
38
40
|
const inputRef = useRef(null);
|
|
39
41
|
const decRef = useRef(null);
|
|
40
42
|
const incRef = useRef(null);
|
|
43
|
+
const wrapRef = useRef(null);
|
|
44
|
+
|
|
41
45
|
const previousValueRef = useRef(value);
|
|
42
|
-
const [isAttemptToChange, setIsAttemptToChange] = useState(false);
|
|
43
|
-
const [isToHighlightError, setIsToHighlightError] = useState(false);
|
|
44
46
|
|
|
47
|
+
// STATES
|
|
48
|
+
const [inputValue, setInputValue] = useState(value || min || '');
|
|
49
|
+
const [inputValueFormated, setInputValueFormated] = useState(inputValue);
|
|
45
50
|
const [intMemoVal, setIntMemoVal] = useState(0);
|
|
46
51
|
|
|
52
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
53
|
+
const [isEditing, setEditing] = useState(false);
|
|
54
|
+
|
|
55
|
+
const [isAttemptToChange, setIsAttemptToChange] = useState(false);
|
|
56
|
+
const [isToHighlightError, setIsToHighlightError] = useState(false);
|
|
57
|
+
|
|
47
58
|
const { onlyNumbers } = formatInput;
|
|
48
59
|
const { addCommas, removeComma } = formatInput.priceInput;
|
|
49
60
|
|
|
@@ -51,8 +62,12 @@ const NumericInput = ({
|
|
|
51
62
|
const handle = {
|
|
52
63
|
change: (e) => {
|
|
53
64
|
let inputValue = e.target ? onlyNumbers(e.target.value) : e;
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
|
|
66
|
+
if (
|
|
67
|
+
inputValue &&
|
|
68
|
+
(decRef.current.contains(e.target) || incRef.current.contains(e.target))
|
|
69
|
+
) {
|
|
70
|
+
inputValue = parseFloat(inputValue);
|
|
56
71
|
if (min && +min > inputValue) {
|
|
57
72
|
inputValue = min;
|
|
58
73
|
} else if (max && +max < inputValue) inputValue = max;
|
|
@@ -60,28 +75,21 @@ const NumericInput = ({
|
|
|
60
75
|
if (symbolsLimit) {
|
|
61
76
|
inputValue = inputValue.toString().substring(0, +symbolsLimit);
|
|
62
77
|
}
|
|
63
|
-
|
|
64
|
-
setIntMemoVal(parseFloat(inputValue));
|
|
65
|
-
onChange(inputValue.toString());
|
|
78
|
+
setInputValue(inputValue.toString());
|
|
66
79
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
onChange('');
|
|
80
|
+
clear: () => {
|
|
81
|
+
handle.change(min || '');
|
|
70
82
|
},
|
|
71
83
|
focus: (e) => {
|
|
84
|
+
if (isFocused) return;
|
|
72
85
|
setIsFocused(true);
|
|
73
|
-
if (isPriceInput) onChange(removeComma(value));
|
|
74
86
|
if (onFocus) onFocus(e);
|
|
75
87
|
},
|
|
76
88
|
blur: (e) => {
|
|
89
|
+
if (!isFocused) return;
|
|
90
|
+
|
|
77
91
|
setIsFocused(false);
|
|
78
92
|
setEditing(false);
|
|
79
|
-
if (isPriceInput) {
|
|
80
|
-
if (!isFinite(value)) {
|
|
81
|
-
value = intMemoVal;
|
|
82
|
-
}
|
|
83
|
-
onChange(addCommas(value));
|
|
84
|
-
}
|
|
85
93
|
|
|
86
94
|
if (onBlur) onBlur(e);
|
|
87
95
|
},
|
|
@@ -110,27 +118,26 @@ const NumericInput = ({
|
|
|
110
118
|
|
|
111
119
|
if (onKeyUp) onKeyUp(e.keyCode, e.target.value);
|
|
112
120
|
},
|
|
113
|
-
decrement: () => {
|
|
121
|
+
decrement: (e) => {
|
|
114
122
|
handle.change(intMemoVal - +numStep);
|
|
115
123
|
},
|
|
116
|
-
increment: () => {
|
|
124
|
+
increment: (e) => {
|
|
117
125
|
handle.change(intMemoVal + +numStep);
|
|
118
126
|
}
|
|
119
127
|
};
|
|
120
128
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
!
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
};
|
|
129
|
+
//Check Outside Click
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
const handleClickOutside = (event) => {
|
|
132
|
+
if (!wrapRef.current.contains(event.target)) {
|
|
133
|
+
setIsFocused(false);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
document.addEventListener('mousedown', handleClickOutside, true);
|
|
138
|
+
return () =>
|
|
139
|
+
document.removeEventListener('mousedown', handleClickOutside, true);
|
|
140
|
+
}, []);
|
|
134
141
|
|
|
135
142
|
useEffect(() => {
|
|
136
143
|
if (!isNotBlinkErrors && isAttemptToChange) {
|
|
@@ -142,51 +149,85 @@ const NumericInput = ({
|
|
|
142
149
|
}
|
|
143
150
|
}, [isAttemptToChange]);
|
|
144
151
|
|
|
152
|
+
//On Input Value Change
|
|
145
153
|
useEffect(() => {
|
|
146
|
-
|
|
147
|
-
return () =>
|
|
148
|
-
document.removeEventListener('click', handleClickOutside, true);
|
|
149
|
-
}, []);
|
|
154
|
+
if (inputValue !== value) setIsFocused(true);
|
|
150
155
|
|
|
156
|
+
setInputValueFormated(
|
|
157
|
+
isPriceInput
|
|
158
|
+
? isFocused
|
|
159
|
+
? removeComma(inputValue)
|
|
160
|
+
: addCommas(inputValue)
|
|
161
|
+
: inputValue
|
|
162
|
+
);
|
|
163
|
+
setIntMemoVal(parseInt(inputValue));
|
|
164
|
+
|
|
165
|
+
if (typeof onChange === 'function') onChange(inputValue?.toString());
|
|
166
|
+
}, [inputValue]);
|
|
167
|
+
|
|
168
|
+
//On Integer Value Change
|
|
151
169
|
useEffect(() => {
|
|
152
|
-
if (isNaN(intMemoVal)) setIntMemoVal(min ||
|
|
170
|
+
if (isNaN(intMemoVal)) setIntMemoVal(min || 0);
|
|
153
171
|
}, [intMemoVal]);
|
|
154
172
|
|
|
173
|
+
//On Focuse Change
|
|
155
174
|
useEffect(() => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
setInputValueFormated(
|
|
176
|
+
isPriceInput
|
|
177
|
+
? isFocused
|
|
178
|
+
? removeComma(inputValue)
|
|
179
|
+
: addCommas(inputValue)
|
|
180
|
+
: inputValue
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
if (isFocused) {
|
|
184
|
+
if (typeof onFocus === 'function') onFocus({ target: inputRef?.current });
|
|
185
|
+
inputRef?.current?.focus();
|
|
186
|
+
} else {
|
|
187
|
+
if (typeof onBlur === 'function') onBlur({ target: inputRef?.current });
|
|
188
|
+
inputRef?.current?.blur();
|
|
189
|
+
}
|
|
190
|
+
}, [isFocused]);
|
|
191
|
+
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (inputRef?.current && typeof isFocusDefault === 'boolean')
|
|
194
|
+
setIsFocused(isFocusDefault);
|
|
195
|
+
}, [inputRef, isFocusDefault]);
|
|
173
196
|
|
|
174
197
|
function renderInput() {
|
|
198
|
+
const uniProps = {
|
|
199
|
+
className: `input ${className || ''}`,
|
|
200
|
+
placeholder,
|
|
201
|
+
value: inputValueFormated,
|
|
202
|
+
disabled,
|
|
203
|
+
onChange: handle.change,
|
|
204
|
+
onFocus: () => {
|
|
205
|
+
setIsFocused(true);
|
|
206
|
+
setEditing(true);
|
|
207
|
+
},
|
|
208
|
+
onBlur: () => setEditing(false),
|
|
209
|
+
onKeyUp: handle.keyUp,
|
|
210
|
+
min,
|
|
211
|
+
max,
|
|
212
|
+
...(maskChar ? { maskChar } : {}),
|
|
213
|
+
...(formatChars ? { formatChars } : {})
|
|
214
|
+
};
|
|
215
|
+
|
|
175
216
|
return (
|
|
176
217
|
<>
|
|
177
|
-
<input {...uniProps} ref={inputRef} type=
|
|
218
|
+
<input {...uniProps} ref={inputRef} type='text' />
|
|
178
219
|
|
|
179
220
|
<div className='input__nums'>
|
|
180
221
|
<button
|
|
181
222
|
ref={decRef}
|
|
182
|
-
|
|
223
|
+
onMouseDown={(e) => handle.decrement(e)}
|
|
183
224
|
className={cn(`input__num-btn`, { disabled: +value <= min })}
|
|
184
225
|
>
|
|
185
226
|
<Minus />
|
|
186
227
|
</button>
|
|
187
228
|
<button
|
|
188
229
|
ref={incRef}
|
|
189
|
-
|
|
230
|
+
onMouseDown={(e) => handle.increment(e)}
|
|
190
231
|
className={cn(`input__num-btn`, { disabled: +value >= max })}
|
|
191
232
|
>
|
|
192
233
|
<Plus />
|
|
@@ -198,6 +239,7 @@ const NumericInput = ({
|
|
|
198
239
|
|
|
199
240
|
return (
|
|
200
241
|
<div
|
|
242
|
+
ref={wrapRef}
|
|
201
243
|
className={cn(
|
|
202
244
|
`input__wrap`,
|
|
203
245
|
{ [`input__wrap_focus`]: isFocused },
|
|
@@ -209,8 +251,8 @@ const NumericInput = ({
|
|
|
209
251
|
{icon}
|
|
210
252
|
{withDelete && (
|
|
211
253
|
<span
|
|
212
|
-
className={cn(`input__close`, { hidden: !
|
|
213
|
-
onClick={handle.
|
|
254
|
+
className={cn(`input__close`, { hidden: !inputValue })}
|
|
255
|
+
onClick={() => handle.clear()}
|
|
214
256
|
/>
|
|
215
257
|
)}
|
|
216
258
|
</div>
|
|
@@ -11,6 +11,9 @@ export default {
|
|
|
11
11
|
disabled: {
|
|
12
12
|
description: 'boolean'
|
|
13
13
|
},
|
|
14
|
+
isFocusDefault: {
|
|
15
|
+
description: 'boolean - if true, input will be focused on mount'
|
|
16
|
+
},
|
|
14
17
|
isInitialFocus: {
|
|
15
18
|
description: 'boolean - if true, the input will be focused on mount'
|
|
16
19
|
},
|
|
@@ -35,25 +38,6 @@ export default {
|
|
|
35
38
|
placeholder: {
|
|
36
39
|
description: 'text'
|
|
37
40
|
},
|
|
38
|
-
type: {
|
|
39
|
-
description:
|
|
40
|
-
"'text', 'number', 'password', 'color', 'date', 'datetime-local', 'month', 'time', 'email', 'range'",
|
|
41
|
-
control: {
|
|
42
|
-
type: 'select',
|
|
43
|
-
options: [
|
|
44
|
-
'text',
|
|
45
|
-
'number',
|
|
46
|
-
'password',
|
|
47
|
-
'color',
|
|
48
|
-
'date',
|
|
49
|
-
'datetime-local',
|
|
50
|
-
'month',
|
|
51
|
-
'time',
|
|
52
|
-
'email',
|
|
53
|
-
'range'
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
41
|
icon: { description: 'JSX' },
|
|
58
42
|
value: { description: '(* - required prop)' },
|
|
59
43
|
className: { description: 'string' },
|
|
@@ -71,15 +55,15 @@ export default {
|
|
|
71
55
|
};
|
|
72
56
|
|
|
73
57
|
const Template = (args) => {
|
|
74
|
-
const [value, setValue] = useState('');
|
|
58
|
+
const [value, setValue] = useState('15000');
|
|
75
59
|
return <NumericInput {...args} value={value} onChange={setValue} />;
|
|
76
60
|
};
|
|
77
61
|
|
|
78
62
|
export const NumericInputTemplate = Template.bind({});
|
|
79
63
|
|
|
80
64
|
NumericInputTemplate.args = {
|
|
81
|
-
type: 'text',
|
|
82
65
|
disabled: false,
|
|
66
|
+
isFocusDefault: false,
|
|
83
67
|
error: '',
|
|
84
68
|
isPriceInput: false,
|
|
85
69
|
mask: '',
|
|
@@ -88,7 +72,7 @@ NumericInputTemplate.args = {
|
|
|
88
72
|
numStep: 100,
|
|
89
73
|
min: '0',
|
|
90
74
|
max: '15000',
|
|
91
|
-
symbolsLimit:
|
|
75
|
+
symbolsLimit: 5,
|
|
92
76
|
placeholder: 'Placeholder',
|
|
93
77
|
icon: <User />
|
|
94
78
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.range-calendar {
|
|
1
|
+
.range-calendar, .calendar {
|
|
2
2
|
width: 195px;
|
|
3
3
|
min-height: 195px;
|
|
4
4
|
display: flex;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
display: flex;
|
|
13
13
|
justify-content: space-between;
|
|
14
14
|
align-items: center;
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
&__title {
|
|
17
17
|
line-height: 20px;
|
|
18
18
|
font-weight: 500;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
&__next, &__prev {
|
|
28
28
|
width: 16px;
|
|
29
29
|
height: 16px;
|
|
30
|
-
background-color: #E2E6F8;
|
|
30
|
+
//background-color: #E2E6F8;
|
|
31
31
|
border-radius: 5px;
|
|
32
32
|
color: #171D33;
|
|
33
33
|
}
|
|
@@ -98,4 +98,4 @@
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
}
|
|
101
|
+
}
|
|
@@ -6,7 +6,7 @@ import './Calendar.scss';
|
|
|
6
6
|
|
|
7
7
|
export default function (props) {
|
|
8
8
|
const { date, setDate, allowPrev = true, allowNext = true, params, className } = props;
|
|
9
|
-
const { minDate, maxDate } = params;
|
|
9
|
+
const { minDate = '01/01/1900', maxDate = moment().format('MM/DD/YYYY') } = params;
|
|
10
10
|
const [days, setDays] = useState({});
|
|
11
11
|
const [showDate, setShowDate] = useState(date);
|
|
12
12
|
|
|
@@ -70,7 +70,7 @@ export default function (props) {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
return (
|
|
73
|
-
<div className={`calendar ${className}`}>
|
|
73
|
+
<div className={`calendar ${className ? className : ""}`}>
|
|
74
74
|
<div className="calendar-header">
|
|
75
75
|
<div className="calendar-header__prev">
|
|
76
76
|
{allowPrev && (
|
|
@@ -92,7 +92,7 @@ export default function (props) {
|
|
|
92
92
|
{[...Array(7).keys()].map((dayOfWeek) => {
|
|
93
93
|
return (
|
|
94
94
|
<div key={`day-of-week_${dayOfWeek}`} className="calendar__day calendar__day--title">
|
|
95
|
-
{moment().weekday(dayOfWeek).format('dd')
|
|
95
|
+
{moment().weekday(dayOfWeek).format('dd')}
|
|
96
96
|
</div>
|
|
97
97
|
);
|
|
98
98
|
})}
|
|
@@ -425,7 +425,17 @@
|
|
|
425
425
|
// box-shadow: 0 0 3px 0 rgb(0 123 255 / 50%);
|
|
426
426
|
// }
|
|
427
427
|
// }
|
|
428
|
+
.calendar-header {
|
|
429
|
+
display: flex;
|
|
430
|
+
justify-content: center;
|
|
431
|
+
align-items: center;
|
|
428
432
|
|
|
433
|
+
&__prev,
|
|
434
|
+
&__next{
|
|
435
|
+
display: flex;
|
|
436
|
+
height: auto;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
429
439
|
.calendar {
|
|
430
440
|
background: #ffffff;
|
|
431
441
|
border: 1px solid #e2e5ec;
|
|
@@ -507,15 +517,21 @@
|
|
|
507
517
|
}
|
|
508
518
|
|
|
509
519
|
&-container {
|
|
510
|
-
width: 200px;
|
|
520
|
+
min-width: 200px;
|
|
521
|
+
position: relative;
|
|
522
|
+
.calendar {
|
|
523
|
+
position: absolute;
|
|
524
|
+
z-index: 9;
|
|
525
|
+
top: 100%;
|
|
526
|
+
padding: 10px 16px;
|
|
527
|
+
border: 1px solid var(--border-color);
|
|
528
|
+
}
|
|
511
529
|
}
|
|
512
530
|
|
|
513
531
|
&-dropdown {
|
|
514
532
|
appearance: none;
|
|
515
533
|
background-color: white;
|
|
516
534
|
cursor: pointer;
|
|
517
|
-
color: gray;
|
|
518
|
-
|
|
519
535
|
width: 100%;
|
|
520
536
|
height: 28px;
|
|
521
537
|
|