@transferwise/components 40.8.3 → 40.8.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [40.8.4](https://github.com/transferwise/neptune-web/compare/@transferwise/components@40.8.3...@transferwise/components@40.8.4) (2022-05-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * types for `useConditionalListener` hooks ([#1437](https://github.com/transferwise/neptune-web/issues/1437)) ([f2ccb49](https://github.com/transferwise/neptune-web/commit/f2ccb492ea8624f01e077c3b2d001667c9deeb46))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [40.8.3](https://github.com/transferwise/neptune-web/compare/@transferwise/components@40.8.2...@transferwise/components@40.8.3) (2022-05-04)
7
18
 
8
19
 
@@ -1,12 +1,3 @@
1
- import{isUndefined}from"@transferwise/neptune-validation";import{useEffect}from"react";/**
2
- * useConditionalListener attaches an event to the document when a condition is met.
3
- *
4
- * @param {bool} attachListener - condition to be met for the listener to be attached
5
- * @param {Function} callback - function registered with the event listener
6
- * @param {string} eventType - type of event to attach to document
7
- * @usage `useConditionalListener({
8
- * eventType: 'click',
9
- * callback,
10
- * attachListener: condition,
11
- * });`
12
- */export var useConditionalListener=function(a){var b=a.attachListener,c=a.callback,d=a.eventType,e=a.parent;useEffect(function(){return b&&!isUndefined(e)&&e.addEventListener(d,c,!0),function(){isUndefined(e)||e.removeEventListener(d,c,!0)}},[b])};
1
+ // @ts-expect-error remove this when `@transferwise/neptune-validation` provides types
2
+ import{isUndefined}from"@transferwise/neptune-validation";import{useEffect}from"react";export var useConditionalListener=function(a){var b=a.attachListener,c=a.callback,d=a.eventType,e=a.parent;useEffect(function(){return b&&// eslint-disable-next-line @typescript-eslint/no-unsafe-call
3
+ !isUndefined(e)&&e.addEventListener(d,c,!0),function(){isUndefined(e)||e.removeEventListener(d,c,!0)}},[b,c,d,e])};
@@ -1,12 +1,3 @@
1
- import{isUndefined}from"@transferwise/neptune-validation";import{useEffect}from"react";/**
2
- * useConditionalListener attaches an event to the document when a condition is met.
3
- *
4
- * @param {bool} attachListener - condition to be met for the listener to be attached
5
- * @param {Function} callback - function registered with the event listener
6
- * @param {string} eventType - type of event to attach to document
7
- * @usage `useConditionalListener({
8
- * eventType: 'click',
9
- * callback,
10
- * attachListener: condition,
11
- * });`
12
- */export var useConditionalListener=function(a){var b=a.attachListener,c=a.callback,d=a.eventType,e=a.parent;useEffect(function(){return b&&!isUndefined(e)&&e.addEventListener(d,c,!0),function(){isUndefined(e)||e.removeEventListener(d,c,!0)}},[b])};
1
+ // @ts-expect-error remove this when `@transferwise/neptune-validation` provides types
2
+ import{isUndefined}from"@transferwise/neptune-validation";import{useEffect}from"react";export var useConditionalListener=function(a){var b=a.attachListener,c=a.callback,d=a.eventType,e=a.parent;useEffect(function(){return b&&// eslint-disable-next-line @typescript-eslint/no-unsafe-call
3
+ !isUndefined(e)&&e.addEventListener(d,c,!0),function(){isUndefined(e)||e.removeEventListener(d,c,!0)}},[b,c,d,e])};
@@ -15,6 +15,7 @@ export declare type LinkProps = {
15
15
  target?: '_blank' | '_self' | '_parent' | '_top';
16
16
  };
17
17
  export declare type Heading = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
18
+ export declare type ParentElement = HTMLElement | Window | Document;
18
19
  export declare type OnClickHandler = {
19
20
  onClick: (event: Event) => void;
20
21
  };
@@ -1 +1,9 @@
1
- export function useConditionalListener({ attachListener, callback, eventType, parent }: bool): void;
1
+ import { ParentElement } from '../..';
2
+ declare type Data = {
3
+ attachListener: boolean;
4
+ callback: EventListenerOrEventListenerObject;
5
+ eventType: string;
6
+ parent: ParentElement | undefined;
7
+ };
8
+ export declare const useConditionalListener: ({ attachListener, callback, eventType, parent }: Data) => void;
9
+ export {};