@semcore/tab-line 17.1.0-prerelease.3 → 17.2.0-prerelease.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/TabLine.js +19 -13
- package/lib/cjs/TabLine.js.map +1 -1
- package/lib/cjs/TabLine.type.js.map +1 -1
- package/lib/es6/TabLine.js +19 -13
- package/lib/es6/TabLine.js.map +1 -1
- package/lib/es6/TabLine.type.js.map +1 -1
- package/lib/esm/TabLine.mjs +15 -15
- package/lib/types/TabLine.d.ts +5 -0
- package/lib/types/TabLine.type.d.ts +6 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/lib/cjs/TabLine.js
CHANGED
|
@@ -13,20 +13,20 @@ var _a11yEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhan
|
|
|
13
13
|
var _typography = require("@semcore/typography");
|
|
14
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
15
|
/*!__reshadow-styles__:"./style/tab-line.shadow.css"*/
|
|
16
|
-
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
16
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___STabLine_1de7a_gg_{position:relative;display:flex;width:100%;max-width:100%}.___STabLine_1de7a_gg_.__underlined_1de7a_gg_{border-bottom:1px solid var(--intergalactic-border-primary,#000c0829)}@supports (color:color(display-p3 0 0 0%)){.___STabLine_1de7a_gg_.__underlined_1de7a_gg_{border-bottom:1px solid var(--intergalactic-border-primary,#000c0829)}@media (color-gamut:p3){.___STabLine_1de7a_gg_.__underlined_1de7a_gg_{border-bottom:1px solid var(--intergalactic-border-primary,color(display-p3 .00798 .04498 .03219/.161))}}}.___STabLineItem_1de7a_gg_{display:inline-flex;align-items:center;justify-content:center;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;-webkit-text-decoration:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;border:none;background:#0000;color:var(--intergalactic-text-primary,#010500e5);margin-right:var(--intergalactic-spacing-4x,16px);font-weight:var(--intergalactic-medium,500)}.___STabLineItem_1de7a_gg_::-moz-focus-inner{border:none;padding:0}.___STabLineItem_1de7a_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabLineItem_1de7a_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___STabLineItem_1de7a_gg_:after,.___STabLineItem_1de7a_gg_:before{content:\"\";position:absolute;left:0;bottom:-1px;height:3px;width:100%;background-color:initial}.___STabLineItem_1de7a_gg_:before{transition:background-color calc(var(--intergalactic-duration-control, 200)*1ms) ease-in-out}@media (hover:hover){.___STabLineItem_1de7a_gg_:hover:before{background-color:var(--intergalactic-border-primary,#000c0829)}@supports (color:color(display-p3 0 0 0%)){.___STabLineItem_1de7a_gg_:hover:before{background-color:var(--intergalactic-border-primary,#000c0829)}@media (color-gamut:p3){.___STabLineItem_1de7a_gg_:hover:before{background-color:var(--intergalactic-border-primary,color(display-p3 .00798 .04498 .03219/.161))}}}}.___STabLineItem_1de7a_gg_.__selected_1de7a_gg_:after{transition-delay:calc(var(--intergalactic-duration-control, 200)*1ms);background-color:var(--intergalactic-border-info-active,#8796ef)}.___STabLineItem_1de7a_gg_ .___SAddon_1de7a_gg_:not(:last-child),.___STabLineItem_1de7a_gg_ .___SText_1de7a_gg_:not(:last-child){margin-right:var(--intergalactic-spacing-2x,8px)}.___SCaret_1de7a_gg_{position:absolute;bottom:-1px;height:3px;background:var(--intergalactic-border-info-active,#8796ef);transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___STabLineItem_1de7a_gg_.__selected_1de7a_gg_{flex-shrink:0}.___STabLineItem_1de7a_gg_.__disabled_1de7a_gg_{opacity:var(--intergalactic-disabled-opacity,.4);cursor:default;pointer-events:none}.___SAddon_1de7a_gg_{display:inline-flex;align-items:center;justify-content:center}.___STabLineItem_1de7a_gg_._size_m_1de7a_gg_{height:28px;min-width:18px}.___STabLineItem_1de7a_gg_._size_l_1de7a_gg_{height:40px;min-width:26px}.___STabLineItem_1de7a_gg_._neighborLocation_left_1de7a_gg_{margin-right:0}@media (prefers-reduced-motion){.___STabLineItem_1de7a_gg_.__selected_1de7a_gg_:after,.___STabLineItem_1de7a_gg_:after,.___STabLineItem_1de7a_gg_:before{transition:none}.___SCaret_1de7a_gg_{display:none}}", /*__inner_css_end__*/"1de7a_gg_"),
|
|
17
17
|
/*__reshadow_css_end__*/
|
|
18
18
|
{
|
|
19
|
-
"__STabLine": "
|
|
20
|
-
"_underlined": "
|
|
21
|
-
"__SCaret": "
|
|
22
|
-
"__STabLineItem": "
|
|
23
|
-
"_selected": "
|
|
24
|
-
"_disabled": "
|
|
25
|
-
"__SAddon": "
|
|
26
|
-
"_size_m": "
|
|
27
|
-
"_size_l": "
|
|
28
|
-
"_neighborLocation_left": "
|
|
29
|
-
"__SText": "
|
|
19
|
+
"__STabLine": "___STabLine_1de7a_gg_",
|
|
20
|
+
"_underlined": "__underlined_1de7a_gg_",
|
|
21
|
+
"__SCaret": "___SCaret_1de7a_gg_",
|
|
22
|
+
"__STabLineItem": "___STabLineItem_1de7a_gg_",
|
|
23
|
+
"_selected": "__selected_1de7a_gg_",
|
|
24
|
+
"_disabled": "__disabled_1de7a_gg_",
|
|
25
|
+
"__SAddon": "___SAddon_1de7a_gg_",
|
|
26
|
+
"_size_m": "_size_m_1de7a_gg_",
|
|
27
|
+
"_size_l": "_size_l_1de7a_gg_",
|
|
28
|
+
"_neighborLocation_left": "_neighborLocation_left_1de7a_gg_",
|
|
29
|
+
"__SText": "___SText_1de7a_gg_"
|
|
30
30
|
});
|
|
31
31
|
class TabLineRoot extends _core.Component {
|
|
32
32
|
constructor(...args) {
|
|
@@ -183,7 +183,7 @@ class TabLineRoot extends _core.Component {
|
|
|
183
183
|
(0, _defineProperty2.default)(TabLineRoot, "displayName", 'TabLine');
|
|
184
184
|
(0, _defineProperty2.default)(TabLineRoot, "style", style);
|
|
185
185
|
(0, _defineProperty2.default)(TabLineRoot, "defaultProps", {
|
|
186
|
-
defaultValue:
|
|
186
|
+
defaultValue: 0,
|
|
187
187
|
size: 'm',
|
|
188
188
|
underlined: true,
|
|
189
189
|
behavior: 'auto'
|
|
@@ -265,6 +265,12 @@ function Addon(props) {
|
|
|
265
265
|
}, _ref4)
|
|
266
266
|
}));
|
|
267
267
|
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* TabLine
|
|
271
|
+
*
|
|
272
|
+
* {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-api/|API} | {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-code/|Examples}
|
|
273
|
+
*/
|
|
268
274
|
const TabLine = (0, _core.createComponent)(TabLineRoot, {
|
|
269
275
|
Item: [TabLineItem, {
|
|
270
276
|
Text,
|
package/lib/cjs/TabLine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabLine.js","names":["_core","require","_baseComponents","_addonTextChildren","_interopRequireDefault","_a11yEnhance","_typography","_react","style","sstyled","insert","TabLineRoot","Component","constructor","args","_defineProperty2","default","animation","undefined","React","createRef","state","started","setState","value","e","handlers","uncontrolledProps","componentDidUpdate","prevValue","asProps","animate","componentDidMount","componentWillUnmount","animationStartTimeout","clearTimeout","fromNode","itemRefs","toString","toNode","containerNode","containerRef","current","containerRect","getBoundingClientRect","fromRect","toRect","fromLeft","x","fromWidth","width","toLeft","toWidth","setTimeout","handleAnimationStart","getItemProps","props","index","size","isSelected","bindHandlerClick","node","buttonRefsList","getItemTextProps","tabLineSize","getCaretProps","left","onTransitionEnd","handleAnimationEnd","render","_ref","_ref5","STabLine","Box","SCaret","styles","Children","controlsLength","createElement","cn","assignProps","NeighborLocation","defaultValue","underlined","behavior","a11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","TabLineItem","_ref2","arguments[0]","STabLineItem","addonLeft","addonRight","neighborLocation","buttonRef","useRef","Detect","_ref6","TabLine","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","ellipsis","SText","SemcoreText","_ref4","_ref8","SAddon","createComponent","wrapTabLine","wrapper","exports","_default"],"sources":["../../src/TabLine.tsx"],"sourcesContent":["import { NeighborLocation, Box } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport { Text as SemcoreText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/tab-line.shadow.css';\nimport type { NSTabLine } from './TabLine.type';\n\ntype State = {\n animation: {\n fromLeft: number;\n fromWidth: number;\n toLeft: number;\n toWidth: number;\n started: boolean;\n } | null;\n};\n\nclass TabLineRoot extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSTabLine.Component>,\n typeof TabLineRoot.enhance,\n NSTabLine.Handlers,\n {},\n State\n> {\n static displayName = 'TabLine';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n size: 'm',\n underlined: true,\n behavior: 'auto',\n };\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: ['role', 'tab'],\n })] as const;\n\n state: State = { animation: null };\n prevValue: NSTabLine.Props['value'] = undefined;\n itemRefs: Record<string, HTMLDivElement> = {};\n containerRef = React.createRef<HTMLDivElement>();\n animationStartTimeout: ReturnType<typeof setTimeout> | null = null;\n buttonRefsList: Array<React.MutableRefObject<HTMLButtonElement | undefined>> = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n componentDidUpdate() {\n if (\n this.prevValue !== null &&\n this.asProps.value !== null &&\n this.prevValue !== this.asProps.value\n ) {\n this.animate();\n }\n this.prevValue = this.asProps.value;\n }\n\n componentDidMount() {\n this.prevValue = this.asProps.value;\n }\n\n componentWillUnmount() {\n if (this.animationStartTimeout) {\n clearTimeout(this.animationStartTimeout);\n }\n }\n\n animate() {\n if (this.prevValue === undefined || this.asProps.value === undefined) return;\n\n const fromNode = this.itemRefs[this.prevValue.toString()];\n const toNode = this.itemRefs[this.asProps.value.toString()];\n const containerNode = this.containerRef.current;\n\n if (!fromNode || !toNode || !containerNode) return;\n const containerRect = containerNode.getBoundingClientRect();\n const fromRect = fromNode.getBoundingClientRect();\n const toRect = toNode.getBoundingClientRect();\n const animation = {\n fromLeft: fromRect.x - containerRect.x,\n fromWidth: fromRect.width,\n toLeft: toRect.x - containerRect.x,\n toWidth: toRect.width,\n started: false,\n };\n this.setState({ animation });\n\n if (this.animationStartTimeout) {\n clearTimeout(this.animationStartTimeout);\n }\n\n this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);\n }\n\n handleAnimationStart = () => {\n if (this.state.animation?.started === false) {\n this.setState({ animation: { ...this.state.animation, started: true } });\n }\n };\n\n handleAnimationEnd = () => {\n this.setState({ animation: null });\n };\n\n bindHandlerClick = (value: NSTabLine.Props['value']) => (e: React.SyntheticEvent) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props: NSTabLine.Item.Props, index: number) {\n const { value, size } = this.asProps;\n const isSelected = value === props.value;\n return {\n size,\n 'selected': isSelected,\n 'onClick': this.bindHandlerClick(props.value),\n 'tabIndex': isSelected ? 0 : -1,\n 'aria-selected': isSelected,\n 'ref': (node: HTMLDivElement) => {\n if (props.value === undefined) return;\n\n this.itemRefs[props.value.toString()] = node;\n },\n 'buttonRefsList': this.buttonRefsList,\n index,\n };\n }\n\n getItemTextProps(props: NSTabLine.Item.Text.Props, index: number) {\n const { size: tabLineSize } = this.asProps;\n const size = props.size\n ? props.size\n : tabLineSize === 'm' ? 200 : 300;\n\n return {\n size,\n buttonRefsList: this.buttonRefsList,\n index,\n };\n }\n\n getCaretProps() {\n const { animation } = this.state;\n if (!animation) return {};\n if (animation.started) {\n return {\n style: {\n left: animation.toLeft,\n width: animation.toWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n } else {\n return {\n style: {\n left: animation.fromLeft,\n width: animation.fromWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n }\n }\n\n render() {\n const STabLine = Root;\n const SCaret = Box;\n const { styles, Children, controlsLength } = this.asProps;\n const { animation } = this.state;\n\n return sstyled(styles)(\n <STabLine render={Box} role='tablist' ref={this.containerRef}>\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n {animation && <SCaret {...this.getCaretProps()} />}\n </STabLine>,\n );\n }\n}\n\nfunction TabLineItem(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabLine.Item.Component,\n typeof TabLineRoot,\n 'Item'\n >,\n) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation, buttonRefsList, index } = props;\n const buttonRef = React.useRef<HTMLButtonElement>();\n\n buttonRefsList[index] = buttonRef;\n\n return (\n <NeighborLocation.Detect neighborLocation={neighborLocation}>\n {(neighborLocation) =>\n sstyled(styles)(\n <STabLineItem\n render={Box}\n tag='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n type='button'\n role='tab'\n ref={buttonRef}\n >\n {addonLeft ? <TabLine.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabLine.Item.Text, TabLine.Item.Addon)}\n {addonRight ? <TabLine.Item.Addon tag={addonRight} /> : null}\n </STabLineItem>,\n )}\n </NeighborLocation.Detect>\n );\n}\n\nfunction Text(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabLine.Item.Text.Component,\n typeof TabLineRoot,\n 'ItemText'\n >,\n) {\n const { styles, ellipsis = true, size, buttonRefsList, index } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={SemcoreText} ellipsis={ellipsis} size={size} hint:triggerRef={buttonRefsList[index]} />);\n}\n\nfunction Addon(\n props: Intergalactic.InternalTypings.InferComponentProps<NSTabLine.Item.Addon.Component>,\n) {\n const { styles } = props;\n const SAddon = Root;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst TabLine = createComponent(TabLineRoot, {\n Item: [TabLineItem, { Text, Addon }],\n}) as unknown as NSTabLine.Component;\n\nexport const wrapTabLine = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSTabLine.WrapperComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSTabLine.WrapperComponent<PropsExtending>;\n\nexport default TabLine;\n"],"mappings":";;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA0B;AAAA,MAAAO,KAAA,8BAAAR,KAAA,CAAAS,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAe1B,MAAMC,WAAW,SAASC,eAAS,CAMjC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,iBAsBe;MAAEC,SAAS,EAAE;IAAK,CAAC;IAAA,IAAAF,gBAAA,CAAAC,OAAA,qBACIE,SAAS;IAAA,IAAAH,gBAAA,CAAAC,OAAA,oBACJ,CAAC,CAAC;IAAA,IAAAD,gBAAA,CAAAC,OAAA,qCAC9BG,cAAK,CAACC,SAAS,CAAiB,CAAC;IAAA,IAAAL,gBAAA,CAAAC,OAAA,iCACc,IAA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M,GAC2B1C,mBAAG;EAA1C,OAAAyC,KAAA,GAAO,IAAAzG,aAAO,EAACkE,MAAM,CAAC,eAACpE,MAAA,CAAAS,OAAA,CAAA8D,aAAA,CAACqC,MAAM,EAAAD,KAAA,CAAAnC,EAAA;IAAA,OAAA/E,KAAA,CAAAgF,WAAA;MAAA,OAAkB;IAAM,GAAAiC,KAAA;EAAA,EAAE,CAAC;AAC3D;AAEA,MAAMX,OAAO,GAAG,IAAAc,qBAAe,EAACzG,WAAW,EAAE;EAC3C4F,IAAI,EAAE,CAACZ,WAAW,EAAE;IAAEgB,IAAI;IAAEH;EAAM,CAAC;AACrC,CAAC,CAAmC;AAE7B,MAAMa,WAAW,GAA+BC,OAKnC,IAAKA,OAAqD;AAACC,OAAA,CAAAF,WAAA,GAAAA,WAAA;AAAA,IAAAG,QAAA,GAAAD,OAAA,CAAAvG,OAAA,GAEhEsF,OAAO","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"TabLine.js","names":["_core","require","_baseComponents","_addonTextChildren","_interopRequireDefault","_a11yEnhance","_typography","_react","style","sstyled","insert","TabLineRoot","Component","constructor","args","_defineProperty2","default","animation","undefined","React","createRef","state","started","setState","value","e","handlers","uncontrolledProps","componentDidUpdate","prevValue","asProps","animate","componentDidMount","componentWillUnmount","animationStartTimeout","clearTimeout","fromNode","itemRefs","toString","toNode","containerNode","containerRef","current","containerRect","getBoundingClientRect","fromRect","toRect","fromLeft","x","fromWidth","width","toLeft","toWidth","setTimeout","handleAnimationStart","getItemProps","props","index","size","isSelected","bindHandlerClick","node","buttonRefsList","getItemTextProps","tabLineSize","getCaretProps","left","onTransitionEnd","handleAnimationEnd","render","_ref","_ref5","STabLine","Box","SCaret","styles","Children","controlsLength","createElement","cn","assignProps","NeighborLocation","defaultValue","underlined","behavior","a11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","TabLineItem","_ref2","arguments[0]","STabLineItem","addonLeft","addonRight","neighborLocation","buttonRef","useRef","Detect","_ref6","TabLine","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","ellipsis","SText","SemcoreText","_ref4","_ref8","SAddon","createComponent","wrapTabLine","wrapper","exports","_default"],"sources":["../../src/TabLine.tsx"],"sourcesContent":["import { NeighborLocation, Box } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport { Text as SemcoreText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/tab-line.shadow.css';\nimport type { NSTabLine } from './TabLine.type';\n\ntype State = {\n animation: {\n fromLeft: number;\n fromWidth: number;\n toLeft: number;\n toWidth: number;\n started: boolean;\n } | null;\n};\n\nclass TabLineRoot extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSTabLine.Component>,\n typeof TabLineRoot.enhance,\n NSTabLine.Handlers,\n {},\n State,\n NSTabLine.DefaultProps\n> {\n static displayName = 'TabLine';\n static style = style;\n static defaultProps = {\n defaultValue: 0,\n size: 'm',\n underlined: true,\n behavior: 'auto',\n } as const;\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: ['role', 'tab'],\n })] as const;\n\n state: State = { animation: null };\n prevValue: NSTabLine.Props['value'] = undefined;\n itemRefs: Record<string, HTMLDivElement> = {};\n containerRef = React.createRef<HTMLDivElement>();\n animationStartTimeout: ReturnType<typeof setTimeout> | null = null;\n buttonRefsList: Array<React.MutableRefObject<HTMLButtonElement | undefined>> = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n componentDidUpdate() {\n if (\n this.prevValue !== null &&\n this.asProps.value !== null &&\n this.prevValue !== this.asProps.value\n ) {\n this.animate();\n }\n this.prevValue = this.asProps.value;\n }\n\n componentDidMount() {\n this.prevValue = this.asProps.value;\n }\n\n componentWillUnmount() {\n if (this.animationStartTimeout) {\n clearTimeout(this.animationStartTimeout);\n }\n }\n\n animate() {\n if (this.prevValue === undefined || this.asProps.value === undefined) return;\n\n const fromNode = this.itemRefs[this.prevValue.toString()];\n const toNode = this.itemRefs[this.asProps.value.toString()];\n const containerNode = this.containerRef.current;\n\n if (!fromNode || !toNode || !containerNode) return;\n const containerRect = containerNode.getBoundingClientRect();\n const fromRect = fromNode.getBoundingClientRect();\n const toRect = toNode.getBoundingClientRect();\n const animation = {\n fromLeft: fromRect.x - containerRect.x,\n fromWidth: fromRect.width,\n toLeft: toRect.x - containerRect.x,\n toWidth: toRect.width,\n started: false,\n };\n this.setState({ animation });\n\n if (this.animationStartTimeout) {\n clearTimeout(this.animationStartTimeout);\n }\n\n this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);\n }\n\n handleAnimationStart = () => {\n if (this.state.animation?.started === false) {\n this.setState({ animation: { ...this.state.animation, started: true } });\n }\n };\n\n handleAnimationEnd = () => {\n this.setState({ animation: null });\n };\n\n bindHandlerClick = (value: NSTabLine.Props['value']) => (e: React.SyntheticEvent) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props: NSTabLine.Item.Props, index: number) {\n const { value, size } = this.asProps;\n const isSelected = value === props.value;\n return {\n size,\n 'selected': isSelected,\n 'onClick': this.bindHandlerClick(props.value),\n 'tabIndex': isSelected ? 0 : -1,\n 'aria-selected': isSelected,\n 'ref': (node: HTMLDivElement) => {\n if (props.value === undefined) return;\n\n this.itemRefs[props.value.toString()] = node;\n },\n 'buttonRefsList': this.buttonRefsList,\n index,\n };\n }\n\n getItemTextProps(props: NSTabLine.Item.Text.Props, index: number) {\n const { size: tabLineSize } = this.asProps;\n const size = props.size\n ? props.size\n : tabLineSize === 'm' ? 200 : 300;\n\n return {\n size,\n buttonRefsList: this.buttonRefsList,\n index,\n };\n }\n\n getCaretProps() {\n const { animation } = this.state;\n if (!animation) return {};\n if (animation.started) {\n return {\n style: {\n left: animation.toLeft,\n width: animation.toWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n } else {\n return {\n style: {\n left: animation.fromLeft,\n width: animation.fromWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n }\n }\n\n render() {\n const STabLine = Root;\n const SCaret = Box;\n const { styles, Children, controlsLength } = this.asProps;\n const { animation } = this.state;\n\n return sstyled(styles)(\n <STabLine render={Box} role='tablist' ref={this.containerRef}>\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n {animation && <SCaret {...this.getCaretProps()} />}\n </STabLine>,\n );\n }\n}\n\nfunction TabLineItem(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabLine.Item.Component,\n typeof TabLineRoot,\n 'Item'\n >,\n) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation, buttonRefsList, index } = props;\n const buttonRef = React.useRef<HTMLButtonElement>();\n\n buttonRefsList[index] = buttonRef;\n\n return (\n <NeighborLocation.Detect neighborLocation={neighborLocation}>\n {(neighborLocation) =>\n sstyled(styles)(\n <STabLineItem\n render={Box}\n tag='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n type='button'\n role='tab'\n ref={buttonRef}\n >\n {addonLeft ? <TabLine.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabLine.Item.Text, TabLine.Item.Addon)}\n {addonRight ? <TabLine.Item.Addon tag={addonRight} /> : null}\n </STabLineItem>,\n )}\n </NeighborLocation.Detect>\n );\n}\n\nfunction Text(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabLine.Item.Text.Component,\n typeof TabLineRoot,\n 'ItemText'\n >,\n) {\n const { styles, ellipsis = true, size, buttonRefsList, index } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={SemcoreText} ellipsis={ellipsis} size={size} hint:triggerRef={buttonRefsList[index]} />);\n}\n\nfunction Addon(\n props: Intergalactic.InternalTypings.InferComponentProps<NSTabLine.Item.Addon.Component>,\n) {\n const { styles } = props;\n const SAddon = Root;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\n/**\n * TabLine\n *\n * {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-api/|API} | {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-code/|Examples}\n */\nconst TabLine = createComponent<\n NSTabLine.Component,\n typeof TabLineRoot\n>(TabLineRoot, {\n Item: [TabLineItem, { Text, Addon }],\n});\n\nexport const wrapTabLine = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSTabLine.WrapperComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSTabLine.WrapperComponent<PropsExtending>;\n\nexport default TabLine;\n"],"mappings":";;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA0B;AAAA,MAAAO,KAAA,8BAAAR,KAAA,CAAAS,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAe1B,MAAMC,WAAW,SAASC,eAAS,CAOjC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,iBAsBe;MAAEC,SAAS,EAAE;IAAK,CAAC;IAAA,IAAAF,gBAAA,CAAAC,OAAA,qBACIE,SAAS;IAAA,IAAAH,gBAAA,CAAAC,OAAA,oBACJ,CAAC,CAAC;IAAA,IAAAD,gBAAA,CAAAC,OAAA,qCAC9BG,cAAK,CAACC,SAAS,CAAiB,CAA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EAAO,CAAC,GAAGnB,KAAK;EACxB,MAAM2D,MAAM,GAC2B1C,mBAAG;EAA1C,OAAAyC,KAAA,GAAO,IAAAzG,aAAO,EAACkE,MAAM,CAAC,eAACpE,MAAA,CAAAS,OAAA,CAAA8D,aAAA,CAACqC,MAAM,EAAAD,KAAA,CAAAnC,EAAA;IAAA,OAAA/E,KAAA,CAAAgF,WAAA;MAAA,OAAkB;IAAM,GAAAiC,KAAA;EAAA,EAAE,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMX,OAAO,GAAG,IAAAc,qBAAe,EAG7BzG,WAAW,EAAE;EACb4F,IAAI,EAAE,CAACZ,WAAW,EAAE;IAAEgB,IAAI;IAAEH;EAAM,CAAC;AACrC,CAAC,CAAC;AAEK,MAAMa,WAAW,GAA+BC,OAKnC,IAAKA,OAAqD;AAACC,OAAA,CAAAF,WAAA,GAAAA,WAAA;AAAA,IAAAG,QAAA,GAAAD,OAAA,CAAAvG,OAAA,GAEhEsF,OAAO","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabLine.type.js","names":[],"sources":["../../src/TabLine.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { NSText } from '@semcore/typography';\nimport type React from 'react';\n\ndeclare namespace NSTabLine {\n type Value = string | number | boolean;\n type Props<T extends NSTabLine.Value = NSTabLine.Value> = BoxProps &\n NeighborLocationProps & {\n /** TabLine size\n * @default m\n * */\n size?: 'm' | 'l' | false;\n /** Adds a bottom border for the entire component\n * @default true\n * */\n underlined?: boolean;\n /** Is invoked when changing the selection */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLButtonElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Value of the selected tab */\n value?: T;\n /** Default value of the selected tab\n * @default null\n * */\n defaultValue?: T;\n\n /**\n * Behavior of tabs.\n * In `auto`, changes the tab immediately when press arrow.\n * In `manual`, needs to press `space` or `enter` for select a choice.\n * @default 'auto'\n */\n behavior?: 'auto' | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value: null;\n };\n\n namespace Item {\n type Props = BoxProps &\n NeighborItemProps & {\n /** Makes a tab selected. This property is determined automatically depending on the value. */\n selected?: boolean;\n /** Disabled state */\n disabled?: boolean;\n /** Tab value */\n value?: NSTabLine.Value;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n };\n\n namespace Text {\n type Props = NSText.Props;\n type Component = NSText.Component;\n }\n\n namespace Addon {\n type Component = typeof Box;\n }\n\n type Component = Intergalactic.Component<'div', Props, {}, [handlers: NSTabLine.Handlers]> & {\n Text: Text.Component;\n Addon: Addon.Component;\n };\n }\n\n type WrapperComponent<PropsExtending = {}> = (<\n V extends Value,\n Tag extends Intergalactic.Tag = 'div',\n >(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n Props<V>,\n Ctx,\n [handlers: Handlers]\n > &\n PropsExtending,\n ) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;\n\n type Component = WrapperComponent & {\n Item: Item.Component;\n };\n}\n\n/** @deprecated It will be removed in v18. */\nexport type TabLineValue = NSTabLine.Value;\n/** @deprecated It will be removed in v18. */\nexport type TabLineProps<T extends TabLineValue = TabLineValue> = NSTabLine.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type TabLineItemProps = NSTabLine.Item.Props;\n/** @deprecated It will be removed in v18. */\nexport type TabLineContext = NSTabLine.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type TabLineHandlers = NSTabLine.Handlers;\n\nexport type { NSTabLine };\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"TabLine.type.js","names":[],"sources":["../../src/TabLine.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { NSText } from '@semcore/typography';\nimport type React from 'react';\n\ndeclare namespace NSTabLine {\n type Value = string | number | boolean;\n type Props<T extends NSTabLine.Value = NSTabLine.Value> = BoxProps &\n NeighborLocationProps & {\n /** TabLine size\n * @default m\n * */\n size?: 'm' | 'l' | false;\n /** Adds a bottom border for the entire component\n * @default true\n * */\n underlined?: boolean;\n /** Is invoked when changing the selection */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLButtonElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Value of the selected tab */\n value?: T;\n /** Default value of the selected tab\n * @default null\n * */\n defaultValue?: T;\n\n /**\n * Behavior of tabs.\n * In `auto`, changes the tab immediately when press arrow.\n * In `manual`, needs to press `space` or `enter` for select a choice.\n * @default 'auto'\n */\n behavior?: 'auto' | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value: null;\n };\n\n type DefaultProps = {\n defaultValue: 0;\n size: 'm';\n underlined: true;\n behavior: 'auto';\n };\n\n namespace Item {\n type Props = BoxProps &\n NeighborItemProps & {\n /** Makes a tab selected. This property is determined automatically depending on the value. */\n selected?: boolean;\n /** Disabled state */\n disabled?: boolean;\n /** Tab value */\n value?: NSTabLine.Value;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n };\n\n namespace Text {\n type Props = NSText.Props;\n type Component = NSText.Component;\n }\n\n namespace Addon {\n type Component = typeof Box;\n }\n\n type Component = Intergalactic.Component<'div', Props, {}, [handlers: NSTabLine.Handlers]> & {\n Text: Text.Component;\n Addon: Addon.Component;\n };\n }\n\n type WrapperComponent<PropsExtending = {}> = (<\n V extends Value,\n Tag extends Intergalactic.Tag = 'div',\n >(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n Props<V>,\n Ctx,\n [handlers: Handlers]\n > &\n PropsExtending,\n ) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;\n\n type Component = WrapperComponent & {\n Item: Item.Component;\n };\n}\n\n/** @deprecated It will be removed in v18. */\nexport type TabLineValue = NSTabLine.Value;\n/** @deprecated It will be removed in v18. */\nexport type TabLineProps<T extends TabLineValue = TabLineValue> = NSTabLine.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type TabLineItemProps = NSTabLine.Item.Props;\n/** @deprecated It will be removed in v18. */\nexport type TabLineContext = NSTabLine.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type TabLineHandlers = NSTabLine.Handlers;\n\nexport type { NSTabLine };\n"],"mappings":"","ignoreList":[]}
|
package/lib/es6/TabLine.js
CHANGED
|
@@ -11,20 +11,20 @@ import a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';
|
|
|
11
11
|
import { Text as SemcoreText } from '@semcore/typography';
|
|
12
12
|
import React from 'react';
|
|
13
13
|
/*!__reshadow-styles__:"./style/tab-line.shadow.css"*/
|
|
14
|
-
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
14
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___STabLine_1de7a_gg_{position:relative;display:flex;width:100%;max-width:100%}.___STabLine_1de7a_gg_.__underlined_1de7a_gg_{border-bottom:1px solid var(--intergalactic-border-primary,#000c0829)}@supports (color:color(display-p3 0 0 0%)){.___STabLine_1de7a_gg_.__underlined_1de7a_gg_{border-bottom:1px solid var(--intergalactic-border-primary,#000c0829)}@media (color-gamut:p3){.___STabLine_1de7a_gg_.__underlined_1de7a_gg_{border-bottom:1px solid var(--intergalactic-border-primary,color(display-p3 .00798 .04498 .03219/.161))}}}.___STabLineItem_1de7a_gg_{display:inline-flex;align-items:center;justify-content:center;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;-webkit-text-decoration:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;border:none;background:#0000;color:var(--intergalactic-text-primary,#010500e5);margin-right:var(--intergalactic-spacing-4x,16px);font-weight:var(--intergalactic-medium,500)}.___STabLineItem_1de7a_gg_::-moz-focus-inner{border:none;padding:0}.___STabLineItem_1de7a_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabLineItem_1de7a_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___STabLineItem_1de7a_gg_:after,.___STabLineItem_1de7a_gg_:before{content:\"\";position:absolute;left:0;bottom:-1px;height:3px;width:100%;background-color:initial}.___STabLineItem_1de7a_gg_:before{transition:background-color calc(var(--intergalactic-duration-control, 200)*1ms) ease-in-out}@media (hover:hover){.___STabLineItem_1de7a_gg_:hover:before{background-color:var(--intergalactic-border-primary,#000c0829)}@supports (color:color(display-p3 0 0 0%)){.___STabLineItem_1de7a_gg_:hover:before{background-color:var(--intergalactic-border-primary,#000c0829)}@media (color-gamut:p3){.___STabLineItem_1de7a_gg_:hover:before{background-color:var(--intergalactic-border-primary,color(display-p3 .00798 .04498 .03219/.161))}}}}.___STabLineItem_1de7a_gg_.__selected_1de7a_gg_:after{transition-delay:calc(var(--intergalactic-duration-control, 200)*1ms);background-color:var(--intergalactic-border-info-active,#8796ef)}.___STabLineItem_1de7a_gg_ .___SAddon_1de7a_gg_:not(:last-child),.___STabLineItem_1de7a_gg_ .___SText_1de7a_gg_:not(:last-child){margin-right:var(--intergalactic-spacing-2x,8px)}.___SCaret_1de7a_gg_{position:absolute;bottom:-1px;height:3px;background:var(--intergalactic-border-info-active,#8796ef);transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___STabLineItem_1de7a_gg_.__selected_1de7a_gg_{flex-shrink:0}.___STabLineItem_1de7a_gg_.__disabled_1de7a_gg_{opacity:var(--intergalactic-disabled-opacity,.4);cursor:default;pointer-events:none}.___SAddon_1de7a_gg_{display:inline-flex;align-items:center;justify-content:center}.___STabLineItem_1de7a_gg_._size_m_1de7a_gg_{height:28px;min-width:18px}.___STabLineItem_1de7a_gg_._size_l_1de7a_gg_{height:40px;min-width:26px}.___STabLineItem_1de7a_gg_._neighborLocation_left_1de7a_gg_{margin-right:0}@media (prefers-reduced-motion){.___STabLineItem_1de7a_gg_.__selected_1de7a_gg_:after,.___STabLineItem_1de7a_gg_:after,.___STabLineItem_1de7a_gg_:before{transition:none}.___SCaret_1de7a_gg_{display:none}}", /*__inner_css_end__*/"1de7a_gg_"),
|
|
15
15
|
/*__reshadow_css_end__*/
|
|
16
16
|
{
|
|
17
|
-
"__STabLine": "
|
|
18
|
-
"_underlined": "
|
|
19
|
-
"__SCaret": "
|
|
20
|
-
"__STabLineItem": "
|
|
21
|
-
"_selected": "
|
|
22
|
-
"_disabled": "
|
|
23
|
-
"__SAddon": "
|
|
24
|
-
"_size_m": "
|
|
25
|
-
"_size_l": "
|
|
26
|
-
"_neighborLocation_left": "
|
|
27
|
-
"__SText": "
|
|
17
|
+
"__STabLine": "___STabLine_1de7a_gg_",
|
|
18
|
+
"_underlined": "__underlined_1de7a_gg_",
|
|
19
|
+
"__SCaret": "___SCaret_1de7a_gg_",
|
|
20
|
+
"__STabLineItem": "___STabLineItem_1de7a_gg_",
|
|
21
|
+
"_selected": "__selected_1de7a_gg_",
|
|
22
|
+
"_disabled": "__disabled_1de7a_gg_",
|
|
23
|
+
"__SAddon": "___SAddon_1de7a_gg_",
|
|
24
|
+
"_size_m": "_size_m_1de7a_gg_",
|
|
25
|
+
"_size_l": "_size_l_1de7a_gg_",
|
|
26
|
+
"_neighborLocation_left": "_neighborLocation_left_1de7a_gg_",
|
|
27
|
+
"__SText": "___SText_1de7a_gg_"
|
|
28
28
|
});
|
|
29
29
|
class TabLineRoot extends Component {
|
|
30
30
|
constructor(...args) {
|
|
@@ -181,7 +181,7 @@ class TabLineRoot extends Component {
|
|
|
181
181
|
_defineProperty(TabLineRoot, "displayName", 'TabLine');
|
|
182
182
|
_defineProperty(TabLineRoot, "style", style);
|
|
183
183
|
_defineProperty(TabLineRoot, "defaultProps", {
|
|
184
|
-
defaultValue:
|
|
184
|
+
defaultValue: 0,
|
|
185
185
|
size: 'm',
|
|
186
186
|
underlined: true,
|
|
187
187
|
behavior: 'auto'
|
|
@@ -263,6 +263,12 @@ function Addon(props) {
|
|
|
263
263
|
}, _ref4)
|
|
264
264
|
}));
|
|
265
265
|
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* TabLine
|
|
269
|
+
*
|
|
270
|
+
* {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-api/|API} | {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-code/|Examples}
|
|
271
|
+
*/
|
|
266
272
|
const TabLine = createComponent(TabLineRoot, {
|
|
267
273
|
Item: [TabLineItem, {
|
|
268
274
|
Text,
|
package/lib/es6/TabLine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabLine.js","names":["NeighborLocation","Box","createComponent","Component","sstyled","Root","addonTextChildren","a11yEnhance","Text","SemcoreText","React","style","_sstyled","insert","TabLineRoot","constructor","args","_defineProperty","animation","undefined","createRef","state","started","setState","value","e","handlers","uncontrolledProps","componentDidUpdate","prevValue","asProps","animate","componentDidMount","componentWillUnmount","animationStartTimeout","clearTimeout","fromNode","itemRefs","toString","toNode","containerNode","containerRef","current","containerRect","getBoundingClientRect","fromRect","toRect","fromLeft","x","fromWidth","width","toLeft","toWidth","setTimeout","handleAnimationStart","getItemProps","props","index","size","isSelected","bindHandlerClick","node","buttonRefsList","getItemTextProps","tabLineSize","getCaretProps","left","onTransitionEnd","handleAnimationEnd","render","_ref","_ref5","STabLine","SCaret","styles","Children","controlsLength","createElement","cn","_assignProps","defaultValue","underlined","behavior","onNeighborChange","neighborElement","focus","click","childSelector","TabLineItem","_ref2","arguments[0]","STabLineItem","addonLeft","addonRight","neighborLocation","buttonRef","useRef","Detect","_ref6","_assignProps2","TabLine","Item","Addon","tag","_ref3","_ref7","ellipsis","SText","_assignProps3","_ref4","_ref8","SAddon","_assignProps4","wrapTabLine","wrapper"],"sources":["../../src/TabLine.tsx"],"sourcesContent":["import { NeighborLocation, Box } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport { Text as SemcoreText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/tab-line.shadow.css';\nimport type { NSTabLine } from './TabLine.type';\n\ntype State = {\n animation: {\n fromLeft: number;\n fromWidth: number;\n toLeft: number;\n toWidth: number;\n started: boolean;\n } | null;\n};\n\nclass TabLineRoot extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSTabLine.Component>,\n typeof TabLineRoot.enhance,\n NSTabLine.Handlers,\n {},\n State\n> {\n static displayName = 'TabLine';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n size: 'm',\n underlined: true,\n behavior: 'auto',\n };\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: ['role', 'tab'],\n })] as const;\n\n state: State = { animation: null };\n prevValue: NSTabLine.Props['value'] = undefined;\n itemRefs: Record<string, HTMLDivElement> = {};\n containerRef = React.createRef<HTMLDivElement>();\n animationStartTimeout: ReturnType<typeof setTimeout> | null = null;\n buttonRefsList: Array<React.MutableRefObject<HTMLButtonElement | undefined>> = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n componentDidUpdate() {\n if (\n this.prevValue !== null &&\n this.asProps.value !== null &&\n this.prevValue !== this.asProps.value\n ) {\n this.animate();\n }\n this.prevValue = this.asProps.value;\n }\n\n componentDidMount() {\n this.prevValue = this.asProps.value;\n }\n\n componentWillUnmount() {\n if (this.animationStartTimeout) {\n clearTimeout(this.animationStartTimeout);\n }\n }\n\n animate() {\n if (this.prevValue === undefined || this.asProps.value === undefined) return;\n\n const fromNode = this.itemRefs[this.prevValue.toString()];\n const toNode = this.itemRefs[this.asProps.value.toString()];\n const containerNode = this.containerRef.current;\n\n if (!fromNode || !toNode || !containerNode) return;\n const containerRect = containerNode.getBoundingClientRect();\n const fromRect = fromNode.getBoundingClientRect();\n const toRect = toNode.getBoundingClientRect();\n const animation = {\n fromLeft: fromRect.x - containerRect.x,\n fromWidth: fromRect.width,\n toLeft: toRect.x - containerRect.x,\n toWidth: toRect.width,\n started: false,\n };\n this.setState({ animation });\n\n if (this.animationStartTimeout) {\n clearTimeout(this.animationStartTimeout);\n }\n\n this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);\n }\n\n handleAnimationStart = () => {\n if (this.state.animation?.started === false) {\n this.setState({ animation: { ...this.state.animation, started: true } });\n }\n };\n\n handleAnimationEnd = () => {\n this.setState({ animation: null });\n };\n\n bindHandlerClick = (value: NSTabLine.Props['value']) => (e: React.SyntheticEvent) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props: NSTabLine.Item.Props, index: number) {\n const { value, size } = this.asProps;\n const isSelected = value === props.value;\n return {\n size,\n 'selected': isSelected,\n 'onClick': this.bindHandlerClick(props.value),\n 'tabIndex': isSelected ? 0 : -1,\n 'aria-selected': isSelected,\n 'ref': (node: HTMLDivElement) => {\n if (props.value === undefined) return;\n\n this.itemRefs[props.value.toString()] = node;\n },\n 'buttonRefsList': this.buttonRefsList,\n index,\n };\n }\n\n getItemTextProps(props: NSTabLine.Item.Text.Props, index: number) {\n const { size: tabLineSize } = this.asProps;\n const size = props.size\n ? props.size\n : tabLineSize === 'm' ? 200 : 300;\n\n return {\n size,\n buttonRefsList: this.buttonRefsList,\n index,\n };\n }\n\n getCaretProps() {\n const { animation } = this.state;\n if (!animation) return {};\n if (animation.started) {\n return {\n style: {\n left: animation.toLeft,\n width: animation.toWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n } else {\n return {\n style: {\n left: animation.fromLeft,\n width: animation.fromWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n }\n }\n\n render() {\n const STabLine = Root;\n const SCaret = Box;\n const { styles, Children, controlsLength } = this.asProps;\n const { animation } = this.state;\n\n return sstyled(styles)(\n <STabLine render={Box} role='tablist' ref={this.containerRef}>\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n {animation && <SCaret {...this.getCaretProps()} />}\n </STabLine>,\n );\n }\n}\n\nfunction TabLineItem(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabLine.Item.Component,\n typeof TabLineRoot,\n 'Item'\n >,\n) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation, buttonRefsList, index } = props;\n const buttonRef = React.useRef<HTMLButtonElement>();\n\n buttonRefsList[index] = buttonRef;\n\n return (\n <NeighborLocation.Detect neighborLocation={neighborLocation}>\n {(neighborLocation) =>\n sstyled(styles)(\n <STabLineItem\n render={Box}\n tag='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n type='button'\n role='tab'\n ref={buttonRef}\n >\n {addonLeft ? <TabLine.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabLine.Item.Text, TabLine.Item.Addon)}\n {addonRight ? <TabLine.Item.Addon tag={addonRight} /> : null}\n </STabLineItem>,\n )}\n </NeighborLocation.Detect>\n );\n}\n\nfunction Text(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabLine.Item.Text.Component,\n typeof TabLineRoot,\n 'ItemText'\n >,\n) {\n const { styles, ellipsis = true, size, buttonRefsList, index } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={SemcoreText} ellipsis={ellipsis} size={size} hint:triggerRef={buttonRefsList[index]} />);\n}\n\nfunction Addon(\n props: Intergalactic.InternalTypings.InferComponentProps<NSTabLine.Item.Addon.Component>,\n) {\n const { styles } = props;\n const SAddon = Root;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst TabLine = createComponent(TabLineRoot, {\n Item: [TabLineItem, { Text, Addon }],\n}) as unknown as NSTabLine.Component;\n\nexport const wrapTabLine = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSTabLine.WrapperComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSTabLine.WrapperComponent<PropsExtending>;\n\nexport default TabLine;\n"],"mappings":";;;;;;AAAA,SAASA,gBAAgB,EAAEC,GAAG,QAAQ,0BAA0B;AAEhE,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,IAAI,IAAIC,WAAW,QAAQ,qBAAqB;AACzD,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAe1B,MAAMC,WAAW,SAASX,SAAS,CAMjC;EAAAY,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,gBAsBe;MAAEC,SAAS,EAAE;IAAK,CAAC;IAAAD,eAAA,oBACIE,SAAS;IAAAF,eAAA,mBACJ,CAAC,CAAC;IAAAA,eAAA,oCAC9BP,KAAK,CAACU,SAAS,CAAiB,CAAC;IAAAH,eAAA,gCACc,IAAI;IAAAA,eAAA,yBACa,EAAE;IAAAA,eAAA,+BAwD1D,MAAM;MAC3B,IAAI,IAAI,CAACI,KAAK,CAACH,SAAS,EAAEI,OAAO,KAAK,KAAK,EAAE;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led","Root","addonTextChildren","a11yEnhance","Text","SemcoreText","React","style","_sstyled","insert","TabLineRoot","constructor","args","_defineProperty","animation","undefined","createRef","state","started","setState","value","e","handlers","uncontrolledProps","componentDidUpdate","prevValue","asProps","animate","componentDidMount","componentWillUnmount","animationStartTimeout","clearTimeout","fromNode","itemRefs","toString","toNode","containerNode","containerRef","current","containerRect","getBoundingClientRect","fromRect","toRect","fromLeft","x","fromWidth","width","toLeft","toWidth","setTimeout","handleAnimationStart","getItemProps","props","index","size","isSelected","bindHandlerClick","node","buttonRefsList","getItemTextProps","tabLineSize","getCaretProps","left","onTransitionEnd","handleAnimationEnd","render","_ref","_ref5","STabLine","SCaret","styles","Children","controlsLength","createElement","cn","_assignProps","defaultValue","underlined","behavior","onNeighborChange","neighborElement","focus","click","childSelector","TabLineItem","_ref2","arguments[0]","STabLineItem","addonLeft","addonRight","neighborLocation","buttonRef","useRef","Detect","_ref6","_assignProps2","TabLine","Item","Addon","tag","_ref3","_ref7","ellipsis","SText","_assignProps3","_ref4","_ref8","SAddon","_assignProps4","wrapTabLine","wrapper"],"sources":["../../src/TabLine.tsx"],"sourcesContent":["import { NeighborLocation, Box } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport { Text as SemcoreText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/tab-line.shadow.css';\nimport type { NSTabLine } from './TabLine.type';\n\ntype State = {\n animation: {\n fromLeft: number;\n fromWidth: number;\n toLeft: number;\n toWidth: number;\n started: boolean;\n } | null;\n};\n\nclass TabLineRoot extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSTabLine.Component>,\n typeof TabLineRoot.enhance,\n NSTabLine.Handlers,\n {},\n State,\n NSTabLine.DefaultProps\n> {\n static displayName = 'TabLine';\n static style = style;\n static defaultProps = {\n defaultValue: 0,\n size: 'm',\n underlined: true,\n behavior: 'auto',\n } as const;\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: ['role', 'tab'],\n })] as const;\n\n state: State = { animation: null };\n prevValue: NSTabLine.Props['value'] = undefined;\n itemRefs: Record<string, HTMLDivElement> = {};\n containerRef = React.createRef<HTMLDivElement>();\n animationStartTimeout: ReturnType<typeof setTimeout> | null = null;\n buttonRefsList: Array<React.MutableRefObject<HTMLButtonElement | undefined>> = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n componentDidUpdate() {\n if (\n this.prevValue !== null &&\n this.asProps.value !== null &&\n this.prevValue !== this.asProps.value\n ) {\n this.animate();\n }\n this.prevValue = this.asProps.value;\n }\n\n componentDidMount() {\n this.prevValue = this.asProps.value;\n }\n\n componentWillUnmount() {\n if (this.animationStartTimeout) {\n clearTimeout(this.animationStartTimeout);\n }\n }\n\n animate() {\n if (this.prevValue === undefined || this.asProps.value === undefined) return;\n\n const fromNode = this.itemRefs[this.prevValue.toString()];\n const toNode = this.itemRefs[this.asProps.value.toString()];\n const containerNode = this.containerRef.current;\n\n if (!fromNode || !toNode || !containerNode) return;\n const containerRect = containerNode.getBoundingClientRect();\n const fromRect = fromNode.getBoundingClientRect();\n const toRect = toNode.getBoundingClientRect();\n const animation = {\n fromLeft: fromRect.x - containerRect.x,\n fromWidth: fromRect.width,\n toLeft: toRect.x - containerRect.x,\n toWidth: toRect.width,\n started: false,\n };\n this.setState({ animation });\n\n if (this.animationStartTimeout) {\n clearTimeout(this.animationStartTimeout);\n }\n\n this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);\n }\n\n handleAnimationStart = () => {\n if (this.state.animation?.started === false) {\n this.setState({ animation: { ...this.state.animation, started: true } });\n }\n };\n\n handleAnimationEnd = () => {\n this.setState({ animation: null });\n };\n\n bindHandlerClick = (value: NSTabLine.Props['value']) => (e: React.SyntheticEvent) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props: NSTabLine.Item.Props, index: number) {\n const { value, size } = this.asProps;\n const isSelected = value === props.value;\n return {\n size,\n 'selected': isSelected,\n 'onClick': this.bindHandlerClick(props.value),\n 'tabIndex': isSelected ? 0 : -1,\n 'aria-selected': isSelected,\n 'ref': (node: HTMLDivElement) => {\n if (props.value === undefined) return;\n\n this.itemRefs[props.value.toString()] = node;\n },\n 'buttonRefsList': this.buttonRefsList,\n index,\n };\n }\n\n getItemTextProps(props: NSTabLine.Item.Text.Props, index: number) {\n const { size: tabLineSize } = this.asProps;\n const size = props.size\n ? props.size\n : tabLineSize === 'm' ? 200 : 300;\n\n return {\n size,\n buttonRefsList: this.buttonRefsList,\n index,\n };\n }\n\n getCaretProps() {\n const { animation } = this.state;\n if (!animation) return {};\n if (animation.started) {\n return {\n style: {\n left: animation.toLeft,\n width: animation.toWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n } else {\n return {\n style: {\n left: animation.fromLeft,\n width: animation.fromWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n }\n }\n\n render() {\n const STabLine = Root;\n const SCaret = Box;\n const { styles, Children, controlsLength } = this.asProps;\n const { animation } = this.state;\n\n return sstyled(styles)(\n <STabLine render={Box} role='tablist' ref={this.containerRef}>\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n {animation && <SCaret {...this.getCaretProps()} />}\n </STabLine>,\n );\n }\n}\n\nfunction TabLineItem(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabLine.Item.Component,\n typeof TabLineRoot,\n 'Item'\n >,\n) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation, buttonRefsList, index } = props;\n const buttonRef = React.useRef<HTMLButtonElement>();\n\n buttonRefsList[index] = buttonRef;\n\n return (\n <NeighborLocation.Detect neighborLocation={neighborLocation}>\n {(neighborLocation) =>\n sstyled(styles)(\n <STabLineItem\n render={Box}\n tag='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n type='button'\n role='tab'\n ref={buttonRef}\n >\n {addonLeft ? <TabLine.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabLine.Item.Text, TabLine.Item.Addon)}\n {addonRight ? <TabLine.Item.Addon tag={addonRight} /> : null}\n </STabLineItem>,\n )}\n </NeighborLocation.Detect>\n );\n}\n\nfunction Text(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabLine.Item.Text.Component,\n typeof TabLineRoot,\n 'ItemText'\n >,\n) {\n const { styles, ellipsis = true, size, buttonRefsList, index } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={SemcoreText} ellipsis={ellipsis} size={size} hint:triggerRef={buttonRefsList[index]} />);\n}\n\nfunction Addon(\n props: Intergalactic.InternalTypings.InferComponentProps<NSTabLine.Item.Addon.Component>,\n) {\n const { styles } = props;\n const SAddon = Root;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\n/**\n * TabLine\n *\n * {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-api/|API} | {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-code/|Examples}\n */\nconst TabLine = createComponent<\n NSTabLine.Component,\n typeof TabLineRoot\n>(TabLineRoot, {\n Item: [TabLineItem, { Text, Addon }],\n});\n\nexport const wrapTabLine = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSTabLine.WrapperComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSTabLine.WrapperComponent<PropsExtending>;\n\nexport default TabLine;\n"],"mappings":";;;;;;AAAA,SAASA,gBAAgB,EAAEC,GAAG,QAAQ,0BAA0B;AAEhE,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,iBAAiB,MAAM,2CAA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AKA,CACZ9C,KAAwF,EACxF;EAAA,IAAAqD,KAAA,GAAAnB,YAAA;IAAAoB,KAAA;EACA,MAAM;IAAEpC;EAAO,CAAC,GAAGlB,KAAK;EACxB,MAAMuD,MAAM,GAC2B9G,GAAG;EAA1C,OAAA6G,KAAA,GAAO1G,OAAO,CAACsE,MAAM,CAAC,eAAChE,KAAA,CAAAmE,aAAA,CAACkC,MAAM,EAAAD,KAAA,CAAAhC,EAAA;IAAA,GAAAkC,aAAA;MAAA,OAAkB;IAAM,GAAAH,KAAA;EAAA,EAAE,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMT,OAAO,GAAGlG,eAAe,CAG7BY,WAAW,EAAE;EACbuF,IAAI,EAAE,CAACb,WAAW,EAAE;IAAEhF,IAAI;IAAE8F;EAAM,CAAC;AACrC,CAAC,CAAC;AAEF,OAAO,MAAMW,WAAW,GAA+BC,OAKnC,IAAKA,OAAqD;AAE9E,eAAed,OAAO","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabLine.type.js","names":[],"sources":["../../src/TabLine.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { NSText } from '@semcore/typography';\nimport type React from 'react';\n\ndeclare namespace NSTabLine {\n type Value = string | number | boolean;\n type Props<T extends NSTabLine.Value = NSTabLine.Value> = BoxProps &\n NeighborLocationProps & {\n /** TabLine size\n * @default m\n * */\n size?: 'm' | 'l' | false;\n /** Adds a bottom border for the entire component\n * @default true\n * */\n underlined?: boolean;\n /** Is invoked when changing the selection */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLButtonElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Value of the selected tab */\n value?: T;\n /** Default value of the selected tab\n * @default null\n * */\n defaultValue?: T;\n\n /**\n * Behavior of tabs.\n * In `auto`, changes the tab immediately when press arrow.\n * In `manual`, needs to press `space` or `enter` for select a choice.\n * @default 'auto'\n */\n behavior?: 'auto' | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value: null;\n };\n\n namespace Item {\n type Props = BoxProps &\n NeighborItemProps & {\n /** Makes a tab selected. This property is determined automatically depending on the value. */\n selected?: boolean;\n /** Disabled state */\n disabled?: boolean;\n /** Tab value */\n value?: NSTabLine.Value;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n };\n\n namespace Text {\n type Props = NSText.Props;\n type Component = NSText.Component;\n }\n\n namespace Addon {\n type Component = typeof Box;\n }\n\n type Component = Intergalactic.Component<'div', Props, {}, [handlers: NSTabLine.Handlers]> & {\n Text: Text.Component;\n Addon: Addon.Component;\n };\n }\n\n type WrapperComponent<PropsExtending = {}> = (<\n V extends Value,\n Tag extends Intergalactic.Tag = 'div',\n >(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n Props<V>,\n Ctx,\n [handlers: Handlers]\n > &\n PropsExtending,\n ) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;\n\n type Component = WrapperComponent & {\n Item: Item.Component;\n };\n}\n\n/** @deprecated It will be removed in v18. */\nexport type TabLineValue = NSTabLine.Value;\n/** @deprecated It will be removed in v18. */\nexport type TabLineProps<T extends TabLineValue = TabLineValue> = NSTabLine.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type TabLineItemProps = NSTabLine.Item.Props;\n/** @deprecated It will be removed in v18. */\nexport type TabLineContext = NSTabLine.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type TabLineHandlers = NSTabLine.Handlers;\n\nexport type { NSTabLine };\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"TabLine.type.js","names":[],"sources":["../../src/TabLine.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { NSText } from '@semcore/typography';\nimport type React from 'react';\n\ndeclare namespace NSTabLine {\n type Value = string | number | boolean;\n type Props<T extends NSTabLine.Value = NSTabLine.Value> = BoxProps &\n NeighborLocationProps & {\n /** TabLine size\n * @default m\n * */\n size?: 'm' | 'l' | false;\n /** Adds a bottom border for the entire component\n * @default true\n * */\n underlined?: boolean;\n /** Is invoked when changing the selection */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLButtonElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Value of the selected tab */\n value?: T;\n /** Default value of the selected tab\n * @default null\n * */\n defaultValue?: T;\n\n /**\n * Behavior of tabs.\n * In `auto`, changes the tab immediately when press arrow.\n * In `manual`, needs to press `space` or `enter` for select a choice.\n * @default 'auto'\n */\n behavior?: 'auto' | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value: null;\n };\n\n type DefaultProps = {\n defaultValue: 0;\n size: 'm';\n underlined: true;\n behavior: 'auto';\n };\n\n namespace Item {\n type Props = BoxProps &\n NeighborItemProps & {\n /** Makes a tab selected. This property is determined automatically depending on the value. */\n selected?: boolean;\n /** Disabled state */\n disabled?: boolean;\n /** Tab value */\n value?: NSTabLine.Value;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n };\n\n namespace Text {\n type Props = NSText.Props;\n type Component = NSText.Component;\n }\n\n namespace Addon {\n type Component = typeof Box;\n }\n\n type Component = Intergalactic.Component<'div', Props, {}, [handlers: NSTabLine.Handlers]> & {\n Text: Text.Component;\n Addon: Addon.Component;\n };\n }\n\n type WrapperComponent<PropsExtending = {}> = (<\n V extends Value,\n Tag extends Intergalactic.Tag = 'div',\n >(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n Props<V>,\n Ctx,\n [handlers: Handlers]\n > &\n PropsExtending,\n ) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;\n\n type Component = WrapperComponent & {\n Item: Item.Component;\n };\n}\n\n/** @deprecated It will be removed in v18. */\nexport type TabLineValue = NSTabLine.Value;\n/** @deprecated It will be removed in v18. */\nexport type TabLineProps<T extends TabLineValue = TabLineValue> = NSTabLine.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type TabLineItemProps = NSTabLine.Item.Props;\n/** @deprecated It will be removed in v18. */\nexport type TabLineContext = NSTabLine.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type TabLineHandlers = NSTabLine.Handlers;\n\nexport type { NSTabLine };\n"],"mappings":"","ignoreList":[]}
|
package/lib/esm/TabLine.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { sstyled, Component, assignProps, createComponent } from "@semcore/core";
|
|
3
3
|
import { Box, NeighborLocation } from "@semcore/base-components";
|
|
4
4
|
import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
@@ -10,22 +10,22 @@ const style = (
|
|
|
10
10
|
/*__reshadow_css_start__*/
|
|
11
11
|
(sstyled.insert(
|
|
12
12
|
/*__inner_css_start__*/
|
|
13
|
-
'.
|
|
13
|
+
'.___STabLine_1de7a_gg_{position:relative;display:flex;width:100%;max-width:100%}.___STabLine_1de7a_gg_.__underlined_1de7a_gg_{border-bottom:1px solid var(--intergalactic-border-primary,#000c0829)}@supports (color:color(display-p3 0 0 0%)){.___STabLine_1de7a_gg_.__underlined_1de7a_gg_{border-bottom:1px solid var(--intergalactic-border-primary,#000c0829)}@media (color-gamut:p3){.___STabLine_1de7a_gg_.__underlined_1de7a_gg_{border-bottom:1px solid var(--intergalactic-border-primary,color(display-p3 .00798 .04498 .03219/.161))}}}.___STabLineItem_1de7a_gg_{display:inline-flex;align-items:center;justify-content:center;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;-webkit-text-decoration:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;border:none;background:#0000;color:var(--intergalactic-text-primary,#010500e5);margin-right:var(--intergalactic-spacing-4x,16px);font-weight:var(--intergalactic-medium,500)}.___STabLineItem_1de7a_gg_::-moz-focus-inner{border:none;padding:0}.___STabLineItem_1de7a_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabLineItem_1de7a_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___STabLineItem_1de7a_gg_:after,.___STabLineItem_1de7a_gg_:before{content:"";position:absolute;left:0;bottom:-1px;height:3px;width:100%;background-color:initial}.___STabLineItem_1de7a_gg_:before{transition:background-color calc(var(--intergalactic-duration-control, 200)*1ms) ease-in-out}@media (hover:hover){.___STabLineItem_1de7a_gg_:hover:before{background-color:var(--intergalactic-border-primary,#000c0829)}@supports (color:color(display-p3 0 0 0%)){.___STabLineItem_1de7a_gg_:hover:before{background-color:var(--intergalactic-border-primary,#000c0829)}@media (color-gamut:p3){.___STabLineItem_1de7a_gg_:hover:before{background-color:var(--intergalactic-border-primary,color(display-p3 .00798 .04498 .03219/.161))}}}}.___STabLineItem_1de7a_gg_.__selected_1de7a_gg_:after{transition-delay:calc(var(--intergalactic-duration-control, 200)*1ms);background-color:var(--intergalactic-border-info-active,#8796ef)}.___STabLineItem_1de7a_gg_ .___SAddon_1de7a_gg_:not(:last-child),.___STabLineItem_1de7a_gg_ .___SText_1de7a_gg_:not(:last-child){margin-right:var(--intergalactic-spacing-2x,8px)}.___SCaret_1de7a_gg_{position:absolute;bottom:-1px;height:3px;background:var(--intergalactic-border-info-active,#8796ef);transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___STabLineItem_1de7a_gg_.__selected_1de7a_gg_{flex-shrink:0}.___STabLineItem_1de7a_gg_.__disabled_1de7a_gg_{opacity:var(--intergalactic-disabled-opacity,.4);cursor:default;pointer-events:none}.___SAddon_1de7a_gg_{display:inline-flex;align-items:center;justify-content:center}.___STabLineItem_1de7a_gg_._size_m_1de7a_gg_{height:28px;min-width:18px}.___STabLineItem_1de7a_gg_._size_l_1de7a_gg_{height:40px;min-width:26px}.___STabLineItem_1de7a_gg_._neighborLocation_left_1de7a_gg_{margin-right:0}@media (prefers-reduced-motion){.___STabLineItem_1de7a_gg_.__selected_1de7a_gg_:after,.___STabLineItem_1de7a_gg_:after,.___STabLineItem_1de7a_gg_:before{transition:none}.___SCaret_1de7a_gg_{display:none}}',
|
|
14
14
|
/*__inner_css_end__*/
|
|
15
|
-
"
|
|
15
|
+
"1de7a_gg_"
|
|
16
16
|
), /*__reshadow_css_end__*/
|
|
17
17
|
{
|
|
18
|
-
"__STabLine": "
|
|
19
|
-
"_underlined": "
|
|
20
|
-
"__SCaret": "
|
|
21
|
-
"__STabLineItem": "
|
|
22
|
-
"_selected": "
|
|
23
|
-
"_disabled": "
|
|
24
|
-
"__SAddon": "
|
|
25
|
-
"_size_m": "
|
|
26
|
-
"_size_l": "
|
|
27
|
-
"_neighborLocation_left": "
|
|
28
|
-
"__SText": "
|
|
18
|
+
"__STabLine": "___STabLine_1de7a_gg_",
|
|
19
|
+
"_underlined": "__underlined_1de7a_gg_",
|
|
20
|
+
"__SCaret": "___SCaret_1de7a_gg_",
|
|
21
|
+
"__STabLineItem": "___STabLineItem_1de7a_gg_",
|
|
22
|
+
"_selected": "__selected_1de7a_gg_",
|
|
23
|
+
"_disabled": "__disabled_1de7a_gg_",
|
|
24
|
+
"__SAddon": "___SAddon_1de7a_gg_",
|
|
25
|
+
"_size_m": "_size_m_1de7a_gg_",
|
|
26
|
+
"_size_l": "_size_l_1de7a_gg_",
|
|
27
|
+
"_neighborLocation_left": "_neighborLocation_left_1de7a_gg_",
|
|
28
|
+
"__SText": "___SText_1de7a_gg_"
|
|
29
29
|
})
|
|
30
30
|
);
|
|
31
31
|
class TabLineRoot extends Component {
|
|
@@ -182,7 +182,7 @@ class TabLineRoot extends Component {
|
|
|
182
182
|
_defineProperty(TabLineRoot, "displayName", "TabLine");
|
|
183
183
|
_defineProperty(TabLineRoot, "style", style);
|
|
184
184
|
_defineProperty(TabLineRoot, "defaultProps", {
|
|
185
|
-
defaultValue:
|
|
185
|
+
defaultValue: 0,
|
|
186
186
|
size: "m",
|
|
187
187
|
underlined: true,
|
|
188
188
|
behavior: "auto"
|
package/lib/types/TabLine.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Intergalactic } from '@semcore/core';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { NSTabLine } from './TabLine.type';
|
|
4
|
+
/**
|
|
5
|
+
* TabLine
|
|
6
|
+
*
|
|
7
|
+
* {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-api/|API} | {@link https://developer.semrush.com/intergalactic/components/tab-line/tab-line-code/|Examples}
|
|
8
|
+
*/
|
|
4
9
|
declare const TabLine: NSTabLine.Component;
|
|
5
10
|
export declare const wrapTabLine: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.UntypeRefAndTag<Intergalactic.InternalTypings.ComponentPropsNesting<NSTabLine.WrapperComponent>> & PropsExtending) => React.ReactNode) => NSTabLine.WrapperComponent<PropsExtending>;
|
|
6
11
|
export default TabLine;
|
|
@@ -35,6 +35,12 @@ declare namespace NSTabLine {
|
|
|
35
35
|
type Handlers = {
|
|
36
36
|
value: null;
|
|
37
37
|
};
|
|
38
|
+
type DefaultProps = {
|
|
39
|
+
defaultValue: 0;
|
|
40
|
+
size: 'm';
|
|
41
|
+
underlined: true;
|
|
42
|
+
behavior: 'auto';
|
|
43
|
+
};
|
|
38
44
|
namespace Item {
|
|
39
45
|
type Props = BoxProps & NeighborItemProps & {
|
|
40
46
|
/** Makes a tab selected. This property is determined automatically depending on the value. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/tab-line",
|
|
3
3
|
"description": "Semrush TabLine Component",
|
|
4
|
-
"version": "17.
|
|
4
|
+
"version": "17.2.0-prerelease.3",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"require": "./lib/cjs/index.js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/typography": "^17.
|
|
17
|
+
"@semcore/typography": "^17.2.0-prerelease.3"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@semcore/base-components": "^17.0
|
|
20
|
+
"@semcore/base-components": "^17.2.0"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"directory": "semcore/tab-line"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@semcore/core": "17.
|
|
29
|
-
"@semcore/base-components": "17.0
|
|
28
|
+
"@semcore/core": "17.2.0-prerelease.3",
|
|
29
|
+
"@semcore/base-components": "17.2.0-prerelease.3",
|
|
30
30
|
"@semcore/testing-utils": "1.0.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|