@scm-manager/ui-components 2.30.2-20220115-125803 → 2.30.2-20220115-150339
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/package.json +5 -5
- package/src/Tooltip.tsx +24 -166
- package/src/__snapshots__/storyshots.test.ts.snap +2059 -2588
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scm-manager/ui-components",
|
|
3
|
-
"version": "2.30.2-20220115-
|
|
3
|
+
"version": "2.30.2-20220115-150339",
|
|
4
4
|
"description": "UI Components for SCM-Manager and its plugins",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@scm-manager/jest-preset": "^2.13.0",
|
|
26
26
|
"@scm-manager/prettier-config": "^2.10.1",
|
|
27
27
|
"@scm-manager/tsconfig": "^2.12.0",
|
|
28
|
-
"@scm-manager/ui-tests": "^2.30.2-20220115-
|
|
28
|
+
"@scm-manager/ui-tests": "^2.30.2-20220115-150339",
|
|
29
29
|
"@storybook/addon-actions": "^6.3.12",
|
|
30
30
|
"@storybook/addon-storyshots": "^6.3.12",
|
|
31
31
|
"@storybook/builder-webpack5": "^6.3.12",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@headlessui/react": "^1.4.3",
|
|
69
|
-
"@scm-manager/ui-api": "^2.30.2-20220115-
|
|
70
|
-
"@scm-manager/ui-extensions": "^2.30.2-20220115-
|
|
71
|
-
"@scm-manager/ui-types": "^2.30.2-20220115-
|
|
69
|
+
"@scm-manager/ui-api": "^2.30.2-20220115-150339",
|
|
70
|
+
"@scm-manager/ui-extensions": "^2.30.2-20220115-150339",
|
|
71
|
+
"@scm-manager/ui-types": "^2.30.2-20220115-150339",
|
|
72
72
|
"classnames": "^2.2.6",
|
|
73
73
|
"date-fns": "^2.4.1",
|
|
74
74
|
"deepmerge": "^4.2.2",
|
package/src/Tooltip.tsx
CHANGED
|
@@ -21,128 +21,12 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
import React, {
|
|
25
|
-
import styled from "styled-components";
|
|
26
|
-
import classNames from "classnames";
|
|
27
|
-
|
|
28
|
-
// See for css reference: https://github.com/Wikiki/bulma-tooltip/blob/master/src/sass/index.sass
|
|
29
|
-
|
|
30
|
-
const TooltipWrapper = styled.span`
|
|
31
|
-
position: relative;
|
|
32
|
-
display: inline-block;
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const ArrowBase = styled.span`
|
|
36
|
-
z-index: 1020;
|
|
37
|
-
position: absolute;
|
|
38
|
-
width: 0;
|
|
39
|
-
height: 0;
|
|
40
|
-
border-style: solid;
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
const ArrowTop = styled(ArrowBase)`
|
|
44
|
-
top: 0;
|
|
45
|
-
right: auto;
|
|
46
|
-
bottom: auto;
|
|
47
|
-
left: 50%;
|
|
48
|
-
margin-top: -5px;
|
|
49
|
-
margin-right: auto;
|
|
50
|
-
margin-bottom: auto;
|
|
51
|
-
margin-left: -5px;
|
|
52
|
-
border-width: 5px 5px 0 5px;
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
const ArrowRight = styled(ArrowBase)`
|
|
56
|
-
top: auto;
|
|
57
|
-
right: 0;
|
|
58
|
-
bottom: 50%;
|
|
59
|
-
left: auto;
|
|
60
|
-
margin-top: auto;
|
|
61
|
-
margin-right: -5px;
|
|
62
|
-
margin-bottom: -5px;
|
|
63
|
-
margin-left: auto;
|
|
64
|
-
border-width: 5px 5px 5px 0;
|
|
65
|
-
`;
|
|
66
|
-
|
|
67
|
-
const ArrowLeft = styled(ArrowBase)`
|
|
68
|
-
top: auto;
|
|
69
|
-
right: auto;
|
|
70
|
-
bottom: 50%;
|
|
71
|
-
left: 0;
|
|
72
|
-
margin-top: auto;
|
|
73
|
-
margin-right: auto;
|
|
74
|
-
margin-bottom: -5px;
|
|
75
|
-
margin-left: -5px;
|
|
76
|
-
border-width: 5px 0 5px 5px;
|
|
77
|
-
`;
|
|
78
|
-
|
|
79
|
-
const ArrowBottom = styled(ArrowBase)`
|
|
80
|
-
top: auto;
|
|
81
|
-
right: auto;
|
|
82
|
-
bottom: 0;
|
|
83
|
-
left: 50%;
|
|
84
|
-
margin-top: auto;
|
|
85
|
-
margin-right: auto;
|
|
86
|
-
margin-bottom: -5px;
|
|
87
|
-
margin-left: -5px;
|
|
88
|
-
border-width: 0 5px 5px 5px;
|
|
89
|
-
`;
|
|
90
|
-
|
|
91
|
-
const Arrow = {
|
|
92
|
-
bottom: ArrowBottom,
|
|
93
|
-
left: ArrowLeft,
|
|
94
|
-
right: ArrowRight,
|
|
95
|
-
top: ArrowTop
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const TooltipContainerBase = styled.div<{ multiline?: boolean }>`
|
|
99
|
-
z-index: 1020;
|
|
100
|
-
position: absolute;
|
|
101
|
-
padding: 0.5rem 1rem;
|
|
102
|
-
overflow: hidden;
|
|
103
|
-
hyphens: auto;
|
|
104
|
-
text-overflow: ${({ multiline }) => (multiline ? "clip" : "ellipsis")};
|
|
105
|
-
white-space: ${({ multiline }) => (multiline ? "normal" : "pre")};
|
|
106
|
-
max-width: ${({ multiline }) => (multiline ? "15rem" : "auto")};
|
|
107
|
-
width: ${({ multiline }) => (multiline ? "15rem" : "auto")};
|
|
108
|
-
word-break: ${({ multiline }) => (multiline ? "keep-all" : "unset")};
|
|
109
|
-
`;
|
|
110
|
-
|
|
111
|
-
const TooltipContainerTop = styled(TooltipContainerBase)`
|
|
112
|
-
left: 50%;
|
|
113
|
-
bottom: calc(100% + 5px);
|
|
114
|
-
transform: translateX(-50%);
|
|
115
|
-
`;
|
|
116
|
-
|
|
117
|
-
const TooltipContainerBottom = styled(TooltipContainerBase)`
|
|
118
|
-
left: 50%;
|
|
119
|
-
top: calc(100% + 5px);
|
|
120
|
-
transform: translateX(-50%);
|
|
121
|
-
`;
|
|
122
|
-
|
|
123
|
-
const TooltipContainerLeft = styled(TooltipContainerBase)`
|
|
124
|
-
right: calc(100% + 5px);
|
|
125
|
-
top: 50%;
|
|
126
|
-
transform: translateY(-50%);
|
|
127
|
-
`;
|
|
128
|
-
|
|
129
|
-
const TooltipContainerRight = styled(TooltipContainerBase)`
|
|
130
|
-
left: calc(100% + 5px);
|
|
131
|
-
top: 50%;
|
|
132
|
-
transform: translateY(-50%);
|
|
133
|
-
`;
|
|
134
|
-
|
|
135
|
-
const Container = {
|
|
136
|
-
bottom: TooltipContainerBottom,
|
|
137
|
-
left: TooltipContainerLeft,
|
|
138
|
-
right: TooltipContainerRight,
|
|
139
|
-
top: TooltipContainerTop
|
|
140
|
-
};
|
|
24
|
+
import React, { ReactNode } from "react";
|
|
141
25
|
|
|
142
26
|
type Props = {
|
|
143
27
|
message: string;
|
|
144
28
|
className?: string;
|
|
145
|
-
location
|
|
29
|
+
location: TooltipLocation;
|
|
146
30
|
multiline?: boolean;
|
|
147
31
|
children: ReactNode;
|
|
148
32
|
id?: string;
|
|
@@ -150,53 +34,27 @@ type Props = {
|
|
|
150
34
|
|
|
151
35
|
export type TooltipLocation = "bottom" | "right" | "top" | "left";
|
|
152
36
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
{open ? (
|
|
176
|
-
<>
|
|
177
|
-
<LocationArrow className={`tooltip-arrow-${location}-border-color`} />
|
|
178
|
-
<LocationContainer
|
|
179
|
-
className={classNames(
|
|
180
|
-
className,
|
|
181
|
-
"is-size-7",
|
|
182
|
-
"is-family-primary",
|
|
183
|
-
"has-rounded-border",
|
|
184
|
-
"has-text-white",
|
|
185
|
-
"has-background-grey-dark",
|
|
186
|
-
"has-text-weight-semibold"
|
|
187
|
-
)}
|
|
188
|
-
multiline={multiline}
|
|
189
|
-
aria-live="polite"
|
|
190
|
-
id={id}
|
|
191
|
-
role="tooltip"
|
|
192
|
-
>
|
|
193
|
-
{message}
|
|
194
|
-
</LocationContainer>
|
|
195
|
-
</>
|
|
196
|
-
) : null}
|
|
197
|
-
{children}
|
|
198
|
-
</TooltipWrapper>
|
|
199
|
-
);
|
|
200
|
-
};
|
|
37
|
+
class Tooltip extends React.Component<Props> {
|
|
38
|
+
static defaultProps = {
|
|
39
|
+
location: "right"
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
render() {
|
|
43
|
+
const { className, message, location, multiline, children, id } = this.props;
|
|
44
|
+
let classes = `tooltip has-tooltip-${location}`;
|
|
45
|
+
if (multiline) {
|
|
46
|
+
classes += " has-tooltip-multiline";
|
|
47
|
+
}
|
|
48
|
+
if (className) {
|
|
49
|
+
classes += " " + className;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<span className={classes} data-tooltip={message} aria-label={message} id={id}>
|
|
54
|
+
{children}
|
|
55
|
+
</span>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
201
59
|
|
|
202
60
|
export default Tooltip;
|