@dnanpm/styleguide 3.12.3 → 4.0.1
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/build/cjs/components/Button/Button.d.ts +1 -7
- package/build/cjs/components/Button/Button.js +3 -3
- package/build/cjs/components/ButtonArrow/ButtonArrow.d.ts +1 -7
- package/build/cjs/components/ButtonArrow/ButtonArrow.js +2 -2
- package/build/cjs/components/ButtonIcon/ButtonIcon.js +3 -3
- package/build/cjs/components/Chip/Chip.d.ts +2 -18
- package/build/cjs/components/Chip/Chip.js +2 -2
- package/build/cjs/components/Drawer/Drawer.d.ts +0 -7
- package/build/cjs/components/Drawer/Drawer.js +1 -1
- package/build/cjs/components/Footer/Components/FooterComponents.js +0 -1
- package/build/cjs/components/Hero/Hero.js +3 -2
- package/build/cjs/components/Icon/Icon.d.ts +2 -8
- package/build/cjs/components/Icon/Icon.js +3 -10
- package/build/cjs/components/Input/Input.d.ts +1 -10
- package/build/cjs/components/LabelText/LabelText.d.ts +1 -6
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/LanguageSelector.js +10 -9
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/LoginTooltip.js +2 -2
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +2 -4
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.js +4 -6
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MinicartTooltip.js +4 -8
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/PageSearch.js +2 -2
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +1 -7
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.js +1 -3
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.d.ts +0 -1
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.js +0 -1
- package/build/cjs/components/Modal/Modal.d.ts +0 -5
- package/build/cjs/components/ReadMore/ReadMore.d.ts +0 -20
- package/build/cjs/components/ReadMore/ReadMore.js +2 -8
- package/build/cjs/components/Tab/Tab.d.ts +2 -30
- package/build/cjs/components/Tab/Tab.js +2 -33
- package/build/cjs/components/Tabs/Tabs.d.ts +1 -9
- package/build/cjs/components/Tabs/Tabs.js +9 -17
- package/build/cjs/components/Tooltip/Tooltip.js +1 -1
- package/build/cjs/components/index.d.ts +0 -4
- package/build/cjs/hooks/useCloseOutsideOrElementClicked.js +1 -1
- package/build/cjs/index.js +0 -8
- package/build/cjs/themes/themeComponents/navigation.js +0 -4
- package/build/es/components/Button/Button.d.ts +1 -7
- package/build/es/components/Button/Button.js +3 -3
- package/build/es/components/ButtonArrow/ButtonArrow.d.ts +1 -7
- package/build/es/components/ButtonArrow/ButtonArrow.js +2 -2
- package/build/es/components/ButtonIcon/ButtonIcon.js +3 -3
- package/build/es/components/Chip/Chip.d.ts +2 -18
- package/build/es/components/Chip/Chip.js +2 -2
- package/build/es/components/Drawer/Drawer.d.ts +0 -7
- package/build/es/components/Drawer/Drawer.js +1 -1
- package/build/es/components/Footer/Components/FooterComponents.js +0 -1
- package/build/es/components/Hero/Hero.js +3 -2
- package/build/es/components/Icon/Icon.d.ts +2 -8
- package/build/es/components/Icon/Icon.js +3 -10
- package/build/es/components/Input/Input.d.ts +1 -10
- package/build/es/components/LabelText/LabelText.d.ts +1 -6
- package/build/es/components/MainHeaderNavigation/ChildComponents/LanguageSelector.js +11 -10
- package/build/es/components/MainHeaderNavigation/ChildComponents/LoginTooltip.js +2 -2
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +2 -4
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.js +4 -6
- package/build/es/components/MainHeaderNavigation/ChildComponents/MinicartTooltip.js +5 -9
- package/build/es/components/MainHeaderNavigation/ChildComponents/PageSearch.js +2 -2
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +1 -7
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.js +1 -3
- package/build/es/components/MainHeaderNavigation/context/NavContext.d.ts +0 -1
- package/build/es/components/MainHeaderNavigation/context/NavContext.js +0 -1
- package/build/es/components/Modal/Modal.d.ts +0 -5
- package/build/es/components/ReadMore/ReadMore.d.ts +0 -20
- package/build/es/components/ReadMore/ReadMore.js +2 -8
- package/build/es/components/Tab/Tab.d.ts +2 -30
- package/build/es/components/Tab/Tab.js +2 -33
- package/build/es/components/Tabs/Tabs.d.ts +1 -9
- package/build/es/components/Tabs/Tabs.js +9 -17
- package/build/es/components/Tooltip/Tooltip.js +1 -1
- package/build/es/components/index.d.ts +0 -4
- package/build/es/hooks/useCloseOutsideOrElementClicked.js +1 -1
- package/build/es/index.js +0 -4
- package/build/es/themes/themeComponents/navigation.js +1 -3
- package/package.json +14 -14
- package/build/cjs/components/ButtonRound/ButtonRound.d.ts +0 -10
- package/build/cjs/components/ButtonRound/ButtonRound.js +0 -37
- package/build/cjs/components/Icons/index.js +0 -224
- package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.d.ts +0 -3
- package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.js +0 -59
- package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.d.ts +0 -3
- package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.js +0 -259
- package/build/cjs/components/MainNavigation/ChildComponents/HeaderNavigationElements.d.ts +0 -10
- package/build/cjs/components/MainNavigation/ChildComponents/HeaderNavigationElements.js +0 -168
- package/build/cjs/components/MainNavigation/ChildComponents/LanguageSelector.d.ts +0 -4
- package/build/cjs/components/MainNavigation/ChildComponents/LanguageSelector.js +0 -38
- package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.d.ts +0 -9
- package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.js +0 -38
- package/build/cjs/components/MainNavigation/ChildComponents/LoginTooltip.d.ts +0 -6
- package/build/cjs/components/MainNavigation/ChildComponents/LoginTooltip.js +0 -23
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.d.ts +0 -24
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +0 -104
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +0 -6
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +0 -62
- package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.d.ts +0 -7
- package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.js +0 -26
- package/build/cjs/components/MainNavigation/ChildComponents/MobileMenu.d.ts +0 -3
- package/build/cjs/components/MainNavigation/ChildComponents/MobileMenu.js +0 -193
- package/build/cjs/components/MainNavigation/ChildComponents/PageSearch.d.ts +0 -6
- package/build/cjs/components/MainNavigation/ChildComponents/PageSearch.js +0 -23
- package/build/cjs/components/MainNavigation/ChildComponents/Ribbon.d.ts +0 -13
- package/build/cjs/components/MainNavigation/ChildComponents/Ribbon.js +0 -74
- package/build/cjs/components/MainNavigation/MainNavigation.d.ts +0 -38
- package/build/cjs/components/MainNavigation/MainNavigation.js +0 -319
- package/build/cjs/components/MainNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/cjs/components/MainNavigation/context/MobileMenuContext.js +0 -11
- package/build/cjs/components/MainNavigation/context/NavContext.d.ts +0 -29
- package/build/cjs/components/MainNavigation/context/NavContext.js +0 -46
- package/build/cjs/components/MainNavigation/globalNavStyles.d.ts +0 -13
- package/build/cjs/components/MainNavigation/globalNavStyles.js +0 -94
- package/build/cjs/components/SecondaryNavigation/SecondaryNavigation.d.ts +0 -90
- package/build/cjs/components/SecondaryNavigation/SecondaryNavigation.js +0 -207
- package/build/cjs/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.d.ts +0 -10
- package/build/cjs/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.js +0 -34
- package/build/cjs/components/TooltipMenu/TooltipMenu.d.ts +0 -45
- package/build/cjs/components/TooltipMenu/TooltipMenu.js +0 -76
- package/build/es/components/ButtonRound/ButtonRound.d.ts +0 -10
- package/build/es/components/ButtonRound/ButtonRound.js +0 -29
- package/build/es/components/Icons/index.js +0 -109
- package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.d.ts +0 -3
- package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.js +0 -51
- package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.d.ts +0 -3
- package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.js +0 -251
- package/build/es/components/MainNavigation/ChildComponents/HeaderNavigationElements.d.ts +0 -10
- package/build/es/components/MainNavigation/ChildComponents/HeaderNavigationElements.js +0 -159
- package/build/es/components/MainNavigation/ChildComponents/LanguageSelector.d.ts +0 -4
- package/build/es/components/MainNavigation/ChildComponents/LanguageSelector.js +0 -30
- package/build/es/components/MainNavigation/ChildComponents/LinkModifier.d.ts +0 -9
- package/build/es/components/MainNavigation/ChildComponents/LinkModifier.js +0 -29
- package/build/es/components/MainNavigation/ChildComponents/LoginTooltip.d.ts +0 -6
- package/build/es/components/MainNavigation/ChildComponents/LoginTooltip.js +0 -15
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.d.ts +0 -24
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +0 -96
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +0 -6
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +0 -57
- package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.d.ts +0 -7
- package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.js +0 -18
- package/build/es/components/MainNavigation/ChildComponents/MobileMenu.d.ts +0 -3
- package/build/es/components/MainNavigation/ChildComponents/MobileMenu.js +0 -185
- package/build/es/components/MainNavigation/ChildComponents/PageSearch.d.ts +0 -6
- package/build/es/components/MainNavigation/ChildComponents/PageSearch.js +0 -15
- package/build/es/components/MainNavigation/ChildComponents/Ribbon.d.ts +0 -13
- package/build/es/components/MainNavigation/ChildComponents/Ribbon.js +0 -66
- package/build/es/components/MainNavigation/MainNavigation.d.ts +0 -38
- package/build/es/components/MainNavigation/MainNavigation.js +0 -311
- package/build/es/components/MainNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/es/components/MainNavigation/context/MobileMenuContext.js +0 -7
- package/build/es/components/MainNavigation/context/NavContext.d.ts +0 -29
- package/build/es/components/MainNavigation/context/NavContext.js +0 -42
- package/build/es/components/MainNavigation/globalNavStyles.d.ts +0 -13
- package/build/es/components/MainNavigation/globalNavStyles.js +0 -89
- package/build/es/components/SecondaryNavigation/SecondaryNavigation.d.ts +0 -90
- package/build/es/components/SecondaryNavigation/SecondaryNavigation.js +0 -199
- package/build/es/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.d.ts +0 -10
- package/build/es/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.js +0 -31
- package/build/es/components/TooltipMenu/TooltipMenu.d.ts +0 -45
- package/build/es/components/TooltipMenu/TooltipMenu.js +0 -68
|
@@ -3,9 +3,7 @@ import React__default from 'react';
|
|
|
3
3
|
import { styled } from 'styled-components';
|
|
4
4
|
import theme from '../../themes/theme.js';
|
|
5
5
|
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
6
|
-
import * as index from '../Icons/index.js';
|
|
7
6
|
|
|
8
|
-
const IconsList = index;
|
|
9
7
|
const IconContainer = styled.span `
|
|
10
8
|
display: inline-flex;
|
|
11
9
|
width: ${({ size }) => size};
|
|
@@ -27,14 +25,9 @@ const IconContainer = styled.span `
|
|
|
27
25
|
}
|
|
28
26
|
`;
|
|
29
27
|
const Icon = (_a) => {
|
|
30
|
-
var {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return (React__default.createElement(React__default.Fragment, null,
|
|
34
|
-
RenderIcon && (React__default.createElement(IconContainer, { "$position": props.position, size: size, className: "dnasg-icon", "data-testid": dataTestId },
|
|
35
|
-
React__default.createElement(RenderIcon, Object.assign({}, props, { size: size, color: color })))),
|
|
36
|
-
IconParam && (React__default.createElement(IconContainer, { onClick: props.onClick, "$position": props.position, size: size, className: `dnasg-icon ${props.className || ''}`.trim(), "data-testid": dataTestId, "aria-label": ariaLabel, "aria-hidden": ariaHidden, role: !ariaHidden ? 'img' : undefined },
|
|
37
|
-
React__default.createElement(IconParam, { size: size, color: color })))));
|
|
28
|
+
var { icon: IconParam, color = 'currentColor', size = '1.5rem', 'data-testid': dataTestId, 'aria-label': ariaLabel, 'aria-hidden': ariaHidden } = _a, props = __rest(_a, ["icon", "color", "size", 'data-testid', 'aria-label', 'aria-hidden']);
|
|
29
|
+
return (React__default.createElement(IconContainer, { onClick: props.onClick, "$position": props.position, size: size, className: `dnasg-icon ${props.className || ''}`.trim(), "data-testid": dataTestId, "aria-label": ariaLabel, "aria-hidden": ariaHidden, role: !ariaHidden ? 'img' : undefined },
|
|
30
|
+
React__default.createElement(IconParam, { size: size, color: color })));
|
|
38
31
|
};
|
|
39
32
|
|
|
40
33
|
export { Icon as default };
|
|
@@ -2,10 +2,6 @@ import type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent } from 'react';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type InputStatus = 'none' | 'success' | 'error' | 'comment';
|
|
4
4
|
type InputType = 'email' | 'hidden' | 'number' | 'password' | 'range' | 'search' | 'tel' | 'text' | 'url';
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use `DateTimePicker` component
|
|
7
|
-
*/
|
|
8
|
-
type InputTypeDeprecated = 'date' | 'month' | 'time' | 'week';
|
|
9
5
|
interface Props {
|
|
10
6
|
/**
|
|
11
7
|
* Unique ID for the input element
|
|
@@ -28,14 +24,9 @@ interface Props {
|
|
|
28
24
|
* @param {InputType} text Single-line text field
|
|
29
25
|
* @param {InputType} url Used for entering a URL and supported with browser validation
|
|
30
26
|
*
|
|
31
|
-
* @param {InputTypeDeprecated} date DEPRECATED Use `DateTimePicker` component
|
|
32
|
-
* @param {InputTypeDeprecated} month DEPRECATED Use `DateTimePicker` component
|
|
33
|
-
* @param {InputTypeDeprecated} time DEPRECATED Use `DateTimePicker` component
|
|
34
|
-
* @param {InputTypeDeprecated} week DEPRECATED Use `DateTimePicker` component
|
|
35
|
-
*
|
|
36
27
|
* @default 'text'
|
|
37
28
|
*/
|
|
38
|
-
type?: InputType
|
|
29
|
+
type?: InputType;
|
|
39
30
|
/**
|
|
40
31
|
* Default value of input element
|
|
41
32
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
type LabelTextStatus = '
|
|
3
|
+
type LabelTextStatus = 'error';
|
|
4
4
|
interface Props {
|
|
5
5
|
/**
|
|
6
6
|
* Unique ID for the component
|
|
@@ -18,12 +18,7 @@ interface Props {
|
|
|
18
18
|
* Styling of `label` element changes depending on the passed status
|
|
19
19
|
*
|
|
20
20
|
* @param {LabelTextStatus} undefined Default styling
|
|
21
|
-
* @param {LabelTextStatus} info Changes color to default color (this type will be deprecated in the future)
|
|
22
|
-
* @param {LabelTextStatus} success Changes color to default color (this type will be deprecated in the future)
|
|
23
|
-
* @param {LabelTextStatus} warning Changes color to default color (this type will be deprecated in the future)
|
|
24
21
|
* @param {LabelTextStatus} error Changes color to `theme.color.notification.error`
|
|
25
|
-
*
|
|
26
|
-
* @deprecated info, success and warning are deprecated, please switch to default or error status
|
|
27
22
|
*/
|
|
28
23
|
status?: LabelTextStatus;
|
|
29
24
|
/**
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import { Globe } from '@dnanpm/icons';
|
|
2
|
-
import React__default, {
|
|
2
|
+
import React__default, { useCallback } from 'react';
|
|
3
3
|
import { styled } from 'styled-components';
|
|
4
4
|
import theme from '../../../themes/theme.js';
|
|
5
|
-
import { navIconSize } from '../../../themes/themeComponents/navigation.js';
|
|
6
5
|
import { getMultipliedSize } from '../../../utils/styledUtils.js';
|
|
7
|
-
import NavContext from '../context/NavContext.js';
|
|
8
6
|
import { MenuLink } from '../globalNavStyles.js';
|
|
9
7
|
import MainNavTooltipMenu from './MainNavTooltipMenu.js';
|
|
10
8
|
|
|
11
|
-
const
|
|
9
|
+
const MenuWrapper = styled.div `
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: ${getMultipliedSize(theme.base.baseWidth, 2)};
|
|
13
|
+
margin: ${getMultipliedSize(theme.base.baseHeight, 2)}
|
|
14
|
+
${getMultipliedSize(theme.base.baseHeight, 3)};
|
|
12
15
|
font-weight: ${theme.fontWeight.medium};
|
|
13
|
-
margin: ${getMultipliedSize(theme.base.baseHeight, 1)} auto;
|
|
14
16
|
text-align: center;
|
|
15
17
|
`;
|
|
16
|
-
const LangComponent = ({ currentLanguage, languagesObject }) => (React__default.createElement(
|
|
18
|
+
const LangComponent = ({ currentLanguage, languagesObject }) => (React__default.createElement(MenuWrapper, null, Object.entries(languagesObject)
|
|
17
19
|
.filter(([key]) => key.toLowerCase() !== currentLanguage.toLowerCase())
|
|
18
|
-
.map(([key, value]) => (React__default.createElement(
|
|
20
|
+
.map(([key, value]) => (React__default.createElement(MenuLink, { key: `language-${key}`, href: value }, key.toUpperCase())))));
|
|
19
21
|
const LanguageSelector = ({ currentLanguage, languagesObject, languageSelectorLabel, }) => {
|
|
20
|
-
const { isMobileMenu, navZIndex } = useContext(NavContext);
|
|
21
22
|
const LngComponent = useCallback(() => (React__default.createElement(LangComponent, { languageSelectorLabel: languageSelectorLabel, currentLanguage: currentLanguage, languagesObject: languagesObject })), [currentLanguage, languagesObject, languageSelectorLabel]);
|
|
22
23
|
if (Object.keys(languagesObject).length < 2) {
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
|
-
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: languageSelectorLabel, closeWhenTagClicked: ['a'], contentComponent: LngComponent, contentWidth: "5rem", globalStateString: "lang", tooltipRight:
|
|
26
|
-
React__default.createElement(Globe,
|
|
26
|
+
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: languageSelectorLabel, closeWhenTagClicked: ['a'], contentComponent: LngComponent, contentWidth: "5rem", globalStateString: "lang", tooltipRight: "auto" },
|
|
27
|
+
React__default.createElement(Globe, null),
|
|
27
28
|
React__default.createElement("span", { "data-testid": "header-lang-label" }, currentLanguage.toUpperCase())));
|
|
28
29
|
};
|
|
29
30
|
|
|
@@ -4,8 +4,8 @@ import NavContext from '../context/NavContext.js';
|
|
|
4
4
|
import MainNavTooltipMenu from './MainNavTooltipMenu.js';
|
|
5
5
|
|
|
6
6
|
const LoginTooltip = ({ isLogged, loginLabel }) => {
|
|
7
|
-
const {
|
|
8
|
-
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: loginLabel, closeWhenTagClicked: ['a', 'button'], contentComponent: loginComponent, globalStateString: "login", tooltipRight: isMobileMenu ? '3rem' : '1rem'
|
|
7
|
+
const { isMobileMenu, loginComponent } = useContext(NavContext);
|
|
8
|
+
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: loginLabel, closeWhenTagClicked: ['a', 'button'], contentComponent: loginComponent, globalStateString: "login", tooltipRight: isMobileMenu ? '3rem' : '1rem' }, !isLogged ? (loginLabel) : (React__default.createElement(React__default.Fragment, null,
|
|
9
9
|
React__default.createElement(User, null),
|
|
10
10
|
React__default.createElement("span", { "data-testid": "header-login-label" }, loginLabel)))));
|
|
11
11
|
};
|
|
@@ -6,13 +6,11 @@ interface MainNavTooltipMenuProps<ContentProps extends object = object> extends
|
|
|
6
6
|
ariaLabel?: string;
|
|
7
7
|
/** Tooltip menu content */
|
|
8
8
|
children?: ReactNode;
|
|
9
|
-
/** Overlap other elements */
|
|
10
|
-
zIndex?: number;
|
|
11
9
|
/** Tooltip position from right. Default: 1.25rem */
|
|
12
10
|
tooltipRight?: string;
|
|
13
11
|
/** Mandatory Component provided as login content */
|
|
14
12
|
contentComponent?: ComponentType<ContentProps> | ReactNode | boolean;
|
|
15
|
-
/** Array of tags (lowercase) that will close menu if they are inside the dropdown tooltip menu. default []. THIS CAN BE OVERRIDEN WITH
|
|
13
|
+
/** Array of tags (lowercase) that will close menu if they are inside the dropdown tooltip menu. default []. THIS CAN BE OVERRIDEN WITH className="no-close" in element */
|
|
16
14
|
closeWhenTagClicked?: string[];
|
|
17
15
|
/** Width of the opened menu content. default 20rem. */
|
|
18
16
|
contentWidth?: string;
|
|
@@ -27,5 +25,5 @@ export declare const IconContainer: import("styled-components/dist/types").IStyl
|
|
|
27
25
|
$isActive?: boolean;
|
|
28
26
|
$collapseSize: number;
|
|
29
27
|
}>> & string;
|
|
30
|
-
declare const MainNavTooltipMenu: <ContentProps extends object = object>({ ariaLabel, children, closeWhenTagClicked, contentComponent, contentWidth, fullWidthBreakpoint, fullWidthDesktop, globalStateString, tooltipRight,
|
|
28
|
+
declare const MainNavTooltipMenu: <ContentProps extends object = object>({ ariaLabel, children, closeWhenTagClicked, contentComponent, contentWidth, fullWidthBreakpoint, fullWidthDesktop, globalStateString, tooltipRight, ...props }: MainNavTooltipMenuProps<ContentProps>) => React.JSX.Element;
|
|
31
29
|
export default MainNavTooltipMenu;
|
|
@@ -41,9 +41,7 @@ const Tooltip = styled.div `
|
|
|
41
41
|
min-height: ${getMultipliedSize(theme.base.baseHeight, 5)};
|
|
42
42
|
// Ensure that the tooltip's content is always visible within the viewport. So, the max-height is the viewport height minus the header's height + some margin.
|
|
43
43
|
max-height: calc(var(--vh100, 100vh) - ${getMultipliedSize(theme.base.baseHeight, 12)});
|
|
44
|
-
width: 100%;
|
|
45
44
|
position: absolute;
|
|
46
|
-
right: 0;
|
|
47
45
|
top: ${navMaxHeight};
|
|
48
46
|
z-index: ${p => p.$zIndex};
|
|
49
47
|
display: flex;
|
|
@@ -77,8 +75,8 @@ const Caret = styled.div `
|
|
|
77
75
|
}
|
|
78
76
|
`;
|
|
79
77
|
const MainNavTooltipMenu = (_a) => {
|
|
80
|
-
var { ariaLabel, children, closeWhenTagClicked = [], contentComponent, contentWidth = '20rem', fullWidthBreakpoint = theme.breakpoints.xs, fullWidthDesktop = false, globalStateString, tooltipRight = '-1rem'
|
|
81
|
-
const { collapseSize, isMobileMenu, isLoggedIn, resetMenuEvents, setTooltipItems, showLoginTooltip, showMinicart, tooltipItems, } = useContext(NavContext);
|
|
78
|
+
var { ariaLabel, children, closeWhenTagClicked = [], contentComponent, contentWidth = '20rem', fullWidthBreakpoint = theme.breakpoints.xs, fullWidthDesktop = false, globalStateString, tooltipRight = '-1rem' } = _a, props = __rest(_a, ["ariaLabel", "children", "closeWhenTagClicked", "contentComponent", "contentWidth", "fullWidthBreakpoint", "fullWidthDesktop", "globalStateString", "tooltipRight"]);
|
|
79
|
+
const { collapseSize, isMobileMenu, isLoggedIn, resetMenuEvents, setTooltipItems, showLoginTooltip, showMinicart, tooltipItems, navZIndex, } = useContext(NavContext);
|
|
82
80
|
const ref = useRef(null);
|
|
83
81
|
const globalStateKey = globalStateString;
|
|
84
82
|
const isLoginItemAndLoggedIn = globalStateKey === 'login' && isLoggedIn;
|
|
@@ -105,8 +103,8 @@ const MainNavTooltipMenu = (_a) => {
|
|
|
105
103
|
return (React__default.createElement(IconContainer, { "data-testid": `header-${globalStateKey}-container`, "$collapseSize": collapseSize, ref: ref },
|
|
106
104
|
globalStateKey === 'login' && !isLoggedIn ? (React__default.createElement(ButtonPrimary, { onClick: ContentComponent ? toggleState : undefined, small: true }, children)) : (React__default.createElement(TooltipWrapper, { "aria-label": ariaLabel, "aria-expanded": tooltipItems[globalStateKey], "$isLoggedIn": isLoginItemAndLoggedIn, "$collapseSize": collapseSize, "$isHighlighted": tooltipItems[globalStateKey] || isLoginItemAndLoggedIn, onClick: props.onCartButtonClick || (ContentComponent ? toggleState : undefined) }, children)),
|
|
107
105
|
tooltipItems[globalStateKey] && ContentComponent && (React__default.createElement(React__default.Fragment, null,
|
|
108
|
-
React__default.createElement(Caret, { "$zIndex":
|
|
109
|
-
React__default.createElement(Tooltip, { "$zIndex":
|
|
106
|
+
React__default.createElement(Caret, { "$zIndex": navZIndex + 1, "$collapseSize": collapseSize }),
|
|
107
|
+
React__default.createElement(Tooltip, { "$zIndex": navZIndex + 1, "$tooltipRight": tooltipRight, "$contentWidth": contentWidth, "$collapseSize": collapseSize, "$fullWidthDesktop": fullWidthDesktop, "$fullWidthBreakpoint": fullWidthBreakpoint },
|
|
110
108
|
React__default.createElement(TooltipBox, { elevation: "high", padding: "0", width: "100%" },
|
|
111
109
|
React__default.createElement(ContentComponent, { mobileView: isMobileMenu })))))));
|
|
112
110
|
};
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { Cart } from '@dnanpm/icons';
|
|
2
|
-
import React__default
|
|
2
|
+
import React__default from 'react';
|
|
3
3
|
import theme from '../../../themes/theme.js';
|
|
4
4
|
import NotificationBadge from '../../NotificationBadge/NotificationBadge.js';
|
|
5
|
-
import NavContext from '../context/NavContext.js';
|
|
6
5
|
import MainNavTooltipMenu from './MainNavTooltipMenu.js';
|
|
7
6
|
|
|
8
|
-
const MinicartTooltip = ({ minicartAmount, minicartAmountLabel, minicartLabel, onCartButtonClick, }) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
React__default.createElement("span", { "aria-hidden": !!minicartAmountLabel }, minicartLabel),
|
|
13
|
-
minicartAmount > 0 && (React__default.createElement(NotificationBadge, { "data-testid": "header-minicart-amount", right: "5px", top: "-5px", visuallyHiddenText: minicartAmountLabel }, minicartAmount))));
|
|
14
|
-
};
|
|
7
|
+
const MinicartTooltip = ({ minicartAmount, minicartAmountLabel, minicartLabel, onCartButtonClick, }) => (React__default.createElement(MainNavTooltipMenu, { closeWhenTagClicked: ['a', 'button'], onCartButtonClick: onCartButtonClick, contentWidth: "35rem", fullWidthBreakpoint: theme.breakpoints.md, globalStateString: "minicart", tooltipRight: "5rem" },
|
|
8
|
+
React__default.createElement(Cart, null),
|
|
9
|
+
React__default.createElement("span", { "aria-hidden": !!minicartAmountLabel }, minicartLabel),
|
|
10
|
+
minicartAmount > 0 && (React__default.createElement(NotificationBadge, { "data-testid": "header-minicart-amount", right: "5px", top: "-5px", visuallyHiddenText: minicartAmountLabel }, minicartAmount))));
|
|
15
11
|
|
|
16
12
|
export { MinicartTooltip as default };
|
|
@@ -4,8 +4,8 @@ import NavContext from '../context/NavContext.js';
|
|
|
4
4
|
import MainNavTooltipMenu from './MainNavTooltipMenu.js';
|
|
5
5
|
|
|
6
6
|
const PageSearch = ({ searchLabel }) => {
|
|
7
|
-
const {
|
|
8
|
-
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: searchLabel, closeWhenTagClicked: ['a'], contentComponent: searchComponent, contentWidth: "100%", "data-testid": "header-search-container", fullWidthDesktop: true, globalStateString: "search", tooltipRight: "0"
|
|
7
|
+
const { searchComponent } = useContext(NavContext);
|
|
8
|
+
return (React__default.createElement(MainNavTooltipMenu, { ariaLabel: searchLabel, closeWhenTagClicked: ['a'], contentComponent: searchComponent, contentWidth: "100%", "data-testid": "header-search-container", fullWidthDesktop: true, globalStateString: "search", tooltipRight: "0" },
|
|
9
9
|
React__default.createElement(Search, null),
|
|
10
10
|
React__default.createElement("span", null, searchLabel)));
|
|
11
11
|
};
|
|
@@ -19,12 +19,6 @@ export interface MainHeaderNavigationProps {
|
|
|
19
19
|
minicartText?: string;
|
|
20
20
|
minicartAmount?: number;
|
|
21
21
|
minicartAmountLabel?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Defines MinicartComponent when used. If minicart is true but component is not provided, shown as disabled element.
|
|
24
|
-
*
|
|
25
|
-
* @deprecated Use `onCartButtonClick` property instead
|
|
26
|
-
*/
|
|
27
|
-
minicartComponent?: ComponentType | ReactNode | boolean;
|
|
28
22
|
showMinicart?: boolean;
|
|
29
23
|
/**
|
|
30
24
|
* On Cart button click callback
|
|
@@ -47,6 +41,6 @@ export interface MainHeaderNavigationProps {
|
|
|
47
41
|
notificationText?: string;
|
|
48
42
|
}
|
|
49
43
|
/** @visibleName MainHeaderNavigation */
|
|
50
|
-
declare const MainHeaderNavigation: ({ backToPreviousCategoryLabel, businessMenuAriaLabel, categoryCollectionText, closeMainMenuAriaLabel, className, collapseSize, currentUrl, dnaLogoLinkAriaLabel, featuredItemsAriaLabel, isLoggedIn, items, language, languageSelector, languageSelectorText, login, loginComponent, loginText, mainMenuAriaLabel, minicart, minicartAmount, minicartAmountLabel,
|
|
44
|
+
declare const MainHeaderNavigation: ({ backToPreviousCategoryLabel, businessMenuAriaLabel, categoryCollectionText, closeMainMenuAriaLabel, className, collapseSize, currentUrl, dnaLogoLinkAriaLabel, featuredItemsAriaLabel, isLoggedIn, items, language, languageSelector, languageSelectorText, login, loginComponent, loginText, mainMenuAriaLabel, minicart, minicartAmount, minicartAmountLabel, minicartText, nextJSLinkComponent, nextJSLinkLegacyBehavior, notificationText, openMainMenuAriaLabel, search, searchComponent, searchText, showLoginTooltip, showMinicart, zIndex, ...props }: MainHeaderNavigationProps) => React.JSX.Element;
|
|
51
45
|
/** @component */
|
|
52
46
|
export default MainHeaderNavigation;
|
|
@@ -126,7 +126,7 @@ const initiateScrollToHeader = (componentRef) => {
|
|
|
126
126
|
/** @visibleName MainHeaderNavigation */
|
|
127
127
|
const MainHeaderNavigation = (_a) => {
|
|
128
128
|
var _b, _c, _d;
|
|
129
|
-
var { backToPreviousCategoryLabel = '', businessMenuAriaLabel = 'Sivustot', categoryCollectionText = 'Muut kategoriat', closeMainMenuAriaLabel, className, collapseSize = 767, currentUrl = '', dnaLogoLinkAriaLabel, featuredItemsAriaLabel = '', isLoggedIn = false, items = {}, language = 'fi', languageSelector = false, languageSelectorText = 'Vaihda kieltä', login = true, loginComponent, loginText = 'Kirjaudu', mainMenuAriaLabel = 'Päänavigaatio', minicart = true, minicartAmount = 0, minicartAmountLabel,
|
|
129
|
+
var { backToPreviousCategoryLabel = '', businessMenuAriaLabel = 'Sivustot', categoryCollectionText = 'Muut kategoriat', closeMainMenuAriaLabel, className, collapseSize = 767, currentUrl = '', dnaLogoLinkAriaLabel, featuredItemsAriaLabel = '', isLoggedIn = false, items = {}, language = 'fi', languageSelector = false, languageSelectorText = 'Vaihda kieltä', login = true, loginComponent, loginText = 'Kirjaudu', mainMenuAriaLabel = 'Päänavigaatio', minicart = true, minicartAmount = 0, minicartAmountLabel, minicartText = 'Ostoskori', nextJSLinkComponent = false, nextJSLinkLegacyBehavior = true, notificationText = '', openMainMenuAriaLabel, search = true, searchComponent = false, searchText = 'Haku', showLoginTooltip = false, showMinicart = false, zIndex = 1030 } = _a, props = __rest(_a, ["backToPreviousCategoryLabel", "businessMenuAriaLabel", "categoryCollectionText", "closeMainMenuAriaLabel", "className", "collapseSize", "currentUrl", "dnaLogoLinkAriaLabel", "featuredItemsAriaLabel", "isLoggedIn", "items", "language", "languageSelector", "languageSelectorText", "login", "loginComponent", "loginText", "mainMenuAriaLabel", "minicart", "minicartAmount", "minicartAmountLabel", "minicartText", "nextJSLinkComponent", "nextJSLinkLegacyBehavior", "notificationText", "openMainMenuAriaLabel", "search", "searchComponent", "searchText", "showLoginTooltip", "showMinicart", "zIndex"]);
|
|
130
130
|
const { isMobile } = useWindowSize(collapseSize);
|
|
131
131
|
const navigationEl = useRef(null);
|
|
132
132
|
const key = prop('id');
|
|
@@ -246,7 +246,6 @@ const MainHeaderNavigation = (_a) => {
|
|
|
246
246
|
level2Items,
|
|
247
247
|
loginComponent,
|
|
248
248
|
menuLevel,
|
|
249
|
-
minicartComponent,
|
|
250
249
|
navZIndex: zIndex,
|
|
251
250
|
nextJSLinkComponent,
|
|
252
251
|
nextJSLinkLegacyBehavior,
|
|
@@ -272,7 +271,6 @@ const MainHeaderNavigation = (_a) => {
|
|
|
272
271
|
level2Items,
|
|
273
272
|
loginComponent,
|
|
274
273
|
menuLevel,
|
|
275
|
-
minicartComponent,
|
|
276
274
|
nextJSLinkComponent,
|
|
277
275
|
nextJSLinkLegacyBehavior,
|
|
278
276
|
searchComponent,
|
|
@@ -17,7 +17,6 @@ export interface NavContextProps {
|
|
|
17
17
|
lang: string;
|
|
18
18
|
loginComponent?: ComponentType | ReactNode | boolean;
|
|
19
19
|
menuLevel: MenuStates;
|
|
20
|
-
minicartComponent?: ComponentType | ReactNode | boolean;
|
|
21
20
|
navZIndex: number;
|
|
22
21
|
nextJSLinkComponent: ComponentType | ReactNode | boolean;
|
|
23
22
|
nextJSLinkLegacyBehavior?: boolean;
|
|
@@ -63,11 +63,6 @@ interface Props {
|
|
|
63
63
|
* Allows to set property `aria-label` for content element
|
|
64
64
|
*/
|
|
65
65
|
contentLabel?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Allows changing CSS property `max-width` for Modal content wrapper element.
|
|
68
|
-
* @deprecated Replaced with 'size' property
|
|
69
|
-
*/
|
|
70
|
-
maxWidth?: string;
|
|
71
66
|
/**
|
|
72
67
|
* Allows to change the size of the component.
|
|
73
68
|
* Size in mobile view is always 100% of the window size
|
|
@@ -17,12 +17,6 @@ interface Props {
|
|
|
17
17
|
* @default false
|
|
18
18
|
*/
|
|
19
19
|
isExpanded?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Allows to show component in expanded state on init and immediately close after load
|
|
22
|
-
*
|
|
23
|
-
* @deprecated Use `isExpanded` property
|
|
24
|
-
*/
|
|
25
|
-
seoInitExpanded?: boolean;
|
|
26
20
|
/**
|
|
27
21
|
* On ButtonIcon mouse click callback.
|
|
28
22
|
*/
|
|
@@ -46,20 +40,6 @@ interface Props {
|
|
|
46
40
|
* @default '10rem'
|
|
47
41
|
*/
|
|
48
42
|
collapsedSize?: string;
|
|
49
|
-
/**
|
|
50
|
-
* Allows to change the label of ButtonIcon.
|
|
51
|
-
* Note: Ignored when `isStateless` is set to true
|
|
52
|
-
*
|
|
53
|
-
* @deprecated Use `buttonLabel` property
|
|
54
|
-
*/
|
|
55
|
-
showMoreText?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Allows to change the label of ButtonIcon.
|
|
58
|
-
* Note: Ignored when `isStateless` is set to true
|
|
59
|
-
*
|
|
60
|
-
* @deprecated Use `buttonLabel` property
|
|
61
|
-
*/
|
|
62
|
-
showLessText?: string;
|
|
63
43
|
/**
|
|
64
44
|
* Allows to pass a custom className
|
|
65
45
|
*/
|
|
@@ -36,14 +36,13 @@ const StyledButtonIcon = styled(ButtonIcon) `
|
|
|
36
36
|
/** @visibleName Read More */
|
|
37
37
|
const ReadMore = (_a) => {
|
|
38
38
|
var { collapsedSize = '10rem', 'data-testid': dataTestId } = _a, props = __rest(_a, ["collapsedSize", 'data-testid']);
|
|
39
|
-
const [expanded, setExpanded] = useState(
|
|
39
|
+
const [expanded, setExpanded] = useState(false);
|
|
40
40
|
const contentRef = useRef(null);
|
|
41
41
|
const buttonRef = useRef(null);
|
|
42
42
|
const userInteractedRef = useRef(false);
|
|
43
43
|
// TODO: Remove once https://jira.dna.fi/browse/STYLE-662 is done
|
|
44
44
|
const temporaryIsStatelessFlag = typeof props.isExpanded !== 'undefined';
|
|
45
45
|
const temporaryStateManagement = temporaryIsStatelessFlag ? props.isExpanded : expanded;
|
|
46
|
-
const temporaryButtonLabel = temporaryStateManagement ? props.showLessText : props.showMoreText;
|
|
47
46
|
const handleOnClick = (event) => {
|
|
48
47
|
if (props.onClick) {
|
|
49
48
|
props.onClick(event);
|
|
@@ -53,11 +52,6 @@ const ReadMore = (_a) => {
|
|
|
53
52
|
}
|
|
54
53
|
userInteractedRef.current = true;
|
|
55
54
|
};
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (props.seoInitExpanded) {
|
|
58
|
-
setExpanded(false);
|
|
59
|
-
}
|
|
60
|
-
}, [props.seoInitExpanded]);
|
|
61
55
|
useEffect(() => {
|
|
62
56
|
var _a, _b;
|
|
63
57
|
if (userInteractedRef.current) {
|
|
@@ -84,7 +78,7 @@ const ReadMore = (_a) => {
|
|
|
84
78
|
return (React__default.createElement(Container, { id: props.id, className: props.className, "data-testid": dataTestId, "aria-label": props.ariaLabel, role: "region" },
|
|
85
79
|
React__default.createElement(Content, { ref: contentRef, "$isExpanded": temporaryStateManagement, "$collapsedSize": collapsedSize, "data-testid": dataTestId && `${dataTestId}-content`, "aria-hidden": temporaryStateManagement ? 'false' : 'true', tabIndex: temporaryStateManagement ? 0 : -1 }, Children.map(props.children, forceTabIndexOnTextLinks)),
|
|
86
80
|
React__default.createElement(ButtonWrapper, { "$buttonPosition": props.buttonPosition },
|
|
87
|
-
React__default.createElement(StyledButtonIcon, { ref: buttonRef, icon: temporaryStateManagement ? ChevronUp : ChevronDown, onClick: handleOnClick, "aria-expanded": temporaryStateManagement },
|
|
81
|
+
React__default.createElement(StyledButtonIcon, { ref: buttonRef, icon: temporaryStateManagement ? ChevronUp : ChevronDown, onClick: handleOnClick, "aria-expanded": temporaryStateManagement }, props.buttonLabel))));
|
|
88
82
|
};
|
|
89
83
|
|
|
90
84
|
export { ReadMore as default };
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type Type = 'box' | 'panel' | 'underlined';
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use `box`, `panel` or `underlined` types
|
|
6
|
-
*/
|
|
7
|
-
type TypeDeprecated = 'default' | 'gray';
|
|
8
4
|
export interface Props {
|
|
9
5
|
/**
|
|
10
6
|
* Unique ID for the component
|
|
@@ -21,45 +17,21 @@ export interface Props {
|
|
|
21
17
|
* @param {Type} panel Content container remains unstyled
|
|
22
18
|
* @param {Type} underlined Tab label is visually similar to anchor, with content container unstyled
|
|
23
19
|
*
|
|
24
|
-
* @param {TypeDeprecated} default DEPRECATED Use `box` type
|
|
25
|
-
* @param {TypeDeprecated} gray DEPRECATED Use `box`, `panel` or `underlined` types
|
|
26
|
-
*
|
|
27
20
|
* @default 'box'
|
|
28
21
|
*/
|
|
29
|
-
type?: Type
|
|
30
|
-
/**
|
|
31
|
-
* Style of the tab
|
|
32
|
-
*
|
|
33
|
-
* @deprecated Use `type` property
|
|
34
|
-
*/
|
|
35
|
-
tabStyle?: Type;
|
|
22
|
+
type?: Type;
|
|
36
23
|
/**
|
|
37
24
|
* Content of the component
|
|
38
25
|
*/
|
|
39
26
|
children?: ReactNode;
|
|
40
|
-
/**
|
|
41
|
-
* Allows to define currently active tab
|
|
42
|
-
*
|
|
43
|
-
* @deprecated Use `isActive` property
|
|
44
|
-
*/
|
|
45
|
-
activeTab?: string;
|
|
46
27
|
/**
|
|
47
28
|
* Allows to set tab as active
|
|
48
29
|
*/
|
|
49
30
|
isActive?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Allows to enable updated internal state management.
|
|
52
|
-
* Note: In updated internal state management, this component acts as truly stateless and can be controlled with `isActive` property.
|
|
53
|
-
*
|
|
54
|
-
* @deprecated Will be removed in next major release
|
|
55
|
-
*/
|
|
56
|
-
isStateless?: boolean;
|
|
57
31
|
/**
|
|
58
32
|
* On tab label click callback
|
|
59
|
-
*
|
|
60
|
-
* @deprecated Parameter `tab` has been deprecated. Use `e` parameter instead
|
|
61
33
|
*/
|
|
62
|
-
onClick?: (
|
|
34
|
+
onClick?: (label: string, e?: MouseEvent<HTMLElement>) => void;
|
|
63
35
|
/**
|
|
64
36
|
* Allows to pass testid string for testing purposes
|
|
65
37
|
*/
|
|
@@ -3,8 +3,6 @@ import React__default from 'react';
|
|
|
3
3
|
import { styled } from 'styled-components';
|
|
4
4
|
import theme from '../../themes/theme.js';
|
|
5
5
|
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
6
|
-
import Box from '../Box/Box.js';
|
|
7
|
-
import Divider from '../Divider/Divider.js';
|
|
8
6
|
|
|
9
7
|
// TODO: Change to button HTML element as a part of https://jira.dna.fi/browse/STYLE-622
|
|
10
8
|
const TabLabel = styled.li `
|
|
@@ -56,26 +54,6 @@ const TabStyle = styled.li `
|
|
|
56
54
|
background-color: transparent;
|
|
57
55
|
`}
|
|
58
56
|
`;
|
|
59
|
-
const ContentContainer = styled.div `
|
|
60
|
-
${({ $type }) => {
|
|
61
|
-
if ($type === 'box' || $type === 'default') {
|
|
62
|
-
return `
|
|
63
|
-
border-top-left-radius: 0;
|
|
64
|
-
`;
|
|
65
|
-
}
|
|
66
|
-
if ($type === 'panel') {
|
|
67
|
-
return `
|
|
68
|
-
border-top: 1px solid ${theme.color.line.L03};
|
|
69
|
-
`;
|
|
70
|
-
}
|
|
71
|
-
if ($type === 'underlined' || $type === 'gray') {
|
|
72
|
-
return `
|
|
73
|
-
margin-top: ${theme.grid.gutter};
|
|
74
|
-
`;
|
|
75
|
-
}
|
|
76
|
-
return '';
|
|
77
|
-
}}
|
|
78
|
-
`;
|
|
79
57
|
/** @visibleName Tab */
|
|
80
58
|
const Tab = (_a) => {
|
|
81
59
|
var { type = 'box', 'data-testid': dataTestId } = _a, props = __rest(_a, ["type", 'data-testid']);
|
|
@@ -84,17 +62,8 @@ const Tab = (_a) => {
|
|
|
84
62
|
props.onClick(props.label, e);
|
|
85
63
|
}
|
|
86
64
|
};
|
|
87
|
-
const isActive = props
|
|
88
|
-
return type === 'box' || type === '
|
|
89
|
-
React__default.createElement(TabLabel, { role: "tab", id: props.id, "$type": type, "aria-selected": isActive, "$isActive": isActive, onClick: onClickHandler, tabIndex: isActive ? 0 : -1 }, props.label),
|
|
90
|
-
props.isStateless &&
|
|
91
|
-
(props.children && (props.activeTab === props.label || props.isActive) ? (React__default.createElement(ContentContainer, { role: "tabpanel", "$type": props.tabStyle || type, as: (type === 'box' || type === 'default') && !props.tabStyle
|
|
92
|
-
? Box
|
|
93
|
-
: undefined }, props.children)) : (React__default.createElement(Divider, { margin: "0" }))))) : (React__default.createElement(React__default.Fragment, null,
|
|
94
|
-
React__default.createElement(TabStyle, { role: "tab", id: props.id, "$type": props.tabStyle || type, "aria-selected": isActive, "$isActive": isActive, onClick: onClickHandler, tabIndex: isActive ? 0 : -1 }, props.label),
|
|
95
|
-
props.isStateless &&
|
|
96
|
-
props.children &&
|
|
97
|
-
(props.activeTab === props.label || props.isActive) && (React__default.createElement(ContentContainer, { role: "tabpanel", "$type": props.tabStyle || type }, props.children))));
|
|
65
|
+
const { isActive } = props;
|
|
66
|
+
return type === 'box' || type === 'panel' ? (React__default.createElement(TabLabel, { role: "tab", "data-testid": dataTestId, id: props.id, "$type": type, "aria-selected": isActive, "$isActive": isActive, onClick: onClickHandler, tabIndex: isActive ? 0 : -1 }, props.label)) : (React__default.createElement(TabStyle, { role: "tab", "data-testid": dataTestId, id: props.id, "$type": type, "aria-selected": isActive, "$isActive": isActive, onClick: onClickHandler, tabIndex: isActive ? 0 : -1 }, props.label));
|
|
98
67
|
};
|
|
99
68
|
|
|
100
69
|
export { Tab as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { Props as TabProps } from '../Tab/Tab';
|
|
4
|
-
interface Props extends Omit<TabProps, 'label' | 'children' | 'activeTab' | 'onClick'> {
|
|
4
|
+
interface Props extends Omit<TabProps, 'label' | 'children' | 'activeTab' | 'onClick' | 'tabStyle' | 'isStateless'> {
|
|
5
5
|
/**
|
|
6
6
|
* Content of the component
|
|
7
7
|
*
|
|
@@ -22,20 +22,12 @@ interface Props extends Omit<TabProps, 'label' | 'children' | 'activeTab' | 'onC
|
|
|
22
22
|
* Allows to reduce gap between tabs in `underlined` type
|
|
23
23
|
*/
|
|
24
24
|
isNarrowUnderlined?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* On tab change callback
|
|
27
|
-
*
|
|
28
|
-
* @deprecated Use `onClick` property
|
|
29
|
-
*/
|
|
30
|
-
onChange?: (tab: string) => void;
|
|
31
25
|
/**
|
|
32
26
|
* Allows to pass common mouse click callback to all children
|
|
33
27
|
*/
|
|
34
28
|
onClick?: (e: MouseEvent<HTMLElement>) => void;
|
|
35
29
|
/**
|
|
36
30
|
* Allows to pass a custom className
|
|
37
|
-
*
|
|
38
|
-
* @deprecated Prefix 'tabs' is deprecated and will be removed in next major version
|
|
39
31
|
*/
|
|
40
32
|
className?: string;
|
|
41
33
|
}
|
|
@@ -21,7 +21,7 @@ const Tablist = styled.ul `
|
|
|
21
21
|
`}
|
|
22
22
|
|
|
23
23
|
${({ $type, $isNarrowUnderlined }) => {
|
|
24
|
-
if ($type === 'box' || $type === '
|
|
24
|
+
if ($type === 'box' || $type === 'panel') {
|
|
25
25
|
return `
|
|
26
26
|
margin: 0;
|
|
27
27
|
|
|
@@ -47,17 +47,12 @@ const Tablist = styled.ul `
|
|
|
47
47
|
border-bottom: 1px solid ${theme.color.line.L02};
|
|
48
48
|
`;
|
|
49
49
|
}
|
|
50
|
-
if ($type === 'gray') {
|
|
51
|
-
return `
|
|
52
|
-
gap: 1.25rem;
|
|
53
|
-
`;
|
|
54
|
-
}
|
|
55
50
|
return '';
|
|
56
51
|
}}
|
|
57
52
|
`;
|
|
58
53
|
const ContentContainer = styled.div `
|
|
59
54
|
${({ $type, $isFullWidth }) => {
|
|
60
|
-
if ($type === 'box'
|
|
55
|
+
if ($type === 'box') {
|
|
61
56
|
return `
|
|
62
57
|
border-top-left-radius: 0;
|
|
63
58
|
${$isFullWidth ? 'border-top-right-radius: 0;' : ''}
|
|
@@ -68,7 +63,7 @@ const ContentContainer = styled.div `
|
|
|
68
63
|
border-top: 1px solid ${theme.color.line.L03};
|
|
69
64
|
`;
|
|
70
65
|
}
|
|
71
|
-
if ($type === 'underlined'
|
|
66
|
+
if ($type === 'underlined') {
|
|
72
67
|
return `
|
|
73
68
|
margin-top: ${theme.grid.gutter};
|
|
74
69
|
`;
|
|
@@ -84,9 +79,6 @@ const Tabs = (_a) => {
|
|
|
84
79
|
const onClickTabItem = (tab, e) => {
|
|
85
80
|
setActiveTab(tab);
|
|
86
81
|
if (tab !== activeTab) {
|
|
87
|
-
if (props.onChange) {
|
|
88
|
-
props.onChange(tab);
|
|
89
|
-
}
|
|
90
82
|
if (props.onClick && e) {
|
|
91
83
|
props.onClick(e);
|
|
92
84
|
}
|
|
@@ -107,16 +99,16 @@ const Tabs = (_a) => {
|
|
|
107
99
|
if (!tabs) {
|
|
108
100
|
return null;
|
|
109
101
|
}
|
|
110
|
-
const outerActiveTab = tabs.find(child => child.props.isActive
|
|
102
|
+
const outerActiveTab = tabs.find(child => child.props.isActive);
|
|
111
103
|
if (!activeTab) {
|
|
112
104
|
setActiveTab((outerActiveTab === null || outerActiveTab === void 0 ? void 0 : outerActiveTab.props.label) || tabs[0].props.label);
|
|
113
105
|
}
|
|
114
|
-
return (React__default.createElement("div", { className: props.className
|
|
115
|
-
React__default.createElement(Tablist, { role: "tablist", "$type":
|
|
116
|
-
tab.type === Tab && (React__default.createElement(Tab, { id: tab.props.id, key: tab.props.label, label: tab.props.label, type:
|
|
106
|
+
return (React__default.createElement("div", { className: props.className, "data-testid": dataTestId },
|
|
107
|
+
React__default.createElement(Tablist, { role: "tablist", "$type": type, "$isFullWidth": props.isFullWidth, "$isNarrowUnderlined": props.isNarrowUnderlined, onKeyDown: onKeyDown }, Children.map(props.children, tab => isValidElement(tab) &&
|
|
108
|
+
tab.type === Tab && (React__default.createElement(Tab, { id: tab.props.id, key: tab.props.label, label: tab.props.label, type: type, isActive: tab.props.isActive
|
|
117
109
|
? tab.props.isActive
|
|
118
|
-
: activeTab === tab.props.label,
|
|
119
|
-
React__default.createElement(ContentContainer, { role: "tabpanel", "$type":
|
|
110
|
+
: activeTab === tab.props.label, onClick: onClickTabItem, className: tab.props.className, "data-testid": tab.props['data-testid'] })))),
|
|
111
|
+
React__default.createElement(ContentContainer, { role: "tabpanel", "$type": type, "$isFullWidth": props.isFullWidth, as: type === 'box' ? Box : undefined }, Children.map(props.children, tab => isValidElement(tab) &&
|
|
120
112
|
tab.type === Tab &&
|
|
121
113
|
(tab.props.isActive || tab.props.label === activeTab) &&
|
|
122
114
|
tab.props.children))));
|
|
@@ -100,7 +100,7 @@ const Tooltip = (_a) => {
|
|
|
100
100
|
scroll: true,
|
|
101
101
|
};
|
|
102
102
|
return (React__default.createElement(React__default.Fragment, null,
|
|
103
|
-
!props.hideTriggerElement && (React__default.createElement(Helper, { "data-tooltip-id": props.id, "$isClickable": isClickable, className: props.className, "data-testid": dataTestId, type: "button", "data-tooltip-delay-hide": 500
|
|
103
|
+
!props.hideTriggerElement && (React__default.createElement(Helper, { "data-tooltip-id": props.id, "$isClickable": isClickable, className: props.className, "data-testid": dataTestId, type: "button", "data-tooltip-delay-hide": 500 },
|
|
104
104
|
React__default.createElement(Icon, { icon: Info, size: "1rem", position: props.position, "aria-hidden": true }))),
|
|
105
105
|
React__default.createElement(StyledReactTooltip, { id: props.id, place: props.placement, openOnClick: isClickable, clickable: isHoverable, "$isMultiline": props.isMultiline, disableStyleInjection: true, role: isHoverable ? 'dialog' : 'tooltip', openEvents: handleReactTooltipOpenEvents, globalCloseEvents: handleReactTooltipGlobalCloseEvents, closeEvents: handleReactTooltipCloseEvents, "data-testid": dataTestId && `${dataTestId}-content` }, props.children)));
|
|
106
106
|
};
|