widenarrow-ui 0.1.11 → 0.1.13
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/.eslintrc +4 -0
- package/lib/components/Button/Button.d.ts +1 -1
- package/lib/components/Checkbox/Checkbox.d.ts +1 -1
- package/lib/components/IconButton/IconButton.d.ts +2 -2
- package/lib/components/InlineButton/InlineButton.d.ts +1 -1
- package/lib/components/Separator/Separator.stories.d.ts +3 -1
- package/lib/components/ToolTip/ToolTip.d.ts +3 -1
- package/lib/index.esm.js +42 -40
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +41 -39
- package/lib/index.js.map +1 -1
- package/package.json +7 -5
- package/rollup.config.mjs +2 -2
- package/src/components/Box/Box.tsx +1 -1
- package/src/components/Button/Button.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/Icon/Icon.stories.tsx +2 -2
- package/src/components/Icon/Icon.tsx +1 -1
- package/src/components/IconButton/IconButton.tsx +3 -3
- package/src/components/InlineButton/InlineButton.tsx +2 -2
- package/src/components/Separator/Separator.stories.tsx +15 -6
- package/src/components/ToolTip/ToolTip.module.scss +7 -2
- package/src/components/ToolTip/ToolTip.tsx +59 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "widenarrow-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "A storybook 6 typeScript component library used for Wide Narrow by infodesk",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.esm.js",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@types/classnames": "2.3.1",
|
|
38
38
|
"@types/ramda": "0.29.4",
|
|
39
39
|
"@types/react": "18.2.21",
|
|
40
|
+
"@types/react-dom": "^18.2.14",
|
|
40
41
|
"@typescript-eslint/eslint-plugin": "5.29.0",
|
|
41
42
|
"autoprefixer": "10.4.15",
|
|
42
43
|
"babel-eslint": "10.1.0",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"postcss": "8.4.21",
|
|
48
49
|
"react": "18.2.0",
|
|
49
50
|
"react-dom": "18.2.0",
|
|
51
|
+
"react-tooltip": "5.21.5",
|
|
50
52
|
"rollup": "3.21.6",
|
|
51
53
|
"rollup-plugin-copy": "3.5.0",
|
|
52
54
|
"rollup-plugin-dts": "5.3.0",
|
|
@@ -56,14 +58,14 @@
|
|
|
56
58
|
"storybook": "7.4.2",
|
|
57
59
|
"storybook-css-modules": "1.0.8",
|
|
58
60
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
59
|
-
"typescript": "5.0.4"
|
|
60
|
-
"react-tooltip": "5.21.5"
|
|
61
|
+
"typescript": "5.0.4"
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
|
-
"react
|
|
64
|
+
"@types/react": "18.2.21",
|
|
64
65
|
"ramda": "0.26.1",
|
|
65
66
|
"react": "18.2.0",
|
|
66
|
-
"react-dom": "18.2.0"
|
|
67
|
+
"react-dom": "18.2.0",
|
|
68
|
+
"react-tooltip": "5.21.5"
|
|
67
69
|
},
|
|
68
70
|
"dependencies": {
|
|
69
71
|
"classnames": "2.2.6"
|
package/rollup.config.mjs
CHANGED
|
@@ -53,7 +53,7 @@ export default [
|
|
|
53
53
|
src: 'src/styles/baseline.scss',
|
|
54
54
|
dest: 'lib/styles'
|
|
55
55
|
}
|
|
56
|
-
]
|
|
56
|
+
]
|
|
57
57
|
})
|
|
58
58
|
],
|
|
59
59
|
external: ['ramda', 'react']
|
|
@@ -63,5 +63,5 @@ export default [
|
|
|
63
63
|
output: [{ file: 'lib/index.d.ts', format: 'es' }],
|
|
64
64
|
plugins: [dts()],
|
|
65
65
|
external: [/\.css$/, 'ramda', 'react']
|
|
66
|
-
}
|
|
66
|
+
}
|
|
67
67
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC, ReactNode, MouseEvent, CSSProperties
|
|
1
|
+
import React, { FC, ReactNode, MouseEvent, CSSProperties } from 'react';
|
|
2
2
|
import classNames from 'classnames/bind';
|
|
3
3
|
|
|
4
4
|
import { HierarchyTypes, SizeTypes, IconTypes } from 'src/constants';
|
|
@@ -123,7 +123,7 @@ const Button: FC<Props> = ({
|
|
|
123
123
|
|
|
124
124
|
if (toolTip) {
|
|
125
125
|
return (
|
|
126
|
-
<ToolTip text={toolTip} id={id} withEllipsis={withEllipsis}>
|
|
126
|
+
<ToolTip text={`${toolTip}`} id={`${id}`} withEllipsis={withEllipsis}>
|
|
127
127
|
{buttonMarkup}
|
|
128
128
|
</ToolTip>
|
|
129
129
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
|
|
3
3
|
import Icon from 'src/components/Icon';
|
|
4
|
-
import {
|
|
4
|
+
import { ColorTypes, IconTypes } from 'src/constants';
|
|
5
5
|
|
|
6
6
|
const meta: Meta<typeof Icon> = {
|
|
7
7
|
title: 'Components/Icon',
|
|
@@ -22,6 +22,6 @@ export const Default: Story = {
|
|
|
22
22
|
export const Primary: Story = {
|
|
23
23
|
args: {
|
|
24
24
|
icon: IconTypes.USER,
|
|
25
|
-
color:
|
|
25
|
+
color: ColorTypes.GREY_4
|
|
26
26
|
}
|
|
27
27
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC, memo, MouseEvent
|
|
1
|
+
import { FC, memo, MouseEvent } from 'react';
|
|
2
2
|
import classNames from 'classnames/bind';
|
|
3
3
|
|
|
4
4
|
import { SizeTypes } from 'src/constants';
|
|
@@ -20,7 +20,7 @@ interface Props extends IconStyleInterface, SizeStyleInterface {
|
|
|
20
20
|
type?: HierarchyTypes.PRIMARY | HierarchyTypes.SECONDARY;
|
|
21
21
|
onClickCallback?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
22
22
|
// Set to implicitly control the icon size. Per default the icon inside the component stretches full width and height of the button.
|
|
23
|
-
iconSize?:
|
|
23
|
+
iconSize?: `${SizeTypes}`;
|
|
24
24
|
href?: string;
|
|
25
25
|
disabled?: boolean;
|
|
26
26
|
toolTip?: string;
|
|
@@ -91,7 +91,7 @@ const IconButton: FC<Props> = ({
|
|
|
91
91
|
|
|
92
92
|
if (toolTip) {
|
|
93
93
|
return (
|
|
94
|
-
<ToolTip text={toolTip} offset={16}>
|
|
94
|
+
<ToolTip text={`${toolTip}`} offset={16}>
|
|
95
95
|
{buttonMarkup()}
|
|
96
96
|
</ToolTip>
|
|
97
97
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { memo, Fragment, FC, ReactNode, MouseEvent
|
|
1
|
+
import { memo, Fragment, FC, ReactNode, MouseEvent } from 'react';
|
|
2
2
|
import classNames from 'classnames/bind';
|
|
3
3
|
|
|
4
4
|
import { SizeTypes, IconTypes, HierarchyTypes } from 'src/constants';
|
|
@@ -87,7 +87,7 @@ const InlineButton: FC<Props> = ({
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
return toolTip ? (
|
|
90
|
-
<ToolTip text={toolTip} offset={16} className={s('toolTip')}>
|
|
90
|
+
<ToolTip text={`${toolTip}`} offset={16} className={s('toolTip')}>
|
|
91
91
|
{getButton()}
|
|
92
92
|
</ToolTip>
|
|
93
93
|
) : (
|
|
@@ -5,11 +5,7 @@ import { ColorTypes, SizeTypes } from 'src/constants';
|
|
|
5
5
|
|
|
6
6
|
const meta: Meta<typeof Separator> = {
|
|
7
7
|
title: 'Components/Separator',
|
|
8
|
-
component: Separator
|
|
9
|
-
argTypes: {
|
|
10
|
-
color: ColorTypes.GREY_4,
|
|
11
|
-
size: SizeTypes.SMALL
|
|
12
|
-
}
|
|
8
|
+
component: Separator
|
|
13
9
|
};
|
|
14
10
|
|
|
15
11
|
export default meta;
|
|
@@ -23,9 +19,22 @@ export const Default: Story = {
|
|
|
23
19
|
}
|
|
24
20
|
};
|
|
25
21
|
|
|
26
|
-
export const
|
|
22
|
+
export const SizeSmall: Story = {
|
|
27
23
|
args: {
|
|
28
24
|
color: ColorTypes.GREY_4,
|
|
29
25
|
size: SizeTypes.SMALL
|
|
30
26
|
}
|
|
31
27
|
};
|
|
28
|
+
|
|
29
|
+
export const SizeMedium: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
color: ColorTypes.GREY_4,
|
|
32
|
+
size: SizeTypes.MEDIUM
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export const SizeLarge: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
color: ColorTypes.GREY_4,
|
|
38
|
+
size: SizeTypes.LARGE
|
|
39
|
+
}
|
|
40
|
+
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
@import 'src/styles/mixins.scss';
|
|
2
2
|
|
|
3
|
+
:root {
|
|
4
|
+
// overwrite default 0.9 opacity variable
|
|
5
|
+
--rt-opacity: 1 !important;
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
// Need to add !important to override libraries' styles
|
|
4
|
-
.
|
|
9
|
+
.container {
|
|
5
10
|
z-index: $tooltip-z-index !important;
|
|
6
11
|
box-shadow: $box-shadow-tooltip !important;
|
|
7
12
|
font-weight: 500 !important;
|
|
8
13
|
font-size: $font-size-m !important;
|
|
9
|
-
|
|
14
|
+
display: block !important;
|
|
10
15
|
pointer-events: none !important;
|
|
11
16
|
max-width: 420px;
|
|
12
17
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fragment, FC, ReactNode } from 'react';
|
|
2
2
|
import { Tooltip as ReactToolTip } from 'react-tooltip';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
3
4
|
import classNames from 'classnames/bind';
|
|
4
5
|
|
|
5
6
|
import styles from './ToolTip.module.scss';
|
|
@@ -13,6 +14,8 @@ function uuid() {
|
|
|
13
14
|
return `${chr4()}${chr4()}-${chr4()}-${chr4()}-${chr4()}`;
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
const htmlRootNode = document.getElementById('root') as HTMLElement;
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
|--------------------------------------------------
|
|
18
21
|
| This components extends the react-tooltip library.
|
|
@@ -21,12 +24,13 @@ function uuid() {
|
|
|
21
24
|
| https://react-tooltip.netlify.com/
|
|
22
25
|
|--------------------------------------------------
|
|
23
26
|
*/
|
|
24
|
-
|
|
25
27
|
interface Props {
|
|
26
28
|
text?: string;
|
|
27
|
-
children?: ReactNode;
|
|
29
|
+
children?: string | number | ReactNode | null;
|
|
30
|
+
component?: ReactNode;
|
|
28
31
|
disabled?: boolean;
|
|
29
32
|
withEllipsis?: boolean;
|
|
33
|
+
displayInPortal?: boolean;
|
|
30
34
|
className?: string;
|
|
31
35
|
toolTipClassName?: string;
|
|
32
36
|
id?: string;
|
|
@@ -35,41 +39,70 @@ interface Props {
|
|
|
35
39
|
placement?: 'top' | 'right' | 'bottom' | 'left';
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
const ToolTip: FC<Props> = ({
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
const ToolTip: FC<Props> = ({
|
|
43
|
+
text,
|
|
44
|
+
children,
|
|
45
|
+
disabled,
|
|
46
|
+
className,
|
|
47
|
+
toolTipClassName,
|
|
48
|
+
component,
|
|
49
|
+
withEllipsis,
|
|
50
|
+
id,
|
|
51
|
+
displayInPortal,
|
|
52
|
+
placement = 'top',
|
|
53
|
+
variant = 'dark',
|
|
54
|
+
offset
|
|
55
|
+
}) => {
|
|
56
|
+
if (!children) {
|
|
57
|
+
return null;
|
|
41
58
|
}
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
|
|
60
|
+
if (disabled || !text) {
|
|
61
|
+
return <Fragment>{children}</Fragment>;
|
|
44
62
|
}
|
|
45
63
|
|
|
46
64
|
const uniq = id ? `${id}` : uuid();
|
|
47
65
|
|
|
66
|
+
const toolTipMarkup = (
|
|
67
|
+
<ReactToolTip
|
|
68
|
+
className={s('container', {
|
|
69
|
+
[toolTipClassName as string]: toolTipClassName
|
|
70
|
+
})}
|
|
71
|
+
id={uniq}
|
|
72
|
+
place={placement}
|
|
73
|
+
variant={variant}
|
|
74
|
+
offset={offset}
|
|
75
|
+
delayShow={300}
|
|
76
|
+
closeOnScroll
|
|
77
|
+
>
|
|
78
|
+
{text ? <span>{text as string}</span> : null}
|
|
79
|
+
{component || null}
|
|
80
|
+
</ReactToolTip>
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
if (displayInPortal || !!htmlRootNode) {
|
|
84
|
+
return (
|
|
85
|
+
<Fragment>
|
|
86
|
+
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
|
87
|
+
{/* @ts-ignore */}
|
|
88
|
+
<div data-tooltip-id={uniq} className={s({ [className as string]: className, withEllipsis })}>
|
|
89
|
+
{children}
|
|
90
|
+
</div>
|
|
91
|
+
{createPortal(toolTipMarkup, htmlRootNode)}
|
|
92
|
+
</Fragment>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
48
96
|
return (
|
|
49
97
|
<Fragment>
|
|
50
|
-
|
|
98
|
+
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
|
99
|
+
{/* @ts-ignore */}
|
|
100
|
+
<div data-tooltip-id={uniq} className={s({ [className as string]: className, withEllipsis })}>
|
|
51
101
|
{children}
|
|
52
102
|
</div>
|
|
53
|
-
|
|
54
|
-
className={s('tooltip', {
|
|
55
|
-
[toolTipClassName]: toolTipClassName
|
|
56
|
-
})}
|
|
57
|
-
id={uniq}
|
|
58
|
-
place={placement}
|
|
59
|
-
variant={variant}
|
|
60
|
-
offset={offset}
|
|
61
|
-
delayShow={300}
|
|
62
|
-
closeOnScroll
|
|
63
|
-
>
|
|
64
|
-
{text ? <span>{text}</span> : null}
|
|
65
|
-
</ReactToolTip>
|
|
103
|
+
{toolTipMarkup}
|
|
66
104
|
</Fragment>
|
|
67
105
|
);
|
|
68
106
|
};
|
|
69
107
|
|
|
70
|
-
ToolTip.defaultProps = {
|
|
71
|
-
variant: 'dark',
|
|
72
|
-
placement: 'top'
|
|
73
|
-
};
|
|
74
|
-
|
|
75
108
|
export default ToolTip;
|