@hh.ru/magritte-ui-tabs 4.0.3 → 5.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/Tab-443da8f8.js +77 -0
- package/Tab-443da8f8.js.map +1 -0
- package/Tab.d.ts +1 -1
- package/Tab.js +2 -2
- package/Tabs.js +2 -2
- package/index.css +159 -150
- package/index.js +2 -2
- package/package.json +9 -9
- package/types.d.ts +2 -1
- package/useTabs.js +2 -2
- package/Tab-90e0c9a2.js +0 -79
- package/Tab-90e0c9a2.js.map +0 -1
package/Tab-443da8f8.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, memo, useRef, useState, useLayoutEffect, useCallback } from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import '@hh.ru/magritte-common-focus-visible';
|
|
6
|
+
import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
|
|
7
|
+
import { ComponentWithBadge, Badge } from '@hh.ru/magritte-ui-badge';
|
|
8
|
+
import { useScrollContext } from '@hh.ru/magritte-ui-scrollable-container';
|
|
9
|
+
import { TooltipHover } from '@hh.ru/magritte-ui-tooltip';
|
|
10
|
+
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
11
|
+
|
|
12
|
+
var styles = {"tabs":"magritte-tabs___VcV8C_5-0-1","tab-wrapper":"magritte-tab-wrapper___9j9qk_5-0-1","tabWrapper":"magritte-tab-wrapper___9j9qk_5-0-1","tab":"magritte-tab___B0BeU_5-0-1","tab_selected":"magritte-tab_selected___w9PT2_5-0-1","tabSelected":"magritte-tab_selected___w9PT2_5-0-1","tab-wrapper_primary":"magritte-tab-wrapper_primary___yt3sT_5-0-1","tabWrapperPrimary":"magritte-tab-wrapper_primary___yt3sT_5-0-1","tab_primary":"magritte-tab_primary___3Of2H_5-0-1","tabPrimary":"magritte-tab_primary___3Of2H_5-0-1","tab-label":"magritte-tab-label___nFmge_5-0-1","tabLabel":"magritte-tab-label___nFmge_5-0-1","postfix":"magritte-postfix___30ZxD_5-0-1","tab-content":"magritte-tab-content___onvTJ_5-0-1","tabContent":"magritte-tab-content___onvTJ_5-0-1","tab-wrapper_secondary":"magritte-tab-wrapper_secondary___avLln_5-0-1","tabWrapperSecondary":"magritte-tab-wrapper_secondary___avLln_5-0-1","tab_secondary":"magritte-tab_secondary___-00LL_5-0-1","tabSecondary":"magritte-tab_secondary___-00LL_5-0-1","postfix-wrapper":"magritte-postfix-wrapper___1dORq_5-0-1","postfixWrapper":"magritte-postfix-wrapper___1dORq_5-0-1","indicator-wrapper":"magritte-indicator-wrapper___Q68i7_5-0-1","indicatorWrapper":"magritte-indicator-wrapper___Q68i7_5-0-1","indicator":"magritte-indicator___irp4W_5-0-1","animate":"magritte-animate___5GxTP_5-0-1"};
|
|
13
|
+
|
|
14
|
+
const TabForwardRefRenderFunc = ({ Element = 'button', badge = false, children, 'data-qa': dataQa = 'tab', focused, hidden, id, itemRef, mode = 'primary', onClick, onSelect, postfix, selected, ...buttonProps }, ref) => {
|
|
15
|
+
const activatorRef = useRef(null);
|
|
16
|
+
const elementRef = useRef(null);
|
|
17
|
+
const elementRefCallback = useMultipleRefs(elementRef, itemRef, ref);
|
|
18
|
+
const mouseEventRef = useRef(false);
|
|
19
|
+
const labelRef = useRef(null);
|
|
20
|
+
const { removeItem, registerItem, scrollToItem } = useScrollContext();
|
|
21
|
+
const [showTooltip, setShowTooltip] = useState(false);
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
if (elementRef.current) {
|
|
24
|
+
registerItem(elementRef);
|
|
25
|
+
}
|
|
26
|
+
return () => {
|
|
27
|
+
removeItem(elementRef);
|
|
28
|
+
};
|
|
29
|
+
}, [registerItem, removeItem]);
|
|
30
|
+
useLayoutEffect(() => {
|
|
31
|
+
if (focused && elementRef.current) {
|
|
32
|
+
elementRef.current.focus();
|
|
33
|
+
}
|
|
34
|
+
}, [focused]);
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
if (selected && elementRef.current) {
|
|
37
|
+
scrollToItem(elementRef);
|
|
38
|
+
if (showTooltip && labelRef.current) {
|
|
39
|
+
labelRef.current.dispatchEvent(new MouseEvent('mouseout', { bubbles: true, cancelable: true }));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, [selected, scrollToItem, showTooltip]);
|
|
43
|
+
useLayoutEffect(() => {
|
|
44
|
+
if (mode === 'secondary' &&
|
|
45
|
+
labelRef.current !== null &&
|
|
46
|
+
labelRef.current.scrollWidth > labelRef.current.offsetWidth) {
|
|
47
|
+
setShowTooltip(true);
|
|
48
|
+
}
|
|
49
|
+
}, [mode, setShowTooltip]);
|
|
50
|
+
const handleFocus = useCallback(() => {
|
|
51
|
+
if (!mouseEventRef.current) {
|
|
52
|
+
scrollToItem(elementRef);
|
|
53
|
+
}
|
|
54
|
+
}, [scrollToItem]);
|
|
55
|
+
const setMouseEventRef = useCallback(() => (mouseEventRef.current = true), []);
|
|
56
|
+
const resetMouseEventRef = useCallback(() => (mouseEventRef.current = false), []);
|
|
57
|
+
const handleWheel = useCallback(() => {
|
|
58
|
+
if (labelRef?.current) {
|
|
59
|
+
labelRef.current.dispatchEvent(new MouseEvent('mouseout', { bubbles: true, cancelable: true }));
|
|
60
|
+
}
|
|
61
|
+
}, []);
|
|
62
|
+
if (hidden) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const handleClick = (event) => {
|
|
66
|
+
onSelect?.(id);
|
|
67
|
+
onClick?.(event);
|
|
68
|
+
};
|
|
69
|
+
const content = (jsxs("span", { className: styles.tabContent, ref: activatorRef, children: [jsx("span", { className: styles.tabLabel, ref: labelRef, children: jsx(Text, { Element: "span", typography: mode === 'primary' ? 'subtitle-1-semibold' : 'label-3-regular', children: children }) }), postfix && (jsx("span", { className: styles.postfixWrapper, "data-qa": "tab-postfix", children: jsx(Text, { Element: "span", typography: mode === 'primary' ? 'subtitle-1-semibold' : 'subtitle-2-semibold', children: jsx("span", { className: styles.postfix, children: postfix }) }) }))] }));
|
|
70
|
+
const tabElement = (jsxs(Element, { ...buttonProps, type: "button", ref: elementRefCallback, role: "tab", "data-qa": dataQa, onClick: handleClick, className: classnames(styles.tab, { [styles.tabSelected]: selected, [styles[`tab_${mode}`]]: !!mode }), "aria-selected": selected, onFocus: handleFocus, onMouseDown: setMouseEventRef, onMouseLeave: resetMouseEventRef, onMouseUp: resetMouseEventRef, onWheel: showTooltip ? handleWheel : undefined, children: [content, showTooltip && (jsx(TooltipHover, { activatorRef: activatorRef, alignment: "center", direction: "top", children: children }))] }));
|
|
71
|
+
return (jsx("div", { className: classnames(styles.tabWrapper, { [styles[`tab-wrapper_${mode}`]]: !!mode }), children: badge && mode === 'primary' ? (jsx(ComponentWithBadge, { badge: jsx(Badge, { size: "extra-small" }), offset: 2, children: tabElement })) : (tabElement) }));
|
|
72
|
+
};
|
|
73
|
+
const TabComponent = forwardRef(TabForwardRefRenderFunc);
|
|
74
|
+
const Tab = memo(TabComponent);
|
|
75
|
+
|
|
76
|
+
export { Tab as T, styles as s };
|
|
77
|
+
//# sourceMappingURL=Tab-443da8f8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tab-443da8f8.js","sources":["../src/Tab.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, useCallback, useLayoutEffect, useRef, useState, MouseEventHandler } from 'react';\nimport classnames from 'classnames';\n\nimport '@hh.ru/magritte-common-focus-visible';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { ComponentWithCustomElement, ForwardRefRenderFuncWithCustomElement } from '@hh.ru/magritte-types';\nimport { Badge, ComponentWithBadge } from '@hh.ru/magritte-ui-badge';\nimport { useScrollContext } from '@hh.ru/magritte-ui-scrollable-container';\nimport { TabProps } from '@hh.ru/magritte-ui-tabs/types';\nimport { TooltipHover } from '@hh.ru/magritte-ui-tooltip';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './tabs.less';\n\nconst TabForwardRefRenderFunc: ForwardRefRenderFuncWithCustomElement<TabProps, 'button'> = (\n {\n Element = 'button',\n badge = false,\n children,\n 'data-qa': dataQa = 'tab',\n focused,\n hidden,\n id,\n itemRef,\n mode = 'primary',\n onClick,\n onSelect,\n postfix,\n selected,\n ...buttonProps\n },\n ref\n) => {\n const activatorRef = useRef<HTMLSpanElement>(null);\n const elementRef = useRef<HTMLElement>(null);\n const elementRefCallback = useMultipleRefs<HTMLElement>(elementRef, itemRef, ref as Ref<HTMLElement>);\n const mouseEventRef = useRef(false);\n const labelRef = useRef<HTMLSpanElement>(null);\n const { removeItem, registerItem, scrollToItem } = useScrollContext();\n const [showTooltip, setShowTooltip] = useState(false);\n\n useLayoutEffect(() => {\n if (elementRef.current) {\n registerItem(elementRef);\n }\n\n return () => {\n removeItem(elementRef);\n };\n }, [registerItem, removeItem]);\n\n useLayoutEffect(() => {\n if (focused && elementRef.current) {\n elementRef.current.focus();\n }\n }, [focused]);\n\n useLayoutEffect(() => {\n if (selected && elementRef.current) {\n scrollToItem(elementRef);\n if (showTooltip && labelRef.current) {\n labelRef.current.dispatchEvent(new MouseEvent('mouseout', { bubbles: true, cancelable: true }));\n }\n }\n }, [selected, scrollToItem, showTooltip]);\n\n useLayoutEffect(() => {\n if (\n mode === 'secondary' &&\n labelRef.current !== null &&\n labelRef.current.scrollWidth > labelRef.current.offsetWidth\n ) {\n setShowTooltip(true);\n }\n }, [mode, setShowTooltip]);\n\n const handleFocus = useCallback(() => {\n if (!mouseEventRef.current) {\n scrollToItem(elementRef);\n }\n }, [scrollToItem]);\n\n const setMouseEventRef = useCallback(() => (mouseEventRef.current = true), []);\n\n const resetMouseEventRef = useCallback(() => (mouseEventRef.current = false), []);\n\n const handleWheel = useCallback(() => {\n if (labelRef?.current) {\n labelRef.current.dispatchEvent(new MouseEvent('mouseout', { bubbles: true, cancelable: true }));\n }\n }, []);\n\n if (hidden) {\n return null;\n }\n\n const handleClick: MouseEventHandler = (event) => {\n onSelect?.(id);\n onClick?.(event);\n };\n\n const content = (\n <span className={styles.tabContent} ref={activatorRef}>\n <span className={styles.tabLabel} ref={labelRef}>\n <Text Element=\"span\" typography={mode === 'primary' ? 'subtitle-1-semibold' : 'label-3-regular'}>\n {children}\n </Text>\n </span>\n {postfix && (\n <span className={styles.postfixWrapper} data-qa=\"tab-postfix\">\n <Text\n Element=\"span\"\n typography={mode === 'primary' ? 'subtitle-1-semibold' : 'subtitle-2-semibold'}\n >\n <span className={styles.postfix}>{postfix}</span>\n </Text>\n </span>\n )}\n </span>\n );\n\n const tabElement = (\n <Element\n {...buttonProps}\n type=\"button\"\n ref={elementRefCallback}\n role=\"tab\"\n data-qa={dataQa}\n onClick={handleClick}\n className={classnames(styles.tab, { [styles.tabSelected]: selected, [styles[`tab_${mode}`]]: !!mode })}\n aria-selected={selected}\n onFocus={handleFocus}\n onMouseDown={setMouseEventRef}\n onMouseLeave={resetMouseEventRef}\n onMouseUp={resetMouseEventRef}\n onWheel={showTooltip ? handleWheel : undefined}\n >\n {content}\n {showTooltip && (\n <TooltipHover activatorRef={activatorRef} alignment=\"center\" direction=\"top\">\n {children}\n </TooltipHover>\n )}\n </Element>\n );\n\n return (\n <div className={classnames(styles.tabWrapper, { [styles[`tab-wrapper_${mode}`]]: !!mode })}>\n {badge && mode === 'primary' ? (\n <ComponentWithBadge badge={<Badge size=\"extra-small\" />} offset={2}>\n {tabElement}\n </ComponentWithBadge>\n ) : (\n tabElement\n )}\n </div>\n );\n};\n\nconst TabComponent = forwardRef(TabForwardRefRenderFunc);\n\nexport const Tab = memo(TabComponent) as ComponentWithCustomElement<TabProps, 'button'>;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAcA,MAAM,uBAAuB,GAA8D,CACvF,EACI,OAAO,GAAG,QAAQ,EAClB,KAAK,GAAG,KAAK,EACb,QAAQ,EACR,SAAS,EAAE,M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magritte-types';
|
|
3
|
-
import {
|
|
3
|
+
import { TabProps } from './types';
|
|
4
4
|
export declare const Tab: ComponentWithCustomElement<TabProps, "button">;
|
package/Tab.js
CHANGED
|
@@ -4,9 +4,9 @@ import 'react';
|
|
|
4
4
|
import 'classnames';
|
|
5
5
|
import '@hh.ru/magritte-common-focus-visible';
|
|
6
6
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
7
|
-
import '@hh.ru/magritte-ui-
|
|
7
|
+
import '@hh.ru/magritte-ui-badge';
|
|
8
8
|
import '@hh.ru/magritte-ui-scrollable-container';
|
|
9
9
|
import '@hh.ru/magritte-ui-tooltip';
|
|
10
10
|
import '@hh.ru/magritte-ui-typography';
|
|
11
|
-
export { T as Tab } from './Tab-
|
|
11
|
+
export { T as Tab } from './Tab-443da8f8.js';
|
|
12
12
|
//# sourceMappingURL=Tab.js.map
|
package/Tabs.js
CHANGED
|
@@ -2,12 +2,12 @@ import './index.css';
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useRef, useCallback } from 'react';
|
|
4
4
|
import { ScrollableContainer } from '@hh.ru/magritte-ui-scrollable-container';
|
|
5
|
-
import { s as styles, T as Tab } from './Tab-
|
|
5
|
+
import { s as styles, T as Tab } from './Tab-443da8f8.js';
|
|
6
6
|
import { useTabs } from './useTabs.js';
|
|
7
7
|
import 'classnames';
|
|
8
8
|
import '@hh.ru/magritte-common-focus-visible';
|
|
9
9
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
10
|
-
import '@hh.ru/magritte-ui-
|
|
10
|
+
import '@hh.ru/magritte-ui-badge';
|
|
11
11
|
import '@hh.ru/magritte-ui-tooltip';
|
|
12
12
|
import '@hh.ru/magritte-ui-typography';
|
|
13
13
|
import '@hh.ru/magritte-common-keyboard';
|
package/index.css
CHANGED
|
@@ -1,65 +1,68 @@
|
|
|
1
1
|
:root{
|
|
2
|
-
--magritte-color-component-tabs-stroke-state-focused-accessible-v18-
|
|
3
|
-
--magritte-color-component-tabs-background-selected-v18-
|
|
4
|
-
--magritte-color-component-tabs-background-unselected-v18-
|
|
5
|
-
--magritte-color-component-tabs-background-state-unselected-pressed-v18-
|
|
6
|
-
--magritte-color-component-tabs-background-state-unselected-focused-v18-
|
|
7
|
-
--magritte-color-component-tabs-background-state-selected-focused-v18-
|
|
8
|
-
--magritte-color-component-tabs-background-state-unselected-hovered-v18-
|
|
9
|
-
--magritte-color-component-tabs-text-selected-v18-
|
|
10
|
-
--magritte-color-component-tabs-text-unselected-v18-
|
|
11
|
-
--magritte-color-component-tabs-
|
|
12
|
-
--magritte-color-component-tabs-
|
|
13
|
-
--magritte-color-component-secondary-tabs-stroke-state-focused-accessible-v18-
|
|
14
|
-
--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
15
|
-
--magritte-color-component-secondary-tabs-text-unselected-v18-
|
|
16
|
-
--magritte-color-component-secondary-tabs-indicator-selected-v18-
|
|
17
|
-
--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-
|
|
18
|
-
--magritte-color-component-secondary-tabs-text-state-unselected-pressed-v18-
|
|
19
|
-
--magritte-color-component-secondary-tabs-
|
|
20
|
-
--magritte-color-component-secondary-tabs-
|
|
2
|
+
--magritte-color-component-tabs-stroke-state-focused-accessible-v18-2-0:#0070ff7a;
|
|
3
|
+
--magritte-color-component-tabs-background-selected-v18-2-0:#000000;
|
|
4
|
+
--magritte-color-component-tabs-background-unselected-v18-2-0:#F1F4F9;
|
|
5
|
+
--magritte-color-component-tabs-background-state-unselected-pressed-v18-2-0:#F1F4F9;
|
|
6
|
+
--magritte-color-component-tabs-background-state-unselected-focused-v18-2-0:#F1F4F9;
|
|
7
|
+
--magritte-color-component-tabs-background-state-selected-focused-v18-2-0:#000000;
|
|
8
|
+
--magritte-color-component-tabs-background-state-unselected-hovered-v18-2-0:#DCE3EB;
|
|
9
|
+
--magritte-color-component-tabs-text-selected-v18-2-0:#ffffff;
|
|
10
|
+
--magritte-color-component-tabs-text-unselected-v18-2-0:#6a7885;
|
|
11
|
+
--magritte-color-component-tabs-postfix-text-selected-v18-2-0:#BBC8D4;
|
|
12
|
+
--magritte-color-component-tabs-postfix-text-unselected-v18-2-0:#AABBCA;
|
|
13
|
+
--magritte-color-component-secondary-tabs-stroke-state-focused-accessible-v18-2-0:#0070ff7a;
|
|
14
|
+
--magritte-color-component-secondary-tabs-text-selected-v18-2-0:#000000;
|
|
15
|
+
--magritte-color-component-secondary-tabs-text-unselected-v18-2-0:#768694;
|
|
16
|
+
--magritte-color-component-secondary-tabs-indicator-selected-v18-2-0:#000000;
|
|
17
|
+
--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-2-0:#000000;
|
|
18
|
+
--magritte-color-component-secondary-tabs-text-state-unselected-pressed-v18-2-0:#000000;
|
|
19
|
+
--magritte-color-component-secondary-tabs-postfix-text-selected-v18-2-0:#AABBCA;
|
|
20
|
+
--magritte-color-component-secondary-tabs-postfix-text-unselected-v18-2-0:#AABBCA;
|
|
21
21
|
}
|
|
22
22
|
:root{
|
|
23
|
-
--magritte-semantic-border-radius-form-v18-
|
|
24
|
-
--magritte-semantic-scale-pressed-v18-
|
|
25
|
-
--magritte-semantic-animation-ease-in-out-tiger-100-timing-function-v18-
|
|
26
|
-
--magritte-semantic-animation-ease-in-out-tiger-100-duration-v18-
|
|
27
|
-
--magritte-semantic-animation-ease-in-out-tiger-200-timing-function-v18-
|
|
28
|
-
--magritte-semantic-animation-ease-in-out-tiger-200-duration-v18-
|
|
29
|
-
--magritte-static-space-0-v18-
|
|
30
|
-
--magritte-static-space-200-v18-
|
|
31
|
-
--magritte-static-space-300-v18-
|
|
32
|
-
--magritte-static-space-400-v18-
|
|
33
|
-
--magritte-static-space-600-v18-
|
|
34
|
-
--magritte-core-border-radius-25-x-v18-
|
|
23
|
+
--magritte-semantic-border-radius-form-v18-2-0:12px;
|
|
24
|
+
--magritte-semantic-scale-pressed-v18-2-0:0.96;
|
|
25
|
+
--magritte-semantic-animation-ease-in-out-tiger-100-timing-function-v18-2-0:cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
26
|
+
--magritte-semantic-animation-ease-in-out-tiger-100-duration-v18-2-0:100ms;
|
|
27
|
+
--magritte-semantic-animation-ease-in-out-tiger-200-timing-function-v18-2-0:cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
28
|
+
--magritte-semantic-animation-ease-in-out-tiger-200-duration-v18-2-0:200ms;
|
|
29
|
+
--magritte-static-space-0-v18-2-0:0px;
|
|
30
|
+
--magritte-static-space-200-v18-2-0:8px;
|
|
31
|
+
--magritte-static-space-300-v18-2-0:12px;
|
|
32
|
+
--magritte-static-space-400-v18-2-0:16px;
|
|
33
|
+
--magritte-static-space-600-v18-2-0:24px;
|
|
34
|
+
--magritte-core-border-radius-25-x-v18-2-0:100px;
|
|
35
35
|
}
|
|
36
36
|
.magritte-night-theme{
|
|
37
|
-
--magritte-color-component-tabs-stroke-state-focused-accessible-v18-
|
|
38
|
-
--magritte-color-component-tabs-background-selected-v18-
|
|
39
|
-
--magritte-color-component-tabs-background-unselected-v18-
|
|
40
|
-
--magritte-color-component-tabs-background-state-unselected-pressed-v18-
|
|
41
|
-
--magritte-color-component-tabs-background-state-unselected-focused-v18-
|
|
42
|
-
--magritte-color-component-tabs-background-state-selected-focused-v18-
|
|
43
|
-
--magritte-color-component-tabs-background-state-unselected-hovered-v18-
|
|
44
|
-
--magritte-color-component-tabs-text-selected-v18-
|
|
45
|
-
--magritte-color-component-tabs-text-unselected-v18-
|
|
46
|
-
--magritte-color-component-tabs-
|
|
47
|
-
--magritte-color-component-tabs-
|
|
48
|
-
--magritte-color-component-secondary-tabs-stroke-state-focused-accessible-v18-
|
|
49
|
-
--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
50
|
-
--magritte-color-component-secondary-tabs-text-unselected-v18-
|
|
51
|
-
--magritte-color-component-secondary-tabs-indicator-selected-v18-
|
|
52
|
-
--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-
|
|
53
|
-
--magritte-color-component-secondary-tabs-text-state-unselected-pressed-v18-
|
|
54
|
-
--magritte-color-component-secondary-tabs-
|
|
55
|
-
--magritte-color-component-secondary-tabs-
|
|
56
|
-
}
|
|
57
|
-
.magritte-
|
|
37
|
+
--magritte-color-component-tabs-stroke-state-focused-accessible-v18-2-0:#0070ff7a;
|
|
38
|
+
--magritte-color-component-tabs-background-selected-v18-2-0:#ffffff;
|
|
39
|
+
--magritte-color-component-tabs-background-unselected-v18-2-0:#303030;
|
|
40
|
+
--magritte-color-component-tabs-background-state-unselected-pressed-v18-2-0:#303030;
|
|
41
|
+
--magritte-color-component-tabs-background-state-unselected-focused-v18-2-0:#303030;
|
|
42
|
+
--magritte-color-component-tabs-background-state-selected-focused-v18-2-0:#ffffff;
|
|
43
|
+
--magritte-color-component-tabs-background-state-unselected-hovered-v18-2-0:#3B3B3B;
|
|
44
|
+
--magritte-color-component-tabs-text-selected-v18-2-0:#000000;
|
|
45
|
+
--magritte-color-component-tabs-text-unselected-v18-2-0:#B9B9B9;
|
|
46
|
+
--magritte-color-component-tabs-postfix-text-selected-v18-2-0:#919191;
|
|
47
|
+
--magritte-color-component-tabs-postfix-text-unselected-v18-2-0:#919191;
|
|
48
|
+
--magritte-color-component-secondary-tabs-stroke-state-focused-accessible-v18-2-0:#0070ff7a;
|
|
49
|
+
--magritte-color-component-secondary-tabs-text-selected-v18-2-0:#ffffff;
|
|
50
|
+
--magritte-color-component-secondary-tabs-text-unselected-v18-2-0:#ABABAB;
|
|
51
|
+
--magritte-color-component-secondary-tabs-indicator-selected-v18-2-0:#ffffff;
|
|
52
|
+
--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-2-0:#ABABAB;
|
|
53
|
+
--magritte-color-component-secondary-tabs-text-state-unselected-pressed-v18-2-0:#ABABAB;
|
|
54
|
+
--magritte-color-component-secondary-tabs-postfix-text-selected-v18-2-0:#919191;
|
|
55
|
+
--magritte-color-component-secondary-tabs-postfix-text-unselected-v18-2-0:#919191;
|
|
56
|
+
}
|
|
57
|
+
.magritte-tabs___VcV8C_5-0-1{
|
|
58
58
|
display:flex;
|
|
59
59
|
align-items:center;
|
|
60
60
|
outline:none;
|
|
61
61
|
}
|
|
62
|
-
.magritte-
|
|
62
|
+
.magritte-tab-wrapper___9j9qk_5-0-1:last-of-type{
|
|
63
|
+
margin-right:var(--magritte-static-space-0-v18-2-0);
|
|
64
|
+
}
|
|
65
|
+
.magritte-tab___B0BeU_5-0-1{
|
|
63
66
|
box-sizing:border-box;
|
|
64
67
|
flex-shrink:0;
|
|
65
68
|
display:block;
|
|
@@ -67,180 +70,186 @@
|
|
|
67
70
|
border:0;
|
|
68
71
|
outline:0 solid transparent;
|
|
69
72
|
min-height:40px;
|
|
70
|
-
transition:all var(--magritte-semantic-animation-ease-in-out-tiger-100-duration-v18-
|
|
73
|
+
transition:all var(--magritte-semantic-animation-ease-in-out-tiger-100-duration-v18-2-0) var(--magritte-semantic-animation-ease-in-out-tiger-100-timing-function-v18-2-0);
|
|
71
74
|
}
|
|
72
|
-
.magritte-
|
|
73
|
-
transform:scale(var(--magritte-semantic-scale-pressed-v18-
|
|
74
|
-
transition:all var(--magritte-semantic-animation-ease-in-out-tiger-200-duration-v18-
|
|
75
|
+
.magritte-tab___B0BeU_5-0-1:active{
|
|
76
|
+
transform:scale(var(--magritte-semantic-scale-pressed-v18-2-0));
|
|
77
|
+
transition:all var(--magritte-semantic-animation-ease-in-out-tiger-200-duration-v18-2-0) var(--magritte-semantic-animation-ease-in-out-tiger-200-timing-function-v18-2-0);
|
|
75
78
|
}
|
|
76
|
-
.magritte-
|
|
79
|
+
.magritte-tab___B0BeU_5-0-1.magritte-tab_selected___w9PT2_5-0-1{
|
|
77
80
|
cursor:default;
|
|
78
81
|
}
|
|
79
|
-
.magritte-
|
|
82
|
+
.magritte-tab___B0BeU_5-0-1.magritte-tab_selected___w9PT2_5-0-1:active{
|
|
80
83
|
transform:none;
|
|
81
84
|
}
|
|
82
|
-
.magritte-
|
|
83
|
-
margin-right:var(--magritte-static-space-
|
|
85
|
+
.magritte-tab-wrapper_primary___yt3sT_5-0-1{
|
|
86
|
+
margin-right:var(--magritte-static-space-300-v18-2-0);
|
|
84
87
|
}
|
|
85
|
-
.magritte-
|
|
86
|
-
border-radius:var(--magritte-core-border-radius-25-x-v18-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-tabs-text-unselected-v18-1-2);
|
|
88
|
+
.magritte-tab_primary___3Of2H_5-0-1{
|
|
89
|
+
border-radius:var(--magritte-core-border-radius-25-x-v18-2-0);
|
|
90
|
+
background-color:var(--magritte-color-component-tabs-background-unselected-v18-2-0);
|
|
91
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-tabs-text-unselected-v18-2-0);
|
|
90
92
|
}
|
|
91
|
-
.magritte-
|
|
92
|
-
background-color:var(--magritte-color-component-tabs-background-state-unselected-pressed-v18-
|
|
93
|
+
.magritte-tab_primary___3Of2H_5-0-1:active{
|
|
94
|
+
background-color:var(--magritte-color-component-tabs-background-state-unselected-pressed-v18-2-0);
|
|
93
95
|
}
|
|
94
|
-
.magritte-
|
|
95
|
-
background-color:var(--magritte-color-component-tabs-background-state-unselected-focused-v18-
|
|
96
|
-
outline:4px solid var(--magritte-color-component-tabs-stroke-state-focused-accessible-v18-
|
|
96
|
+
.magritte-tab_primary___3Of2H_5-0-1.focus-visible{
|
|
97
|
+
background-color:var(--magritte-color-component-tabs-background-state-unselected-focused-v18-2-0);
|
|
98
|
+
outline:4px solid var(--magritte-color-component-tabs-stroke-state-focused-accessible-v18-2-0);
|
|
97
99
|
}
|
|
98
|
-
.magritte-
|
|
99
|
-
background-color:var(--magritte-color-component-tabs-background-selected-v18-
|
|
100
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-tabs-text-selected-v18-
|
|
100
|
+
.magritte-tab_primary___3Of2H_5-0-1.magritte-tab_selected___w9PT2_5-0-1{
|
|
101
|
+
background-color:var(--magritte-color-component-tabs-background-selected-v18-2-0);
|
|
102
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-tabs-text-selected-v18-2-0);
|
|
101
103
|
}
|
|
102
|
-
.magritte-
|
|
103
|
-
color:var(--magritte-color-component-tabs-text-selected-v18-
|
|
104
|
+
.magritte-tab_primary___3Of2H_5-0-1.magritte-tab_selected___w9PT2_5-0-1 .magritte-tab-label___nFmge_5-0-1{
|
|
105
|
+
color:var(--magritte-color-component-tabs-text-selected-v18-2-0);
|
|
104
106
|
}
|
|
105
|
-
.magritte-
|
|
106
|
-
|
|
107
|
+
.magritte-tab_primary___3Of2H_5-0-1.magritte-tab_selected___w9PT2_5-0-1 .magritte-postfix___30ZxD_5-0-1{
|
|
108
|
+
color:var(--magritte-color-component-tabs-postfix-text-selected-v18-2-0);
|
|
107
109
|
}
|
|
108
|
-
.magritte-
|
|
109
|
-
background-color:var(--magritte-color-component-tabs-background-selected-v18-
|
|
110
|
+
.magritte-tab_primary___3Of2H_5-0-1.magritte-tab_selected___w9PT2_5-0-1:active{
|
|
111
|
+
background-color:var(--magritte-color-component-tabs-background-selected-v18-2-0);
|
|
110
112
|
}
|
|
111
|
-
.magritte-
|
|
112
|
-
background-color:var(--magritte-color-component-tabs-background-state-selected-focused-v18-
|
|
113
|
-
outline:4px solid var(--magritte-color-component-tabs-stroke-state-focused-accessible-v18-
|
|
113
|
+
.magritte-tab_primary___3Of2H_5-0-1.magritte-tab_selected___w9PT2_5-0-1.focus-visible{
|
|
114
|
+
background-color:var(--magritte-color-component-tabs-background-state-selected-focused-v18-2-0);
|
|
115
|
+
outline:4px solid var(--magritte-color-component-tabs-stroke-state-focused-accessible-v18-2-0);
|
|
114
116
|
}
|
|
115
117
|
@media (min-width: 1020px){
|
|
116
|
-
body.magritte-old-layout .magritte-
|
|
117
|
-
background-color:var(--magritte-color-component-tabs-background-selected-v18-
|
|
118
|
+
body.magritte-old-layout .magritte-tab_primary___3Of2H_5-0-1.magritte-tab_selected___w9PT2_5-0-1:hover:not(:active){
|
|
119
|
+
background-color:var(--magritte-color-component-tabs-background-selected-v18-2-0);
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
@media (min-width: 1024px){
|
|
121
|
-
body:not(.magritte-old-layout) .magritte-
|
|
122
|
-
background-color:var(--magritte-color-component-tabs-background-selected-v18-
|
|
123
|
+
body:not(.magritte-old-layout) .magritte-tab_primary___3Of2H_5-0-1.magritte-tab_selected___w9PT2_5-0-1:hover:not(:active){
|
|
124
|
+
background-color:var(--magritte-color-component-tabs-background-selected-v18-2-0);
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
|
-
.magritte-
|
|
126
|
-
padding:var(--magritte-static-space-200-v18-
|
|
127
|
+
.magritte-tab_primary___3Of2H_5-0-1 .magritte-tab-content___onvTJ_5-0-1{
|
|
128
|
+
padding:var(--magritte-static-space-200-v18-2-0) var(--magritte-static-space-400-v18-2-0);
|
|
127
129
|
}
|
|
128
|
-
.magritte-
|
|
129
|
-
color:var(--magritte-color-component-tabs-text-unselected-v18-
|
|
130
|
+
.magritte-tab_primary___3Of2H_5-0-1 .magritte-tab-label___nFmge_5-0-1{
|
|
131
|
+
color:var(--magritte-color-component-tabs-text-unselected-v18-2-0);
|
|
130
132
|
}
|
|
131
|
-
.magritte-
|
|
132
|
-
|
|
133
|
+
.magritte-tab_primary___3Of2H_5-0-1 .magritte-postfix___30ZxD_5-0-1{
|
|
134
|
+
color:var(--magritte-color-component-tabs-postfix-text-unselected-v18-2-0);
|
|
133
135
|
}
|
|
134
136
|
@media (min-width: 1020px){
|
|
135
|
-
body.magritte-old-layout .magritte-
|
|
136
|
-
background-color:var(--magritte-color-component-tabs-background-state-unselected-hovered-v18-
|
|
137
|
+
body.magritte-old-layout .magritte-tab_primary___3Of2H_5-0-1:hover:not(:active){
|
|
138
|
+
background-color:var(--magritte-color-component-tabs-background-state-unselected-hovered-v18-2-0);
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
@media (min-width: 1024px){
|
|
140
|
-
body:not(.magritte-old-layout) .magritte-
|
|
141
|
-
background-color:var(--magritte-color-component-tabs-background-state-unselected-hovered-v18-
|
|
142
|
+
body:not(.magritte-old-layout) .magritte-tab_primary___3Of2H_5-0-1:hover:not(:active){
|
|
143
|
+
background-color:var(--magritte-color-component-tabs-background-state-unselected-hovered-v18-2-0);
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
|
-
.magritte-
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
.magritte-tab-wrapper_secondary___avLln_5-0-1{
|
|
147
|
+
margin-right:var(--magritte-static-space-600-v18-2-0);
|
|
148
|
+
}
|
|
149
|
+
.magritte-tab_secondary___-00LL_5-0-1{
|
|
150
|
+
border-radius:var(--magritte-semantic-border-radius-form-v18-2-0);
|
|
147
151
|
max-width:288px;
|
|
148
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-unselected-v18-
|
|
152
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-unselected-v18-2-0);
|
|
149
153
|
}
|
|
150
|
-
.magritte-tab_secondary___-
|
|
151
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-state-unselected-pressed-v18-
|
|
154
|
+
.magritte-tab_secondary___-00LL_5-0-1:active{
|
|
155
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-state-unselected-pressed-v18-2-0);
|
|
152
156
|
}
|
|
153
|
-
.magritte-tab_secondary___-
|
|
154
|
-
color:var(--magritte-color-component-secondary-tabs-text-state-unselected-pressed-v18-
|
|
157
|
+
.magritte-tab_secondary___-00LL_5-0-1:active .magritte-tab-label___nFmge_5-0-1{
|
|
158
|
+
color:var(--magritte-color-component-secondary-tabs-text-state-unselected-pressed-v18-2-0);
|
|
155
159
|
}
|
|
156
|
-
.magritte-tab_secondary___-
|
|
157
|
-
outline:4px solid var(--magritte-color-component-secondary-tabs-stroke-state-focused-accessible-v18-
|
|
160
|
+
.magritte-tab_secondary___-00LL_5-0-1.focus-visible{
|
|
161
|
+
outline:4px solid var(--magritte-color-component-secondary-tabs-stroke-state-focused-accessible-v18-2-0);
|
|
158
162
|
}
|
|
159
|
-
.magritte-tab_secondary___-
|
|
160
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
163
|
+
.magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1{
|
|
164
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-selected-v18-2-0);
|
|
161
165
|
}
|
|
162
|
-
.magritte-tab_secondary___-
|
|
163
|
-
color:var(--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
166
|
+
.magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1 .magritte-tab-label___nFmge_5-0-1{
|
|
167
|
+
color:var(--magritte-color-component-secondary-tabs-text-selected-v18-2-0);
|
|
164
168
|
}
|
|
165
|
-
.magritte-tab_secondary___-
|
|
166
|
-
|
|
169
|
+
.magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1 .magritte-postfix___30ZxD_5-0-1{
|
|
170
|
+
color:var(--magritte-color-component-secondary-tabs-postfix-text-selected-v18-2-0);
|
|
167
171
|
}
|
|
168
|
-
.magritte-tab_secondary___-
|
|
169
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
172
|
+
.magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1:active{
|
|
173
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-selected-v18-2-0);
|
|
170
174
|
}
|
|
171
|
-
.magritte-tab_secondary___-
|
|
172
|
-
color:var(--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
175
|
+
.magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1:active .magritte-tab-label___nFmge_5-0-1{
|
|
176
|
+
color:var(--magritte-color-component-secondary-tabs-text-selected-v18-2-0);
|
|
173
177
|
}
|
|
174
|
-
.magritte-tab_secondary___-
|
|
175
|
-
outline:4px solid var(--magritte-color-component-secondary-tabs-stroke-state-focused-accessible-v18-
|
|
178
|
+
.magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1.focus-visible{
|
|
179
|
+
outline:4px solid var(--magritte-color-component-secondary-tabs-stroke-state-focused-accessible-v18-2-0);
|
|
176
180
|
}
|
|
177
181
|
@media (min-width: 1020px){
|
|
178
|
-
body.magritte-old-layout .magritte-tab_secondary___-
|
|
179
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
182
|
+
body.magritte-old-layout .magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1:hover:not(:active){
|
|
183
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-selected-v18-2-0);
|
|
180
184
|
}
|
|
181
|
-
body.magritte-old-layout .magritte-tab_secondary___-
|
|
182
|
-
color:var(--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
185
|
+
body.magritte-old-layout .magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1:hover:not(:active) .magritte-tab-label___nFmge_5-0-1{
|
|
186
|
+
color:var(--magritte-color-component-secondary-tabs-text-selected-v18-2-0);
|
|
183
187
|
}
|
|
184
188
|
}
|
|
185
189
|
@media (min-width: 1024px){
|
|
186
|
-
body:not(.magritte-old-layout) .magritte-tab_secondary___-
|
|
187
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
190
|
+
body:not(.magritte-old-layout) .magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1:hover:not(:active){
|
|
191
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-selected-v18-2-0);
|
|
188
192
|
}
|
|
189
|
-
body:not(.magritte-old-layout) .magritte-tab_secondary___-
|
|
190
|
-
color:var(--magritte-color-component-secondary-tabs-text-selected-v18-
|
|
193
|
+
body:not(.magritte-old-layout) .magritte-tab_secondary___-00LL_5-0-1.magritte-tab_selected___w9PT2_5-0-1:hover:not(:active) .magritte-tab-label___nFmge_5-0-1{
|
|
194
|
+
color:var(--magritte-color-component-secondary-tabs-text-selected-v18-2-0);
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
|
-
.magritte-tab_secondary___-
|
|
194
|
-
padding:var(--magritte-static-space-400-v18-
|
|
197
|
+
.magritte-tab_secondary___-00LL_5-0-1 .magritte-tab-content___onvTJ_5-0-1{
|
|
198
|
+
padding:var(--magritte-static-space-400-v18-2-0) 0;
|
|
195
199
|
}
|
|
196
|
-
.magritte-tab_secondary___-
|
|
197
|
-
color:var(--magritte-color-component-secondary-tabs-text-unselected-v18-
|
|
200
|
+
.magritte-tab_secondary___-00LL_5-0-1 .magritte-tab-label___nFmge_5-0-1{
|
|
201
|
+
color:var(--magritte-color-component-secondary-tabs-text-unselected-v18-2-0);
|
|
198
202
|
}
|
|
199
|
-
.magritte-tab_secondary___-
|
|
200
|
-
|
|
203
|
+
.magritte-tab_secondary___-00LL_5-0-1 .magritte-postfix___30ZxD_5-0-1{
|
|
204
|
+
color:var(--magritte-color-component-secondary-tabs-postfix-text-unselected-v18-2-0);
|
|
201
205
|
}
|
|
202
206
|
@media (min-width: 1020px){
|
|
203
|
-
body.magritte-old-layout .magritte-tab_secondary___-
|
|
204
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-
|
|
207
|
+
body.magritte-old-layout .magritte-tab_secondary___-00LL_5-0-1:hover:not(:active){
|
|
208
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-2-0);
|
|
205
209
|
}
|
|
206
|
-
body.magritte-old-layout .magritte-tab_secondary___-
|
|
207
|
-
color:var(--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-
|
|
210
|
+
body.magritte-old-layout .magritte-tab_secondary___-00LL_5-0-1:hover:not(:active) .magritte-tab-label___nFmge_5-0-1{
|
|
211
|
+
color:var(--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-2-0);
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
214
|
@media (min-width: 1024px){
|
|
211
|
-
body:not(.magritte-old-layout) .magritte-tab_secondary___-
|
|
212
|
-
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-
|
|
215
|
+
body:not(.magritte-old-layout) .magritte-tab_secondary___-00LL_5-0-1:hover:not(:active){
|
|
216
|
+
--magritte-ui-text-color-override:var(--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-2-0);
|
|
213
217
|
}
|
|
214
|
-
body:not(.magritte-old-layout) .magritte-tab_secondary___-
|
|
215
|
-
color:var(--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-
|
|
218
|
+
body:not(.magritte-old-layout) .magritte-tab_secondary___-00LL_5-0-1:hover:not(:active) .magritte-tab-label___nFmge_5-0-1{
|
|
219
|
+
color:var(--magritte-color-component-secondary-tabs-text-state-unselected-hovered-v18-2-0);
|
|
216
220
|
}
|
|
217
221
|
}
|
|
218
|
-
.magritte-tab-
|
|
222
|
+
.magritte-tab-content___onvTJ_5-0-1{
|
|
219
223
|
display:flex;
|
|
220
224
|
align-items:center;
|
|
221
225
|
height:24px;
|
|
222
226
|
}
|
|
223
|
-
.magritte-tab-
|
|
227
|
+
.magritte-tab-label___nFmge_5-0-1{
|
|
224
228
|
flex:0 1 auto;
|
|
225
229
|
min-width:0;
|
|
226
230
|
overflow:hidden;
|
|
227
231
|
text-overflow:ellipsis;
|
|
228
232
|
white-space:pre;
|
|
229
233
|
}
|
|
230
|
-
.magritte-
|
|
234
|
+
.magritte-postfix-wrapper___1dORq_5-0-1{
|
|
231
235
|
flex:0 0 auto;
|
|
232
|
-
|
|
236
|
+
min-width:0;
|
|
237
|
+
max-width:100%;
|
|
238
|
+
margin-left:var(--magritte-static-space-200-v18-2-0);
|
|
239
|
+
overflow:hidden;
|
|
240
|
+
text-overflow:ellipsis;
|
|
241
|
+
white-space:pre;
|
|
233
242
|
}
|
|
234
|
-
.magritte-indicator-
|
|
243
|
+
.magritte-indicator-wrapper___Q68i7_5-0-1{
|
|
235
244
|
margin-top:-4px;
|
|
236
245
|
}
|
|
237
|
-
.magritte-
|
|
246
|
+
.magritte-indicator___irp4W_5-0-1{
|
|
238
247
|
position:relative;
|
|
239
|
-
background-color:var(--magritte-color-component-secondary-tabs-indicator-selected-v18-
|
|
248
|
+
background-color:var(--magritte-color-component-secondary-tabs-indicator-selected-v18-2-0);
|
|
240
249
|
border-radius:4px 4px 0 0;
|
|
241
250
|
height:4px;
|
|
242
251
|
width:0;
|
|
243
252
|
}
|
|
244
|
-
.magritte-
|
|
245
|
-
transition:all var(--magritte-semantic-animation-ease-in-out-tiger-200-duration-v18-
|
|
253
|
+
.magritte-animate___5GxTP_5-0-1{
|
|
254
|
+
transition:all var(--magritte-semantic-animation-ease-in-out-tiger-200-duration-v18-2-0) var(--magritte-semantic-animation-ease-in-out-tiger-200-timing-function-v18-2-0);
|
|
246
255
|
}
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
export * from '@hh.ru/magritte-ui-theme-provider';
|
|
3
3
|
export { Tabs } from './Tabs.js';
|
|
4
|
-
export { T as Tab } from './Tab-
|
|
4
|
+
export { T as Tab } from './Tab-443da8f8.js';
|
|
5
5
|
import 'react/jsx-runtime';
|
|
6
6
|
import 'react';
|
|
7
7
|
import '@hh.ru/magritte-ui-scrollable-container';
|
|
@@ -11,7 +11,7 @@ import '@hh.ru/magritte-ui-breakpoint';
|
|
|
11
11
|
import 'classnames';
|
|
12
12
|
import '@hh.ru/magritte-common-focus-visible';
|
|
13
13
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
14
|
-
import '@hh.ru/magritte-ui-
|
|
14
|
+
import '@hh.ru/magritte-ui-badge';
|
|
15
15
|
import '@hh.ru/magritte-ui-tooltip';
|
|
16
16
|
import '@hh.ru/magritte-ui-typography';
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-tabs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"@hh.ru/magritte-common-focus-visible": "0.1.3",
|
|
23
23
|
"@hh.ru/magritte-common-keyboard": "4.0.0",
|
|
24
24
|
"@hh.ru/magritte-common-use-multiple-refs": "1.1.2",
|
|
25
|
-
"@hh.ru/magritte-design-tokens": "18.
|
|
25
|
+
"@hh.ru/magritte-design-tokens": "18.2.0",
|
|
26
26
|
"@hh.ru/magritte-types": "4.0.1",
|
|
27
|
+
"@hh.ru/magritte-ui-badge": "2.1.13",
|
|
27
28
|
"@hh.ru/magritte-ui-breakpoint": "4.0.2",
|
|
28
|
-
"@hh.ru/magritte-ui-button": "
|
|
29
|
-
"@hh.ru/magritte-ui-
|
|
30
|
-
"@hh.ru/magritte-ui-
|
|
31
|
-
"@hh.ru/magritte-ui-
|
|
32
|
-
"@hh.ru/magritte-ui-
|
|
33
|
-
"@hh.ru/magritte-ui-typography": "3.0.10"
|
|
29
|
+
"@hh.ru/magritte-ui-button": "5.0.1",
|
|
30
|
+
"@hh.ru/magritte-ui-scrollable-container": "4.3.16",
|
|
31
|
+
"@hh.ru/magritte-ui-theme-provider": "1.1.24",
|
|
32
|
+
"@hh.ru/magritte-ui-tooltip": "6.1.7",
|
|
33
|
+
"@hh.ru/magritte-ui-typography": "3.0.11"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"classnames": ">=2.3.2",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "4480faadc19af08673481a84a62f77d081e9be2e"
|
|
43
43
|
}
|
package/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface TabProps extends PropsWithRef<PropsWithChildren> {
|
|
|
5
5
|
Element?: 'button';
|
|
6
6
|
id: TabId;
|
|
7
7
|
selected?: boolean;
|
|
8
|
-
|
|
8
|
+
postfix?: string;
|
|
9
9
|
onClick?: MouseEventHandler;
|
|
10
10
|
onSelect?: (itemId: TabId) => void;
|
|
11
11
|
hidden?: boolean;
|
|
@@ -13,6 +13,7 @@ export interface TabProps extends PropsWithRef<PropsWithChildren> {
|
|
|
13
13
|
focused?: boolean;
|
|
14
14
|
mode?: 'primary' | 'secondary';
|
|
15
15
|
itemRef?: Ref<HTMLElement>;
|
|
16
|
+
badge?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export interface TabsProps {
|
|
18
19
|
children: ReactElement<TabProps>[];
|
package/useTabs.js
CHANGED
|
@@ -2,12 +2,12 @@ import './index.css';
|
|
|
2
2
|
import { useState, useRef, useMemo, useCallback, Children, useEffect, isValidElement } from 'react';
|
|
3
3
|
import { keyboardMatch, keyboardKeys, keyboardMatches } from '@hh.ru/magritte-common-keyboard';
|
|
4
4
|
import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
|
|
5
|
-
import { s as styles, T as Tab } from './Tab-
|
|
5
|
+
import { s as styles, T as Tab } from './Tab-443da8f8.js';
|
|
6
6
|
import 'react/jsx-runtime';
|
|
7
7
|
import 'classnames';
|
|
8
8
|
import '@hh.ru/magritte-common-focus-visible';
|
|
9
9
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
10
|
-
import '@hh.ru/magritte-ui-
|
|
10
|
+
import '@hh.ru/magritte-ui-badge';
|
|
11
11
|
import '@hh.ru/magritte-ui-scrollable-container';
|
|
12
12
|
import '@hh.ru/magritte-ui-tooltip';
|
|
13
13
|
import '@hh.ru/magritte-ui-typography';
|
package/Tab-90e0c9a2.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { forwardRef, memo, useRef, useState, useLayoutEffect, useCallback } from 'react';
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
import '@hh.ru/magritte-common-focus-visible';
|
|
6
|
-
import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
|
|
7
|
-
import { Counter } from '@hh.ru/magritte-ui-counter';
|
|
8
|
-
import { useScrollContext } from '@hh.ru/magritte-ui-scrollable-container';
|
|
9
|
-
import { TooltipHover } from '@hh.ru/magritte-ui-tooltip';
|
|
10
|
-
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
11
|
-
|
|
12
|
-
var styles = {"tabs":"magritte-tabs___VcV8C_4-0-3","tab":"magritte-tab___B0BeU_4-0-3","tab_selected":"magritte-tab_selected___w9PT2_4-0-3","tabSelected":"magritte-tab_selected___w9PT2_4-0-3","tab_primary":"magritte-tab_primary___3Of2H_4-0-3","tabPrimary":"magritte-tab_primary___3Of2H_4-0-3","tab-text":"magritte-tab-text___ql-Rb_4-0-3","tabText":"magritte-tab-text___ql-Rb_4-0-3","tab-counter":"magritte-tab-counter___esy3g_4-0-3","tabCounter":"magritte-tab-counter___esy3g_4-0-3","tab-content":"magritte-tab-content___onvTJ_4-0-3","tabContent":"magritte-tab-content___onvTJ_4-0-3","tab_secondary":"magritte-tab_secondary___-00LL_4-0-3","tabSecondary":"magritte-tab_secondary___-00LL_4-0-3","indicator-wrapper":"magritte-indicator-wrapper___Q68i7_4-0-3","indicatorWrapper":"magritte-indicator-wrapper___Q68i7_4-0-3","indicator":"magritte-indicator___irp4W_4-0-3","animate":"magritte-animate___5GxTP_4-0-3"};
|
|
13
|
-
|
|
14
|
-
const TabForwardRefRenderFunc = ({ Element = 'button', id, children, counter, selected, onClick, onSelect, hidden, 'data-qa': dataQa = 'tab', focused, mode = 'primary', itemRef, ...buttonProps }, ref) => {
|
|
15
|
-
const activatorRef = useRef(null);
|
|
16
|
-
const elementRef = useRef(null);
|
|
17
|
-
const elementRefCallback = useMultipleRefs(elementRef, itemRef, ref);
|
|
18
|
-
const mouseEventRef = useRef(false);
|
|
19
|
-
const textRef = useRef(null);
|
|
20
|
-
const { removeItem, registerItem, scrollToItem } = useScrollContext();
|
|
21
|
-
const [showTooltip, setShowTooltip] = useState(false);
|
|
22
|
-
useLayoutEffect(() => {
|
|
23
|
-
if (elementRef.current) {
|
|
24
|
-
registerItem(elementRef);
|
|
25
|
-
}
|
|
26
|
-
return () => {
|
|
27
|
-
removeItem(elementRef);
|
|
28
|
-
};
|
|
29
|
-
}, [registerItem, removeItem]);
|
|
30
|
-
useLayoutEffect(() => {
|
|
31
|
-
if (focused && elementRef.current) {
|
|
32
|
-
elementRef.current.focus();
|
|
33
|
-
}
|
|
34
|
-
}, [focused]);
|
|
35
|
-
useLayoutEffect(() => {
|
|
36
|
-
if (selected && elementRef.current) {
|
|
37
|
-
scrollToItem(elementRef);
|
|
38
|
-
if (showTooltip && textRef.current) {
|
|
39
|
-
textRef.current.dispatchEvent(new MouseEvent('mouseout', { bubbles: true, cancelable: true }));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}, [selected, scrollToItem, showTooltip]);
|
|
43
|
-
useLayoutEffect(() => {
|
|
44
|
-
if (mode === 'secondary' &&
|
|
45
|
-
textRef.current !== null &&
|
|
46
|
-
textRef.current.scrollWidth > textRef.current.offsetWidth) {
|
|
47
|
-
setShowTooltip(true);
|
|
48
|
-
}
|
|
49
|
-
}, [mode, setShowTooltip]);
|
|
50
|
-
const handleFocus = useCallback(() => {
|
|
51
|
-
if (!mouseEventRef.current) {
|
|
52
|
-
scrollToItem(elementRef);
|
|
53
|
-
}
|
|
54
|
-
}, [scrollToItem]);
|
|
55
|
-
const setMouseEventRef = useCallback(() => (mouseEventRef.current = true), []);
|
|
56
|
-
const resetMouseEventRef = useCallback(() => (mouseEventRef.current = false), []);
|
|
57
|
-
const handleWheel = useCallback(() => {
|
|
58
|
-
if (textRef?.current) {
|
|
59
|
-
textRef.current.dispatchEvent(new MouseEvent('mouseout', { bubbles: true, cancelable: true }));
|
|
60
|
-
}
|
|
61
|
-
}, []);
|
|
62
|
-
if (hidden) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
const handleClick = (event) => {
|
|
66
|
-
onSelect?.(id);
|
|
67
|
-
onClick?.(event);
|
|
68
|
-
};
|
|
69
|
-
const content = (jsxs("span", { className: styles.tabContent, ref: activatorRef, children: [jsx("span", { className: styles.tabText, ref: textRef, children: jsx(Text, { Element: "span", typography: mode === 'primary' ? 'subtitle-1-semibold' : 'label-2-regular', children: children }) }), counter && (jsx("span", { className: styles.tabCounter, "data-qa": "tab-counter", children: jsx(Counter, { mode: "secondary", label: counter }) }))] }));
|
|
70
|
-
return (jsxs(Element, { ...buttonProps, type: "button", ref: elementRefCallback, role: "tab", "data-qa": dataQa, onClick: handleClick, className: classnames(styles.tab, {
|
|
71
|
-
[styles.tabSelected]: selected,
|
|
72
|
-
[styles[`tab_${mode}`]]: !!mode,
|
|
73
|
-
}), "aria-selected": selected, onFocus: handleFocus, onMouseDown: setMouseEventRef, onMouseLeave: resetMouseEventRef, onMouseUp: resetMouseEventRef, onWheel: showTooltip ? handleWheel : undefined, children: [content, showTooltip && (jsx(TooltipHover, { activatorRef: activatorRef, alignment: "center", direction: "top", children: children }))] }));
|
|
74
|
-
};
|
|
75
|
-
const TabComponent = forwardRef(TabForwardRefRenderFunc);
|
|
76
|
-
const Tab = memo(TabComponent);
|
|
77
|
-
|
|
78
|
-
export { Tab as T, styles as s };
|
|
79
|
-
//# sourceMappingURL=Tab-90e0c9a2.js.map
|
package/Tab-90e0c9a2.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Tab-90e0c9a2.js","sources":["../src/Tab.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, useCallback, useLayoutEffect, useRef, useState, MouseEventHandler } from 'react';\nimport classnames from 'classnames';\n\nimport '@hh.ru/magritte-common-focus-visible';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { ComponentWithCustomElement, ForwardRefRenderFuncWithCustomElement } from '@hh.ru/magritte-types';\nimport { Counter } from '@hh.ru/magritte-ui-counter';\nimport { useScrollContext } from '@hh.ru/magritte-ui-scrollable-container';\nimport { type TabProps } from '@hh.ru/magritte-ui-tabs/types';\nimport { TooltipHover } from '@hh.ru/magritte-ui-tooltip';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './tabs.less';\n\nconst TabForwardRefRenderFunc: ForwardRefRenderFuncWithCustomElement<TabProps, 'button'> = (\n {\n Element = 'button',\n id,\n children,\n counter,\n selected,\n onClick,\n onSelect,\n hidden,\n 'data-qa': dataQa = 'tab',\n focused,\n mode = 'primary',\n itemRef,\n ...buttonProps\n },\n ref\n) => {\n const activatorRef = useRef<HTMLSpanElement>(null);\n const elementRef = useRef<HTMLElement>(null);\n const elementRefCallback = useMultipleRefs<HTMLElement>(elementRef, itemRef, ref as Ref<HTMLElement>);\n const mouseEventRef = useRef(false);\n const textRef = useRef<HTMLSpanElement>(null);\n const { removeItem, registerItem, scrollToItem } = useScrollContext();\n const [showTooltip, setShowTooltip] = useState(false);\n\n useLayoutEffect(() => {\n if (elementRef.current) {\n registerItem(elementRef);\n }\n\n return () => {\n removeItem(elementRef);\n };\n }, [registerItem, removeItem]);\n\n useLayoutEffect(() => {\n if (focused && elementRef.current) {\n elementRef.current.focus();\n }\n }, [focused]);\n\n useLayoutEffect(() => {\n if (selected && elementRef.current) {\n scrollToItem(elementRef);\n if (showTooltip && textRef.current) {\n textRef.current.dispatchEvent(new MouseEvent('mouseout', { bubbles: true, cancelable: true }));\n }\n }\n }, [selected, scrollToItem, showTooltip]);\n\n useLayoutEffect(() => {\n if (\n mode === 'secondary' &&\n textRef.current !== null &&\n textRef.current.scrollWidth > textRef.current.offsetWidth\n ) {\n setShowTooltip(true);\n }\n }, [mode, setShowTooltip]);\n\n const handleFocus = useCallback(() => {\n if (!mouseEventRef.current) {\n scrollToItem(elementRef);\n }\n }, [scrollToItem]);\n\n const setMouseEventRef = useCallback(() => (mouseEventRef.current = true), []);\n\n const resetMouseEventRef = useCallback(() => (mouseEventRef.current = false), []);\n\n const handleWheel = useCallback(() => {\n if (textRef?.current) {\n textRef.current.dispatchEvent(new MouseEvent('mouseout', { bubbles: true, cancelable: true }));\n }\n }, []);\n\n if (hidden) {\n return null;\n }\n\n const handleClick: MouseEventHandler = (event) => {\n onSelect?.(id);\n onClick?.(event);\n };\n\n const content = (\n <span className={styles.tabContent} ref={activatorRef}>\n <span className={styles.tabText} ref={textRef}>\n <Text Element=\"span\" typography={mode === 'primary' ? 'subtitle-1-semibold' : 'label-2-regular'}>\n {children}\n </Text>\n </span>\n {counter && (\n <span className={styles.tabCounter} data-qa=\"tab-counter\">\n <Counter mode=\"secondary\" label={counter} />\n </span>\n )}\n </span>\n );\n\n return (\n <Element\n {...buttonProps}\n type=\"button\"\n ref={elementRefCallback}\n role=\"tab\"\n data-qa={dataQa}\n onClick={handleClick}\n className={classnames(styles.tab, {\n [styles.tabSelected]: selected,\n [styles[`tab_${mode}`]]: !!mode,\n })}\n aria-selected={selected}\n onFocus={handleFocus}\n onMouseDown={setMouseEventRef}\n onMouseLeave={resetMouseEventRef}\n onMouseUp={resetMouseEventRef}\n onWheel={showTooltip ? handleWheel : undefined}\n >\n {content}\n {showTooltip && (\n <TooltipHover activatorRef={activatorRef} alignment=\"center\" direction=\"top\">\n {children}\n </TooltipHover>\n )}\n </Element>\n );\n};\n\nconst TabComponent = forwardRef(TabForwardRefRenderFunc);\n\nexport const Tab = memo(TabComponent) as ComponentWithCustomElement<TabProps, 'button'>;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;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