@axinom/mosaic-ui 0.34.0-rc.20 → 0.34.0-rc.21
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/index.es.js +2 -2
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/initialize.d.ts +3 -3
- package/dist/initialize.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/FormStation/FormStation.spec.tsx +12 -6
- package/src/components/FormStation/FormStation.tsx +6 -6
- package/src/initialize.ts +4 -4
package/dist/initialize.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AddIndicator, CustomEventEmitter, RemoveIndicator, ShowNotification } from './types/ui-config';
|
|
2
|
-
export declare enum
|
|
2
|
+
export declare enum SaveIndicatorType {
|
|
3
3
|
Saving = "saving",
|
|
4
4
|
Inactive = "inactive",
|
|
5
5
|
Dirty = "dirty"
|
|
@@ -8,7 +8,7 @@ export declare let showNotification: ShowNotification | (() => void);
|
|
|
8
8
|
export declare let addIndicator: AddIndicator | (() => void);
|
|
9
9
|
export declare let removeIndicator: RemoveIndicator | (() => void);
|
|
10
10
|
export declare let on: CustomEventEmitter['on'] | (() => void);
|
|
11
|
-
export declare let setSaveIndicator: (type:
|
|
11
|
+
export declare let setSaveIndicator: (type: SaveIndicatorType) => void;
|
|
12
12
|
/**
|
|
13
13
|
* Passes the PiralApi methods to the UI library.
|
|
14
14
|
* @param app {UiConfig} object containing PiralApi methods for use in UI library.
|
|
@@ -19,6 +19,6 @@ export interface UiConfig {
|
|
|
19
19
|
addIndicator: AddIndicator;
|
|
20
20
|
removeIndicator: RemoveIndicator;
|
|
21
21
|
on: CustomEventEmitter['on'];
|
|
22
|
-
setSaveIndicator: (type:
|
|
22
|
+
setSaveIndicator: (type: SaveIndicatorType) => void;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=initialize.d.ts.map
|
package/dist/initialize.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../src/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,oBAAY,
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../src/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,oBAAY,iBAAiB;IAC3B,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AAED,eAAO,IAAI,gBAAgB,EAAE,gBAAgB,GAAG,CAAC,MAAM,IAAI,CAC7B,CAAC;AAE/B,eAAO,IAAI,YAAY,EAAE,YAAY,GAAG,CAAC,MAAM,IAAI,CAA4B,CAAC;AAEhF,eAAO,IAAI,eAAe,EAAE,eAAe,GAAG,CAAC,MAAM,IAAI,CAC5B,CAAC;AAE9B,eAAO,IAAI,EAAE,EAAE,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAkB,CAAC;AAExE,eAAO,IAAI,gBAAgB,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAC5B,CAAC;AAE/B;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAQhD;AAED,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,EAAE,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC7B,gBAAgB,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACrD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-ui",
|
|
3
|
-
"version": "0.34.0-rc.
|
|
3
|
+
"version": "0.34.0-rc.21",
|
|
4
4
|
"description": "UI components for building Axinom Mosaic applications",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"build-storybook": "storybook build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@axinom/mosaic-core": "^0.4.7-rc.
|
|
35
|
+
"@axinom/mosaic-core": "^0.4.7-rc.21",
|
|
36
36
|
"@faker-js/faker": "^7.4.0",
|
|
37
37
|
"@popperjs/core": "^2.9.2",
|
|
38
38
|
"clsx": "^1.1.0",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "df13367a88d317969e5b2c3960268938fa07c41f"
|
|
106
106
|
}
|
|
@@ -5,7 +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 {
|
|
8
|
+
import { SaveIndicatorType, setSaveIndicator } from '../../initialize';
|
|
9
9
|
import { ActionData, Actions } from '../Actions';
|
|
10
10
|
import { Action } from '../Actions/Action';
|
|
11
11
|
import { MessageBar } from '../MessageBar/MessageBar';
|
|
@@ -677,9 +677,12 @@ describe('Details', () => {
|
|
|
677
677
|
);
|
|
678
678
|
expect(setSaveIndicator).toHaveBeenNthCalledWith(
|
|
679
679
|
1,
|
|
680
|
-
|
|
681
|
-
); // 1. inactive
|
|
682
|
-
expect(setSaveIndicator).toHaveBeenNthCalledWith(
|
|
680
|
+
SaveIndicatorType.Inactive,
|
|
681
|
+
); // 1. inactive
|
|
682
|
+
expect(setSaveIndicator).toHaveBeenNthCalledWith(
|
|
683
|
+
3,
|
|
684
|
+
SaveIndicatorType.Dirty,
|
|
685
|
+
); // 3. dirty
|
|
683
686
|
|
|
684
687
|
// submit form
|
|
685
688
|
const actionSelected = wrapper
|
|
@@ -697,7 +700,10 @@ describe('Details', () => {
|
|
|
697
700
|
|
|
698
701
|
wrapper.update();
|
|
699
702
|
|
|
700
|
-
expect(setSaveIndicator).toHaveBeenNthCalledWith(
|
|
703
|
+
expect(setSaveIndicator).toHaveBeenNthCalledWith(
|
|
704
|
+
4,
|
|
705
|
+
SaveIndicatorType.Saving,
|
|
706
|
+
);
|
|
701
707
|
|
|
702
708
|
// complete form submission
|
|
703
709
|
await act(async () => {
|
|
@@ -707,7 +713,7 @@ describe('Details', () => {
|
|
|
707
713
|
|
|
708
714
|
expect(setSaveIndicator).toHaveBeenNthCalledWith(
|
|
709
715
|
5,
|
|
710
|
-
|
|
716
|
+
SaveIndicatorType.Inactive,
|
|
711
717
|
);
|
|
712
718
|
|
|
713
719
|
console.warn((setSaveIndicator as jest.Mock).mock.calls);
|
|
@@ -16,7 +16,7 @@ import React, {
|
|
|
16
16
|
} from 'react';
|
|
17
17
|
import { useHistory } from 'react-router-dom';
|
|
18
18
|
import { OptionalObjectSchema } from 'yup/lib/object';
|
|
19
|
-
import {
|
|
19
|
+
import { SaveIndicatorType, setSaveIndicator } from '../../initialize';
|
|
20
20
|
import { Data } from '../../types/data';
|
|
21
21
|
import { ErrorTypeToStationError } from '../../utils/ErrorTypeToStationError';
|
|
22
22
|
import { Actions, ActionsProps } from '../Actions';
|
|
@@ -155,7 +155,7 @@ export const FormStation = <TValues extends Data, TSubmitResponse = unknown>({
|
|
|
155
155
|
|
|
156
156
|
try {
|
|
157
157
|
setIsFormSubmitting(true);
|
|
158
|
-
setSaveIndicator(
|
|
158
|
+
setSaveIndicator(SaveIndicatorType.Saving);
|
|
159
159
|
setStationError(undefined);
|
|
160
160
|
if (!initialData.loading && saveData) {
|
|
161
161
|
const response = await saveData(values, initialData, formikHelpers);
|
|
@@ -171,7 +171,7 @@ export const FormStation = <TValues extends Data, TSubmitResponse = unknown>({
|
|
|
171
171
|
),
|
|
172
172
|
);
|
|
173
173
|
|
|
174
|
-
setSaveIndicator(
|
|
174
|
+
setSaveIndicator(SaveIndicatorType.Dirty);
|
|
175
175
|
|
|
176
176
|
// We still throw the error, to make sure that navigation or action execution
|
|
177
177
|
// will not continue after a failed save.
|
|
@@ -449,15 +449,15 @@ const FormStationHeader: React.FC<
|
|
|
449
449
|
useEffect(() => {
|
|
450
450
|
// Set the save indicator to dirty depending on the form state
|
|
451
451
|
if (dirty) {
|
|
452
|
-
setSaveIndicator(
|
|
452
|
+
setSaveIndicator(SaveIndicatorType.Dirty);
|
|
453
453
|
} else {
|
|
454
|
-
setSaveIndicator(
|
|
454
|
+
setSaveIndicator(SaveIndicatorType.Inactive);
|
|
455
455
|
}
|
|
456
456
|
return () => {
|
|
457
457
|
// The form is not always considered "not dirty" after the save
|
|
458
458
|
// so this code will make sure that the indicator is set to inactive
|
|
459
459
|
// when the station is left.
|
|
460
|
-
setSaveIndicator(
|
|
460
|
+
setSaveIndicator(SaveIndicatorType.Inactive);
|
|
461
461
|
};
|
|
462
462
|
}, [dirty]);
|
|
463
463
|
|
package/src/initialize.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ShowNotification,
|
|
6
6
|
} from './types/ui-config';
|
|
7
7
|
|
|
8
|
-
export enum
|
|
8
|
+
export enum SaveIndicatorType {
|
|
9
9
|
Saving = 'saving',
|
|
10
10
|
Inactive = 'inactive',
|
|
11
11
|
Dirty = 'dirty',
|
|
@@ -21,8 +21,8 @@ export let removeIndicator: RemoveIndicator | (() => void) =
|
|
|
21
21
|
|
|
22
22
|
export let on: CustomEventEmitter['on'] | (() => void) = polyfill('on');
|
|
23
23
|
|
|
24
|
-
export let setSaveIndicator: (type:
|
|
25
|
-
polyfill('
|
|
24
|
+
export let setSaveIndicator: (type: SaveIndicatorType) => void =
|
|
25
|
+
polyfill('setSaveIndicator');
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Passes the PiralApi methods to the UI library.
|
|
@@ -43,7 +43,7 @@ export interface UiConfig {
|
|
|
43
43
|
addIndicator: AddIndicator;
|
|
44
44
|
removeIndicator: RemoveIndicator;
|
|
45
45
|
on: CustomEventEmitter['on'];
|
|
46
|
-
setSaveIndicator: (type:
|
|
46
|
+
setSaveIndicator: (type: SaveIndicatorType) => void;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function polyfill(methodName: string): () => void {
|