intelicoreact 0.0.8 → 0.0.9
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/Dropdown/Dropdown.js +43 -19
- package/dist/Atomic/FormElements/Dropdown/Dropdown.scss +6 -0
- package/dist/Atomic/FormElements/Dropdown/Dropdown.stories.js +34 -7
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +20 -0
- package/dist/Atomic/FormElements/Dropdown/components/Loader.scss +57 -0
- package/dist/Atomic/FormElements/Input/Input.js +42 -18
- package/dist/Atomic/FormElements/Input/Input.stories.js +4 -0
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +33 -31
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +29 -19
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +8 -2
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.scss +2 -4
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +2 -0
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +35 -20
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +8 -2
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +1 -1
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +125 -87
- package/dist/Atomic/FormElements/NumericInput/NumericInput.stories.js +6 -10
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +3 -1
- 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 -3
- package/src/Atomic/FormElements/Dropdown/Dropdown.js +66 -35
- package/src/Atomic/FormElements/Dropdown/Dropdown.scss +6 -0
- package/src/Atomic/FormElements/Dropdown/Dropdown.stories.js +22 -8
- package/src/Atomic/FormElements/Dropdown/components/DropdownLoader.js +16 -0
- package/src/Atomic/FormElements/Dropdown/components/Loader.scss +57 -0
- package/src/Atomic/FormElements/Input/Input.js +56 -39
- package/src/Atomic/FormElements/Input/Input.stories.js +4 -0
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +18 -17
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +17 -14
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.js +5 -0
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.scss +2 -4
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +2 -0
- package/src/Atomic/FormElements/InputDateRange/components/Datepicker.js +41 -20
- package/src/Atomic/FormElements/InputDateRange/components/OpenedPart.js +5 -1
- package/src/Atomic/FormElements/InputDateRange/dependencies.js +1 -1
- package/src/Atomic/FormElements/NumericInput/NumericInput.js +107 -64
- package/src/Atomic/FormElements/NumericInput/NumericInput.stories.js +6 -22
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.js +1 -1
- 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
|
@@ -41,7 +41,9 @@ const Datepicker = props => {
|
|
|
41
41
|
limitRange,
|
|
42
42
|
handleItemClick,
|
|
43
43
|
setActiveInterval,
|
|
44
|
-
isShortWeekNames
|
|
44
|
+
isShortWeekNames,
|
|
45
|
+
minDate = null,
|
|
46
|
+
maxDate = null
|
|
45
47
|
} = props;
|
|
46
48
|
const { start = null, end = null, compare = false } = values;
|
|
47
49
|
const startDateInputRef = useRef(null);
|
|
@@ -191,7 +193,7 @@ const Datepicker = props => {
|
|
|
191
193
|
const handleChangeStartHour = val => {
|
|
192
194
|
setStartHour(+val);
|
|
193
195
|
setStartDate(
|
|
194
|
-
moment(startDate)
|
|
196
|
+
moment(startDate || moment())
|
|
195
197
|
.set('hour', +val)
|
|
196
198
|
.toDate(),
|
|
197
199
|
);
|
|
@@ -200,14 +202,16 @@ const Datepicker = props => {
|
|
|
200
202
|
const handleChangeEndHour = val => {
|
|
201
203
|
const newHour = +val;
|
|
202
204
|
setEndHour(newHour);
|
|
203
|
-
let newEndDate;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
let newEndDate = moment();
|
|
206
|
+
|
|
207
|
+
if(endDate){
|
|
208
|
+
if (prevEndHour.current === 0 && newHour !== 0) {
|
|
209
|
+
newEndDate = moment(endDate).subtract(1, 'days');
|
|
210
|
+
} else if (prevEndHour.current !== 0 && newHour === 0) {
|
|
211
|
+
newEndDate = moment(endDate).add(1, 'days');
|
|
212
|
+
}
|
|
210
213
|
}
|
|
214
|
+
|
|
211
215
|
prevEndHour.current = newHour;
|
|
212
216
|
setEndDate(moment(newEndDate).set('hour', newHour).toDate());
|
|
213
217
|
};
|
|
@@ -256,13 +260,22 @@ const Datepicker = props => {
|
|
|
256
260
|
|
|
257
261
|
const handleStartDateBlur = e => {
|
|
258
262
|
let newDate;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
|
|
264
|
+
if(!moment(startDateInput).isValid()){
|
|
265
|
+
newDate = startDate;
|
|
262
266
|
} else {
|
|
263
|
-
|
|
264
|
-
|
|
267
|
+
if(minDate && !moment(startDateInput).isSameOrAfter(minDate)){
|
|
268
|
+
newDate = minDate;
|
|
269
|
+
} else if(maxDate && !moment(startDateInput).isSameOrBefore(maxDate)){
|
|
270
|
+
newDate = maxDate;
|
|
271
|
+
} else {
|
|
272
|
+
newDate = moment(startDateInput);
|
|
273
|
+
}
|
|
265
274
|
}
|
|
275
|
+
|
|
276
|
+
setStartDateInput(newDate);
|
|
277
|
+
setStartDate(newDate.set('hour', parseInt(startHour, 10)).toDate());
|
|
278
|
+
|
|
266
279
|
doBlur('start', e);
|
|
267
280
|
setDate1(
|
|
268
281
|
moment(newDate).isSameOrAfter(moment(date2), 'month') ? moment(date2).subtract(1, 'month') : moment(newDate),
|
|
@@ -277,16 +290,24 @@ const Datepicker = props => {
|
|
|
277
290
|
|
|
278
291
|
const handleEndDateBlur = e => {
|
|
279
292
|
let newDate;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
293
|
+
|
|
294
|
+
if(!moment(endDateInput).isValid()){
|
|
295
|
+
newDate = endDate;
|
|
283
296
|
} else {
|
|
284
|
-
|
|
285
|
-
|
|
297
|
+
if(minDate && !moment(endDateInput).isSameOrAfter(minDate)){
|
|
298
|
+
newDate = minDate;
|
|
299
|
+
} else if(maxDate && !moment(endDateInput).isSameOrBefore(maxDate)){
|
|
300
|
+
newDate = maxDate;
|
|
301
|
+
} else {
|
|
302
|
+
newDate = moment(endDateInput);
|
|
303
|
+
}
|
|
286
304
|
}
|
|
305
|
+
|
|
306
|
+
setEndDate(addDay(newDate.set('hour', parseInt(endHour, 10)).toDate()));
|
|
307
|
+
setEndDateInput(newDate);
|
|
308
|
+
|
|
287
309
|
doBlur('end', e);
|
|
288
310
|
setDate2(newDate);
|
|
289
|
-
setEndDateInput();
|
|
290
311
|
};
|
|
291
312
|
|
|
292
313
|
const handleKeyPressed = (code, e, type) => {
|
|
@@ -25,7 +25,9 @@ const OpenedPart = React.forwardRef((props, ref) => {
|
|
|
25
25
|
isCompare,
|
|
26
26
|
setIsCompare,
|
|
27
27
|
toggleOff,
|
|
28
|
-
isShortWeekNames
|
|
28
|
+
isShortWeekNames,
|
|
29
|
+
minDate = null,
|
|
30
|
+
maxDate = null
|
|
29
31
|
} = props;
|
|
30
32
|
|
|
31
33
|
const items = isCompact ? [...Object.keys(intervals)] : [...Object.keys(intervals), customKey];
|
|
@@ -105,6 +107,8 @@ const OpenedPart = React.forwardRef((props, ref) => {
|
|
|
105
107
|
limitRange={limitRange}
|
|
106
108
|
setActiveInterval={setActiveInterval}
|
|
107
109
|
isShortWeekNames={isShortWeekNames}
|
|
110
|
+
minDate={minDate}
|
|
111
|
+
maxDate={maxDate}
|
|
108
112
|
/>
|
|
109
113
|
)}
|
|
110
114
|
</div>
|
|
@@ -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,86 @@ 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
|
+
setEditing(isFocusDefault)
|
|
196
|
+
}, [inputRef, isFocusDefault]);
|
|
173
197
|
|
|
174
198
|
function renderInput() {
|
|
199
|
+
const uniProps = {
|
|
200
|
+
className: `input ${className || ''}`,
|
|
201
|
+
placeholder,
|
|
202
|
+
value: inputValueFormated,
|
|
203
|
+
disabled,
|
|
204
|
+
onChange: handle.change,
|
|
205
|
+
onFocus: () => {
|
|
206
|
+
setIsFocused(true);
|
|
207
|
+
setEditing(true);
|
|
208
|
+
},
|
|
209
|
+
onBlur: () => setEditing(false),
|
|
210
|
+
onKeyUp: handle.keyUp,
|
|
211
|
+
min,
|
|
212
|
+
max,
|
|
213
|
+
...(maskChar ? { maskChar } : {}),
|
|
214
|
+
...(formatChars ? { formatChars } : {})
|
|
215
|
+
};
|
|
216
|
+
|
|
175
217
|
return (
|
|
176
218
|
<>
|
|
177
|
-
<input {...uniProps} ref={inputRef} type=
|
|
219
|
+
<input {...uniProps} ref={inputRef} type='text' />
|
|
178
220
|
|
|
179
221
|
<div className='input__nums'>
|
|
180
222
|
<button
|
|
181
223
|
ref={decRef}
|
|
182
|
-
|
|
224
|
+
onMouseDown={(e) => handle.decrement(e)}
|
|
183
225
|
className={cn(`input__num-btn`, { disabled: +value <= min })}
|
|
184
226
|
>
|
|
185
227
|
<Minus />
|
|
186
228
|
</button>
|
|
187
229
|
<button
|
|
188
230
|
ref={incRef}
|
|
189
|
-
|
|
231
|
+
onMouseDown={(e) => handle.increment(e)}
|
|
190
232
|
className={cn(`input__num-btn`, { disabled: +value >= max })}
|
|
191
233
|
>
|
|
192
234
|
<Plus />
|
|
@@ -198,6 +240,7 @@ const NumericInput = ({
|
|
|
198
240
|
|
|
199
241
|
return (
|
|
200
242
|
<div
|
|
243
|
+
ref={wrapRef}
|
|
201
244
|
className={cn(
|
|
202
245
|
`input__wrap`,
|
|
203
246
|
{ [`input__wrap_focus`]: isFocused },
|
|
@@ -209,8 +252,8 @@ const NumericInput = ({
|
|
|
209
252
|
{icon}
|
|
210
253
|
{withDelete && (
|
|
211
254
|
<span
|
|
212
|
-
className={cn(`input__close`, { hidden: !
|
|
213
|
-
onClick={handle.
|
|
255
|
+
className={cn(`input__close`, { hidden: !inputValue })}
|
|
256
|
+
onClick={() => handle.clear()}
|
|
214
257
|
/>
|
|
215
258
|
)}
|
|
216
259
|
</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
|
};
|
|
@@ -88,7 +88,7 @@ const RangeCalendar = props => {
|
|
|
88
88
|
onMouseOver={day && !isFutureDay ? () => onHover(day.date) : null}
|
|
89
89
|
onMouseLeave={() => onHover(null)}
|
|
90
90
|
>
|
|
91
|
-
|
|
91
|
+
<span className="calendar__day-num">{day && day.date.getDate()}</span>
|
|
92
92
|
</div>
|
|
93
93
|
);
|
|
94
94
|
};
|
|
@@ -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
|
|
|
@@ -4,38 +4,29 @@ export const formatInput = {
|
|
|
4
4
|
value = value.toString();
|
|
5
5
|
const isFraction = value.includes('.');
|
|
6
6
|
|
|
7
|
-
const valueBeforeDot = isFraction
|
|
8
|
-
? value.slice(0, value.indexOf('.'))
|
|
9
|
-
: value;
|
|
7
|
+
const valueBeforeDot = isFraction ? value.slice(0, value.indexOf('.')) : value;
|
|
10
8
|
|
|
11
9
|
const intPart = valueBeforeDot
|
|
12
10
|
.split('')
|
|
13
11
|
.reverse()
|
|
14
|
-
.reduce(
|
|
15
|
-
(acc, item, idx) =>
|
|
16
|
-
idx % 3 === 0 && idx !== 0 ? [...acc, ',', item] : [...acc, item],
|
|
17
|
-
[]
|
|
18
|
-
)
|
|
12
|
+
.reduce((acc, item, idx) => (idx % 3 === 0 && idx !== 0 ? [...acc, ',', item] : [...acc, item]), [])
|
|
19
13
|
.reverse()
|
|
20
14
|
.join('');
|
|
21
15
|
|
|
22
16
|
return isFraction ? intPart + value.slice(value.indexOf('.')) : intPart;
|
|
23
17
|
},
|
|
24
18
|
removeComma: (value) => {
|
|
25
|
-
return
|
|
26
|
-
}
|
|
19
|
+
return parseInt(value.toString().replace(/\,/g, ''));
|
|
20
|
+
},
|
|
27
21
|
},
|
|
28
22
|
onlyNumbers: (value, isDot = false) => {
|
|
29
|
-
const val =
|
|
30
|
-
value.slice(0, 1) !== '0' && value.slice(0, 1) !== '.'
|
|
31
|
-
? value
|
|
32
|
-
: value.slice(1);
|
|
23
|
+
const val = value.slice(0, 1) !== '0' && value.slice(0, 1) !== '.' ? value : value.slice(1);
|
|
33
24
|
if (isDot) return twoDigitAfterDot(val.replace(/[^0-9.]/g, ''));
|
|
34
25
|
else return +val.toString().replace(/\D/g, '');
|
|
35
26
|
},
|
|
36
27
|
onlyString: (value) => {
|
|
37
28
|
return value.toString().replace(/[^a-z]/gi, '');
|
|
38
|
-
}
|
|
29
|
+
},
|
|
39
30
|
};
|
|
40
31
|
|
|
41
32
|
//обрезает числа после точки до 2х
|