intelicoreact 1.8.8 → 1.8.10
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/components/DropdownLoader.jsx +18 -1
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.jsx +121 -1
- package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.jsx +507 -1
- package/dist/Atomic/FormElements/MultiSelect/MultiSelect.jsx +46 -1
- package/dist/Atomic/FormElements/NumericInput/NumericInput.jsx +337 -1
- package/dist/Atomic/FormElements/RadioGroup/RadioGroup.jsx +66 -1
- package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.jsx +78 -1
- package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.jsx +54 -1
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.jsx +183 -1
- package/dist/Atomic/FormElements/RangeList/RangeList.jsx +181 -1
- package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.jsx +41 -1
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.jsx +449 -1
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.jsx +865 -1
- package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.jsx +37 -1
- package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.jsx +48 -1
- package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.jsx +62 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.jsx +175 -1
- package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.jsx +65 -1
- package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.jsx +118 -1
- package/dist/Atomic/FormElements/Text/Text.jsx +126 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.jsx +61 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.jsx +181 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.jsx +60 -1
- package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.jsx +83 -1
- package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.jsx +80 -1
- package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.jsx +103 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.jsx +115 -1
- package/dist/Atomic/Layout/Header/Header.jsx +86 -1
- package/dist/Atomic/Layout/MainMenu/MainMenu.jsx +164 -1
- package/dist/Atomic/UI/AccordionTable/AccordionTable.jsx +250 -1
- package/dist/Atomic/UI/AccordionText/AccordionText.jsx +68 -1
- package/dist/Atomic/UI/Arrow/Arrow.jsx +134 -1
- package/dist/Atomic/UI/Box/Box.jsx +53 -1
- package/dist/Atomic/UI/Chart/Chart.jsx +178 -1
- package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.jsx +78 -1
- package/dist/Atomic/UI/Chart/partial/optionsConstructor.jsx +334 -1
- package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.jsx +111 -1
- package/dist/Atomic/UI/DateTime/DateTime.jsx +57 -1
- package/dist/Atomic/UI/DebugContainer/DebugContainer.jsx +44 -1
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.jsx +15 -1
- package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.jsx +223 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion._test.jsx +75 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion.jsx +86 -1
- package/dist/Atomic/UI/PieChart/PieChart.jsx +41 -1
- package/dist/Atomic/UI/Table/Partials/TdCell.jsx +87 -1
- package/dist/Atomic/UI/Table/Partials/TdHeader.jsx +36 -1
- package/dist/Atomic/UI/Table/Partials/TdRow.jsx +103 -1
- package/dist/Atomic/UI/Table/Partials/TdTitle.jsx +55 -1
- package/dist/Atomic/UI/Table/Table.jsx +63 -1
- package/dist/Atomic/UI/Table/TdTypes/TdActions.jsx +80 -1
- package/dist/Atomic/UI/Table/TdTypes/TdPriority.jsx +26 -1
- package/dist/Atomic/UI/Table/TdTypes/TdRange.jsx +13 -1
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.jsx +56 -1
- package/dist/Atomic/UI/TagList/TagList.jsx +256 -1
- package/dist/Atomic/UI/WizardStepper/constructor.jsx +86 -1
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.jsx +254 -1
- package/dist/Functions/customEventListener.jsx +96 -1
- package/dist/Functions/operations.jsx +138 -1
- package/dist/Functions/useFormTools/functions/RenderFields.jsx +108 -1
- package/dist/Functions/useFormTools/index.jsx +777 -1
- package/dist/Functions/usePasswordChecker.jsx +128 -1
- package/dist/Functions/utils.jsx +492 -1
- package/dist/Molecular/CustomIcons/components/AffiliateNetworks.jsx +22 -1
- package/dist/Molecular/CustomIcons/components/AlertCircle.jsx +24 -1
- package/dist/Molecular/CustomIcons/components/AppStore.jsx +30 -1
- package/dist/Molecular/CustomIcons/components/Arrow.jsx +33 -1
- package/dist/Molecular/CustomIcons/components/ArrowDown.jsx +18 -1
- package/dist/Molecular/CustomIcons/components/ArrowLeft.jsx +23 -1
- package/dist/Molecular/CustomIcons/components/ArrowRight.jsx +23 -1
- package/dist/Molecular/CustomIcons/components/ArrowUp.jsx +18 -1
- package/dist/Molecular/CustomIcons/components/Bell.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Button.jsx +13 -1
- package/dist/Molecular/CustomIcons/components/Campaigns.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/Check.jsx +15 -1
- package/dist/Molecular/CustomIcons/components/Check2.jsx +13 -1
- package/dist/Molecular/CustomIcons/components/ChevronDown.jsx +13 -1
- package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.jsx +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronLeft.jsx +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronRight.jsx +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronUp.jsx +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronUpDown.jsx +28 -1
- package/dist/Molecular/CustomIcons/components/Close.jsx +15 -1
- package/dist/Molecular/CustomIcons/components/ColumnsOrder.jsx +18 -1
- package/dist/Molecular/CustomIcons/components/Delete.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/Edit.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Email.jsx +32 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo.jsx +19 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo2.jsx +36 -1
- package/dist/Molecular/CustomIcons/components/Flows.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Gift.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/GoogleAuth.jsx +30 -1
- package/dist/Molecular/CustomIcons/components/GooglePlay.jsx +30 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle.jsx +20 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle2.jsx +21 -1
- package/dist/Molecular/CustomIcons/components/HelpCircleFilled.jsx +20 -1
- package/dist/Molecular/CustomIcons/components/Home.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/Home2.jsx +23 -1
- package/dist/Molecular/CustomIcons/components/Key.jsx +24 -1
- package/dist/Molecular/CustomIcons/components/Landers.jsx +21 -1
- package/dist/Molecular/CustomIcons/components/Lock.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Mail.jsx +27 -1
- package/dist/Molecular/CustomIcons/components/Mastercard.jsx +74 -1
- package/dist/Molecular/CustomIcons/components/Minus.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/Offers.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/Pause.jsx +29 -1
- package/dist/Molecular/CustomIcons/components/PayPal.jsx +42 -1
- package/dist/Molecular/CustomIcons/components/PayPalLightLarge.jsx +29 -1
- package/dist/Molecular/CustomIcons/components/Phone.jsx +31 -1
- package/dist/Molecular/CustomIcons/components/Play.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/Plus.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/Profile.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/QRCode.jsx +30 -1
- package/dist/Molecular/CustomIcons/components/Rectangle.jsx +13 -1
- package/dist/Molecular/CustomIcons/components/Revert.jsx +14 -1
- package/dist/Molecular/CustomIcons/components/Star.jsx +15 -1
- package/dist/Molecular/CustomIcons/components/Star2.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/TrafficSources.jsx +15 -1
- package/dist/Molecular/CustomIcons/components/Trash.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/TrashRed.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Triggers.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/User.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/Visa.jsx +32 -1
- package/dist/Molecular/CustomIcons/components/X.jsx +13 -1
- package/dist/Molecular/FormElement/FormElement.jsx +52 -1
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.jsx +161 -1
- package/dist/Molecular/InputAddress/InputAddress.jsx +641 -1
- package/dist/Molecular/InputPassword/InputPassword.jsx +50 -1
- package/package.json +1 -1
|
@@ -1 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { ChevronDown, ChevronUp } from 'react-feather';
|
|
4
|
+
import './AccordionText.scss';
|
|
5
|
+
|
|
6
|
+
const defaultText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.`;
|
|
7
|
+
|
|
8
|
+
function AccordionText({
|
|
9
|
+
isDefaultOpen = false,
|
|
10
|
+
isOuterOpen = false,
|
|
11
|
+
className,
|
|
12
|
+
text = defaultText,
|
|
13
|
+
shortText = null,
|
|
14
|
+
}) {
|
|
15
|
+
const bodyRef = useRef(null);
|
|
16
|
+
const [isOpen, setIsOpen] = useState(isDefaultOpen);
|
|
17
|
+
const [isNeedTrimText, setIsNeedTrimText] = useState(false);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setIsOpen(isOuterOpen);
|
|
21
|
+
}, [isOuterOpen]);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const checkEllipsis = () => {
|
|
25
|
+
if (bodyRef.current) {
|
|
26
|
+
setIsNeedTrimText(bodyRef.current.scrollWidth > bodyRef.current.clientWidth);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
31
|
+
checkEllipsis();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (bodyRef.current) {
|
|
35
|
+
resizeObserver.observe(bodyRef.current);
|
|
36
|
+
checkEllipsis();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return () => {
|
|
40
|
+
if (bodyRef.current) {
|
|
41
|
+
resizeObserver.unobserve(bodyRef.current);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, [text]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
className={cn('accordion-text', className, {
|
|
49
|
+
'accordion-text--open': isOpen,
|
|
50
|
+
})}
|
|
51
|
+
onClick={() => setIsOpen(prevIsOpen => !prevIsOpen)}
|
|
52
|
+
>
|
|
53
|
+
<div
|
|
54
|
+
className={cn('accordion-text__body', {
|
|
55
|
+
'accordion-text__body--trim-text': isNeedTrimText && !isOpen,
|
|
56
|
+
})}
|
|
57
|
+
ref={bodyRef}
|
|
58
|
+
>
|
|
59
|
+
{shortText ? (isOpen ? text : shortText) : text}
|
|
60
|
+
</div>
|
|
61
|
+
<div className="accordion-text__toggle">
|
|
62
|
+
{isOpen ? <ChevronUp /> : <ChevronDown />}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default AccordionText;
|
|
@@ -1 +1,134 @@
|
|
|
1
|
-
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import { getStyles } from '../../../Functions/utils';
|
|
6
|
+
|
|
7
|
+
import './Arrow.scss';
|
|
8
|
+
|
|
9
|
+
function Arrow({ type, className, onClick, disabled, testId, isAlt }) {
|
|
10
|
+
if (!type || (type !== 'left' && type !== 'right')) return null;
|
|
11
|
+
const ref = useRef();
|
|
12
|
+
const [color, setColor] = useState('currentColor');
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (ref.current) {
|
|
16
|
+
setColor(getStyles(ref.current, 'color'));
|
|
17
|
+
}
|
|
18
|
+
}, [ref.current]);
|
|
19
|
+
|
|
20
|
+
function renderSVG() {
|
|
21
|
+
if (type === 'left') {
|
|
22
|
+
if (isAlt) {
|
|
23
|
+
return (
|
|
24
|
+
<svg
|
|
25
|
+
data-testid={testId}
|
|
26
|
+
version="1.1"
|
|
27
|
+
id="Layer_1"
|
|
28
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
+
width="16"
|
|
30
|
+
height="16"
|
|
31
|
+
viewBox="0 0 16 16"
|
|
32
|
+
>
|
|
33
|
+
<path
|
|
34
|
+
d="M12.7,8H3.3"
|
|
35
|
+
stroke={color}
|
|
36
|
+
fill="none"
|
|
37
|
+
strokeWidth={1.3333}
|
|
38
|
+
strokeLinecap="round"
|
|
39
|
+
strokeLinejoin="round"
|
|
40
|
+
/>
|
|
41
|
+
<path
|
|
42
|
+
d="M8,3.3L3.3,8L8,12.7"
|
|
43
|
+
stroke={color}
|
|
44
|
+
fill="none"
|
|
45
|
+
strokeWidth={1.3333}
|
|
46
|
+
strokeLinecap="round"
|
|
47
|
+
strokeLinejoin="round"
|
|
48
|
+
/>
|
|
49
|
+
</svg>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return (
|
|
53
|
+
<svg
|
|
54
|
+
data-testid={testId}
|
|
55
|
+
width="24"
|
|
56
|
+
height="24"
|
|
57
|
+
viewBox="0 0 24 24"
|
|
58
|
+
fill="none"
|
|
59
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
+
>
|
|
61
|
+
<path
|
|
62
|
+
d="M15 18L9 12L15 6"
|
|
63
|
+
stroke={color}
|
|
64
|
+
strokeWidth="2"
|
|
65
|
+
strokeLinecap="round"
|
|
66
|
+
strokeLinejoin="round"
|
|
67
|
+
/>
|
|
68
|
+
</svg>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
if (isAlt) {
|
|
72
|
+
return (
|
|
73
|
+
<svg
|
|
74
|
+
data-testid={testId}
|
|
75
|
+
id="Layer_1"
|
|
76
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
77
|
+
width="16"
|
|
78
|
+
height="16"
|
|
79
|
+
viewBox="0 0 16 16"
|
|
80
|
+
>
|
|
81
|
+
<path
|
|
82
|
+
d="M3.3,8h9.3"
|
|
83
|
+
stroke={color}
|
|
84
|
+
fill="none"
|
|
85
|
+
strokeWidth={1.3333}
|
|
86
|
+
strokeLinecap="round"
|
|
87
|
+
strokeLinejoin="round"
|
|
88
|
+
/>
|
|
89
|
+
<path
|
|
90
|
+
d="M8,3.3L12.7,8L8,12.7"
|
|
91
|
+
stroke={color}
|
|
92
|
+
fill="none"
|
|
93
|
+
strokeWidth={1.3333}
|
|
94
|
+
strokeLinecap="round"
|
|
95
|
+
strokeLinejoin="round"
|
|
96
|
+
/>
|
|
97
|
+
</svg>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return (
|
|
101
|
+
<svg
|
|
102
|
+
data-testid={testId}
|
|
103
|
+
width="24"
|
|
104
|
+
height="24"
|
|
105
|
+
viewBox="0 0 24 24"
|
|
106
|
+
fill="none"
|
|
107
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
108
|
+
>
|
|
109
|
+
<path
|
|
110
|
+
d="M9 18L15 12L9 6"
|
|
111
|
+
stroke="currentColor"
|
|
112
|
+
strokeWidth="2"
|
|
113
|
+
strokeLinecap="round"
|
|
114
|
+
strokeLinejoin="round"
|
|
115
|
+
/>
|
|
116
|
+
</svg>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div
|
|
122
|
+
data-testid={`arrow--key-${testId}--type-${type}`}
|
|
123
|
+
ref={ref}
|
|
124
|
+
className={cn('arrow', `arrow_${type}`, className, {
|
|
125
|
+
arrow_disabled: disabled,
|
|
126
|
+
})}
|
|
127
|
+
onClick={onClick}
|
|
128
|
+
>
|
|
129
|
+
{renderSVG()}
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default Arrow;
|
|
@@ -1 +1,53 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
|
|
3
|
+
// global
|
|
4
|
+
|
|
5
|
+
// styles
|
|
6
|
+
import './Box.scss';
|
|
7
|
+
|
|
8
|
+
const directionVariants = {
|
|
9
|
+
column: 'column',
|
|
10
|
+
row: 'row',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const sizes = {
|
|
14
|
+
none: 'none',
|
|
15
|
+
xs: 'xs',
|
|
16
|
+
s: 's',
|
|
17
|
+
m: 'm',
|
|
18
|
+
l: 'l',
|
|
19
|
+
xl: 'xl',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function Box({
|
|
23
|
+
children,
|
|
24
|
+
paddingVariant = sizes.m,
|
|
25
|
+
radiiVariant = sizes.s,
|
|
26
|
+
direction = directionVariants.column,
|
|
27
|
+
className,
|
|
28
|
+
...restProps
|
|
29
|
+
}) {
|
|
30
|
+
const styles = {
|
|
31
|
+
flexDirection: direction,
|
|
32
|
+
};
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
style={styles}
|
|
36
|
+
className={cn(
|
|
37
|
+
'box',
|
|
38
|
+
`box--padding-${paddingVariant}`,
|
|
39
|
+
`box--radii-${radiiVariant}`,
|
|
40
|
+
className,
|
|
41
|
+
{
|
|
42
|
+
'df': direction === directionVariants.row,
|
|
43
|
+
'dfc-jc': direction === directionVariants.column,
|
|
44
|
+
},
|
|
45
|
+
)}
|
|
46
|
+
{...restProps}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default Box;
|
|
@@ -1 +1,178 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
BarElement,
|
|
3
|
+
CategoryScale,
|
|
4
|
+
Chart as ChartJS,
|
|
5
|
+
Filler,
|
|
6
|
+
LinearScale,
|
|
7
|
+
LineElement,
|
|
8
|
+
PointElement,
|
|
9
|
+
Tooltip,
|
|
10
|
+
} from 'chart.js';
|
|
11
|
+
|
|
12
|
+
import cn from 'classnames';
|
|
13
|
+
import {
|
|
14
|
+
useCallback,
|
|
15
|
+
useEffect,
|
|
16
|
+
useLayoutEffect,
|
|
17
|
+
useMemo,
|
|
18
|
+
useRef,
|
|
19
|
+
useState,
|
|
20
|
+
} from 'react';
|
|
21
|
+
import * as ChartComponents from 'react-chartjs-2';
|
|
22
|
+
|
|
23
|
+
import { clone } from '../../../Functions/utils';
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
COMPONENT_OPTIONS,
|
|
27
|
+
DEFAULT_CHART_MODEL,
|
|
28
|
+
ICON_MODELS,
|
|
29
|
+
} from './partial/Chart.constants';
|
|
30
|
+
import ChartTypeSwitcherIcon from './partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon';
|
|
31
|
+
import {
|
|
32
|
+
correctModelKey,
|
|
33
|
+
getChartTypeKey,
|
|
34
|
+
getNotLibraryOptionsOptions,
|
|
35
|
+
getOptions,
|
|
36
|
+
prepareData,
|
|
37
|
+
} from './partial/utils';
|
|
38
|
+
|
|
39
|
+
import './Chart.scss';
|
|
40
|
+
|
|
41
|
+
const RC = 'chart';
|
|
42
|
+
|
|
43
|
+
ChartJS.register(
|
|
44
|
+
CategoryScale,
|
|
45
|
+
LinearScale,
|
|
46
|
+
BarElement,
|
|
47
|
+
PointElement,
|
|
48
|
+
LineElement,
|
|
49
|
+
Filler,
|
|
50
|
+
Tooltip,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
function Chart({
|
|
54
|
+
className,
|
|
55
|
+
initialModel,
|
|
56
|
+
modelsForSwitch,
|
|
57
|
+
setModelExternalValue,
|
|
58
|
+
description,
|
|
59
|
+
customOptions,
|
|
60
|
+
data,
|
|
61
|
+
addToDatasets,
|
|
62
|
+
modifyOptions,
|
|
63
|
+
}) {
|
|
64
|
+
if (!data) return null;
|
|
65
|
+
|
|
66
|
+
const { label, value } = description || {};
|
|
67
|
+
|
|
68
|
+
const [model, setModel] = useState(DEFAULT_CHART_MODEL);
|
|
69
|
+
const [localData, setLocalData] = useState(data);
|
|
70
|
+
const chartRef = useRef(null);
|
|
71
|
+
const charContainertRef = useRef(null);
|
|
72
|
+
|
|
73
|
+
const options = useMemo(
|
|
74
|
+
() =>
|
|
75
|
+
customOptions
|
|
76
|
+
|| (modifyOptions ? modifyOptions(getOptions(model)) : getOptions(model)),
|
|
77
|
+
[customOptions, model, modifyOptions?.toString?.(), data],
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const notLibraryOptionsOptions = useMemo(
|
|
81
|
+
() =>
|
|
82
|
+
customOptions
|
|
83
|
+
? customOptions?.notLibraryOptions
|
|
84
|
+
: getNotLibraryOptionsOptions(model),
|
|
85
|
+
[customOptions, model, data],
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const ChartComponent = useCallback(
|
|
89
|
+
(props) => {
|
|
90
|
+
const Component = ChartComponents[getChartTypeKey(model)];
|
|
91
|
+
return <Component ref={chartRef} {...props} />;
|
|
92
|
+
},
|
|
93
|
+
[model],
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const isExcludeDescription
|
|
97
|
+
= COMPONENT_OPTIONS.disableDescriptionsFor.includes(model);
|
|
98
|
+
const isExcludeChartTypeSwitcher
|
|
99
|
+
= COMPONENT_OPTIONS.disableChartTypeSwitcherFor.includes(model);
|
|
100
|
+
|
|
101
|
+
useLayoutEffect(() => {
|
|
102
|
+
if (setModelExternalValue && model !== 'emptyLayout')
|
|
103
|
+
setModelExternalValue(model);
|
|
104
|
+
}, [model]);
|
|
105
|
+
|
|
106
|
+
useLayoutEffect(() => {
|
|
107
|
+
const { setCanvasDimensions } = notLibraryOptionsOptions || {};
|
|
108
|
+
if (charContainertRef.current) {
|
|
109
|
+
charContainertRef.current.style.width = setCanvasDimensions?.width ?? '';
|
|
110
|
+
charContainertRef.current.style.height
|
|
111
|
+
= setCanvasDimensions?.height ?? '';
|
|
112
|
+
}
|
|
113
|
+
}, [notLibraryOptionsOptions]);
|
|
114
|
+
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
setModel(correctModelKey(initialModel));
|
|
117
|
+
}, [initialModel]);
|
|
118
|
+
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
setLocalData(
|
|
121
|
+
prepareData(model, clone(data), chartRef.current, addToDatasets),
|
|
122
|
+
);
|
|
123
|
+
}, [model, data]);
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<div
|
|
127
|
+
className={cn(
|
|
128
|
+
RC,
|
|
129
|
+
{ [`${RC}_icon-mode`]: ICON_MODELS.includes(model) },
|
|
130
|
+
className,
|
|
131
|
+
)}
|
|
132
|
+
>
|
|
133
|
+
<div
|
|
134
|
+
className={cn(`${RC}__header`, {
|
|
135
|
+
[`${RC}__header_only-switcher`]: !description,
|
|
136
|
+
})}
|
|
137
|
+
>
|
|
138
|
+
{description && !isExcludeDescription
|
|
139
|
+
? (
|
|
140
|
+
<div className={cn(`${RC}__description`)}>
|
|
141
|
+
{label
|
|
142
|
+
? (
|
|
143
|
+
<span className={cn(`${RC}__description-title`)}>{label}</span>
|
|
144
|
+
)
|
|
145
|
+
: null}
|
|
146
|
+
{value
|
|
147
|
+
? (
|
|
148
|
+
<div className={cn(`${RC}__description-value`)}>{value}</div>
|
|
149
|
+
)
|
|
150
|
+
: null}
|
|
151
|
+
</div>
|
|
152
|
+
)
|
|
153
|
+
: null}
|
|
154
|
+
{!isExcludeChartTypeSwitcher
|
|
155
|
+
? (
|
|
156
|
+
<div className={cn(`${RC}__type-switcher`)}>
|
|
157
|
+
<ChartTypeSwitcherIcon
|
|
158
|
+
iconType="Bar"
|
|
159
|
+
isActive={getChartTypeKey(model) === 'Bar'}
|
|
160
|
+
onClick={() => setModel(modelsForSwitch?.[0] || 'barLayout')}
|
|
161
|
+
/>
|
|
162
|
+
<ChartTypeSwitcherIcon
|
|
163
|
+
iconType="Line"
|
|
164
|
+
isActive={getChartTypeKey(model) === 'Line'}
|
|
165
|
+
onClick={() => setModel(modelsForSwitch?.[1] || 'lineLayout')}
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
)
|
|
169
|
+
: null}
|
|
170
|
+
</div>
|
|
171
|
+
<div ref={charContainertRef} className={cn(`${RC}__chart-wrapper`)}>
|
|
172
|
+
<ChartComponent {...options} data={localData} />
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export default Chart;
|
|
@@ -1 +1,78 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
|
|
3
|
+
import './ChartTypeSwitcherIcon.scss';
|
|
4
|
+
|
|
5
|
+
const RC = 'chart__type-switcher-icon';
|
|
6
|
+
|
|
7
|
+
function getIcon(type) {
|
|
8
|
+
switch (type) {
|
|
9
|
+
case 'Bar':
|
|
10
|
+
return (
|
|
11
|
+
<svg
|
|
12
|
+
width="24"
|
|
13
|
+
height="24"
|
|
14
|
+
viewBox="0 0 24 25"
|
|
15
|
+
fill="none"
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
>
|
|
18
|
+
<rect y="0.5" width="24" height="24" rx="4" fill="#EAF2FF" />
|
|
19
|
+
<path
|
|
20
|
+
d="M18 18V11"
|
|
21
|
+
stroke="#1F7499"
|
|
22
|
+
strokeWidth="2"
|
|
23
|
+
strokeLinecap="round"
|
|
24
|
+
strokeLinejoin="round"
|
|
25
|
+
/>
|
|
26
|
+
<path
|
|
27
|
+
d="M12 18V6"
|
|
28
|
+
stroke="#1F7499"
|
|
29
|
+
strokeWidth="2"
|
|
30
|
+
strokeLinecap="round"
|
|
31
|
+
strokeLinejoin="round"
|
|
32
|
+
/>
|
|
33
|
+
<path
|
|
34
|
+
d="M6 18V13"
|
|
35
|
+
stroke="#1F7499"
|
|
36
|
+
strokeWidth="2"
|
|
37
|
+
strokeLinecap="round"
|
|
38
|
+
strokeLinejoin="round"
|
|
39
|
+
/>
|
|
40
|
+
</svg>
|
|
41
|
+
);
|
|
42
|
+
case 'Line':
|
|
43
|
+
return (
|
|
44
|
+
<svg
|
|
45
|
+
width="24"
|
|
46
|
+
height="24"
|
|
47
|
+
viewBox="0 0 24 25"
|
|
48
|
+
fill="none"
|
|
49
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
50
|
+
>
|
|
51
|
+
<rect y="0.5" width="24" height="24" rx="4" fill="#EAF2FF" />
|
|
52
|
+
<path
|
|
53
|
+
d="M21 8L15.2544 13.2668C14.1075 14.3181 12.3288 14.3014 11.1818
|
|
54
|
+
13.25V13.25C10.0349 12.1986 8.25615 12.1819 7.10919 13.2332L3 17"
|
|
55
|
+
stroke="#1F7499"
|
|
56
|
+
strokeWidth="2"
|
|
57
|
+
strokeLinecap="round"
|
|
58
|
+
strokeLinejoin="round"
|
|
59
|
+
/>
|
|
60
|
+
</svg>
|
|
61
|
+
);
|
|
62
|
+
default:
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function ChartTypeSwitcherIcon({ iconType, isActive, className, onClick }) {
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
className={cn(RC, { [`${RC}_active`]: isActive }, className)}
|
|
71
|
+
onClick={onClick}
|
|
72
|
+
>
|
|
73
|
+
{getIcon(iconType)}
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default ChartTypeSwitcherIcon;
|