@semcore/tab-line 17.0.0 → 17.0.2-prerelease.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/lib/cjs/TabLine.js +35 -30
- package/lib/cjs/TabLine.js.map +1 -1
- package/lib/cjs/TabLine.type.js +2 -0
- package/lib/cjs/TabLine.type.js.map +1 -0
- package/lib/cjs/index.js +13 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/es6/TabLine.js +37 -32
- package/lib/es6/TabLine.js.map +1 -1
- package/lib/es6/TabLine.type.js +2 -0
- package/lib/es6/TabLine.type.js.map +1 -0
- package/lib/es6/index.js +2 -2
- package/lib/es6/index.js.map +1 -1
- package/lib/esm/TabLine.mjs +37 -31
- package/lib/esm/TabLine.type.mjs +1 -0
- package/lib/esm/index.mjs +1 -0
- package/lib/types/TabLine.d.ts +6 -0
- package/lib/types/TabLine.type.d.ts +80 -0
- package/lib/types/index.d.ts +2 -92
- package/package.json +7 -7
- package/vite.config.ts +1 -1
- package/lib/cjs/index.d.js +0 -2
- package/lib/cjs/index.d.js.map +0 -1
- package/lib/es6/index.d.js +0 -2
- package/lib/es6/index.d.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [17.0.2] - 2026-04-29
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Rewrite component to TS.
|
|
10
|
+
|
|
11
|
+
## [17.0.1] - 2026-04-16
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Build processing to correct extract styles.
|
|
16
|
+
|
|
5
17
|
## [17.0.0] - 2026-04-15
|
|
6
18
|
|
|
7
19
|
### BREAK
|
package/lib/cjs/TabLine.js
CHANGED
|
@@ -13,32 +13,21 @@ 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_1v9ch_gg_{position:relative;display:flex;width:100%;max-width:100%}.___STabLine_1v9ch_gg_.__underlined_1v9ch_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabLineItem_1v9ch_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:0;background:0 0;color:var(--intergalactic-text-primary, #191b23);margin-right:var(--intergalactic-spacing-4x, 16px);font-weight:var(--intergalactic-medium, 500)}.___STabLineItem_1v9ch_gg_::-moz-focus-inner{border:0;padding:0}.___STabLineItem_1v9ch_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabLineItem_1v9ch_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___STabLineItem_1v9ch_gg_::after,.___STabLineItem_1v9ch_gg_::before{content:\"\";position:absolute;left:0;bottom:-1px;height:3px;width:100%;background-color:transparent}.___STabLineItem_1v9ch_gg_::before{transition:background-color calc(var(--intergalactic-duration-control, 200)*1ms) ease-in-out}@media (hover:hover){.___STabLineItem_1v9ch_gg_:hover::before{background-color:var(--intergalactic-border-primary, #c4c7cf)}}.___STabLineItem_1v9ch_gg_.__selected_1v9ch_gg_::after{transition-delay:calc(var(--intergalactic-duration-control, 200)*1ms);background-color:var(--intergalactic-border-info-active, #006dca)}.___STabLineItem_1v9ch_gg_ .___SAddon_1v9ch_gg_:not(:last-child),.___STabLineItem_1v9ch_gg_ .___SText_1v9ch_gg_:not(:last-child){margin-right:var(--intergalactic-spacing-2x, 8px)}.___SCaret_1v9ch_gg_{position:absolute;bottom:-1px;height:3px;background:var(--intergalactic-border-info-active, #006dca);transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___STabLineItem_1v9ch_gg_.__selected_1v9ch_gg_{flex-shrink:0}.___STabLineItem_1v9ch_gg_.__disabled_1v9ch_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SAddon_1v9ch_gg_{display:inline-flex;align-items:center;justify-content:center}.___STabLineItem_1v9ch_gg_._size_m_1v9ch_gg_{height:28px;min-width:18px}.___STabLineItem_1v9ch_gg_._size_l_1v9ch_gg_{height:40px;min-width:26px}.___STabLineItem_1v9ch_gg_._neighborLocation_left_1v9ch_gg_{margin-right:0}@media (prefers-reduced-motion){.___STabLineItem_1v9ch_gg_.__selected_1v9ch_gg_::after,.___STabLineItem_1v9ch_gg_::after,.___STabLineItem_1v9ch_gg_::before{transition:none}.___SCaret_1v9ch_gg_{display:none}}", /*__inner_css_end__*/"1v9ch_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_1v9ch_gg_",
|
|
20
|
+
"_underlined": "__underlined_1v9ch_gg_",
|
|
21
|
+
"__SCaret": "___SCaret_1v9ch_gg_",
|
|
22
|
+
"__STabLineItem": "___STabLineItem_1v9ch_gg_",
|
|
23
|
+
"_selected": "__selected_1v9ch_gg_",
|
|
24
|
+
"_disabled": "__disabled_1v9ch_gg_",
|
|
25
|
+
"__SAddon": "___SAddon_1v9ch_gg_",
|
|
26
|
+
"_size_m": "_size_m_1v9ch_gg_",
|
|
27
|
+
"_size_l": "_size_l_1v9ch_gg_",
|
|
28
|
+
"_neighborLocation_left": "_neighborLocation_left_1v9ch_gg_",
|
|
29
|
+
"__SText": "___SText_1v9ch_gg_"
|
|
30
30
|
});
|
|
31
|
-
const optionsA11yEnhance = {
|
|
32
|
-
onNeighborChange: (neighborElement, props) => {
|
|
33
|
-
if (neighborElement) {
|
|
34
|
-
neighborElement.focus();
|
|
35
|
-
if (props.behavior === 'auto') {
|
|
36
|
-
neighborElement.click();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
childSelector: ['role', 'tab']
|
|
41
|
-
};
|
|
42
31
|
class TabLineRoot extends _core.Component {
|
|
43
32
|
constructor(...args) {
|
|
44
33
|
super(...args);
|
|
@@ -48,7 +37,7 @@ class TabLineRoot extends _core.Component {
|
|
|
48
37
|
(0, _defineProperty2.default)(this, "prevValue", undefined);
|
|
49
38
|
(0, _defineProperty2.default)(this, "itemRefs", {});
|
|
50
39
|
(0, _defineProperty2.default)(this, "containerRef", /*#__PURE__*/_react.default.createRef());
|
|
51
|
-
(0, _defineProperty2.default)(this, "animationStartTimeout",
|
|
40
|
+
(0, _defineProperty2.default)(this, "animationStartTimeout", null);
|
|
52
41
|
(0, _defineProperty2.default)(this, "buttonRefsList", []);
|
|
53
42
|
(0, _defineProperty2.default)(this, "handleAnimationStart", () => {
|
|
54
43
|
if (this.state.animation?.started === false) {
|
|
@@ -84,11 +73,14 @@ class TabLineRoot extends _core.Component {
|
|
|
84
73
|
this.prevValue = this.asProps.value;
|
|
85
74
|
}
|
|
86
75
|
componentWillUnmount() {
|
|
87
|
-
|
|
76
|
+
if (this.animationStartTimeout) {
|
|
77
|
+
clearTimeout(this.animationStartTimeout);
|
|
78
|
+
}
|
|
88
79
|
}
|
|
89
80
|
animate() {
|
|
90
|
-
|
|
91
|
-
const
|
|
81
|
+
if (this.prevValue === undefined || this.asProps.value === undefined) return;
|
|
82
|
+
const fromNode = this.itemRefs[this.prevValue.toString()];
|
|
83
|
+
const toNode = this.itemRefs[this.asProps.value.toString()];
|
|
92
84
|
const containerNode = this.containerRef.current;
|
|
93
85
|
if (!fromNode || !toNode || !containerNode) return;
|
|
94
86
|
const containerRect = containerNode.getBoundingClientRect();
|
|
@@ -104,7 +96,9 @@ class TabLineRoot extends _core.Component {
|
|
|
104
96
|
this.setState({
|
|
105
97
|
animation
|
|
106
98
|
});
|
|
107
|
-
|
|
99
|
+
if (this.animationStartTimeout) {
|
|
100
|
+
clearTimeout(this.animationStartTimeout);
|
|
101
|
+
}
|
|
108
102
|
this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);
|
|
109
103
|
}
|
|
110
104
|
getItemProps(props, index) {
|
|
@@ -120,7 +114,8 @@ class TabLineRoot extends _core.Component {
|
|
|
120
114
|
'tabIndex': isSelected ? 0 : -1,
|
|
121
115
|
'aria-selected': isSelected,
|
|
122
116
|
'ref': node => {
|
|
123
|
-
|
|
117
|
+
if (props.value === undefined) return;
|
|
118
|
+
this.itemRefs[props.value.toString()] = node;
|
|
124
119
|
},
|
|
125
120
|
'buttonRefsList': this.buttonRefsList,
|
|
126
121
|
index
|
|
@@ -193,7 +188,17 @@ class TabLineRoot extends _core.Component {
|
|
|
193
188
|
underlined: true,
|
|
194
189
|
behavior: 'auto'
|
|
195
190
|
});
|
|
196
|
-
(0, _defineProperty2.default)(TabLineRoot, "enhance", [(0, _a11yEnhance.default)(
|
|
191
|
+
(0, _defineProperty2.default)(TabLineRoot, "enhance", [(0, _a11yEnhance.default)({
|
|
192
|
+
onNeighborChange: (neighborElement, props) => {
|
|
193
|
+
if (neighborElement) {
|
|
194
|
+
neighborElement.focus();
|
|
195
|
+
if (props.behavior === 'auto') {
|
|
196
|
+
neighborElement.click();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
childSelector: ['role', 'tab']
|
|
201
|
+
})]);
|
|
197
202
|
function TabLineItem(props) {
|
|
198
203
|
var _ref2 = arguments[0];
|
|
199
204
|
const STabLineItem = _baseComponents.Box;
|
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","optionsA11yEnhance","onNeighborChange","neighborElement","props","focus","behavior","click","childSelector","TabLineRoot","Component","constructor","args","_defineProperty2","default","animation","undefined","React","createRef","state","started","setState","value","e","handlers","uncontrolledProps","componentDidUpdate","prevValue","asProps","animate","componentDidMount","componentWillUnmount","clearTimeout","animationStartTimeout","fromNode","itemRefs","toNode","containerNode","containerRef","current","containerRect","getBoundingClientRect","fromRect","toRect","fromLeft","x","fromWidth","width","toLeft","toWidth","setTimeout","handleAnimationStart","getItemProps","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","a11yEnhance","TabLineItem","_ref2","arguments[0]","STabLineItem","addonLeft","addonRight","neighborLocation","buttonRef","useRef","Detect","_ref6","TabLine","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","ellipsis","SText","UikitText","_ref4","_ref8","SAddon","createComponent","wrapTabLine","wrapper","exports","_default"],"sources":["../../src/TabLine.jsx"],"sourcesContent":["import { NeighborLocation, Box } from '@semcore/base-components';\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 UikitText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/tab-line.shadow.css';\n\nconst optionsA11yEnhance = {\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};\n\nclass TabLineRoot extends Component {\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(optionsA11yEnhance)];\n state = { animation: null };\n prevValue = undefined;\n itemRefs = {};\n containerRef = React.createRef();\n animationStartTimeout = -1;\n buttonRefsList = [];\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 clearTimeout(this.animationStartTimeout);\n }\n\n animate() {\n const fromNode = this.itemRefs[this.prevValue];\n const toNode = this.itemRefs[this.asProps.value];\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 clearTimeout(this.animationStartTimeout);\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) => (e) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props, index) {\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) => {\n this.itemRefs[props.value] = node;\n },\n 'buttonRefsList': this.buttonRefsList,\n index,\n };\n }\n\n getItemTextProps(props, index) {\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(props) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation, buttonRefsList, index } = props;\n const buttonRef = React.useRef();\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(props) {\n const { styles, ellipsis = true, size, buttonRefsList, index } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={UikitText} ellipsis={ellipsis} size={size} hint:triggerRef={buttonRefsList[index]} />);\n}\n\nfunction Addon(props) {\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});\n\nexport const wrapTabLine = (wrapper) => wrapper;\n\nexport default TabLine;\n"],"mappings":";;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,eAAA,GAAAD,OAAA;AAEA,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;AAI1B,MAAMC,kBAAkB,GAAG;EACzBC,gBAAgB,EAAEA,CAACC,eAAe,EAAEC,KAAK,KAAK;IAC5C,IAAID,eAAe,EAAE;MACnBA,eAAe,CAACE,KAAK,CAAC,CAAC;MACvB,IAAID,KAAK,CAACE,QAAQ,KAAK,MAAM,EAAE;QAC7BH,eAAe,CAACI,KAAK,CAAC,CAAC;MACzB;IACF;EACF,CAAC;EACDC,aAAa,EAAE,CAAC,MAAM,EAAE,KAAK;AAC/B,CAAC;AAED,MAAMC,WAAW,SAASC,eAAS,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,iBAW1B;MAAEC,SAAS,EAAE;IAAK,C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;IAAEgB,IAAI;IAAEH;EAAM,CAAC;AACrC,CAAC,CAAC;AAEK,MAAMa,WAAW,GAAIC,OAAO,IAAKA,OAAO;AAACC,OAAA,CAAAF,WAAA,GAAAA,WAAA;AAAA,IAAAG,QAAA,GAAAD,OAAA,CAAA/F,OAAA,GAEjC8E,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> {\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":";;;;;;;;AA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,CAAAF,WAAA,GAAAA,WAAA;AAAA,IAAAG,QAAA,GAAAD,OAAA,CAAAvG,OAAA,GAEhEsF,OAAO","ignoreList":[]}
|
|
@@ -0,0 +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":[]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -4,22 +4,31 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
var _exportNames = {
|
|
7
|
+
var _exportNames = {
|
|
8
|
+
wrapTabLine: true
|
|
9
|
+
};
|
|
8
10
|
Object.defineProperty(exports, "default", {
|
|
9
11
|
enumerable: true,
|
|
10
12
|
get: function () {
|
|
11
13
|
return _TabLine.default;
|
|
12
14
|
}
|
|
13
15
|
});
|
|
16
|
+
Object.defineProperty(exports, "wrapTabLine", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _TabLine.wrapTabLine;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
14
22
|
var _TabLine = _interopRequireWildcard(require("./TabLine"));
|
|
15
|
-
|
|
23
|
+
var _TabLine2 = require("./TabLine.type");
|
|
24
|
+
Object.keys(_TabLine2).forEach(function (key) {
|
|
16
25
|
if (key === "default" || key === "__esModule") return;
|
|
17
26
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
18
|
-
if (key in exports && exports[key] ===
|
|
27
|
+
if (key in exports && exports[key] === _TabLine2[key]) return;
|
|
19
28
|
Object.defineProperty(exports, key, {
|
|
20
29
|
enumerable: true,
|
|
21
30
|
get: function () {
|
|
22
|
-
return
|
|
31
|
+
return _TabLine2[key];
|
|
23
32
|
}
|
|
24
33
|
});
|
|
25
34
|
});
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_TabLine","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.
|
|
1
|
+
{"version":3,"file":"index.js","names":["_TabLine","_interopRequireWildcard","require","_TabLine2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.ts"],"sourcesContent":["export { default, wrapTabLine } from './TabLine';\nexport * from './TabLine.type';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,SAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,SAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,SAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/lib/es6/TabLine.js
CHANGED
|
@@ -8,35 +8,24 @@ import { NeighborLocation, Box } from '@semcore/base-components';
|
|
|
8
8
|
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
9
9
|
import addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';
|
|
10
10
|
import a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';
|
|
11
|
-
import { Text as
|
|
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_1v9ch_gg_{position:relative;display:flex;width:100%;max-width:100%}.___STabLine_1v9ch_gg_.__underlined_1v9ch_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabLineItem_1v9ch_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:0;background:0 0;color:var(--intergalactic-text-primary, #191b23);margin-right:var(--intergalactic-spacing-4x, 16px);font-weight:var(--intergalactic-medium, 500)}.___STabLineItem_1v9ch_gg_::-moz-focus-inner{border:0;padding:0}.___STabLineItem_1v9ch_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabLineItem_1v9ch_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___STabLineItem_1v9ch_gg_::after,.___STabLineItem_1v9ch_gg_::before{content:\"\";position:absolute;left:0;bottom:-1px;height:3px;width:100%;background-color:transparent}.___STabLineItem_1v9ch_gg_::before{transition:background-color calc(var(--intergalactic-duration-control, 200)*1ms) ease-in-out}@media (hover:hover){.___STabLineItem_1v9ch_gg_:hover::before{background-color:var(--intergalactic-border-primary, #c4c7cf)}}.___STabLineItem_1v9ch_gg_.__selected_1v9ch_gg_::after{transition-delay:calc(var(--intergalactic-duration-control, 200)*1ms);background-color:var(--intergalactic-border-info-active, #006dca)}.___STabLineItem_1v9ch_gg_ .___SAddon_1v9ch_gg_:not(:last-child),.___STabLineItem_1v9ch_gg_ .___SText_1v9ch_gg_:not(:last-child){margin-right:var(--intergalactic-spacing-2x, 8px)}.___SCaret_1v9ch_gg_{position:absolute;bottom:-1px;height:3px;background:var(--intergalactic-border-info-active, #006dca);transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___STabLineItem_1v9ch_gg_.__selected_1v9ch_gg_{flex-shrink:0}.___STabLineItem_1v9ch_gg_.__disabled_1v9ch_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SAddon_1v9ch_gg_{display:inline-flex;align-items:center;justify-content:center}.___STabLineItem_1v9ch_gg_._size_m_1v9ch_gg_{height:28px;min-width:18px}.___STabLineItem_1v9ch_gg_._size_l_1v9ch_gg_{height:40px;min-width:26px}.___STabLineItem_1v9ch_gg_._neighborLocation_left_1v9ch_gg_{margin-right:0}@media (prefers-reduced-motion){.___STabLineItem_1v9ch_gg_.__selected_1v9ch_gg_::after,.___STabLineItem_1v9ch_gg_::after,.___STabLineItem_1v9ch_gg_::before{transition:none}.___SCaret_1v9ch_gg_{display:none}}", /*__inner_css_end__*/"1v9ch_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_1v9ch_gg_",
|
|
18
|
+
"_underlined": "__underlined_1v9ch_gg_",
|
|
19
|
+
"__SCaret": "___SCaret_1v9ch_gg_",
|
|
20
|
+
"__STabLineItem": "___STabLineItem_1v9ch_gg_",
|
|
21
|
+
"_selected": "__selected_1v9ch_gg_",
|
|
22
|
+
"_disabled": "__disabled_1v9ch_gg_",
|
|
23
|
+
"__SAddon": "___SAddon_1v9ch_gg_",
|
|
24
|
+
"_size_m": "_size_m_1v9ch_gg_",
|
|
25
|
+
"_size_l": "_size_l_1v9ch_gg_",
|
|
26
|
+
"_neighborLocation_left": "_neighborLocation_left_1v9ch_gg_",
|
|
27
|
+
"__SText": "___SText_1v9ch_gg_"
|
|
28
28
|
});
|
|
29
|
-
const optionsA11yEnhance = {
|
|
30
|
-
onNeighborChange: (neighborElement, props) => {
|
|
31
|
-
if (neighborElement) {
|
|
32
|
-
neighborElement.focus();
|
|
33
|
-
if (props.behavior === 'auto') {
|
|
34
|
-
neighborElement.click();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
childSelector: ['role', 'tab']
|
|
39
|
-
};
|
|
40
29
|
class TabLineRoot extends Component {
|
|
41
30
|
constructor(...args) {
|
|
42
31
|
super(...args);
|
|
@@ -46,7 +35,7 @@ class TabLineRoot extends Component {
|
|
|
46
35
|
_defineProperty(this, "prevValue", undefined);
|
|
47
36
|
_defineProperty(this, "itemRefs", {});
|
|
48
37
|
_defineProperty(this, "containerRef", /*#__PURE__*/React.createRef());
|
|
49
|
-
_defineProperty(this, "animationStartTimeout",
|
|
38
|
+
_defineProperty(this, "animationStartTimeout", null);
|
|
50
39
|
_defineProperty(this, "buttonRefsList", []);
|
|
51
40
|
_defineProperty(this, "handleAnimationStart", () => {
|
|
52
41
|
if (this.state.animation?.started === false) {
|
|
@@ -82,11 +71,14 @@ class TabLineRoot extends Component {
|
|
|
82
71
|
this.prevValue = this.asProps.value;
|
|
83
72
|
}
|
|
84
73
|
componentWillUnmount() {
|
|
85
|
-
|
|
74
|
+
if (this.animationStartTimeout) {
|
|
75
|
+
clearTimeout(this.animationStartTimeout);
|
|
76
|
+
}
|
|
86
77
|
}
|
|
87
78
|
animate() {
|
|
88
|
-
|
|
89
|
-
const
|
|
79
|
+
if (this.prevValue === undefined || this.asProps.value === undefined) return;
|
|
80
|
+
const fromNode = this.itemRefs[this.prevValue.toString()];
|
|
81
|
+
const toNode = this.itemRefs[this.asProps.value.toString()];
|
|
90
82
|
const containerNode = this.containerRef.current;
|
|
91
83
|
if (!fromNode || !toNode || !containerNode) return;
|
|
92
84
|
const containerRect = containerNode.getBoundingClientRect();
|
|
@@ -102,7 +94,9 @@ class TabLineRoot extends Component {
|
|
|
102
94
|
this.setState({
|
|
103
95
|
animation
|
|
104
96
|
});
|
|
105
|
-
|
|
97
|
+
if (this.animationStartTimeout) {
|
|
98
|
+
clearTimeout(this.animationStartTimeout);
|
|
99
|
+
}
|
|
106
100
|
this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);
|
|
107
101
|
}
|
|
108
102
|
getItemProps(props, index) {
|
|
@@ -118,7 +112,8 @@ class TabLineRoot extends Component {
|
|
|
118
112
|
'tabIndex': isSelected ? 0 : -1,
|
|
119
113
|
'aria-selected': isSelected,
|
|
120
114
|
'ref': node => {
|
|
121
|
-
|
|
115
|
+
if (props.value === undefined) return;
|
|
116
|
+
this.itemRefs[props.value.toString()] = node;
|
|
122
117
|
},
|
|
123
118
|
'buttonRefsList': this.buttonRefsList,
|
|
124
119
|
index
|
|
@@ -191,7 +186,17 @@ _defineProperty(TabLineRoot, "defaultProps", {
|
|
|
191
186
|
underlined: true,
|
|
192
187
|
behavior: 'auto'
|
|
193
188
|
});
|
|
194
|
-
_defineProperty(TabLineRoot, "enhance", [a11yEnhance(
|
|
189
|
+
_defineProperty(TabLineRoot, "enhance", [a11yEnhance({
|
|
190
|
+
onNeighborChange: (neighborElement, props) => {
|
|
191
|
+
if (neighborElement) {
|
|
192
|
+
neighborElement.focus();
|
|
193
|
+
if (props.behavior === 'auto') {
|
|
194
|
+
neighborElement.click();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
childSelector: ['role', 'tab']
|
|
199
|
+
})]);
|
|
195
200
|
function TabLineItem(props) {
|
|
196
201
|
var _ref2 = arguments[0];
|
|
197
202
|
const STabLineItem = Box;
|
|
@@ -236,7 +241,7 @@ function Text(props) {
|
|
|
236
241
|
buttonRefsList,
|
|
237
242
|
index
|
|
238
243
|
} = props;
|
|
239
|
-
const SText =
|
|
244
|
+
const SText = SemcoreText;
|
|
240
245
|
return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SText, _ref7.cn("SText", {
|
|
241
246
|
..._assignProps3({
|
|
242
247
|
"ellipsis": ellipsis,
|
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","UikitText","React","style","_sstyled","insert","optionsA11yEnhance","onNeighborChange","neighborElement","props","focus","behavior","click","childSelector","TabLineRoot","constructor","args","_defineProperty","animation","undefined","createRef","state","started","setState","value","e","handlers","uncontrolledProps","componentDidUpdate","prevValue","asProps","animate","componentDidMount","componentWillUnmount","clearTimeout","animationStartTimeout","fromNode","itemRefs","toNode","containerNode","containerRef","current","containerRect","getBoundingClientRect","fromRect","toRect","fromLeft","x","fromWidth","width","toLeft","toWidth","setTimeout","handleAnimationStart","getItemProps","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","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.jsx"],"sourcesContent":["import { NeighborLocation, Box } from '@semcore/base-components';\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 UikitText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/tab-line.shadow.css';\n\nconst optionsA11yEnhance = {\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};\n\nclass TabLineRoot extends Component {\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(optionsA11yEnhance)];\n state = { animation: null };\n prevValue = undefined;\n itemRefs = {};\n containerRef = React.createRef();\n animationStartTimeout = -1;\n buttonRefsList = [];\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 clearTimeout(this.animationStartTimeout);\n }\n\n animate() {\n const fromNode = this.itemRefs[this.prevValue];\n const toNode = this.itemRefs[this.asProps.value];\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 clearTimeout(this.animationStartTimeout);\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) => (e) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props, index) {\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) => {\n this.itemRefs[props.value] = node;\n },\n 'buttonRefsList': this.buttonRefsList,\n index,\n };\n }\n\n getItemTextProps(props, index) {\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(props) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation, buttonRefsList, index } = props;\n const buttonRef = React.useRef();\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(props) {\n const { styles, ellipsis = true, size, buttonRefsList, index } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={UikitText} ellipsis={ellipsis} size={size} hint:triggerRef={buttonRefsList[index]} />);\n}\n\nfunction Addon(props) {\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});\n\nexport const wrapTabLine = (wrapper) => wrapper;\n\nexport default TabLine;\n"],"mappings":";;;;;;AAAA,SAASA,gBAAgB,EAAEC,GAAG,QAAQ,0BAA0B;AAChE,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,IAAI,IAAIC,SAAS,QAAQ,qBAAqB;AACvD,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;AAI1B,MAAMC,kBAAkB,GAAG;EACzBC,gBAAgB,EAAEA,CAACC,eAAe,EAAEC,KAAK,KAAK;IAC5C,IAAID,eAAe,EAAE;MACnBA,eAAe,CAACE,K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TextChildren","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,M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1C,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,MAAMT,OAAO,GAAGlG,eAAe,CAACY,WAAW,EAAE;EAC3CuF,IAAI,EAAE,CAACb,WAAW,EAAE;IAAEhF,IAAI;IAAE8F;EAAM,CAAC;AACrC,CAAC,CAAmC;AAEpC,OAAO,MAAMW,WAAW,GAA+BC,OAKnC,IAAKA,OAAqD;AAE9E,eAAed,OAAO","ignoreList":[]}
|
|
@@ -0,0 +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":[]}
|
package/lib/es6/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default } from './TabLine';
|
|
2
|
-
export * from './TabLine';
|
|
1
|
+
export { default, wrapTabLine } from './TabLine';
|
|
2
|
+
export * from './TabLine.type';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/lib/es6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default"],"sources":["../../src/index.
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","wrapTabLine"],"sources":["../../src/index.ts"],"sourcesContent":["export { default, wrapTabLine } from './TabLine';\nexport * from './TabLine.type';\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,WAAW,QAAQ,WAAW;AAChD,cAAc,gBAAgB","ignoreList":[]}
|
package/lib/esm/TabLine.mjs
CHANGED
|
@@ -5,39 +5,29 @@ import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
|
5
5
|
import a11yEnhance from "@semcore/core/lib/utils/enhances/a11yEnhance";
|
|
6
6
|
import { Text as Text$1 } from "@semcore/typography";
|
|
7
7
|
import React from "react";
|
|
8
|
+
/*!__reshadow-styles__:"./style/tab-line.shadow.css"*/
|
|
8
9
|
const style = (
|
|
9
10
|
/*__reshadow_css_start__*/
|
|
10
11
|
(sstyled.insert(
|
|
11
12
|
/*__inner_css_start__*/
|
|
12
|
-
'.
|
|
13
|
+
'.___STabLine_1v9ch_gg_{position:relative;display:flex;width:100%;max-width:100%}.___STabLine_1v9ch_gg_.__underlined_1v9ch_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabLineItem_1v9ch_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:0;background:0 0;color:var(--intergalactic-text-primary, #191b23);margin-right:var(--intergalactic-spacing-4x, 16px);font-weight:var(--intergalactic-medium, 500)}.___STabLineItem_1v9ch_gg_::-moz-focus-inner{border:0;padding:0}.___STabLineItem_1v9ch_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabLineItem_1v9ch_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___STabLineItem_1v9ch_gg_::after,.___STabLineItem_1v9ch_gg_::before{content:"";position:absolute;left:0;bottom:-1px;height:3px;width:100%;background-color:transparent}.___STabLineItem_1v9ch_gg_::before{transition:background-color calc(var(--intergalactic-duration-control, 200)*1ms) ease-in-out}@media (hover:hover){.___STabLineItem_1v9ch_gg_:hover::before{background-color:var(--intergalactic-border-primary, #c4c7cf)}}.___STabLineItem_1v9ch_gg_.__selected_1v9ch_gg_::after{transition-delay:calc(var(--intergalactic-duration-control, 200)*1ms);background-color:var(--intergalactic-border-info-active, #006dca)}.___STabLineItem_1v9ch_gg_ .___SAddon_1v9ch_gg_:not(:last-child),.___STabLineItem_1v9ch_gg_ .___SText_1v9ch_gg_:not(:last-child){margin-right:var(--intergalactic-spacing-2x, 8px)}.___SCaret_1v9ch_gg_{position:absolute;bottom:-1px;height:3px;background:var(--intergalactic-border-info-active, #006dca);transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___STabLineItem_1v9ch_gg_.__selected_1v9ch_gg_{flex-shrink:0}.___STabLineItem_1v9ch_gg_.__disabled_1v9ch_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SAddon_1v9ch_gg_{display:inline-flex;align-items:center;justify-content:center}.___STabLineItem_1v9ch_gg_._size_m_1v9ch_gg_{height:28px;min-width:18px}.___STabLineItem_1v9ch_gg_._size_l_1v9ch_gg_{height:40px;min-width:26px}.___STabLineItem_1v9ch_gg_._neighborLocation_left_1v9ch_gg_{margin-right:0}@media (prefers-reduced-motion){.___STabLineItem_1v9ch_gg_.__selected_1v9ch_gg_::after,.___STabLineItem_1v9ch_gg_::after,.___STabLineItem_1v9ch_gg_::before{transition:none}.___SCaret_1v9ch_gg_{display:none}}',
|
|
13
14
|
/*__inner_css_end__*/
|
|
14
|
-
"
|
|
15
|
+
"1v9ch_gg_"
|
|
15
16
|
), /*__reshadow_css_end__*/
|
|
16
17
|
{
|
|
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": "
|
|
18
|
+
"__STabLine": "___STabLine_1v9ch_gg_",
|
|
19
|
+
"_underlined": "__underlined_1v9ch_gg_",
|
|
20
|
+
"__SCaret": "___SCaret_1v9ch_gg_",
|
|
21
|
+
"__STabLineItem": "___STabLineItem_1v9ch_gg_",
|
|
22
|
+
"_selected": "__selected_1v9ch_gg_",
|
|
23
|
+
"_disabled": "__disabled_1v9ch_gg_",
|
|
24
|
+
"__SAddon": "___SAddon_1v9ch_gg_",
|
|
25
|
+
"_size_m": "_size_m_1v9ch_gg_",
|
|
26
|
+
"_size_l": "_size_l_1v9ch_gg_",
|
|
27
|
+
"_neighborLocation_left": "_neighborLocation_left_1v9ch_gg_",
|
|
28
|
+
"__SText": "___SText_1v9ch_gg_"
|
|
28
29
|
})
|
|
29
30
|
);
|
|
30
|
-
const optionsA11yEnhance = {
|
|
31
|
-
onNeighborChange: (neighborElement, props) => {
|
|
32
|
-
if (neighborElement) {
|
|
33
|
-
neighborElement.focus();
|
|
34
|
-
if (props.behavior === "auto") {
|
|
35
|
-
neighborElement.click();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
childSelector: ["role", "tab"]
|
|
40
|
-
};
|
|
41
31
|
class TabLineRoot extends Component {
|
|
42
32
|
constructor(...args) {
|
|
43
33
|
super(...args);
|
|
@@ -47,7 +37,7 @@ class TabLineRoot extends Component {
|
|
|
47
37
|
_defineProperty(this, "prevValue", void 0);
|
|
48
38
|
_defineProperty(this, "itemRefs", {});
|
|
49
39
|
_defineProperty(this, "containerRef", /* @__PURE__ */ React.createRef());
|
|
50
|
-
_defineProperty(this, "animationStartTimeout",
|
|
40
|
+
_defineProperty(this, "animationStartTimeout", null);
|
|
51
41
|
_defineProperty(this, "buttonRefsList", []);
|
|
52
42
|
_defineProperty(this, "handleAnimationStart", () => {
|
|
53
43
|
if (this.state.animation?.started === false) {
|
|
@@ -83,11 +73,14 @@ class TabLineRoot extends Component {
|
|
|
83
73
|
this.prevValue = this.asProps.value;
|
|
84
74
|
}
|
|
85
75
|
componentWillUnmount() {
|
|
86
|
-
|
|
76
|
+
if (this.animationStartTimeout) {
|
|
77
|
+
clearTimeout(this.animationStartTimeout);
|
|
78
|
+
}
|
|
87
79
|
}
|
|
88
80
|
animate() {
|
|
89
|
-
|
|
90
|
-
const
|
|
81
|
+
if (this.prevValue === void 0 || this.asProps.value === void 0) return;
|
|
82
|
+
const fromNode = this.itemRefs[this.prevValue.toString()];
|
|
83
|
+
const toNode = this.itemRefs[this.asProps.value.toString()];
|
|
91
84
|
const containerNode = this.containerRef.current;
|
|
92
85
|
if (!fromNode || !toNode || !containerNode) return;
|
|
93
86
|
const containerRect = containerNode.getBoundingClientRect();
|
|
@@ -103,7 +96,9 @@ class TabLineRoot extends Component {
|
|
|
103
96
|
this.setState({
|
|
104
97
|
animation
|
|
105
98
|
});
|
|
106
|
-
|
|
99
|
+
if (this.animationStartTimeout) {
|
|
100
|
+
clearTimeout(this.animationStartTimeout);
|
|
101
|
+
}
|
|
107
102
|
this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);
|
|
108
103
|
}
|
|
109
104
|
getItemProps(props, index) {
|
|
@@ -119,7 +114,8 @@ class TabLineRoot extends Component {
|
|
|
119
114
|
"tabIndex": isSelected ? 0 : -1,
|
|
120
115
|
"aria-selected": isSelected,
|
|
121
116
|
"ref": (node) => {
|
|
122
|
-
|
|
117
|
+
if (props.value === void 0) return;
|
|
118
|
+
this.itemRefs[props.value.toString()] = node;
|
|
123
119
|
},
|
|
124
120
|
"buttonRefsList": this.buttonRefsList,
|
|
125
121
|
index
|
|
@@ -191,7 +187,17 @@ _defineProperty(TabLineRoot, "defaultProps", {
|
|
|
191
187
|
underlined: true,
|
|
192
188
|
behavior: "auto"
|
|
193
189
|
});
|
|
194
|
-
_defineProperty(TabLineRoot, "enhance", [a11yEnhance(
|
|
190
|
+
_defineProperty(TabLineRoot, "enhance", [a11yEnhance({
|
|
191
|
+
onNeighborChange: (neighborElement, props) => {
|
|
192
|
+
if (neighborElement) {
|
|
193
|
+
neighborElement.focus();
|
|
194
|
+
if (props.behavior === "auto") {
|
|
195
|
+
neighborElement.click();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
childSelector: ["role", "tab"]
|
|
200
|
+
})]);
|
|
195
201
|
function TabLineItem(props) {
|
|
196
202
|
var _ref2 = arguments[0];
|
|
197
203
|
const STabLineItem = Box;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/lib/esm/index.mjs
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Intergalactic } from '@semcore/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { NSTabLine } from './TabLine.type';
|
|
4
|
+
declare const TabLine: NSTabLine.Component;
|
|
5
|
+
export declare const wrapTabLine: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.UntypeRefAndTag<Intergalactic.InternalTypings.ComponentPropsNesting<NSTabLine.WrapperComponent>> & PropsExtending) => React.ReactNode) => NSTabLine.WrapperComponent<PropsExtending>;
|
|
6
|
+
export default TabLine;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';
|
|
2
|
+
import type { PropGetterFn, Intergalactic } from '@semcore/core';
|
|
3
|
+
import type { NSText } from '@semcore/typography';
|
|
4
|
+
import type React from 'react';
|
|
5
|
+
declare namespace NSTabLine {
|
|
6
|
+
type Value = string | number | boolean;
|
|
7
|
+
type Props<T extends NSTabLine.Value = NSTabLine.Value> = BoxProps & NeighborLocationProps & {
|
|
8
|
+
/** TabLine size
|
|
9
|
+
* @default m
|
|
10
|
+
* */
|
|
11
|
+
size?: 'm' | 'l' | false;
|
|
12
|
+
/** Adds a bottom border for the entire component
|
|
13
|
+
* @default true
|
|
14
|
+
* */
|
|
15
|
+
underlined?: boolean;
|
|
16
|
+
/** Is invoked when changing the selection */
|
|
17
|
+
onChange?: ((value: T, e?: React.SyntheticEvent<HTMLButtonElement>) => void) | React.Dispatch<React.SetStateAction<T>>;
|
|
18
|
+
/** Value of the selected tab */
|
|
19
|
+
value?: T;
|
|
20
|
+
/** Default value of the selected tab
|
|
21
|
+
* @default null
|
|
22
|
+
* */
|
|
23
|
+
defaultValue?: T;
|
|
24
|
+
/**
|
|
25
|
+
* Behavior of tabs.
|
|
26
|
+
* In `auto`, changes the tab immediately when press arrow.
|
|
27
|
+
* In `manual`, needs to press `space` or `enter` for select a choice.
|
|
28
|
+
* @default 'auto'
|
|
29
|
+
*/
|
|
30
|
+
behavior?: 'auto' | 'manual';
|
|
31
|
+
};
|
|
32
|
+
type Ctx = {
|
|
33
|
+
getItemProps: PropGetterFn;
|
|
34
|
+
};
|
|
35
|
+
type Handlers = {
|
|
36
|
+
value: null;
|
|
37
|
+
};
|
|
38
|
+
namespace Item {
|
|
39
|
+
type Props = BoxProps & NeighborItemProps & {
|
|
40
|
+
/** Makes a tab selected. This property is determined automatically depending on the value. */
|
|
41
|
+
selected?: boolean;
|
|
42
|
+
/** Disabled state */
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
/** Tab value */
|
|
45
|
+
value?: NSTabLine.Value;
|
|
46
|
+
/** Left addon tag */
|
|
47
|
+
addonLeft?: React.ElementType;
|
|
48
|
+
/** Right addon tag */
|
|
49
|
+
addonRight?: React.ElementType;
|
|
50
|
+
};
|
|
51
|
+
namespace Text {
|
|
52
|
+
type Props = NSText.Props;
|
|
53
|
+
type Component = NSText.Component;
|
|
54
|
+
}
|
|
55
|
+
namespace Addon {
|
|
56
|
+
type Component = typeof Box;
|
|
57
|
+
}
|
|
58
|
+
type Component = Intergalactic.Component<'div', Props, {}, [handlers: NSTabLine.Handlers]> & {
|
|
59
|
+
Text: Text.Component;
|
|
60
|
+
Addon: Addon.Component;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
type WrapperComponent<PropsExtending = {}> = (<V extends Value, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', Props<V>, Ctx, [
|
|
64
|
+
handlers: Handlers
|
|
65
|
+
]> & PropsExtending) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;
|
|
66
|
+
type Component = WrapperComponent & {
|
|
67
|
+
Item: Item.Component;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** @deprecated It will be removed in v18. */
|
|
71
|
+
export type TabLineValue = NSTabLine.Value;
|
|
72
|
+
/** @deprecated It will be removed in v18. */
|
|
73
|
+
export type TabLineProps<T extends TabLineValue = TabLineValue> = NSTabLine.Props<T>;
|
|
74
|
+
/** @deprecated It will be removed in v18. */
|
|
75
|
+
export type TabLineItemProps = NSTabLine.Item.Props;
|
|
76
|
+
/** @deprecated It will be removed in v18. */
|
|
77
|
+
export type TabLineContext = NSTabLine.Ctx;
|
|
78
|
+
/** @deprecated It will be removed in v18. */
|
|
79
|
+
export type TabLineHandlers = NSTabLine.Handlers;
|
|
80
|
+
export type { NSTabLine };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,92 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { Text } from '@semcore/typography';
|
|
4
|
-
import type React from 'react';
|
|
5
|
-
|
|
6
|
-
export type TabLineValue = string | number | boolean;
|
|
7
|
-
|
|
8
|
-
export type TabLineProps<T extends TabLineValue = TabLineValue> = BoxProps &
|
|
9
|
-
NeighborLocationProps & {
|
|
10
|
-
/** TabLine size
|
|
11
|
-
* @default m
|
|
12
|
-
* */
|
|
13
|
-
size?: 'm' | 'l' | false;
|
|
14
|
-
/** Adds a bottom border for the entire component
|
|
15
|
-
* @default true
|
|
16
|
-
* */
|
|
17
|
-
underlined?: boolean;
|
|
18
|
-
/** Is invoked when changing the selection */
|
|
19
|
-
onChange?:
|
|
20
|
-
| ((value: T, e?: React.SyntheticEvent<HTMLButtonElement>) => void)
|
|
21
|
-
| React.Dispatch<React.SetStateAction<T>>;
|
|
22
|
-
/** Value of the selected tab */
|
|
23
|
-
value?: T;
|
|
24
|
-
/** Default value of the selected tab
|
|
25
|
-
* @default null
|
|
26
|
-
* */
|
|
27
|
-
defaultValue?: T;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Behavior of tabs.
|
|
31
|
-
* In `auto`, changes the tab immediately when press arrow.
|
|
32
|
-
* In `manual`, needs to press `space` or `enter` for select a choice.
|
|
33
|
-
* @default 'auto'
|
|
34
|
-
*/
|
|
35
|
-
behavior?: 'auto' | 'manual';
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type TabLineItemProps = BoxProps &
|
|
39
|
-
NeighborItemProps & {
|
|
40
|
-
/** Makes a tab selected. This property is determined automatically depending on the value. */
|
|
41
|
-
selected?: boolean;
|
|
42
|
-
/** Disabled state */
|
|
43
|
-
disabled?: boolean;
|
|
44
|
-
/** Tab value */
|
|
45
|
-
value?: TabLineValue;
|
|
46
|
-
/** Left addon tag */
|
|
47
|
-
addonLeft?: React.ElementType;
|
|
48
|
-
/** Right addon tag */
|
|
49
|
-
addonRight?: React.ElementType;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export type TabLineContext = {
|
|
53
|
-
getItemProps: PropGetterFn;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export type TabLineHandlers = {
|
|
57
|
-
value: (value: TabLineValue) => void;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
type IntergalacticTabLineComponent<PropsExtending = {}> = (<
|
|
61
|
-
Value extends TabLineValue,
|
|
62
|
-
Tag extends Intergalactic.Tag = 'div',
|
|
63
|
-
>(
|
|
64
|
-
props: Intergalactic.InternalTypings.ComponentProps<
|
|
65
|
-
Tag,
|
|
66
|
-
'div',
|
|
67
|
-
TabLineProps<Value>,
|
|
68
|
-
TabLineContext,
|
|
69
|
-
[handlers: TabLineHandlers]
|
|
70
|
-
> &
|
|
71
|
-
PropsExtending,
|
|
72
|
-
) => Intergalactic.InternalTypings.ComponentRenderingResults) &
|
|
73
|
-
Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', TabLineProps>;
|
|
74
|
-
|
|
75
|
-
declare const TabLine: IntergalacticTabLineComponent & {
|
|
76
|
-
Item: Intergalactic.Component<'div', TabLineItemProps, {}, [handlers: TabLineHandlers]> & {
|
|
77
|
-
Text: typeof Text;
|
|
78
|
-
Addon: typeof Box;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
declare const wrapTabLine: <PropsExtending extends {}>(
|
|
83
|
-
wrapper: (
|
|
84
|
-
props: Intergalactic.InternalTypings.UntypeRefAndTag<
|
|
85
|
-
Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticTabLineComponent>
|
|
86
|
-
> &
|
|
87
|
-
PropsExtending,
|
|
88
|
-
) => React.ReactNode,
|
|
89
|
-
) => IntergalacticTabLineComponent<PropsExtending>;
|
|
90
|
-
export { wrapTabLine };
|
|
91
|
-
|
|
92
|
-
export default TabLine;
|
|
1
|
+
export { default, wrapTabLine } from './TabLine';
|
|
2
|
+
export * from './TabLine.type';
|
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.0.0",
|
|
4
|
+
"version": "17.0.2-prerelease.0",
|
|
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.0.0"
|
|
17
|
+
"@semcore/typography": "^17.0.2-prerelease.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@semcore/base-components": "^17.0.
|
|
20
|
+
"@semcore/base-components": "^17.0.2"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"directory": "semcore/tab-line"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@semcore/
|
|
29
|
-
"@semcore/
|
|
30
|
-
"@semcore/
|
|
28
|
+
"@semcore/base-components": "17.0.2-prerelease.0",
|
|
29
|
+
"@semcore/testing-utils": "1.0.0",
|
|
30
|
+
"@semcore/core": "17.0.1"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "pnpm semcore-builder
|
|
33
|
+
"build": "pnpm semcore-builder && pnpm vite build"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/vite.config.ts
CHANGED
package/lib/cjs/index.d.js
DELETED
package/lib/cjs/index.d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { Text } from '@semcore/typography';\nimport type React from 'react';\n\nexport type TabLineValue = string | number | boolean;\n\nexport type TabLineProps<T extends TabLineValue = TabLineValue> = 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\nexport type TabLineItemProps = 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?: TabLineValue;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n };\n\nexport type TabLineContext = {\n getItemProps: PropGetterFn;\n};\n\nexport type TabLineHandlers = {\n value: (value: TabLineValue) => void;\n};\n\ntype IntergalacticTabLineComponent<PropsExtending = {}> = (<\n Value extends TabLineValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n TabLineProps<Value>,\n TabLineContext,\n [handlers: TabLineHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', TabLineProps>;\n\ndeclare const TabLine: IntergalacticTabLineComponent & {\n Item: Intergalactic.Component<'div', TabLineItemProps, {}, [handlers: TabLineHandlers]> & {\n Text: typeof Text;\n Addon: typeof Box;\n };\n};\n\ndeclare const wrapTabLine: <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticTabLineComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => IntergalacticTabLineComponent<PropsExtending>;\nexport { wrapTabLine };\n\nexport default TabLine;\n"],"mappings":"","ignoreList":[]}
|
package/lib/es6/index.d.js
DELETED
package/lib/es6/index.d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { Text } from '@semcore/typography';\nimport type React from 'react';\n\nexport type TabLineValue = string | number | boolean;\n\nexport type TabLineProps<T extends TabLineValue = TabLineValue> = 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\nexport type TabLineItemProps = 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?: TabLineValue;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n };\n\nexport type TabLineContext = {\n getItemProps: PropGetterFn;\n};\n\nexport type TabLineHandlers = {\n value: (value: TabLineValue) => void;\n};\n\ntype IntergalacticTabLineComponent<PropsExtending = {}> = (<\n Value extends TabLineValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n TabLineProps<Value>,\n TabLineContext,\n [handlers: TabLineHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', TabLineProps>;\n\ndeclare const TabLine: IntergalacticTabLineComponent & {\n Item: Intergalactic.Component<'div', TabLineItemProps, {}, [handlers: TabLineHandlers]> & {\n Text: typeof Text;\n Addon: typeof Box;\n };\n};\n\ndeclare const wrapTabLine: <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticTabLineComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => IntergalacticTabLineComponent<PropsExtending>;\nexport { wrapTabLine };\n\nexport default TabLine;\n"],"mappings":"","ignoreList":[]}
|