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,223 @@
|
|
|
1
|
-
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
|
|
3
|
+
import { useLayoutEffect, useMemo, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import { formatToPriceWithUSD } from '../../../Functions/fieldValueFormatters';
|
|
6
|
+
import { clone } from '../../../Functions/utils';
|
|
7
|
+
import InputDateRange from '../../FormElements/InputDateRange/InputDateRange';
|
|
8
|
+
import Chart from '../Chart/Chart';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
getLabels,
|
|
12
|
+
getMockValue,
|
|
13
|
+
getSafelyDateRange,
|
|
14
|
+
getTab,
|
|
15
|
+
} from './partial/utils';
|
|
16
|
+
|
|
17
|
+
import './partial/AnyOuterClass.scss';
|
|
18
|
+
|
|
19
|
+
function ExampleChartIntegration(props) {
|
|
20
|
+
const { inputDateRangeProps, chartProps } = props || {};
|
|
21
|
+
const { value: outerDateRange, onChange: changeDateRange }
|
|
22
|
+
= inputDateRangeProps || {};
|
|
23
|
+
const { initialChartType } = chartProps || {};
|
|
24
|
+
const dateRange = useMemo(
|
|
25
|
+
() => getSafelyDateRange(outerDateRange),
|
|
26
|
+
[outerDateRange],
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const [chartType, setChartType] = useState(initialChartType || 'Bar');
|
|
30
|
+
const [tab, setTab] = useState('tab1');
|
|
31
|
+
const [initialModel, setInitialModel] = useState(
|
|
32
|
+
chartType === 'Bar' ? 'finturfLoadingModeBar' : 'finturfLoadingModeLine',
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const [tab1, setTab1] = useState(null);
|
|
36
|
+
const [tab2, setTab2] = useState(null);
|
|
37
|
+
const [tab3, setTab3] = useState(null);
|
|
38
|
+
const [tab4, setTab4] = useState(null);
|
|
39
|
+
|
|
40
|
+
const [dataForRender, setDataForRender] = useState(null);
|
|
41
|
+
|
|
42
|
+
const getMockData = () => {
|
|
43
|
+
const labels = getLabels(dateRange);
|
|
44
|
+
const mock = () => labels.map(label => getMockValue());
|
|
45
|
+
return {
|
|
46
|
+
labels,
|
|
47
|
+
datasets: [
|
|
48
|
+
{
|
|
49
|
+
data: mock(),
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const getTabData = (tabId) => {
|
|
56
|
+
switch (tabId) {
|
|
57
|
+
case 'tab1':
|
|
58
|
+
return !tab1 ? null : clone(tab1);
|
|
59
|
+
case 'tab2':
|
|
60
|
+
return !tab2 ? null : clone(tab2);
|
|
61
|
+
case 'tab3':
|
|
62
|
+
return !tab3 ? null : clone(tab3);
|
|
63
|
+
case 'tab4':
|
|
64
|
+
return !tab4 ? null : clone(tab4);
|
|
65
|
+
default:
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getDescription = (tabId) => {
|
|
71
|
+
switch (tabId) {
|
|
72
|
+
case 'tab1':
|
|
73
|
+
return 'Tab 1';
|
|
74
|
+
case 'tab2':
|
|
75
|
+
return 'Tab 2';
|
|
76
|
+
case 'tab3':
|
|
77
|
+
return 'Tab 3';
|
|
78
|
+
case 'tab4':
|
|
79
|
+
return 'Tab 4';
|
|
80
|
+
default:
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const selectData = () => (getTabData(tab) ? getTabData(tab) : getMockData());
|
|
86
|
+
|
|
87
|
+
const modelsForSwitch = useMemo(
|
|
88
|
+
() =>
|
|
89
|
+
getTabData(tab)
|
|
90
|
+
? ['finturfChartBar', 'finturfChartLine']
|
|
91
|
+
: ['finturfLoadingModeBar', 'finturfLoadingModeLine'],
|
|
92
|
+
[Boolean(getTabData(tab))],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const handleChangeChartType = (model) => {
|
|
96
|
+
setChartType(model.includes('Line') ? 'Line' : 'Bar');
|
|
97
|
+
setInitialModel(model);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const getModel = () => {
|
|
101
|
+
if (!getTabData(tab)) {
|
|
102
|
+
return chartType === 'Bar'
|
|
103
|
+
? 'finturfLoadingModeBar'
|
|
104
|
+
: 'finturfLoadingModeLine';
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return chartType === 'Bar' ? 'finturfChartBar' : 'finturfChartLine';
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const processResponse = (res, tabId) => {
|
|
112
|
+
switch (tabId) {
|
|
113
|
+
case 'tab1':
|
|
114
|
+
setTab1(res);
|
|
115
|
+
break;
|
|
116
|
+
case 'tab2':
|
|
117
|
+
setTab2(res);
|
|
118
|
+
break;
|
|
119
|
+
case 'tab3':
|
|
120
|
+
setTab3(res);
|
|
121
|
+
break;
|
|
122
|
+
case 'tab4':
|
|
123
|
+
setTab4(res);
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
return res;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
useLayoutEffect(() => {
|
|
132
|
+
setTab1(null);
|
|
133
|
+
setTab2(null);
|
|
134
|
+
setTab3(null);
|
|
135
|
+
setTab4(null);
|
|
136
|
+
|
|
137
|
+
// эмуляция запросов
|
|
138
|
+
// вся логика происходит в самих входящих промисах
|
|
139
|
+
// Promise.all добавлен для расширения на случай надобности описания эффектов по завершении всех запросов
|
|
140
|
+
Promise.all([
|
|
141
|
+
getTab('tab1', dateRange, processResponse),
|
|
142
|
+
getTab('tab2', dateRange, processResponse),
|
|
143
|
+
getTab('tab3', dateRange, processResponse),
|
|
144
|
+
getTab('tab4', dateRange, processResponse),
|
|
145
|
+
]);
|
|
146
|
+
}, [dateRange]);
|
|
147
|
+
|
|
148
|
+
useLayoutEffect(() => {
|
|
149
|
+
setInitialModel(getModel());
|
|
150
|
+
setDataForRender(selectData());
|
|
151
|
+
}, [Boolean(getTabData(tab)), tab, chartType]);
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div className="example-wrapper">
|
|
155
|
+
<InputDateRange
|
|
156
|
+
{...inputDateRangeProps}
|
|
157
|
+
value={outerDateRange}
|
|
158
|
+
onChange={changeDateRange}
|
|
159
|
+
/>
|
|
160
|
+
|
|
161
|
+
<div className="buttons-block">
|
|
162
|
+
<button
|
|
163
|
+
className={cn('tab-button', { 'tab-button_active': tab === 'tab1' })}
|
|
164
|
+
onClick={() => setTab('tab1')}
|
|
165
|
+
>
|
|
166
|
+
Tab 1
|
|
167
|
+
</button>
|
|
168
|
+
<button
|
|
169
|
+
className={cn('tab-button', { 'tab-button_active': tab === 'tab2' })}
|
|
170
|
+
onClick={() => setTab('tab2')}
|
|
171
|
+
>
|
|
172
|
+
Tab 2
|
|
173
|
+
</button>
|
|
174
|
+
<button
|
|
175
|
+
className={cn('tab-button', { 'tab-button_active': tab === 'tab3' })}
|
|
176
|
+
onClick={() => setTab('tab3')}
|
|
177
|
+
>
|
|
178
|
+
Tab 3
|
|
179
|
+
</button>
|
|
180
|
+
<button
|
|
181
|
+
className={cn('tab-button', { 'tab-button_active': tab === 'tab4' })}
|
|
182
|
+
onClick={() => setTab('tab4')}
|
|
183
|
+
>
|
|
184
|
+
Tab 4
|
|
185
|
+
</button>
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
<Chart
|
|
189
|
+
{...chartProps}
|
|
190
|
+
key={JSON.stringify(dataForRender)}
|
|
191
|
+
data={dataForRender}
|
|
192
|
+
setModelExternalValue={handleChangeChartType}
|
|
193
|
+
initialModel={initialModel}
|
|
194
|
+
modelsForSwitch={modelsForSwitch}
|
|
195
|
+
description={{ label: getDescription(tab) }}
|
|
196
|
+
addToDatasets={{ id: tab }}
|
|
197
|
+
modifyOptions={options => ({
|
|
198
|
+
...options,
|
|
199
|
+
options: {
|
|
200
|
+
...options?.options,
|
|
201
|
+
plugins: {
|
|
202
|
+
...options?.options?.plugins,
|
|
203
|
+
tooltip: {
|
|
204
|
+
...options?.options?.plugins?.tooltip,
|
|
205
|
+
callbacks: {
|
|
206
|
+
...options?.options?.plugins?.tooltip?.callbacks,
|
|
207
|
+
label: (context) => {
|
|
208
|
+
return context.dataset.id === 'tab3'
|
|
209
|
+
|| context.dataset.id === 'tab4'
|
|
210
|
+
? formatToPriceWithUSD(context.raw || '0')
|
|
211
|
+
: context.raw || '0';
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
})}
|
|
218
|
+
/>
|
|
219
|
+
</div>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export default ExampleChartIntegration;
|
|
@@ -1 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
|
|
3
|
+
import MonoAccordion from './MonoAccordion';
|
|
4
|
+
|
|
5
|
+
describe('monoAccordion', () => {
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
titleJSX: <div>Accordion Title</div>,
|
|
8
|
+
icon: <span>▼</span>,
|
|
9
|
+
isOpen: false,
|
|
10
|
+
onClick: jest.fn(),
|
|
11
|
+
testId: 'test-accordion',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
it('renders correctly with default props', () => {
|
|
15
|
+
render(
|
|
16
|
+
<MonoAccordion {...defaultProps}>
|
|
17
|
+
<div>Accordion Content</div>
|
|
18
|
+
</MonoAccordion>,
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
expect(screen.getByTestId('test-accordion')).toBeInTheDocument();
|
|
22
|
+
expect(screen.getByText('Accordion Title')).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('handles click events correctly', () => {
|
|
26
|
+
render(
|
|
27
|
+
<MonoAccordion {...defaultProps}>
|
|
28
|
+
<div>Accordion Content</div>
|
|
29
|
+
</MonoAccordion>,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
fireEvent.click(screen.getByRole('button'));
|
|
33
|
+
expect(defaultProps.onClick).toHaveBeenCalled();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('applies correct classes when open', () => {
|
|
37
|
+
render(
|
|
38
|
+
<MonoAccordion {...defaultProps} isOpen={true}>
|
|
39
|
+
<div>Accordion Content</div>
|
|
40
|
+
</MonoAccordion>,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
expect(screen.getByTestId('test-accordion')).toHaveClass('mono-accordion--is-open');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('applies disabled state correctly', () => {
|
|
47
|
+
render(
|
|
48
|
+
<MonoAccordion {...defaultProps} disabled={true}>
|
|
49
|
+
<div>Accordion Content</div>
|
|
50
|
+
</MonoAccordion>,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const button = screen.getByRole('button');
|
|
54
|
+
expect(button).toBeDisabled();
|
|
55
|
+
expect(screen.getByTestId('test-accordion')).toHaveClass('mono-accordion--disabled');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('handles aria attributes correctly', () => {
|
|
59
|
+
const { rerender } = render(
|
|
60
|
+
<MonoAccordion {...defaultProps}>
|
|
61
|
+
<div>Accordion Content</div>
|
|
62
|
+
</MonoAccordion>,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'false');
|
|
66
|
+
|
|
67
|
+
rerender(
|
|
68
|
+
<MonoAccordion {...defaultProps} isOpen={true}>
|
|
69
|
+
<div>Accordion Content</div>
|
|
70
|
+
</MonoAccordion>,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'true');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -1 +1,86 @@
|
|
|
1
|
-
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import './MonoAccordion.scss';
|
|
6
|
+
|
|
7
|
+
const RC = 'mono-accordion';
|
|
8
|
+
|
|
9
|
+
function MonoAccordion({
|
|
10
|
+
titleJSX,
|
|
11
|
+
icon,
|
|
12
|
+
children,
|
|
13
|
+
isOpen,
|
|
14
|
+
onClick,
|
|
15
|
+
className,
|
|
16
|
+
disabled,
|
|
17
|
+
testId = 'mono-accordion',
|
|
18
|
+
datasetProp = {},
|
|
19
|
+
}) {
|
|
20
|
+
const [maxHeight, setMaxHeight] = useState();
|
|
21
|
+
const titleRef = useRef();
|
|
22
|
+
const containerRef = useRef();
|
|
23
|
+
|
|
24
|
+
const setHeight = (value) => {
|
|
25
|
+
if (value !== undefined) {
|
|
26
|
+
setMaxHeight(state => `${value}px`);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
setMaxHeight(
|
|
30
|
+
state =>
|
|
31
|
+
`${Array.from(containerRef.current?.childNodes)?.reduce?.((acc, el) => acc + el.offsetHeight, 0)}px`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const handleClick = (e) => {
|
|
37
|
+
if (
|
|
38
|
+
!Array.from(titleRef.current.childNodes).some(el =>
|
|
39
|
+
el.contains(e.target),
|
|
40
|
+
)
|
|
41
|
+
) {
|
|
42
|
+
onClick(e);
|
|
43
|
+
e?.preventDefault();
|
|
44
|
+
e?.stopPropagation();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return e;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!isOpen) setHeight(0);
|
|
53
|
+
else setHeight();
|
|
54
|
+
}, [isOpen, children]);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
{...datasetProp}
|
|
59
|
+
data-testid={testId}
|
|
60
|
+
className={cn(RC, className, {
|
|
61
|
+
[`${RC}_is-open`]: isOpen,
|
|
62
|
+
[`${RC}_disabled`]: disabled,
|
|
63
|
+
})}
|
|
64
|
+
>
|
|
65
|
+
<div
|
|
66
|
+
className={`${RC}__head`}
|
|
67
|
+
onClick={handleClick}
|
|
68
|
+
>
|
|
69
|
+
<div ref={titleRef} className={`${RC}__tile-container`}>
|
|
70
|
+
{titleJSX}
|
|
71
|
+
</div>
|
|
72
|
+
<span className={`${RC}__icon-container`}>{icon}</span>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<div
|
|
76
|
+
ref={containerRef}
|
|
77
|
+
style={{ maxHeight }}
|
|
78
|
+
className={cn(`${RC}__container`)}
|
|
79
|
+
>
|
|
80
|
+
<div className={`${RC}__content-wrapper`}>{children}</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default MonoAccordion;
|
|
@@ -1 +1,41 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { ArcElement, Chart as ChartJS, Tooltip } from 'chart.js';
|
|
2
|
+
import { Pie } from 'react-chartjs-2';
|
|
3
|
+
|
|
4
|
+
import './PieChart.scss';
|
|
5
|
+
|
|
6
|
+
ChartJS.register(ArcElement, Tooltip);
|
|
7
|
+
|
|
8
|
+
function PieChart({
|
|
9
|
+
data,
|
|
10
|
+
cutout = '80%',
|
|
11
|
+
resultLabel,
|
|
12
|
+
resultValue = 0,
|
|
13
|
+
withLegend = false,
|
|
14
|
+
}) {
|
|
15
|
+
const options = {
|
|
16
|
+
cutout,
|
|
17
|
+
plugins: {
|
|
18
|
+
legend: {
|
|
19
|
+
display: withLegend,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="pie-chart-box" style={{ maxWidth: `320px` }}>
|
|
26
|
+
<Pie data={data} options={options} />
|
|
27
|
+
{Boolean(resultLabel) && (
|
|
28
|
+
<div className="pie-chart__result">
|
|
29
|
+
<div className="pie-chart__result-value">
|
|
30
|
+
{resultValue}
|
|
31
|
+
<span className="pie-chart__result-percent">%</span>
|
|
32
|
+
{' '}
|
|
33
|
+
</div>
|
|
34
|
+
<div className="pie-chart__result-label">{resultLabel}</div>
|
|
35
|
+
</div>
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default PieChart;
|
|
@@ -1 +1,87 @@
|
|
|
1
|
-
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import AccordionItem from '../../Accordion/AccordionItem';
|
|
4
|
+
import AdvancedTags from '../../AdvancedTag/AdvancedTags';
|
|
5
|
+
import Status from '../../Status/Status';
|
|
6
|
+
import Tag from '../../Tag/Tag';
|
|
7
|
+
import Table from '../Table';
|
|
8
|
+
import { TdActions } from '../TdTypes/TdActions';
|
|
9
|
+
import TdPriority from '../TdTypes/TdPriority';
|
|
10
|
+
import TdWeight from '../TdTypes/TdWeight';
|
|
11
|
+
|
|
12
|
+
import '../Table.scss';
|
|
13
|
+
|
|
14
|
+
function TdCell({
|
|
15
|
+
type,
|
|
16
|
+
item,
|
|
17
|
+
rowIndex,
|
|
18
|
+
onChange,
|
|
19
|
+
cardLength,
|
|
20
|
+
changePriority,
|
|
21
|
+
getAdviceWeight,
|
|
22
|
+
onActionClick,
|
|
23
|
+
rowItem,
|
|
24
|
+
isDeleted,
|
|
25
|
+
}) {
|
|
26
|
+
const [isAccordionOpen, setIsAccordionOpen] = useState(item.isOpen);
|
|
27
|
+
|
|
28
|
+
const percent
|
|
29
|
+
= item.type === 'weight' && getAdviceWeight(isDeleted ? 0 : item.value);
|
|
30
|
+
|
|
31
|
+
switch (type) {
|
|
32
|
+
case 'accordion':
|
|
33
|
+
return (
|
|
34
|
+
<AccordionItem
|
|
35
|
+
className={item.itemClassName}
|
|
36
|
+
item={item}
|
|
37
|
+
isOpen={isAccordionOpen}
|
|
38
|
+
onClick={e => setIsAccordionOpen(e)}
|
|
39
|
+
>
|
|
40
|
+
<Table rows={item.rows} className="accordion--table" />
|
|
41
|
+
</AccordionItem>
|
|
42
|
+
);
|
|
43
|
+
case 'actions':
|
|
44
|
+
return (
|
|
45
|
+
<TdActions
|
|
46
|
+
rowItem={rowItem}
|
|
47
|
+
actions={item}
|
|
48
|
+
onChange={onChange}
|
|
49
|
+
onActionClick={onActionClick}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
case 'advancedTags':
|
|
53
|
+
return <AdvancedTags items={item} />;
|
|
54
|
+
case 'link':
|
|
55
|
+
return <a href={item.link}>{item.label}</a>;
|
|
56
|
+
case 'priority':
|
|
57
|
+
return (
|
|
58
|
+
<TdPriority
|
|
59
|
+
rowIndex={rowIndex}
|
|
60
|
+
cardLength={cardLength}
|
|
61
|
+
onClick={changePriority}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
case 'status':
|
|
65
|
+
return (
|
|
66
|
+
<Status
|
|
67
|
+
className={item.className}
|
|
68
|
+
label={item.label}
|
|
69
|
+
status={item.status}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
case 'tags':
|
|
73
|
+
return item.map((tag, index) => <Tag key={index} label={tag.label} />);
|
|
74
|
+
case 'weight':
|
|
75
|
+
return (
|
|
76
|
+
<TdWeight
|
|
77
|
+
value={item.value}
|
|
78
|
+
percent={percent}
|
|
79
|
+
onChange={value => onChange({ ...item, value })}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
default:
|
|
83
|
+
return <span className={item.className}>{item.value}</span>;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default TdCell;
|
|
@@ -1 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
|
|
3
|
+
import Langs from '../../../../Langs';
|
|
4
|
+
|
|
5
|
+
import '../Table.scss';
|
|
6
|
+
|
|
7
|
+
function TdHeader({ item, testId = 'td-header' }) {
|
|
8
|
+
const txt = Langs[globalThis.lng];
|
|
9
|
+
|
|
10
|
+
switch (item.type) {
|
|
11
|
+
case 'double':
|
|
12
|
+
return (
|
|
13
|
+
<th data-testid={testId}>
|
|
14
|
+
<div className="j46">
|
|
15
|
+
<div className="">{txt.labels[item.left] || item.left}</div>
|
|
16
|
+
<div className="">{txt.labels[item.right] || item.right}</div>
|
|
17
|
+
</div>
|
|
18
|
+
</th>
|
|
19
|
+
);
|
|
20
|
+
default:
|
|
21
|
+
return (
|
|
22
|
+
<th data-testid={testId} className={cn(item.className)}>
|
|
23
|
+
<div className={cn({ df: item.button })}>
|
|
24
|
+
<div className="mr5">{txt.labels[item.label] || item.label}</div>
|
|
25
|
+
{item.button && (
|
|
26
|
+
<div className="cards-table__btn">
|
|
27
|
+
{txt.buttons[item.button] || item.button}
|
|
28
|
+
</div>
|
|
29
|
+
)}
|
|
30
|
+
</div>
|
|
31
|
+
</th>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default TdHeader;
|