@axinom/mosaic-ui 0.32.0 → 0.33.0-rc.1
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/FormStation/SaveOnNavigate/SaveOnNavigate.d.ts +2 -0
- package/dist/components/FormStation/SaveOnNavigate/SaveOnNavigate.d.ts.map +1 -1
- package/dist/components/FormStation/SaveOnNavigate/handleNavigationAttempt.d.ts +1 -1
- package/dist/components/FormStation/SaveOnNavigate/handleNavigationAttempt.d.ts.map +1 -1
- package/dist/components/FormStation/StationErrorStateType.d.ts +5 -0
- package/dist/components/FormStation/StationErrorStateType.d.ts.map +1 -0
- package/dist/components/FormStation/useValidationError.d.ts +15 -0
- package/dist/components/FormStation/useValidationError.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/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 +34 -16
- package/src/components/FormStation/SaveOnNavigate/SaveOnNavigate.tsx +5 -0
- package/src/components/FormStation/SaveOnNavigate/handleNavigationAttempt.spec.ts +21 -0
- package/src/components/FormStation/SaveOnNavigate/handleNavigationAttempt.ts +2 -0
- package/src/components/FormStation/StationErrorStateType.tsx +5 -0
- package/src/components/FormStation/useValidationError.tsx +59 -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/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
|
@@ -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
|
+
}
|