intelicoreact 0.0.63 → 0.0.71
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/CheckboxInput/CheckboxInput.js +6 -2
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.scss +91 -60
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.stories.js +2 -1
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +48 -17
- package/dist/Atomic/FormElements/Dropdown/Dropdown.scss +21 -3
- package/dist/Atomic/FormElements/Dropdown/Dropdown.stories.js +22 -6
- package/dist/Atomic/FormElements/Input/Input.js +15 -4
- package/dist/Atomic/FormElements/Input/Input.stories.js +7 -1
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +33 -50
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.scss +98 -73
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +6 -2
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +10 -7
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +5 -3
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +3 -3
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +15 -7
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +7 -2
- package/dist/Atomic/FormElements/Table/Table.scss +1 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.scss +1 -1
- package/dist/Atomic/MainMenu/MainMenu.scss +2 -2
- package/dist/Atomic/UI/Accordion/Accordion.scss +2 -2
- package/dist/Atomic/UI/Arrow/Arrow.js +7 -8
- package/dist/Atomic/UI/Calendar/Calendar.js +3 -2
- package/dist/Atomic/UI/Calendar/Calendar.stories.js +3 -2
- package/dist/Atomic/UI/Status/Status.scss +1 -1
- package/dist/Molecular/Datepicker/Datepicker.js +451 -0
- package/dist/Molecular/Datepicker/Datepicker.scss +8 -0
- package/dist/Molecular/Datepicker/Datepicker.stories.js +44 -0
- package/dist/Molecular/Datepicker/components/Calendar.js +156 -0
- package/dist/scss/_vars.scss +3 -1
- package/dist/scss/main.scss +1 -1
- package/package.json +6 -4
- package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.js +12 -2
- package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.scss +91 -60
- package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.stories.js +4 -3
- package/src/Atomic/FormElements/Dropdown/Dropdown.js +53 -19
- package/src/Atomic/FormElements/Dropdown/Dropdown.scss +21 -3
- package/src/Atomic/FormElements/Dropdown/Dropdown.stories.js +28 -15
- package/src/Atomic/FormElements/Input/Input.js +4 -0
- package/src/Atomic/FormElements/Input/Input.stories.js +7 -1
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.js +28 -48
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.scss +98 -73
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +26 -23
- package/src/Atomic/FormElements/InputDateRange/components/Datepicker.js +6 -3
- package/src/Atomic/FormElements/InputDateRange/components/OpenedPart.js +4 -2
- package/src/Atomic/FormElements/InputDateRange/components/SelectItem.js +1 -1
- package/src/Atomic/FormElements/InputDateRange/dependencies.js +14 -6
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.js +5 -2
- package/src/Atomic/FormElements/Table/Table.scss +1 -1
- package/src/Atomic/FormElements/Textarea/Textarea.scss +1 -1
- package/src/Atomic/MainMenu/MainMenu.scss +2 -2
- package/src/Atomic/UI/Accordion/Accordion.scss +2 -2
- package/src/Atomic/UI/Arrow/Arrow.js +5 -5
- package/src/Atomic/UI/Calendar/Calendar.js +2 -2
- package/src/Atomic/UI/Calendar/Calendar.stories.js +2 -1
- package/src/Atomic/UI/Status/Status.scss +1 -1
- package/src/Molecular/Datepicker/Datepicker.js +346 -0
- package/src/Molecular/Datepicker/Datepicker.scss +8 -0
- package/src/Molecular/Datepicker/Datepicker.stories.js +27 -0
- package/src/Molecular/Datepicker/components/Calendar.js +118 -0
- package/src/scss/_vars.scss +3 -1
- package/src/scss/main.scss +1 -1
- package/dist/scss/anme/_anme-bootstrap-grid.scss +0 -748
- package/dist/scss/anme/_anme-elements.scss +0 -269
- package/dist/scss/anme/_anme-grid.scss +0 -111
- package/dist/scss/anme/_anme-justify.scss +0 -111
- package/dist/scss/anme/_anme-mixins-media.scss +0 -116
- package/dist/scss/anme/_anme-mixins.scss +0 -166
- package/dist/scss/anme/_anme-normalize.scss +0 -8
- package/dist/scss/anme/_anme-overall.scss +0 -34
- package/dist/scss/anme/_anme-padding-margins.scss +0 -419
- package/dist/scss/anme/_anme-table.scss +0 -81
- package/dist/scss/anme/_anme-theme.scss +0 -275
- package/dist/scss/anme/_anme-vars.scss +0 -91
- package/dist/scss/anme/_code-styling.scss +0 -23
- package/dist/scss/anme/styles.scss +0 -12
- package/src/scss/anme/_anme-bootstrap-grid.scss +0 -748
- package/src/scss/anme/_anme-elements.scss +0 -269
- package/src/scss/anme/_anme-grid.scss +0 -111
- package/src/scss/anme/_anme-justify.scss +0 -111
- package/src/scss/anme/_anme-mixins-media.scss +0 -116
- package/src/scss/anme/_anme-mixins.scss +0 -166
- package/src/scss/anme/_anme-normalize.scss +0 -8
- package/src/scss/anme/_anme-overall.scss +0 -34
- package/src/scss/anme/_anme-padding-margins.scss +0 -419
- package/src/scss/anme/_anme-table.scss +0 -81
- package/src/scss/anme/_anme-theme.scss +0 -275
- package/src/scss/anme/_anme-vars.scss +0 -91
- package/src/scss/anme/_code-styling.scss +0 -23
- package/src/scss/anme/styles.scss +0 -12
package/dist/scss/main.scss
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intelicoreact",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.71",
|
|
4
|
+
"description": "Date range fixes and dropdown refactor",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -14,13 +14,15 @@
|
|
|
14
14
|
"moment-timezone": "^0.5.34",
|
|
15
15
|
"react": "^17.0.2",
|
|
16
16
|
"react-feather": "^2.0.9",
|
|
17
|
-
"react-input-mask": "^2.0.4"
|
|
17
|
+
"react-input-mask": "^2.0.4",
|
|
18
|
+
"classnames": "^2.3.1"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@babel/cli": "^7.15.7",
|
|
21
22
|
"@babel/core": "^7.15.5",
|
|
22
23
|
"@babel/polyfill": "^7.12.1",
|
|
23
24
|
"@babel/preset-env": "^7.15.6",
|
|
24
|
-
"
|
|
25
|
+
"anme": "^1.0.0"
|
|
26
|
+
|
|
25
27
|
}
|
|
26
28
|
}
|
|
@@ -3,11 +3,21 @@ import cn from 'classnames';
|
|
|
3
3
|
|
|
4
4
|
import './CheckboxInput.scss';
|
|
5
5
|
|
|
6
|
-
const CheckboxInput = ({ label, id, value, onChange, disabled, className }) => {
|
|
6
|
+
const CheckboxInput = ({ label, id, value, onChange, disabled, className, isStark }) => {
|
|
7
7
|
return (
|
|
8
8
|
<label className={cn('checkbox-input', className, { [`checkbox-input_disabled`]: disabled })} htmlFor={id}>
|
|
9
9
|
<div className={cn(`checkbox-input__input`, { [`checkbox-input__input_checked`]: value })}>
|
|
10
|
-
<input
|
|
10
|
+
<input
|
|
11
|
+
id={id}
|
|
12
|
+
type="checkbox"
|
|
13
|
+
className="checkbox-input__checkbox"
|
|
14
|
+
onChange={(e) => onChange(!value, e)}
|
|
15
|
+
checked={value}
|
|
16
|
+
disabled={disabled}
|
|
17
|
+
ref={(elem) => {
|
|
18
|
+
if (elem) elem.indeterminate = isStark;
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
11
21
|
<span className="checkbox-input__mark" />
|
|
12
22
|
</div>
|
|
13
23
|
{label && <div className="checkbox-input__label">{label}</div>}
|
|
@@ -1,76 +1,107 @@
|
|
|
1
1
|
.checkbox-input {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
|
|
6
|
+
&_disabled {
|
|
7
|
+
opacity: 0.5;
|
|
8
|
+
pointer-events: none;
|
|
9
|
+
cursor: auto;
|
|
10
|
+
}
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
cursor: auto;
|
|
12
|
+
&:hover {
|
|
13
|
+
.checkbox-input__input {
|
|
14
|
+
background-color: rgba(#6b81dd, 0.2);
|
|
10
15
|
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&__input {
|
|
19
|
+
position: relative;
|
|
20
|
+
height: 14px;
|
|
21
|
+
width: 14px;
|
|
22
|
+
min-width: 14px;
|
|
23
|
+
border: 1px solid #9aa0b9;
|
|
24
|
+
border-radius: 2px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
margin-right: 5px;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
transition: background-color 0.2s ease;
|
|
29
|
+
background-color: #ffff;
|
|
11
30
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
background-color: rgba(#6b81dd, .2);
|
|
15
|
-
}
|
|
31
|
+
&_checked {
|
|
32
|
+
border-color: #6b81dd;
|
|
16
33
|
}
|
|
17
34
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
min-width: 14px;
|
|
23
|
-
border: 1px solid #9AA0B9;
|
|
24
|
-
border-radius: 2px;
|
|
25
|
-
overflow: hidden;
|
|
26
|
-
margin-right: 5px;
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
transition: background-color .2s ease;
|
|
29
|
-
background-color: #ffff;
|
|
35
|
+
.checkbox-input__checkbox:checked ~ .checkbox-input__mark {
|
|
36
|
+
display: block;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
30
39
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
&__checkbox {
|
|
41
|
+
opacity: 0;
|
|
42
|
+
position: absolute;
|
|
43
|
+
height: 0;
|
|
44
|
+
width: 0;
|
|
45
|
+
}
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
&__mark {
|
|
48
|
+
display: none;
|
|
49
|
+
position: absolute;
|
|
50
|
+
width: 14px;
|
|
51
|
+
height: 14px;
|
|
52
|
+
background-color: #6b81dd;
|
|
38
53
|
|
|
54
|
+
&:after {
|
|
55
|
+
content: "";
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: -2px;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
left: 0;
|
|
60
|
+
right: 0;
|
|
61
|
+
margin: auto;
|
|
62
|
+
width: 4px;
|
|
63
|
+
height: 8px;
|
|
64
|
+
border: solid white;
|
|
65
|
+
border-radius: 2px;
|
|
66
|
+
border-width: 0 2px 2px 0;
|
|
67
|
+
transform: rotate(45deg);
|
|
39
68
|
}
|
|
69
|
+
}
|
|
40
70
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
width: 0;
|
|
46
|
-
}
|
|
71
|
+
&__label {
|
|
72
|
+
font-size: 13px;
|
|
73
|
+
user-select: none;
|
|
74
|
+
}
|
|
47
75
|
|
|
48
|
-
|
|
49
|
-
|
|
76
|
+
input[type="checkbox" i] {
|
|
77
|
+
&:indeterminate {
|
|
78
|
+
display: block;
|
|
79
|
+
width: 100%;
|
|
80
|
+
height: 100%;
|
|
81
|
+
&:after {
|
|
82
|
+
content: "";
|
|
50
83
|
position: absolute;
|
|
51
|
-
|
|
52
|
-
|
|
84
|
+
top: 0;
|
|
85
|
+
bottom: 0;
|
|
86
|
+
left: 0;
|
|
87
|
+
right: 0;
|
|
88
|
+
margin: auto;
|
|
89
|
+
width: 100%;
|
|
90
|
+
height: 100%;
|
|
53
91
|
background-color: #6b81dd;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
border-width: 0 2px 2px 0;
|
|
68
|
-
transform: rotate(45deg);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
&__label{
|
|
73
|
-
font-size: 13px;
|
|
74
|
-
user-select: none;
|
|
92
|
+
}
|
|
93
|
+
&:before {
|
|
94
|
+
content: "";
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 50%;
|
|
97
|
+
left: 50%;
|
|
98
|
+
transform: translate(-50%, -50%);
|
|
99
|
+
width: 65%;
|
|
100
|
+
border: solid white;
|
|
101
|
+
border-radius: 2px;
|
|
102
|
+
border-width: 0 2px 2px 0;
|
|
103
|
+
z-index: 1;
|
|
104
|
+
}
|
|
75
105
|
}
|
|
106
|
+
}
|
|
76
107
|
}
|
|
@@ -5,10 +5,10 @@ global.lng = 'en';
|
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
title: 'Form Elements/CheckboxInput',
|
|
8
|
-
component: CheckboxInput
|
|
8
|
+
component: CheckboxInput,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const Template = args => {
|
|
11
|
+
const Template = (args) => {
|
|
12
12
|
const { value: argsValue } = args;
|
|
13
13
|
const [value, setValue] = useState(argsValue);
|
|
14
14
|
|
|
@@ -21,5 +21,6 @@ Checkbox.args = {
|
|
|
21
21
|
label: 'Test label',
|
|
22
22
|
value: true,
|
|
23
23
|
disabled: false,
|
|
24
|
-
forced: false
|
|
24
|
+
forced: false,
|
|
25
|
+
isStark: true,
|
|
25
26
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { Check, ChevronDown, ChevronUp } from 'react-feather';
|
|
4
|
-
import Label from '../Label/Label';
|
|
5
4
|
|
|
6
5
|
import './Dropdown.scss';
|
|
7
6
|
|
|
8
7
|
const RC = 'dropdown';
|
|
9
8
|
|
|
10
|
-
const Dropdown = ({ options, value, error, onChange, placeholder, className, isSearchable }) => {
|
|
9
|
+
const Dropdown = ({ options, value, error, onChange, placeholder, className, isSearchable, entity }) => {
|
|
11
10
|
const [isOpen, setIsOpen] = useState(false);
|
|
12
11
|
const [searchValue, setSearchValue] = useState('');
|
|
13
12
|
const dropdownRef = useRef(null);
|
|
14
|
-
|
|
13
|
+
if (!options) return null;
|
|
15
14
|
const filteredGroups = options
|
|
16
15
|
.filter(item => item.items?.length)
|
|
17
16
|
.map(item => ({ ...item, items: item.items.filter(el => el?.label?.toLowerCase().includes(searchValue?.toLowerCase() || '')) }))
|
|
@@ -23,6 +22,38 @@ const Dropdown = ({ options, value, error, onChange, placeholder, className, isS
|
|
|
23
22
|
|
|
24
23
|
const filteredOptions = [...filteredItems, ...filteredGroups];
|
|
25
24
|
|
|
25
|
+
const modalBtnTrigger = entity && entity !== '' && typeof entity === 'string';
|
|
26
|
+
const onChangeHandler = item => {
|
|
27
|
+
setIsOpen(false);
|
|
28
|
+
setSearchValue(null);
|
|
29
|
+
onChange(item.value);
|
|
30
|
+
};
|
|
31
|
+
// decorator
|
|
32
|
+
const getDepends = getDependsTrigger => {
|
|
33
|
+
const newOnChange = e => {
|
|
34
|
+
if (e.value === 'open_modal') {
|
|
35
|
+
onChange('open_modal');
|
|
36
|
+
} else {
|
|
37
|
+
onChangeHandler(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// add pseudo option
|
|
42
|
+
const newOptions = [
|
|
43
|
+
{
|
|
44
|
+
label: `New ${entity}`,
|
|
45
|
+
value: 'open_modal',
|
|
46
|
+
className: 'dropdown__list-item--modal'
|
|
47
|
+
},
|
|
48
|
+
...filteredOptions
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
onChange: changeItem => (getDependsTrigger ? newOnChange(changeItem) : onChangeHandler(changeItem)),
|
|
53
|
+
options: getDependsTrigger ? newOptions : options
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
26
57
|
const handleClickOutside = event => {
|
|
27
58
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
28
59
|
setIsOpen(false);
|
|
@@ -30,12 +61,6 @@ const Dropdown = ({ options, value, error, onChange, placeholder, className, isS
|
|
|
30
61
|
}
|
|
31
62
|
};
|
|
32
63
|
|
|
33
|
-
const onChangeHandler = item => {
|
|
34
|
-
setIsOpen(false);
|
|
35
|
-
setSearchValue(null);
|
|
36
|
-
onChange(item.value);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
64
|
const onSearchHandler = name => {
|
|
40
65
|
setSearchValue(name);
|
|
41
66
|
};
|
|
@@ -43,11 +68,13 @@ const Dropdown = ({ options, value, error, onChange, placeholder, className, isS
|
|
|
43
68
|
const hightlightedText = text =>
|
|
44
69
|
searchValue ? text?.replace(new RegExp(searchValue, 'i'), match => `<span class="bg--yellow">${match}</span>`) : text;
|
|
45
70
|
|
|
71
|
+
const depend = getDepends(modalBtnTrigger);
|
|
72
|
+
|
|
46
73
|
const getMarkupForElement = item =>
|
|
47
74
|
item.label.toLowerCase().includes(searchValue?.toLowerCase() || '') ? (
|
|
48
75
|
<button
|
|
49
76
|
key={item.value}
|
|
50
|
-
onClick={() =>
|
|
77
|
+
onClick={() => depend.onChange(item)}
|
|
51
78
|
className={cn(`${RC}__list-item`, { [`${RC}__list-item_active`]: item.value === value }, { [`${RC}__list-item_disabled`]: item.disabled })}
|
|
52
79
|
>
|
|
53
80
|
<span className={cn(`${RC}__active-icon`, { [`${RC}__active-icon_active`]: item.value === value })}>
|
|
@@ -58,9 +85,10 @@ const Dropdown = ({ options, value, error, onChange, placeholder, className, isS
|
|
|
58
85
|
) : null;
|
|
59
86
|
|
|
60
87
|
useEffect(() => {
|
|
88
|
+
if (!value) setSearchValue(null);
|
|
61
89
|
document.addEventListener('click', handleClickOutside, true);
|
|
62
90
|
return () => document.removeEventListener('click', handleClickOutside, true);
|
|
63
|
-
});
|
|
91
|
+
}, [value]);
|
|
64
92
|
|
|
65
93
|
const filteredOptionList = filteredOption =>
|
|
66
94
|
filteredOption.items?.length > 0 ? (
|
|
@@ -75,19 +103,25 @@ const Dropdown = ({ options, value, error, onChange, placeholder, className, isS
|
|
|
75
103
|
|
|
76
104
|
return (
|
|
77
105
|
<div className={cn(RC, className)} ref={dropdownRef}>
|
|
78
|
-
<button
|
|
106
|
+
<button
|
|
107
|
+
className={`${RC}__trigger input__wrap ${!value ? 'placeholder' : ''} ${error ? 'error' : ''}`}
|
|
108
|
+
onClick={() => (!isSearchable ? setIsOpen(!isOpen) : null)}
|
|
109
|
+
>
|
|
79
110
|
{isSearchable ? (
|
|
80
111
|
<input
|
|
81
112
|
className={`${RC}__input`}
|
|
82
|
-
value={searchValue
|
|
83
|
-
onChange={e =>
|
|
113
|
+
value={searchValue || filteredOptions.find(el => el.value === value)?.label || ''}
|
|
114
|
+
onChange={e => {
|
|
115
|
+
onSearchHandler(e.target.value);
|
|
116
|
+
}}
|
|
84
117
|
placeholder={placeholder}
|
|
85
|
-
onFocus={
|
|
118
|
+
onFocus={e => {
|
|
119
|
+
e.target.select();
|
|
120
|
+
setIsOpen(true);
|
|
121
|
+
}}
|
|
86
122
|
/>
|
|
87
123
|
) : (
|
|
88
|
-
<span className="text">
|
|
89
|
-
{selectedLabel || placeholder}
|
|
90
|
-
</span>
|
|
124
|
+
<span className="text">{selectedLabel || placeholder}</span>
|
|
91
125
|
)}
|
|
92
126
|
<span className={cn(`${RC}__arrow`, { [`${RC}__arrow_active`]: isOpen })} onClick={() => setIsOpen(!isOpen)}>
|
|
93
127
|
{isOpen ? <ChevronUp /> : <ChevronDown />}
|
|
@@ -95,7 +129,7 @@ const Dropdown = ({ options, value, error, onChange, placeholder, className, isS
|
|
|
95
129
|
</button>
|
|
96
130
|
{isOpen && filteredOptions.length > 0 && (
|
|
97
131
|
<div className={`${RC}__list`}>
|
|
98
|
-
{
|
|
132
|
+
{depend.options.map(filteredOption =>
|
|
99
133
|
filteredOption.items?.length ? filteredOptionList(filteredOption) : getMarkupForElement(filteredOption)
|
|
100
134
|
)}
|
|
101
135
|
</div>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
position: relative;
|
|
7
7
|
width: 100%;
|
|
8
|
+
border-radius: 7px;
|
|
8
9
|
|
|
9
10
|
&__trigger {
|
|
10
11
|
background: #ffffff;
|
|
@@ -28,8 +29,8 @@
|
|
|
28
29
|
&.error {
|
|
29
30
|
border-color: $color--secondary;
|
|
30
31
|
}
|
|
31
|
-
&.placeholder .text{
|
|
32
|
-
opacity: .7;
|
|
32
|
+
&.placeholder .text {
|
|
33
|
+
opacity: 0.7;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -85,7 +86,24 @@
|
|
|
85
86
|
width: 100%;
|
|
86
87
|
height: 24px;
|
|
87
88
|
white-space: nowrap;
|
|
88
|
-
|
|
89
|
+
overflow-x: hidden;
|
|
90
|
+
|
|
91
|
+
&--modal {
|
|
92
|
+
color: #1f7499;
|
|
93
|
+
font-size: 14px;
|
|
94
|
+
line-height: 20px;
|
|
95
|
+
letter-spacing: 0.2px;
|
|
96
|
+
position: relative;
|
|
97
|
+
&:after {
|
|
98
|
+
content: "";
|
|
99
|
+
position: absolute;
|
|
100
|
+
bottom: -2px;
|
|
101
|
+
height: 1px;
|
|
102
|
+
width: 300%;
|
|
103
|
+
transform: translateX(-50%);
|
|
104
|
+
background-color: #e8e9ec;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
89
107
|
&:hover,
|
|
90
108
|
&_active {
|
|
91
109
|
background: $color--gray--gentle;
|
|
@@ -7,35 +7,48 @@ export default {
|
|
|
7
7
|
component: Dropdown,
|
|
8
8
|
argTypes: {
|
|
9
9
|
className: {
|
|
10
|
-
description: 'string'
|
|
10
|
+
description: 'string',
|
|
11
11
|
},
|
|
12
|
-
value: { description: 'string - current option'},
|
|
12
|
+
value: { description: 'string - current option' },
|
|
13
13
|
isSearchable: {
|
|
14
14
|
description: 'boolean - enable search',
|
|
15
15
|
},
|
|
16
|
-
onChange: { description: 'callback return selected value'}
|
|
17
|
-
|
|
16
|
+
onChange: { description: 'callback return selected value' },
|
|
17
|
+
entity: {
|
|
18
|
+
description: 'string',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const buttonStyles={
|
|
24
|
+
border: 'solid 1px #000',
|
|
25
|
+
padding: '5px'
|
|
18
26
|
};
|
|
19
27
|
|
|
20
|
-
const Template = args => {
|
|
28
|
+
const Template = (args) => {
|
|
21
29
|
const [value, setValue] = useState('');
|
|
22
30
|
return (
|
|
23
|
-
|
|
24
|
-
<
|
|
25
|
-
|
|
31
|
+
<>
|
|
32
|
+
<div style={{ width: 200 }}>
|
|
33
|
+
<Dropdown {...args} value={value} onChange={setValue} />
|
|
34
|
+
</div>
|
|
35
|
+
<button style={buttonStyles} className='mt10' onClick={() => {console.log('click!'); setValue('')}} >Reset</button>
|
|
36
|
+
</>
|
|
26
37
|
);
|
|
27
38
|
};
|
|
28
39
|
|
|
29
40
|
export const DropdownTemplate = Template.bind({});
|
|
30
41
|
|
|
31
42
|
DropdownTemplate.args = {
|
|
43
|
+
entity: 'entity',
|
|
44
|
+
value: 'drop6',
|
|
32
45
|
placeholder: 'Placeholder',
|
|
33
46
|
isSearchable: true,
|
|
34
47
|
options: [
|
|
35
|
-
{ label: 'Dropdown1', value: 'drop1', className: 'status status--approved' },
|
|
36
48
|
{ label: 'Dropdown2', value: 'drop2' },
|
|
37
49
|
{ label: 'Dropdown3', value: 'drop3', disabled: true },
|
|
38
50
|
{ label: 'Dropdown4', value: 'drop4' },
|
|
51
|
+
{ label: 'Dropdown1', value: 'drop1', className: 'status status--approved' },
|
|
39
52
|
{ label: 'Dropdown5', value: 'drop5' },
|
|
40
53
|
{ label: 'Dropdown6', value: 'drop6' },
|
|
41
54
|
{
|
|
@@ -43,17 +56,17 @@ DropdownTemplate.args = {
|
|
|
43
56
|
items: [
|
|
44
57
|
{ label: 'Group 11', value: 'group11' },
|
|
45
58
|
{ label: 'Group 12', value: 'group12', disabled: true },
|
|
46
|
-
{ label: 'Group 13', value: 'group13' }
|
|
47
|
-
]
|
|
59
|
+
{ label: 'Group 13', value: 'group13' },
|
|
60
|
+
],
|
|
48
61
|
},
|
|
49
62
|
{
|
|
50
63
|
label: 'Some Group 2',
|
|
51
64
|
items: [
|
|
52
65
|
{ label: 'Group 21', value: 'group21' },
|
|
53
66
|
{ label: 'Group 22', value: 'group22' },
|
|
54
|
-
{ label: 'Group 23', value: 'group23' }
|
|
55
|
-
]
|
|
56
|
-
}
|
|
67
|
+
{ label: 'Group 23', value: 'group23' },
|
|
68
|
+
],
|
|
69
|
+
},
|
|
57
70
|
],
|
|
58
|
-
error: ''
|
|
71
|
+
error: '',
|
|
59
72
|
};
|
|
@@ -21,6 +21,8 @@ const Input = ({
|
|
|
21
21
|
onFocus,
|
|
22
22
|
onKeyUp,
|
|
23
23
|
mask,
|
|
24
|
+
maskChar,
|
|
25
|
+
formatChars,
|
|
24
26
|
error,
|
|
25
27
|
icon,
|
|
26
28
|
symbolsLimit,
|
|
@@ -72,6 +74,8 @@ const Input = ({
|
|
|
72
74
|
onKeyUp: handle.keyUp,
|
|
73
75
|
min,
|
|
74
76
|
max,
|
|
77
|
+
...(maskChar ? { maskChar } : {}),
|
|
78
|
+
...(formatChars ? { formatChars } : {}),
|
|
75
79
|
};
|
|
76
80
|
|
|
77
81
|
function renderInput() {
|
|
@@ -67,7 +67,13 @@ InputTemplate.args = {
|
|
|
67
67
|
min: '0',
|
|
68
68
|
max: '5',
|
|
69
69
|
placeholder: 'Placeholder',
|
|
70
|
-
mask: '',
|
|
70
|
+
// mask: 'nnnnn0129',
|
|
71
|
+
// maskChar: '_',
|
|
72
|
+
// formatChars: {
|
|
73
|
+
// 'n': '[0-9]',
|
|
74
|
+
// 's': '[A-Za-z]',
|
|
75
|
+
// '*': '[A-Za-z0-9]'
|
|
76
|
+
// },
|
|
71
77
|
icon: <User />,
|
|
72
78
|
symbolsLimit: 225
|
|
73
79
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import moment from 'moment-timezone';
|
|
4
4
|
|
|
@@ -15,22 +15,15 @@ const InputDateRange = props => {
|
|
|
15
15
|
id,
|
|
16
16
|
label,
|
|
17
17
|
className,
|
|
18
|
-
buttonsTypes,
|
|
19
18
|
value,
|
|
20
19
|
onChange = () => {},
|
|
21
20
|
error,
|
|
22
21
|
disabled,
|
|
23
22
|
isHoverable,
|
|
24
|
-
short,
|
|
25
23
|
isCompact = false,
|
|
26
|
-
// isFocused = false,
|
|
27
|
-
isIntervalsHidden = false,
|
|
28
|
-
isCompareHidden = false,
|
|
29
24
|
hideArrows = false,
|
|
30
25
|
isOptionsRight,
|
|
31
|
-
limitRange,
|
|
32
26
|
isUseAbs,
|
|
33
|
-
absTooltip
|
|
34
27
|
} = props;
|
|
35
28
|
|
|
36
29
|
const actualValues = getActualDateRange(value);
|
|
@@ -40,7 +33,25 @@ const InputDateRange = props => {
|
|
|
40
33
|
|
|
41
34
|
const ref = !isUseAbs ? useClickOutside(toggleOff) : useRef(null);
|
|
42
35
|
const internalContainerRef = useRef(null);
|
|
43
|
-
|
|
36
|
+
|
|
37
|
+
const handleChange = input => {
|
|
38
|
+
const newValue = getActualDateRange(input);
|
|
39
|
+
const formatedValue = {
|
|
40
|
+
intervalKey: newValue.intervalKey,
|
|
41
|
+
start: newValue.start ? moment(newValue.start).format('YYYY-MM-DDTHH:mm') : newValue.start,
|
|
42
|
+
end: newValue.end ? moment(newValue.end).format('YYYY-MM-DDTHH:mm') : newValue.end,
|
|
43
|
+
...(newValue.compare ? { compare: newValue.compare } : {}),
|
|
44
|
+
...(newValue.startPrevDate ? { startPrevDate: moment(newValue.startPrevDate).format('YYYY-MM-DDTHH:mm') } : {}),
|
|
45
|
+
...(newValue.endPrevDate ? { endPrevDate: moment(newValue.endPrevDate).format('YYYY-MM-DDTHH:mm') } : {})
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
onChange(formatedValue);
|
|
49
|
+
return formatedValue;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
handleChange({ ...value });
|
|
54
|
+
}, []);
|
|
44
55
|
|
|
45
56
|
const Range = () => {
|
|
46
57
|
const SYMBOLS_QUANTITY_IF_TIME_ADDED = 13;
|
|
@@ -95,7 +106,7 @@ const InputDateRange = props => {
|
|
|
95
106
|
}
|
|
96
107
|
const startPrevDate = moment(newStart).subtract(intervalHoursCount, 'hours').subtract(1, 'seconds');
|
|
97
108
|
const endPrevDate = moment(newEnd).subtract(1, 'seconds');
|
|
98
|
-
|
|
109
|
+
handleChange({
|
|
99
110
|
...value,
|
|
100
111
|
intervalKey: getActualDateRange({
|
|
101
112
|
start: newStart,
|
|
@@ -113,35 +124,6 @@ const InputDateRange = props => {
|
|
|
113
124
|
toggleOff();
|
|
114
125
|
};
|
|
115
126
|
|
|
116
|
-
const absData = useMemo(
|
|
117
|
-
() => ({
|
|
118
|
-
body: OpenedPart,
|
|
119
|
-
props: {
|
|
120
|
-
...props,
|
|
121
|
-
key: `${actualValues.start}-${actualValues.end}-${actualValues.intervalKey}-${current}-${isCompare}`,
|
|
122
|
-
actualValues,
|
|
123
|
-
current,
|
|
124
|
-
setCurrent,
|
|
125
|
-
isCompare,
|
|
126
|
-
setIsCompare,
|
|
127
|
-
toggleOff,
|
|
128
|
-
onChange
|
|
129
|
-
},
|
|
130
|
-
clickOutsideCallback: () => toggleOff(),
|
|
131
|
-
top: internalContainerRef.current?.getBoundingClientRect()?.bottom || 0,
|
|
132
|
-
left: internalContainerRef.current?.getBoundingClientRect()?.left || 0
|
|
133
|
-
}),
|
|
134
|
-
[isToggled, value, actualValues, current, isCompare]
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
if (current && isUseAbs && absTooltip) onChange(current, 'absTooltip/props/current');
|
|
139
|
-
}, [current]);
|
|
140
|
-
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
if (isUseAbs) onChange(isToggled ? absData : null, 'absTooltip');
|
|
143
|
-
}, [isToggled]);
|
|
144
|
-
|
|
145
127
|
return (
|
|
146
128
|
<div
|
|
147
129
|
ref={internalContainerRef}
|
|
@@ -154,7 +136,12 @@ const InputDateRange = props => {
|
|
|
154
136
|
})}
|
|
155
137
|
>
|
|
156
138
|
<span className="date-range-input__label">{label}</span>
|
|
157
|
-
<div
|
|
139
|
+
<div
|
|
140
|
+
className="date-range-input__wraper"
|
|
141
|
+
ref={ref}
|
|
142
|
+
onMouseEnter={isHoverable ? toggleOn : () => null}
|
|
143
|
+
onMouseLeave={isHoverable ? toggleOff : () => null}
|
|
144
|
+
>
|
|
158
145
|
<div
|
|
159
146
|
className={cn('date-range-input__absolut-wraper', {
|
|
160
147
|
'date-range-input__absolut-wraper_right-position': isOptionsRight
|
|
@@ -164,13 +151,6 @@ const InputDateRange = props => {
|
|
|
164
151
|
<button
|
|
165
152
|
id={id}
|
|
166
153
|
className={cn('date-range-input__toggle-button')}
|
|
167
|
-
// className={cn(
|
|
168
|
-
// 'date-range-input__toggle-button',
|
|
169
|
-
// { 'form-select__input--disabled': disabled },
|
|
170
|
-
// { 'form-select__input--opened': isToggled },
|
|
171
|
-
// { 'form-select__input--focused': isToggled },
|
|
172
|
-
// className,
|
|
173
|
-
// )}
|
|
174
154
|
disabled={disabled}
|
|
175
155
|
onClick={!disabled && !isHoverable ? toggle : undefined}
|
|
176
156
|
>
|
|
@@ -221,7 +201,7 @@ const InputDateRange = props => {
|
|
|
221
201
|
isCompare={isCompare}
|
|
222
202
|
setIsCompare={setIsCompare}
|
|
223
203
|
toggleOff={toggleOff}
|
|
224
|
-
onChange={
|
|
204
|
+
onChange={handleChange}
|
|
225
205
|
/>
|
|
226
206
|
)}
|
|
227
207
|
</div>
|