@axinom/mosaic-ui 0.32.0 → 0.33.0-rc.0
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/Actions/Actions.d.ts.map +1 -1
- package/dist/components/Explorer/Explorer.d.ts.map +1 -1
- package/dist/components/Explorer/Explorer.model.d.ts +5 -0
- package/dist/components/Explorer/Explorer.model.d.ts.map +1 -1
- package/dist/components/Explorer/SelectionExplorer/SelectionExplorer.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/FormStation/FormStation.d.ts.map +1 -1
- package/dist/components/InfoPanel/Section/Section.d.ts +3 -1
- package/dist/components/InfoPanel/Section/Section.d.ts.map +1 -1
- package/dist/hooks/useBusy/useBusy.d.ts +4 -0
- package/dist/hooks/useBusy/useBusy.d.ts.map +1 -0
- 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/dist/initialize.d.ts +11 -1
- package/dist/initialize.d.ts.map +1 -1
- package/dist/types/ui-config.d.ts +7 -0
- package/dist/types/ui-config.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/Accordion/AccordionItem/AccordionItem.spec.tsx +11 -0
- package/src/components/Accordion/AccordionItem/AccordionItem.tsx +5 -1
- package/src/components/Actions/Actions.spec.tsx +19 -0
- package/src/components/Actions/Actions.tsx +8 -1
- package/src/components/Explorer/Explorer.model.ts +5 -0
- package/src/components/Explorer/Explorer.spec.tsx +37 -5
- package/src/components/Explorer/Explorer.tsx +5 -3
- package/src/components/Explorer/SelectionExplorer/SelectionExplorer.spec.tsx +30 -0
- package/src/components/Explorer/SelectionExplorer/SelectionExplorer.tsx +1 -0
- 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/FormStation/FormStation.scss +29 -0
- package/src/components/FormStation/FormStation.spec.tsx +66 -8
- package/src/components/FormStation/FormStation.tsx +5 -1
- 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/components/LandingPageTiles/TileLarge/TileLarge.scss +3 -3
- package/src/components/LandingPageTiles/TileSmall/TileSmall.scss +3 -3
- package/src/hooks/useBusy/useBusy.spec.tsx +34 -0
- package/src/hooks/useBusy/useBusy.tsx +14 -0
- package/src/initialize.ts +30 -2
- package/src/styles/variables.scss +3 -0
- package/src/types/ui-config.ts +15 -0
|
@@ -5,6 +5,7 @@ import { act } from 'react-dom/test-utils';
|
|
|
5
5
|
import { MemoryRouter, Route } from 'react-router-dom';
|
|
6
6
|
import * as Yup from 'yup';
|
|
7
7
|
import { noop } from '../../helpers/utils';
|
|
8
|
+
import { hideSaveIndicator, showSaveIndicator } from '../../initialize';
|
|
8
9
|
import { ActionData, Actions } from '../Actions';
|
|
9
10
|
import { Action } from '../Actions/Action';
|
|
10
11
|
import { MessageBar } from '../MessageBar/MessageBar';
|
|
@@ -12,6 +13,8 @@ import { PageHeader, PageHeaderAction } from '../PageHeader';
|
|
|
12
13
|
import { FormStation, ObjectSchemaDefinition } from './FormStation';
|
|
13
14
|
import { SaveOnNavigate } from './SaveOnNavigate/SaveOnNavigate';
|
|
14
15
|
|
|
16
|
+
jest.mock('../../initialize');
|
|
17
|
+
|
|
15
18
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
16
19
|
|
|
17
20
|
const mockActions = (onActionSelected: jest.Mock): ActionData[] => [
|
|
@@ -41,6 +44,10 @@ const MakeDirty: React.FC = () => {
|
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
describe('Details', () => {
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
jest.clearAllMocks();
|
|
49
|
+
});
|
|
50
|
+
|
|
44
51
|
it('renders the component without crashing', () => {
|
|
45
52
|
const wrapper = shallow(<FormStation {...defaultProps} />);
|
|
46
53
|
|
|
@@ -102,7 +109,7 @@ describe('Details', () => {
|
|
|
102
109
|
.find(Action)
|
|
103
110
|
.prop('action').onActionSelected;
|
|
104
111
|
await act(async () => {
|
|
105
|
-
actionSelected();
|
|
112
|
+
actionSelected && actionSelected();
|
|
106
113
|
});
|
|
107
114
|
|
|
108
115
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
@@ -148,7 +155,7 @@ describe('Details', () => {
|
|
|
148
155
|
.find(Action)
|
|
149
156
|
.prop('action').onActionSelected;
|
|
150
157
|
await act(async () => {
|
|
151
|
-
actionSelected();
|
|
158
|
+
actionSelected && actionSelected();
|
|
152
159
|
});
|
|
153
160
|
|
|
154
161
|
expect(spy).not.toHaveBeenCalled();
|
|
@@ -176,7 +183,7 @@ describe('Details', () => {
|
|
|
176
183
|
.find(Action)
|
|
177
184
|
.prop('action').onActionSelected;
|
|
178
185
|
await act(async () => {
|
|
179
|
-
actionSelected();
|
|
186
|
+
actionSelected && actionSelected();
|
|
180
187
|
});
|
|
181
188
|
|
|
182
189
|
expect(spy).not.toHaveBeenCalled();
|
|
@@ -201,7 +208,7 @@ describe('Details', () => {
|
|
|
201
208
|
.find(Action)
|
|
202
209
|
.prop('action').onActionSelected;
|
|
203
210
|
await act(async () => {
|
|
204
|
-
actionSelected();
|
|
211
|
+
actionSelected && actionSelected();
|
|
205
212
|
});
|
|
206
213
|
|
|
207
214
|
expect(saveSpy).not.toHaveBeenCalled();
|
|
@@ -421,7 +428,7 @@ describe('Details', () => {
|
|
|
421
428
|
.find(Action)
|
|
422
429
|
.prop('action').onActionSelected;
|
|
423
430
|
await act(async () => {
|
|
424
|
-
actionSelected();
|
|
431
|
+
actionSelected && actionSelected();
|
|
425
432
|
});
|
|
426
433
|
|
|
427
434
|
wrapper.update();
|
|
@@ -473,7 +480,7 @@ describe('Details', () => {
|
|
|
473
480
|
.find(Action)
|
|
474
481
|
.prop('action').onActionSelected;
|
|
475
482
|
await act(async () => {
|
|
476
|
-
actionSelected();
|
|
483
|
+
actionSelected && actionSelected();
|
|
477
484
|
});
|
|
478
485
|
|
|
479
486
|
wrapper.update();
|
|
@@ -534,7 +541,7 @@ describe('Details', () => {
|
|
|
534
541
|
.find(Action)
|
|
535
542
|
.prop('action').onActionSelected;
|
|
536
543
|
await act(async () => {
|
|
537
|
-
actionSelected();
|
|
544
|
+
actionSelected && actionSelected();
|
|
538
545
|
});
|
|
539
546
|
|
|
540
547
|
// place form into 'submitting' state
|
|
@@ -611,7 +618,7 @@ describe('Details', () => {
|
|
|
611
618
|
.find(Action)
|
|
612
619
|
.prop('action').onActionSelected;
|
|
613
620
|
await act(async () => {
|
|
614
|
-
actionSelected();
|
|
621
|
+
actionSelected && actionSelected();
|
|
615
622
|
});
|
|
616
623
|
|
|
617
624
|
// place form into 'submitting' state
|
|
@@ -644,5 +651,56 @@ describe('Details', () => {
|
|
|
644
651
|
isDisabled = action.prop('action').isDisabled;
|
|
645
652
|
expect(isDisabled).toBe(false);
|
|
646
653
|
});
|
|
654
|
+
|
|
655
|
+
it('sets the global busy state when submitting', async () => {
|
|
656
|
+
jest.useFakeTimers();
|
|
657
|
+
const spy = jest.fn();
|
|
658
|
+
const sampleActions = mockActions(spy);
|
|
659
|
+
const onSubmit = (): Promise<{ id: number }> =>
|
|
660
|
+
new Promise((resolve) =>
|
|
661
|
+
setTimeout(() => {
|
|
662
|
+
resolve({ id: 3 });
|
|
663
|
+
}, 1000),
|
|
664
|
+
);
|
|
665
|
+
|
|
666
|
+
const wrapper = mount(
|
|
667
|
+
<MemoryRouter>
|
|
668
|
+
<FormStation
|
|
669
|
+
{...defaultProps}
|
|
670
|
+
actions={sampleActions}
|
|
671
|
+
saveData={onSubmit}
|
|
672
|
+
initialData={{ loading: false, data: {} }}
|
|
673
|
+
>
|
|
674
|
+
<MakeDirty />
|
|
675
|
+
</FormStation>
|
|
676
|
+
</MemoryRouter>,
|
|
677
|
+
);
|
|
678
|
+
|
|
679
|
+
// submit form
|
|
680
|
+
const actionSelected = wrapper
|
|
681
|
+
.find(Action)
|
|
682
|
+
.prop('action').onActionSelected;
|
|
683
|
+
|
|
684
|
+
await act(async () => {
|
|
685
|
+
actionSelected && actionSelected();
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
// place form into 'submitting' state
|
|
689
|
+
await act(async () => {
|
|
690
|
+
jest.advanceTimersByTime(500);
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
wrapper.update();
|
|
694
|
+
|
|
695
|
+
expect(showSaveIndicator).toHaveBeenCalledTimes(1);
|
|
696
|
+
|
|
697
|
+
// complete form submission
|
|
698
|
+
await act(async () => {
|
|
699
|
+
jest.runAllTimers();
|
|
700
|
+
});
|
|
701
|
+
wrapper.update();
|
|
702
|
+
|
|
703
|
+
expect(hideSaveIndicator).toHaveBeenCalledTimes(1);
|
|
704
|
+
});
|
|
647
705
|
});
|
|
648
706
|
});
|
|
@@ -16,18 +16,19 @@ import React, {
|
|
|
16
16
|
} from 'react';
|
|
17
17
|
import { useHistory } from 'react-router-dom';
|
|
18
18
|
import { OptionalObjectSchema } from 'yup/lib/object';
|
|
19
|
+
import { hideSaveIndicator, showSaveIndicator } from '../../initialize';
|
|
19
20
|
import { Data } from '../../types/data';
|
|
20
21
|
import { ErrorTypeToStationError } from '../../utils/ErrorTypeToStationError';
|
|
21
22
|
import { Actions, ActionsProps } from '../Actions';
|
|
22
23
|
import { isNavigationAction } from '../Actions/Action/Action';
|
|
23
24
|
import { IconName } from '../Icons';
|
|
24
25
|
import { MessageBar } from '../MessageBar';
|
|
25
|
-
import { ErrorType, StationError, StationMessage } from '../models';
|
|
26
26
|
import {
|
|
27
27
|
PageHeader,
|
|
28
28
|
PageHeaderActionType,
|
|
29
29
|
PageHeaderProps,
|
|
30
30
|
} from '../PageHeader';
|
|
31
|
+
import { ErrorType, StationError, StationMessage } from '../models';
|
|
31
32
|
import { FormActionData, InitialFormData } from './FormStation.models';
|
|
32
33
|
import classes from './FormStation.scss';
|
|
33
34
|
import { SaveOnNavigate } from './SaveOnNavigate/SaveOnNavigate';
|
|
@@ -144,8 +145,10 @@ export const FormStation = <TValues extends Data, TSubmitResponse = unknown>({
|
|
|
144
145
|
if (isFormSubmitting) {
|
|
145
146
|
return;
|
|
146
147
|
}
|
|
148
|
+
|
|
147
149
|
try {
|
|
148
150
|
setIsFormSubmitting(true);
|
|
151
|
+
showSaveIndicator();
|
|
149
152
|
setStationError(undefined);
|
|
150
153
|
if (!initialData.loading && saveData) {
|
|
151
154
|
const response = await saveData(values, initialData, formikHelpers);
|
|
@@ -167,6 +170,7 @@ export const FormStation = <TValues extends Data, TSubmitResponse = unknown>({
|
|
|
167
170
|
} finally {
|
|
168
171
|
formikHelpers.setSubmitting(false);
|
|
169
172
|
setIsFormSubmitting(false);
|
|
173
|
+
hideSaveIndicator();
|
|
170
174
|
}
|
|
171
175
|
},
|
|
172
176
|
[isFormSubmitting, initialData, saveData, setStationError],
|
|
@@ -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
|
};
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
|
|
34
34
|
.icon {
|
|
35
35
|
align-self: center;
|
|
36
|
-
width:
|
|
37
|
-
height:
|
|
36
|
+
width: 100px;
|
|
37
|
+
height: 100px;
|
|
38
38
|
svg * {
|
|
39
39
|
stroke: var(
|
|
40
40
|
--landingpage-largetile-stroke-color,
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
text-align: center;
|
|
54
54
|
|
|
55
55
|
.label {
|
|
56
|
-
font-size:
|
|
56
|
+
font-size: 26px;
|
|
57
57
|
font-weight: regular;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
|
|
47
47
|
.icon {
|
|
48
48
|
align-self: center;
|
|
49
|
-
width:
|
|
50
|
-
height:
|
|
49
|
+
width: 40px;
|
|
50
|
+
height: 40px;
|
|
51
51
|
svg * {
|
|
52
52
|
stroke: var(
|
|
53
53
|
--landingpage-smalltile-stroke-color,
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
.label {
|
|
60
60
|
text-align: center;
|
|
61
61
|
align-self: center;
|
|
62
|
-
font-size:
|
|
62
|
+
font-size: 15px;
|
|
63
63
|
color: var(--landingpage-smalltile-color, $landingpage-smalltile-color);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mount } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { on } from '../../initialize';
|
|
4
|
+
import { useBusy } from './useBusy';
|
|
5
|
+
|
|
6
|
+
let callback: (busyState: boolean) => void;
|
|
7
|
+
|
|
8
|
+
jest.mock('../../initialize', () => ({
|
|
9
|
+
on: jest.fn().mockImplementationOnce((event, cb) => {
|
|
10
|
+
callback = cb;
|
|
11
|
+
}),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const TestWrapper: React.FC = () => {
|
|
15
|
+
const { isBusy } = useBusy();
|
|
16
|
+
|
|
17
|
+
return <p id="value">{String(isBusy)}</p>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe('useBusy', () => {
|
|
21
|
+
it(`both 'val' and 'debouncedValue' are set to the initial value`, () => {
|
|
22
|
+
const wrapper = mount(<TestWrapper />);
|
|
23
|
+
const currentValue = wrapper.find('#value');
|
|
24
|
+
|
|
25
|
+
expect(on).toHaveBeenCalled();
|
|
26
|
+
expect(currentValue.text()).toBe('false');
|
|
27
|
+
|
|
28
|
+
callback(true);
|
|
29
|
+
|
|
30
|
+
wrapper.update();
|
|
31
|
+
|
|
32
|
+
expect(currentValue.text()).toBe('true');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { on } from '../../initialize';
|
|
3
|
+
|
|
4
|
+
export const useBusy = (): {
|
|
5
|
+
isBusy: boolean;
|
|
6
|
+
} => {
|
|
7
|
+
const [busy, setBusy] = React.useState(false);
|
|
8
|
+
|
|
9
|
+
on('busy', (busyState) => {
|
|
10
|
+
setBusy(busyState as boolean);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return { isBusy: busy };
|
|
14
|
+
};
|
package/src/initialize.ts
CHANGED
|
@@ -1,18 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AddIndicator,
|
|
3
|
+
CustomEventEmitter,
|
|
4
|
+
RemoveIndicator,
|
|
5
|
+
ShowNotification,
|
|
6
|
+
} from './types/ui-config';
|
|
2
7
|
|
|
3
8
|
export let showNotification: ShowNotification | (() => void) =
|
|
4
9
|
polyfill('showNotification');
|
|
5
10
|
|
|
11
|
+
export let addIndicator: AddIndicator | (() => void) = polyfill('addIndicator');
|
|
12
|
+
|
|
13
|
+
export let removeIndicator: RemoveIndicator | (() => void) =
|
|
14
|
+
polyfill('removeIndicator');
|
|
15
|
+
|
|
16
|
+
export let on: CustomEventEmitter['on'] | (() => void) = polyfill('on');
|
|
17
|
+
|
|
18
|
+
export let showSaveIndicator: () => void = polyfill('showSaveIndicator');
|
|
19
|
+
|
|
20
|
+
export let hideSaveIndicator: () => void = polyfill('hideSaveIndicator');
|
|
21
|
+
|
|
6
22
|
/**
|
|
7
23
|
* Passes the PiralApi methods to the UI library.
|
|
8
24
|
* @param app {UiConfig} object containing PiralApi methods for use in UI library.
|
|
9
25
|
*/
|
|
10
26
|
export function initializeUi(app: UiConfig): void {
|
|
11
|
-
({
|
|
27
|
+
({
|
|
28
|
+
showNotification,
|
|
29
|
+
addIndicator,
|
|
30
|
+
removeIndicator,
|
|
31
|
+
on,
|
|
32
|
+
showSaveIndicator,
|
|
33
|
+
hideSaveIndicator,
|
|
34
|
+
} = app);
|
|
12
35
|
}
|
|
13
36
|
|
|
14
37
|
export interface UiConfig {
|
|
15
38
|
showNotification: ShowNotification;
|
|
39
|
+
addIndicator: AddIndicator;
|
|
40
|
+
removeIndicator: RemoveIndicator;
|
|
41
|
+
on: CustomEventEmitter['on'];
|
|
42
|
+
showSaveIndicator: () => void;
|
|
43
|
+
hideSaveIndicator: () => void;
|
|
16
44
|
}
|
|
17
45
|
|
|
18
46
|
function polyfill(methodName: string): () => void {
|
|
@@ -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;
|
|
@@ -195,6 +197,7 @@ $date-picker-max-width: $width-small;
|
|
|
195
197
|
$form-element-min-height: 50px;
|
|
196
198
|
$read-only-text-background-color: $light-gray-2;
|
|
197
199
|
$select-background-color: white;
|
|
200
|
+
$form-indicator-color: $green;
|
|
198
201
|
|
|
199
202
|
/* Dynamic Data List */
|
|
200
203
|
$dynamic-list-row-bg-color: white;
|
package/src/types/ui-config.ts
CHANGED
|
@@ -28,3 +28,18 @@ export type NotificationId = string | number;
|
|
|
28
28
|
export type NotificationBody = string | ReactNode | Component;
|
|
29
29
|
|
|
30
30
|
export type NotificationType = 'success' | 'error' | 'info' | 'warning';
|
|
31
|
+
|
|
32
|
+
export type IndicatorId = number;
|
|
33
|
+
|
|
34
|
+
export type AddIndicator = (content: React.ReactNode) => IndicatorId;
|
|
35
|
+
|
|
36
|
+
export type RemoveIndicator = (id: IndicatorId) => void;
|
|
37
|
+
|
|
38
|
+
export type UpdateIndicator = (
|
|
39
|
+
id: IndicatorId,
|
|
40
|
+
content: React.ReactNode,
|
|
41
|
+
) => void;
|
|
42
|
+
|
|
43
|
+
export interface CustomEventEmitter {
|
|
44
|
+
on(eventName: string, listener: (...args: unknown[]) => void): void;
|
|
45
|
+
}
|