@salutejs/plasma-new-hope 0.85.0-dev.0 → 0.86.0-canary.1220.9257117448.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Tabs/ui/TabItem/TabItem.js +7 -6
- package/cjs/components/Tabs/ui/TabItem/TabItem.js.map +1 -1
- package/cjs/components/Tabs/ui/Tabs/Tabs.css +4 -4
- package/cjs/components/Tabs/ui/Tabs/Tabs.js +3 -2
- package/cjs/components/Tabs/ui/Tabs/Tabs.js.map +1 -1
- package/cjs/components/Tabs/ui/Tabs/Tabs.styles.js +1 -1
- package/cjs/components/Tabs/ui/Tabs/Tabs.styles.js.map +1 -1
- package/cjs/components/Tabs/ui/Tabs/{Tabs.styles_1mml8ws.css → Tabs.styles_194je23.css} +1 -1
- package/cjs/index.css +4 -4
- package/es/components/Tabs/ui/TabItem/TabItem.js +7 -6
- package/es/components/Tabs/ui/TabItem/TabItem.js.map +1 -1
- package/es/components/Tabs/ui/Tabs/Tabs.css +4 -4
- package/es/components/Tabs/ui/Tabs/Tabs.js +3 -2
- package/es/components/Tabs/ui/Tabs/Tabs.js.map +1 -1
- package/es/components/Tabs/ui/Tabs/Tabs.styles.js +1 -1
- package/es/components/Tabs/ui/Tabs/Tabs.styles.js.map +1 -1
- package/es/components/Tabs/ui/Tabs/{Tabs.styles_1mml8ws.css → Tabs.styles_194je23.css} +1 -1
- package/es/index.css +4 -4
- package/package.json +2 -2
- package/styled-components/cjs/components/Segment/Segment.template-doc.mdx +5 -3
- package/styled-components/cjs/components/Tabs/Tabs.template-doc.mdx +36 -32
- package/styled-components/cjs/components/Tabs/ui/TabItem/TabItem.js +7 -6
- package/styled-components/cjs/components/Tabs/ui/Tabs/Tabs.js +3 -2
- package/styled-components/cjs/components/Tabs/ui/Tabs/Tabs.styles.js +1 -1
- package/styled-components/es/components/Segment/Segment.template-doc.mdx +5 -3
- package/styled-components/es/components/Tabs/Tabs.template-doc.mdx +36 -32
- package/styled-components/es/components/Tabs/ui/TabItem/TabItem.js +7 -6
- package/styled-components/es/components/Tabs/ui/Tabs/Tabs.js +3 -2
- package/styled-components/es/components/Tabs/ui/Tabs/Tabs.styles.js +1 -1
- package/types/components/Tabs/ui/TabItem/TabItem.d.ts.map +1 -1
- package/types/components/Tabs/ui/Tabs/Tabs.d.ts.map +1 -1
- package/types/components/Tabs/ui/Tabs/Tabs.styles.d.ts.map +1 -1
@@ -14,7 +14,7 @@ var base$3 = require('./variations/_pilled/base.js');
|
|
14
14
|
var base$2 = require('./variations/_disabled/base.js');
|
15
15
|
var TabItem_styles = require('./TabItem.styles.js');
|
16
16
|
|
17
|
-
var _excluded = ["size", "view", "isActive", "selected", "disabled", "pilled", "children", "contentLeft", "contentRight", "animated", "onIndexChange", "itemIndex", "tabIndex"];
|
17
|
+
var _excluded = ["size", "view", "isActive", "selected", "disabled", "pilled", "children", "contentLeft", "contentRight", "animated", "onIndexChange", "itemIndex", "tabIndex", "className"];
|
18
18
|
var tabItemRoot = function tabItemRoot(Root) {
|
19
19
|
return /*#__PURE__*/React.forwardRef(function (props, outerRef) {
|
20
20
|
var size = props.size,
|
@@ -33,6 +33,7 @@ var tabItemRoot = function tabItemRoot(Root) {
|
|
33
33
|
onIndexChange = props.onIndexChange,
|
34
34
|
itemIndex = props.itemIndex,
|
35
35
|
tabIndex = props.tabIndex,
|
36
|
+
className = props.className,
|
36
37
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
37
38
|
var innerRef = React.useRef(null);
|
38
39
|
var ref = plasmaCore.useForkRef(outerRef, innerRef);
|
@@ -54,10 +55,10 @@ var tabItemRoot = function tabItemRoot(Root) {
|
|
54
55
|
};
|
55
56
|
}, [refs]);
|
56
57
|
var onItemFocus = React.useCallback(function (event) {
|
57
|
-
if (!hasKeyNavigation) {
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
if (!hasKeyNavigation && innerRef !== null && innerRef !== void 0 && innerRef.current) {
|
59
|
+
innerRef.current.scrollTo({
|
60
|
+
top: 0,
|
61
|
+
left: innerRef.current.offsetLeft,
|
61
62
|
behavior: 'smooth'
|
62
63
|
});
|
63
64
|
return;
|
@@ -83,7 +84,7 @@ var tabItemRoot = function tabItemRoot(Root) {
|
|
83
84
|
size: size,
|
84
85
|
onFocus: onItemFocus,
|
85
86
|
tabIndex: hasKeyNavigation ? navigationTabIndex : tabIndex,
|
86
|
-
className: index.cx(pilledClass, selectedClass, animatedClass)
|
87
|
+
className: index.cx(pilledClass, selectedClass, animatedClass, className)
|
87
88
|
}, rest), /*#__PURE__*/React.createElement(React.Fragment, null, contentLeft && /*#__PURE__*/React.createElement(TabItem_styles.LeftContent, {
|
88
89
|
className: tokens.classes.tabLeftContent
|
89
90
|
}, contentLeft), /*#__PURE__*/React.createElement(TabItem_styles.StyledContent, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TabItem.js","sources":["../../../../../src/components/Tabs/ui/TabItem/TabItem.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useContext, useEffect, useCallback } from 'react';\nimport { useForkRef } from '@salutejs/plasma-core';\n\nimport { ComponentConfig, RootProps } from '../../../../engines';\nimport { classes } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabsContext } from '../../TabsContext';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { TabItemProps } from './TabItem.types';\nimport { LeftContent, RightContent, StyledContent, base } from './TabItem.styles';\n\nexport const tabItemRoot = (Root: RootProps<HTMLDivElement, TabItemProps>) =>\n forwardRef<HTMLDivElement, TabItemProps>((props, outerRef) => {\n const {\n size,\n view,\n isActive,\n selected,\n disabled = false,\n pilled = false,\n children,\n contentLeft,\n contentRight,\n animated = true,\n onIndexChange,\n itemIndex,\n tabIndex,\n ...rest\n } = props;\n\n const innerRef = useRef<HTMLDivElement>(null);\n const ref = useForkRef(outerRef, innerRef);\n const refs = useContext(TabsContext);\n\n const role = 'tab';\n\n const pilledAttr = view !== 'clear' && pilled;\n const animatedClass = animated ? classes.tabItemAnimated : undefined;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n const selectedClass = isActive || selected ? classes.selectedTabsItem : undefined;\n const hasKeyNavigation = itemIndex !== undefined && onIndexChange !== undefined;\n const navigationTabIndex = !disabled && refs?.current === itemIndex ? 0 : -1;\n\n useEffect(() => {\n if (!refs) {\n return;\n }\n\n refs.register(innerRef);\n\n return () => refs.unregister(innerRef);\n }, [refs]);\n\n const onItemFocus = useCallback<React.FocusEventHandler>(\n (event) => {\n if (!hasKeyNavigation) {\n
|
1
|
+
{"version":3,"file":"TabItem.js","sources":["../../../../../src/components/Tabs/ui/TabItem/TabItem.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useContext, useEffect, useCallback } from 'react';\nimport { useForkRef } from '@salutejs/plasma-core';\n\nimport { ComponentConfig, RootProps } from '../../../../engines';\nimport { classes } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabsContext } from '../../TabsContext';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { TabItemProps } from './TabItem.types';\nimport { LeftContent, RightContent, StyledContent, base } from './TabItem.styles';\n\nexport const tabItemRoot = (Root: RootProps<HTMLDivElement, TabItemProps>) =>\n forwardRef<HTMLDivElement, TabItemProps>((props, outerRef) => {\n const {\n size,\n view,\n isActive,\n selected,\n disabled = false,\n pilled = false,\n children,\n contentLeft,\n contentRight,\n animated = true,\n onIndexChange,\n itemIndex,\n tabIndex,\n className,\n ...rest\n } = props;\n\n const innerRef = useRef<HTMLDivElement>(null);\n const ref = useForkRef(outerRef, innerRef);\n const refs = useContext(TabsContext);\n\n const role = 'tab';\n\n const pilledAttr = view !== 'clear' && pilled;\n const animatedClass = animated ? classes.tabItemAnimated : undefined;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n const selectedClass = isActive || selected ? classes.selectedTabsItem : undefined;\n const hasKeyNavigation = itemIndex !== undefined && onIndexChange !== undefined;\n const navigationTabIndex = !disabled && refs?.current === itemIndex ? 0 : -1;\n\n useEffect(() => {\n if (!refs) {\n return;\n }\n\n refs.register(innerRef);\n\n return () => refs.unregister(innerRef);\n }, [refs]);\n\n const onItemFocus = useCallback<React.FocusEventHandler>(\n (event) => {\n if (!hasKeyNavigation && innerRef?.current) {\n innerRef.current.scrollTo({\n top: 0,\n left: innerRef.current.offsetLeft,\n behavior: 'smooth',\n });\n\n return;\n }\n\n if (disabled || !refs) {\n return;\n }\n\n const focusIndex = refs.items.findIndex((itemRef) => itemRef.current === event.target);\n\n if (focusIndex === refs.current) {\n return;\n }\n\n onIndexChange?.(focusIndex);\n refs.setCurrent(focusIndex);\n },\n [refs, innerRef, onIndexChange, disabled],\n );\n\n return (\n <Root\n ref={ref}\n disabled={disabled}\n pilled={pilled}\n role={role}\n view={view}\n size={size}\n onFocus={onItemFocus}\n tabIndex={hasKeyNavigation ? navigationTabIndex : tabIndex}\n className={cx(pilledClass, selectedClass, animatedClass, className)}\n {...rest}\n >\n <>\n {contentLeft && <LeftContent className={classes.tabLeftContent}>{contentLeft}</LeftContent>}\n <StyledContent className={classes.tabContent}>{children}</StyledContent>\n {contentRight && <RightContent className={classes.tabRightContent}>{contentRight}</RightContent>}\n </>\n </Root>\n );\n });\n\nexport const tabItemConfig: ComponentConfig = {\n name: 'TabItem',\n tag: 'button',\n layout: tabItemRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'default',\n },\n};\n"],"names":["tabItemRoot","Root","forwardRef","props","outerRef","size","view","isActive","selected","_props$disabled","disabled","_props$pilled","pilled","children","contentLeft","contentRight","_props$animated","animated","onIndexChange","itemIndex","tabIndex","className","rest","_objectWithoutProperties","_excluded","innerRef","useRef","ref","useForkRef","refs","useContext","TabsContext","role","pilledAttr","animatedClass","classes","tabItemAnimated","undefined","pilledClass","tabsPilled","selectedClass","selectedTabsItem","hasKeyNavigation","navigationTabIndex","current","useEffect","register","unregister","onItemFocus","useCallback","event","scrollTo","top","left","offsetLeft","behavior","focusIndex","items","findIndex","itemRef","target","setCurrent","React","createElement","_extends","onFocus","cx","Fragment","LeftContent","tabLeftContent","StyledContent","tabContent","RightContent","tabRightContent","tabItemConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;IAeaA,WAAW,GAAG,SAAdA,WAAWA,CAAIC,IAA6C,EAAA;AAAA,EAAA,oBACrEC,gBAAU,CAA+B,UAACC,KAAK,EAAEC,QAAQ,EAAK;AAC1D,IAAA,IACIC,IAAI,GAeJF,KAAK,CAfLE,IAAI;MACJC,IAAI,GAcJH,KAAK,CAdLG,IAAI;MACJC,QAAQ,GAaRJ,KAAK,CAbLI,QAAQ;MACRC,QAAQ,GAYRL,KAAK,CAZLK,QAAQ;MAAAC,eAAA,GAYRN,KAAK,CAXLO,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,eAAA;MAAAE,aAAA,GAWhBR,KAAK,CAVLS,MAAM;AAANA,MAAAA,MAAM,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,aAAA;MACdE,QAAQ,GASRV,KAAK,CATLU,QAAQ;MACRC,WAAW,GAQXX,KAAK,CARLW,WAAW;MACXC,YAAY,GAOZZ,KAAK,CAPLY,YAAY;MAAAC,eAAA,GAOZb,KAAK,CANLc,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,eAAA;MACfE,aAAa,GAKbf,KAAK,CALLe,aAAa;MACbC,SAAS,GAIThB,KAAK,CAJL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,GAAG,EAAEG,WAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDxE,IAAAA,MAAM,EAAE;AACJoE,MAAAA,GAAG,EAAEK,WAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNhF,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;;"}
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac{width:100%;}.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_sh5e38r__f15737ac,.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_s8qwlso__f15737ac,.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_s8qwlso__f15737ac > button{width:100%;}
|
12
12
|
|
13
|
-
.
|
14
|
-
.
|
15
|
-
.
|
16
|
-
.
|
13
|
+
.Tabs_styles_194je23_bu8v92r__2ffe5f71{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;}
|
14
|
+
.Tabs_styles_194je23_s8qwlso__2ffe5f71{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
15
|
+
.Tabs_styles_194je23_sh5e38r__2ffe5f71{margin:-0.125rem;padding:0.25rem;box-sizing:content-box;overflow:scroll;position:relative;height:100%;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overscroll-behavior:contain;}.Tabs_styles_194je23_sh5e38r__2ffe5f71::-webkit-scrollbar{display:none;}
|
16
|
+
.Tabs_styles_194je23_s1ekwj92__2ffe5f71{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;cursor:pointer;border:none;background-color:transparent;padding:0;outline:none;position:relative;--plasma_private-outer-padding:var(--s1ekwj92-0);padding-right:var(--s1ekwj92-1);padding-left:var(--s1ekwj92-2);}.Tabs_styles_194je23_s1ekwj92__2ffe5f71::before{content:'';position:absolute;top:-0.125rem;left:-0.125rem;right:-0.125rem;bottom:-0.125rem;z-index:1;display:block;box-sizing:content-box;border:0.063rem solid transparent;border-radius:calc(var(--plasma_private-outline-radius) - 0.063rem);-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.Tabs_styles_194je23_s1ekwj92__2ffe5f71.Tabs_styles_194je23_focusVisible__2ffe5f71:focus::before,.Tabs_styles_194je23_s1ekwj92__2ffe5f71[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 0.063rem var(--plasma-tabs-outline-focus-color);}.Tabs_styles_194je23_s1ekwj92__2ffe5f71[disabled]{cursor:not-allowed;}
|
@@ -18,7 +18,7 @@ var base$4 = require('./variations/_pilled/base.js');
|
|
18
18
|
var base$3 = require('./variations/_stretch/base.js');
|
19
19
|
var Tabs_styles = require('./Tabs.styles.js');
|
20
20
|
|
21
|
-
var _excluded = ["id", "stretch", "disabled", "size", "view", "children", "pilled", "index"];
|
21
|
+
var _excluded = ["id", "stretch", "disabled", "size", "view", "children", "pilled", "index", "className"];
|
22
22
|
var Keys = /*#__PURE__*/function (Keys) {
|
23
23
|
Keys[Keys["end"] = 35] = "end";
|
24
24
|
Keys[Keys["home"] = 36] = "home";
|
@@ -38,6 +38,7 @@ var tabsRoot = function tabsRoot(Root) {
|
|
38
38
|
children = props.children,
|
39
39
|
pilled = props.pilled,
|
40
40
|
index$1 = props.index,
|
41
|
+
className = props.className,
|
41
42
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
42
43
|
var _useState = React.useState(true),
|
43
44
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
@@ -145,7 +146,7 @@ var tabsRoot = function tabsRoot(Root) {
|
|
145
146
|
id: tabsId,
|
146
147
|
ref: outerRef,
|
147
148
|
disabled: disabled,
|
148
|
-
className: index.cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass),
|
149
|
+
className: index.cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, className),
|
149
150
|
onKeyDown: onKeyDown
|
150
151
|
}, rest), !firstItemVisible && PreviousButton, /*#__PURE__*/React.createElement(Tabs_styles.StyledContentWrapper, {
|
151
152
|
ref: scrollRef,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.js","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, useEffect, useRef, KeyboardEvent } from 'react';\nimport type { MutableRefObject } from 'react';\nimport { animatedScrollToX, safeUseId } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabItemRefs, TabsContext } from '../../TabsContext';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './Tabs.styles';\nimport type { TabsProps } from './Tabs.types';\n\nenum Keys {\n end = 35,\n home = 36,\n left = 37,\n right = 39,\n}\n\nexport const tabsRoot = (Root: RootProps<HTMLDivElement, TabsProps>) =>\n forwardRef<HTMLDivElement, TabsProps>((props, outerRef) => {\n const { id, stretch = false, disabled = false, size, view, children, pilled, index, ...rest } = props;\n\n const [firstItemVisible, setFirstItemVisible] = useState(true);\n const [lastItemVisible, setLastItemVisible] = useState(true);\n\n const refs = useMemo(() => new TabItemRefs(index), []);\n\n const uniqId = safeUseId();\n const tabsId = id || uniqId;\n\n const isFilled = view === 'filled'; // outer padding is only for filled view\n const pilledAttr = view !== 'clear' && pilled;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.tabsStretch : undefined;\n const hasLeftArrowClass = !firstItemVisible ? classes.tabsHasLeftArrow : undefined;\n const hasRightArrowClass = !lastItemVisible ? classes.tabsHasRightArrow : undefined;\n\n const scrollRef = useRef<HTMLElement | null>(null);\n const trackRef = useRef<HTMLElement | null>(null);\n\n const onPrev = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft - scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const onNext = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft + scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий таб\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n isLeftArrow\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev, disabled, isFilled],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий таб\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext, disabled, isFilled],\n );\n\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLElement>): void => {\n event.stopPropagation();\n const maxScrollLeft = event.currentTarget.scrollWidth - event.currentTarget.clientWidth;\n\n setFirstItemVisible(event.currentTarget.scrollLeft <= 0);\n setLastItemVisible(event.currentTarget.scrollLeft >= maxScrollLeft);\n },\n [setFirstItemVisible, setLastItemVisible],\n );\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (index === undefined) {\n return;\n }\n\n const minIndex = 0;\n const maxIndex = refs.items.length - 1;\n let nextIndex: number;\n\n switch (event.keyCode) {\n case Keys.end:\n nextIndex = maxIndex;\n break;\n case Keys.left:\n nextIndex = index > minIndex ? index - 1 : index;\n break;\n case Keys.right:\n nextIndex = index < maxIndex ? index + 1 : index;\n break;\n case Keys.home:\n nextIndex = minIndex;\n break;\n default:\n return;\n }\n\n if (nextIndex !== index) {\n event.preventDefault();\n refs.items[nextIndex].current?.focus();\n refs.items[nextIndex].current?.scrollIntoView({\n block: 'center',\n inline: 'center',\n behavior: 'smooth',\n });\n }\n },\n [index],\n );\n\n useEffect(() => {\n setLastItemVisible(scrollRef.current?.scrollWidth === scrollRef.current?.clientWidth);\n }, []);\n\n return (\n <TabsContext.Provider value={refs}>\n <Root\n view={view}\n role=\"tablist\"\n size={size}\n pilled={pilled}\n id={tabsId}\n ref={outerRef}\n disabled={disabled}\n className={cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass)}\n onKeyDown={onKeyDown}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper\n ref={scrollRef as MutableRefObject<HTMLDivElement | null>}\n onScroll={handleScroll}\n >\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>\n {children}\n </StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n </TabsContext.Provider>\n );\n });\n\nexport const tabsConfig = {\n name: 'Tabs',\n tag: 'div',\n layout: tabsRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["Keys","tabsRoot","Root","forwardRef","props","outerRef","id","_props$stretch","stretch","_props$disabled","disabled","size","view","children","pilled","index","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","firstItemVisible","setFirstItemVisible","_useState3","_useState4","lastItemVisible","setLastItemVisible","refs","useMemo","TabItemRefs","uniqId","safeUseId","tabsId","isFilled","pilledAttr","pilledClass","classes","tabsPilled","undefined","stretchClass","tabsStretch","hasLeftArrowClass","tabsHasLeftArrow","hasRightArrowClass","tabsHasRightArrow","scrollRef","useRef","trackRef","onPrev","useCallback","current","animatedScrollToX","scrollLeft","offsetWidth","onNext","PreviousButton","React","createElement","StyledArrow","type","onClick","tabIndex","isLeftArrow","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","handleScroll","event","stopPropagation","maxScrollLeft","currentTarget","scrollWidth","clientWidth","onKeyDown","minIndex","maxIndex","items","length","nextIndex","keyCode","end","left","right","home","_refs$items$nextIndex","_refs$items$nextIndex2","preventDefault","focus","scrollIntoView","block","inline","behavior","useEffect","_scrollRef$current","_scrollRef$current2","TabsContext","Provider","value","_extends","role","ref","className","cx","StyledContentWrapper","onScroll","StyledContent","tabsConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","stretchCSS","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeuF,IAGlFA,IAAI,0BAAJA,IAAI,EAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,KAAA,CAAA,GAAA,EAAA,CAAA,GAAA,KAAA,CAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,MAAA,CAAA,GAAA,EAAA,CAAA,GAAA,MAAA,CAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,MAAA,CAAA,GAAA,EAAA,CAAA,GAAA,MAAA,CAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,OA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,EAAElH,QAAQ;AAChBmH,EAAAA,IAAI,EAAJA,gBAAI;AACJC,EAAAA,UAAU,EAAE;AACR1G,IAAAA,IAAI,EAAE;AACF2G,MAAAA,GAAG,EAAEC,SAAAA;KACR;AACD3G,IAAAA,IAAI,EAAE;AACF0G,MAAAA,GAAG,EAAEE,WAAAA;KACR;AACD9G,IAAAA,QAAQ,EAAE;AACN4G,MAAAA,GAAG,EAAEG,WAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDlH,IAAAA,OAAO,EAAE;AACL8G,MAAAA,GAAG,EAAEK,WAAU;AACfD,MAAAA,KAAK,EAAE,IAAA;KACV;AACD5G,IAAAA,MAAM,EAAE;AACJwG,MAAAA,GAAG,EAAEM,WAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNjH,IAAAA,IAAI,EAAE,OAAO;AACbD,IAAAA,IAAI,EAAE,IAAA;AACV,GAAA;AACJ;;;;;"}
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, useEffect, useRef, KeyboardEvent } from 'react';\nimport type { MutableRefObject } from 'react';\nimport { animatedScrollToX, safeUseId } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabItemRefs, TabsContext } from '../../TabsContext';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './Tabs.styles';\nimport type { TabsProps } from './Tabs.types';\n\nenum Keys {\n end = 35,\n home = 36,\n left = 37,\n right = 39,\n}\n\nexport const tabsRoot = (Root: RootProps<HTMLDivElement, TabsProps>) =>\n forwardRef<HTMLDivElement, TabsProps>((props, outerRef) => {\n const {\n id,\n stretch = false,\n disabled = false,\n size,\n view,\n children,\n pilled,\n index,\n className,\n ...rest\n } = props;\n\n const [firstItemVisible, setFirstItemVisible] = useState(true);\n const [lastItemVisible, setLastItemVisible] = useState(true);\n\n const refs = useMemo(() => new TabItemRefs(index), []);\n\n const uniqId = safeUseId();\n const tabsId = id || uniqId;\n\n const isFilled = view === 'filled'; // outer padding is only for filled view\n const pilledAttr = view !== 'clear' && pilled;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.tabsStretch : undefined;\n const hasLeftArrowClass = !firstItemVisible ? classes.tabsHasLeftArrow : undefined;\n const hasRightArrowClass = !lastItemVisible ? classes.tabsHasRightArrow : undefined;\n\n const scrollRef = useRef<HTMLElement | null>(null);\n const trackRef = useRef<HTMLElement | null>(null);\n\n const onPrev = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft - scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const onNext = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft + scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий таб\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n isLeftArrow\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev, disabled, isFilled],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий таб\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext, disabled, isFilled],\n );\n\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLElement>): void => {\n event.stopPropagation();\n const maxScrollLeft = event.currentTarget.scrollWidth - event.currentTarget.clientWidth;\n\n setFirstItemVisible(event.currentTarget.scrollLeft <= 0);\n setLastItemVisible(event.currentTarget.scrollLeft >= maxScrollLeft);\n },\n [setFirstItemVisible, setLastItemVisible],\n );\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (index === undefined) {\n return;\n }\n\n const minIndex = 0;\n const maxIndex = refs.items.length - 1;\n let nextIndex: number;\n\n switch (event.keyCode) {\n case Keys.end:\n nextIndex = maxIndex;\n break;\n case Keys.left:\n nextIndex = index > minIndex ? index - 1 : index;\n break;\n case Keys.right:\n nextIndex = index < maxIndex ? index + 1 : index;\n break;\n case Keys.home:\n nextIndex = minIndex;\n break;\n default:\n return;\n }\n\n if (nextIndex !== index) {\n event.preventDefault();\n refs.items[nextIndex].current?.focus();\n refs.items[nextIndex].current?.scrollIntoView({\n block: 'center',\n inline: 'center',\n behavior: 'smooth',\n });\n }\n },\n [index],\n );\n\n useEffect(() => {\n setLastItemVisible(scrollRef.current?.scrollWidth === scrollRef.current?.clientWidth);\n }, []);\n\n return (\n <TabsContext.Provider value={refs}>\n <Root\n view={view}\n role=\"tablist\"\n size={size}\n pilled={pilled}\n id={tabsId}\n ref={outerRef}\n disabled={disabled}\n className={cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, className)}\n onKeyDown={onKeyDown}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper\n ref={scrollRef as MutableRefObject<HTMLDivElement | null>}\n onScroll={handleScroll}\n >\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>\n {children}\n </StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n </TabsContext.Provider>\n );\n });\n\nexport const tabsConfig = {\n name: 'Tabs',\n tag: 'div',\n layout: tabsRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["Keys","tabsRoot","Root","forwardRef","props","outerRef","id","_props$stretch","stretch","_props$disabled","disabled","size","view","children","pilled","index","className","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","firstItemVisible","setFirstItemVisible","_useState3","_useState4","lastItemVisible","setLastItemVisible","refs","useMemo","TabItemRefs","uniqId","safeUseId","tabsId","isFilled","pilledAttr","pilledClass","classes","tabsPilled","undefined","stretchClass","tabsStretch","hasLeftArrowClass","tabsHasLeftArrow","hasRightArrowClass","tabsHasRightArrow","scrollRef","useRef","trackRef","onPrev","useCallback","current","animatedScrollToX","scrollLeft","offsetWidth","onNext","PreviousButton","React","createElement","StyledArrow","type","onClick","tabIndex","isLeftArrow","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","handleScroll","event","stopPropagation","maxScrollLeft","currentTarget","scrollWidth","clientWidth","onKeyDown","minIndex","maxIndex","items","length","nextIndex","keyCode","end","left","right","home","_refs$items$nextIndex","_refs$items$nextIndex2","preventDefault","focus","scrollIntoView","block","inline","behavior","useEffect","_scrollRef$current","_scrollRef$current2","TabsContext","Provider","value","_extends","role","ref","cx","StyledContentWrapper","onScroll","StyledContent","tabsConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","stretchCSS","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeuF,IAGlFA,IAAI,0BAAJA,IAAI,EAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,KAAA,CAAA,GAAA,EAAA,CAAA,GAAA,KAAA,CAA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AACJ,MAAAA,GAAG,EAAEzD,QAAAA;KACfrC,EAAAA,QACU,CACG,CAAC,EACtB,CAACe,eAAe,IAAI2C,UACnB,CACY,CAAC,CAAA;AAE/B,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMyC,UAAU,GAAG;AACtBC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElH,QAAQ;AAChBmH,EAAAA,IAAI,EAAJA,gBAAI;AACJC,EAAAA,UAAU,EAAE;AACR1G,IAAAA,IAAI,EAAE;AACF2G,MAAAA,GAAG,EAAEC,SAAAA;KACR;AACD3G,IAAAA,IAAI,EAAE;AACF0G,MAAAA,GAAG,EAAEE,WAAAA;KACR;AACD9G,IAAAA,QAAQ,EAAE;AACN4G,MAAAA,GAAG,EAAEG,WAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDlH,IAAAA,OAAO,EAAE;AACL8G,MAAAA,GAAG,EAAEK,WAAU;AACfD,MAAAA,KAAK,EAAE,IAAA;KACV;AACD5G,IAAAA,MAAM,EAAE;AACJwG,MAAAA,GAAG,EAAEM,WAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNjH,IAAAA,IAAI,EAAE,OAAO;AACbD,IAAAA,IAAI,EAAE,IAAA;AACV,GAAA;AACJ;;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.styles.js","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.styles.ts"],"sourcesContent":["import { css } from '@linaria/core';\nimport { styled } from '@linaria/react';\n\nimport { addFocus } from '../../../../mixins';\nimport { tokens } from '../../tokens';\n\nexport const base = css`\n display: flex;\n align-items: center;\n position: relative;\n`;\n\nexport const StyledContent = styled.div`\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n`;\n\nexport const StyledContentWrapper = styled.div`\n /* allows correctly display outline focus on tabs item */\n margin: -0.125rem;\n padding: 0.25rem;\n\n overflow: scroll;\n position: relative;\n height: 100%;\n width: 100%;\n display: flex;\n align-items: center;\n\n ::-webkit-scrollbar {\n display: none;\n }\n\n overscroll-behavior: contain;\n`;\n\nexport const StyledArrow = styled.button<{ isLeftArrow?: boolean; isFilled?: boolean }>`\n display: flex;\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0;\n outline: none;\n\n ${addFocus({\n outlineSize: '0.063rem',\n outlineOffset: '-0.125rem',\n outlineColor: `var(${tokens.outlineFocusColor})`,\n outlineRadius: 'calc(var(--plasma_private-outline-radius) - 0.063rem)',\n })};\n\n &[disabled] {\n cursor: not-allowed;\n }\n\n --plasma_private-outer-padding: ${({ isFilled }) => (isFilled ? `var(${tokens.arrowOuterPadding})` : '')};\n\n padding-right: ${({ isLeftArrow }) =>\n isLeftArrow ? `var(${tokens.arrowInnerPadding})` : 'var(--plasma_private-outer-padding)'};\n padding-left: ${({ isLeftArrow }) =>\n isLeftArrow ? 'var(--plasma_private-outer-padding)' : `var(${tokens.arrowInnerPadding})`};\n`;\n"],"names":["base","StyledContent","styled","name","class","propsAsIs","StyledContentWrapper","_exp2","_ref","isFilled","concat","tokens","arrowOuterPadding","_exp3","_ref2","isLeftArrow","arrowInnerPadding","_exp4","_ref3","StyledArrow","vars"],"mappings":";;;;;;;AAMO,IAAMA,IAAI,GAIhB,UAAA;AAEM,IAAMC,aAAa,gBAAGC,YAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,eAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAIlC,EAAA;AAEM,IAAMC,oBAAoB,gBAAGJ,YAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,sBAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,
|
1
|
+
{"version":3,"file":"Tabs.styles.js","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.styles.ts"],"sourcesContent":["import { css } from '@linaria/core';\nimport { styled } from '@linaria/react';\n\nimport { addFocus } from '../../../../mixins';\nimport { tokens } from '../../tokens';\n\nexport const base = css`\n display: flex;\n align-items: center;\n position: relative;\n`;\n\nexport const StyledContent = styled.div`\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n`;\n\nexport const StyledContentWrapper = styled.div`\n /* allows correctly display outline focus on tabs item */\n margin: -0.125rem;\n padding: 0.25rem;\n\n box-sizing: content-box;\n overflow: scroll;\n position: relative;\n height: 100%;\n width: 100%;\n display: flex;\n align-items: center;\n\n ::-webkit-scrollbar {\n display: none;\n }\n\n overscroll-behavior: contain;\n`;\n\nexport const StyledArrow = styled.button<{ isLeftArrow?: boolean; isFilled?: boolean }>`\n display: flex;\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0;\n outline: none;\n\n ${addFocus({\n outlineSize: '0.063rem',\n outlineOffset: '-0.125rem',\n outlineColor: `var(${tokens.outlineFocusColor})`,\n outlineRadius: 'calc(var(--plasma_private-outline-radius) - 0.063rem)',\n })};\n\n &[disabled] {\n cursor: not-allowed;\n }\n\n --plasma_private-outer-padding: ${({ isFilled }) => (isFilled ? `var(${tokens.arrowOuterPadding})` : '')};\n\n padding-right: ${({ isLeftArrow }) =>\n isLeftArrow ? `var(${tokens.arrowInnerPadding})` : 'var(--plasma_private-outer-padding)'};\n padding-left: ${({ isLeftArrow }) =>\n isLeftArrow ? 'var(--plasma_private-outer-padding)' : `var(${tokens.arrowInnerPadding})`};\n`;\n"],"names":["base","StyledContent","styled","name","class","propsAsIs","StyledContentWrapper","_exp2","_ref","isFilled","concat","tokens","arrowOuterPadding","_exp3","_ref2","isLeftArrow","arrowInnerPadding","_exp4","_ref3","StyledArrow","vars"],"mappings":";;;;;;;AAMO,IAAMA,IAAI,GAIhB,UAAA;AAEM,IAAMC,aAAa,gBAAGC,YAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IA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OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAAe,EAAAA,IAAA,EAAA;AAAA,IAAA,YAAA,EAAA,cAmBKb,KAAsE,EAAA,CAAA;AAAA,IAAA,YAAA,EAAA,cAEvFM,KAC2E,EAAA,CAAA;AAAA,IAAA,YAAA,EAAA,cAC5EI,KAC4E,EAAA,CAAA;AAAA,GAAA;AAAA,CAC/F;;;;;;;"}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
.bu8v92r{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;}
|
2
2
|
.s8qwlso{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
3
|
-
.sh5e38r{margin:-0.125rem;padding:0.25rem;overflow:scroll;position:relative;height:100%;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overscroll-behavior:contain;}.sh5e38r::-webkit-scrollbar{display:none;}
|
3
|
+
.sh5e38r{margin:-0.125rem;padding:0.25rem;box-sizing:content-box;overflow:scroll;position:relative;height:100%;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overscroll-behavior:contain;}.sh5e38r::-webkit-scrollbar{display:none;}
|
4
4
|
.s1ekwj92{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;cursor:pointer;border:none;background-color:transparent;padding:0;outline:none;position:relative;--plasma_private-outer-padding:var(--s1ekwj92-0);padding-right:var(--s1ekwj92-1);padding-left:var(--s1ekwj92-2);}.s1ekwj92::before{content:'';position:absolute;top:-0.125rem;left:-0.125rem;right:-0.125rem;bottom:-0.125rem;z-index:1;display:block;box-sizing:content-box;border:0.063rem solid transparent;border-radius:calc(var(--plasma_private-outline-radius) - 0.063rem);-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.s1ekwj92.focus-visible:focus::before,.s1ekwj92[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 0.063rem var(--plasma-tabs-outline-focus-color);}.s1ekwj92[disabled]{cursor:not-allowed;}
|
package/cjs/index.css
CHANGED
@@ -168,10 +168,10 @@
|
|
168
168
|
|
169
169
|
.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac{width:100%;}.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_sh5e38r__f15737ac,.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_s8qwlso__f15737ac,.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_s8qwlso__f15737ac > button{width:100%;}
|
170
170
|
|
171
|
-
.
|
172
|
-
.
|
173
|
-
.
|
174
|
-
.
|
171
|
+
.Tabs_styles_194je23_bu8v92r__2ffe5f71{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;}
|
172
|
+
.Tabs_styles_194je23_s8qwlso__2ffe5f71{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
173
|
+
.Tabs_styles_194je23_sh5e38r__2ffe5f71{margin:-0.125rem;padding:0.25rem;box-sizing:content-box;overflow:scroll;position:relative;height:100%;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overscroll-behavior:contain;}.Tabs_styles_194je23_sh5e38r__2ffe5f71::-webkit-scrollbar{display:none;}
|
174
|
+
.Tabs_styles_194je23_s1ekwj92__2ffe5f71{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;cursor:pointer;border:none;background-color:transparent;padding:0;outline:none;position:relative;--plasma_private-outer-padding:var(--s1ekwj92-0);padding-right:var(--s1ekwj92-1);padding-left:var(--s1ekwj92-2);}.Tabs_styles_194je23_s1ekwj92__2ffe5f71::before{content:'';position:absolute;top:-0.125rem;left:-0.125rem;right:-0.125rem;bottom:-0.125rem;z-index:1;display:block;box-sizing:content-box;border:0.063rem solid transparent;border-radius:calc(var(--plasma_private-outline-radius) - 0.063rem);-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.Tabs_styles_194je23_s1ekwj92__2ffe5f71.Tabs_styles_194je23_focusVisible__2ffe5f71:focus::before,.Tabs_styles_194je23_s1ekwj92__2ffe5f71[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 0.063rem var(--plasma-tabs-outline-focus-color);}.Tabs_styles_194je23_s1ekwj92__2ffe5f71[disabled]{cursor:not-allowed;}
|
175
175
|
|
176
176
|
.base_q8xs21_b5uyjxl__66eab5c4{color:var(--plasma-tab-item-color);background-color:var(--plasma-tab-item-background-color);margin-left:var(--plasma-tab-item-margin-left-filled,var(--plasma-tab-item-margin-left));}.base_q8xs21_b5uyjxl__66eab5c4:hover{color:var(--plasma-tab-item-color-hover);background-color:var(--plasma-tab-item-background-color-hover);}.base_q8xs21_b5uyjxl__66eab5c4:hover .base_q8xs21_r265xop__66eab5c4{color:var(--plasma-tab-item-hover-additional-content-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_tabItemAnimated__66eab5c4{-webkit-transition:var(--plasma-tab-item-background-transition);transition:var(--plasma-tab-item-background-transition);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4{color:var(--plasma-tab-item-selected-color);background-color:var(--plasma-tab-item-selected-background-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4:hover{color:var(--plasma-tab-item-selected-color-hover);background-color:var(--plasma-tab-item-selected-background-color-hover);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4:hover::after{background:var(--plasma-tab-item-selected-hover-divider-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4 .base_q8xs21_r265xop__66eab5c4{color:var(--plasma-tab-item-selected-additional-content-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4 .base_q8xs21_r265xop__66eab5c4:hover{color:var(--plasma-tab-item-selected-hover-additional-content-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4::after{content:'';position:absolute;bottom:0px;left:0;right:0;background:var(--plasma-tab-item-selected-divider-color);height:var(--plasma-tab-item-selected-divider-height);border-radius:1px;}
|
177
177
|
|
@@ -10,7 +10,7 @@ import { base as base$4 } from './variations/_pilled/base.js';
|
|
10
10
|
import { base as base$3 } from './variations/_disabled/base.js';
|
11
11
|
import { LeftContent, StyledContent, RightContent, base } from './TabItem.styles.js';
|
12
12
|
|
13
|
-
var _excluded = ["size", "view", "isActive", "selected", "disabled", "pilled", "children", "contentLeft", "contentRight", "animated", "onIndexChange", "itemIndex", "tabIndex"];
|
13
|
+
var _excluded = ["size", "view", "isActive", "selected", "disabled", "pilled", "children", "contentLeft", "contentRight", "animated", "onIndexChange", "itemIndex", "tabIndex", "className"];
|
14
14
|
var tabItemRoot = function tabItemRoot(Root) {
|
15
15
|
return /*#__PURE__*/forwardRef(function (props, outerRef) {
|
16
16
|
var size = props.size,
|
@@ -29,6 +29,7 @@ var tabItemRoot = function tabItemRoot(Root) {
|
|
29
29
|
onIndexChange = props.onIndexChange,
|
30
30
|
itemIndex = props.itemIndex,
|
31
31
|
tabIndex = props.tabIndex,
|
32
|
+
className = props.className,
|
32
33
|
rest = _objectWithoutProperties(props, _excluded);
|
33
34
|
var innerRef = useRef(null);
|
34
35
|
var ref = useForkRef(outerRef, innerRef);
|
@@ -50,10 +51,10 @@ var tabItemRoot = function tabItemRoot(Root) {
|
|
50
51
|
};
|
51
52
|
}, [refs]);
|
52
53
|
var onItemFocus = useCallback(function (event) {
|
53
|
-
if (!hasKeyNavigation) {
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
if (!hasKeyNavigation && innerRef !== null && innerRef !== void 0 && innerRef.current) {
|
55
|
+
innerRef.current.scrollTo({
|
56
|
+
top: 0,
|
57
|
+
left: innerRef.current.offsetLeft,
|
57
58
|
behavior: 'smooth'
|
58
59
|
});
|
59
60
|
return;
|
@@ -79,7 +80,7 @@ var tabItemRoot = function tabItemRoot(Root) {
|
|
79
80
|
size: size,
|
80
81
|
onFocus: onItemFocus,
|
81
82
|
tabIndex: hasKeyNavigation ? navigationTabIndex : tabIndex,
|
82
|
-
className: cx(pilledClass, selectedClass, animatedClass)
|
83
|
+
className: cx(pilledClass, selectedClass, animatedClass, className)
|
83
84
|
}, rest), /*#__PURE__*/React.createElement(React.Fragment, null, contentLeft && /*#__PURE__*/React.createElement(LeftContent, {
|
84
85
|
className: classes.tabLeftContent
|
85
86
|
}, contentLeft), /*#__PURE__*/React.createElement(StyledContent, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TabItem.js","sources":["../../../../../src/components/Tabs/ui/TabItem/TabItem.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useContext, useEffect, useCallback } from 'react';\nimport { useForkRef } from '@salutejs/plasma-core';\n\nimport { ComponentConfig, RootProps } from '../../../../engines';\nimport { classes } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabsContext } from '../../TabsContext';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { TabItemProps } from './TabItem.types';\nimport { LeftContent, RightContent, StyledContent, base } from './TabItem.styles';\n\nexport const tabItemRoot = (Root: RootProps<HTMLDivElement, TabItemProps>) =>\n forwardRef<HTMLDivElement, TabItemProps>((props, outerRef) => {\n const {\n size,\n view,\n isActive,\n selected,\n disabled = false,\n pilled = false,\n children,\n contentLeft,\n contentRight,\n animated = true,\n onIndexChange,\n itemIndex,\n tabIndex,\n ...rest\n } = props;\n\n const innerRef = useRef<HTMLDivElement>(null);\n const ref = useForkRef(outerRef, innerRef);\n const refs = useContext(TabsContext);\n\n const role = 'tab';\n\n const pilledAttr = view !== 'clear' && pilled;\n const animatedClass = animated ? classes.tabItemAnimated : undefined;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n const selectedClass = isActive || selected ? classes.selectedTabsItem : undefined;\n const hasKeyNavigation = itemIndex !== undefined && onIndexChange !== undefined;\n const navigationTabIndex = !disabled && refs?.current === itemIndex ? 0 : -1;\n\n useEffect(() => {\n if (!refs) {\n return;\n }\n\n refs.register(innerRef);\n\n return () => refs.unregister(innerRef);\n }, [refs]);\n\n const onItemFocus = useCallback<React.FocusEventHandler>(\n (event) => {\n if (!hasKeyNavigation) {\n
|
1
|
+
{"version":3,"file":"TabItem.js","sources":["../../../../../src/components/Tabs/ui/TabItem/TabItem.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useContext, useEffect, useCallback } from 'react';\nimport { useForkRef } from '@salutejs/plasma-core';\n\nimport { ComponentConfig, RootProps } from '../../../../engines';\nimport { classes } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabsContext } from '../../TabsContext';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { TabItemProps } from './TabItem.types';\nimport { LeftContent, RightContent, StyledContent, base } from './TabItem.styles';\n\nexport const tabItemRoot = (Root: RootProps<HTMLDivElement, TabItemProps>) =>\n forwardRef<HTMLDivElement, TabItemProps>((props, outerRef) => {\n const {\n size,\n view,\n isActive,\n selected,\n disabled = false,\n pilled = false,\n children,\n contentLeft,\n contentRight,\n animated = true,\n onIndexChange,\n itemIndex,\n tabIndex,\n className,\n ...rest\n } = props;\n\n const innerRef = useRef<HTMLDivElement>(null);\n const ref = useForkRef(outerRef, innerRef);\n const refs = useContext(TabsContext);\n\n const role = 'tab';\n\n const pilledAttr = view !== 'clear' && pilled;\n const animatedClass = animated ? classes.tabItemAnimated : undefined;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n const selectedClass = isActive || selected ? classes.selectedTabsItem : undefined;\n const hasKeyNavigation = itemIndex !== undefined && onIndexChange !== undefined;\n const navigationTabIndex = !disabled && refs?.current === itemIndex ? 0 : -1;\n\n useEffect(() => {\n if (!refs) {\n return;\n }\n\n refs.register(innerRef);\n\n return () => refs.unregister(innerRef);\n }, [refs]);\n\n const onItemFocus = useCallback<React.FocusEventHandler>(\n (event) => {\n if (!hasKeyNavigation && innerRef?.current) {\n innerRef.current.scrollTo({\n top: 0,\n left: innerRef.current.offsetLeft,\n behavior: 'smooth',\n });\n\n return;\n }\n\n if (disabled || !refs) {\n return;\n }\n\n const focusIndex = refs.items.findIndex((itemRef) => itemRef.current === event.target);\n\n if (focusIndex === refs.current) {\n return;\n }\n\n onIndexChange?.(focusIndex);\n refs.setCurrent(focusIndex);\n },\n [refs, innerRef, onIndexChange, disabled],\n );\n\n return (\n <Root\n ref={ref}\n disabled={disabled}\n pilled={pilled}\n role={role}\n view={view}\n size={size}\n onFocus={onItemFocus}\n tabIndex={hasKeyNavigation ? navigationTabIndex : tabIndex}\n className={cx(pilledClass, selectedClass, animatedClass, className)}\n {...rest}\n >\n <>\n {contentLeft && <LeftContent className={classes.tabLeftContent}>{contentLeft}</LeftContent>}\n <StyledContent className={classes.tabContent}>{children}</StyledContent>\n {contentRight && <RightContent className={classes.tabRightContent}>{contentRight}</RightContent>}\n </>\n </Root>\n );\n });\n\nexport const tabItemConfig: ComponentConfig = {\n name: 'TabItem',\n tag: 'button',\n layout: tabItemRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'default',\n },\n};\n"],"names":["tabItemRoot","Root","forwardRef","props","outerRef","size","view","isActive","selected","_props$disabled","disabled","_props$pilled","pilled","children","contentLeft","contentRight","_props$animated","animated","onIndexChange","itemIndex","tabIndex","className","rest","_objectWithoutProperties","_excluded","innerRef","useRef","ref","useForkRef","refs","useContext","TabsContext","role","pilledAttr","animatedClass","classes","tabItemAnimated","undefined","pilledClass","tabsPilled","selectedClass","selectedTabsItem","hasKeyNavigation","navigationTabIndex","current","useEffect","register","unregister","onItemFocus","useCallback","event","scrollTo","top","left","offsetLeft","behavior","focusIndex","items","findIndex","itemRef","target","setCurrent","React","createElement","_extends","onFocus","cx","Fragment","LeftContent","tabLeftContent","StyledContent","tabContent","RightContent","tabRightContent","tabItemConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;IAeaA,WAAW,GAAG,SAAdA,WAAWA,CAAIC,IAA6C,EAAA;AAAA,EAAA,oBACrEC,UAAU,CAA+B,UAACC,KAAK,EAAEC,QAAQ,EAAK;AAC1D,IAAA,IACIC,IAAI,GAeJF,KAAK,CAfLE,IAAI;MACJC,IAAI,GAcJH,KAAK,CAdLG,IAAI;MACJC,QAAQ,GAaRJ,KAAK,CAbLI,QAAQ;MACRC,QAAQ,GAYRL,KAAK,CAZLK,QAAQ;MAAAC,eAAA,GAYRN,KAAK,CAXLO,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,eAAA;MAAAE,aAAA,GAWhBR,KAAK,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AAA;AAAA,EAAA;AAEC,IAAM2D,aAA8B,GAAG;AAC1CC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,GAAG,EAAE,QAAQ;AACbC,EAAAA,MAAM,EAAE7E,WAAW;AACnB8E,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACR1E,IAAAA,IAAI,EAAE;AACF2E,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACD3E,IAAAA,IAAI,EAAE;AACF0E,MAAAA,GAAG,EAAEE,MAAAA;KACR;AACDxE,IAAAA,QAAQ,EAAE;AACNsE,MAAAA,GAAG,EAAEG,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDxE,IAAAA,MAAM,EAAE;AACJoE,MAAAA,GAAG,EAAEK,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNhF,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;"}
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac{width:100%;}.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_sh5e38r__f15737ac,.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_s8qwlso__f15737ac,.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_s8qwlso__f15737ac > button{width:100%;}
|
12
12
|
|
13
|
-
.
|
14
|
-
.
|
15
|
-
.
|
16
|
-
.
|
13
|
+
.Tabs_styles_194je23_bu8v92r__2ffe5f71{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;}
|
14
|
+
.Tabs_styles_194je23_s8qwlso__2ffe5f71{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
15
|
+
.Tabs_styles_194je23_sh5e38r__2ffe5f71{margin:-0.125rem;padding:0.25rem;box-sizing:content-box;overflow:scroll;position:relative;height:100%;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overscroll-behavior:contain;}.Tabs_styles_194je23_sh5e38r__2ffe5f71::-webkit-scrollbar{display:none;}
|
16
|
+
.Tabs_styles_194je23_s1ekwj92__2ffe5f71{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;cursor:pointer;border:none;background-color:transparent;padding:0;outline:none;position:relative;--plasma_private-outer-padding:var(--s1ekwj92-0);padding-right:var(--s1ekwj92-1);padding-left:var(--s1ekwj92-2);}.Tabs_styles_194je23_s1ekwj92__2ffe5f71::before{content:'';position:absolute;top:-0.125rem;left:-0.125rem;right:-0.125rem;bottom:-0.125rem;z-index:1;display:block;box-sizing:content-box;border:0.063rem solid transparent;border-radius:calc(var(--plasma_private-outline-radius) - 0.063rem);-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.Tabs_styles_194je23_s1ekwj92__2ffe5f71.Tabs_styles_194je23_focusVisible__2ffe5f71:focus::before,.Tabs_styles_194je23_s1ekwj92__2ffe5f71[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 0.063rem var(--plasma-tabs-outline-focus-color);}.Tabs_styles_194je23_s1ekwj92__2ffe5f71[disabled]{cursor:not-allowed;}
|
@@ -14,7 +14,7 @@ import { base as base$5 } from './variations/_pilled/base.js';
|
|
14
14
|
import { base as base$4 } from './variations/_stretch/base.js';
|
15
15
|
import { StyledArrow, StyledContentWrapper, StyledContent, base } from './Tabs.styles.js';
|
16
16
|
|
17
|
-
var _excluded = ["id", "stretch", "disabled", "size", "view", "children", "pilled", "index"];
|
17
|
+
var _excluded = ["id", "stretch", "disabled", "size", "view", "children", "pilled", "index", "className"];
|
18
18
|
var Keys = /*#__PURE__*/function (Keys) {
|
19
19
|
Keys[Keys["end"] = 35] = "end";
|
20
20
|
Keys[Keys["home"] = 36] = "home";
|
@@ -34,6 +34,7 @@ var tabsRoot = function tabsRoot(Root) {
|
|
34
34
|
children = props.children,
|
35
35
|
pilled = props.pilled,
|
36
36
|
index = props.index,
|
37
|
+
className = props.className,
|
37
38
|
rest = _objectWithoutProperties(props, _excluded);
|
38
39
|
var _useState = useState(true),
|
39
40
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -141,7 +142,7 @@ var tabsRoot = function tabsRoot(Root) {
|
|
141
142
|
id: tabsId,
|
142
143
|
ref: outerRef,
|
143
144
|
disabled: disabled,
|
144
|
-
className: cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass),
|
145
|
+
className: cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, className),
|
145
146
|
onKeyDown: onKeyDown
|
146
147
|
}, rest), !firstItemVisible && PreviousButton, /*#__PURE__*/React.createElement(StyledContentWrapper, {
|
147
148
|
ref: scrollRef,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.js","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, useEffect, useRef, KeyboardEvent } from 'react';\nimport type { MutableRefObject } from 'react';\nimport { animatedScrollToX, safeUseId } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabItemRefs, TabsContext } from '../../TabsContext';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './Tabs.styles';\nimport type { TabsProps } from './Tabs.types';\n\nenum Keys {\n end = 35,\n home = 36,\n left = 37,\n right = 39,\n}\n\nexport const tabsRoot = (Root: RootProps<HTMLDivElement, TabsProps>) =>\n forwardRef<HTMLDivElement, TabsProps>((props, outerRef) => {\n const { id, stretch = false, disabled = false, size, view, children, pilled, index, ...rest } = props;\n\n const [firstItemVisible, setFirstItemVisible] = useState(true);\n const [lastItemVisible, setLastItemVisible] = useState(true);\n\n const refs = useMemo(() => new TabItemRefs(index), []);\n\n const uniqId = safeUseId();\n const tabsId = id || uniqId;\n\n const isFilled = view === 'filled'; // outer padding is only for filled view\n const pilledAttr = view !== 'clear' && pilled;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.tabsStretch : undefined;\n const hasLeftArrowClass = !firstItemVisible ? classes.tabsHasLeftArrow : undefined;\n const hasRightArrowClass = !lastItemVisible ? classes.tabsHasRightArrow : undefined;\n\n const scrollRef = useRef<HTMLElement | null>(null);\n const trackRef = useRef<HTMLElement | null>(null);\n\n const onPrev = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft - scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const onNext = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft + scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий таб\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n isLeftArrow\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev, disabled, isFilled],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий таб\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext, disabled, isFilled],\n );\n\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLElement>): void => {\n event.stopPropagation();\n const maxScrollLeft = event.currentTarget.scrollWidth - event.currentTarget.clientWidth;\n\n setFirstItemVisible(event.currentTarget.scrollLeft <= 0);\n setLastItemVisible(event.currentTarget.scrollLeft >= maxScrollLeft);\n },\n [setFirstItemVisible, setLastItemVisible],\n );\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (index === undefined) {\n return;\n }\n\n const minIndex = 0;\n const maxIndex = refs.items.length - 1;\n let nextIndex: number;\n\n switch (event.keyCode) {\n case Keys.end:\n nextIndex = maxIndex;\n break;\n case Keys.left:\n nextIndex = index > minIndex ? index - 1 : index;\n break;\n case Keys.right:\n nextIndex = index < maxIndex ? index + 1 : index;\n break;\n case Keys.home:\n nextIndex = minIndex;\n break;\n default:\n return;\n }\n\n if (nextIndex !== index) {\n event.preventDefault();\n refs.items[nextIndex].current?.focus();\n refs.items[nextIndex].current?.scrollIntoView({\n block: 'center',\n inline: 'center',\n behavior: 'smooth',\n });\n }\n },\n [index],\n );\n\n useEffect(() => {\n setLastItemVisible(scrollRef.current?.scrollWidth === scrollRef.current?.clientWidth);\n }, []);\n\n return (\n <TabsContext.Provider value={refs}>\n <Root\n view={view}\n role=\"tablist\"\n size={size}\n pilled={pilled}\n id={tabsId}\n ref={outerRef}\n disabled={disabled}\n className={cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass)}\n onKeyDown={onKeyDown}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper\n ref={scrollRef as MutableRefObject<HTMLDivElement | null>}\n onScroll={handleScroll}\n >\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>\n {children}\n </StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n </TabsContext.Provider>\n );\n });\n\nexport const tabsConfig = {\n name: 'Tabs',\n tag: 'div',\n layout: tabsRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["Keys","tabsRoot","Root","forwardRef","props","outerRef","id","_props$stretch","stretch","_props$disabled","disabled","size","view","children","pilled","index","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","firstItemVisible","setFirstItemVisible","_useState3","_useState4","lastItemVisible","setLastItemVisible","refs","useMemo","TabItemRefs","uniqId","safeUseId","tabsId","isFilled","pilledAttr","pilledClass","classes","tabsPilled","undefined","stretchClass","tabsStretch","hasLeftArrowClass","tabsHasLeftArrow","hasRightArrowClass","tabsHasRightArrow","scrollRef","useRef","trackRef","onPrev","useCallback","current","animatedScrollToX","scrollLeft","offsetWidth","onNext","PreviousButton","React","createElement","StyledArrow","type","onClick","tabIndex","isLeftArrow","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","handleScroll","event","stopPropagation","maxScrollLeft","currentTarget","scrollWidth","clientWidth","onKeyDown","minIndex","maxIndex","items","length","nextIndex","keyCode","end","left","right","home","_refs$items$nextIndex","_refs$items$nextIndex2","preventDefault","focus","scrollIntoView","block","inline","behavior","useEffect","_scrollRef$current","_scrollRef$current2","TabsContext","Provider","value","_extends","role","ref","className","cx","StyledContentWrapper","onScroll","StyledContent","tabsConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","stretchCSS","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;AAeu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YAAAA;AAAa,KAAA,eAEvBd,KAAA,CAAAC,aAAA,CAACoD,aAAa,EAAA;AAACL,MAAAA,GAAG,EAAEzD,QAAAA;KACfpC,EAAAA,QACU,CACG,CAAC,EACtB,CAACc,eAAe,IAAI2C,UACnB,CACY,CAAC,CAAA;AAE/B,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAM0C,UAAU,GAAG;AACtBC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElH,QAAQ;AAChBmH,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACR1G,IAAAA,IAAI,EAAE;AACF2G,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACD3G,IAAAA,IAAI,EAAE;AACF0G,MAAAA,GAAG,EAAEE,MAAAA;KACR;AACD9G,IAAAA,QAAQ,EAAE;AACN4G,MAAAA,GAAG,EAAEG,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDlH,IAAAA,OAAO,EAAE;AACL8G,MAAAA,GAAG,EAAEK,MAAU;AACfD,MAAAA,KAAK,EAAE,IAAA;KACV;AACD5G,IAAAA,MAAM,EAAE;AACJwG,MAAAA,GAAG,EAAEM,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNjH,IAAAA,IAAI,EAAE,OAAO;AACbD,IAAAA,IAAI,EAAE,IAAA;AACV,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, useEffect, useRef, KeyboardEvent } from 'react';\nimport type { MutableRefObject } from 'react';\nimport { animatedScrollToX, safeUseId } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabItemRefs, TabsContext } from '../../TabsContext';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './Tabs.styles';\nimport type { TabsProps } from './Tabs.types';\n\nenum Keys {\n end = 35,\n home = 36,\n left = 37,\n right = 39,\n}\n\nexport const tabsRoot = (Root: RootProps<HTMLDivElement, TabsProps>) =>\n forwardRef<HTMLDivElement, TabsProps>((props, outerRef) => {\n const {\n id,\n stretch = false,\n disabled = false,\n size,\n view,\n children,\n pilled,\n index,\n className,\n ...rest\n } = props;\n\n const [firstItemVisible, setFirstItemVisible] = useState(true);\n const [lastItemVisible, setLastItemVisible] = useState(true);\n\n const refs = useMemo(() => new TabItemRefs(index), []);\n\n const uniqId = safeUseId();\n const tabsId = id || uniqId;\n\n const isFilled = view === 'filled'; // outer padding is only for filled view\n const pilledAttr = view !== 'clear' && pilled;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.tabsStretch : undefined;\n const hasLeftArrowClass = !firstItemVisible ? classes.tabsHasLeftArrow : undefined;\n const hasRightArrowClass = !lastItemVisible ? classes.tabsHasRightArrow : undefined;\n\n const scrollRef = useRef<HTMLElement | null>(null);\n const trackRef = useRef<HTMLElement | null>(null);\n\n const onPrev = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft - scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const onNext = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft + scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий таб\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n isLeftArrow\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev, disabled, isFilled],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий таб\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext, disabled, isFilled],\n );\n\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLElement>): void => {\n event.stopPropagation();\n const maxScrollLeft = event.currentTarget.scrollWidth - event.currentTarget.clientWidth;\n\n setFirstItemVisible(event.currentTarget.scrollLeft <= 0);\n setLastItemVisible(event.currentTarget.scrollLeft >= maxScrollLeft);\n },\n [setFirstItemVisible, setLastItemVisible],\n );\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (index === undefined) {\n return;\n }\n\n const minIndex = 0;\n const maxIndex = refs.items.length - 1;\n let nextIndex: number;\n\n switch (event.keyCode) {\n case Keys.end:\n nextIndex = maxIndex;\n break;\n case Keys.left:\n nextIndex = index > minIndex ? index - 1 : index;\n break;\n case Keys.right:\n nextIndex = index < maxIndex ? index + 1 : index;\n break;\n case Keys.home:\n nextIndex = minIndex;\n break;\n default:\n return;\n }\n\n if (nextIndex !== index) {\n event.preventDefault();\n refs.items[nextIndex].current?.focus();\n refs.items[nextIndex].current?.scrollIntoView({\n block: 'center',\n inline: 'center',\n behavior: 'smooth',\n });\n }\n },\n [index],\n );\n\n useEffect(() => {\n setLastItemVisible(scrollRef.current?.scrollWidth === scrollRef.current?.clientWidth);\n }, []);\n\n return (\n <TabsContext.Provider value={refs}>\n <Root\n view={view}\n role=\"tablist\"\n size={size}\n pilled={pilled}\n id={tabsId}\n ref={outerRef}\n disabled={disabled}\n className={cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, className)}\n onKeyDown={onKeyDown}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper\n ref={scrollRef as MutableRefObject<HTMLDivElement | null>}\n onScroll={handleScroll}\n >\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>\n {children}\n </StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n </TabsContext.Provider>\n );\n });\n\nexport const tabsConfig = {\n name: 'Tabs',\n tag: 'div',\n layout: tabsRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["Keys","tabsRoot","Root","forwardRef","props","outerRef","id","_props$stretch","stretch","_props$disabled","disabled","size","view","children","pilled","index","className","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","firstItemVisible","setFirstItemVisible","_useState3","_useState4","lastItemVisible","setLastItemVisible","refs","useMemo","TabItemRefs","uniqId","safeUseId","tabsId","isFilled","pilledAttr","pilledClass","classes","tabsPilled","undefined","stretchClass","tabsStretch","hasLeftArrowClass","tabsHasLeftArrow","hasRightArrowClass","tabsHasRightArrow","scrollRef","useRef","trackRef","onPrev","useCallback","current","animatedScrollToX","scrollLeft","offsetWidth","onNext","PreviousButton","React","createElement","StyledArrow","type","onClick","tabIndex","isLeftArrow","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","handleScroll","event","stopPropagation","maxScrollLeft","currentTarget","scrollWidth","clientWidth","onKeyDown","minIndex","maxIndex","items","length","nextIndex","keyCode","end","left","right","home","_refs$items$nextIndex","_refs$items$nextIndex2","preventDefault","focus","scrollIntoView","block","inline","behavior","useEffect","_scrollRef$current","_scrollRef$current2","TabsContext","Provider","value","_extends","role","ref","cx","StyledContentWrapper","onScroll","StyledContent","tabsConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","stretchCSS","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;AAeuF,IAGlFA,IAAI,0BAAJA,IAAI,EAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,KAAA,CAAA,GAAA,EAAA,CAAA,GAAA,KAAA,CAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,MAAA,CAAA,GAAA,EAAA,CAAA,GAAA,MAAA,CAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,MAAA,CAAA,GAAA,EAAA,CAAA,GAAA,MAAA,CAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,OAAA,CAAA,GAAA,EAAA,CAAA,GAAA,OAAA,CAAA;AAAA,EAAA,OAAJA,IAAI,CAAA;AAAA,CAAA,CAAJA,IAAI,IAAA,EAAA,CAAA,CAAA;IAOIC,QAAQ,GAAG,SAAXA,QAAQA,CAAIC,IAA0C,EAAA;AAAA,EAAA,oBAC/DC,UAAU,CAA4B,UAACC,KAAK,EAAEC,QAAQ,EAAK;AACvD,IAAA,IACIC,EAAE,GAUFF,KAAK,CAVLE,EAAE;MAAAC,cAAA,GAUFH,KAAK,CATLI,OAAO;AAAPA,MAAAA,OAAO,GAAAD,cAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,cAAA;MAAAE,eAAA,GASfL,KAAK,CARLM,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,eAAA;MAChBE,IAAI,GAOJP,KAAK,CAPLO,IAAI;MACJC,IAAI,GAMJR,KAAK,CANLQ,IAAI;MACJC,QAAQ,GAKRT,KAAK,CALLS,QAAQ;MACRC,MAAM,GAINV,KAAK,CAJLU,MAAM;MACNC,K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ui/Tabs/Tabs.styles.ts"],"sourcesContent":["import { css } from '@linaria/core';\nimport { styled } from '@linaria/react';\n\nimport { addFocus } from '../../../../mixins';\nimport { tokens } from '../../tokens';\n\nexport const base = css`\n display: flex;\n align-items: center;\n position: relative;\n`;\n\nexport const StyledContent = styled.div`\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n`;\n\nexport const StyledContentWrapper = styled.div`\n /* allows correctly display outline focus on tabs item */\n margin: -0.125rem;\n padding: 0.25rem;\n\n overflow: scroll;\n position: relative;\n height: 100%;\n width: 100%;\n display: flex;\n align-items: center;\n\n ::-webkit-scrollbar {\n display: none;\n }\n\n overscroll-behavior: contain;\n`;\n\nexport const StyledArrow = styled.button<{ isLeftArrow?: boolean; isFilled?: boolean }>`\n display: flex;\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0;\n outline: none;\n\n ${addFocus({\n outlineSize: '0.063rem',\n outlineOffset: '-0.125rem',\n outlineColor: `var(${tokens.outlineFocusColor})`,\n outlineRadius: 'calc(var(--plasma_private-outline-radius) - 0.063rem)',\n })};\n\n &[disabled] {\n cursor: not-allowed;\n }\n\n --plasma_private-outer-padding: ${({ isFilled }) => (isFilled ? `var(${tokens.arrowOuterPadding})` : '')};\n\n padding-right: ${({ isLeftArrow }) =>\n isLeftArrow ? `var(${tokens.arrowInnerPadding})` : 'var(--plasma_private-outer-padding)'};\n padding-left: ${({ isLeftArrow }) =>\n isLeftArrow ? 'var(--plasma_private-outer-padding)' : `var(${tokens.arrowInnerPadding})`};\n`;\n"],"names":["base","StyledContent","styled","name","class","propsAsIs","StyledContentWrapper","_exp2","_ref","isFilled","concat","tokens","arrowOuterPadding","_exp3","_ref2","isLeftArrow","arrowInnerPadding","_exp4","_ref3","StyledArrow","vars"],"mappings":";;;AAMO,IAAMA,IAAI,GAIhB,UAAA;AAEM,IAAMC,aAAa,gBAAGC,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,eAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAIlC,EAAA;AAEM,IAAMC,oBAAoB,gBAAGJ,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,sBAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,
|
1
|
+
{"version":3,"file":"Tabs.styles.js","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.styles.ts"],"sourcesContent":["import { css } from '@linaria/core';\nimport { styled } from '@linaria/react';\n\nimport { addFocus } from '../../../../mixins';\nimport { tokens } from '../../tokens';\n\nexport const base = css`\n display: flex;\n align-items: center;\n position: relative;\n`;\n\nexport const StyledContent = styled.div`\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n`;\n\nexport const StyledContentWrapper = styled.div`\n /* allows correctly display outline focus on tabs item */\n margin: -0.125rem;\n padding: 0.25rem;\n\n box-sizing: content-box;\n overflow: scroll;\n position: relative;\n height: 100%;\n width: 100%;\n display: flex;\n align-items: center;\n\n ::-webkit-scrollbar {\n display: none;\n }\n\n overscroll-behavior: contain;\n`;\n\nexport const StyledArrow = styled.button<{ isLeftArrow?: boolean; isFilled?: boolean }>`\n display: flex;\n cursor: pointer;\n border: none;\n background-color: transparent;\n padding: 0;\n outline: none;\n\n ${addFocus({\n outlineSize: '0.063rem',\n outlineOffset: '-0.125rem',\n outlineColor: `var(${tokens.outlineFocusColor})`,\n outlineRadius: 'calc(var(--plasma_private-outline-radius) - 0.063rem)',\n })};\n\n &[disabled] {\n cursor: not-allowed;\n }\n\n --plasma_private-outer-padding: ${({ isFilled }) => (isFilled ? `var(${tokens.arrowOuterPadding})` : '')};\n\n padding-right: ${({ isLeftArrow }) =>\n isLeftArrow ? `var(${tokens.arrowInnerPadding})` : 'var(--plasma_private-outer-padding)'};\n padding-left: ${({ isLeftArrow }) =>\n isLeftArrow ? 'var(--plasma_private-outer-padding)' : `var(${tokens.arrowInnerPadding})`};\n`;\n"],"names":["base","StyledContent","styled","name","class","propsAsIs","StyledContentWrapper","_exp2","_ref","isFilled","concat","tokens","arrowOuterPadding","_exp3","_ref2","isLeftArrow","arrowInnerPadding","_exp4","_ref3","StyledArrow","vars"],"mappings":";;;AAMO,IAAMA,IAAI,GAIhB,UAAA;AAEM,IAAMC,aAAa,gBAAGC,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,eAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAIlC,EAAA;AAEM,IAAMC,oBAAoB,gBAAGJ,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,sBAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAkBzC,EAAA;AAAC,IAAAE,KAAA,GAnCgBA,SAmChBA,KAAAA,GAAA;AAAA,EAAA,OAqBoC,UAAAC,IAAA,EAAA;AAAA,IAAA,IAAGC,QAAAA,GAAAA,IAAAA,CAAAA,QAAAA,CAAAA;IAAAA,OAAgBA,QAAQ,UAAAC,MAAA,CAAUC,MAAM,CAACC,iBAAkB,SAAK,EAAG,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAAA,IAAAC,KAAA,GAxD1FA,SAwD0FA,KAAAA,GAAA;AAAA,EAAA,OAEvF,UAAAC,KAAA,EAAA;AAAA,IAAA,IAAGC,WAAAA,GAAAA,KAAAA,CAAAA,WAAAA,CAAAA;IAAAA,OAChBA,WAAW,UAAAL,MAAA,CAAUC,MAAM,CAACK,iBAAkB,SAAK,qCAAqC,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAAA,IAAAC,KAAA,GA3D9EA,SA2D8EA,KAAAA,GAAA;AAAA,EAAA,OAC5E,UAAAC,KAAA,EAAA;AAAA,IAAA,IAAGH,WAAAA,GAAAA,KAAAA,CAAAA,WAAAA,CAAAA;IAAAA,OACfA,WAAW,GAAG,qCAAqC,GAAA,MAAA,CAAAL,MAAA,CAAUC,MAAM,CAACK,iBAAkB,EAAE,GAAA,CAAA,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAxBzF,IAAMG,WAAW,gBAAGjB,MAAM,CAAA,QAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,aAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAAe,EAAAA,IAAA,EAAA;AAAA,IAAA,YAAA,EAAA,cAmBKb,KAAsE,EAAA,CAAA;AAAA,IAAA,YAAA,EAAA,cAEvFM,KAC2E,EAAA,CAAA;AAAA,IAAA,YAAA,EAAA,cAC5EI,KAC4E,EAAA,CAAA;AAAA,GAAA;AAAA,CAC/F;;;;"}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
.bu8v92r{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;}
|
2
2
|
.s8qwlso{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
3
|
-
.sh5e38r{margin:-0.125rem;padding:0.25rem;overflow:scroll;position:relative;height:100%;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overscroll-behavior:contain;}.sh5e38r::-webkit-scrollbar{display:none;}
|
3
|
+
.sh5e38r{margin:-0.125rem;padding:0.25rem;box-sizing:content-box;overflow:scroll;position:relative;height:100%;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overscroll-behavior:contain;}.sh5e38r::-webkit-scrollbar{display:none;}
|
4
4
|
.s1ekwj92{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;cursor:pointer;border:none;background-color:transparent;padding:0;outline:none;position:relative;--plasma_private-outer-padding:var(--s1ekwj92-0);padding-right:var(--s1ekwj92-1);padding-left:var(--s1ekwj92-2);}.s1ekwj92::before{content:'';position:absolute;top:-0.125rem;left:-0.125rem;right:-0.125rem;bottom:-0.125rem;z-index:1;display:block;box-sizing:content-box;border:0.063rem solid transparent;border-radius:calc(var(--plasma_private-outline-radius) - 0.063rem);-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.s1ekwj92.focus-visible:focus::before,.s1ekwj92[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 0.063rem var(--plasma-tabs-outline-focus-color);}.s1ekwj92[disabled]{cursor:not-allowed;}
|
package/es/index.css
CHANGED
@@ -168,10 +168,10 @@
|
|
168
168
|
|
169
169
|
.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac{width:100%;}.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_sh5e38r__f15737ac,.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_s8qwlso__f15737ac,.base_176tz0n_be36ynn__f15737ac.base_176tz0n_tabsStretched__f15737ac .base_176tz0n_s8qwlso__f15737ac > button{width:100%;}
|
170
170
|
|
171
|
-
.
|
172
|
-
.
|
173
|
-
.
|
174
|
-
.
|
171
|
+
.Tabs_styles_194je23_bu8v92r__2ffe5f71{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;}
|
172
|
+
.Tabs_styles_194je23_s8qwlso__2ffe5f71{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
173
|
+
.Tabs_styles_194je23_sh5e38r__2ffe5f71{margin:-0.125rem;padding:0.25rem;box-sizing:content-box;overflow:scroll;position:relative;height:100%;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overscroll-behavior:contain;}.Tabs_styles_194je23_sh5e38r__2ffe5f71::-webkit-scrollbar{display:none;}
|
174
|
+
.Tabs_styles_194je23_s1ekwj92__2ffe5f71{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;cursor:pointer;border:none;background-color:transparent;padding:0;outline:none;position:relative;--plasma_private-outer-padding:var(--s1ekwj92-0);padding-right:var(--s1ekwj92-1);padding-left:var(--s1ekwj92-2);}.Tabs_styles_194je23_s1ekwj92__2ffe5f71::before{content:'';position:absolute;top:-0.125rem;left:-0.125rem;right:-0.125rem;bottom:-0.125rem;z-index:1;display:block;box-sizing:content-box;border:0.063rem solid transparent;border-radius:calc(var(--plasma_private-outline-radius) - 0.063rem);-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.Tabs_styles_194je23_s1ekwj92__2ffe5f71.Tabs_styles_194je23_focusVisible__2ffe5f71:focus::before,.Tabs_styles_194je23_s1ekwj92__2ffe5f71[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 0.063rem var(--plasma-tabs-outline-focus-color);}.Tabs_styles_194je23_s1ekwj92__2ffe5f71[disabled]{cursor:not-allowed;}
|
175
175
|
|
176
176
|
.base_q8xs21_b5uyjxl__66eab5c4{color:var(--plasma-tab-item-color);background-color:var(--plasma-tab-item-background-color);margin-left:var(--plasma-tab-item-margin-left-filled,var(--plasma-tab-item-margin-left));}.base_q8xs21_b5uyjxl__66eab5c4:hover{color:var(--plasma-tab-item-color-hover);background-color:var(--plasma-tab-item-background-color-hover);}.base_q8xs21_b5uyjxl__66eab5c4:hover .base_q8xs21_r265xop__66eab5c4{color:var(--plasma-tab-item-hover-additional-content-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_tabItemAnimated__66eab5c4{-webkit-transition:var(--plasma-tab-item-background-transition);transition:var(--plasma-tab-item-background-transition);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4{color:var(--plasma-tab-item-selected-color);background-color:var(--plasma-tab-item-selected-background-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4:hover{color:var(--plasma-tab-item-selected-color-hover);background-color:var(--plasma-tab-item-selected-background-color-hover);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4:hover::after{background:var(--plasma-tab-item-selected-hover-divider-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4 .base_q8xs21_r265xop__66eab5c4{color:var(--plasma-tab-item-selected-additional-content-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4 .base_q8xs21_r265xop__66eab5c4:hover{color:var(--plasma-tab-item-selected-hover-additional-content-color);}.base_q8xs21_b5uyjxl__66eab5c4.base_q8xs21_selectedTabsItem__66eab5c4::after{content:'';position:absolute;bottom:0px;left:0;right:0;background:var(--plasma-tab-item-selected-divider-color);height:var(--plasma-tab-item-selected-divider-height);border-radius:1px;}
|
177
177
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.86.0-canary.1220.9257117448.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -103,5 +103,5 @@
|
|
103
103
|
"react-popper": "2.3.0",
|
104
104
|
"storeon": "3.1.5"
|
105
105
|
},
|
106
|
-
"gitHead": "
|
106
|
+
"gitHead": "a74ea0aac098dedad55628f5bb435e51929b251a"
|
107
107
|
}
|
@@ -39,21 +39,23 @@ export function App() {
|
|
39
39
|
const [index, setIndex] = useState(0);
|
40
40
|
|
41
41
|
return (
|
42
|
-
<
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
42
|
+
<div>
|
43
|
+
<Tabs view="filled" stretch size="xs">
|
44
|
+
{items.map((_, i) => (
|
45
|
+
<TabItem
|
46
|
+
view="secondary"
|
47
|
+
key={`item:${i}`}
|
48
|
+
size="xs"
|
49
|
+
selected={i === index}
|
50
|
+
tabIndex={0}
|
51
|
+
contentLeft={<IconClock size="xs" color="inherit" />}
|
52
|
+
onClick={() => setIndex(i)}
|
53
|
+
>
|
54
|
+
Label
|
55
|
+
</TabItem>
|
56
|
+
))}
|
57
|
+
</Tabs>
|
58
|
+
</div>
|
57
59
|
);
|
58
60
|
}
|
59
61
|
```
|
@@ -72,23 +74,25 @@ export function App() {
|
|
72
74
|
const [index, setIndex] = useState(0);
|
73
75
|
|
74
76
|
return (
|
75
|
-
<
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
77
|
+
<div>
|
78
|
+
<Tabs view="filled" stretch size="xs" index={index}>
|
79
|
+
{items.map((_, i) => (
|
80
|
+
<TabItem
|
81
|
+
view="secondary"
|
82
|
+
key={`item:${i}`}
|
83
|
+
size="xs"
|
84
|
+
itemIndex={i}
|
85
|
+
onIndexChange={(i) => setIndex(i)}
|
86
|
+
selected={i === index}
|
87
|
+
tabIndex={0}
|
88
|
+
contentLeft={<IconClock size="xs" color="inherit" />}
|
89
|
+
onClick={() => setIndex(i)}
|
90
|
+
>
|
91
|
+
Label
|
92
|
+
</TabItem>
|
93
|
+
))}
|
94
|
+
</Tabs>
|
95
|
+
</div>
|
92
96
|
);
|
93
97
|
}
|
94
98
|
```
|
@@ -15,7 +15,7 @@ var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
|
15
15
|
var _base3 = /*#__PURE__*/require("./variations/_pilled/base");
|
16
16
|
var _base4 = /*#__PURE__*/require("./variations/_disabled/base");
|
17
17
|
var _TabItem = /*#__PURE__*/require("./TabItem.styles");
|
18
|
-
var _excluded = ["size", "view", "isActive", "selected", "disabled", "pilled", "children", "contentLeft", "contentRight", "animated", "onIndexChange", "itemIndex", "tabIndex"];
|
18
|
+
var _excluded = ["size", "view", "isActive", "selected", "disabled", "pilled", "children", "contentLeft", "contentRight", "animated", "onIndexChange", "itemIndex", "tabIndex", "className"];
|
19
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
20
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
21
21
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -39,6 +39,7 @@ var tabItemRoot = exports.tabItemRoot = function tabItemRoot(Root) {
|
|
39
39
|
onIndexChange = props.onIndexChange,
|
40
40
|
itemIndex = props.itemIndex,
|
41
41
|
tabIndex = props.tabIndex,
|
42
|
+
className = props.className,
|
42
43
|
rest = _objectWithoutProperties(props, _excluded);
|
43
44
|
var innerRef = (0, _react.useRef)(null);
|
44
45
|
var ref = (0, _plasmaCore.useForkRef)(outerRef, innerRef);
|
@@ -60,10 +61,10 @@ var tabItemRoot = exports.tabItemRoot = function tabItemRoot(Root) {
|
|
60
61
|
};
|
61
62
|
}, [refs]);
|
62
63
|
var onItemFocus = (0, _react.useCallback)(function (event) {
|
63
|
-
if (!hasKeyNavigation) {
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
if (!hasKeyNavigation && innerRef !== null && innerRef !== void 0 && innerRef.current) {
|
65
|
+
innerRef.current.scrollTo({
|
66
|
+
top: 0,
|
67
|
+
left: innerRef.current.offsetLeft,
|
67
68
|
behavior: 'smooth'
|
68
69
|
});
|
69
70
|
return;
|
@@ -89,7 +90,7 @@ var tabItemRoot = exports.tabItemRoot = function tabItemRoot(Root) {
|
|
89
90
|
size: size,
|
90
91
|
onFocus: onItemFocus,
|
91
92
|
tabIndex: hasKeyNavigation ? navigationTabIndex : tabIndex,
|
92
|
-
className: (0, _utils.cx)(pilledClass, selectedClass, animatedClass)
|
93
|
+
className: (0, _utils.cx)(pilledClass, selectedClass, animatedClass, className)
|
93
94
|
}, rest), /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, contentLeft && /*#__PURE__*/_react["default"].createElement(_TabItem.LeftContent, {
|
94
95
|
className: _tokens.classes.tabLeftContent
|
95
96
|
}, contentLeft), /*#__PURE__*/_react["default"].createElement(_TabItem.StyledContent, {
|
@@ -17,7 +17,7 @@ var _base3 = /*#__PURE__*/require("./variations/_disabled/base");
|
|
17
17
|
var _base4 = /*#__PURE__*/require("./variations/_pilled/base");
|
18
18
|
var _base5 = /*#__PURE__*/require("./variations/_stretch/base");
|
19
19
|
var _Tabs = /*#__PURE__*/require("./Tabs.styles");
|
20
|
-
var _excluded = ["id", "stretch", "disabled", "size", "view", "children", "pilled", "index"];
|
20
|
+
var _excluded = ["id", "stretch", "disabled", "size", "view", "children", "pilled", "index", "className"];
|
21
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
22
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
23
23
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -48,6 +48,7 @@ var tabsRoot = exports.tabsRoot = function tabsRoot(Root) {
|
|
48
48
|
children = props.children,
|
49
49
|
pilled = props.pilled,
|
50
50
|
index = props.index,
|
51
|
+
className = props.className,
|
51
52
|
rest = _objectWithoutProperties(props, _excluded);
|
52
53
|
var _useState = (0, _react.useState)(true),
|
53
54
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -155,7 +156,7 @@ var tabsRoot = exports.tabsRoot = function tabsRoot(Root) {
|
|
155
156
|
id: tabsId,
|
156
157
|
ref: outerRef,
|
157
158
|
disabled: disabled,
|
158
|
-
className: (0, _utils.cx)(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass),
|
159
|
+
className: (0, _utils.cx)(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, className),
|
159
160
|
onKeyDown: onKeyDown
|
160
161
|
}, rest), !firstItemVisible && PreviousButton, /*#__PURE__*/_react["default"].createElement(_Tabs.StyledContentWrapper, {
|
161
162
|
ref: scrollRef,
|
@@ -18,7 +18,7 @@ var StyledContent = exports.StyledContent = /*#__PURE__*/_styledComponents["defa
|
|
18
18
|
})(["display:inline-flex;flex-direction:row;align-items:center;"]);
|
19
19
|
var StyledContentWrapper = exports.StyledContentWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
20
20
|
componentId: "plasma-new-hope__sc-1ibkmsl-1"
|
21
|
-
})(["margin:-0.125rem;padding:0.25rem;overflow:scroll;position:relative;height:100%;width:100%;display:flex;align-items:center;::-webkit-scrollbar{display:none;}overscroll-behavior:contain;"]);
|
21
|
+
})(["margin:-0.125rem;padding:0.25rem;box-sizing:content-box;overflow:scroll;position:relative;height:100%;width:100%;display:flex;align-items:center;::-webkit-scrollbar{display:none;}overscroll-behavior:contain;"]);
|
22
22
|
var StyledArrow = exports.StyledArrow = /*#__PURE__*/_styledComponents["default"].button.withConfig({
|
23
23
|
componentId: "plasma-new-hope__sc-1ibkmsl-2"
|
24
24
|
})(["display:flex;cursor:pointer;border:none;background-color:transparent;padding:0;outline:none;", ";&[disabled]{cursor:not-allowed;}--plasma_private-outer-padding:", ";padding-right:", ";padding-left:", ";"], /*#__PURE__*/(0, _mixins.addFocus)({
|
@@ -39,21 +39,23 @@ export function App() {
|
|
39
39
|
const [index, setIndex] = useState(0);
|
40
40
|
|
41
41
|
return (
|
42
|
-
<
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
42
|
+
<div>
|
43
|
+
<Tabs view="filled" stretch size="xs">
|
44
|
+
{items.map((_, i) => (
|
45
|
+
<TabItem
|
46
|
+
view="secondary"
|
47
|
+
key={`item:${i}`}
|
48
|
+
size="xs"
|
49
|
+
selected={i === index}
|
50
|
+
tabIndex={0}
|
51
|
+
contentLeft={<IconClock size="xs" color="inherit" />}
|
52
|
+
onClick={() => setIndex(i)}
|
53
|
+
>
|
54
|
+
Label
|
55
|
+
</TabItem>
|
56
|
+
))}
|
57
|
+
</Tabs>
|
58
|
+
</div>
|
57
59
|
);
|
58
60
|
}
|
59
61
|
```
|
@@ -72,23 +74,25 @@ export function App() {
|
|
72
74
|
const [index, setIndex] = useState(0);
|
73
75
|
|
74
76
|
return (
|
75
|
-
<
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
77
|
+
<div>
|
78
|
+
<Tabs view="filled" stretch size="xs" index={index}>
|
79
|
+
{items.map((_, i) => (
|
80
|
+
<TabItem
|
81
|
+
view="secondary"
|
82
|
+
key={`item:${i}`}
|
83
|
+
size="xs"
|
84
|
+
itemIndex={i}
|
85
|
+
onIndexChange={(i) => setIndex(i)}
|
86
|
+
selected={i === index}
|
87
|
+
tabIndex={0}
|
88
|
+
contentLeft={<IconClock size="xs" color="inherit" />}
|
89
|
+
onClick={() => setIndex(i)}
|
90
|
+
>
|
91
|
+
Label
|
92
|
+
</TabItem>
|
93
|
+
))}
|
94
|
+
</Tabs>
|
95
|
+
</div>
|
92
96
|
);
|
93
97
|
}
|
94
98
|
```
|
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["size", "view", "isActive", "selected", "disabled", "pilled", "children", "contentLeft", "contentRight", "animated", "onIndexChange", "itemIndex", "tabIndex"];
|
1
|
+
var _excluded = ["size", "view", "isActive", "selected", "disabled", "pilled", "children", "contentLeft", "contentRight", "animated", "onIndexChange", "itemIndex", "tabIndex", "className"];
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
@@ -30,6 +30,7 @@ export var tabItemRoot = function tabItemRoot(Root) {
|
|
30
30
|
onIndexChange = props.onIndexChange,
|
31
31
|
itemIndex = props.itemIndex,
|
32
32
|
tabIndex = props.tabIndex,
|
33
|
+
className = props.className,
|
33
34
|
rest = _objectWithoutProperties(props, _excluded);
|
34
35
|
var innerRef = useRef(null);
|
35
36
|
var ref = useForkRef(outerRef, innerRef);
|
@@ -51,10 +52,10 @@ export var tabItemRoot = function tabItemRoot(Root) {
|
|
51
52
|
};
|
52
53
|
}, [refs]);
|
53
54
|
var onItemFocus = useCallback(function (event) {
|
54
|
-
if (!hasKeyNavigation) {
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
if (!hasKeyNavigation && innerRef !== null && innerRef !== void 0 && innerRef.current) {
|
56
|
+
innerRef.current.scrollTo({
|
57
|
+
top: 0,
|
58
|
+
left: innerRef.current.offsetLeft,
|
58
59
|
behavior: 'smooth'
|
59
60
|
});
|
60
61
|
return;
|
@@ -80,7 +81,7 @@ export var tabItemRoot = function tabItemRoot(Root) {
|
|
80
81
|
size: size,
|
81
82
|
onFocus: onItemFocus,
|
82
83
|
tabIndex: hasKeyNavigation ? navigationTabIndex : tabIndex,
|
83
|
-
className: cx(pilledClass, selectedClass, animatedClass)
|
84
|
+
className: cx(pilledClass, selectedClass, animatedClass, className)
|
84
85
|
}, rest), /*#__PURE__*/React.createElement(React.Fragment, null, contentLeft && /*#__PURE__*/React.createElement(LeftContent, {
|
85
86
|
className: classes.tabLeftContent
|
86
87
|
}, contentLeft), /*#__PURE__*/React.createElement(StyledContent, {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["id", "stretch", "disabled", "size", "view", "children", "pilled", "index"];
|
1
|
+
var _excluded = ["id", "stretch", "disabled", "size", "view", "children", "pilled", "index", "className"];
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
3
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
4
4
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
@@ -39,6 +39,7 @@ export var tabsRoot = function tabsRoot(Root) {
|
|
39
39
|
children = props.children,
|
40
40
|
pilled = props.pilled,
|
41
41
|
index = props.index,
|
42
|
+
className = props.className,
|
42
43
|
rest = _objectWithoutProperties(props, _excluded);
|
43
44
|
var _useState = useState(true),
|
44
45
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -146,7 +147,7 @@ export var tabsRoot = function tabsRoot(Root) {
|
|
146
147
|
id: tabsId,
|
147
148
|
ref: outerRef,
|
148
149
|
disabled: disabled,
|
149
|
-
className: cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass),
|
150
|
+
className: cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, className),
|
150
151
|
onKeyDown: onKeyDown
|
151
152
|
}, rest), !firstItemVisible && PreviousButton, /*#__PURE__*/React.createElement(StyledContentWrapper, {
|
152
153
|
ref: scrollRef,
|
@@ -10,7 +10,7 @@ export var StyledContent = /*#__PURE__*/styled.div.withConfig({
|
|
10
10
|
})(["display:inline-flex;flex-direction:row;align-items:center;"]);
|
11
11
|
export var StyledContentWrapper = /*#__PURE__*/styled.div.withConfig({
|
12
12
|
componentId: "plasma-new-hope__sc-1ibkmsl-1"
|
13
|
-
})(["margin:-0.125rem;padding:0.25rem;overflow:scroll;position:relative;height:100%;width:100%;display:flex;align-items:center;::-webkit-scrollbar{display:none;}overscroll-behavior:contain;"]);
|
13
|
+
})(["margin:-0.125rem;padding:0.25rem;box-sizing:content-box;overflow:scroll;position:relative;height:100%;width:100%;display:flex;align-items:center;::-webkit-scrollbar{display:none;}overscroll-behavior:contain;"]);
|
14
14
|
export var StyledArrow = /*#__PURE__*/styled.button.withConfig({
|
15
15
|
componentId: "plasma-new-hope__sc-1ibkmsl-2"
|
16
16
|
})(["display:flex;cursor:pointer;border:none;background-color:transparent;padding:0;outline:none;", ";&[disabled]{cursor:not-allowed;}--plasma_private-outer-padding:", ";padding-right:", ";padding-left:", ";"], /*#__PURE__*/addFocus({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TabItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tabs/ui/TabItem/TabItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiE,MAAM,OAAO,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AASjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,eAAO,MAAM,WAAW,SAAU,UAAU,cAAc,EAAE,YAAY,CAAC;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"TabItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tabs/ui/TabItem/TabItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiE,MAAM,OAAO,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AASjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,eAAO,MAAM,WAAW,SAAU,UAAU,cAAc,EAAE,YAAY,CAAC;;;;;;;;;;;;wCA2FnE,CAAC;AAEP,eAAO,MAAM,aAAa,EAAE,eAuB3B,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuF,MAAM,OAAO,CAAC;AAI5G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAY3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAS9C,eAAO,MAAM,QAAQ,SAAU,UAAU,cAAc,EAAE,SAAS,CAAC;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuF,MAAM,OAAO,CAAC;AAI5G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAY3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAS9C,eAAO,MAAM,QAAQ,SAAU,UAAU,cAAc,EAAE,SAAS,CAAC;;;;;;;;;;;wCAiK7D,CAAC;AAEP,eAAO,MAAM,UAAU;;;mBAnKQ,UAAU,cAAc,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+LlE,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.styles.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.styles.ts"],"names":[],"mappings":";AAMA,eAAO,MAAM,IAAI,0CAIhB,CAAC;AAEF,eAAO,MAAM,aAAa,qKAIzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,
|
1
|
+
{"version":3,"file":"Tabs.styles.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.styles.ts"],"names":[],"mappings":";AAMA,eAAO,MAAM,IAAI,0CAIhB,CAAC;AAEF,eAAO,MAAM,aAAa,qKAIzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,qKAkBhC,CAAC;AAEF,eAAO,MAAM,WAAW;;;EAyBvB,CAAC"}
|