@salla.sa/twilight 2.0.254 → 2.0.255
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {RequestError} from "../common";
|
|
2
2
|
|
|
3
3
|
export interface requestPayload {
|
|
4
4
|
namespace: string | 'cart';
|
|
@@ -10,6 +10,7 @@ export interface requestPayload {
|
|
|
10
10
|
headers?: {};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
|
|
13
14
|
export default interface DocumentEvent {
|
|
14
15
|
onClick: (selector: string | ((event) => void), callback?: (event) => void) => void;
|
|
15
16
|
onChange: (selector: string | ((event) => void), callback?: (event) => void) => void;
|
|
@@ -18,4 +19,11 @@ export default interface DocumentEvent {
|
|
|
18
19
|
onLeaving: (event: BeforeUnloadEvent) => boolean; //return false to show alert 'Changes you made may not be saved.'
|
|
19
20
|
onRequest: (payload: requestPayload) => void; //💡handy when there is need to prevent request by throwing an error `throw 'stop the request';`.
|
|
20
21
|
onRequestFailed: (payload: requestPayload, error?: RequestError) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Helper method to fake firing event on element, for
|
|
24
|
+
* @example someInput.addEventListener("change",()=>{...});
|
|
25
|
+
* we want to fire this event programmatically, we can do that by:
|
|
26
|
+
* @example salla.document.event.fireEvent(someInput, 'change', {'bubbles': true})
|
|
27
|
+
*/
|
|
28
|
+
fireEvent: (element: HTMLElement, eventName: 'click' | 'change' | string, payload: undefined | Object) => void;
|
|
21
29
|
}
|