@axinom/mosaic-ui 0.32.0-rc.12 → 0.32.0-rc.14
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/components/Accordion/AccordionItem/AccordionItem.d.ts +2 -0
- package/dist/components/Accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/dist/components/Filters/Filter/Filter.d.ts.map +1 -1
- package/dist/components/Filters/Filters.model.d.ts +7 -2
- package/dist/components/Filters/Filters.model.d.ts.map +1 -1
- package/dist/components/Filters/SelectionTypes/MultiOptionFilter/MultiOptionFilter.d.ts +13 -0
- package/dist/components/Filters/SelectionTypes/MultiOptionFilter/MultiOptionFilter.d.ts.map +1 -0
- package/dist/components/InfoPanel/Section/Section.d.ts +3 -1
- package/dist/components/InfoPanel/Section/Section.d.ts.map +1 -1
- package/dist/index.es.js +3 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Accordion/AccordionItem/AccordionItem.spec.tsx +11 -0
- package/src/components/Accordion/AccordionItem/AccordionItem.tsx +5 -1
- package/src/components/Filters/Filter/Filter.tsx +24 -0
- package/src/components/Filters/Filters.model.ts +7 -1
- package/src/components/Filters/Filters.stories.tsx +20 -0
- package/src/components/Filters/SelectionTypes/MultiOptionFilter/MultiOptionFilter.scss +40 -0
- package/src/components/Filters/SelectionTypes/MultiOptionFilter/MultiOptionFilter.tsx +71 -0
- package/src/components/InfoPanel/Paragraph/Paragraph.scss +1 -1
- package/src/components/InfoPanel/Section/Section.scss +34 -2
- package/src/components/InfoPanel/Section/Section.spec.tsx +117 -0
- package/src/components/InfoPanel/Section/Section.tsx +32 -9
- package/src/styles/variables.scss +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-ui",
|
|
3
|
-
"version": "0.32.0-rc.
|
|
3
|
+
"version": "0.32.0-rc.14",
|
|
4
4
|
"description": "UI components for building Axinom Mosaic applications",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "339cc30335b00fb5323a413139f34f770a6c86ce"
|
|
106
106
|
}
|
|
@@ -105,4 +105,15 @@ describe('AccordionItem', () => {
|
|
|
105
105
|
|
|
106
106
|
expect(containerStyles).toEqual({ maxHeight: 100 });
|
|
107
107
|
});
|
|
108
|
+
|
|
109
|
+
it('creates a class based off of the className prop', () => {
|
|
110
|
+
const mockClassName = 'test-class';
|
|
111
|
+
const wrapper = shallow(
|
|
112
|
+
<AccordionItem header={<b>Item 1</b>} className={mockClassName} />,
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const item = wrapper.find('.test-class');
|
|
116
|
+
|
|
117
|
+
expect(item.hasClass(mockClassName)).toBe(true);
|
|
118
|
+
});
|
|
108
119
|
});
|
|
@@ -18,6 +18,9 @@ export interface AccordionItemProps {
|
|
|
18
18
|
|
|
19
19
|
/** Sticky state of the current row. When used within the Accordion component, this prop will be overridden with the value from stickyRows. */
|
|
20
20
|
sticky?: boolean;
|
|
21
|
+
|
|
22
|
+
/** CSS Class name for additional styles */
|
|
23
|
+
className?: string;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
/**
|
|
@@ -34,6 +37,7 @@ export const AccordionItem: React.FC<AccordionItemProps> = ({
|
|
|
34
37
|
isExpanded = false,
|
|
35
38
|
allowLeftSpacing = true,
|
|
36
39
|
sticky = false,
|
|
40
|
+
className,
|
|
37
41
|
}) => {
|
|
38
42
|
const [scrollHeight, setScrollHeight] = useState<number>(0);
|
|
39
43
|
const elementRef = useRef<HTMLDivElement>(null);
|
|
@@ -45,7 +49,7 @@ export const AccordionItem: React.FC<AccordionItemProps> = ({
|
|
|
45
49
|
}, [scrollHeight, children]);
|
|
46
50
|
|
|
47
51
|
return (
|
|
48
|
-
<div data-test-id="accordion-item">
|
|
52
|
+
<div data-test-id="accordion-item" className={className}>
|
|
49
53
|
<div
|
|
50
54
|
data-test-id="accordion-item-row"
|
|
51
55
|
className={clsx(
|
|
@@ -14,6 +14,7 @@ import { formatDate, formatDateTime } from '../../Utils/Transformers/DateTime';
|
|
|
14
14
|
import { FilterType, FilterTypes, FilterValue } from '../Filters.model';
|
|
15
15
|
import { DateTimeFilter } from '../SelectionTypes/DateTimeFilter/DateTimeFilter';
|
|
16
16
|
import { FreeTextFilter } from '../SelectionTypes/FreeTextFilter/FreeTextFilter';
|
|
17
|
+
import { MultiOptionsFilter } from '../SelectionTypes/MultiOptionFilter/MultiOptionFilter';
|
|
17
18
|
import { NumericTextFilter } from '../SelectionTypes/NumericTextFilter/NumericTextFilter';
|
|
18
19
|
import { OptionsFilter } from '../SelectionTypes/OptionsFilter/OptionsFilter';
|
|
19
20
|
import { SearcheableOptionsFilter } from '../SelectionTypes/SearcheableOptionsFilter/SearcheableOptionsFilter';
|
|
@@ -78,6 +79,19 @@ export const Filter = <T extends Data>({
|
|
|
78
79
|
return formatDateTime(String(value));
|
|
79
80
|
case FilterTypes.Options:
|
|
80
81
|
return options.options.find((option) => option.value === value)?.label;
|
|
82
|
+
case FilterTypes.MultipleOptions: {
|
|
83
|
+
const selectedVal: string[] = [];
|
|
84
|
+
String(value)
|
|
85
|
+
.split(',')
|
|
86
|
+
.map((item: string) =>
|
|
87
|
+
selectedVal.push(
|
|
88
|
+
options?.options.find(
|
|
89
|
+
(option) => option.value.toString() === item,
|
|
90
|
+
)?.label ?? '',
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
return selectedVal.join(', ');
|
|
94
|
+
}
|
|
81
95
|
case FilterTypes.SearcheableOptions:
|
|
82
96
|
return stringValue;
|
|
83
97
|
default:
|
|
@@ -122,6 +136,16 @@ export const Filter = <T extends Data>({
|
|
|
122
136
|
/>
|
|
123
137
|
);
|
|
124
138
|
|
|
139
|
+
case FilterTypes.MultipleOptions:
|
|
140
|
+
return (
|
|
141
|
+
<MultiOptionsFilter
|
|
142
|
+
value={value as string}
|
|
143
|
+
options={options.options}
|
|
144
|
+
onSelect={(value: FilterValue) =>
|
|
145
|
+
onFilterValueChange(options.property, value?.toString())
|
|
146
|
+
}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
125
149
|
case FilterTypes.SearcheableOptions:
|
|
126
150
|
return (
|
|
127
151
|
<SearcheableOptionsFilter
|
|
@@ -8,6 +8,7 @@ export enum FilterTypes {
|
|
|
8
8
|
Date,
|
|
9
9
|
DateTime,
|
|
10
10
|
Custom,
|
|
11
|
+
MultipleOptions,
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export interface FilterConfig<T extends Data> {
|
|
@@ -36,6 +37,10 @@ export interface OptionsFilter<T extends Data> extends FilterConfig<T> {
|
|
|
36
37
|
options: Option[];
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
export interface MultipleOptions<T extends Data> extends FilterConfig<T> {
|
|
41
|
+
type: FilterTypes.MultipleOptions;
|
|
42
|
+
options: Option[];
|
|
43
|
+
}
|
|
39
44
|
export interface SearcheableOptionsFilter<T extends Data>
|
|
40
45
|
extends FilterConfig<T> {
|
|
41
46
|
type: FilterTypes.SearcheableOptions;
|
|
@@ -87,7 +92,8 @@ export type FilterType<T extends Data> =
|
|
|
87
92
|
| SearcheableOptionsFilter<T>
|
|
88
93
|
| DateFilter<T>
|
|
89
94
|
| DateTimeFilter<T>
|
|
90
|
-
| CustomFilter<T
|
|
95
|
+
| CustomFilter<T>
|
|
96
|
+
| MultipleOptions<T>;
|
|
91
97
|
|
|
92
98
|
export type FilterValues<T> = {
|
|
93
99
|
[K in keyof T]?: FilterValue;
|
|
@@ -43,6 +43,7 @@ interface FilterStoryData {
|
|
|
43
43
|
datetime: Date;
|
|
44
44
|
id: number;
|
|
45
45
|
holderType: string;
|
|
46
|
+
roleTypes: string;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
const options: Option[] = generateItemArray(10, (index) => ({
|
|
@@ -55,6 +56,11 @@ const searcheableOptions: Option[] = generateItemArray(10, (index) => ({
|
|
|
55
56
|
value: index,
|
|
56
57
|
}));
|
|
57
58
|
|
|
59
|
+
const multipleOptions: Option[] = generateItemArray(10, (index) => ({
|
|
60
|
+
label: faker.lorem.words(),
|
|
61
|
+
value: index,
|
|
62
|
+
}));
|
|
63
|
+
|
|
58
64
|
const textFilter: FilterType<FilterStoryData> = {
|
|
59
65
|
label: 'Title',
|
|
60
66
|
property: 'title',
|
|
@@ -76,6 +82,13 @@ const searcheableOptionFilter: FilterType<FilterStoryData> = {
|
|
|
76
82
|
searcheableOptions.filter((option) => option.label.includes(searchText)),
|
|
77
83
|
};
|
|
78
84
|
|
|
85
|
+
const multipleOptionFilter: FilterType<FilterStoryData> = {
|
|
86
|
+
label: 'Role Types',
|
|
87
|
+
property: 'roleTypes',
|
|
88
|
+
type: FilterTypes.MultipleOptions,
|
|
89
|
+
options: multipleOptions,
|
|
90
|
+
};
|
|
91
|
+
|
|
79
92
|
const numberFilter: FilterType<FilterStoryData> = {
|
|
80
93
|
label: 'ID',
|
|
81
94
|
property: 'id',
|
|
@@ -167,6 +180,12 @@ export const searchableOptionsFilter: StoryObj<typeof Filters> = {
|
|
|
167
180
|
},
|
|
168
181
|
};
|
|
169
182
|
|
|
183
|
+
export const multiOptionFilter: StoryObj<typeof Filters> = {
|
|
184
|
+
args: {
|
|
185
|
+
options: [multipleOptionFilter],
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
|
|
170
189
|
export const DateFilter: StoryObj<typeof Filters> = {
|
|
171
190
|
args: {
|
|
172
191
|
options: [dateFilter, dateTimeFilter],
|
|
@@ -196,6 +215,7 @@ export const MultipleFilters: StoryObj<typeof Filters> = {
|
|
|
196
215
|
dateTimeFilter,
|
|
197
216
|
customFilter,
|
|
198
217
|
searcheableOptionFilter,
|
|
218
|
+
multipleOptionFilter,
|
|
199
219
|
]}
|
|
200
220
|
defaultValues={filters}
|
|
201
221
|
onFiltersChange={(filters) => {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import '../../../../styles/common.scss';
|
|
2
|
+
|
|
3
|
+
.multiFilterContainer {
|
|
4
|
+
padding: 0;
|
|
5
|
+
.Checkbox {
|
|
6
|
+
padding-left: 20px;
|
|
7
|
+
padding-right: 20px;
|
|
8
|
+
grid-template-columns: auto 30px;
|
|
9
|
+
label {
|
|
10
|
+
color: var(--multi-option-label-colorr, $multi-option-label-color);
|
|
11
|
+
font-weight: normal;
|
|
12
|
+
}
|
|
13
|
+
input {
|
|
14
|
+
border-color: var(
|
|
15
|
+
--multi-option-checbox-border,
|
|
16
|
+
$multi-option-checbox-border
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
&:hover {
|
|
20
|
+
background-color: var(
|
|
21
|
+
--filter-background-selected-color,
|
|
22
|
+
$filter-background-selected-color
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
&.selected {
|
|
26
|
+
background-color: var(
|
|
27
|
+
--filter-background-selected-color,
|
|
28
|
+
$filter-background-selected-color
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.applyButtonContainer {
|
|
35
|
+
display: grid;
|
|
36
|
+
|
|
37
|
+
.applyButton {
|
|
38
|
+
height: 50px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { ButtonContext } from '../../../Buttons';
|
|
4
|
+
import { TextButton } from '../../../Buttons/TextButton/TextButton';
|
|
5
|
+
import { Checkbox } from '../../../FormElements';
|
|
6
|
+
import { Option } from '../../Filters.model';
|
|
7
|
+
import classes from './MultiOptionFilter.scss';
|
|
8
|
+
|
|
9
|
+
export interface MultiOptionFilterProps {
|
|
10
|
+
value?: string;
|
|
11
|
+
|
|
12
|
+
/** Array of Options to be displayed */
|
|
13
|
+
options: Option[];
|
|
14
|
+
|
|
15
|
+
/** Callback triggered when a new filter value is selected */
|
|
16
|
+
onSelect: (text: string[]) => void;
|
|
17
|
+
|
|
18
|
+
/** CSS Class name for additional styles */
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const MultiOptionsFilter: React.FC<MultiOptionFilterProps> = ({
|
|
23
|
+
value,
|
|
24
|
+
options,
|
|
25
|
+
onSelect,
|
|
26
|
+
}) => {
|
|
27
|
+
const [selectedOptionList, setSelectedOptionList] = useState<string[]>(
|
|
28
|
+
value ? value.split(',') : [],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className={clsx(classes.multiFilterContainer)}>
|
|
33
|
+
{options?.map((option: Option) => (
|
|
34
|
+
<Checkbox
|
|
35
|
+
className={clsx(
|
|
36
|
+
classes.Checkbox,
|
|
37
|
+
selectedOptionList.includes(option.value.toString()) &&
|
|
38
|
+
classes.selected,
|
|
39
|
+
)}
|
|
40
|
+
key={option.value}
|
|
41
|
+
name={option.label}
|
|
42
|
+
value={selectedOptionList.includes(option.value.toString())}
|
|
43
|
+
label={option.label}
|
|
44
|
+
onChange={(value) => {
|
|
45
|
+
if (value) {
|
|
46
|
+
setSelectedOptionList([
|
|
47
|
+
...selectedOptionList,
|
|
48
|
+
option.value.toString(),
|
|
49
|
+
]);
|
|
50
|
+
} else {
|
|
51
|
+
setSelectedOptionList(
|
|
52
|
+
[...selectedOptionList].filter(
|
|
53
|
+
(i) => i !== option.value.toString(),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
))}
|
|
60
|
+
<div className={clsx(classes.applyButtonContainer)}>
|
|
61
|
+
<TextButton
|
|
62
|
+
className={clsx(classes.applyButton)}
|
|
63
|
+
text="Apply"
|
|
64
|
+
buttonContext={ButtonContext.Active}
|
|
65
|
+
onButtonClicked={() => onSelect(selectedOptionList)}
|
|
66
|
+
disabled={selectedOptionList.length === 0}
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
@@ -7,12 +7,19 @@
|
|
|
7
7
|
grid-template-columns: 1fr;
|
|
8
8
|
|
|
9
9
|
&.hasTitle {
|
|
10
|
-
grid-template-rows: max-content
|
|
10
|
+
grid-template-rows: max-content;
|
|
11
|
+
|
|
12
|
+
padding-top: 6px;
|
|
13
|
+
padding-bottom: 6px;
|
|
14
|
+
|
|
15
|
+
&.expanded {
|
|
16
|
+
grid-template-rows: max-content max-content;
|
|
17
|
+
}
|
|
11
18
|
}
|
|
12
19
|
|
|
13
20
|
padding: 30px;
|
|
14
21
|
|
|
15
|
-
row-gap:
|
|
22
|
+
row-gap: 20px;
|
|
16
23
|
|
|
17
24
|
.title,
|
|
18
25
|
.main {
|
|
@@ -37,4 +44,29 @@
|
|
|
37
44
|
--infopanel-background-color,
|
|
38
45
|
$infopanel-background-color
|
|
39
46
|
);
|
|
47
|
+
|
|
48
|
+
.collapsibleSection {
|
|
49
|
+
& > div:first-child {
|
|
50
|
+
background-color: unset;
|
|
51
|
+
|
|
52
|
+
div:last-child {
|
|
53
|
+
margin-left: -18px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
svg {
|
|
57
|
+
margin-left: -34px;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
& > div:last-child {
|
|
62
|
+
border-bottom: unset;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
& > div > div:last-child {
|
|
66
|
+
background-color: var(
|
|
67
|
+
--infopanel-background-color,
|
|
68
|
+
$infopanel-background-color
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
40
72
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { shallow } from 'enzyme';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { AccordionItem } from '../../Accordion';
|
|
3
4
|
import { Section } from './Section';
|
|
4
5
|
|
|
5
6
|
describe('Section Tests', () => {
|
|
@@ -8,4 +9,120 @@ describe('Section Tests', () => {
|
|
|
8
9
|
|
|
9
10
|
expect(wrapper).toBeTruthy();
|
|
10
11
|
});
|
|
12
|
+
|
|
13
|
+
it('should not render anything if section has no children', () => {
|
|
14
|
+
const wrapper = shallow(<Section></Section>);
|
|
15
|
+
|
|
16
|
+
const section = wrapper.find('.container');
|
|
17
|
+
|
|
18
|
+
expect(section.exists()).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('creates a class based off of the className prop', () => {
|
|
22
|
+
const mockClassName = 'test-class';
|
|
23
|
+
const wrapper = shallow(
|
|
24
|
+
<Section className={mockClassName}>
|
|
25
|
+
<p>test</p>
|
|
26
|
+
</Section>,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const item = wrapper.find('.test-class');
|
|
30
|
+
|
|
31
|
+
expect(item.hasClass(mockClassName)).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('accepts styles', () => {
|
|
35
|
+
const mockStyles: React.CSSProperties = { backgroundColor: 'blue' };
|
|
36
|
+
const wrapper = shallow(
|
|
37
|
+
<Section style={mockStyles}>
|
|
38
|
+
<p>test</p>
|
|
39
|
+
</Section>,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const section = wrapper.find('.container');
|
|
43
|
+
|
|
44
|
+
expect(section.prop('style')).toBe(mockStyles);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it(`should not be toggleable if no 'title' is given`, () => {
|
|
48
|
+
const wrapper = shallow(
|
|
49
|
+
<Section>
|
|
50
|
+
<p>test</p>
|
|
51
|
+
</Section>,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const item = wrapper.find(AccordionItem);
|
|
55
|
+
|
|
56
|
+
expect(item.exists()).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it(`should be toggleable if a 'title' is given`, () => {
|
|
60
|
+
const wrapper = shallow(
|
|
61
|
+
<Section title="test">
|
|
62
|
+
<p>test</p>
|
|
63
|
+
</Section>,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const item = wrapper.find(AccordionItem);
|
|
67
|
+
|
|
68
|
+
expect(item.exists()).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('section should be expanded by default', () => {
|
|
72
|
+
const wrapper = shallow(
|
|
73
|
+
<Section>
|
|
74
|
+
<p>test</p>
|
|
75
|
+
</Section>,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const section = wrapper.find('.container');
|
|
79
|
+
|
|
80
|
+
expect(section.hasClass('expanded')).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it(`section is collasped if 'expandedByDefault' is set to false`, () => {
|
|
84
|
+
const wrapper = shallow(
|
|
85
|
+
<Section expandedByDefault={false}>
|
|
86
|
+
<p>test</p>
|
|
87
|
+
</Section>,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const section = wrapper.find('.container');
|
|
91
|
+
|
|
92
|
+
expect(section.hasClass('expanded')).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('section can be toggled when the title is clicked', () => {
|
|
96
|
+
const wrapper = shallow(
|
|
97
|
+
<Section title="test">
|
|
98
|
+
<p>test</p>
|
|
99
|
+
</Section>,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
let section = wrapper.find('.container').first();
|
|
103
|
+
let item = wrapper.find(AccordionItem);
|
|
104
|
+
|
|
105
|
+
expect(section.hasClass('expanded')).toBe(true);
|
|
106
|
+
expect(item.prop('isExpanded')).toBe(true);
|
|
107
|
+
|
|
108
|
+
item = wrapper.find(AccordionItem);
|
|
109
|
+
item.prop('toggleExpanded')!();
|
|
110
|
+
wrapper.update();
|
|
111
|
+
|
|
112
|
+
section = wrapper.find('.container').first();
|
|
113
|
+
item = wrapper.find(AccordionItem);
|
|
114
|
+
|
|
115
|
+
expect(section.hasClass('expanded')).toBe(false);
|
|
116
|
+
expect(item.prop('isExpanded')).toBe(false);
|
|
117
|
+
|
|
118
|
+
item = wrapper.find(AccordionItem);
|
|
119
|
+
item.prop('toggleExpanded')!();
|
|
120
|
+
wrapper.update();
|
|
121
|
+
|
|
122
|
+
section = wrapper.find('.container').first();
|
|
123
|
+
item = wrapper.find(AccordionItem);
|
|
124
|
+
|
|
125
|
+
expect(section.hasClass('expanded')).toBe(true);
|
|
126
|
+
expect(item.prop('isExpanded')).toBe(true);
|
|
127
|
+
});
|
|
11
128
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { AccordionItem } from '../../Accordion';
|
|
3
4
|
import { Paragraph } from '../Paragraph/Paragraph';
|
|
4
5
|
import classes from './Section.scss';
|
|
5
6
|
|
|
6
7
|
export interface SectionProps {
|
|
7
|
-
/** Section Title */
|
|
8
|
+
/** Section Title. If set, will allow the section to be expandable/collapsible */
|
|
8
9
|
title?: string;
|
|
9
10
|
|
|
10
11
|
/** Optional class */
|
|
@@ -12,6 +13,9 @@ export interface SectionProps {
|
|
|
12
13
|
|
|
13
14
|
/** Optional styles */
|
|
14
15
|
style?: React.CSSProperties;
|
|
16
|
+
|
|
17
|
+
/** Whether the section should be expanded or collapsed intially (default: true)*/
|
|
18
|
+
expandedByDefault?: boolean;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export const Section: React.FC<SectionProps> = ({
|
|
@@ -19,7 +23,9 @@ export const Section: React.FC<SectionProps> = ({
|
|
|
19
23
|
title,
|
|
20
24
|
style,
|
|
21
25
|
children,
|
|
26
|
+
expandedByDefault = true,
|
|
22
27
|
}) => {
|
|
28
|
+
const [expanded, setExpanded] = useState<boolean>(expandedByDefault);
|
|
23
29
|
const validChildren: React.ReactNode[] = [];
|
|
24
30
|
|
|
25
31
|
// Special case for removing paragraph components if they are empty
|
|
@@ -42,21 +48,38 @@ export const Section: React.FC<SectionProps> = ({
|
|
|
42
48
|
<div
|
|
43
49
|
className={clsx(
|
|
44
50
|
classes.container,
|
|
45
|
-
{ [classes.hasTitle]: title },
|
|
51
|
+
{ [classes.hasTitle]: title, [classes.expanded]: expanded },
|
|
46
52
|
'info-panel-section-container',
|
|
47
53
|
className,
|
|
48
54
|
)}
|
|
49
55
|
style={style}
|
|
50
56
|
data-test-id="section"
|
|
51
57
|
>
|
|
52
|
-
{title
|
|
53
|
-
<
|
|
54
|
-
{
|
|
58
|
+
{title ? (
|
|
59
|
+
<AccordionItem
|
|
60
|
+
header={
|
|
61
|
+
title ? (
|
|
62
|
+
<div className={classes.title} data-test-id="section-title">
|
|
63
|
+
{title}
|
|
64
|
+
</div>
|
|
65
|
+
) : (
|
|
66
|
+
<div className={classes.title} data-test-id="section-title"></div>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
allowLeftSpacing={false}
|
|
70
|
+
isExpanded={expanded}
|
|
71
|
+
toggleExpanded={() => setExpanded((prev) => !prev)}
|
|
72
|
+
className={classes.collapsibleSection}
|
|
73
|
+
>
|
|
74
|
+
<div className={classes.main} data-test-id="section-content">
|
|
75
|
+
{validChildren}
|
|
76
|
+
</div>
|
|
77
|
+
</AccordionItem>
|
|
78
|
+
) : (
|
|
79
|
+
<div className={classes.main} data-test-id="section-content">
|
|
80
|
+
{validChildren}
|
|
55
81
|
</div>
|
|
56
82
|
)}
|
|
57
|
-
<div className={classes.main} data-test-id="section-content">
|
|
58
|
-
{validChildren}
|
|
59
|
-
</div>
|
|
60
83
|
</div>
|
|
61
84
|
);
|
|
62
85
|
};
|
|
@@ -71,6 +71,8 @@ $filter-font-size: 16px;
|
|
|
71
71
|
$filter-width: 360px;
|
|
72
72
|
$filter-controller-background-color: $light-gray-2;
|
|
73
73
|
$filter-border-color: $blue;
|
|
74
|
+
$multi-option-checbox-border: $blue;
|
|
75
|
+
$multi-option-label-color: $dark-gray;
|
|
74
76
|
|
|
75
77
|
/* Details vars */
|
|
76
78
|
$details-background-color: #ffffff;
|