@sisense/sdk-shared-ui 0.1.0 → 1.26.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/.storybook/main.ts +44 -0
- package/.storybook/preview-head.html +4 -0
- package/.storybook/preview.tsx +34 -0
- package/dist/index.js +40 -2
- package/package.json +99 -2
- package/src/lib/CheckableList/CheckableList.module.scss +13 -0
- package/src/lib/CheckableList/CheckableList.test.tsx +61 -0
- package/src/lib/CheckableList/CheckableList.tsx +41 -0
- package/src/lib/CheckableList/index.ts +4 -0
- package/src/lib/Checkbox/Checkbox.tsx +28 -0
- package/src/lib/Checkbox/index.ts +4 -0
- package/src/lib/Checkbox/themes/checkboxTheme.ts +42 -0
- package/src/lib/Checkbox/themes/index.ts +1 -0
- package/src/lib/Checkbox/themes/uiCustomization.ts +28 -0
- package/src/lib/DEPRECATED_Button/DEPRECATED_Button.module.scss +57 -0
- package/src/lib/DEPRECATED_Button/DEPRECATED_Button.stories.tsx +169 -0
- package/src/lib/DEPRECATED_Button/DEPRECATED_Button.test.tsx +154 -0
- package/src/lib/DEPRECATED_Button/DEPRECATED_Button.tsx +129 -0
- package/src/lib/DEPRECATED_Button/index.ts +4 -0
- package/src/lib/DEPRECATED_Checkbox/Checkbox.module.scss +49 -0
- package/src/lib/DEPRECATED_Checkbox/DEPRECATED_Checkbox.test.tsx +131 -0
- package/src/lib/DEPRECATED_Checkbox/DEPRECATED_Checkbox.tsx +103 -0
- package/src/lib/DEPRECATED_Checkbox/index.ts +4 -0
- package/src/lib/DEPRECATED_Icon/DEPRECATED_Icon.stories.tsx +27 -0
- package/src/lib/DEPRECATED_Icon/DEPRECATED_Icon.tsx +2 -0
- package/src/lib/DEPRECATED_Toggle/DEPRECATED_Toggle.tsx +49 -0
- package/src/lib/DEPRECATED_Toggle/index.ts +4 -0
- package/src/lib/DEPRECATED_Tooltip/DEPRECATED_Tooltip.module.scss +115 -0
- package/src/lib/DEPRECATED_Tooltip/DEPRECATED_Tooltip.tsx +68 -0
- package/src/lib/DEPRECATED_Tooltip/index.ts +4 -0
- package/src/lib/Dropdown/Dropdown.module.scss +9 -0
- package/src/lib/Dropdown/Dropdown.tsx +150 -0
- package/src/lib/Dropdown/DropdownButton/DropdownButton.module.scss +49 -0
- package/src/lib/Dropdown/DropdownButton/DropdownButton.tsx +81 -0
- package/src/lib/Dropdown/DropdownButton/DropdownButtonBody/DropdownButtonBody.test.tsx +121 -0
- package/src/lib/Dropdown/DropdownButton/DropdownButtonBody/DropdownButtonBody.tsx +39 -0
- package/src/lib/Dropdown/DropdownButton/DropdownButtonBody/index.ts +2 -0
- package/src/lib/Dropdown/DropdownButton/DropdownButtonSearch/DropdownButtonSearch.module.scss +20 -0
- package/src/lib/Dropdown/DropdownButton/DropdownButtonSearch/DropdownButtonSearch.tsx +44 -0
- package/src/lib/Dropdown/DropdownButton/DropdownButtonSearch/constants.ts +1 -0
- package/src/lib/Dropdown/DropdownButton/DropdownButtonSearch/index.ts +2 -0
- package/src/lib/Dropdown/DropdownButton/hooks/index.tsx +1 -0
- package/src/lib/Dropdown/DropdownButton/hooks/useDropdownButtonSearch.ts +51 -0
- package/src/lib/Dropdown/DropdownButton/index.ts +1 -0
- package/src/lib/Dropdown/hooks/index.tsx +1 -0
- package/src/lib/Dropdown/hooks/useDropdown.ts +29 -0
- package/src/lib/Dropdown/index.ts +5 -0
- package/src/lib/Dropdown/types.ts +17 -0
- package/src/lib/Icon/Icon.tsx +118 -0
- package/src/lib/Icon/index.ts +4 -0
- package/src/lib/Icon/themes/iconTheme.tsx +38 -0
- package/src/lib/Icon/themes/index.ts +1 -0
- package/src/lib/Icon/themes/uiCustomization.ts +9 -0
- package/src/lib/Input/Input.module.scss +97 -0
- package/src/lib/Input/Input.test.tsx +177 -0
- package/src/lib/Input/Input.tsx +134 -0
- package/src/lib/Input/index.ts +4 -0
- package/src/lib/LazyLoader/LazyLoader.module.scss +18 -0
- package/src/lib/LazyLoader/LazyLoader.tsx +42 -0
- package/src/lib/LazyLoader/index.ts +4 -0
- package/src/lib/Menu/Confirmation/Confirmation.module.scss +48 -0
- package/src/lib/Menu/Confirmation/Confirmation.tsx +45 -0
- package/src/lib/Menu/Confirmation/index.ts +1 -0
- package/src/lib/Menu/Confirmation/translation.ts +17 -0
- package/src/lib/Menu/Menu.module.scss +178 -0
- package/src/lib/Menu/Menu.tsx +363 -0
- package/src/lib/Menu/MenuItem/MenuItem.test.tsx +241 -0
- package/src/lib/Menu/MenuItem/MenuItem.tsx +186 -0
- package/src/lib/Menu/MenuItem/index.ts +2 -0
- package/src/lib/Menu/index.ts +6 -0
- package/src/lib/Menu/utils.ts +13 -0
- package/src/lib/Popover/Popover.module.scss +15 -0
- package/src/lib/Popover/Popover.tsx +92 -0
- package/src/lib/Popover/align.interface.ts +20 -0
- package/src/lib/Popover/index.ts +6 -0
- package/src/lib/RadioButton/RadioButton.module.scss +22 -0
- package/src/lib/RadioButton/RadioButton.tsx +89 -0
- package/src/lib/RadioButton/index.ts +4 -0
- package/src/lib/TablePagination/PaginationActionsComponent/PaginationActionsComponent.tsx +87 -0
- package/src/lib/TablePagination/PaginationActionsComponent/index.ts +4 -0
- package/src/lib/TablePagination/PaginationActionsComponent/themes/index.ts +4 -0
- package/src/lib/TablePagination/PaginationActionsComponent/themes/paginationActionsComponentTheme.tsx +70 -0
- package/src/lib/TablePagination/PaginationActionsComponent/themes/uiCustomization.ts +17 -0
- package/src/lib/TablePagination/TablePagination.tsx +148 -0
- package/src/lib/TablePagination/TablePaginationContext.ts +4 -0
- package/src/lib/TablePagination/index.ts +4 -0
- package/src/lib/TablePagination/themes/index.ts +1 -0
- package/src/lib/TablePagination/themes/tablePaginationResponsiveDesign.ts +33 -0
- package/src/lib/TablePagination/themes/tablePaginationTheme.tsx +128 -0
- package/src/lib/TablePagination/themes/uiCustomization.ts +50 -0
- package/src/lib/Tooltip/Tooltip.module.scss +125 -0
- package/src/lib/Tooltip/Tooltip.tsx +34 -0
- package/src/lib/Tooltip/index.ts +5 -0
- package/src/lib/Tooltip/themes/index.ts +1 -0
- package/src/lib/Tooltip/themes/tooltipTheme.ts +30 -0
- package/src/lib/Typography/Typography.tsx +28 -0
- package/src/lib/Typography/index.ts +5 -0
- package/src/lib/Typography/themes/index.ts +1 -0
- package/src/lib/Typography/themes/typographyTheme.tsx +170 -0
- package/src/lib/Typography/themes/uiCustomization.ts +10 -0
- package/src/lib/constants/styleguideConstants.ts +8 -0
- package/src/lib/index.ts +16 -0
- package/src/lib/styles/colors.module.scss +10 -0
- package/src/lib/styles/sisenseStyleguideReactColors.scss +57 -0
- package/src/lib/styles/style_styleguide_react/_variables.deprecated.scss +107 -0
- package/src/lib/styles/style_styleguide_react/_variables.scss +100 -0
- package/src/lib/styles/style_styleguide_react/base.scss +9 -0
- package/src/lib/styles/style_styleguide_react/colors.scss +71 -0
- package/src/lib/styles/style_styleguide_react/exports/colors.exports.scss +69 -0
- package/src/lib/styles/style_styleguide_react/exports/fonts.exports.scss +33 -0
- package/src/lib/styles/style_styleguide_react/fonts.scss +27 -0
- package/src/lib/styles/style_styleguide_react/mixins.scss +90 -0
- package/src/lib/themes/colors/index.ts +1 -0
- package/src/lib/themes/colors/siColors.ts +143 -0
- package/src/lib/themes/index.ts +2 -0
- package/src/lib/themes/types/SisenseTheme.ts +12 -0
- package/src/lib/themes/types/index.ts +1 -0
- package/tsconfig.lib.json +2 -1
- package/vite.config.ts +18 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React, { ChangeEvent, MouseEvent } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { DEPRECATED_Icon } from '../DEPRECATED_Icon';
|
|
5
|
+
|
|
6
|
+
import style from './Checkbox.module.scss';
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
|
+
export type DEPRECATED_CheckboxProps = {
|
|
10
|
+
checked: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
inline?: boolean;
|
|
14
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
15
|
+
|
|
16
|
+
// The description is the icon and text. If undefined, use onChange.
|
|
17
|
+
onDescriptionClick?: () => void;
|
|
18
|
+
text?: string;
|
|
19
|
+
textClassName?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
transparent?: boolean;
|
|
22
|
+
dataTestId?: string;
|
|
23
|
+
iconName?: string;
|
|
24
|
+
inputCheckboxClassName?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
28
|
+
const DEPRECATED_Checkbox = (props: DEPRECATED_CheckboxProps) => {
|
|
29
|
+
const {
|
|
30
|
+
className,
|
|
31
|
+
disabled,
|
|
32
|
+
inline,
|
|
33
|
+
text,
|
|
34
|
+
textClassName,
|
|
35
|
+
title,
|
|
36
|
+
transparent,
|
|
37
|
+
dataTestId,
|
|
38
|
+
iconName,
|
|
39
|
+
onDescriptionClick,
|
|
40
|
+
inputCheckboxClassName,
|
|
41
|
+
...otherProps
|
|
42
|
+
} = props;
|
|
43
|
+
|
|
44
|
+
const propsPassedToInput: any = { disabled, ...otherProps };
|
|
45
|
+
if (title && !disabled) {
|
|
46
|
+
// eslint-disable-next-line
|
|
47
|
+
propsPassedToInput.title = title;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const cssPrefix = 'custom-checkbox';
|
|
51
|
+
|
|
52
|
+
const containerClass = classnames(
|
|
53
|
+
cssPrefix,
|
|
54
|
+
{
|
|
55
|
+
'custom-checkbox--inline': inline,
|
|
56
|
+
[style.disabled]: disabled,
|
|
57
|
+
},
|
|
58
|
+
className,
|
|
59
|
+
);
|
|
60
|
+
const checkboxClass = classnames(`${cssPrefix}__icon`, 'app-icon app-icon--form-checkbox-mark', {
|
|
61
|
+
[style.transparent]: transparent,
|
|
62
|
+
});
|
|
63
|
+
const textClass = classnames(`${cssPrefix}__text`, textClassName);
|
|
64
|
+
const onDescriptionClickWrapper = onDescriptionClick
|
|
65
|
+
? (e: MouseEvent) => {
|
|
66
|
+
onDescriptionClick();
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
}
|
|
69
|
+
: undefined;
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div className={containerClass}>
|
|
73
|
+
<label className={`${cssPrefix}__label`}>
|
|
74
|
+
<div className={classnames(style.sharedComponentsInputCheckbox, inputCheckboxClassName)}>
|
|
75
|
+
<input
|
|
76
|
+
type="checkbox"
|
|
77
|
+
className={`${cssPrefix}__input`}
|
|
78
|
+
data-testid={dataTestId}
|
|
79
|
+
{...propsPassedToInput}
|
|
80
|
+
/>
|
|
81
|
+
<span className={checkboxClass}>
|
|
82
|
+
<svg className="app-icon__svg">
|
|
83
|
+
<use xlinkHref="#form-checkbox-mark" />
|
|
84
|
+
</svg>
|
|
85
|
+
</span>
|
|
86
|
+
</div>
|
|
87
|
+
{iconName && (
|
|
88
|
+
<DEPRECATED_Icon
|
|
89
|
+
name={iconName}
|
|
90
|
+
className={style.icon}
|
|
91
|
+
onClick={onDescriptionClickWrapper}
|
|
92
|
+
/>
|
|
93
|
+
)}
|
|
94
|
+
<span className={textClass} onClick={onDescriptionClickWrapper}>
|
|
95
|
+
{text}
|
|
96
|
+
</span>
|
|
97
|
+
</label>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default DEPRECATED_Checkbox;
|
|
103
|
+
export { DEPRECATED_Checkbox };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { DEPRECATED_Icon } from './DEPRECATED_Icon';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'DEPRECATED/Icon',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const GeneralArrowDown = () => <DEPRECATED_Icon name={'general-arrow-down'} />;
|
|
10
|
+
|
|
11
|
+
export const GeneralArrowDownDisabled = () => (
|
|
12
|
+
<DEPRECATED_Icon name={'general-arrow-down'} disabled />
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const GeneralArrowDownClickable = () => (
|
|
16
|
+
<DEPRECATED_Icon name={'general-arrow-down'} onClick={() => {}} />
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const GeneralViSmallWhite = () => <DEPRECATED_Icon name={'general-vi-small-white'} />;
|
|
20
|
+
|
|
21
|
+
export const GeneralViSmallWhiteDisabled = () => (
|
|
22
|
+
<DEPRECATED_Icon name={'general-vi-small-white'} disabled />
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const GeneralViSmallWhiteClickable = () => (
|
|
26
|
+
<DEPRECATED_Icon name={'general-vi-small-white'} onClick={() => {}} />
|
|
27
|
+
);
|
|
@@ -3,6 +3,7 @@ import classNames from 'classnames';
|
|
|
3
3
|
|
|
4
4
|
import styles from './DEPRECATED_Icon.module.scss';
|
|
5
5
|
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
6
7
|
export type DEPRECATED_IconProps = {
|
|
7
8
|
className?: string;
|
|
8
9
|
disabled?: boolean;
|
|
@@ -18,6 +19,7 @@ export type DEPRECATED_IconProps = {
|
|
|
18
19
|
|
|
19
20
|
const noop = () => {};
|
|
20
21
|
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
21
23
|
const DEPRECATED_Icon = (props: DEPRECATED_IconProps) => {
|
|
22
24
|
const [isHovered, setIsHovered] = useState(false);
|
|
23
25
|
const {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
|
|
4
|
+
export type ToggleProps = {
|
|
5
|
+
checked: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
inline?: boolean;
|
|
9
|
+
onChange: (evt: React.ChangeEvent<HTMLInputElement>) => any;
|
|
10
|
+
text?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14
|
+
const DEPRECATED_Toggle = ({
|
|
15
|
+
checked,
|
|
16
|
+
onChange,
|
|
17
|
+
className = '',
|
|
18
|
+
disabled = false,
|
|
19
|
+
inline = false,
|
|
20
|
+
text = '',
|
|
21
|
+
}: ToggleProps) => {
|
|
22
|
+
const inputProps = {
|
|
23
|
+
checked,
|
|
24
|
+
disabled,
|
|
25
|
+
onChange,
|
|
26
|
+
};
|
|
27
|
+
const cssPrefix = 'custom-togglebtn';
|
|
28
|
+
const containerClass = classnames(
|
|
29
|
+
cssPrefix,
|
|
30
|
+
{
|
|
31
|
+
[`${cssPrefix}--inline`]: inline,
|
|
32
|
+
},
|
|
33
|
+
className,
|
|
34
|
+
);
|
|
35
|
+
const checkboxClass = `${cssPrefix}__icon`;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className={containerClass}>
|
|
39
|
+
<label className={`${cssPrefix}__label`}>
|
|
40
|
+
<input type="checkbox" className={`${cssPrefix}__input`} {...inputProps} />
|
|
41
|
+
<span className={checkboxClass} />
|
|
42
|
+
{text && <span className={`${cssPrefix}__text`}>{text}</span>}
|
|
43
|
+
</label>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default DEPRECATED_Toggle;
|
|
49
|
+
export { DEPRECATED_Toggle };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
// @import '../style_styleguide_react/base';
|
|
3
|
+
|
|
4
|
+
:global {
|
|
5
|
+
@import 'rc-tooltip/assets/bootstrap_white';
|
|
6
|
+
|
|
7
|
+
$arrow-size: 8px;
|
|
8
|
+
$arrow-depth: 6px; // Math.ceil(sqrt(2) * $arrow-size / 2)
|
|
9
|
+
|
|
10
|
+
.rc-tooltip {
|
|
11
|
+
padding: 0;
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
opacity: 1;
|
|
14
|
+
|
|
15
|
+
&.hide-arrow {
|
|
16
|
+
.rc-tooltip-arrow,
|
|
17
|
+
.rc-tooltip-content:before {
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&.rc-tooltip-placement-top,
|
|
22
|
+
&.rc-tooltip-placement-bottom,
|
|
23
|
+
&.rc-tooltip-placement-left,
|
|
24
|
+
&.rc-tooltip-placement-right {
|
|
25
|
+
padding: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.rc-tooltip-inner {
|
|
29
|
+
padding: 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rc-tooltip-content {
|
|
35
|
+
position: relative;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.rc-tooltip-inner {
|
|
39
|
+
padding: 6px 12px;
|
|
40
|
+
min-height: 0;
|
|
41
|
+
border: 0;
|
|
42
|
+
border-radius: 4px;
|
|
43
|
+
// @include boxShadow;
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
color: red; //$fore;
|
|
46
|
+
font-size: 14px; //$sizeDefault;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.rc-tooltip-arrow {
|
|
50
|
+
border-width: 0 !important;
|
|
51
|
+
width: $arrow-size;
|
|
52
|
+
height: $arrow-size;
|
|
53
|
+
background-color: #000; //$back;
|
|
54
|
+
// @include boxShadow;
|
|
55
|
+
z-index: -1;
|
|
56
|
+
transform: rotate(45deg);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.rc-tooltip-content:before {
|
|
60
|
+
content: '';
|
|
61
|
+
position: absolute;
|
|
62
|
+
width: $arrow-size;
|
|
63
|
+
height: $arrow-size;
|
|
64
|
+
background-color: #000; //$back;
|
|
65
|
+
transform: rotate(45deg);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.rc-tooltip-placement-top {
|
|
69
|
+
padding-bottom: $arrow-depth;
|
|
70
|
+
|
|
71
|
+
.rc-tooltip-arrow,
|
|
72
|
+
.rc-tooltip-content:before {
|
|
73
|
+
left: 50%;
|
|
74
|
+
margin-left: math.div(-$arrow-size, 2);
|
|
75
|
+
bottom: math.div(-$arrow-size, 2);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.rc-tooltip-placement-bottom {
|
|
80
|
+
padding-top: $arrow-depth;
|
|
81
|
+
|
|
82
|
+
.rc-tooltip-arrow,
|
|
83
|
+
.rc-tooltip-content:before {
|
|
84
|
+
left: 50%;
|
|
85
|
+
margin-left: math.div(-$arrow-size, 2);
|
|
86
|
+
top: math.div(-$arrow-size, 2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.rc-tooltip-placement-right {
|
|
91
|
+
padding-left: $arrow-depth;
|
|
92
|
+
|
|
93
|
+
.rc-tooltip-arrow,
|
|
94
|
+
.rc-tooltip-content:before {
|
|
95
|
+
top: 50%;
|
|
96
|
+
margin-top: math.div(-$arrow-size, 2);
|
|
97
|
+
left: math.div(-$arrow-size, 2);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.rc-tooltip-placement-left {
|
|
102
|
+
padding-right: $arrow-depth;
|
|
103
|
+
|
|
104
|
+
.rc-tooltip-arrow,
|
|
105
|
+
.rc-tooltip-content:before {
|
|
106
|
+
top: 50%;
|
|
107
|
+
margin-top: math.div(-$arrow-size, 2);
|
|
108
|
+
right: math.div(-$arrow-size, 2);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.breakLongWord {
|
|
114
|
+
word-break: break-all;
|
|
115
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import RcTooltip from 'rc-tooltip';
|
|
5
|
+
import type { TooltipProps } from 'rc-tooltip/lib/Tooltip';
|
|
6
|
+
|
|
7
|
+
import styles from './DEPRECATED_Tooltip.module.scss';
|
|
8
|
+
import { styleguideConstants } from '../constants/styleguideConstants';
|
|
9
|
+
|
|
10
|
+
export type DEPRECATED_TooltipProps = {
|
|
11
|
+
breakingLongWord?: boolean;
|
|
12
|
+
hideArrow?: boolean;
|
|
13
|
+
onClick?: (ev: MouseEvent) => void;
|
|
14
|
+
overlayClassName?: string;
|
|
15
|
+
zIndex?: number;
|
|
16
|
+
imgOverlay?: boolean;
|
|
17
|
+
semanticText?: boolean;
|
|
18
|
+
} & TooltipProps;
|
|
19
|
+
|
|
20
|
+
const DEPRECATED_Tooltip = (
|
|
21
|
+
props: React.PropsWithChildren<DEPRECATED_TooltipProps>,
|
|
22
|
+
): JSX.Element => {
|
|
23
|
+
const {
|
|
24
|
+
breakingLongWord,
|
|
25
|
+
hideArrow = false,
|
|
26
|
+
overlayClassName,
|
|
27
|
+
overlay,
|
|
28
|
+
imgOverlay = false,
|
|
29
|
+
semanticText,
|
|
30
|
+
...otherProps
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
const overlayClasses = classnames(
|
|
34
|
+
overlayClassName,
|
|
35
|
+
'slf-default',
|
|
36
|
+
styleguideConstants.SISENSE_NAMESPACE,
|
|
37
|
+
{
|
|
38
|
+
'hide-arrow': hideArrow,
|
|
39
|
+
[styles.breakLongWord]: breakingLongWord,
|
|
40
|
+
[styles.semanticText]: semanticText,
|
|
41
|
+
[styles.semanticText]: semanticText,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const getOverlay = () => {
|
|
46
|
+
if (typeof overlay === 'string') {
|
|
47
|
+
if (imgOverlay) {
|
|
48
|
+
return <img src={overlay} />;
|
|
49
|
+
} else {
|
|
50
|
+
return <div dangerouslySetInnerHTML={{ __html: overlay }} />;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return overlay;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<RcTooltip
|
|
59
|
+
destroyTooltipOnHide
|
|
60
|
+
overlay={getOverlay()}
|
|
61
|
+
{...otherProps}
|
|
62
|
+
overlayClassName={overlayClasses}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default DEPRECATED_Tooltip;
|
|
68
|
+
export { DEPRECATED_Tooltip };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { ScrollbarProps } from 'react-custom-scrollbars';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
// import { SLF } from '@sbi/styleguide';
|
|
5
|
+
|
|
6
|
+
import { Popover } from '../Popover';
|
|
7
|
+
import { Menu, itemTypes } from '../Menu';
|
|
8
|
+
import { DropdownButton } from './DropdownButton';
|
|
9
|
+
|
|
10
|
+
import { useDropdown } from './hooks';
|
|
11
|
+
import { styleguideConstants } from '../constants/styleguideConstants';
|
|
12
|
+
|
|
13
|
+
import type { DropdownItem, DropdownInputProps } from './types';
|
|
14
|
+
import type { MenuItemConfig } from '../Menu';
|
|
15
|
+
|
|
16
|
+
import style from './Dropdown.module.scss';
|
|
17
|
+
|
|
18
|
+
const noop = () => {};
|
|
19
|
+
|
|
20
|
+
export type DropdownProps = {
|
|
21
|
+
bubblePopoverMouseEvents?: boolean;
|
|
22
|
+
classNameButton?: string;
|
|
23
|
+
classNameDropdown?: string;
|
|
24
|
+
classNameSearch?: string;
|
|
25
|
+
classNameMenu?: string;
|
|
26
|
+
classNameTooltip?: string;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
items: DropdownItem[];
|
|
29
|
+
mask?: boolean;
|
|
30
|
+
onSelectItem?: (item: MenuItemConfig) => void;
|
|
31
|
+
popoverOverlayLevel?: number;
|
|
32
|
+
selectedItemId?: string;
|
|
33
|
+
selectedShowIcon?: boolean;
|
|
34
|
+
width?: number;
|
|
35
|
+
inlineVariant?: boolean;
|
|
36
|
+
scrollbarProps?: ScrollbarProps;
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
placement?: string;
|
|
39
|
+
zIndex?: number;
|
|
40
|
+
searchInputProps?: DropdownInputProps;
|
|
41
|
+
open?: boolean;
|
|
42
|
+
isLoading?: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
|
|
46
|
+
(
|
|
47
|
+
{
|
|
48
|
+
bubblePopoverMouseEvents = false,
|
|
49
|
+
items = [],
|
|
50
|
+
onSelectItem = noop,
|
|
51
|
+
popoverOverlayLevel = 0,
|
|
52
|
+
selectedShowIcon = true,
|
|
53
|
+
mask = true,
|
|
54
|
+
placeholder = '',
|
|
55
|
+
placement = 'bottomLeft',
|
|
56
|
+
disabled = false,
|
|
57
|
+
selectedItemId,
|
|
58
|
+
width,
|
|
59
|
+
scrollbarProps,
|
|
60
|
+
classNameMenu,
|
|
61
|
+
inlineVariant,
|
|
62
|
+
classNameDropdown,
|
|
63
|
+
classNameButton,
|
|
64
|
+
classNameSearch,
|
|
65
|
+
classNameTooltip,
|
|
66
|
+
zIndex,
|
|
67
|
+
searchInputProps,
|
|
68
|
+
open = false,
|
|
69
|
+
isLoading = false,
|
|
70
|
+
},
|
|
71
|
+
ref,
|
|
72
|
+
) => {
|
|
73
|
+
const popoverVerticalOffset = inlineVariant ? 12 : 0;
|
|
74
|
+
const menuItems = items.map((item) => ({
|
|
75
|
+
id: item.id,
|
|
76
|
+
caption: item.caption || item.id,
|
|
77
|
+
type: itemTypes.ITEM,
|
|
78
|
+
iconName: item.iconName,
|
|
79
|
+
iconClass: item.iconClass,
|
|
80
|
+
selected: item.id === selectedItemId,
|
|
81
|
+
tooltip: item.tooltip,
|
|
82
|
+
disabled: item.disabled,
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
const {
|
|
86
|
+
isOpen,
|
|
87
|
+
handlers: { handleOnSelectItem, handleDropdownClick },
|
|
88
|
+
} = useDropdown(onSelectItem, open, disabled);
|
|
89
|
+
|
|
90
|
+
const renderDropdown = () => {
|
|
91
|
+
const menuClassNames = classNames(
|
|
92
|
+
style.menu,
|
|
93
|
+
// SLF.BACK,
|
|
94
|
+
// SLF.TEXT_PRIMARY,
|
|
95
|
+
styleguideConstants.SISENSE_NAMESPACE,
|
|
96
|
+
classNameMenu,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Menu
|
|
101
|
+
items={menuItems}
|
|
102
|
+
onItemSelected={handleOnSelectItem}
|
|
103
|
+
className={menuClassNames}
|
|
104
|
+
width={width}
|
|
105
|
+
scrollbarProps={scrollbarProps}
|
|
106
|
+
isLoading={isLoading}
|
|
107
|
+
classNameTooltip={classNameTooltip}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div ref={ref} data-testid="popover_container">
|
|
114
|
+
<Popover
|
|
115
|
+
zIndex={zIndex}
|
|
116
|
+
bubbleMouseEvents={bubblePopoverMouseEvents}
|
|
117
|
+
trigger={['click']}
|
|
118
|
+
visible={isOpen}
|
|
119
|
+
placement={placement}
|
|
120
|
+
overlay={renderDropdown}
|
|
121
|
+
level={popoverOverlayLevel}
|
|
122
|
+
onVisibleChange={handleDropdownClick}
|
|
123
|
+
onRequestClose={handleDropdownClick}
|
|
124
|
+
align={{ offset: [0, popoverVerticalOffset] }}
|
|
125
|
+
mask={mask}
|
|
126
|
+
>
|
|
127
|
+
<div>
|
|
128
|
+
<DropdownButton
|
|
129
|
+
isOpen={isOpen}
|
|
130
|
+
items={items}
|
|
131
|
+
selectedShowIcon={selectedShowIcon}
|
|
132
|
+
placeholder={placeholder}
|
|
133
|
+
width={width}
|
|
134
|
+
disabled={disabled}
|
|
135
|
+
classNameButton={classNameButton}
|
|
136
|
+
classNameDropdown={classNameDropdown}
|
|
137
|
+
classNameSearch={classNameSearch}
|
|
138
|
+
inlineVariant={inlineVariant}
|
|
139
|
+
searchInputProps={searchInputProps}
|
|
140
|
+
selectedItemId={selectedItemId}
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
</Popover>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
export default Dropdown;
|
|
150
|
+
export { Dropdown };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
@import '../../styles/style_styleguide_react/mixins';
|
|
2
|
+
@import '../../styles/colors.module';
|
|
3
|
+
|
|
4
|
+
.dropdownButton {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
background: $ATHENS_GRAY;
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
height: 28px;
|
|
11
|
+
min-width: 192px;
|
|
12
|
+
|
|
13
|
+
&.inlineVariant {
|
|
14
|
+
background: none;
|
|
15
|
+
height: 18px;
|
|
16
|
+
border: none;
|
|
17
|
+
text-indent: 0;
|
|
18
|
+
min-width: initial;
|
|
19
|
+
&.open {
|
|
20
|
+
border: none;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.open {
|
|
25
|
+
border: 1px solid $COLOR-TEXT;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&.disabled {
|
|
29
|
+
@include disabled;
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.selectedIcon {
|
|
34
|
+
flex-shrink: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.chosenTitle {
|
|
38
|
+
margin-left: 12px;
|
|
39
|
+
flex-grow: 1;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
text-overflow: ellipsis;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.clickIcon {
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
margin-right: 2px;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { FC, useRef } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { DropdownButtonSearch } from './DropdownButtonSearch';
|
|
5
|
+
import { DropdownButtonBody } from './DropdownButtonBody';
|
|
6
|
+
import { useDropdownButtonSearch } from './hooks';
|
|
7
|
+
|
|
8
|
+
import type { DropdownItem, DropdownInputProps } from '../types';
|
|
9
|
+
|
|
10
|
+
import style from './DropdownButton.module.scss';
|
|
11
|
+
|
|
12
|
+
export type DropdownButtonProps = {
|
|
13
|
+
items?: DropdownItem[];
|
|
14
|
+
selectedShowIcon?: boolean;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
selectedItemId?: string;
|
|
18
|
+
width?: number;
|
|
19
|
+
inlineVariant?: boolean;
|
|
20
|
+
classNameDropdown?: string;
|
|
21
|
+
classNameButton?: string;
|
|
22
|
+
classNameSearch?: string;
|
|
23
|
+
searchInputProps?: DropdownInputProps;
|
|
24
|
+
isOpen?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const DropdownButton: FC<DropdownButtonProps> = ({
|
|
28
|
+
items = [],
|
|
29
|
+
selectedShowIcon = true,
|
|
30
|
+
placeholder = '',
|
|
31
|
+
disabled,
|
|
32
|
+
selectedItemId,
|
|
33
|
+
width,
|
|
34
|
+
inlineVariant,
|
|
35
|
+
classNameDropdown,
|
|
36
|
+
classNameButton,
|
|
37
|
+
classNameSearch,
|
|
38
|
+
searchInputProps,
|
|
39
|
+
isOpen = false,
|
|
40
|
+
}) => {
|
|
41
|
+
const selectedItem = items.find((item) => item.id === selectedItemId);
|
|
42
|
+
const ref = useRef(null);
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
inputProps,
|
|
46
|
+
handlers: { handleOnSearchInputClick, handleOnSearchInputChange },
|
|
47
|
+
} = useDropdownButtonSearch(isOpen, selectedItem, searchInputProps, ref);
|
|
48
|
+
|
|
49
|
+
const dropDownButtonClasses = classNames(
|
|
50
|
+
classNameButton,
|
|
51
|
+
style.dropdownButton,
|
|
52
|
+
{
|
|
53
|
+
[style.disabled]: disabled,
|
|
54
|
+
[style.open]: isOpen,
|
|
55
|
+
[style.inlineVariant]: inlineVariant,
|
|
56
|
+
},
|
|
57
|
+
classNameDropdown,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
{searchInputProps && isOpen && !disabled ? (
|
|
63
|
+
<DropdownButtonSearch
|
|
64
|
+
ref={ref}
|
|
65
|
+
width={width}
|
|
66
|
+
onClick={handleOnSearchInputClick}
|
|
67
|
+
inputProps={{ ...inputProps, onChange: handleOnSearchInputChange }}
|
|
68
|
+
className={classNameSearch}
|
|
69
|
+
/>
|
|
70
|
+
) : (
|
|
71
|
+
<DropdownButtonBody
|
|
72
|
+
selectedItem={selectedItem}
|
|
73
|
+
width={width}
|
|
74
|
+
placeholder={placeholder}
|
|
75
|
+
selectedShowIcon={selectedShowIcon}
|
|
76
|
+
dropDownButtonClasses={dropDownButtonClasses}
|
|
77
|
+
/>
|
|
78
|
+
)}
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
};
|