@bitrise/bitkit 9.4.1 → 9.4.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 (75) 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/.tool-versions +1 -1
  6. package/CHANGELOG.md +2 -0
  7. package/bitrise.yml +31 -27
  8. package/jest.setup.js +2 -1
  9. package/lib/cjs/Dropdown/Dropdown.d.ts.map +1 -1
  10. package/lib/cjs/Dropdown/Dropdown.js +6 -8
  11. package/lib/cjs/Dropdown/Dropdown.js.map +1 -1
  12. package/lib/cjs/Dropdown/DropdownMenu.css +1 -1
  13. package/lib/cjs/Placement/Placement.css +17 -35
  14. package/lib/cjs/Placement/Placement.d.ts +5 -8
  15. package/lib/cjs/Placement/Placement.d.ts.map +1 -1
  16. package/lib/cjs/Placement/Placement.js.map +1 -1
  17. package/lib/cjs/Placement/PlacementPopper.d.ts +3 -4
  18. package/lib/cjs/Placement/PlacementPopper.d.ts.map +1 -1
  19. package/lib/cjs/Placement/PlacementPopper.js +52 -19
  20. package/lib/cjs/Placement/PlacementPopper.js.map +1 -1
  21. package/lib/cjs/Tooltip/Tooltip.d.ts +1 -1
  22. package/lib/cjs/Tooltip/Tooltip.d.ts.map +1 -1
  23. package/lib/cjs/hooks/useEventListener.d.ts.map +1 -1
  24. package/lib/cjs/hooks/useEventListener.js +0 -1
  25. package/lib/cjs/hooks/useEventListener.js.map +1 -1
  26. package/lib/cjs/index.d.ts +0 -1
  27. package/lib/cjs/index.d.ts.map +1 -1
  28. package/lib/cjs/index.js +2 -4
  29. package/lib/cjs/index.js.map +1 -1
  30. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  31. package/lib/esn/Dropdown/Dropdown.d.ts.map +1 -1
  32. package/lib/esn/Dropdown/Dropdown.js +6 -5
  33. package/lib/esn/Dropdown/Dropdown.js.map +1 -1
  34. package/lib/esn/Dropdown/DropdownMenu.css +1 -1
  35. package/lib/esn/Placement/Placement.css +17 -35
  36. package/lib/esn/Placement/Placement.d.ts +5 -8
  37. package/lib/esn/Placement/Placement.d.ts.map +1 -1
  38. package/lib/esn/Placement/Placement.js.map +1 -1
  39. package/lib/esn/Placement/PlacementPopper.d.ts +3 -4
  40. package/lib/esn/Placement/PlacementPopper.d.ts.map +1 -1
  41. package/lib/esn/Placement/PlacementPopper.js +53 -30
  42. package/lib/esn/Placement/PlacementPopper.js.map +1 -1
  43. package/lib/esn/Tooltip/Tooltip.d.ts +1 -1
  44. package/lib/esn/Tooltip/Tooltip.d.ts.map +1 -1
  45. package/lib/esn/hooks/useEventListener.d.ts.map +1 -1
  46. package/lib/esn/hooks/useEventListener.js +0 -1
  47. package/lib/esn/hooks/useEventListener.js.map +1 -1
  48. package/lib/esn/index.d.ts +0 -1
  49. package/lib/esn/index.d.ts.map +1 -1
  50. package/lib/esn/index.js +0 -1
  51. package/lib/esn/index.js.map +1 -1
  52. package/lib/esn/tsconfig.tsbuildinfo +1 -1
  53. package/package.json +34 -35
  54. package/postcss.config.js +9 -5
  55. package/site/components/Documentation/Components/SectionButtons.tsx +1 -47
  56. package/site/components/Documentation/Components/SectionDropdowns.tsx +1 -1
  57. package/site/components/Documentation/Components/SectionPlacement.tsx +4 -1
  58. package/site/components/Documentation/Documentation.tsx +1 -6
  59. package/src/Dropdown/Dropdown.tsx +13 -8
  60. package/src/Dropdown/DropdownMenu.css +1 -1
  61. package/src/Placement/Placement.css +17 -35
  62. package/src/Placement/Placement.tsx +5 -8
  63. package/src/Placement/PlacementPopper.tsx +78 -50
  64. package/src/Tooltip/Tooltip.tsx +1 -1
  65. package/src/hooks/useEventListener.ts +25 -5
  66. package/src/index.ts +0 -4
  67. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.d.ts +0 -19
  68. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.d.ts.map +0 -1
  69. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.js +0 -55
  70. package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.js.map +0 -1
  71. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.d.ts +0 -19
  72. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.d.ts.map +0 -1
  73. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.js +0 -12
  74. package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.js.map +0 -1
  75. package/src/ButtonWithDropdown/ButtonWithDropdown.tsx +0 -81
