openapi-explorer 2.1.642 → 2.1.643
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/browser/openapi-explorer.min.js +1 -1
- package/dist/es/react.js +32 -0
- package/dist/lib/react.js +37 -0
- package/package.json +1 -1
package/dist/es/react.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* reactEventListener - takes the hard work out of adding and removing listeners in React
|
3
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener}
|
4
|
+
*
|
5
|
+
* @param {object} React - The React object that contains the method { useEffect }.
|
6
|
+
* @param {string} eventName - A case-sensitive string or strings representing the event type to listen for
|
7
|
+
* @param {function} callbackFunction - callback function - The object that receives a notification (an object that implements the Event interface) when an event of the specified type occurs
|
8
|
+
*/
|
9
|
+
export function reactEventListener({
|
10
|
+
useEffect
|
11
|
+
}, eventName, functionCallback) {
|
12
|
+
const targetElement = window;
|
13
|
+
useEffect(() => {
|
14
|
+
targetElement.addEventListener(eventName, functionCallback); // This is an effect that requires cleanup when the component using this
|
15
|
+
// custom hook unmounts:
|
16
|
+
// https://reactjs.org/docs/hooks-effect.html#effects-with-cleanup
|
17
|
+
|
18
|
+
return () => {
|
19
|
+
// Check if the event functionCallback we were given was a debounced or throttled
|
20
|
+
// event functionCallback, if it is, cancel any future events
|
21
|
+
// https://github.com/niksy/throttle-debounce#cancelling
|
22
|
+
if (functionCallback !== null && functionCallback !== void 0 && functionCallback.cancel) {
|
23
|
+
functionCallback.cancel();
|
24
|
+
} // Remove the event functionCallbacks
|
25
|
+
|
26
|
+
|
27
|
+
if (targetElement !== null && targetElement !== void 0 && targetElement.removeEventListener) {
|
28
|
+
targetElement.removeEventListener(eventName, functionCallback);
|
29
|
+
}
|
30
|
+
};
|
31
|
+
}, [eventName, functionCallback, targetElement]);
|
32
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.reactEventListener = reactEventListener;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* reactEventListener - takes the hard work out of adding and removing listeners in React
|
8
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener}
|
9
|
+
*
|
10
|
+
* @param {object} React - The React object that contains the method { useEffect }.
|
11
|
+
* @param {string} eventName - A case-sensitive string or strings representing the event type to listen for
|
12
|
+
* @param {function} callbackFunction - callback function - The object that receives a notification (an object that implements the Event interface) when an event of the specified type occurs
|
13
|
+
*/
|
14
|
+
function reactEventListener({
|
15
|
+
useEffect
|
16
|
+
}, eventName, functionCallback) {
|
17
|
+
const targetElement = window;
|
18
|
+
useEffect(() => {
|
19
|
+
targetElement.addEventListener(eventName, functionCallback); // This is an effect that requires cleanup when the component using this
|
20
|
+
// custom hook unmounts:
|
21
|
+
// https://reactjs.org/docs/hooks-effect.html#effects-with-cleanup
|
22
|
+
|
23
|
+
return () => {
|
24
|
+
// Check if the event functionCallback we were given was a debounced or throttled
|
25
|
+
// event functionCallback, if it is, cancel any future events
|
26
|
+
// https://github.com/niksy/throttle-debounce#cancelling
|
27
|
+
if (functionCallback !== null && functionCallback !== void 0 && functionCallback.cancel) {
|
28
|
+
functionCallback.cancel();
|
29
|
+
} // Remove the event functionCallbacks
|
30
|
+
|
31
|
+
|
32
|
+
if (targetElement !== null && targetElement !== void 0 && targetElement.removeEventListener) {
|
33
|
+
targetElement.removeEventListener(eventName, functionCallback);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
}, [eventName, functionCallback, targetElement]);
|
37
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "openapi-explorer",
|
3
|
-
"version": "2.1.
|
3
|
+
"version": "2.1.643",
|
4
4
|
"description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
|
5
5
|
"author": "Authress Developers <developers@authress.io>",
|
6
6
|
"type": "module",
|