@bitrise/bitkit 9.4.1-beta.2 → 9.4.1
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/.eslintrc.js +1 -8
- package/.nvmrc +1 -1
- package/.stylelintrc +3 -2
- package/.tool-versions +1 -1
- package/CHANGELOG.md +5 -2
- package/bitrise.yml +27 -41
- package/jest.setup.js +1 -2
- package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.d.ts +3 -6
- package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.d.ts.map +1 -1
- package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.js +6 -9
- package/lib/cjs/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -1
- package/lib/cjs/DatePicker/DatePickerDay.js +1 -1
- package/lib/cjs/DatePicker/DatePickerDay.js.map +1 -1
- package/lib/cjs/Dropdown/Dropdown.d.ts.map +1 -1
- package/lib/cjs/Dropdown/Dropdown.js +8 -6
- package/lib/cjs/Dropdown/Dropdown.js.map +1 -1
- package/lib/cjs/Dropdown/DropdownMenu.css +1 -1
- package/lib/cjs/Placement/Placement.css +35 -17
- package/lib/cjs/Placement/Placement.d.ts +8 -5
- package/lib/cjs/Placement/Placement.d.ts.map +1 -1
- package/lib/cjs/Placement/Placement.js.map +1 -1
- package/lib/cjs/Placement/PlacementPopper.d.ts +4 -3
- package/lib/cjs/Placement/PlacementPopper.d.ts.map +1 -1
- package/lib/cjs/Placement/PlacementPopper.js +19 -52
- package/lib/cjs/Placement/PlacementPopper.js.map +1 -1
- package/lib/cjs/Tooltip/Tooltip.d.ts +1 -1
- package/lib/cjs/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib/cjs/hooks/useEventListener.d.ts.map +1 -1
- package/lib/cjs/hooks/useEventListener.js +1 -0
- package/lib/cjs/hooks/useEventListener.js.map +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.d.ts +3 -6
- package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.d.ts.map +1 -1
- package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.js +3 -6
- package/lib/esn/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -1
- package/lib/esn/DatePicker/DatePickerDay.js +1 -1
- package/lib/esn/DatePicker/DatePickerDay.js.map +1 -1
- package/lib/esn/Dropdown/Dropdown.d.ts.map +1 -1
- package/lib/esn/Dropdown/Dropdown.js +5 -6
- package/lib/esn/Dropdown/Dropdown.js.map +1 -1
- package/lib/esn/Dropdown/DropdownMenu.css +1 -1
- package/lib/esn/Placement/Placement.css +35 -17
- package/lib/esn/Placement/Placement.d.ts +8 -5
- package/lib/esn/Placement/Placement.d.ts.map +1 -1
- package/lib/esn/Placement/Placement.js.map +1 -1
- package/lib/esn/Placement/PlacementPopper.d.ts +4 -3
- package/lib/esn/Placement/PlacementPopper.d.ts.map +1 -1
- package/lib/esn/Placement/PlacementPopper.js +30 -53
- package/lib/esn/Placement/PlacementPopper.js.map +1 -1
- package/lib/esn/Tooltip/Tooltip.d.ts +1 -1
- package/lib/esn/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib/esn/hooks/useEventListener.d.ts.map +1 -1
- package/lib/esn/hooks/useEventListener.js +1 -0
- package/lib/esn/hooks/useEventListener.js.map +1 -1
- package/lib/esn/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -29
- package/postcss.config.js +5 -9
- package/release.config.js +1 -2
- package/site/components/Documentation/Components/SectionButtons.tsx +4 -37
- package/site/components/Documentation/Components/SectionDropdowns.tsx +1 -1
- package/site/components/Documentation/Components/SectionPlacement.tsx +1 -4
- package/src/ButtonWithDropdown/ButtonWithDropdown.tsx +21 -18
- package/src/DatePicker/DatePickerDay.tsx +1 -1
- package/src/Dropdown/Dropdown.tsx +8 -13
- package/src/Dropdown/DropdownMenu.css +1 -1
- package/src/Placement/Placement.css +35 -17
- package/src/Placement/Placement.tsx +8 -5
- package/src/Placement/PlacementPopper.tsx +50 -78
- package/src/Tooltip/Tooltip.tsx +1 -1
- package/src/hooks/useEventListener.ts +5 -25
- package/.husky/commit-msg +0 -4
|
@@ -376,55 +376,22 @@ const SectionButtons = () => {
|
|
|
376
376
|
<ButtonWithDropdown
|
|
377
377
|
items={[
|
|
378
378
|
{
|
|
379
|
-
key: '1',
|
|
380
379
|
component: 'button',
|
|
381
380
|
icon: 'Percent',
|
|
382
|
-
|
|
381
|
+
text: 'Refer your friends',
|
|
383
382
|
},
|
|
384
383
|
{
|
|
385
|
-
key: '2',
|
|
386
384
|
component: 'a',
|
|
387
385
|
icon: 'Settings',
|
|
388
|
-
|
|
386
|
+
text: 'Account setings',
|
|
389
387
|
},
|
|
390
388
|
{
|
|
391
|
-
key: '3',
|
|
392
389
|
icon: 'ChangePlan',
|
|
393
|
-
|
|
390
|
+
text: 'Change plan',
|
|
394
391
|
},
|
|
395
392
|
{
|
|
396
|
-
key: '4',
|
|
397
393
|
icon: 'Logout',
|
|
398
|
-
|
|
399
|
-
},
|
|
400
|
-
]}
|
|
401
|
-
>
|
|
402
|
-
<Icon name="Bitbot" />
|
|
403
|
-
<Text>Account</Text>
|
|
404
|
-
</ButtonWithDropdown>
|
|
405
|
-
<ButtonWithDropdown
|
|
406
|
-
items={[
|
|
407
|
-
{
|
|
408
|
-
key: '1',
|
|
409
|
-
component: 'button',
|
|
410
|
-
icon: 'Percent',
|
|
411
|
-
content: 'Refer your friends',
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
key: '2',
|
|
415
|
-
component: 'a',
|
|
416
|
-
icon: 'Settings',
|
|
417
|
-
content: 'Account setings',
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
key: '3',
|
|
421
|
-
icon: 'ChangePlan',
|
|
422
|
-
content: 'Change plan',
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
key: '4',
|
|
426
|
-
icon: 'Logout',
|
|
427
|
-
content: 'Log out',
|
|
394
|
+
text: 'Log out',
|
|
428
395
|
},
|
|
429
396
|
]}
|
|
430
397
|
>
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
DropdownMenu,
|
|
5
5
|
DropdownMenus,
|
|
6
6
|
DropdownMenuItem,
|
|
7
|
+
DropdownMenuItemGroup,
|
|
7
8
|
Flex,
|
|
8
9
|
Icon,
|
|
9
10
|
Placement,
|
|
@@ -244,7 +245,6 @@ const SectionDropdown = () => {
|
|
|
244
245
|
setSelectedItem(undefined);
|
|
245
246
|
handleToggle3();
|
|
246
247
|
}}
|
|
247
|
-
sameWidth
|
|
248
248
|
visible={visible3}
|
|
249
249
|
>
|
|
250
250
|
{() => (
|
|
@@ -21,9 +21,7 @@ const SectionPlacement = () => {
|
|
|
21
21
|
const [selectedTab, setSelectedTab] = useState(1);
|
|
22
22
|
const [ref, setRef] = useState<SVGSVGElement>();
|
|
23
23
|
|
|
24
|
-
const handleToggle = () =>
|
|
25
|
-
setVisible(!visible);
|
|
26
|
-
};
|
|
24
|
+
const handleToggle = () => setVisible(!visible);
|
|
27
25
|
|
|
28
26
|
return (
|
|
29
27
|
<Section>
|
|
@@ -41,7 +39,6 @@ const SectionPlacement = () => {
|
|
|
41
39
|
<>
|
|
42
40
|
<PlacementManager>
|
|
43
41
|
<PlacementReference>
|
|
44
|
-
{/* eslint-disable-next-line @typescript-eslint/no-shadow */}
|
|
45
42
|
{({ ref }) => (
|
|
46
43
|
<Button innerRef={ref} level="primary" onClick={handleToggle}>
|
|
47
44
|
<Icon name="More" />
|
|
@@ -10,18 +10,14 @@ import {
|
|
|
10
10
|
PlacementManager,
|
|
11
11
|
PlacementProps,
|
|
12
12
|
PlacementReference,
|
|
13
|
-
BaseProps,
|
|
14
13
|
} from '@bitrise/bitkit';
|
|
15
14
|
|
|
16
15
|
export interface ItemProps extends DropdownMenuItemProps {
|
|
17
|
-
key: string;
|
|
18
16
|
component?: string;
|
|
19
17
|
disabled?: boolean;
|
|
20
18
|
href?: string;
|
|
21
|
-
onClick?: (e?: any) => void;
|
|
22
19
|
target?: string;
|
|
23
|
-
|
|
24
|
-
textColor?: BaseProps['textColor'];
|
|
20
|
+
text: string;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
export interface Props {
|
|
@@ -32,39 +28,46 @@ export interface Props {
|
|
|
32
28
|
placementProps?: PlacementProps;
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
const ButtonWithDropdown = ({
|
|
31
|
+
const ButtonWithDropdown = ({
|
|
32
|
+
buttonProps = {},
|
|
33
|
+
children,
|
|
34
|
+
dropdownWidth,
|
|
35
|
+
items,
|
|
36
|
+
placementProps,
|
|
37
|
+
}: Props): JSX.Element => {
|
|
36
38
|
const [visible, setVisible] = React.useState(false);
|
|
37
39
|
|
|
38
|
-
const onButtonClick = () => {
|
|
39
|
-
setVisible(!visible);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
40
|
return (
|
|
43
41
|
<PlacementManager>
|
|
44
42
|
<PlacementReference>
|
|
45
43
|
{({ ref }) => (
|
|
46
|
-
<Button innerRef={ref} {
|
|
44
|
+
<Button innerRef={ref} onClick={() => setVisible(true)} {...buttonProps}>
|
|
47
45
|
{children}
|
|
48
46
|
<Icon name="ChevronDown" />
|
|
49
47
|
</Button>
|
|
50
48
|
)}
|
|
51
49
|
</PlacementReference>
|
|
52
|
-
{!buttonProps
|
|
53
|
-
<Placement
|
|
50
|
+
{!buttonProps.disabled && (
|
|
51
|
+
<Placement
|
|
52
|
+
disableMargin="left-right"
|
|
53
|
+
onClose={() => setVisible(false)}
|
|
54
|
+
placement="bottom-end"
|
|
55
|
+
visible={visible}
|
|
56
|
+
{...placementProps}
|
|
57
|
+
>
|
|
54
58
|
{() => (
|
|
55
59
|
<DropdownMenu width={dropdownWidth} withArrow>
|
|
56
|
-
{items.map(({
|
|
60
|
+
{items.map(({ component, disabled, href, icon, onClick, target, text }) => (
|
|
57
61
|
<DropdownMenuItem
|
|
58
|
-
Component={component || '
|
|
62
|
+
Component={component || 'div'}
|
|
59
63
|
disabled={disabled}
|
|
60
64
|
href={href}
|
|
61
65
|
icon={icon}
|
|
66
|
+
key={text}
|
|
62
67
|
onClick={onClick}
|
|
63
|
-
key={key}
|
|
64
68
|
target={target}
|
|
65
|
-
textColor={textColor}
|
|
66
69
|
>
|
|
67
|
-
{
|
|
70
|
+
{text}
|
|
68
71
|
</DropdownMenuItem>
|
|
69
72
|
))}
|
|
70
73
|
</DropdownMenu>
|
|
@@ -63,7 +63,7 @@ const DatePickerDay: React.FunctionComponent<Props> = (props: Props) => {
|
|
|
63
63
|
onClick={isSelectable ? () => onSelect(date) : undefined}
|
|
64
64
|
>
|
|
65
65
|
<Flex alignChildren="middle" className="DatePicker__day-inner" direction="horizontal">
|
|
66
|
-
{isPreviousMonth && daysInPreviousMonth - (dayOfWeek - n)}
|
|
66
|
+
{isPreviousMonth && daysInPreviousMonth - (dayOfWeek - n - 1)}
|
|
67
67
|
{isCurrentMonth && n - dayOfWeek + 1}
|
|
68
68
|
{isNextMonth && n - dayOfWeek - daysInMonth + 1}
|
|
69
69
|
</Flex>
|
|
@@ -41,15 +41,17 @@ 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
|
+
|
|
44
46
|
const handleChange = (value: DropdownValue) => {
|
|
45
47
|
if (onChange) {
|
|
46
48
|
onChange(value);
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
handleToggleVisible();
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
const renderOption = ({ text, value }: Option) => (
|
|
52
|
-
<DropdownMenuItem onClick={() => handleChange(value)} selected={selected === value}
|
|
54
|
+
<DropdownMenuItem onClick={() => handleChange(value)} selected={selected === value}>
|
|
53
55
|
{text}
|
|
54
56
|
</DropdownMenuItem>
|
|
55
57
|
);
|
|
@@ -58,22 +60,15 @@ const Dropdown: React.FunctionComponent<Props> = (props: Props) => {
|
|
|
58
60
|
<PlacementManager>
|
|
59
61
|
<PlacementReference>
|
|
60
62
|
{({ ref }) => (
|
|
61
|
-
<DropdownButton
|
|
62
|
-
{...rest}
|
|
63
|
-
alignChildrenHorizontal="start"
|
|
64
|
-
innerRef={ref}
|
|
65
|
-
onClick={() => {
|
|
66
|
-
setVisible(!visible);
|
|
67
|
-
}}
|
|
68
|
-
>
|
|
63
|
+
<DropdownButton {...rest} alignChildrenHorizontal="start" innerRef={ref} onClick={handleToggleVisible}>
|
|
69
64
|
<Text ellipsis>{children}</Text>
|
|
70
65
|
</DropdownButton>
|
|
71
66
|
)}
|
|
72
67
|
</PlacementReference>
|
|
73
68
|
|
|
74
|
-
<Placement onClose={
|
|
75
|
-
{() => (
|
|
76
|
-
<DropdownMenu maxHeight={maxHeight} width=
|
|
69
|
+
<Placement onClose={handleToggleVisible} visible={visible}>
|
|
70
|
+
{({ width }) => (
|
|
71
|
+
<DropdownMenu maxHeight={maxHeight} width={width}>
|
|
77
72
|
{options.map((option) => (
|
|
78
73
|
<React.Fragment key={option.text}>
|
|
79
74
|
{'options' in option ? (
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
|
|
2
|
+
:root {
|
|
3
|
+
--Placement-arrow-size: var(--size--x3);
|
|
4
|
+
}
|
|
5
|
+
|
|
2
6
|
.Placement {
|
|
3
7
|
position: absolute;
|
|
8
|
+
margin: var(--Placement-arrow-size);
|
|
4
9
|
z-index: var(--z-index-Placement--below-modal);
|
|
5
10
|
pointer-events: none;
|
|
6
11
|
}
|
|
7
12
|
|
|
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
|
+
|
|
8
27
|
.Placement--animate {
|
|
9
28
|
transition-property: transform;
|
|
10
29
|
transition-duration: var(--transition-duration--fast);
|
|
@@ -64,51 +83,50 @@
|
|
|
64
83
|
border-top: 0.0625rem solid var(--color-gray--2);
|
|
65
84
|
}
|
|
66
85
|
|
|
67
|
-
.Placement__arrow
|
|
68
|
-
.Placement__arrow::before {
|
|
86
|
+
.Placement__arrow {
|
|
69
87
|
position: absolute;
|
|
70
|
-
width: var(--size
|
|
71
|
-
height: var(--size
|
|
88
|
+
width: var(--Placement-arrow-size);
|
|
89
|
+
height: var(--Placement-arrow-size);
|
|
72
90
|
}
|
|
73
91
|
|
|
74
92
|
.Placement__arrow,
|
|
75
93
|
.Placement__arrow:first-child,
|
|
76
94
|
.Placement__arrow:last-child {
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.Placement__arrow::before {
|
|
81
|
-
content: '';
|
|
82
|
-
display: block;
|
|
83
|
-
transform: rotate(45deg);
|
|
84
|
-
background: inherit;
|
|
85
|
-
visibility: visible;
|
|
95
|
+
margin: var(--Placement-arrow-size);
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
.Placement--top .Placement__arrow,
|
|
89
99
|
.Placement--top-start .Placement__arrow,
|
|
90
100
|
.Placement--top-end .Placement__arrow {
|
|
91
101
|
top: 100%;
|
|
92
|
-
|
|
102
|
+
transform:
|
|
103
|
+
translateY(calc(-50% + var(--Placement-arrow-size) * -1))
|
|
104
|
+
rotate(45deg);
|
|
93
105
|
}
|
|
94
106
|
|
|
95
107
|
.Placement--right .Placement__arrow,
|
|
96
108
|
.Placement--right-start .Placement__arrow,
|
|
97
109
|
.Placement--right-end .Placement__arrow {
|
|
98
110
|
right: 100%;
|
|
99
|
-
|
|
111
|
+
transform:
|
|
112
|
+
translateX(calc(50% - var(--Placement-arrow-size) * -1))
|
|
113
|
+
rotate(45deg);
|
|
100
114
|
}
|
|
101
115
|
|
|
102
116
|
.Placement--bottom .Placement__arrow,
|
|
103
117
|
.Placement--bottom-start .Placement__arrow,
|
|
104
118
|
.Placement--bottom-end .Placement__arrow {
|
|
105
119
|
bottom: 100%;
|
|
106
|
-
|
|
120
|
+
transform:
|
|
121
|
+
translateY(calc(50% - var(--Placement-arrow-size) * -1))
|
|
122
|
+
rotate(45deg);
|
|
107
123
|
}
|
|
108
124
|
|
|
109
125
|
.Placement--left .Placement__arrow,
|
|
110
126
|
.Placement--left-start .Placement__arrow,
|
|
111
127
|
.Placement--left-end .Placement__arrow {
|
|
112
128
|
left: 100%;
|
|
113
|
-
|
|
129
|
+
transform:
|
|
130
|
+
translateX(calc(-50% + var(--Placement-arrow-size) * -1))
|
|
131
|
+
rotate(45deg);
|
|
114
132
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Placement as TypePlacement } from '
|
|
2
|
+
import { Placement as TypePlacement, ReferenceObject as TypeReferenceObject } from 'popper.js';
|
|
3
3
|
import { Props as BaseProps } from '../Base/Base';
|
|
4
4
|
import { ModalContext } from '../Modal/ModalContext';
|
|
5
5
|
import PlacementPopper from './PlacementPopper';
|
|
@@ -13,11 +13,15 @@ export interface Props extends BaseProps {
|
|
|
13
13
|
animatePosition?: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* A render callback function that provides a
|
|
16
|
-
*
|
|
16
|
+
* scheduleUpdate 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: {
|
|
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';
|
|
21
25
|
/**
|
|
22
26
|
* Flag that disables repositioning on scroll and resize events.
|
|
23
27
|
*/
|
|
@@ -41,8 +45,7 @@ export interface Props extends BaseProps {
|
|
|
41
45
|
/**
|
|
42
46
|
* An optional reference element to be used as the target.
|
|
43
47
|
*/
|
|
44
|
-
referenceElement?:
|
|
45
|
-
sameWidth?: boolean;
|
|
48
|
+
referenceElement?: TypeReferenceObject;
|
|
46
49
|
/**
|
|
47
50
|
* The visibilty of the positioned content.
|
|
48
51
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/* eslint-disable react/default-props-match-prop-types */
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { createPortal } from 'react-dom';
|
|
4
|
-
import { Placement as TypePlacement,
|
|
3
|
+
import { Placement as TypePlacement, ReferenceObject as TypeReferenceObject } from 'popper.js';
|
|
5
4
|
import { Popper, PopperProps } from 'react-popper';
|
|
6
5
|
import { CSSTransition } from 'react-transition-group';
|
|
7
6
|
import classnames from 'classnames';
|
|
@@ -28,14 +27,15 @@ const transitionClasses = {
|
|
|
28
27
|
|
|
29
28
|
export interface Props extends BaseProps {
|
|
30
29
|
animatePosition?: boolean;
|
|
31
|
-
children: (props: {
|
|
30
|
+
children: (props: { scheduleUpdate: () => void; width?: number }) => React.ReactNode;
|
|
32
31
|
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?:
|
|
38
|
+
referenceElement?: TypeReferenceObject;
|
|
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,
|
|
49
50
|
disableReposition,
|
|
50
51
|
flip,
|
|
51
52
|
isInsideModal,
|
|
52
53
|
onClose,
|
|
53
54
|
placement: desiredPlacement,
|
|
54
55
|
referenceElement,
|
|
55
|
-
sameWidth,
|
|
56
56
|
visible,
|
|
57
57
|
timeout = transitionDurationFast,
|
|
58
58
|
...rest
|
|
@@ -61,8 +61,6 @@ 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
|
-
|
|
66
64
|
useEffect(() => {
|
|
67
65
|
if (visible) {
|
|
68
66
|
setRender(true);
|
|
@@ -73,14 +71,11 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
|
|
|
73
71
|
closeElement || document,
|
|
74
72
|
'click',
|
|
75
73
|
(event) => {
|
|
76
|
-
|
|
77
|
-
/* @ts-ignore */
|
|
78
|
-
const isReferenceInPath = [...event.composedPath()].includes(reference);
|
|
79
|
-
if (onClose && ref.current && !ref.current.contains(event.target as Node) && !isReferenceInPath) {
|
|
74
|
+
if (onClose && ref.current && !ref.current.contains(event.target as Node)) {
|
|
80
75
|
onClose(event as MouseEvent);
|
|
81
76
|
}
|
|
82
77
|
},
|
|
83
|
-
[onClose
|
|
78
|
+
[onClose],
|
|
84
79
|
);
|
|
85
80
|
|
|
86
81
|
useEventListener(
|
|
@@ -98,36 +93,19 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
|
|
|
98
93
|
return null;
|
|
99
94
|
}
|
|
100
95
|
|
|
101
|
-
const
|
|
102
|
-
{
|
|
103
|
-
name: 'offset',
|
|
104
|
-
options: {
|
|
105
|
-
offset: [0, 12],
|
|
106
|
-
},
|
|
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> = {
|
|
96
|
+
const popperProps: PopperProps = {
|
|
128
97
|
children: () => null,
|
|
98
|
+
eventsEnabled: !disableReposition,
|
|
129
99
|
placement: desiredPlacement,
|
|
130
|
-
modifiers
|
|
100
|
+
modifiers: {
|
|
101
|
+
preventOverflow: {
|
|
102
|
+
boundariesElement: 'window',
|
|
103
|
+
},
|
|
104
|
+
flip: {
|
|
105
|
+
behavior: 'flip',
|
|
106
|
+
enabled: flip,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
131
109
|
};
|
|
132
110
|
|
|
133
111
|
if (referenceElement) {
|
|
@@ -136,45 +114,39 @@ const PlacementPopper: React.FunctionComponent<Props> = (props: Props) => {
|
|
|
136
114
|
|
|
137
115
|
return createPortal(
|
|
138
116
|
// eslint-disable-next-line no-return-assign
|
|
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
|
-
>
|
|
117
|
+
<Popper {...popperProps} innerRef={(el) => (ref.current = el || null)}>
|
|
147
118
|
{/* eslint-disable-next-line @typescript-eslint/no-shadow */}
|
|
148
|
-
{({ arrowProps, placement, ref,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
+
)}
|
|
178
150
|
</Popper>,
|
|
179
151
|
document.body,
|
|
180
152
|
);
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ReferenceChildrenProps } from 'react-popper';
|
|
3
|
-
import { Placement as TypePlacement } from '
|
|
3
|
+
import { Placement as TypePlacement } from 'popper.js';
|
|
4
4
|
import { Props as BaseProps } from '../Base/Base';
|
|
5
5
|
import Placement from '../Placement/Placement';
|
|
6
6
|
import PlacementArea from '../Placement/PlacementArea';
|
|
@@ -4,30 +4,10 @@ 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>(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
|
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;
|
|
31
11
|
function useEventListener(el: any, type: string, handler: any, watch?: any[]) {
|
|
32
12
|
useEffect(() => {
|
|
33
13
|
if (el) {
|
|
@@ -40,6 +20,6 @@ function useEventListener(el: any, type: string, handler: any, watch?: any[]) {
|
|
|
40
20
|
}
|
|
41
21
|
};
|
|
42
22
|
}, watch || []);
|
|
43
|
-
}
|
|
23
|
+
};
|
|
44
24
|
|
|
45
25
|
export default useEventListener;
|
package/.husky/commit-msg
DELETED