@axinom/mosaic-ui 0.33.0-rc.1 → 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.
Files changed (99) hide show
  1. package/dist/components/Actions/Actions.models.d.ts +0 -13
  2. package/dist/components/Actions/Actions.models.d.ts.map +1 -1
  3. package/dist/components/DynamicDataList/DynamicDataList.d.ts.map +1 -1
  4. package/dist/components/DynamicDataList/DynamicListRow/DynamicListRow.d.ts +3 -1
  5. package/dist/components/DynamicDataList/DynamicListRow/DynamicListRow.d.ts.map +1 -1
  6. package/dist/components/FormElements/CustomTags/CustomTags.d.ts.map +1 -1
  7. package/dist/components/FormElements/FileUploadControl/FileUploadControl.d.ts.map +1 -1
  8. package/dist/components/FormElements/Radio/Radio.d.ts.map +1 -1
  9. package/dist/components/FormElements/Tags/Tags.d.ts.map +1 -1
  10. package/dist/components/FormElements/formStoryHelper.d.ts.map +1 -1
  11. package/dist/components/FormStation/FormStation.d.ts.map +1 -1
  12. package/dist/components/InfoPanel/InfoImage/InfoImage.d.ts.map +1 -1
  13. package/dist/components/List/List.d.ts.map +1 -1
  14. package/dist/components/Loaders/ImageLoader/ImageLoader.d.ts +2 -0
  15. package/dist/components/Loaders/ImageLoader/ImageLoader.d.ts.map +1 -1
  16. package/dist/components/PageHeader/PageHeaderAction/PageHeaderAction.model.d.ts +1 -11
  17. package/dist/components/PageHeader/PageHeaderAction/PageHeaderAction.model.d.ts.map +1 -1
  18. package/dist/components/index.d.ts +1 -1
  19. package/dist/components/index.d.ts.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.es.js +3 -3
  23. package/dist/index.es.js.map +1 -1
  24. package/dist/index.js +3 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/initialize.d.ts +7 -4
  27. package/dist/initialize.d.ts.map +1 -1
  28. package/dist/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.d.ts +9 -0
  29. package/dist/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.d.ts.map +1 -0
  30. package/dist/utils/ErrorMapper/ErrorMapper.d.ts +15 -0
  31. package/dist/utils/ErrorMapper/ErrorMapper.d.ts.map +1 -0
  32. package/dist/utils/ErrorMapper/ErrorMapper.type.d.ts +11 -0
  33. package/dist/utils/ErrorMapper/ErrorMapper.type.d.ts.map +1 -0
  34. package/dist/utils/ErrorMapper/index.d.ts +4 -0
  35. package/dist/utils/ErrorMapper/index.d.ts.map +1 -0
  36. package/dist/utils/ErrorTypeToStationError.d.ts +1 -1
  37. package/dist/utils/ErrorTypeToStationError.d.ts.map +1 -1
  38. package/package.json +3 -3
  39. package/src/components/Accordion/Accordion.scss +1 -1
  40. package/src/components/Accordion/AccordionItem/AccordionItem.scss +1 -1
  41. package/src/components/Actions/Action/Action.scss +0 -2
  42. package/src/components/Actions/Actions.models.ts +0 -14
  43. package/src/components/Actions/Actions.stories.tsx +4 -1
  44. package/src/components/Buttons/Button/Button.scss +66 -20
  45. package/src/components/Buttons/CompositeButton/CompositeButton.scss +50 -18
  46. package/src/components/Buttons/TextButton/TextButton.scss +45 -16
  47. package/src/components/DateTime/DatePicker/DatePicker.scss +15 -6
  48. package/src/components/DateTime/DateTimePicker.scss +6 -2
  49. package/src/components/DynamicDataList/DynamicDataList.tsx +1 -0
  50. package/src/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.scss +15 -5
  51. package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createInputRenderer/createInputRenderer.tsx +1 -1
  52. package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createSelectRenderer/createSelectRenderer.scss +36 -12
  53. package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createSelectRenderer/createSelectRenderer.tsx +2 -2
  54. package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.scss +26 -0
  55. package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.tsx +7 -1
  56. package/src/components/Filters/Filter/Filter.scss +8 -2
  57. package/src/components/Filters/SelectionTypes/DateTimeFilter/DateTimeFilter.scss +4 -1
  58. package/src/components/FormElements/Checkbox/Checkbox.scss +20 -0
  59. package/src/components/FormElements/CustomTags/CustomTags.scss +24 -0
  60. package/src/components/FormElements/CustomTags/CustomTags.tsx +8 -2
  61. package/src/components/FormElements/DateTimeField/DateTimeText.spec.tsx +1 -1
  62. package/src/components/FormElements/DateTimeField/DateTimeText.tsx +1 -1
  63. package/src/components/FormElements/FileUploadControl/FileUploadControl.scss +4 -2
  64. package/src/components/FormElements/FileUploadControl/FileUploadControl.tsx +12 -3
  65. package/src/components/FormElements/Radio/Radio.scss +18 -3
  66. package/src/components/FormElements/Radio/Radio.tsx +2 -2
  67. package/src/components/FormElements/Select/Select.scss +10 -0
  68. package/src/components/FormElements/SingleLineText/SingleLineText.spec.tsx +2 -2
  69. package/src/components/FormElements/SingleLineText/SingleLineText.tsx +1 -1
  70. package/src/components/FormElements/Tags/Tags.scss +14 -0
  71. package/src/components/FormElements/Tags/Tags.tsx +5 -1
  72. package/src/components/FormElements/TextArea/TextArea.spec.tsx +2 -2
  73. package/src/components/FormElements/TextArea/TextArea.tsx +1 -1
  74. package/src/components/FormElements/formStoryHelper.tsx +163 -97
  75. package/src/components/FormStation/FormStation.spec.tsx +13 -3
  76. package/src/components/FormStation/FormStation.tsx +13 -3
  77. package/src/components/InfoPanel/InfoImage/InfoImage.scss +8 -3
  78. package/src/components/InfoPanel/InfoImage/InfoImage.tsx +1 -0
  79. package/src/components/List/List.tsx +3 -1
  80. package/src/components/List/ListCheckBox/ListCheckBox.scss +8 -3
  81. package/src/components/List/ListRow/ListRow.scss +0 -4
  82. package/src/components/Loaders/ImageLoader/ImageLoader.scss +27 -21
  83. package/src/components/Loaders/ImageLoader/ImageLoader.spec.tsx +8 -12
  84. package/src/components/Loaders/ImageLoader/ImageLoader.tsx +8 -3
  85. package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.model.ts +0 -10
  86. package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.scss +0 -1
  87. package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.stories.tsx +5 -0
  88. package/src/components/index.ts +1 -1
  89. package/src/index.ts +1 -0
  90. package/src/initialize.ts +15 -12
  91. package/src/styles/variables.scss +32 -2
  92. package/src/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.spec.ts +32 -0
  93. package/src/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.tsx +33 -0
  94. package/src/utils/ErrorMapper/ErrorMapper.spec.ts +67 -0
  95. package/src/utils/ErrorMapper/ErrorMapper.ts +31 -0
  96. package/src/utils/ErrorMapper/ErrorMapper.type.ts +11 -0
  97. package/src/utils/ErrorMapper/index.ts +3 -0
  98. package/src/utils/ErrorTypeToStationError.spec.tsx +12 -0
  99. package/src/utils/ErrorTypeToStationError.tsx +5 -1
