@ssa-ui-kit/core 0.0.24-alpha → 0.0.25-alpha
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/dist/components/Tooltip/types.d.ts +1 -3
- package/dist/components/TooltipContent/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -3
- package/src/components/Tooltip/Tooltip.stories.tsx +14 -29
- package/src/components/Tooltip/types.ts +1 -3
- package/src/components/TooltipContent/TooltipContent.tsx +4 -26
- package/src/components/TooltipContent/index.ts +0 -1
- package/tsbuildcache +1 -1
- package/dist/components/TooltipContent/constants.d.ts +0 -1
- package/src/components/TooltipContent/constants.ts +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssa-ui-kit/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25-alpha",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"private": false,
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"@nivo/line": "0.83.0",
|
|
24
24
|
"@playwright/test": "^1.37.1",
|
|
25
25
|
"@testing-library/jest-dom": "^5.16.5",
|
|
26
|
-
"@types/dompurify": "^3.0.5",
|
|
27
26
|
"@types/testing-library__jest-dom": "^5.14.6",
|
|
28
27
|
"@types/uuid": "^9.0.3",
|
|
29
28
|
"resolve-tspaths": "^0.8.16",
|
|
@@ -37,7 +36,6 @@
|
|
|
37
36
|
"@emotion/react": "^11.11.1",
|
|
38
37
|
"@emotion/styled": "^11.11.0",
|
|
39
38
|
"@floating-ui/react": "0.25.4",
|
|
40
|
-
"dompurify": "^3.1.3",
|
|
41
39
|
"dotenv": "^16.0.3",
|
|
42
40
|
"js-tokens": "^4.0.0",
|
|
43
41
|
"loose-envify": "^1.4.0",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Fragment } from 'react';
|
|
2
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
2
|
import { useTheme } from '@emotion/react';
|
|
4
3
|
|
|
@@ -51,13 +50,7 @@ export const OnClick: StoryObj<typeof Tooltip> = (args: Args) => {
|
|
|
51
50
|
<TooltipTrigger>
|
|
52
51
|
<Button size="medium" text="Click me!" />
|
|
53
52
|
</TooltipTrigger>
|
|
54
|
-
<TooltipContent
|
|
55
|
-
<Fragment>
|
|
56
|
-
<u>
|
|
57
|
-
<b>Tooltip</b>
|
|
58
|
-
</u>
|
|
59
|
-
</Fragment>
|
|
60
|
-
</TooltipContent>
|
|
53
|
+
<TooltipContent>Tooltip</TooltipContent>
|
|
61
54
|
</Tooltip>
|
|
62
55
|
);
|
|
63
56
|
};
|
|
@@ -73,9 +66,7 @@ export const OnHover: StoryObj<typeof Tooltip> = (args: Args) => {
|
|
|
73
66
|
<TooltipTrigger>
|
|
74
67
|
<Button size="medium" text="Hover over me!" />
|
|
75
68
|
</TooltipTrigger>
|
|
76
|
-
<TooltipContent>
|
|
77
|
-
<Fragment>Tooltip</Fragment>
|
|
78
|
-
</TooltipContent>
|
|
69
|
+
<TooltipContent>Tooltip</TooltipContent>
|
|
79
70
|
</Tooltip>
|
|
80
71
|
);
|
|
81
72
|
};
|
|
@@ -99,18 +90,16 @@ export const CustomContent: StoryObj<typeof Tooltip> = (args: Args) => {
|
|
|
99
90
|
/>
|
|
100
91
|
</TooltipTrigger>
|
|
101
92
|
<TooltipContent css={{ textAlign: 'center' }}>
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
</div>
|
|
113
|
-
</Fragment>
|
|
93
|
+
<Typography variant="h6">Your progress</Typography>
|
|
94
|
+
<div css={{ margin: '0 auto', width: '60px' }}>
|
|
95
|
+
<ProgressCircle
|
|
96
|
+
max={100}
|
|
97
|
+
currentValue={80}
|
|
98
|
+
color="purple"
|
|
99
|
+
infoContent="80%"
|
|
100
|
+
size={60}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
114
103
|
</TooltipContent>
|
|
115
104
|
</Tooltip>
|
|
116
105
|
);
|
|
@@ -134,9 +123,7 @@ export const NoArrow: StoryObj<typeof Tooltip> = (args: Args) => {
|
|
|
134
123
|
text="Action"
|
|
135
124
|
/>
|
|
136
125
|
</TooltipTrigger>
|
|
137
|
-
<TooltipContent>
|
|
138
|
-
<Fragment>No arrow</Fragment>
|
|
139
|
-
</TooltipContent>
|
|
126
|
+
<TooltipContent>No arrow</TooltipContent>
|
|
140
127
|
</Tooltip>
|
|
141
128
|
);
|
|
142
129
|
};
|
|
@@ -154,9 +141,7 @@ export const Opened: StoryObj<typeof Tooltip> = (args: Args) => {
|
|
|
154
141
|
<TooltipTrigger>
|
|
155
142
|
<Button size="medium" text="Hover over me!" />
|
|
156
143
|
</TooltipTrigger>
|
|
157
|
-
<TooltipContent>
|
|
158
|
-
<Fragment>Tooltip</Fragment>
|
|
159
|
-
</TooltipContent>
|
|
144
|
+
<TooltipContent>Tooltip</TooltipContent>
|
|
160
145
|
</Tooltip>
|
|
161
146
|
);
|
|
162
147
|
};
|
|
@@ -56,11 +56,9 @@ export type TooltipArrowProps = Omit<
|
|
|
56
56
|
>;
|
|
57
57
|
|
|
58
58
|
export interface ITooltipContentProps {
|
|
59
|
-
children: React.
|
|
59
|
+
children: React.ReactNode;
|
|
60
60
|
className?: string;
|
|
61
61
|
style?: React.CSSProperties;
|
|
62
|
-
allowTags?: boolean;
|
|
63
|
-
allowedTags?: string[];
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
export interface ITooltipContentSizes {
|
|
@@ -1,42 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { renderToString } from 'react-dom/server';
|
|
1
|
+
import { forwardRef } from 'react';
|
|
3
2
|
import {
|
|
4
3
|
FloatingPortal,
|
|
5
4
|
FloatingFocusManager,
|
|
6
5
|
useMergeRefs,
|
|
7
6
|
} from '@floating-ui/react';
|
|
8
|
-
|
|
7
|
+
|
|
9
8
|
import { TooltipArrow } from '@components/Tooltip/TooltipArrow';
|
|
10
9
|
import { TooltipContentBase } from '@components/Tooltip/TooltipContentBase';
|
|
11
10
|
import { ITooltipContentProps, TooltipSize } from '@components/Tooltip/types';
|
|
12
11
|
import { useTooltipContext } from '@components/Tooltip/useTooltipContext';
|
|
13
12
|
import { mapSizes } from '@components/Tooltip/utils';
|
|
14
|
-
import { ALLOWED_TAGS } from './constants';
|
|
15
13
|
|
|
16
14
|
const TooltipContent = forwardRef<HTMLDivElement, ITooltipContentProps>(
|
|
17
|
-
function TooltipContent(
|
|
18
|
-
{
|
|
19
|
-
children,
|
|
20
|
-
className,
|
|
21
|
-
style,
|
|
22
|
-
allowTags = false,
|
|
23
|
-
allowedTags = ALLOWED_TAGS,
|
|
24
|
-
},
|
|
25
|
-
refProp,
|
|
26
|
-
) {
|
|
15
|
+
function TooltipContent({ children, className, style }, refProp) {
|
|
27
16
|
const tooltipCtx = useTooltipContext();
|
|
28
17
|
const ref = useMergeRefs([tooltipCtx?.refs.setFloating, refProp]);
|
|
29
|
-
let output: string | ReactNode = '';
|
|
30
|
-
|
|
31
|
-
if (allowTags) {
|
|
32
|
-
const html = renderToString(children);
|
|
33
|
-
const htmlSanitized = DOMPurify.sanitize(html, {
|
|
34
|
-
ALLOWED_TAGS: allowedTags,
|
|
35
|
-
});
|
|
36
|
-
output = <div dangerouslySetInnerHTML={{ __html: htmlSanitized }} />;
|
|
37
|
-
} else {
|
|
38
|
-
output = children;
|
|
39
|
-
}
|
|
40
18
|
|
|
41
19
|
return (
|
|
42
20
|
<FloatingPortal>
|
|
@@ -59,7 +37,7 @@ const TooltipContent = forwardRef<HTMLDivElement, ITooltipContentProps>(
|
|
|
59
37
|
{tooltipCtx.hasArrow && (
|
|
60
38
|
<TooltipArrow {...tooltipCtx.arrowProps} />
|
|
61
39
|
)}
|
|
62
|
-
{
|
|
40
|
+
{children}
|
|
63
41
|
</TooltipContentBase>
|
|
64
42
|
</FloatingFocusManager>
|
|
65
43
|
)}
|