@bitrise/bitkit 9.4.0 → 9.5.0-alpha.2

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.
Files changed (64) hide show
  1. package/.eslintrc.js +8 -1
  2. package/.husky/commit-msg +4 -0
  3. package/.nvmrc +1 -1
  4. package/.stylelintrc +2 -3
  5. package/CHANGELOG.md +10 -1
  6. package/bitrise.yml +32 -28
  7. package/jest.setup.js +2 -1
  8. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.d.ts +6 -3
  9. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.d.ts.map +1 -1
  10. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.js +13 -6
  11. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -1
  12. package/lib/cjs/Dropdown/Dropdown.d.ts.map +1 -1
  13. package/lib/cjs/Dropdown/Dropdown.js +9 -8
  14. package/lib/cjs/Dropdown/Dropdown.js.map +1 -1
  15. package/lib/cjs/Dropdown/DropdownMenu.css +1 -1
  16. package/lib/cjs/Placement/Placement.css +17 -35
  17. package/lib/cjs/Placement/Placement.d.ts +5 -8
  18. package/lib/cjs/Placement/Placement.d.ts.map +1 -1
  19. package/lib/cjs/Placement/Placement.js.map +1 -1
  20. package/lib/cjs/Placement/PlacementPopper.d.ts +3 -4
  21. package/lib/cjs/Placement/PlacementPopper.d.ts.map +1 -1
  22. package/lib/cjs/Placement/PlacementPopper.js +32 -17
  23. package/lib/cjs/Placement/PlacementPopper.js.map +1 -1
  24. package/lib/cjs/Tooltip/Tooltip.d.ts +1 -1
  25. package/lib/cjs/Tooltip/Tooltip.d.ts.map +1 -1
  26. package/lib/cjs/hooks/useEventListener.d.ts.map +1 -1
  27. package/lib/cjs/hooks/useEventListener.js +0 -1
  28. package/lib/cjs/hooks/useEventListener.js.map +1 -1
  29. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  30. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.d.ts +6 -3
  31. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.d.ts.map +1 -1
  32. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.js +10 -3
  33. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -1
  34. package/lib/esn/Dropdown/Dropdown.d.ts.map +1 -1
  35. package/lib/esn/Dropdown/Dropdown.js +9 -5
  36. package/lib/esn/Dropdown/Dropdown.js.map +1 -1
  37. package/lib/esn/Dropdown/DropdownMenu.css +1 -1
  38. package/lib/esn/Placement/Placement.css +17 -35
  39. package/lib/esn/Placement/Placement.d.ts +5 -8
  40. package/lib/esn/Placement/Placement.d.ts.map +1 -1
  41. package/lib/esn/Placement/Placement.js.map +1 -1
  42. package/lib/esn/Placement/PlacementPopper.d.ts +3 -4
  43. package/lib/esn/Placement/PlacementPopper.d.ts.map +1 -1
  44. package/lib/esn/Placement/PlacementPopper.js +44 -29
  45. package/lib/esn/Placement/PlacementPopper.js.map +1 -1
  46. package/lib/esn/Tooltip/Tooltip.d.ts +1 -1
  47. package/lib/esn/Tooltip/Tooltip.d.ts.map +1 -1
  48. package/lib/esn/hooks/useEventListener.d.ts.map +1 -1
  49. package/lib/esn/hooks/useEventListener.js +0 -1
  50. package/lib/esn/hooks/useEventListener.js.map +1 -1
  51. package/lib/esn/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +28 -29
  53. package/postcss.config.js +9 -5
  54. package/site/components/Documentation/Components/SectionButtons.tsx +8 -4
  55. package/site/components/Documentation/Components/SectionDropdowns.tsx +1 -1
  56. package/site/components/Documentation/Components/SectionPlacement.tsx +7 -1
  57. package/src/ButtonWithDropdown/ButtonWithDropdown.tsx +22 -21
  58. package/src/Dropdown/Dropdown.tsx +16 -8
  59. package/src/Dropdown/DropdownMenu.css +1 -1
  60. package/src/Placement/Placement.css +17 -35
  61. package/src/Placement/Placement.tsx +5 -8
  62. package/src/Placement/PlacementPopper.tsx +64 -48
  63. package/src/Tooltip/Tooltip.tsx +1 -1
  64. package/src/hooks/useEventListener.ts +25 -5