package/src/index.ts CHANGED
@@ -4,5 +4,6 @@ export * from './helpers';
4
4
  export * from './hooks';
5
5
  export * from './initialize';
6
6
  export * from './types';
7
+ export * from './utils/ErrorMapper';
7
8
  export { ErrorTypeToStationError } from './utils/ErrorTypeToStationError';
8
9
  export * from './validators';
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 showSaveIndicator: () => void = polyfill('showSaveIndicator');
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
- showSaveIndicator,
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
- showSaveIndicator: () => void;
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-arrow-button-color: $blue;
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: $light-gray;
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;
@@ -0,0 +1,32 @@
1
+ import { ErrorType } from '../../../components';
2
+ import { ApolloErrorMapper } from './ApolloErrorMapper';
3
+
4
+ describe('ApolloErrorMapper', () => {
5
+ const mockError: ErrorType = {
6
+ name: 'ApolloError',
7
+ networkError: { message: 'Network connection lost' },
8
+ };
9
+
10
+ it('should map an Apollo error with a network error', () => {
11
+ const mappedError = ApolloErrorMapper(mockError);
12
+ expect(mappedError).toEqual({
13
+ title: 'A network error occurred',
14
+ body: expect.any(Object), // You can modify the expectation here based on your needs
15
+ });
16
+ });
17
+
18
+ it('should not map an error if already mapped by a previous error mapper', () => {
19
+ const previousMappedError: ErrorType = {
20
+ title: 'Previous Error',
21
+ body: 'Previous error message',
22
+ };
23
+ const mappedError = ApolloErrorMapper(mockError, previousMappedError);
24
+ expect(mappedError).toBeUndefined();
25
+ });
26
+
27
+ it('should return undefined if it does not match the conditions', () => {
28
+ const error: ErrorType = new Error('Some other error');
29
+ const mappedError = ApolloErrorMapper(error);
30
+ expect(mappedError).toBeUndefined();
31
+ });
32
+ });
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { ErrorMapper } from '../ErrorMapper.type';
3
+
4
+ /**
5
+ * An error mapper that maps errors from the Apollo Client to more user friendly errors.
6
+ * @param error The error to map
7
+ * @param mappedError The error that was mapped by a previous error mapper
8
+ * @returns The mapped error or undefined if the error could not be mapped
9
+ */
10
+ export const ApolloErrorMapper: ErrorMapper = (error, mappedError) => {
11
+ if (!mappedError) {
12
+ const apolloError = error as {
13
+ networkError?: { message: string };
14
+ name?: string;
15
+ };
16
+
17
+ if (apolloError.name === 'ApolloError' && apolloError.networkError) {
18
+ return {
19
+ title: 'A network error occurred',
20
+ body: (
21
+ <>
22
+ <p>Please check your internet connection and try again.</p>
23
+ <>
24
+ <i>Original Error:</i>
25
+ <pre>{JSON.stringify(error, undefined, 2)}</pre>
26
+ </>
27
+ </>
28
+ ),
29
+ };
30
+ }
31
+ return undefined;
32
+ }
33
+ };
@@ -0,0 +1,67 @@
1
+ import { ErrorType } from '../../components/models';
2
+ import { mapError, setErrorMappers } from './ErrorMapper';
3
+ import { ErrorMapper } from './ErrorMapper.type';
4
+
5
+ describe('mapError', () => {
6
+ const errorMapper1: ErrorMapper = (error) => {
7
+ if (typeof error === 'string') {
8
+ return { title: 'String Error', body: error };
9
+ }
10
+ return undefined;
11
+ };
12
+
13
+ const errorMapper2: ErrorMapper = (error) => {
14
+ if (typeof error === 'number') {
15
+ return { title: 'Number Error', body: error.toString() };
16
+ }
17
+ return undefined;
18
+ };
19
+
20
+ const errorMapper3: ErrorMapper = (error) => {
21
+ if (error instanceof Error) {
22
+ return { title: 'Custom Error', body: error.message };
23
+ }
24
+ return undefined;
25
+ };
26
+
27
+ beforeEach(() => {
28
+ setErrorMappers([errorMapper1, errorMapper2, errorMapper3]);
29
+ });
30
+
31
+ afterEach(() => {
32
+ setErrorMappers([]);
33
+ });
34
+
35
+ it('should map a string error', () => {
36
+ const error: ErrorType = 'Something went wrong';
37
+ const mappedError = mapError(error);
38
+ expect(mappedError).toEqual({
39
+ title: 'String Error',
40
+ body: 'Something went wrong',
41
+ });
42
+ });
43
+
44
+ it('should map a number error', () => {
45
+ const error: ErrorType = 42;
46
+ const mappedError = mapError(error);
47
+ expect(mappedError).toEqual({ title: 'Number Error', body: '42' });
48
+ });
49
+
50
+ it('should map a custom error', () => {
51
+ const error: ErrorType = new Error('Custom error message');
52
+ const mappedError = mapError(error);
53
+ expect(mappedError).toEqual({
54
+ title: 'Custom Error',
55
+ body: 'Custom error message',
56
+ });
57
+ });
58
+
59
+ it('should return the original error if no mapper can map it', () => {
60
+ const error: ErrorType = {
61
+ title: 'Unknown Error',
62
+ body: 'Something unexpected happened',
63
+ };
64
+ const mappedError = mapError(error);
65
+ expect(mappedError).toBe(error);
66
+ });
67
+ });
@@ -0,0 +1,31 @@
1
+ import { ApolloErrorMapper } from './ApolloClient/ApolloErrorMapper';
2
+ import { ErrorMapper } from './ErrorMapper.type';
3
+
4
+ let ErrorMappers: ErrorMapper[] = [ApolloErrorMapper];
5
+
6
+ /**
7
+ * Sets the error mappers to use for mapping errors.
8
+ * By default the `ApolloErrorMapper` is registered.
9
+ * @param mappers an array of error mappers that should be used
10
+ */
11
+ export const setErrorMappers = (mappers: ErrorMapper[]): void => {
12
+ ErrorMappers = mappers;
13
+ };
14
+
15
+ /**
16
+ * Uses the currently registered error mappers to map the given error.
17
+ * To register error mappers use the `setErrorMappers` function.
18
+ * @param error the error to map
19
+ * @returns the mapped error or the original error if no mapper was able to map the error
20
+ */
21
+ export const mapError: ErrorMapper = (error) => {
22
+ const originalError = error;
23
+ let mappedError = undefined;
24
+ for (const mapper of ErrorMappers) {
25
+ const mappingResult = mapper(originalError, mappedError);
26
+ if (mappingResult !== undefined && mappingResult !== originalError) {
27
+ mappedError = mappingResult;
28
+ }
29
+ }
30
+ return mappedError ?? originalError;
31
+ };
@@ -0,0 +1,11 @@
1
+ import { ErrorType } from '../../components/models';
2
+
3
+ export interface ErrorMapper {
4
+ /**
5
+ * Maps the given error to a new error.
6
+ * @param error the error to map
7
+ * @param currentlyMappedError the error that was mapped by a previous error mapper
8
+ * @returns the mapped error or undefined if the error could not be mapped
9
+ */
10
+ (error: ErrorType, currentlyMappedError?: ErrorType): ErrorType | undefined;
11
+ }
@@ -0,0 +1,3 @@
1
+ export * from './ApolloClient/ApolloErrorMapper';
2
+ export * from './ErrorMapper';
3
+ export * from './ErrorMapper.type';
@@ -55,4 +55,16 @@ describe('ErrorTypeToStationError', () => {
55
55
  const result = ErrorTypeToStationError(error, 'custom title');
56
56
  expect(result.title).toBe('custom title');
57
57
  });
