@limetech/lime-web-components-interfaces
Advanced tools
Comparing version 4.43.0 to 4.44.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [4.44.0](https://github.com/Lundalogik/lime-web-components/compare/v4.43.0...v4.44.0) (2022-04-21) | ||
### Features | ||
* **navigation:** add interface to block navigation ([c60f895](https://github.com/Lundalogik/lime-web-components/commit/c60f8952b09f4ee1b703f702984553d0308af828)), closes [Lundalogik/crm-feature#2767](https://github.com/Lundalogik/crm-feature/issues/2767) | ||
# [4.43.0](https://github.com/Lundalogik/lime-web-components/compare/v4.42.2...v4.43.0) (2022-04-21) | ||
@@ -8,0 +19,0 @@ |
@@ -59,2 +59,46 @@ /** | ||
getLocation(): Location; | ||
/** | ||
* Add a blocker that can prevent navigation away from the current page, for | ||
* example when there is some unsaved data that would otherwise be discarded. | ||
* | ||
* If the blocker function returns true navigation is blocked. If it returns | ||
* false navigation will proceed as normal, if not blocked by other blockers. | ||
* | ||
* To later on resume navigation that was blocked, you may save away the new | ||
* location provided to the blocker function. | ||
* | ||
* @note Blockers are not guaranteed to be executed upon a navigation event. | ||
* Blockers will be executed until either all returns false or up until one | ||
* of them returns true. | ||
* | ||
* @example | ||
* navigator.addBlocker(myBlocker); | ||
* | ||
* let blocked = null; | ||
* | ||
* function myBlocker(newLocation) { | ||
* if (!blocked) { | ||
* showConfirmDialog().then(retry); | ||
* } | ||
* blocked = newLocation; | ||
* return true; | ||
* } | ||
* | ||
* function retry(yes) { | ||
* if (yes) { | ||
* navigator.removeBlocker(myBlocker); | ||
* navigator.navigate(blocked); | ||
* } | ||
* blocked = null; | ||
* } | ||
* | ||
* @param {Blocker} blocker function to be called before navigation | ||
*/ | ||
addBlocker(blocker: Blocker): void; | ||
/** | ||
* Removes a previously configured blocker. | ||
* | ||
* @param {Blocker} blocker previously added blocker function | ||
*/ | ||
removeBlocker(blocker: Blocker): void; | ||
} | ||
@@ -91,1 +135,9 @@ export declare type Location = { | ||
export declare type NavigationEvent = CustomEvent<Location>; | ||
/** | ||
* Function to determine if navigation should be blocked or not. | ||
* | ||
* @param {Location} newLocation location to navigate to | ||
* @param {Location} currentLocation current location before navigation | ||
* @returns true if navigation should be blocked | ||
*/ | ||
export declare type Blocker = (newLocation: Location, currentLocation: Location) => boolean; |
{ | ||
"name": "@limetech/lime-web-components-interfaces", | ||
"version": "4.43.0", | ||
"version": "4.44.0", | ||
"author": "Lime Technologies", | ||
@@ -33,3 +33,3 @@ "homepage": "https://github.com/Lundalogik/lime-web-components", | ||
}, | ||
"gitHead": "374ea677ed896ad4877f729d3f4d9ef2656fdfb6" | ||
"gitHead": "2aa4c04f6a2d570501abecb35e0049ebeabc1fd4" | ||
} |
88678
2012