1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | const __chunk_1 = require('./stencilrouter-a3d77a87.js');
|
6 | const __chunk_2 = require('./chunk-94c92d88.js');
|
7 |
|
8 | class StencilRouterPrompt {
|
9 | constructor(hostRef) {
|
10 | __chunk_1.registerInstance(this, hostRef);
|
11 | this.when = true;
|
12 | this.message = '';
|
13 | }
|
14 | enable(message) {
|
15 | if (this.unblock) {
|
16 | this.unblock();
|
17 | }
|
18 | if (this.history) {
|
19 | this.unblock = this.history.block(message);
|
20 | }
|
21 | }
|
22 | disable() {
|
23 | if (this.unblock) {
|
24 | this.unblock();
|
25 | this.unblock = undefined;
|
26 | }
|
27 | }
|
28 | componentWillLoad() {
|
29 | if (this.when) {
|
30 | this.enable(this.message);
|
31 | }
|
32 | }
|
33 | updateMessage(newMessage, prevMessage) {
|
34 | if (this.when) {
|
35 | if (!this.when || prevMessage !== newMessage) {
|
36 | this.enable(this.message);
|
37 | }
|
38 | }
|
39 | else {
|
40 | this.disable();
|
41 | }
|
42 | }
|
43 | componentDidUnload() {
|
44 | this.disable();
|
45 | }
|
46 | render() {
|
47 | return null;
|
48 | }
|
49 | get el() { return __chunk_1.getElement(this); }
|
50 | static get watchers() { return {
|
51 | "message": ["updateMessage"],
|
52 | "when": ["updateMessage"]
|
53 | }; }
|
54 | }
|
55 | __chunk_2.ActiveRouter.injectProps(StencilRouterPrompt, [
|
56 | 'history',
|
57 | ]);
|
58 |
|
59 | exports.stencil_router_prompt = StencilRouterPrompt;
|