@@ -376,22 +376,26 @@ const SectionButtons = () => {
376
376
  <ButtonWithDropdown
377
377
  items={[
378
378
  {
379
+ key: '1',
379
380
  component: 'button',
380
381
  icon: 'Percent',
381
- text: 'Refer your friends',
382
+ content: 'Refer your friends',
382
383
  },
383
384
  {
385
+ key: '2',
384
386
  component: 'a',
385
387
  icon: 'Settings',
386
- text: 'Account setings',
388
+ content: 'Account setings',
387
389
  },
388
390
  {
391
+ key: '3',
389
392
  icon: 'ChangePlan',
390
- text: 'Change plan',
393
+ content: 'Change plan',
391
394
  },
392
395
  {
396
+ key: '4',
393
397
  icon: 'Logout',
394
- text: 'Log out',
398
+ content: 'Log out',
395
399
  },
396
400
  ]}
397
401
  >
@@ -4,7 +4,6 @@ import {
4
4
  DropdownMenu,
5
5
  DropdownMenus,
6
6
  DropdownMenuItem,
7
- DropdownMenuItemGroup,
8
7
  Flex,
9
8
  Icon,
10
9
  Placement,
@@ -245,6 +244,7 @@ const SectionDropdown = () => {
245
244
  setSelectedItem(undefined);
246
245
  handleToggle3();
247
246
  }}
247
+ sameWidth
248
248
  visible={visible3}
249
249
  >
250
250
  {() => (
@@ -21,7 +21,12 @@ const SectionPlacement = () => {
21
21
  const [selectedTab, setSelectedTab] = useState(1);
22
22
  const [ref, setRef] = useState<SVGSVGElement>();
23
23
 
24
- const handleToggle = () => setVisible(!visible);
24
+ const handleToggle = (event?: any) => {
25
+ if (event && event.stopPropagation) {
26
+ event.stopPropagation();
27
+ }
28
+ setVisible(!visible);
29
+ };
25
30
 
26
31
  return (
27
32
  <Section>
@@ -39,6 +44,7 @@ const SectionPlacement = () => {
39
44
  <>
40
45
  <PlacementManager>
41
46
  <PlacementReference>
47
+ {/* eslint-disable-next-line @typescript-eslint/no-shadow */}
42
48
  {({ ref }) => (
43
49
  <Button innerRef={ref} level="primary" onClick={handleToggle}>
44
50
  <Icon name="More" />
@@ -10,14 +10,18 @@ import {
10
10
  PlacementManager,
11
11
  PlacementProps,
12
12
  PlacementReference,
13
+ BaseProps,
13
14
  } from '@bitrise/bitkit';
14
15
 
15
16
  export interface ItemProps extends DropdownMenuItemProps {
17
+ key: string;
16
18
  component?: string;
17
19
  disabled?: boolean;
18
20
  href?: string;
21
+ onClick?: (e?: any) => void;
19
22
  target?: string;
20
- text: string;
23
+ content: React.ReactNode;
24
+ textColor?: BaseProps['textColor'];
21
25
  }
22
26
 
23
27
  export interface Props {
@@ -28,46 +32,43 @@ export interface Props {
28
32
  placementProps?: PlacementProps;
29
33
  }
30
34
 
31
- const ButtonWithDropdown = ({
32
- buttonProps = {},
33
- children,
34
- dropdownWidth,
35
- items,
36
- placementProps,
37
- }: Props): JSX.Element => {
35
+ const ButtonWithDropdown = ({ buttonProps, children, dropdownWidth, items, placementProps }: Props): JSX.Element => {
38
36
  const [visible, setVisible] = React.useState(false);
39
37
 
38
+ const onButtonClick = (event: any) => {
39
+ event.stopPropagation();
40
+ if (buttonProps?.onClick) {
41
+ buttonProps.onClick(!visible);
42
+ }
43
+ setVisible(!visible);
44
+ };
45
+
40
46
  return (
41
47
  <PlacementManager>
42
48
  <PlacementReference>
43
49
  {({ ref }) => (
44
- <Button innerRef={ref} onClick={() => setVisible(true)} {...buttonProps}>
50
+ <Button innerRef={ref} {...buttonProps} onClick={onButtonClick}>
45
51
  {children}
46
52
  <Icon name="ChevronDown" />
47
53
  </Button>
48
54
  )}
49
55
  </PlacementReference>
50
- {!buttonProps.disabled && (
51
- <Placement
52
- disableMargin="left-right"
53
- onClose={() => setVisible(false)}
54
- placement="bottom-end"
55
- visible={visible}
56
- {...placementProps}
57
- >
56
+ {!buttonProps?.disabled && (
57
+ <Placement onClose={() => setVisible(false)} placement="bottom-end" visible={visible} {...placementProps}>
58
58
  {() => (
59
59
  <DropdownMenu width={dropdownWidth} withArrow>
60
- {items.map(({ component, disabled, href, icon, onClick, target, text }) => (
60
+ {items.map(({ key, component, disabled, href, icon, onClick, target, content, textColor }) => (
61
61
  <DropdownMenuItem
62
- Component={component || 'div'}
62
+ Component={component || 'button'}
63
63
  disabled={disabled}
64
64
  href={href}
65
65
  icon={icon}
66
- key={text}
67
66
  onClick={onClick}
67
+ key={key}
68
68
  target={target}
69
+ textColor={textColor}
69
70
  >
70
- {text}
71
+ {content}
71
72
  </DropdownMenuItem>
72
73
  ))}
73
74
  </DropdownMenu>
@@ -41,17 +41,15 @@ const Dropdown: React.FunctionComponent<Props> = (props: Props) => {
41
41
  const { children, options, onChange, selected, maxHeight, ...rest } = props;
42
42
  const [visible, setVisible] = useState(false);
43
43
 
44
- const handleToggleVisible = () => setVisible(!visible);
45
-
46
44
  const handleChange = (value: DropdownValue) => {
47
45
  if (onChange) {
48
46
  onChange(value);
49
47
  }
50
- handleToggleVisible();
48
+ setVisible(false);
51
49
  };
52
50
 
53
51
  const renderOption = ({ text, value }: Option) => (
54
- <DropdownMenuItem onClick={() => handleChange(value)} selected={selected === value}>
52
+ <DropdownMenuItem onClick={() => handleChange(value)} selected={selected === value} width="100%">
55
53
  {text}
56
54
  </DropdownMenuItem>
57
55
  );
@@ -60,15 +58,25 @@ const Dropdown: React.FunctionComponent<Props> = (props: Props) => {
60
58
  <PlacementManager>
61
59
  <PlacementReference>
62
60
  {({ ref }) => (
63
- <DropdownButton {...rest} alignChildrenHorizontal="start" innerRef={ref} onClick={handleToggleVisible}>
61
+ <DropdownButton
62
+ {...rest}
63
+ alignChildrenHorizontal="start"
64
+ innerRef={ref}
65
+ onClick={(event: any) => {
66
+ if (event && event.preventDefault) {
67
+ event.stopPropagation();
68
+ }
69
+ setVisible(!visible);
70
+ }}
71
+ >
64
72
  <Text ellipsis>{children}</Text>
65
73
  </DropdownButton>
66
74
  )}
67
75
  </PlacementReference>
68
76
 
69
- <Placement onClose={handleToggleVisible} visible={visible}>
70
- {({ width }) => (
71
- <DropdownMenu maxHeight={maxHeight} width={width}>
77
+ <Placement onClose={() => setVisible(false)} sameWidth visible={visible}>
78
+ {() => (
79
+ <DropdownMenu maxHeight={maxHeight} width="100%">
72
80
  {options.map((option) => (
73
81
  <React.Fragment key={option.text}>
74
82
  {'options' in option ? (
@@ -15,7 +15,7 @@
15
15
  .DropdownMenu__group-text::after {
16
16
  content: '';
17
17
  flex: 1;
18
- /* stylelint-disable-next-line unit-blacklist */
18
+ /* stylelint-disable-next-line unit-disallowed-list */
19
19
  height: 1px;
20
20
  background-color: var(--color-gray--3);
21
21
  }
@@ -1,29 +1,10 @@
1
1
 
2
- :root {
3
- --Placement-arrow-size: var(--size--x3);
4
- }
5
-
6
2
  .Placement {
7
3
  position: absolute;
8
- margin: var(--Placement-arrow-size);
9
4
  z-index: var(--z-index-Placement--below-modal);
10
5
  pointer-events: none;
11
6
  }
12
7
 
13
- .Placement--disable-margin {
14
- margin: 0;
15
- }
16
-
17
- .Placement--disable-margin-top-bottom {
18
- margin-top: 0;
19
- margin-bottom: 0;
20
- }
21
-
22
- .Placement--disable-margin-left-right {
23
- margin-right: 0;
24
- margin-left: 0;
25
- }
26
-
27
8
  .Placement--animate {
28
9
  transition-property: transform;
29
10
  transition-duration: var(--transition-duration--fast);
@@ -83,50 +64,51 @@
83
64
  border-top: 0.0625rem solid var(--color-gray--2);
84
65
  }
85
66
 
86
- .Placement__arrow {
67
+ .Placement__arrow,
68
+ .Placement__arrow::before {
87
69
  position: absolute;
88
- width: var(--Placement-arrow-size);
89
- height: var(--Placement-arrow-size);
70
+ width: var(--size--x3);
71
+ height: var(--size--x3);
90
72
  }
91
73
 
92
74
  .Placement__arrow,
93
75
  .Placement__arrow:first-child,
94
76
  .Placement__arrow:last-child {
95
- margin: var(--Placement-arrow-size);
77
+ visibility: hidden;
78
+ }
79
+
80
+ .Placement__arrow::before {
81
+ content: '';
82
+ display: block;
83
+ transform: rotate(45deg);
84
+ background: inherit;
85
+ visibility: visible;
96
86
  }
97
87
 
98
88
  .Placement--top .Placement__arrow,
99
89
  .Placement--top-start .Placement__arrow,
100
90
  .Placement--top-end .Placement__arrow {
101
91
  top: 100%;
102
- transform:
103
- translateY(calc(-50% + var(--Placement-arrow-size) * -1))
104
- rotate(45deg);
92
+ margin-top: -0.375rem;
105
93
  }
106
94
 
107
95
  .Placement--right .Placement__arrow,
108
96
  .Placement--right-start .Placement__arrow,
109
97
  .Placement--right-end .Placement__arrow {
110
98
  right: 100%;
111
- transform:
112
- translateX(calc(50% - var(--Placement-arrow-size) * -1))
113
- rotate(45deg);
99
+ margin-right: -0.375rem;
114
100
  }
115
101
 
116
102
  .Placement--bottom .Placement__arrow,
117
103
  .Placement--bottom-start .Placement__arrow,
118
104
  .Placement--bottom-end .Placement__arrow {
119
105
  bottom: 100%;
120
- transform:
121
- translateY(calc(50% - var(--Placement-arrow-size) * -1))
122
- rotate(45deg);
106
+ margin-bottom: -0.375rem;
123
107
  }
124
108
 
125
109
  .Placement--left .Placement__arrow,
126
110
  .Placement--left-start .Placement__arrow,
127
111
  .Placement--left-end .Placement__arrow {
128
112
  left: 100%;
129
- transform:
130
- translateX(calc(-50% + var(--Placement-arrow-size) * -1))
131
- rotate(45deg);
113
+ margin-left: -0.375rem;
132
114
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { Placement as TypePlacement, ReferenceObject as TypeReferenceObject } from 'popper.js';
2
+ import { Placement as TypePlacement } from '@popperjs/core';
3
3
  import { Props as BaseProps } from '../Base/Base';
4
4
  import { ModalContext } from '../Modal/ModalContext';
5
5
  import PlacementPopper from './PlacementPopper';
@@ -13,15 +13,11 @@ export interface Props extends BaseProps {
13
13
  animatePosition?: boolean;
14
14
  /**
15
15
  * A render callback function that provides a
16
- * scheduleUpdate function to trigger a reposition,
16
+ * update function to trigger a reposition,
17
17
  * and the width of the target that is being positioned
18
18
  * around.
19
19
  */
20
- children: (props: { scheduleUpdate: () => void; width?: number }) => React.ReactNode;
21
- /**
22
- * Flag that disables margin around the Placement.
23
- */
24
- disableMargin?: boolean | 'top-bottom' | 'left-right';
20
+ children: (props: { update: () => void; width?: number }) => React.ReactNode;
25
21
  /**
26
22
  * Flag that disables repositioning on scroll and resize events.
27
23
  */
@@ -45,7 +41,8 @@ export interface Props extends BaseProps {
45
41
  /**
46
42
  * An optional reference element to be used as the target.
47
43
  */
48
- referenceElement?: TypeReferenceObject;
44
+ referenceElement?: any;
45
+ sameWidth?: boolean;
49
46
  /**
50
47
  * The visibilty of the positioned content.
51
48
  */
@@ -1,6 +1,7 @@
1
+ /* eslint-disable react/default-props-match-prop-types */
1
2
  import * as React from 'react';
2
3
  import { createPortal } from 'react-dom';
3
- import { Placement as TypePlacement, ReferenceObject as TypeReferenceObject } from 'popper.js';
4
+ import { Placement as TypePlacement } from '@popperjs/core';
4
5
  import { Popper, PopperProps } from 'react-popper';
5
6
  import { CSSTransition } from 'react-transition-group';
6
7
  import classnames from 'classnames';
@@ -27,15 +28,14 @@ const transitionClasses = {
27
28
 
28
29
  export interface Props extends BaseProps {
29
30
  animatePosition?: boolean;
30
- children: (props: { scheduleUpdate: () => void; width?: number }) => React.ReactNode;
31
+ children: (props: { update: () => void; width?: number }) => React.ReactNode;
31
32
  closeElement?: null | HTMLElement;
32
- disableMargin?: boolean | 'top-bottom' | 'left-right';
33
33
  disableReposition?: boolean;
34
34
  flip?: boolean;
35
35
  isInsideModal?: boolean;
36
36
  onClose?: (event: MouseEvent) => void;
37
37
  placement?: TypePlacement;
38
- referenceElement?: TypeReferenceObject;
38
+ referenceElement?: any;
39
39
  visible?: boolean;
40
40
  timeout?: number;
41
41
  }
@@ -46,13 +46,13 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
46
46
  backgroundColor,
47
47
  children,
48
48
  closeElement,
49
- disableMargin,
50
49
  disableReposition,
51
50
  flip,
52
51
  isInsideModal,
53
52
  onClose,
54
53
  placement: desiredPlacement,
55
54
  referenceElement,
55
+ sameWidth,
56
56
  visible,
57
57
  timeout = transitionDurationFast,
58
58
  ...rest
@@ -71,7 +71,7 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
71
71
  closeElement || document,
72
72
  'click',
73
73
  (event) => {
74
- if (onClose && ref.current && !ref.current.contains(event.target as Node)) {
74
+ if (onClose && ref.current && !ref.current.contains(event.target as Node) && visible) {
75
75
  onClose(event as MouseEvent);
76
76
  }
77
77
  },
@@ -93,19 +93,36 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
93
93
  return null;
94
94
  }
95
95
 
96
- const popperProps: PopperProps = {
97
- children: () => null,
98
- eventsEnabled: !disableReposition,
99
- placement: desiredPlacement,
100
- modifiers: {
101
- preventOverflow: {
102
- boundariesElement: 'window',
103
- },
104
- flip: {
105
- behavior: 'flip',
106
- enabled: flip,
96
+ const modifiers: any[] = [
97
+ {
98
+ name: 'offset',
99
+ options: {
100
+ offset: [0, 12],
107
101
  },
108
102
  },
103
+ ];
104
+
105
+ if (sameWidth) {
106
+ modifiers.push({
107
+ enabled: true,
108
+ name: 'sameWidth',
109
+ phase: 'beforeWrite',
110
+ requires: ['computeStyles'],
111
+ fn: ({ state }: any) => {
112
+ // eslint-disable-next-line no-param-reassign
113
+ state.styles.popper.width = `${state.rects.reference.width}px`;
114
+ },
115
+ effect: ({ state }: any) => {
116
+ // eslint-disable-next-line no-param-reassign
117
+ state.elements.popper.style.width = `${state.elements.reference.getBoundingClientRect().width || 0}px`;
118
+ },
119
+ });
120
+ }
121
+
122
+ const popperProps: PopperProps<any> = {
123
+ children: () => null,
124
+ placement: desiredPlacement,
125
+ modifiers,
109
126
  };
110
127
 
111
128
  if (referenceElement) {
@@ -116,37 +133,36 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
116
133
  // eslint-disable-next-line no-return-assign
117
134
  <Popper {...popperProps} innerRef={(el) => (ref.current = el || null)}>
118
135
  {/* eslint-disable-next-line @typescript-eslint/no-shadow */}
119
- {({ arrowProps, placement, ref, scheduleUpdate, style }) => (
120
- // eslint-disable-next-line react/jsx-no-constructed-context-values
121
- <PlacementArrowPropsContext.Provider value={{ ...arrowProps, backgroundColor }}>
122
- <div
123
- className={classnames('Placement', `Placement--${placement}`, {
124
- 'Placement--above-modal': isInsideModal,
125
- 'Placement--animate': animatePosition,
126
- 'Placement--disable-margin': disableMargin === true,
127
- 'Placement--disable-margin-top-bottom': disableMargin === 'top-bottom',
128
- 'Placement--disable-margin-left-right': disableMargin === 'left-right',
129
- })}
130
- ref={ref}
131
- style={style}
132
- >
133
- <CSSTransition appear={visible} classNames={transitionClasses} in={visible} timeout={timeout}>
134
- <div className="Placement__content">
135
- <Base {...rest} backgroundColor={backgroundColor} className="Placement__shadow">
136
- <PlacementManagerContext.Consumer>
137
- {({ referenceNode }) =>
138
- children({
139
- scheduleUpdate,
140
- width: (referenceNode && referenceNode.clientWidth) || undefined,
141
- })
142
- }
143
- </PlacementManagerContext.Consumer>
144
- </Base>
145
- </div>
146
- </CSSTransition>
147
- </div>
148
- </PlacementArrowPropsContext.Provider>
149
- )}
136
+ {({ arrowProps, placement, ref, update, style }) => {
137
+ return (
138
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
139
+ <PlacementArrowPropsContext.Provider value={{ ...arrowProps, backgroundColor }}>
140
+ <div
141
+ className={classnames('Placement', `Placement--${placement}`, {
142
+ 'Placement--above-modal': isInsideModal,
143
+ 'Placement--animate': animatePosition,
144
+ })}
145
+ ref={ref}
146
+ style={style}
147
+ >
148
+ <CSSTransition appear={visible} classNames={transitionClasses} in={visible} timeout={timeout}>
149
+ <div className="Placement__content">
150
+ <Base {...rest} backgroundColor={backgroundColor} className="Placement__shadow">
151
+ <PlacementManagerContext.Consumer>
152
+ {({ referenceNode }) =>
153
+ children({
154
+ update,
155
+ width: (referenceNode && referenceNode.clientWidth) || undefined,
156
+ })
157
+ }
158
+ </PlacementManagerContext.Consumer>
159
+ </Base>
160
+ </div>
161
+ </CSSTransition>
162
+ </div>
163
+ </PlacementArrowPropsContext.Provider>
164
+ );
165
+ }}
150
166
  </Popper>,
151
167
  document.body,
152
168
  );
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { ReferenceChildrenProps } from 'react-popper';
3
- import { Placement as TypePlacement } from 'popper.js';
3
+ import { Placement as TypePlacement } from '@popperjs/core';
4
4
  import { Props as BaseProps } from '../Base/Base';
5
5
  import Placement from '../Placement/Placement';
6
6
  import PlacementArea from '../Placement/PlacementArea';
@@ -4,10 +4,30 @@ type HTMLElementOrDocumentOrWindow = HTMLElement | Document | Window;
4
4
  interface HTMLElementOrDocumentOrWindowEventMap extends HTMLElementEventMap, DocumentEventMap, WindowEventMap {}
5
5
 
6
6
  /* eslint-disable @typescript-eslint/no-explicit-any */
7
- function useEventListener<E extends Window, K extends keyof WindowEventMap>(el: E | null | undefined, type: K, handler: (evnt: WindowEventMap[K]) => void, watch?: any[]): void;
8
- function useEventListener<E extends Document, K extends keyof DocumentEventMap>(el: E | null | undefined, type: K, handler: (evt: DocumentEventMap[K]) => void, watch?: any[]): void;
9
- function useEventListener<E extends HTMLElement, K extends keyof HTMLElementEventMap>(el: E | null | undefined, type: K, handler: (evt: HTMLElementEventMap[K]) => void, watch?: any[]): void;
10
- function useEventListener<K extends keyof HTMLElementOrDocumentOrWindowEventMap>(el: HTMLElementOrDocumentOrWindow, type: string, handler: (evt: HTMLElementOrDocumentOrWindowEventMap[K]) => void, watch?: any[]): void;
7
+ function useEventListener<E extends Window, K extends keyof WindowEventMap>(
8
+ el: E | null | undefined,
9
+ type: K,
10
+ handler: (evnt: WindowEventMap[K]) => void,
11
+ watch?: any[],
12
+ ): void;
13
+ function useEventListener<E extends Document, K extends keyof DocumentEventMap>(
14
+ el: E | null | undefined,
15
+ type: K,
16
+ handler: (evt: DocumentEventMap[K]) => void,
17
+ watch?: any[],
18
+ ): void;
19
+ function useEventListener<E extends HTMLElement, K extends keyof HTMLElementEventMap>(
20
+ el: E | null | undefined,
21
+ type: K,
22
+ handler: (evt: HTMLElementEventMap[K]) => void,
23
+ watch?: any[],
24
+ ): void;
25
+ function useEventListener<K extends keyof HTMLElementOrDocumentOrWindowEventMap>(
26
+ el: HTMLElementOrDocumentOrWindow,
27
+ type: string,
28
+ handler: (evt: HTMLElementOrDocumentOrWindowEventMap[K]) => void,
29
+ watch?: any[],
30
+ ): void;
11
31
  function useEventListener(el: any, type: string, handler: any, watch?: any[]) {
12
32
  useEffect(() => {
13
33
  if (el) {
@@ -20,6 +40,6 @@ function useEventListener(el: any, type: string, handler: any, watch?: any[]) {
20
40
  }
21
41
  };
22
42
  }, watch || []);
23
- };
43
+ }
24
44
 
25
45
  export default useEventListener;