dce-reactkit 5.0.8 → 5.0.9
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/cjs/index.js +300 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/useBackButton.d.ts +20 -0
- package/dist/cjs/types/index.d.ts +4 -1
- package/dist/cjs/types/types/BackButtonController.d.ts +40 -0
- package/dist/cjs/types/types/BackState.d.ts +11 -0
- package/dist/esm/index.js +298 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/useBackButton.d.ts +20 -0
- package/dist/esm/types/index.d.ts +4 -1
- package/dist/esm/types/types/BackButtonController.d.ts +40 -0
- package/dist/esm/types/types/BackState.d.ts +11 -0
- package/dist/index.d.ts +70 -1
- package/package.json +1 -1
- package/src/components/ItemPicker/NestableItemList.tsx +44 -42
- package/src/helpers/useBackButton.tsx +352 -0
- package/src/index.ts +7 -0
- package/src/types/BackButtonController.ts +43 -0
- package/src/types/BackState.ts +15 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Import types
|
|
2
|
+
import BackState from './BackState';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Controller for the back button, used to drive back navigation from anywhere
|
|
6
|
+
* in the app. Pass this to subpanels so they can describe their state and
|
|
7
|
+
* send the user home.
|
|
8
|
+
* @author Yuen Ler Chow
|
|
9
|
+
*/
|
|
10
|
+
type BackButtonController = {
|
|
11
|
+
/**
|
|
12
|
+
* Call this when the user navigates to a child of the home screen (something
|
|
13
|
+
* they can come back from)
|
|
14
|
+
*/
|
|
15
|
+
onSubpanelEntered: () => void,
|
|
16
|
+
/**
|
|
17
|
+
* Send the user back to the home screen
|
|
18
|
+
* @param [force] if true, go home immediately without checking the subpanel
|
|
19
|
+
* state (no confirmation, not blocked). If falsy, nothing happens when
|
|
20
|
+
* blocked and confirmation is required when there are unsaved changes
|
|
21
|
+
*/
|
|
22
|
+
goHome: (force?: boolean) => Promise<void>,
|
|
23
|
+
/**
|
|
24
|
+
* Set the state of the current subpanel, which determines what happens when
|
|
25
|
+
* the user tries to go back
|
|
26
|
+
* @param newSubpanelState the new state of the subpanel
|
|
27
|
+
*/
|
|
28
|
+
setSubpanelState: (newSubpanelState: BackState) => void,
|
|
29
|
+
/**
|
|
30
|
+
* Set the confirmation message shown if the user tries to go back while there
|
|
31
|
+
* are unsaved changes (cleared upon returning to the home screen)
|
|
32
|
+
* @param message the message to show
|
|
33
|
+
*/
|
|
34
|
+
setCustomUnsavedChangesMessage: (message: string) => void,
|
|
35
|
+
/**
|
|
36
|
+
* Set the message shown if the user tries to go back while blocked (cleared
|
|
37
|
+
* upon returning to the home screen)
|
|
38
|
+
* @param message the message to show
|
|
39
|
+
*/
|
|
40
|
+
setCustomBlockedMessage: (message: string) => void,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default BackButtonController;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State of the current subpanel, determining what happens when the user tries
|
|
3
|
+
* to go back to the home screen
|
|
4
|
+
* @author Yuen Ler Chow
|
|
5
|
+
*/
|
|
6
|
+
enum BackState {
|
|
7
|
+
// The user can go back immediately, no confirmation required
|
|
8
|
+
Normal = 'Normal',
|
|
9
|
+
// The user must confirm before going back because progress will be lost
|
|
10
|
+
UnsavedChanges = 'UnsavedChanges',
|
|
11
|
+
// The user cannot go back right now because work is in progress
|
|
12
|
+
Blocked = 'Blocked',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default BackState;
|