@axinom/mosaic-ui 0.33.0-rc.0 → 0.33.0-rc.19
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/Actions/Actions.models.d.ts +0 -13
- package/dist/components/Actions/Actions.models.d.ts.map +1 -1
- package/dist/components/DynamicDataList/DynamicDataList.d.ts.map +1 -1
- package/dist/components/DynamicDataList/DynamicListRow/DynamicListRow.d.ts +3 -1
- package/dist/components/DynamicDataList/DynamicListRow/DynamicListRow.d.ts.map +1 -1
- package/dist/components/FormElements/CustomTags/CustomTags.d.ts.map +1 -1
- package/dist/components/FormElements/FileUploadControl/FileUploadControl.d.ts.map +1 -1
- package/dist/components/FormElements/Radio/Radio.d.ts.map +1 -1
- package/dist/components/FormElements/Tags/Tags.d.ts.map +1 -1
- package/dist/components/FormElements/formStoryHelper.d.ts.map +1 -1
- 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/InfoImage/InfoImage.d.ts.map +1 -1
- package/dist/components/List/List.d.ts.map +1 -1
- package/dist/components/Loaders/ImageLoader/ImageLoader.d.ts +2 -0
- package/dist/components/Loaders/ImageLoader/ImageLoader.d.ts.map +1 -1
- package/dist/components/PageHeader/PageHeaderAction/PageHeaderAction.model.d.ts +1 -11
- package/dist/components/PageHeader/PageHeaderAction/PageHeaderAction.model.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.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/dist/initialize.d.ts +7 -4
- package/dist/initialize.d.ts.map +1 -1
- package/dist/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.d.ts +9 -0
- package/dist/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.d.ts.map +1 -0
- package/dist/utils/ErrorMapper/ErrorMapper.d.ts +15 -0
- package/dist/utils/ErrorMapper/ErrorMapper.d.ts.map +1 -0
- package/dist/utils/ErrorMapper/ErrorMapper.type.d.ts +11 -0
- package/dist/utils/ErrorMapper/ErrorMapper.type.d.ts.map +1 -0
- package/dist/utils/ErrorMapper/index.d.ts +4 -0
- package/dist/utils/ErrorMapper/index.d.ts.map +1 -0
- package/dist/utils/ErrorTypeToStationError.d.ts +1 -1
- package/dist/utils/ErrorTypeToStationError.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/Accordion/Accordion.scss +1 -1
- package/src/components/Accordion/AccordionItem/AccordionItem.scss +1 -1
- package/src/components/Actions/Action/Action.scss +0 -2
- package/src/components/Actions/Actions.models.ts +0 -14
- package/src/components/Actions/Actions.stories.tsx +4 -1
- package/src/components/Buttons/Button/Button.scss +66 -20
- package/src/components/Buttons/CompositeButton/CompositeButton.scss +50 -18
- package/src/components/Buttons/TextButton/TextButton.scss +45 -16
- package/src/components/DateTime/DatePicker/DatePicker.scss +15 -6
- package/src/components/DateTime/DateTimePicker.scss +6 -2
- package/src/components/DynamicDataList/DynamicDataList.tsx +1 -0
- package/src/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.scss +15 -5
- package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createInputRenderer/createInputRenderer.tsx +1 -1
- package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createSelectRenderer/createSelectRenderer.scss +36 -12
- package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createSelectRenderer/createSelectRenderer.tsx +2 -2
- package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.scss +26 -0
- package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.tsx +7 -1
- package/src/components/Filters/Filter/Filter.scss +8 -2
- package/src/components/Filters/SelectionTypes/DateTimeFilter/DateTimeFilter.scss +4 -1
- package/src/components/FormElements/Checkbox/Checkbox.scss +20 -0
- package/src/components/FormElements/CustomTags/CustomTags.scss +24 -0
- package/src/components/FormElements/CustomTags/CustomTags.tsx +8 -2
- package/src/components/FormElements/DateTimeField/DateTimeText.spec.tsx +1 -1
- package/src/components/FormElements/DateTimeField/DateTimeText.tsx +1 -1
- package/src/components/FormElements/FileUploadControl/FileUploadControl.scss +4 -2
- package/src/components/FormElements/FileUploadControl/FileUploadControl.tsx +12 -3
- package/src/components/FormElements/Radio/Radio.scss +18 -3
- package/src/components/FormElements/Radio/Radio.tsx +2 -2
- package/src/components/FormElements/Select/Select.scss +10 -0
- package/src/components/FormElements/SingleLineText/SingleLineText.spec.tsx +2 -2
- package/src/components/FormElements/SingleLineText/SingleLineText.tsx +1 -1
- package/src/components/FormElements/Tags/Tags.scss +14 -0
- package/src/components/FormElements/Tags/Tags.tsx +5 -1
- package/src/components/FormElements/TextArea/TextArea.spec.tsx +2 -2
- package/src/components/FormElements/TextArea/TextArea.tsx +1 -1
- package/src/components/FormElements/formStoryHelper.tsx +163 -97
- package/src/components/FormStation/FormStation.spec.tsx +13 -3
- package/src/components/FormStation/FormStation.tsx +43 -19
- 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/InfoImage/InfoImage.scss +8 -3
- package/src/components/InfoPanel/InfoImage/InfoImage.tsx +1 -0
- package/src/components/List/List.tsx +3 -1
- package/src/components/List/ListCheckBox/ListCheckBox.scss +8 -3
- package/src/components/List/ListRow/ListRow.scss +0 -4
- package/src/components/Loaders/ImageLoader/ImageLoader.scss +27 -21
- package/src/components/Loaders/ImageLoader/ImageLoader.spec.tsx +8 -12
- package/src/components/Loaders/ImageLoader/ImageLoader.tsx +8 -3
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.model.ts +0 -10
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.scss +0 -1
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.stories.tsx +5 -0
- package/src/components/index.ts +1 -1
- package/src/index.ts +1 -0
- package/src/initialize.ts +15 -12
- package/src/styles/variables.scss +32 -2
- package/src/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.spec.ts +32 -0
- package/src/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.tsx +33 -0
- package/src/utils/ErrorMapper/ErrorMapper.spec.ts +67 -0
- package/src/utils/ErrorMapper/ErrorMapper.ts +31 -0
- package/src/utils/ErrorMapper/ErrorMapper.type.ts +11 -0
- package/src/utils/ErrorMapper/index.ts +3 -0
- package/src/utils/ErrorTypeToStationError.spec.tsx +12 -0
- package/src/utils/ErrorTypeToStationError.tsx +5 -1
|
@@ -20,6 +20,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
20
20
|
const isSubmitting = false;
|
|
21
21
|
const canSubmit = true;
|
|
22
22
|
const setCanSubmit = jest.fn();
|
|
23
|
+
const onNavigationCancelled = jest.fn();
|
|
23
24
|
|
|
24
25
|
// Act
|
|
25
26
|
await handleNavigationAttempt(
|
|
@@ -30,6 +31,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
30
31
|
isSubmitting,
|
|
31
32
|
canSubmit,
|
|
32
33
|
setCanSubmit,
|
|
34
|
+
onNavigationCancelled,
|
|
33
35
|
);
|
|
34
36
|
|
|
35
37
|
// Assert
|
|
@@ -38,6 +40,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
38
40
|
expect(navigation.cancel).not.toHaveBeenCalled();
|
|
39
41
|
expect(submitForm).not.toHaveBeenCalled();
|
|
40
42
|
expect(setCanSubmit).not.toHaveBeenCalled();
|
|
43
|
+
expect(onNavigationCancelled).not.toHaveBeenCalled();
|
|
41
44
|
});
|
|
42
45
|
|
|
43
46
|
it(`blocks navigation when 'isValid' is 'false' by calling 'navigation.cancel()'`, async () => {
|
|
@@ -48,6 +51,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
48
51
|
const isSubmitting = false;
|
|
49
52
|
const canSubmit = true;
|
|
50
53
|
const setCanSubmit = jest.fn();
|
|
54
|
+
const onNavigationCancelled = jest.fn();
|
|
51
55
|
|
|
52
56
|
// Act
|
|
53
57
|
await handleNavigationAttempt(
|
|
@@ -58,6 +62,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
58
62
|
isSubmitting,
|
|
59
63
|
canSubmit,
|
|
60
64
|
setCanSubmit,
|
|
65
|
+
onNavigationCancelled,
|
|
61
66
|
);
|
|
62
67
|
|
|
63
68
|
// Assert
|
|
@@ -66,6 +71,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
66
71
|
expect(navigation.cancel).toHaveBeenCalledTimes(1);
|
|
67
72
|
expect(submitForm).not.toHaveBeenCalled();
|
|
68
73
|
expect(setCanSubmit).not.toHaveBeenCalled();
|
|
74
|
+
expect(onNavigationCancelled).toHaveBeenCalled();
|
|
69
75
|
});
|
|
70
76
|
|
|
71
77
|
it(`pauses further navigation when 'dirty' is 'true' and 'isValid' is 'true' by calling 'navigation.pause()'`, async () => {
|
|
@@ -76,6 +82,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
76
82
|
const isSubmitting = true;
|
|
77
83
|
const canSubmit = true;
|
|
78
84
|
const setCanSubmit = jest.fn();
|
|
85
|
+
const onNavigationCancelled = jest.fn();
|
|
79
86
|
|
|
80
87
|
// Act
|
|
81
88
|
await handleNavigationAttempt(
|
|
@@ -86,6 +93,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
86
93
|
isSubmitting,
|
|
87
94
|
canSubmit,
|
|
88
95
|
setCanSubmit,
|
|
96
|
+
onNavigationCancelled,
|
|
89
97
|
);
|
|
90
98
|
|
|
91
99
|
// Assert
|
|
@@ -94,6 +102,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
94
102
|
expect(navigation.cancel).not.toHaveBeenCalled();
|
|
95
103
|
expect(submitForm).not.toHaveBeenCalled();
|
|
96
104
|
expect(setCanSubmit).not.toHaveBeenCalled();
|
|
105
|
+
expect(onNavigationCancelled).not.toHaveBeenCalled();
|
|
97
106
|
});
|
|
98
107
|
|
|
99
108
|
it(`while 'isSubmitting' is 'true' navigation should continue to be paused by not calling 'navigation.resume()'`, async () => {
|
|
@@ -104,6 +113,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
104
113
|
const isSubmitting = true;
|
|
105
114
|
const canSubmit = true;
|
|
106
115
|
const setCanSubmit = jest.fn();
|
|
116
|
+
const onNavigationCancelled = jest.fn();
|
|
107
117
|
|
|
108
118
|
// Act
|
|
109
119
|
await handleNavigationAttempt(
|
|
@@ -114,6 +124,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
114
124
|
isSubmitting,
|
|
115
125
|
canSubmit,
|
|
116
126
|
setCanSubmit,
|
|
127
|
+
onNavigationCancelled,
|
|
117
128
|
);
|
|
118
129
|
|
|
119
130
|
// Assert
|
|
@@ -122,6 +133,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
122
133
|
expect(navigation.cancel).not.toHaveBeenCalled();
|
|
123
134
|
expect(submitForm).not.toHaveBeenCalled();
|
|
124
135
|
expect(setCanSubmit).not.toHaveBeenCalled();
|
|
136
|
+
expect(onNavigationCancelled).not.toHaveBeenCalled();
|
|
125
137
|
});
|
|
126
138
|
|
|
127
139
|
it(`while 'canSubmit' is 'false' navigation should continue to be paused by not calling 'navigation.resume()'`, async () => {
|
|
@@ -132,6 +144,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
132
144
|
const isSubmitting = false;
|
|
133
145
|
const canSubmit = false;
|
|
134
146
|
const setCanSubmit = jest.fn();
|
|
147
|
+
const onNavigationCancelled = jest.fn();
|
|
135
148
|
|
|
136
149
|
// Act
|
|
137
150
|
await handleNavigationAttempt(
|
|
@@ -142,6 +155,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
142
155
|
isSubmitting,
|
|
143
156
|
canSubmit,
|
|
144
157
|
setCanSubmit,
|
|
158
|
+
onNavigationCancelled,
|
|
145
159
|
);
|
|
146
160
|
|
|
147
161
|
// Assert
|
|
@@ -150,6 +164,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
150
164
|
expect(navigation.cancel).not.toHaveBeenCalled();
|
|
151
165
|
expect(submitForm).not.toHaveBeenCalled();
|
|
152
166
|
expect(setCanSubmit).not.toHaveBeenCalled();
|
|
167
|
+
expect(onNavigationCancelled).not.toHaveBeenCalled();
|
|
153
168
|
});
|
|
154
169
|
|
|
155
170
|
it(`navigation can resume after the submitForm promise was successfully resolved by calling 'navigation.resume()'`, async () => {
|
|
@@ -160,6 +175,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
160
175
|
const isSubmitting = false;
|
|
161
176
|
const canSubmit = true;
|
|
162
177
|
const setCanSubmit = jest.fn();
|
|
178
|
+
const onNavigationCancelled = jest.fn();
|
|
163
179
|
|
|
164
180
|
// Act
|
|
165
181
|
await handleNavigationAttempt(
|
|
@@ -170,6 +186,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
170
186
|
isSubmitting,
|
|
171
187
|
canSubmit,
|
|
172
188
|
setCanSubmit,
|
|
189
|
+
onNavigationCancelled,
|
|
173
190
|
);
|
|
174
191
|
|
|
175
192
|
// Assert
|
|
@@ -179,6 +196,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
179
196
|
expect(submitForm).toHaveBeenCalledTimes(1);
|
|
180
197
|
expect(setCanSubmit).toHaveBeenCalledTimes(1);
|
|
181
198
|
expect(setCanSubmit).toHaveBeenCalledWith(false);
|
|
199
|
+
expect(onNavigationCancelled).not.toHaveBeenCalledWith(false);
|
|
182
200
|
});
|
|
183
201
|
|
|
184
202
|
it(`navigation is cancelled when the 'submitForm' promise was rejected by calling 'navigation.cancel()'`, async () => {
|
|
@@ -191,6 +209,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
191
209
|
const isSubmitting = false;
|
|
192
210
|
const canSubmit = true;
|
|
193
211
|
const setCanSubmit = jest.fn();
|
|
212
|
+
const onNavigationCancelled = jest.fn();
|
|
194
213
|
|
|
195
214
|
// Act
|
|
196
215
|
await handleNavigationAttempt(
|
|
@@ -201,6 +220,7 @@ describe('handleNavigationAttempt', () => {
|
|
|
201
220
|
isSubmitting,
|
|
202
221
|
canSubmit,
|
|
203
222
|
setCanSubmit,
|
|
223
|
+
onNavigationCancelled,
|
|
204
224
|
);
|
|
205
225
|
|
|
206
226
|
// Assert
|
|
@@ -211,5 +231,6 @@ describe('handleNavigationAttempt', () => {
|
|
|
211
231
|
expect(setCanSubmit).toHaveBeenCalledTimes(2);
|
|
212
232
|
expect(setCanSubmit).toHaveBeenNthCalledWith(1, false);
|
|
213
233
|
expect(setCanSubmit).toHaveBeenNthCalledWith(2, true);
|
|
234
|
+
expect(onNavigationCancelled).not.toHaveBeenCalled();
|
|
214
235
|
});
|
|
215
236
|
});
|
|
@@ -10,6 +10,7 @@ export const handleNavigationAttempt = async (
|
|
|
10
10
|
isSubmitting: boolean,
|
|
11
11
|
canSubmit: boolean,
|
|
12
12
|
setCanSubmit: React.Dispatch<React.SetStateAction<boolean>>,
|
|
13
|
+
onNavigationCancelled: () => void,
|
|
13
14
|
): Promise<void> => {
|
|
14
15
|
if (!dirty) {
|
|
15
16
|
// Form values didn't change, just navigate away
|
|
@@ -20,6 +21,7 @@ export const handleNavigationAttempt = async (
|
|
|
20
21
|
// Form is invalid, cancel navigation
|
|
21
22
|
// TODO: Add a message here (probably connected to "Error handling")
|
|
22
23
|
navigation.cancel();
|
|
24
|
+
onNavigationCancelled();
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
27
|
// Form values have changed and form is valid, attempt save
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useFormikContext } from 'formik';
|
|
2
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { StationErrorStateType } from './StationErrorStateType';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Component that watches for changes in the form validation state
|
|
7
|
+
* and calls the callback with the current state.
|
|
8
|
+
*/
|
|
9
|
+
const ValidationWatcher: React.FC<{
|
|
10
|
+
callback: (isValid: boolean) => void;
|
|
11
|
+
}> = ({ callback: isValid }) => {
|
|
12
|
+
const formik = useFormikContext();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
isValid(formik.isValid);
|
|
15
|
+
}, [formik.isValid, isValid]);
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Cares for showing (and removing) validation errors.
|
|
20
|
+
* @param stationError the currently showing error
|
|
21
|
+
* @param setStationError the setter for the currently showing error
|
|
22
|
+
* @returns
|
|
23
|
+
* `setValidationError` - call this method to set the validation error.
|
|
24
|
+
* `validationWatcher` - place this JSX somewhere inside the <Formik /> component children.
|
|
25
|
+
*/
|
|
26
|
+
export function useValidationError(
|
|
27
|
+
stationError: StationErrorStateType | undefined,
|
|
28
|
+
setStationError: React.Dispatch<
|
|
29
|
+
React.SetStateAction<StationErrorStateType | undefined>
|
|
30
|
+
>,
|
|
31
|
+
): {
|
|
32
|
+
setValidationError: () => void;
|
|
33
|
+
validationWatcher: JSX.Element;
|
|
34
|
+
} {
|
|
35
|
+
// Track validation state of the from using the validationWatcher
|
|
36
|
+
const [isValid, setIsValid] = useState<boolean>(true);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
// if the form became valid, remove the validation error
|
|
40
|
+
if (isValid && stationError && stationError.type === 'validation') {
|
|
41
|
+
setStationError(undefined);
|
|
42
|
+
}
|
|
43
|
+
}, [isValid, setStationError, stationError]);
|
|
44
|
+
|
|
45
|
+
const setValidationError = useCallback((): void => {
|
|
46
|
+
// set the validation error
|
|
47
|
+
setStationError({
|
|
48
|
+
title: 'Please fix the errors in the form to proceed.',
|
|
49
|
+
type: 'validation',
|
|
50
|
+
});
|
|
51
|
+
}, [setStationError]);
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
setValidationError,
|
|
55
|
+
validationWatcher: (
|
|
56
|
+
<ValidationWatcher callback={(valid) => setIsValid(valid)} />
|
|
57
|
+
),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -320,7 +320,9 @@ export const List = <T extends Data>({
|
|
|
320
320
|
horizontalTextAlign={horizontalTextAlign}
|
|
321
321
|
verticalTextAlign={verticalTextAlign}
|
|
322
322
|
showItemCheckbox={
|
|
323
|
-
enableSelectAll &&
|
|
323
|
+
enableSelectAll &&
|
|
324
|
+
selectionMode === ListSelectMode.Multi &&
|
|
325
|
+
listItems.length > 0
|
|
324
326
|
}
|
|
325
327
|
isCheckboxDisabled={listItems.length === 0}
|
|
326
328
|
onCheckboxToggled={headerCheckboxHandler}
|
|
@@ -9,8 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
.disabled {
|
|
11
11
|
background-color: var(
|
|
12
|
-
--
|
|
13
|
-
$
|
|
14
|
-
)
|
|
12
|
+
--actions-disabled-bg-color,
|
|
13
|
+
$actions-disabled-bg-color
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// background-color: var(
|
|
17
|
+
// --page-header-action-context-background-color,
|
|
18
|
+
// $page-header-action-context-background-color
|
|
19
|
+
// ) !important;
|
|
15
20
|
}
|
|
16
21
|
}
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
@import '../../../styles/common.scss';
|
|
2
2
|
|
|
3
3
|
.container {
|
|
4
|
-
@include boxSizing;
|
|
5
|
-
|
|
6
|
-
width: 50px;
|
|
7
|
-
height: 50px;
|
|
8
4
|
display: grid;
|
|
9
|
-
grid
|
|
10
|
-
grid-template-rows: 1fr;
|
|
11
|
-
place-items: center;
|
|
12
|
-
}
|
|
5
|
+
grid: 1fr / 1fr;
|
|
13
6
|
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
}
|
|
7
|
+
.loader {
|
|
8
|
+
@include boxSizing;
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
width: 50px;
|
|
11
|
+
height: 50px;
|
|
12
|
+
display: grid;
|
|
13
|
+
grid: 1fr / 1fr;
|
|
14
|
+
place-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.imageContainer {
|
|
18
|
+
display: grid;
|
|
19
|
+
grid: 1fr / 1fr;
|
|
20
|
+
place-items: center;
|
|
21
|
+
|
|
22
|
+
.fallback {
|
|
23
|
+
background-color: var(
|
|
24
|
+
--fallback-image-bg-color,
|
|
25
|
+
$fallback-image-bg-color
|
|
26
|
+
);
|
|
27
|
+
}
|
|
23
28
|
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
.fallBackImage {
|
|
30
|
+
height: 50px;
|
|
31
|
+
width: 50px;
|
|
32
|
+
align-self: center;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
29
35
|
}
|
|
@@ -99,7 +99,7 @@ describe('ImageLoader', () => {
|
|
|
99
99
|
|
|
100
100
|
const loader = wrapper.find(ContentLoader);
|
|
101
101
|
const imgDisplay = wrapper.find('img').prop('style')?.display;
|
|
102
|
-
const fallbackContainer = wrapper.find('.container');
|
|
102
|
+
const fallbackContainer = wrapper.find('.container').at(1);
|
|
103
103
|
|
|
104
104
|
expect(loader.exists()).toBe(false);
|
|
105
105
|
expect(imgDisplay).toBe('none');
|
|
@@ -116,7 +116,7 @@ describe('ImageLoader', () => {
|
|
|
116
116
|
|
|
117
117
|
const loader = wrapper.find(ContentLoader);
|
|
118
118
|
const images = wrapper.find('img');
|
|
119
|
-
const fallbackContainer = wrapper.find('.container');
|
|
119
|
+
const fallbackContainer = wrapper.find('.container').at(1);
|
|
120
120
|
|
|
121
121
|
expect(loader.exists()).toBe(false);
|
|
122
122
|
expect(images.at(0).prop('style')?.display).toBe('none'); // hidden failed image
|
|
@@ -198,12 +198,10 @@ describe('ImageLoader', () => {
|
|
|
198
198
|
it(`loader dimensions defaults to '50px' by '50px'`, () => {
|
|
199
199
|
const wrapper = shallow(<ImageLoader imgSrc="" />);
|
|
200
200
|
|
|
201
|
-
const
|
|
202
|
-
.find('.container')
|
|
203
|
-
.prop('style') as React.CSSProperties;
|
|
201
|
+
const loader = wrapper.find('.loader').prop('style') as React.CSSProperties;
|
|
204
202
|
|
|
205
|
-
expect(
|
|
206
|
-
expect(
|
|
203
|
+
expect(loader.height).toBe('50px');
|
|
204
|
+
expect(loader.width).toBe('50px');
|
|
207
205
|
});
|
|
208
206
|
|
|
209
207
|
it('sets the height and width of the loader', () => {
|
|
@@ -213,11 +211,9 @@ describe('ImageLoader', () => {
|
|
|
213
211
|
<ImageLoader imgSrc="" height={mockHeight} width={mockWidth} />,
|
|
214
212
|
);
|
|
215
213
|
|
|
216
|
-
const
|
|
217
|
-
.find('.container')
|
|
218
|
-
.prop('style') as React.CSSProperties;
|
|
214
|
+
const loader = wrapper.find('.loader').prop('style') as React.CSSProperties;
|
|
219
215
|
|
|
220
|
-
expect(
|
|
221
|
-
expect(
|
|
216
|
+
expect(loader.height).toBe(`${mockHeight}px`);
|
|
217
|
+
expect(loader.width).toBe(`${mockWidth}px`);
|
|
222
218
|
});
|
|
223
219
|
});
|
|
@@ -40,6 +40,9 @@ export interface ImageLoaderProps {
|
|
|
40
40
|
onImageClick?: (
|
|
41
41
|
event: React.MouseEvent<HTMLImageElement, MouseEvent>,
|
|
42
42
|
) => void;
|
|
43
|
+
|
|
44
|
+
/** CSS Class name for additional img element styles */
|
|
45
|
+
imageClassName?: string;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
/**
|
|
@@ -65,6 +68,7 @@ export const ImageLoader: React.FC<ImageLoaderProps> = ({
|
|
|
65
68
|
onError = noop,
|
|
66
69
|
onImageClick = noop,
|
|
67
70
|
children,
|
|
71
|
+
imageClassName = '',
|
|
68
72
|
}) => {
|
|
69
73
|
const actualViewBox = viewBox || `0 0 ${width} ${height}`;
|
|
70
74
|
|
|
@@ -106,9 +110,9 @@ export const ImageLoader: React.FC<ImageLoaderProps> = ({
|
|
|
106
110
|
}, [imgSrc, onError]);
|
|
107
111
|
|
|
108
112
|
return (
|
|
109
|
-
|
|
113
|
+
<div className={classes.container}>
|
|
110
114
|
{isLoading && (
|
|
111
|
-
<div className={classes.
|
|
115
|
+
<div className={classes.loader} style={customStyles}>
|
|
112
116
|
<ContentLoader
|
|
113
117
|
speed={speed}
|
|
114
118
|
backgroundColor={backgroundColor}
|
|
@@ -135,6 +139,7 @@ export const ImageLoader: React.FC<ImageLoaderProps> = ({
|
|
|
135
139
|
onError={onErrorHandler}
|
|
136
140
|
onClick={onImageClick}
|
|
137
141
|
data-test-id="image-loader-img"
|
|
142
|
+
className={imageClassName}
|
|
138
143
|
/>
|
|
139
144
|
{fallBack &&
|
|
140
145
|
(!fallbackSrc ? (
|
|
@@ -153,6 +158,6 @@ export const ImageLoader: React.FC<ImageLoaderProps> = ({
|
|
|
153
158
|
{!isLoading && !fallBack && children}
|
|
154
159
|
</div>
|
|
155
160
|
)}
|
|
156
|
-
|
|
161
|
+
</div>
|
|
157
162
|
);
|
|
158
163
|
};
|
|
@@ -5,14 +5,6 @@ import { ConfirmAction, DefaultHandler, LinkAction } from '../../models';
|
|
|
5
5
|
export enum PageHeaderActionType {
|
|
6
6
|
Active,
|
|
7
7
|
Context,
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated This value is no longer necessary for navigation type actions in the
|
|
10
|
-
* `PageHeaderAction` component, and will be removed in the future.
|
|
11
|
-
* To create a navigation link, use the `path` property instead of the `onClick` handler,
|
|
12
|
-
* which will automatically generate an anchor element.
|
|
13
|
-
* @note This deprecation only affects the `Navigation` enum value in the PageHeaderActionType
|
|
14
|
-
*/
|
|
15
|
-
Navigation,
|
|
16
8
|
}
|
|
17
9
|
|
|
18
10
|
export type PageHeaderActionProps =
|
|
@@ -27,8 +19,6 @@ export interface PageHeaderJsActionProps
|
|
|
27
19
|
/**
|
|
28
20
|
* Whether the action is an 'Active' or 'Context' type.
|
|
29
21
|
* Changes the background color to the corresponding action type. (default: 'Context')
|
|
30
|
-
* Type `Navigation` is deprecated and will be removed in the future
|
|
31
|
-
* define instead of `onClick` handler `path` property to render element with anchor tag
|
|
32
22
|
*/
|
|
33
23
|
actionType?: PageHeaderActionType;
|
|
34
24
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -19,8 +19,8 @@ export * from './List';
|
|
|
19
19
|
export * from './Loaders';
|
|
20
20
|
export * from './MessageBar';
|
|
21
21
|
export * from './Modal';
|
|
22
|
-
export * from './models';
|
|
23
22
|
export * from './NavigationAwareStation';
|
|
24
23
|
export * from './PageHeader';
|
|
25
24
|
export * from './ProgressBar';
|
|
26
25
|
export * from './Utils';
|
|
26
|
+
export * from './models';
|
package/src/index.ts
CHANGED
package/src/initialize.ts
CHANGED
|
@@ -5,6 +5,12 @@ import {
|
|
|
5
5
|
ShowNotification,
|
|
6
6
|
} from './types/ui-config';
|
|
7
7
|
|
|
8
|
+
export enum IndicatorType {
|
|
9
|
+
Saving = 'saving',
|
|
10
|
+
Inactive = 'inactive',
|
|
11
|
+
Dirty = 'dirty',
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
export let showNotification: ShowNotification | (() => void) =
|
|
9
15
|
polyfill('showNotification');
|
|
10
16
|
|
|
@@ -15,9 +21,8 @@ export let removeIndicator: RemoveIndicator | (() => void) =
|
|
|
15
21
|
|
|
16
22
|
export let on: CustomEventEmitter['on'] | (() => void) = polyfill('on');
|
|
17
23
|
|
|
18
|
-
export let
|
|
19
|
-
|
|
20
|
-
export let hideSaveIndicator: () => void = polyfill('hideSaveIndicator');
|
|
24
|
+
export let setSaveIndicator: (type: IndicatorType) => void =
|
|
25
|
+
polyfill('showSaveIndicator');
|
|
21
26
|
|
|
22
27
|
/**
|
|
23
28
|
* Passes the PiralApi methods to the UI library.
|
|
@@ -25,12 +30,11 @@ export let hideSaveIndicator: () => void = polyfill('hideSaveIndicator');
|
|
|
25
30
|
*/
|
|
26
31
|
export function initializeUi(app: UiConfig): void {
|
|
27
32
|
({
|
|
28
|
-
showNotification,
|
|
29
|
-
addIndicator,
|
|
30
|
-
removeIndicator,
|
|
31
|
-
on,
|
|
32
|
-
|
|
33
|
-
hideSaveIndicator,
|
|
33
|
+
showNotification = polyfill('showNotification'),
|
|
34
|
+
addIndicator = polyfill('addIndicator'),
|
|
35
|
+
removeIndicator = polyfill('removeIndicator'),
|
|
36
|
+
on = polyfill('on'),
|
|
37
|
+
setSaveIndicator = polyfill('setSaveIndicator'),
|
|
34
38
|
} = app);
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -39,15 +43,14 @@ export interface UiConfig {
|
|
|
39
43
|
addIndicator: AddIndicator;
|
|
40
44
|
removeIndicator: RemoveIndicator;
|
|
41
45
|
on: CustomEventEmitter['on'];
|
|
42
|
-
|
|
43
|
-
hideSaveIndicator: () => void;
|
|
46
|
+
setSaveIndicator: (type: IndicatorType) => void;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
function polyfill(methodName: string): () => void {
|
|
47
50
|
return () => {
|
|
48
51
|
// eslint-disable-next-line no-console
|
|
49
52
|
console.warn(
|
|
50
|
-
`Could not find ${methodName} method. Is the UI initialized in the pilet? To initialize UI library call 'initializeUi(app)' in your pilet.`,
|
|
53
|
+
`Could not find '${methodName}' method. Is the UI initialized in the pilet? To initialize UI library call 'initializeUi(app)' in your pilet.`,
|
|
51
54
|
);
|
|
52
55
|
};
|
|
53
56
|
}
|
|
@@ -41,6 +41,7 @@ $accordion-item-background-color: white;
|
|
|
41
41
|
$accordion-item-text-color: $dark-gray;
|
|
42
42
|
$accordion-item-hover-color: rgba($blue, 0.15);
|
|
43
43
|
$accordion-item-border: 1px solid $light-gray;
|
|
44
|
+
$accordion-item-arrow-color: $blue;
|
|
44
45
|
|
|
45
46
|
/* Explorer vars */
|
|
46
47
|
$explorer-background-color: #ffffff;
|
|
@@ -65,7 +66,7 @@ $filter-background-color: white;
|
|
|
65
66
|
$filter-background-selected-color: rgba($blue, 0.15);
|
|
66
67
|
$filter-light-font-color: $dark-gray;
|
|
67
68
|
$filter-option-background-color: #d7e9f1;
|
|
68
|
-
$filter-
|
|
69
|
+
$filter-context-button-color: $blue;
|
|
69
70
|
$filter-title-color: $blue;
|
|
70
71
|
$filter-font-size: 16px;
|
|
71
72
|
$filter-width: 360px;
|
|
@@ -184,7 +185,7 @@ $tag-font-color: $dark-gray;
|
|
|
184
185
|
$tag-background-color: $light-gray-2;
|
|
185
186
|
$form-error-color: $red;
|
|
186
187
|
$select-arrow-color: $blue;
|
|
187
|
-
$select-disabled-arrow-color: $
|
|
188
|
+
$select-disabled-arrow-color: $gray;
|
|
188
189
|
$label-font-size: 16px;
|
|
189
190
|
$file-upload-progress: $blue;
|
|
190
191
|
$file-upload-progress-background: $light-gray-2;
|
|
@@ -198,6 +199,16 @@ $form-element-min-height: 50px;
|
|
|
198
199
|
$read-only-text-background-color: $light-gray-2;
|
|
199
200
|
$select-background-color: white;
|
|
200
201
|
$form-indicator-color: $green;
|
|
202
|
+
$radio-hover-stroke-color: $blue;
|
|
203
|
+
$radio-checked-fill-color: $blue;
|
|
204
|
+
|
|
205
|
+
/* Date Time Picker*/
|
|
206
|
+
$calendar-tile-active: $blue;
|
|
207
|
+
$calendar-tile-active-hover: rgba($blue, 0.2);
|
|
208
|
+
$calendar-button-stroke-color: $blue;
|
|
209
|
+
$calendar-title-color: $dark-blue;
|
|
210
|
+
$calendar-container-border-color: $blue;
|
|
211
|
+
$calendar-container-bg-color: $blue;
|
|
201
212
|
|
|
202
213
|
/* Dynamic Data List */
|
|
203
214
|
$dynamic-list-row-bg-color: white;
|
|
@@ -271,3 +282,22 @@ $infotooltip-font-size: 16px;
|
|
|
271
282
|
/* Video Player */
|
|
272
283
|
$video-player-controls-background: $light-gray-2;
|
|
273
284
|
$video-player-controls-text-color: $dark-gray;
|
|
285
|
+
|
|
286
|
+
/* Buttons */
|
|
287
|
+
$navigation-button-background-color: $light-blue;
|
|
288
|
+
$navigation-button-background-color-hover: rgba($light-blue, 0.9);
|
|
289
|
+
$navigation-button-stroke-color: white;
|
|
290
|
+
$navigation-button-background-active-color: white;
|
|
291
|
+
$navigation-button-stroke-active-color: $light-blue;
|
|
292
|
+
$navigation-button-background-disabled-color: $gray;
|
|
293
|
+
$active-button-background-color: $blue;
|
|
294
|
+
$active-button-hover-background-color: rgba($blue, 0.9);
|
|
295
|
+
$active-button-stroke-background-color: white;
|
|
296
|
+
$active-button-active-background-color: white;
|
|
297
|
+
$active-button-active-stroke-color: $blue;
|
|
298
|
+
$context-button-border-color: $blue;
|
|
299
|
+
$context-button-stroke-color: $blue;
|
|
300
|
+
$context-button-hover-border-color: $blue;
|
|
301
|
+
$context-button-active-color: $blue;
|
|
302
|
+
$icon-button-stroke-color: $blue;
|
|
303
|
+
$icon-button-hover-color: $blue;
|