@pushwoosh/kit-helpers 4.8.4 → 4.8.6
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.
|
@@ -600,7 +600,7 @@ const cleanup = elementAddListeners(
|
|
|
600
600
|
- **Path:** `~/src/hooks/useClickAway`
|
|
601
601
|
- **Description:** Subscribes to clicks outside an element
|
|
602
602
|
- **Signature:**
|
|
603
|
-
```
|
|
603
|
+
```typescript
|
|
604
604
|
subscribeClickAway<T extends HTMLElement>(
|
|
605
605
|
element: T,
|
|
606
606
|
callback: (event: MouseEvent | TouchEvent) => void
|
package/hooks/useClickAway.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ type ClickAwayCallback = (event: MouseEvent | TouchEvent) => void;
|
|
|
7
7
|
* @param listener The callback function to execute when the event occurs.
|
|
8
8
|
* @returns A function to remove the added event listeners.
|
|
9
9
|
*/
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function elementAddListener<K extends keyof HTMLElementEventMap, E extends HTMLElement>(element: E | Document, // Allow Document as well
|
|
11
11
|
eventNames: K | K[], listener: (this: E | Document, ev: HTMLElementEventMap[K]) => void): () => void;
|
|
12
12
|
/**
|
|
13
13
|
* Subscribes to mousedown/touchstart events outside a given element.
|
package/hooks/useClickAway.js
CHANGED
|
@@ -7,7 +7,7 @@ import usePersistentFunction from './usePersistentFunction';
|
|
|
7
7
|
* @param listener The callback function to execute when the event occurs.
|
|
8
8
|
* @returns A function to remove the added event listeners.
|
|
9
9
|
*/
|
|
10
|
-
export function
|
|
10
|
+
export function elementAddListener(element,
|
|
11
11
|
// Allow Document as well
|
|
12
12
|
eventNames, listener) {
|
|
13
13
|
const eventNamesArray = Array.isArray(eventNames) ? eventNames : [eventNames];
|
|
@@ -28,7 +28,7 @@ eventNames, listener) {
|
|
|
28
28
|
*/
|
|
29
29
|
export function subscribeClickAway(element, callback) {
|
|
30
30
|
// Use document directly, no need for 'any' cast
|
|
31
|
-
return
|
|
31
|
+
return elementAddListener(document, ['mousedown', 'touchstart'], event => {
|
|
32
32
|
// Type assertion for event target
|
|
33
33
|
const target = event.target;
|
|
34
34
|
// Check if the element exists and the click target is outside the element
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/kit-helpers",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.6",
|
|
4
4
|
"description": "React component for build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "npm run playground",
|
|
11
|
-
"build": "pushwoosh-engine lib:build && cp ai-documentation.
|
|
11
|
+
"build": "pushwoosh-engine lib:build && cp ai-documentation.md dist/ai-documentation.md",
|
|
12
12
|
"playground": "pushwoosh-engine lib:playground",
|
|
13
13
|
"check": "npm run check:lint && npm run check:types",
|
|
14
14
|
"check:lint": "echo \"Run check:lint\" && eslint .",
|