@@ -1,18 +1,5 @@
1
- /* eslint-disable object-shorthand */
2
1
  import * as React from 'react';
3
- import {
4
- Base,
5
- Button,
6
- Buttons,
7
- ColorButton,
8
- Icon,
9
- Tab,
10
- Tabs,
11
- Text,
12
- Ribbon,
13
- ButtonWithDropdown,
14
- Flex,
15
- } from '@bitrise/bitkit';
2
+ import { Base, Button, Buttons, ColorButton, Icon, Tab, Tabs, Text, Ribbon } from '@bitrise/bitkit';
16
3
  import CodeBlock from '../../CodeBlock/CodeBlock';
17
4
  import Section from '../../Section/Section';
18
5
  import SectionSubTitle from '../../Section/SectionSubTitle';
@@ -34,10 +21,6 @@ const SectionButtons = () => {
34
21
  <Tab active={selectedTab === 3} onClick={() => setSelectedTab(3)}>
35
22
  Color Button
36
23
  </Tab>
37
-
38
- <Tab active={selectedTab === 4} onClick={() => setSelectedTab(4)}>
39
- with dropdown
40
- </Tab>
41
24
  </Tabs>
42
25
 
43
26
  {selectedTab === 1 && (
@@ -371,35 +354,6 @@ const SectionButtons = () => {
371
354
  );`}</CodeBlock>
372
355
  </>
373
356
  )}
374
- {selectedTab === 4 && (
375
- <Flex alignChildren="end" direction="horizontal">
376
- <ButtonWithDropdown
377
- items={[
378
- {
379
- component: 'button',
380
- icon: 'Percent',
381
- text: 'Refer your friends',
382
- },
383
- {
384
- component: 'a',
385
- icon: 'Settings',
386
- text: 'Account setings',
387
- },
388
- {
389
- icon: 'ChangePlan',
390
- text: 'Change plan',
391
- },
392
- {
393
- icon: 'Logout',
394
- text: 'Log out',
395
- },
396
- ]}
397
- >
398
- <Icon name="Bitbot" />
399
- <Text>Account</Text>
400
- </ButtonWithDropdown>
401
- </Flex>
402
- )}
403
357
  </Section>
404
358
  );
405
359
  };
@@ -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,9 @@ 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 = () => {
25
+ setVisible(!visible);
26
+ };
25
27
 
26
28
  return (
27
29
  <Section>
@@ -39,6 +41,7 @@ const SectionPlacement = () => {
39
41
  <>
40
42
  <PlacementManager>
41
43
  <PlacementReference>
44
+ {/* eslint-disable-next-line @typescript-eslint/no-shadow */}
42
45
  {({ ref }) => (
43
46
  <Button innerRef={ref} level="primary" onClick={handleToggle}>
44
47
  <Icon name="More" />
@@ -41,12 +41,7 @@ const SectionMap = {
41
41
  },
42
42
  Button: {
43
43
  Showcase: require('./Components/SectionButtons').default,
44
- components: [
45
- documentation.Button,
46
- documentation.Buttons,
47
- documentation.ColorButton,
48
- documentation.ButtonWithDropdown,
49
- ],
44
+ components: [documentation.Button, documentation.Buttons, documentation.ColorButton],
50
45
  },
51
46
  Card: {
52
47
  Showcase: require('./Components/SectionCards').default,
@@ -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,22 @@ 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={() => {
66
+ setVisible(!visible);
67
+ }}
68
+ >
64
69
  <Text ellipsis>{children}</Text>
65
70
  </DropdownButton>
66
71
  )}
67
72
  </PlacementReference>
68
73
 
69
- <Placement onClose={handleToggleVisible} visible={visible}>
70
- {({ width }) => (
71
- <DropdownMenu maxHeight={maxHeight} width={width}>
74
+ <Placement onClose={() => setVisible(false)} sameWidth visible={visible}>
75
+ {() => (
76
+ <DropdownMenu maxHeight={maxHeight} width="100%">
72
77
  {options.map((option) => (
73
78
  <React.Fragment key={option.text}>
74
79
  {'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, VirtualElement } 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
@@ -61,6 +61,8 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
61
61
  const ref = useRef<HTMLElement | null>();
62
62
  const [render, setRender] = useState(visible);
63
63
 
64
+ const [reference, setReference] = useState<Element | VirtualElement | undefined>(undefined);
65
+
64
66
  useEffect(() => {
65
67
  if (visible) {
66
68
  setRender(true);
@@ -71,11 +73,14 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
71
73
  closeElement || document,
72
74
  'click',
73
75
  (event) => {
74
- if (onClose && ref.current && !ref.current.contains(event.target as Node)) {
76
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
77
+ /* @ts-ignore */
78
+ const isReferenceInPath = [...event.composedPath()].includes(reference);
79
+ if (onClose && ref.current && !ref.current.contains(event.target as Node) && !isReferenceInPath) {
75
80
  onClose(event as MouseEvent);
76
81
  }
77
82
  },
78
- [onClose],
83
+ [onClose, reference],
79
84
  );
80
85
 
81
86
  useEventListener(
@@ -93,19 +98,36 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
93
98
  return null;
94
99
  }
95
100
 
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,
101
+ const modifiers: any[] = [
102
+ {
103
+ name: 'offset',
104
+ options: {
105
+ offset: [0, 12],
107
106
  },
108
107
  },
108
+ ];
109
+
110
+ if (sameWidth) {
111
+ modifiers.push({
112
+ enabled: true,
113
+ name: 'sameWidth',
114
+ phase: 'beforeWrite',
115
+ requires: ['computeStyles'],
116
+ fn: ({ state }: any) => {
117
+ // eslint-disable-next-line no-param-reassign
118
+ state.styles.popper.width = `${state.rects.reference.width}px`;
119
+ },
120
+ effect: ({ state }: any) => {
121
+ // eslint-disable-next-line no-param-reassign
122
+ state.elements.popper.style.width = `${state.elements.reference.getBoundingClientRect().width || 0}px`;
123
+ },
124
+ });
125
+ }
126
+
127
+ const popperProps: PopperProps<any> = {
128
+ children: () => null,
129
+ placement: desiredPlacement,
130
+ modifiers,
109
131
  };
110
132
 
111
133
  if (referenceElement) {
@@ -114,39 +136,45 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
114
136
 
115
137
  return createPortal(
116
138
  // eslint-disable-next-line no-return-assign
117
- <Popper {...popperProps} innerRef={(el) => (ref.current = el || null)}>
139
+ <Popper
140
+ {...popperProps}
141
+ // eslint-disable-next-line no-return-assign
142
+ innerRef={(el) => (ref.current = el || null)}
143
+ onFirstUpdate={(state) => {
144
+ setReference(state.elements?.reference);
145
+ }}
146
+ >
118
147
  {/* 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
- )}
148
+ {({ arrowProps, placement, ref, update, style }) => {
149
+ return (
150
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
151
+ <PlacementArrowPropsContext.Provider value={{ ...arrowProps, backgroundColor }}>
152
+ <div
153
+ className={classnames('Placement', `Placement--${placement}`, {
154
+ 'Placement--above-modal': isInsideModal,
155
+ 'Placement--animate': animatePosition,
156
+ })}
157
+ ref={ref}
158
+ style={style}
159
+ >
160
+ <CSSTransition appear={visible} classNames={transitionClasses} in={visible} timeout={timeout}>
161
+ <div className="Placement__content">
162
+ <Base {...rest} backgroundColor={backgroundColor} className="Placement__shadow">
163
+ <PlacementManagerContext.Consumer>
164
+ {({ referenceNode }) =>
165
+ children({
166
+ update,
167
+ width: (referenceNode && referenceNode.clientWidth) || undefined,
168
+ })
169
+ }
170
+ </PlacementManagerContext.Consumer>
171
+ </Base>
172
+ </div>
173
+ </CSSTransition>
174
+ </div>
175
+ </PlacementArrowPropsContext.Provider>
176
+ );
177
+ }}
150
178
  </Popper>,
151
179
  document.body,
152
180
  );
@@ -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;
package/src/index.ts CHANGED
@@ -23,10 +23,6 @@ export { default as Base, Props as BaseProps, TypeColors, TypeSizes } from './Ba
23
23
  export { default as Bounds, Props as BoundsProps } from './Bounds/Bounds';
24
24
  export { default as Button, Props as ButtonProps } from './Button/Button';
25
25
  export { default as Buttons, Props as ButtonsProps } from './Button/Buttons';
26
- export {
27
- default as ButtonWithDropdown,
28
- Props as ButtonWithDropdownProps,
29
- } from './ButtonWithDropdown/ButtonWithDropdown';
30
26
  export { default as Card, Props as CardProps } from './Card/Card';
31
27
  export { default as CardButton, Props as CardButtonProps } from './Card/CardButton';
32
28
  export { default as CardContent, Props as CardContentProps } from './Card/CardContent';
@@ -1,19 +0,0 @@
1
- import * as React from 'react';
2
- import { ButtonProps, DropdownMenuItemProps, PlacementProps } from '@bitrise/bitkit';
3
- export interface ItemProps extends DropdownMenuItemProps {
4
- component?: string;
5
- disabled?: boolean;
6
- href?: string;
7
- target?: string;
8
- text: string;
9
- }
10
- export interface Props {
11
- buttonProps?: ButtonProps;
12
- children?: React.ReactElement | React.ReactNodeArray;
13
- dropdownWidth?: string;
14
- items: ItemProps[];
15
- placementProps?: PlacementProps;
16
- }
17
- declare const ButtonWithDropdown: ({ buttonProps, children, dropdownWidth, items, placementProps, }: Props) => JSX.Element;
18
- export default ButtonWithDropdown;
19
- //# sourceMappingURL=ButtonWithDropdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ButtonWithDropdown.d.ts","sourceRoot":"","sources":["../../../src/ButtonWithDropdown/ButtonWithDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,WAAW,EAGX,qBAAqB,EAIrB,cAAc,EAEf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,SAAU,SAAQ,qBAAqB;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,KAAK;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,QAAA,MAAM,kBAAkB,qEAMrB,KAAK,KAAG,WA0CV,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- var React = __importStar(require("react"));
38
- var bitkit_1 = require("@bitrise/bitkit");
39
- var ButtonWithDropdown = function (_a) {
40
- var _b = _a.buttonProps, buttonProps = _b === void 0 ? {} : _b, children = _a.children, dropdownWidth = _a.dropdownWidth, items = _a.items, placementProps = _a.placementProps;
41
- var _c = React.useState(false), visible = _c[0], setVisible = _c[1];
42
- return (React.createElement(bitkit_1.PlacementManager, null,
43
- React.createElement(bitkit_1.PlacementReference, null, function (_a) {
44
- var ref = _a.ref;
45
- return (React.createElement(bitkit_1.Button, __assign({ innerRef: ref, onClick: function () { return setVisible(true); } }, buttonProps),
46
- children,
47
- React.createElement(bitkit_1.Icon, { name: "ChevronDown" })));
48
- }),
49
- !buttonProps.disabled && (React.createElement(bitkit_1.Placement, __assign({ disableMargin: "left-right", onClose: function () { return setVisible(false); }, placement: "bottom-end", visible: visible }, placementProps), function () { return (React.createElement(bitkit_1.DropdownMenu, { width: dropdownWidth, withArrow: true }, items.map(function (_a) {
50
- var component = _a.component, disabled = _a.disabled, href = _a.href, icon = _a.icon, onClick = _a.onClick, target = _a.target, text = _a.text;
51
- return (React.createElement(bitkit_1.DropdownMenuItem, { Component: component || 'div', disabled: disabled, href: href, icon: icon, key: text, onClick: onClick, target: target }, text));
52
- }))); }))));
53
- };
54
- exports.default = ButtonWithDropdown;
55
- //# sourceMappingURL=ButtonWithDropdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ButtonWithDropdown.js","sourceRoot":"","sources":["../../../src/ButtonWithDropdown/ButtonWithDropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+B;AAC/B,0CAWyB;AAkBzB,IAAM,kBAAkB,GAAG,UAAC,EAMpB;QALN,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,KAAA,EAChB,QAAQ,cAAA,EACR,aAAa,mBAAA,EACb,KAAK,WAAA,EACL,cAAc,oBAAA;IAER,IAAA,KAAwB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAA5C,OAAO,QAAA,EAAE,UAAU,QAAyB,CAAC;IAEpD,OAAO,CACL,oBAAC,yBAAgB;QACf,oBAAC,2BAAkB,QAChB,UAAC,EAAO;gBAAL,GAAG,SAAA;YAAO,OAAA,CACZ,oBAAC,eAAM,aAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,cAAM,OAAA,UAAU,CAAC,IAAI,CAAC,EAAhB,CAAgB,IAAM,WAAW;gBACpE,QAAQ;gBACT,oBAAC,aAAI,IAAC,IAAI,EAAC,aAAa,GAAG,CACpB,CACV;QALa,CAKb,CACkB;QACpB,CAAC,WAAW,CAAC,QAAQ,IAAI,CACxB,oBAAC,kBAAS,aACR,aAAa,EAAC,YAAY,EAC1B,OAAO,EAAE,cAAM,OAAA,UAAU,CAAC,KAAK,CAAC,EAAjB,CAAiB,EAChC,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,OAAO,IACZ,cAAc,GAEjB,cAAM,OAAA,CACL,oBAAC,qBAAY,IAAC,KAAK,EAAE,aAAa,EAAE,SAAS,UAC1C,KAAK,CAAC,GAAG,CAAC,UAAC,EAA0D;gBAAxD,SAAS,eAAA,EAAE,QAAQ,cAAA,EAAE,IAAI,UAAA,EAAE,IAAI,UAAA,EAAE,OAAO,aAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAA;YAAO,OAAA,CACzE,oBAAC,yBAAgB,IACf,SAAS,EAAE,SAAS,IAAI,KAAK,EAC7B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,IAEb,IAAI,CACY,CACpB;QAZ0E,CAY1E,CAAC,CACW,CAChB,EAhBM,CAgBN,CACS,CACb,CACgB,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}