58
+
59
+ it('uses the apollo mapper by default', () => {
60
+ const error = {
61
+ name: 'ApolloError',
62
+ networkError: { message: 'test error' },
63
+ };
64
+ const result = ErrorTypeToStationError(error);
65
+ expect(result.title).toBe('A network error occurred');
66
+ const wrapper = render(<>{result.body}</>);
67
+
68
+ expect(wrapper.toString()).toContain('test error');
69
+ });
58
70
  });
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ErrorType, StationError } from '../components/models';
3
+ import { mapError } from './ErrorMapper/ErrorMapper';
3
4
 
4
5
  /**
5
6
  * Converts an `ErrorType` object into a station error.
@@ -9,10 +10,13 @@ import { ErrorType, StationError } from '../components/models';
9
10
  * @returns A station error object
10
11
  */
11
12
  export const ErrorTypeToStationError = (
12
- error?: ErrorType,
13
+ originalError?: ErrorType,
13
14
  defaultTitle = 'An error occurred.',
14
15
  defaultBody?: string,
15
16
  ): StationError => {
17
+ const error = mapError(
18
+ originalError ?? { title: defaultTitle, body: defaultBody },
19
+ );
16
20
  let stationError: StationError;
17
21
  if (isStationError(error)) {
18
22
  // we already got a station error