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