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