@targetprocess/popover 12.20.1-alpha.4 → 12.21.0
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/BodyDomNode.tsx +79 -76
- package/CHANGELOG.md +22 -22
- package/Popover.tsx +191 -188
- package/PopoverBody.tsx +40 -37
- package/PopoverContainer.tsx +325 -322
- package/PopoverPosition.ts +62 -59
- package/PositioningTarget.tsx +29 -26
- package/StatlessPopover.tsx +98 -101
- package/__tests__/BodyDomNode.tests.tsx +287 -284
- package/__tests__/Popover.tests.tsx +66 -63
- package/__tests__/PositioningTarget.tests.tsx +46 -43
- package/dist/BodyDomNode.d.ts +3 -0
- package/dist/Popover.d.ts +3 -0
- package/dist/PopoverBody.d.ts +3 -0
- package/dist/PopoverContainer.d.ts +3 -0
- package/dist/PositioningTarget.d.ts +3 -0
- package/dist/StatlessPopover.d.ts +4 -1
- package/dist/index.d.ts +3 -0
- package/dist/popover.es.js +22 -11
- package/dist/popover.js +22 -11
- package/dist/types.d.ts +3 -0
- package/index.ts +17 -14
- package/package.json +3 -3
- package/style/index.css +107 -104
- package/types.ts +40 -37
package/style/index.css
CHANGED
|
@@ -1,104 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
$popoverTipSize: 16px;
|
|
5
|
+
|
|
6
|
+
.popover-body-container {
|
|
7
|
+
box-shadow: $gBoxShadowL;
|
|
8
|
+
border-radius: $gBorderRadiusL;
|
|
9
|
+
border: 1px solid $gHighlightBlockBorderColor;
|
|
10
|
+
background: $gBackgroundDefault;
|
|
11
|
+
z-index: $gZIndexModal;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.popover-body {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
padding: $gSpaceSM;
|
|
18
|
+
font-size: $gFontSizeDefault;
|
|
19
|
+
color: $gFontColorDefault;
|
|
20
|
+
|
|
21
|
+
&--no-padding {
|
|
22
|
+
padding: 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.popover-tip {
|
|
27
|
+
position: absolute;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
z-index: calc($gZIndexModal + 1);
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
|
|
35
|
+
&:before {
|
|
36
|
+
content: '';
|
|
37
|
+
position: absolute;
|
|
38
|
+
display: block;
|
|
39
|
+
box-sizing: border-box;
|
|
40
|
+
background-color: $gBackgroundDefault;
|
|
41
|
+
border: 1px solid $gHighlightBlockBorderColor;
|
|
42
|
+
/*
|
|
43
|
+
geometry FTW
|
|
44
|
+
|
|
45
|
+
2*$popoverTipSize
|
|
46
|
+
_______ _______
|
|
47
|
+
| /|\ |
|
|
48
|
+
| / | \ | $popoverTipSize
|
|
49
|
+
| / | \ |
|
|
50
|
+
|/______|______\|
|
|
51
|
+
since tip is rotated 45 degrees, its width and height is a
|
|
52
|
+
diagonal of a square with side=$popoverTipSize, thus diagonal
|
|
53
|
+
is sqrt(2) * $popoverTipSize.
|
|
54
|
+
sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding
|
|
55
|
+
*/
|
|
56
|
+
width: calc($popoverTipSize / 2 * 1.4);
|
|
57
|
+
height: calc($popoverTipSize / 2 * 1.4);
|
|
58
|
+
transform: rotate(45deg);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&--bottom,
|
|
62
|
+
&--top {
|
|
63
|
+
width: 100%;
|
|
64
|
+
border-top: 1px $gBackgroundDefault;
|
|
65
|
+
border-bottom: 1px $gBackgroundDefault;
|
|
66
|
+
height: calc($popoverTipSize / 2 + 1px);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&--left,
|
|
70
|
+
&--right {
|
|
71
|
+
border-left: 1px $gBackgroundDefault;
|
|
72
|
+
border-right: 1px $gBackgroundDefault;
|
|
73
|
+
height: 100%;
|
|
74
|
+
width: calc($popoverTipSize / 2 + 1px);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
To determine tip position, we need to rotate it
|
|
79
|
+
along the "tip" point, after that, the "tip" point
|
|
80
|
+
can be placed with exactly 50% offset from the origin
|
|
81
|
+
so that it is centered.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
&--bottom:before {
|
|
85
|
+
transform-origin: left top;
|
|
86
|
+
left: 50%;
|
|
87
|
+
top: 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&--top:before {
|
|
91
|
+
transform-origin: right bottom;
|
|
92
|
+
right: 50%;
|
|
93
|
+
bottom: 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&--left:before {
|
|
97
|
+
transform-origin: right top;
|
|
98
|
+
right: 0;
|
|
99
|
+
top: 50%;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&--right:before {
|
|
103
|
+
transform-origin: left bottom;
|
|
104
|
+
left: 0;
|
|
105
|
+
bottom: 50%;
|
|
106
|
+
}
|
|
107
|
+
}
|
package/types.ts
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
import {CSSProperties} from 'react'
|
|
5
|
+
|
|
6
|
+
export type PositionParams = {
|
|
7
|
+
left: number
|
|
8
|
+
top: number
|
|
9
|
+
right?: number
|
|
10
|
+
bottom?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type DimensionParams = {
|
|
14
|
+
height: number
|
|
15
|
+
width: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type GetPopoverPositionCallback = (
|
|
19
|
+
hostRect: DimensionParams,
|
|
20
|
+
popoverRect: DimensionParams,
|
|
21
|
+
containerScroll: PositionParams,
|
|
22
|
+
containerElement?: HTMLElement
|
|
23
|
+
) => CSSProperties
|
|
24
|
+
|
|
25
|
+
export type DefaultPopoverPositions = {
|
|
26
|
+
bottomLeft: GetPopoverPositionCallback
|
|
27
|
+
bottom: GetPopoverPositionCallback
|
|
28
|
+
bottomRight: GetPopoverPositionCallback
|
|
29
|
+
topLeft: GetPopoverPositionCallback
|
|
30
|
+
top: GetPopoverPositionCallback
|
|
31
|
+
topRight: GetPopoverPositionCallback
|
|
32
|
+
leftTop: GetPopoverPositionCallback
|
|
33
|
+
left: GetPopoverPositionCallback
|
|
34
|
+
leftBottom: GetPopoverPositionCallback
|
|
35
|
+
rightTop: GetPopoverPositionCallback
|
|
36
|
+
right: GetPopoverPositionCallback
|
|
37
|
+
rightBottom: GetPopoverPositionCallback
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type GetPopoverPositionType = GetPopoverPositionCallback | keyof DefaultPopoverPositions
|