blue-react 8.0.0-next.4 → 8.0.0-next.5
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/components/Layout.js +30 -9
- package/dist/style.css +2 -2
- package/dist/style.min.css +2 -2
- package/dist/style.scss +1 -1
- package/dist/types/components/Layout.d.ts +15 -7
- package/package.json +1 -1
|
@@ -41,16 +41,23 @@ window.toggleSidebarEvent = new CustomEvent("toggleSidebar");
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* The main component. As soon this component is mounted, it is globally available under `window.blueLayoutRef`.
|
|
44
|
-
*
|
|
44
|
+
* You can also append your own event listeners.
|
|
45
45
|
*
|
|
46
|
-
* Allowed
|
|
46
|
+
* Allowed events:
|
|
47
47
|
*
|
|
48
48
|
* * **componentDidUpdate** - Component was updated.
|
|
49
|
-
* Example: `blueLayoutRef.addEventListener("componentDidUpdate", (prevProps, prevState) => { })`
|
|
49
|
+
* Example: `window.blueLayoutRef.addEventListener("componentDidUpdate", (prevProps, prevState) => { })`
|
|
50
50
|
* * **pageDidShowAgain** - Page appeared again with the same old state. In the callback function you can reinitialize things.
|
|
51
|
-
* Example: `blueLayoutRef.addEventListener("pageDidShowAgain", "home", (prevProps, prevState) => { })`
|
|
51
|
+
* Example: `window.blueLayoutRef.addEventListener("pageDidShowAgain", "home", (prevProps, prevState) => { })`
|
|
52
52
|
* * **pageDidHide** - This page disappeared and another page appears instead.
|
|
53
|
-
* Example: `blueLayoutRef.addEventListener("pageDidHide", "home", (prevProps, prevState) => { })`
|
|
53
|
+
* Example: `window.blueLayoutRef.addEventListener("pageDidHide", "home", (prevProps, prevState) => { })`
|
|
54
|
+
*
|
|
55
|
+
* Method to add event listeners:
|
|
56
|
+
* * `window.blueLayoutRef.`**addEventListener**`(eventName: string, param2: any, param3: any, listenerId?: string)`
|
|
57
|
+
*
|
|
58
|
+
* Methods to remove event listeners:
|
|
59
|
+
* * `window.blueLayoutRef.`**removeEventListener**`(eventName: string, listenerId: string)`
|
|
60
|
+
* * `window.blueLayoutRef.`**removeDuplicatedEventListeners**`()` - Will automatically be called when running `addEventListener`
|
|
54
61
|
*/
|
|
55
62
|
var Layout = /*#__PURE__*/function (_Component) {
|
|
56
63
|
_inherits(Layout, _Component);
|
|
@@ -198,14 +205,28 @@ var Layout = /*#__PURE__*/function (_Component) {
|
|
|
198
205
|
}
|
|
199
206
|
}, {
|
|
200
207
|
key: "addEventListener",
|
|
201
|
-
value: function addEventListener(param1, param2, param3) {
|
|
202
|
-
this.eventListeners.push([param1, param2, param3]);
|
|
208
|
+
value: function addEventListener(param1, param2, param3, listenerId) {
|
|
209
|
+
this.eventListeners.push([param1, param2, param3, listenerId]);
|
|
210
|
+
this.removeDuplicatedEventListeners();
|
|
203
211
|
}
|
|
204
212
|
}, {
|
|
205
213
|
key: "removeEventListener",
|
|
206
|
-
value: function removeEventListener(type,
|
|
214
|
+
value: function removeEventListener(type, listenerId) {
|
|
207
215
|
this.eventListeners = this.eventListeners.filter(function (param) {
|
|
208
|
-
|
|
216
|
+
if (param[0] !== type) {
|
|
217
|
+
return param;
|
|
218
|
+
} else if (param[0] === type && param[3] !== listenerId) {
|
|
219
|
+
return param;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}, {
|
|
224
|
+
key: "removeDuplicatedEventListeners",
|
|
225
|
+
value: function removeDuplicatedEventListeners() {
|
|
226
|
+
this.eventListeners = this.eventListeners.filter(function (value, index, self) {
|
|
227
|
+
return index === self.findIndex(function (t) {
|
|
228
|
+
return t[3] === value[3] && t[0] === value[0];
|
|
229
|
+
});
|
|
209
230
|
});
|
|
210
231
|
}
|
|
211
232
|
}, {
|