@semcore/tab-panel 16.0.11 → 17.0.0-prerelease.17
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/README.md +4 -4
- package/lib/cjs/TabPanel.js +122 -103
- package/lib/cjs/TabPanel.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/index.js +4 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/tab-panel.shadow.css +0 -10
- package/lib/es6/TabPanel.js +113 -95
- package/lib/es6/TabPanel.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/tab-panel.shadow.css +0 -10
- package/lib/esm/TabPanel.mjs +113 -92
- package/lib/esm/style/tab-panel.shadow.css +0 -10
- package/lib/types/index.d.ts +2 -12
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/@semcore/tab-panel)
|
|
4
4
|
[](https://www.npmjs.com/package/@semcore/tab-panel)
|
|
5
|
-
[](https://github.com/semrush/intergalactic/blob/
|
|
5
|
+
[](https://github.com/semrush/intergalactic/blob/HEAD/LICENSE)
|
|
6
6
|
|
|
7
7
|
> This component is part of the Intergalactic Design System
|
|
8
8
|
|
|
@@ -20,13 +20,13 @@ npm install @semcore/tab-panel
|
|
|
20
20
|
|
|
21
21
|
## 👤 Author
|
|
22
22
|
|
|
23
|
-
[UI-kit team](https://github.com/semrush/intergalactic/blob/
|
|
23
|
+
[UI-kit team](https://github.com/semrush/intergalactic/blob/HEAD/MAINTAINERS) and [others ❤️](https://github.com/semrush/intergalactic/graphs/contributors)
|
|
24
24
|
|
|
25
25
|
## 🤝 Contributing
|
|
26
26
|
|
|
27
27
|
Contributions, issues and feature requests are welcome!
|
|
28
28
|
|
|
29
|
-
Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at the [contributing guide](https://github.com/semrush/intergalactic/blob/
|
|
29
|
+
Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at the [contributing guide](https://github.com/semrush/intergalactic/blob/HEAD/CONTRIBUTING.md).
|
|
30
30
|
|
|
31
31
|
## Show your support
|
|
32
32
|
|
|
@@ -34,4 +34,4 @@ Give a ⭐️ if this project helped you!
|
|
|
34
34
|
|
|
35
35
|
## 📝 License
|
|
36
36
|
|
|
37
|
-
This project is [MIT](https://github.com/semrush/intergalactic/blob/
|
|
37
|
+
This project is [MIT](https://github.com/semrush/intergalactic/blob/HEAD/LICENSE) licensed.
|
package/lib/cjs/TabPanel.js
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.wrapTabPanel = exports
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
7
|
+
exports.wrapTabPanel = exports.default = void 0;
|
|
13
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
9
|
var _core = require("@semcore/core");
|
|
10
|
+
var _baseComponents = require("@semcore/base-components");
|
|
15
11
|
var _addonTextChildren = _interopRequireDefault(require("@semcore/core/lib/utils/addonTextChildren"));
|
|
16
12
|
var _a11yEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/a11yEnhance"));
|
|
17
|
-
var
|
|
13
|
+
var _typography = require("@semcore/typography");
|
|
18
14
|
var _react = _interopRequireDefault(require("react"));
|
|
19
15
|
/*!__reshadow-styles__:"./style/tab-panel.shadow.css"*/
|
|
20
|
-
|
|
16
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___STabPanel_1w4cf_gg_{display:flex;width:100%;max-width:100%}.___STabPanel_1w4cf_gg_::after{content:\"\";position:relative;bottom:-1px;flex:1;border-top:1px solid transparent;border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabPanelItem_1w4cf_gg_{position:relative;bottom:-1px;display:inline-flex;min-width:0;height:32px;color:var(--intergalactic-text-secondary, #6c6e79);border:1px solid transparent;border-bottom:none;border-radius:var(--intergalactic-control-rounded, 6px) var(--intergalactic-control-rounded, 6px)0 0;background:0 0;align-items:center;justify-content:center;touch-action:manipulation;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0 0 1px;margin:0;box-shadow:none;-webkit-text-decoration:none;text-decoration:none;-webkit-tap-highlight-color:transparent;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer}.___STabPanelItem_1w4cf_gg_::-moz-focus-inner{border:0;padding:0}.___STabPanelItem_1w4cf_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabPanelItem_1w4cf_gg_:hover{-webkit-text-decoration:none;text-decoration:none;color:var(--intergalactic-text-primary, #191b23)}}.___STabPanelItem_1w4cf_gg_::after{content:\"\";position:absolute;left:-1px;bottom:0;width:calc(100% + 2px);border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabPanelItem_1w4cf_gg_.__disabled_1w4cf_gg_{cursor:default;pointer-events:none}.___STabPanelItem_1w4cf_gg_.__disabled_1w4cf_gg_ .___SAddon_1w4cf_gg_,.___STabPanelItem_1w4cf_gg_.__disabled_1w4cf_gg_ .___SText_1w4cf_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___STabPanelItem_1w4cf_gg_.__selected_1w4cf_gg_{color:var(--intergalactic-text-link, #006dca);border-color:var(--intergalactic-border-primary, #c4c7cf);flex-shrink:0}@media (hover:hover){.___STabPanelItem_1w4cf_gg_.__selected_1w4cf_gg_:hover{color:var(--intergalactic-text-link-hover-active, #044792)}}.___STabPanelItem_1w4cf_gg_.__selected_1w4cf_gg_::after{border-bottom:none}.___SText_1w4cf_gg_{margin:auto var(--intergalactic-spacing-2x, 8px)}.___SAddon_1w4cf_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_1w4cf_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1w4cf_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1w4cf_gg_:only-child{margin-right:var(--intergalactic-spacing-2x, 8px);margin-left:var(--intergalactic-spacing-2x, 8px)}", /*__inner_css_end__*/"1w4cf_gg_"),
|
|
21
17
|
/*__reshadow_css_end__*/
|
|
22
18
|
{
|
|
23
|
-
"__SText": "
|
|
24
|
-
"__SAddon": "
|
|
25
|
-
"__STabPanel": "
|
|
26
|
-
"__STabPanelItem": "
|
|
27
|
-
"_disabled": "
|
|
28
|
-
"_selected": "
|
|
19
|
+
"__SText": "___SText_1w4cf_gg_",
|
|
20
|
+
"__SAddon": "___SAddon_1w4cf_gg_",
|
|
21
|
+
"__STabPanel": "___STabPanel_1w4cf_gg_",
|
|
22
|
+
"__STabPanelItem": "___STabPanelItem_1w4cf_gg_",
|
|
23
|
+
"_disabled": "__disabled_1w4cf_gg_",
|
|
24
|
+
"_selected": "__selected_1w4cf_gg_"
|
|
29
25
|
});
|
|
30
|
-
|
|
31
|
-
onNeighborChange:
|
|
26
|
+
const optionsA11yEnhance = {
|
|
27
|
+
onNeighborChange: (neighborElement, props) => {
|
|
32
28
|
if (neighborElement) {
|
|
33
29
|
neighborElement.focus();
|
|
34
30
|
if (props.behavior === 'auto') {
|
|
@@ -38,115 +34,138 @@ var optionsA11yEnhance = {
|
|
|
38
34
|
},
|
|
39
35
|
childSelector: ['role', 'tab']
|
|
40
36
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(0,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
_this = (0, _callSuper2["default"])(this, TabPanelRoot, [].concat(args));
|
|
49
|
-
(0, _defineProperty2["default"])(_this, "handleClick", function (value) {
|
|
50
|
-
return function (event) {
|
|
51
|
-
_this.handlers.value(value, event);
|
|
52
|
-
};
|
|
37
|
+
class TabPanelRoot extends _core.Component {
|
|
38
|
+
constructor(...args) {
|
|
39
|
+
super(...args);
|
|
40
|
+
(0, _defineProperty2.default)(this, "buttonRefsList", []);
|
|
41
|
+
(0, _defineProperty2.default)(this, "handleClick", value => event => {
|
|
42
|
+
this.handlers.value(value, event);
|
|
53
43
|
});
|
|
54
|
-
(0, _defineProperty2
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
};
|
|
44
|
+
(0, _defineProperty2.default)(this, "handleKeyDown", value => event => {
|
|
45
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
this.handlers.value(value, event);
|
|
48
|
+
}
|
|
61
49
|
});
|
|
62
|
-
return _this;
|
|
63
50
|
}
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
51
|
+
uncontrolledProps() {
|
|
52
|
+
return {
|
|
53
|
+
value: null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
getItemProps(props, index) {
|
|
57
|
+
const {
|
|
58
|
+
value
|
|
59
|
+
} = this.asProps;
|
|
60
|
+
const isSelected = value === props.value;
|
|
61
|
+
return {
|
|
62
|
+
'selected': isSelected,
|
|
63
|
+
'onClick': this.handleClick(props.value),
|
|
64
|
+
'onKeyDown': this.handleKeyDown(props.value),
|
|
65
|
+
'tabIndex': isSelected ? 0 : -1,
|
|
66
|
+
'aria-selected': isSelected,
|
|
67
|
+
'buttonRefsList': this.buttonRefsList,
|
|
68
|
+
index
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
getItemTextProps(_, index) {
|
|
72
|
+
return {
|
|
73
|
+
buttonRefsList: this.buttonRefsList,
|
|
74
|
+
index
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
var _ref = this.asProps,
|
|
79
|
+
_ref5;
|
|
80
|
+
const STabPanel = _baseComponents.Box;
|
|
81
|
+
const {
|
|
82
|
+
styles
|
|
83
|
+
} = this.asProps;
|
|
84
|
+
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(STabPanel, _ref5.cn("STabPanel", {
|
|
85
|
+
...(0, _core.assignProps)({
|
|
93
86
|
"role": 'tablist'
|
|
94
|
-
}, _ref)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
(0, _defineProperty2
|
|
99
|
-
(0, _defineProperty2
|
|
100
|
-
(0, _defineProperty2
|
|
87
|
+
}, _ref)
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
(0, _defineProperty2.default)(TabPanelRoot, "displayName", 'TabPanel');
|
|
92
|
+
(0, _defineProperty2.default)(TabPanelRoot, "style", style);
|
|
93
|
+
(0, _defineProperty2.default)(TabPanelRoot, "defaultProps", {
|
|
101
94
|
defaultValue: null,
|
|
102
95
|
behavior: 'manual'
|
|
103
96
|
});
|
|
104
|
-
(0, _defineProperty2
|
|
97
|
+
(0, _defineProperty2.default)(TabPanelRoot, "enhance", [(0, _a11yEnhance.default)(optionsA11yEnhance)]);
|
|
105
98
|
function TabPanelItem(props) {
|
|
106
99
|
var _ref2 = arguments[0],
|
|
107
100
|
_ref6;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
101
|
+
const STabPanelItem = _baseComponents.Box;
|
|
102
|
+
const {
|
|
103
|
+
Children,
|
|
104
|
+
styles,
|
|
105
|
+
addonLeft,
|
|
106
|
+
addonRight,
|
|
107
|
+
buttonRefsList,
|
|
108
|
+
index
|
|
109
|
+
} = props;
|
|
110
|
+
const buttonRef = _react.default.useRef();
|
|
111
|
+
buttonRefsList[index] = buttonRef;
|
|
112
|
+
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(STabPanelItem, _ref6.cn("STabPanelItem", {
|
|
113
|
+
...(0, _core.assignProps)({
|
|
114
|
+
"type": 'button',
|
|
115
|
+
"tag": 'button',
|
|
116
|
+
"tabIndex": 0,
|
|
117
|
+
"role": 'tab',
|
|
118
|
+
"ref": buttonRef
|
|
119
|
+
}, _ref2)
|
|
120
|
+
}), addonLeft ? /*#__PURE__*/_react.default.createElement(TabPanel.Item.Addon, {
|
|
119
121
|
tag: addonLeft
|
|
120
|
-
}) : null, (0, _addonTextChildren
|
|
122
|
+
}) : null, (0, _addonTextChildren.default)(Children, TabPanel.Item.Text, TabPanel.Item.Addon), addonRight ? /*#__PURE__*/_react.default.createElement(TabPanel.Item.Addon, {
|
|
121
123
|
tag: addonRight
|
|
122
124
|
}) : null);
|
|
123
125
|
}
|
|
124
126
|
function Text(props) {
|
|
125
127
|
var _ref3 = arguments[0],
|
|
126
128
|
_ref7;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
const SText = _typography.Text;
|
|
130
|
+
const {
|
|
131
|
+
styles,
|
|
132
|
+
ellipsis = true,
|
|
133
|
+
buttonRefsList,
|
|
134
|
+
index,
|
|
135
|
+
hintProps = {}
|
|
136
|
+
} = props;
|
|
137
|
+
return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SText, _ref7.cn("SText", {
|
|
138
|
+
...(0, _core.assignProps)({
|
|
139
|
+
"size": 200,
|
|
140
|
+
"ellipsis": ellipsis,
|
|
141
|
+
"medium": true,
|
|
142
|
+
"use:hintProps": {
|
|
143
|
+
triggerRef: buttonRefsList[index],
|
|
144
|
+
...hintProps
|
|
145
|
+
}
|
|
146
|
+
}, _ref3)
|
|
147
|
+
}));
|
|
132
148
|
}
|
|
133
149
|
function Addon(props) {
|
|
134
150
|
var _ref4 = arguments[0],
|
|
135
151
|
_ref8;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
152
|
+
const SAddon = _baseComponents.Box;
|
|
153
|
+
const {
|
|
154
|
+
styles
|
|
155
|
+
} = props;
|
|
156
|
+
return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SAddon, _ref8.cn("SAddon", {
|
|
157
|
+
...(0, _core.assignProps)({
|
|
158
|
+
"tag": 'span'
|
|
159
|
+
}, _ref4)
|
|
160
|
+
}));
|
|
141
161
|
}
|
|
142
|
-
|
|
162
|
+
const TabPanel = (0, _core.createComponent)(TabPanelRoot, {
|
|
143
163
|
Item: [TabPanelItem, {
|
|
144
|
-
Text
|
|
145
|
-
Addon
|
|
164
|
+
Text,
|
|
165
|
+
Addon
|
|
146
166
|
}]
|
|
147
167
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
var _default = exports["default"] = TabPanel;
|
|
168
|
+
const wrapTabPanel = wrapper => wrapper;
|
|
169
|
+
exports.wrapTabPanel = wrapTabPanel;
|
|
170
|
+
var _default = exports.default = TabPanel;
|
|
152
171
|
//# sourceMappingURL=TabPanel.js.map
|
package/lib/cjs/TabPanel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabPanel.js","names":["_core","require","_addonTextChildren","_interopRequireDefault","_a11yEnhance","
|
|
1
|
+
{"version":3,"file":"TabPanel.js","names":["_core","require","_baseComponents","_addonTextChildren","_interopRequireDefault","_a11yEnhance","_typography","_react","style","sstyled","insert","optionsA11yEnhance","onNeighborChange","neighborElement","props","focus","behavior","click","childSelector","TabPanelRoot","Component","constructor","args","_defineProperty2","default","value","event","handlers","key","preventDefault","uncontrolledProps","getItemProps","index","asProps","isSelected","handleClick","handleKeyDown","buttonRefsList","getItemTextProps","_","render","_ref","_ref5","STabPanel","Box","styles","createElement","cn","assignProps","defaultValue","a11yEnhance","TabPanelItem","_ref2","arguments[0]","_ref6","STabPanelItem","Children","addonLeft","addonRight","buttonRef","React","useRef","TabPanel","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","SText","UikitText","ellipsis","hintProps","triggerRef","_ref4","_ref8","SAddon","createComponent","wrapTabPanel","wrapper","exports","_default"],"sources":["../../src/TabPanel.jsx"],"sourcesContent":["import { 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-panel.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 TabPanelRoot extends Component {\n static displayName = 'TabPanel';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n behavior: 'manual',\n };\n\n static enhance = [a11yEnhance(optionsA11yEnhance)];\n\n buttonRefsList = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n handleClick = (value) => (event) => {\n this.handlers.value(value, event);\n };\n\n handleKeyDown = (value) => (event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handlers.value(value, event);\n }\n };\n\n getItemProps(props, index) {\n const { value } = this.asProps;\n const isSelected = value === props.value;\n return {\n 'selected': isSelected,\n 'onClick': this.handleClick(props.value),\n 'onKeyDown': this.handleKeyDown(props.value),\n 'tabIndex': isSelected ? 0 : -1,\n 'aria-selected': isSelected,\n 'buttonRefsList': this.buttonRefsList,\n index,\n };\n }\n\n getItemTextProps(_, index) {\n return {\n buttonRefsList: this.buttonRefsList,\n index,\n };\n }\n\n render() {\n const STabPanel = Root;\n const { styles } = this.asProps;\n\n return sstyled(styles)(<STabPanel render={Box} role='tablist' />);\n }\n}\n\nfunction TabPanelItem(props) {\n const STabPanelItem = Root;\n const { Children, styles, addonLeft, addonRight, buttonRefsList, index } = props;\n const buttonRef = React.useRef();\n\n buttonRefsList[index] = buttonRef;\n\n return sstyled(styles)(\n <STabPanelItem render={Box} type='button' tag='button' tabIndex={0} role='tab' ref={buttonRef}>\n {addonLeft ? <TabPanel.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabPanel.Item.Text, TabPanel.Item.Addon)}\n {addonRight ? <TabPanel.Item.Addon tag={addonRight} /> : null}\n </STabPanelItem>,\n );\n}\n\nfunction Text(props) {\n const SText = Root;\n const { styles, ellipsis = true, buttonRefsList, index, hintProps = {} } = props;\n return sstyled(styles)(<SText render={UikitText} size={200} ellipsis={ellipsis} medium use:hintProps={{ triggerRef: buttonRefsList[index], ...hintProps }} />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n const { styles } = props;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst TabPanel = createComponent(TabPanelRoot, {\n Item: [TabPanelItem, { Text, Addon }],\n});\n\nexport const wrapTabPanel = (wrapper) => wrapper;\n\nexport default TabPanel;\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;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,YAAY,SAASC,eAAS,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,0BAUlB,EAAE;IAAA,IAAAD,gBAAA,CAAAC,OAAA,uBAQJC,KAAK,IAAMC,KAAK,IAAK;MAClC,IAAI,CAACC,QAAQ,CAACF,KAAK,CAACA,KAAK,EAAEC,KAAK,CAAC;IACnC,CAAC;IAAA,IAAAH,gBAAA,CAAAC,OAAA,yBAEgBC,KAAK,IAAMC,KAAK,IAAK;MACpC,IAAIA,KAAK,CAACE,GAAG,KAAK,OAAO,IAAIF,KAAK,CAACE,GAAG,KAAK,GAAG,EAAE;QAC9CF,K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ACZ,YAAY,EAAE;IAAEgB,IAAI;IAAEH;EAAM,CAAC;AACtC,CAAC,CAAC;AAEK,MAAMe,YAAY,GAAIC,OAAO,IAAKA,OAAO;AAACC,OAAA,CAAAF,YAAA,GAAAA,YAAA;AAAA,IAAAG,QAAA,GAAAD,OAAA,CAAAzD,OAAA,GAElCsC,QAAQ","ignoreList":[]}
|
package/lib/cjs/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { Box, BoxProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\nexport type TabPanelValue = string | number | boolean;\n\nexport type TabPanelProps<T extends TabPanelValue = TabPanelValue> = BoxProps & {\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 * 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 TabPanelItemProps = BoxProps & {\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?: TabPanelValue;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n};\n\nexport type TabPanelContext = {\n getItemProps: PropGetterFn;\n};\n\nexport type TabPanelHandlers = {\n value: (value: TabPanelValue) => void;\n};\n\ntype IntergalacticTabPanelComponent<PropsExtending = {}> = (<\n Value extends TabPanelValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n TabPanelProps<Value>,\n TabPanelContext,\n [handlers: TabPanelHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', TabPanelProps>;\n\ndeclare const TabPanel: IntergalacticTabPanelComponent & {\n Item: Intergalactic.Component<'div', TabPanelItemProps, {}, [handlers: TabPanelHandlers]> & {\n Text: typeof Box;\n Addon: typeof Box;\n };\n};\n\ndeclare const wrapTabPanel: <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticTabPanelComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => IntergalacticTabPanelComponent<PropsExtending>;\nexport { wrapTabPanel };\n\nexport default TabPanel;\n"],"mappings":"","ignoreList":[]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
var _exportNames = {};
|
|
8
8
|
Object.defineProperty(exports, "default", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function
|
|
11
|
-
return _TabPanel
|
|
10
|
+
get: function () {
|
|
11
|
+
return _TabPanel.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
var _TabPanel = _interopRequireWildcard(require("./TabPanel"));
|
|
@@ -18,7 +18,7 @@ Object.keys(_TabPanel).forEach(function (key) {
|
|
|
18
18
|
if (key in exports && exports[key] === _TabPanel[key]) return;
|
|
19
19
|
Object.defineProperty(exports, key, {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function
|
|
21
|
+
get: function () {
|
|
22
22
|
return _TabPanel[key];
|
|
23
23
|
}
|
|
24
24
|
});
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_TabPanel","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.js"],"sourcesContent":["export { default } from './TabPanel';\nexport * from './TabPanel';\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AACAC,MAAA,CAAAC,IAAA,CAAAJ,SAAA,EAAAK,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,MAAAN,SAAA,CAAAM,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_TabPanel","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.js"],"sourcesContent":["export { default } from './TabPanel';\nexport * from './TabPanel';\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AACAC,MAAA,CAAAC,IAAA,CAAAJ,SAAA,EAAAK,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,MAAAN,SAAA,CAAAM,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAd,SAAA,CAAAM,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -40,12 +40,6 @@ STabPanelItem {
|
|
|
40
40
|
font-family: inherit;
|
|
41
41
|
cursor: pointer;
|
|
42
42
|
|
|
43
|
-
& SText {
|
|
44
|
-
font-size: var(--intergalactic-fs-200, 14px);
|
|
45
|
-
line-height: var(--intergalactic-lh-200, 142%);
|
|
46
|
-
font-weight: var(--intergalactic-medium, 500);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
43
|
&::-moz-focus-inner {
|
|
50
44
|
border: none;
|
|
51
45
|
padding: 0;
|
|
@@ -96,11 +90,7 @@ STabPanelItem[selected] {
|
|
|
96
90
|
}
|
|
97
91
|
|
|
98
92
|
SText {
|
|
99
|
-
display: inline-block;
|
|
100
93
|
margin: auto var(--intergalactic-spacing-2x, 8px);
|
|
101
|
-
white-space: nowrap;
|
|
102
|
-
overflow: hidden;
|
|
103
|
-
text-overflow: ellipsis;
|
|
104
94
|
}
|
|
105
95
|
|
|
106
96
|
SAddon {
|
package/lib/es6/TabPanel.js
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _callSuper from "@babel/runtime/helpers/callSuper";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
2
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
8
3
|
import { assignProps as _assignProps4 } from "@semcore/core";
|
|
9
4
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
10
5
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
11
6
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
7
|
+
import { Box } from '@semcore/base-components';
|
|
12
8
|
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
13
9
|
import addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';
|
|
14
10
|
import a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';
|
|
15
|
-
import {
|
|
11
|
+
import { Text as UikitText } from '@semcore/typography';
|
|
16
12
|
import React from 'react';
|
|
17
13
|
/*!__reshadow-styles__:"./style/tab-panel.shadow.css"*/
|
|
18
|
-
|
|
14
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___STabPanel_1w4cf_gg_{display:flex;width:100%;max-width:100%}.___STabPanel_1w4cf_gg_::after{content:\"\";position:relative;bottom:-1px;flex:1;border-top:1px solid transparent;border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabPanelItem_1w4cf_gg_{position:relative;bottom:-1px;display:inline-flex;min-width:0;height:32px;color:var(--intergalactic-text-secondary, #6c6e79);border:1px solid transparent;border-bottom:none;border-radius:var(--intergalactic-control-rounded, 6px) var(--intergalactic-control-rounded, 6px)0 0;background:0 0;align-items:center;justify-content:center;touch-action:manipulation;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0 0 1px;margin:0;box-shadow:none;-webkit-text-decoration:none;text-decoration:none;-webkit-tap-highlight-color:transparent;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer}.___STabPanelItem_1w4cf_gg_::-moz-focus-inner{border:0;padding:0}.___STabPanelItem_1w4cf_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabPanelItem_1w4cf_gg_:hover{-webkit-text-decoration:none;text-decoration:none;color:var(--intergalactic-text-primary, #191b23)}}.___STabPanelItem_1w4cf_gg_::after{content:\"\";position:absolute;left:-1px;bottom:0;width:calc(100% + 2px);border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabPanelItem_1w4cf_gg_.__disabled_1w4cf_gg_{cursor:default;pointer-events:none}.___STabPanelItem_1w4cf_gg_.__disabled_1w4cf_gg_ .___SAddon_1w4cf_gg_,.___STabPanelItem_1w4cf_gg_.__disabled_1w4cf_gg_ .___SText_1w4cf_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___STabPanelItem_1w4cf_gg_.__selected_1w4cf_gg_{color:var(--intergalactic-text-link, #006dca);border-color:var(--intergalactic-border-primary, #c4c7cf);flex-shrink:0}@media (hover:hover){.___STabPanelItem_1w4cf_gg_.__selected_1w4cf_gg_:hover{color:var(--intergalactic-text-link-hover-active, #044792)}}.___STabPanelItem_1w4cf_gg_.__selected_1w4cf_gg_::after{border-bottom:none}.___SText_1w4cf_gg_{margin:auto var(--intergalactic-spacing-2x, 8px)}.___SAddon_1w4cf_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_1w4cf_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1w4cf_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1w4cf_gg_:only-child{margin-right:var(--intergalactic-spacing-2x, 8px);margin-left:var(--intergalactic-spacing-2x, 8px)}", /*__inner_css_end__*/"1w4cf_gg_"),
|
|
19
15
|
/*__reshadow_css_end__*/
|
|
20
16
|
{
|
|
21
|
-
"__SText": "
|
|
22
|
-
"__SAddon": "
|
|
23
|
-
"__STabPanel": "
|
|
24
|
-
"__STabPanelItem": "
|
|
25
|
-
"_disabled": "
|
|
26
|
-
"_selected": "
|
|
17
|
+
"__SText": "___SText_1w4cf_gg_",
|
|
18
|
+
"__SAddon": "___SAddon_1w4cf_gg_",
|
|
19
|
+
"__STabPanel": "___STabPanel_1w4cf_gg_",
|
|
20
|
+
"__STabPanelItem": "___STabPanelItem_1w4cf_gg_",
|
|
21
|
+
"_disabled": "__disabled_1w4cf_gg_",
|
|
22
|
+
"_selected": "__selected_1w4cf_gg_"
|
|
27
23
|
});
|
|
28
|
-
|
|
29
|
-
onNeighborChange:
|
|
24
|
+
const optionsA11yEnhance = {
|
|
25
|
+
onNeighborChange: (neighborElement, props) => {
|
|
30
26
|
if (neighborElement) {
|
|
31
27
|
neighborElement.focus();
|
|
32
28
|
if (props.behavior === 'auto') {
|
|
@@ -36,63 +32,60 @@ var optionsA11yEnhance = {
|
|
|
36
32
|
},
|
|
37
33
|
childSelector: ['role', 'tab']
|
|
38
34
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
_this = _callSuper(this, TabPanelRoot, [].concat(args));
|
|
47
|
-
_defineProperty(_this, "handleClick", function (value) {
|
|
48
|
-
return function (event) {
|
|
49
|
-
_this.handlers.value(value, event);
|
|
50
|
-
};
|
|
35
|
+
class TabPanelRoot extends Component {
|
|
36
|
+
constructor(...args) {
|
|
37
|
+
super(...args);
|
|
38
|
+
_defineProperty(this, "buttonRefsList", []);
|
|
39
|
+
_defineProperty(this, "handleClick", value => event => {
|
|
40
|
+
this.handlers.value(value, event);
|
|
51
41
|
});
|
|
52
|
-
_defineProperty(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
};
|
|
42
|
+
_defineProperty(this, "handleKeyDown", value => event => {
|
|
43
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
this.handlers.value(value, event);
|
|
46
|
+
}
|
|
59
47
|
});
|
|
60
|
-
return _this;
|
|
61
48
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
49
|
+
uncontrolledProps() {
|
|
50
|
+
return {
|
|
51
|
+
value: null
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
getItemProps(props, index) {
|
|
55
|
+
const {
|
|
56
|
+
value
|
|
57
|
+
} = this.asProps;
|
|
58
|
+
const isSelected = value === props.value;
|
|
59
|
+
return {
|
|
60
|
+
'selected': isSelected,
|
|
61
|
+
'onClick': this.handleClick(props.value),
|
|
62
|
+
'onKeyDown': this.handleKeyDown(props.value),
|
|
63
|
+
'tabIndex': isSelected ? 0 : -1,
|
|
64
|
+
'aria-selected': isSelected,
|
|
65
|
+
'buttonRefsList': this.buttonRefsList,
|
|
66
|
+
index
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
getItemTextProps(_, index) {
|
|
70
|
+
return {
|
|
71
|
+
buttonRefsList: this.buttonRefsList,
|
|
72
|
+
index
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
render() {
|
|
76
|
+
var _ref = this.asProps,
|
|
77
|
+
_ref5;
|
|
78
|
+
const STabPanel = Box;
|
|
79
|
+
const {
|
|
80
|
+
styles
|
|
81
|
+
} = this.asProps;
|
|
82
|
+
return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(STabPanel, _ref5.cn("STabPanel", {
|
|
83
|
+
..._assignProps({
|
|
91
84
|
"role": 'tablist'
|
|
92
|
-
}, _ref)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
85
|
+
}, _ref)
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
96
89
|
_defineProperty(TabPanelRoot, "displayName", 'TabPanel');
|
|
97
90
|
_defineProperty(TabPanelRoot, "style", style);
|
|
98
91
|
_defineProperty(TabPanelRoot, "defaultProps", {
|
|
@@ -103,17 +96,26 @@ _defineProperty(TabPanelRoot, "enhance", [a11yEnhance(optionsA11yEnhance)]);
|
|
|
103
96
|
function TabPanelItem(props) {
|
|
104
97
|
var _ref2 = arguments[0],
|
|
105
98
|
_ref6;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
const STabPanelItem = Box;
|
|
100
|
+
const {
|
|
101
|
+
Children,
|
|
102
|
+
styles,
|
|
103
|
+
addonLeft,
|
|
104
|
+
addonRight,
|
|
105
|
+
buttonRefsList,
|
|
106
|
+
index
|
|
107
|
+
} = props;
|
|
108
|
+
const buttonRef = React.useRef();
|
|
109
|
+
buttonRefsList[index] = buttonRef;
|
|
110
|
+
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(STabPanelItem, _ref6.cn("STabPanelItem", {
|
|
111
|
+
..._assignProps2({
|
|
112
|
+
"type": 'button',
|
|
113
|
+
"tag": 'button',
|
|
114
|
+
"tabIndex": 0,
|
|
115
|
+
"role": 'tab',
|
|
116
|
+
"ref": buttonRef
|
|
117
|
+
}, _ref2)
|
|
118
|
+
}), addonLeft ? /*#__PURE__*/React.createElement(TabPanel.Item.Addon, {
|
|
117
119
|
tag: addonLeft
|
|
118
120
|
}) : null, addonTextChildren(Children, TabPanel.Item.Text, TabPanel.Item.Addon), addonRight ? /*#__PURE__*/React.createElement(TabPanel.Item.Addon, {
|
|
119
121
|
tag: addonRight
|
|
@@ -122,29 +124,45 @@ function TabPanelItem(props) {
|
|
|
122
124
|
function Text(props) {
|
|
123
125
|
var _ref3 = arguments[0],
|
|
124
126
|
_ref7;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
const SText = UikitText;
|
|
128
|
+
const {
|
|
129
|
+
styles,
|
|
130
|
+
ellipsis = true,
|
|
131
|
+
buttonRefsList,
|
|
132
|
+
index,
|
|
133
|
+
hintProps = {}
|
|
134
|
+
} = props;
|
|
135
|
+
return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SText, _ref7.cn("SText", {
|
|
136
|
+
..._assignProps3({
|
|
137
|
+
"size": 200,
|
|
138
|
+
"ellipsis": ellipsis,
|
|
139
|
+
"medium": true,
|
|
140
|
+
"use:hintProps": {
|
|
141
|
+
triggerRef: buttonRefsList[index],
|
|
142
|
+
...hintProps
|
|
143
|
+
}
|
|
144
|
+
}, _ref3)
|
|
145
|
+
}));
|
|
130
146
|
}
|
|
131
147
|
function Addon(props) {
|
|
132
148
|
var _ref4 = arguments[0],
|
|
133
149
|
_ref8;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
150
|
+
const SAddon = Box;
|
|
151
|
+
const {
|
|
152
|
+
styles
|
|
153
|
+
} = props;
|
|
154
|
+
return _ref8 = sstyled(styles), /*#__PURE__*/React.createElement(SAddon, _ref8.cn("SAddon", {
|
|
155
|
+
..._assignProps4({
|
|
156
|
+
"tag": 'span'
|
|
157
|
+
}, _ref4)
|
|
158
|
+
}));
|
|
139
159
|
}
|
|
140
|
-
|
|
160
|
+
const TabPanel = createComponent(TabPanelRoot, {
|
|
141
161
|
Item: [TabPanelItem, {
|
|
142
|
-
Text
|
|
143
|
-
Addon
|
|
162
|
+
Text,
|
|
163
|
+
Addon
|
|
144
164
|
}]
|
|
145
165
|
});
|
|
146
|
-
export
|
|
147
|
-
return wrapper;
|
|
148
|
-
};
|
|
166
|
+
export const wrapTabPanel = wrapper => wrapper;
|
|
149
167
|
export default TabPanel;
|
|
150
168
|
//# sourceMappingURL=TabPanel.js.map
|
package/lib/es6/TabPanel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabPanel.js","names":["createComponent","Component","sstyled","Root","addonTextChildren","a11yEnhance","
|
|
1
|
+
{"version":3,"file":"TabPanel.js","names":["Box","createComponent","Component","sstyled","Root","addonTextChildren","a11yEnhance","Text","UikitText","React","style","_sstyled","insert","optionsA11yEnhance","onNeighborChange","neighborElement","props","focus","behavior","click","childSelector","TabPanelRoot","constructor","args","_defineProperty","value","event","handlers","key","preventDefault","uncontrolledProps","getItemProps","index","asProps","isSelected","handleClick","handleKeyDown","buttonRefsList","getItemTextProps","_","render","_ref","_ref5","STabPanel","styles","createElement","cn","_assignProps","defaultValue","TabPanelItem","_ref2","arguments[0]","_ref6","STabPanelItem","Children","addonLeft","addonRight","buttonRef","useRef","_assignProps2","TabPanel","Item","Addon","tag","_ref3","_ref7","SText","ellipsis","hintProps","_assignProps3","triggerRef","_ref4","_ref8","SAddon","_assignProps4","wrapTabPanel","wrapper"],"sources":["../../src/TabPanel.jsx"],"sourcesContent":["import { 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-panel.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 TabPanelRoot extends Component {\n static displayName = 'TabPanel';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n behavior: 'manual',\n };\n\n static enhance = [a11yEnhance(optionsA11yEnhance)];\n\n buttonRefsList = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n handleClick = (value) => (event) => {\n this.handlers.value(value, event);\n };\n\n handleKeyDown = (value) => (event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handlers.value(value, event);\n }\n };\n\n getItemProps(props, index) {\n const { value } = this.asProps;\n const isSelected = value === props.value;\n return {\n 'selected': isSelected,\n 'onClick': this.handleClick(props.value),\n 'onKeyDown': this.handleKeyDown(props.value),\n 'tabIndex': isSelected ? 0 : -1,\n 'aria-selected': isSelected,\n 'buttonRefsList': this.buttonRefsList,\n index,\n };\n }\n\n getItemTextProps(_, index) {\n return {\n buttonRefsList: this.buttonRefsList,\n index,\n };\n }\n\n render() {\n const STabPanel = Root;\n const { styles } = this.asProps;\n\n return sstyled(styles)(<STabPanel render={Box} role='tablist' />);\n }\n}\n\nfunction TabPanelItem(props) {\n const STabPanelItem = Root;\n const { Children, styles, addonLeft, addonRight, buttonRefsList, index } = props;\n const buttonRef = React.useRef();\n\n buttonRefsList[index] = buttonRef;\n\n return sstyled(styles)(\n <STabPanelItem render={Box} type='button' tag='button' tabIndex={0} role='tab' ref={buttonRef}>\n {addonLeft ? <TabPanel.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabPanel.Item.Text, TabPanel.Item.Addon)}\n {addonRight ? <TabPanel.Item.Addon tag={addonRight} /> : null}\n </STabPanelItem>,\n );\n}\n\nfunction Text(props) {\n const SText = Root;\n const { styles, ellipsis = true, buttonRefsList, index, hintProps = {} } = props;\n return sstyled(styles)(<SText render={UikitText} size={200} ellipsis={ellipsis} medium use:hintProps={{ triggerRef: buttonRefsList[index], ...hintProps }} />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n const { styles } = props;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst TabPanel = createComponent(TabPanelRoot, {\n Item: [TabPanelItem, { Text, Addon }],\n});\n\nexport const wrapTabPanel = (wrapper) => wrapper;\n\nexport default TabPanel;\n"],"mappings":";;;;;;AAAA,SAASA,GAAG,QAAQ,0BAA0B;AAC9C,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,IAAI,I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;MAAA;MAAA,iBAAwB;QAAEG,UAAU,EAAEjC,cAAc,CAACL,KAAK,CAAC;QAAE,GAAGoC;MAAU;IAAC,GAAAJ,KAAA;EAAA,EAAG,CAAC;AAC/J;AAEA,SAASF,KAAKA,CAAC9C,KAAK,EAAE;EAAA,IAAAuD,KAAA,GAAApB,YAAA;IAAAqB,KAAA;EACpB,MAAMC,MAAM,GAE2BzE,GAAG;EAD1C,MAAM;IAAE4C;EAAO,CAAC,GAAG5B,KAAK;EACxB,OAAAwD,KAAA,GAAOrE,OAAO,CAACyC,MAAM,CAAC,eAACnC,KAAA,CAAAoC,aAAA,CAAC4B,MAAM,EAAAD,KAAA,CAAA1B,EAAA;IAAA,GAAA4B,aAAA;MAAA,OAAkB;IAAM,GAAAH,KAAA;EAAA,EAAE,CAAC;AAC3D;AAEA,MAAMX,QAAQ,GAAG3D,eAAe,CAACoB,YAAY,EAAE;EAC7CwC,IAAI,EAAE,CAACZ,YAAY,EAAE;IAAE1C,IAAI;IAAEuD;EAAM,CAAC;AACtC,CAAC,CAAC;AAEF,OAAO,MAAMa,YAAY,GAAIC,OAAO,IAAKA,OAAO;AAEhD,eAAehB,QAAQ","ignoreList":[]}
|
package/lib/es6/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { Box, BoxProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\nexport type TabPanelValue = string | number | boolean;\n\nexport type TabPanelProps<T extends TabPanelValue = TabPanelValue> = BoxProps & {\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 * 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 TabPanelItemProps = BoxProps & {\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?: TabPanelValue;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n};\n\nexport type TabPanelContext = {\n getItemProps: PropGetterFn;\n};\n\nexport type TabPanelHandlers = {\n value: (value: TabPanelValue) => void;\n};\n\ntype IntergalacticTabPanelComponent<PropsExtending = {}> = (<\n Value extends TabPanelValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n TabPanelProps<Value>,\n TabPanelContext,\n [handlers: TabPanelHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', TabPanelProps>;\n\ndeclare const TabPanel: IntergalacticTabPanelComponent & {\n Item: Intergalactic.Component<'div', TabPanelItemProps, {}, [handlers: TabPanelHandlers]> & {\n Text: typeof Box;\n Addon: typeof Box;\n };\n};\n\ndeclare const wrapTabPanel: <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticTabPanelComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => IntergalacticTabPanelComponent<PropsExtending>;\nexport { wrapTabPanel };\n\nexport default TabPanel;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -40,12 +40,6 @@ STabPanelItem {
|
|
|
40
40
|
font-family: inherit;
|
|
41
41
|
cursor: pointer;
|
|
42
42
|
|
|
43
|
-
& SText {
|
|
44
|
-
font-size: var(--intergalactic-fs-200, 14px);
|
|
45
|
-
line-height: var(--intergalactic-lh-200, 142%);
|
|
46
|
-
font-weight: var(--intergalactic-medium, 500);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
43
|
&::-moz-focus-inner {
|
|
50
44
|
border: none;
|
|
51
45
|
padding: 0;
|
|
@@ -96,11 +90,7 @@ STabPanelItem[selected] {
|
|
|
96
90
|
}
|
|
97
91
|
|
|
98
92
|
SText {
|
|
99
|
-
display: inline-block;
|
|
100
93
|
margin: auto var(--intergalactic-spacing-2x, 8px);
|
|
101
|
-
white-space: nowrap;
|
|
102
|
-
overflow: hidden;
|
|
103
|
-
text-overflow: ellipsis;
|
|
104
94
|
}
|
|
105
95
|
|
|
106
96
|
SAddon {
|
package/lib/esm/TabPanel.mjs
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
-
import { createComponent, sstyled,
|
|
2
|
+
import { createComponent, sstyled, Component, assignProps } from "@semcore/core";
|
|
3
|
+
import { Box } from "@semcore/base-components";
|
|
8
4
|
import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
9
5
|
import a11yEnhance from "@semcore/core/lib/utils/enhances/a11yEnhance";
|
|
10
|
-
import {
|
|
6
|
+
import { Text as Text$1 } from "@semcore/typography";
|
|
11
7
|
import React from "react";
|
|
12
8
|
/*!__reshadow-styles__:"./style/tab-panel.shadow.css"*/
|
|
13
|
-
|
|
9
|
+
const style = (
|
|
14
10
|
/*__reshadow_css_start__*/
|
|
15
11
|
(sstyled.insert(
|
|
16
12
|
/*__inner_css_start__*/
|
|
17
|
-
'.
|
|
13
|
+
'.___STabPanel_1w4cf_gg_{display:flex;width:100%;max-width:100%}.___STabPanel_1w4cf_gg_::after{content:"";position:relative;bottom:-1px;flex:1;border-top:1px solid transparent;border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabPanelItem_1w4cf_gg_{position:relative;bottom:-1px;display:inline-flex;min-width:0;height:32px;color:var(--intergalactic-text-secondary, #6c6e79);border:1px solid transparent;border-bottom:none;border-radius:var(--intergalactic-control-rounded, 6px) var(--intergalactic-control-rounded, 6px)0 0;background:0 0;align-items:center;justify-content:center;touch-action:manipulation;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0 0 1px;margin:0;box-shadow:none;-webkit-text-decoration:none;text-decoration:none;-webkit-tap-highlight-color:transparent;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer}.___STabPanelItem_1w4cf_gg_::-moz-focus-inner{border:0;padding:0}.___STabPanelItem_1w4cf_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabPanelItem_1w4cf_gg_:hover{-webkit-text-decoration:none;text-decoration:none;color:var(--intergalactic-text-primary, #191b23)}}.___STabPanelItem_1w4cf_gg_::after{content:"";position:absolute;left:-1px;bottom:0;width:calc(100% + 2px);border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabPanelItem_1w4cf_gg_.__disabled_1w4cf_gg_{cursor:default;pointer-events:none}.___STabPanelItem_1w4cf_gg_.__disabled_1w4cf_gg_ .___SAddon_1w4cf_gg_,.___STabPanelItem_1w4cf_gg_.__disabled_1w4cf_gg_ .___SText_1w4cf_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___STabPanelItem_1w4cf_gg_.__selected_1w4cf_gg_{color:var(--intergalactic-text-link, #006dca);border-color:var(--intergalactic-border-primary, #c4c7cf);flex-shrink:0}@media (hover:hover){.___STabPanelItem_1w4cf_gg_.__selected_1w4cf_gg_:hover{color:var(--intergalactic-text-link-hover-active, #044792)}}.___STabPanelItem_1w4cf_gg_.__selected_1w4cf_gg_::after{border-bottom:none}.___SText_1w4cf_gg_{margin:auto var(--intergalactic-spacing-2x, 8px)}.___SAddon_1w4cf_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_1w4cf_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1w4cf_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1w4cf_gg_:only-child{margin-right:var(--intergalactic-spacing-2x, 8px);margin-left:var(--intergalactic-spacing-2x, 8px)}',
|
|
18
14
|
/*__inner_css_end__*/
|
|
19
|
-
"
|
|
15
|
+
"1w4cf_gg_"
|
|
20
16
|
), /*__reshadow_css_end__*/
|
|
21
17
|
{
|
|
22
|
-
"__SText": "
|
|
23
|
-
"__SAddon": "
|
|
24
|
-
"__STabPanel": "
|
|
25
|
-
"__STabPanelItem": "
|
|
26
|
-
"_disabled": "
|
|
27
|
-
"_selected": "
|
|
18
|
+
"__SText": "___SText_1w4cf_gg_",
|
|
19
|
+
"__SAddon": "___SAddon_1w4cf_gg_",
|
|
20
|
+
"__STabPanel": "___STabPanel_1w4cf_gg_",
|
|
21
|
+
"__STabPanelItem": "___STabPanelItem_1w4cf_gg_",
|
|
22
|
+
"_disabled": "__disabled_1w4cf_gg_",
|
|
23
|
+
"_selected": "__selected_1w4cf_gg_"
|
|
28
24
|
})
|
|
29
25
|
);
|
|
30
|
-
|
|
31
|
-
onNeighborChange:
|
|
26
|
+
const optionsA11yEnhance = {
|
|
27
|
+
onNeighborChange: (neighborElement, props) => {
|
|
32
28
|
if (neighborElement) {
|
|
33
29
|
neighborElement.focus();
|
|
34
30
|
if (props.behavior === "auto") {
|
|
@@ -38,62 +34,59 @@ var optionsA11yEnhance = {
|
|
|
38
34
|
},
|
|
39
35
|
childSelector: ["role", "tab"]
|
|
40
36
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
_this = _callSuper(this, TabPanelRoot2, [].concat(args));
|
|
49
|
-
_defineProperty(_this, "handleClick", function(value) {
|
|
50
|
-
return function(event) {
|
|
51
|
-
_this.handlers.value(value, event);
|
|
52
|
-
};
|
|
37
|
+
class TabPanelRoot extends Component {
|
|
38
|
+
constructor(...args) {
|
|
39
|
+
super(...args);
|
|
40
|
+
_defineProperty(this, "buttonRefsList", []);
|
|
41
|
+
_defineProperty(this, "handleClick", (value) => (event) => {
|
|
42
|
+
this.handlers.value(value, event);
|
|
53
43
|
});
|
|
54
|
-
_defineProperty(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
};
|
|
44
|
+
_defineProperty(this, "handleKeyDown", (value) => (event) => {
|
|
45
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
this.handlers.value(value, event);
|
|
48
|
+
}
|
|
61
49
|
});
|
|
62
|
-
return _this;
|
|
63
50
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
51
|
+
uncontrolledProps() {
|
|
52
|
+
return {
|
|
53
|
+
value: null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
getItemProps(props, index) {
|
|
57
|
+
const {
|
|
58
|
+
value
|
|
59
|
+
} = this.asProps;
|
|
60
|
+
const isSelected = value === props.value;
|
|
61
|
+
return {
|
|
62
|
+
"selected": isSelected,
|
|
63
|
+
"onClick": this.handleClick(props.value),
|
|
64
|
+
"onKeyDown": this.handleKeyDown(props.value),
|
|
65
|
+
"tabIndex": isSelected ? 0 : -1,
|
|
66
|
+
"aria-selected": isSelected,
|
|
67
|
+
"buttonRefsList": this.buttonRefsList,
|
|
68
|
+
index
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
getItemTextProps(_, index) {
|
|
72
|
+
return {
|
|
73
|
+
buttonRefsList: this.buttonRefsList,
|
|
74
|
+
index
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
var _ref = this.asProps, _ref5;
|
|
79
|
+
const STabPanel = Box;
|
|
80
|
+
const {
|
|
81
|
+
styles
|
|
82
|
+
} = this.asProps;
|
|
83
|
+
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(STabPanel, _ref5.cn("STabPanel", {
|
|
84
|
+
...assignProps({
|
|
92
85
|
"role": "tablist"
|
|
93
|
-
}, _ref)
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
86
|
+
}, _ref)
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
97
90
|
_defineProperty(TabPanelRoot, "displayName", "TabPanel");
|
|
98
91
|
_defineProperty(TabPanelRoot, "style", style);
|
|
99
92
|
_defineProperty(TabPanelRoot, "defaultProps", {
|
|
@@ -103,14 +96,26 @@ _defineProperty(TabPanelRoot, "defaultProps", {
|
|
|
103
96
|
_defineProperty(TabPanelRoot, "enhance", [a11yEnhance(optionsA11yEnhance)]);
|
|
104
97
|
function TabPanelItem(props) {
|
|
105
98
|
var _ref2 = arguments[0], _ref6;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
99
|
+
const STabPanelItem = Box;
|
|
100
|
+
const {
|
|
101
|
+
Children,
|
|
102
|
+
styles,
|
|
103
|
+
addonLeft,
|
|
104
|
+
addonRight,
|
|
105
|
+
buttonRefsList,
|
|
106
|
+
index
|
|
107
|
+
} = props;
|
|
108
|
+
const buttonRef = React.useRef();
|
|
109
|
+
buttonRefsList[index] = buttonRef;
|
|
110
|
+
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(STabPanelItem, _ref6.cn("STabPanelItem", {
|
|
111
|
+
...assignProps({
|
|
112
|
+
"type": "button",
|
|
113
|
+
"tag": "button",
|
|
114
|
+
"tabIndex": 0,
|
|
115
|
+
"role": "tab",
|
|
116
|
+
"ref": buttonRef
|
|
117
|
+
}, _ref2)
|
|
118
|
+
}), addonLeft ? /* @__PURE__ */ React.createElement(TabPanel.Item.Addon, {
|
|
114
119
|
tag: addonLeft
|
|
115
120
|
}) : null, addonTextChildren(Children, TabPanel.Item.Text, TabPanel.Item.Addon), addonRight ? /* @__PURE__ */ React.createElement(TabPanel.Item.Addon, {
|
|
116
121
|
tag: addonRight
|
|
@@ -118,29 +123,45 @@ function TabPanelItem(props) {
|
|
|
118
123
|
}
|
|
119
124
|
function Text(props) {
|
|
120
125
|
var _ref3 = arguments[0], _ref7;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
const SText = Text$1;
|
|
127
|
+
const {
|
|
128
|
+
styles,
|
|
129
|
+
ellipsis = true,
|
|
130
|
+
buttonRefsList,
|
|
131
|
+
index,
|
|
132
|
+
hintProps = {}
|
|
133
|
+
} = props;
|
|
134
|
+
return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SText, _ref7.cn("SText", {
|
|
135
|
+
...assignProps({
|
|
136
|
+
"size": 200,
|
|
137
|
+
"ellipsis": ellipsis,
|
|
138
|
+
"medium": true,
|
|
139
|
+
"use:hintProps": {
|
|
140
|
+
triggerRef: buttonRefsList[index],
|
|
141
|
+
...hintProps
|
|
142
|
+
}
|
|
143
|
+
}, _ref3)
|
|
144
|
+
}));
|
|
126
145
|
}
|
|
127
146
|
function Addon(props) {
|
|
128
147
|
var _ref4 = arguments[0], _ref8;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
148
|
+
const SAddon = Box;
|
|
149
|
+
const {
|
|
150
|
+
styles
|
|
151
|
+
} = props;
|
|
152
|
+
return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(SAddon, _ref8.cn("SAddon", {
|
|
153
|
+
...assignProps({
|
|
154
|
+
"tag": "span"
|
|
155
|
+
}, _ref4)
|
|
156
|
+
}));
|
|
134
157
|
}
|
|
135
|
-
|
|
158
|
+
const TabPanel = createComponent(TabPanelRoot, {
|
|
136
159
|
Item: [TabPanelItem, {
|
|
137
160
|
Text,
|
|
138
161
|
Addon
|
|
139
162
|
}]
|
|
140
163
|
});
|
|
141
|
-
|
|
142
|
-
return wrapper;
|
|
143
|
-
};
|
|
164
|
+
const wrapTabPanel = (wrapper) => wrapper;
|
|
144
165
|
export {
|
|
145
166
|
TabPanel as default,
|
|
146
167
|
wrapTabPanel
|
|
@@ -40,12 +40,6 @@ STabPanelItem {
|
|
|
40
40
|
font-family: inherit;
|
|
41
41
|
cursor: pointer;
|
|
42
42
|
|
|
43
|
-
& SText {
|
|
44
|
-
font-size: var(--intergalactic-fs-200, 14px);
|
|
45
|
-
line-height: var(--intergalactic-lh-200, 142%);
|
|
46
|
-
font-weight: var(--intergalactic-medium, 500);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
43
|
&::-moz-focus-inner {
|
|
50
44
|
border: none;
|
|
51
45
|
padding: 0;
|
|
@@ -96,11 +90,7 @@ STabPanelItem[selected] {
|
|
|
96
90
|
}
|
|
97
91
|
|
|
98
92
|
SText {
|
|
99
|
-
display: inline-block;
|
|
100
93
|
margin: auto var(--intergalactic-spacing-2x, 8px);
|
|
101
|
-
white-space: nowrap;
|
|
102
|
-
overflow: hidden;
|
|
103
|
-
text-overflow: ellipsis;
|
|
104
94
|
}
|
|
105
95
|
|
|
106
96
|
SAddon {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Box, BoxProps } from '@semcore/base-components';
|
|
2
|
+
import type { PropGetterFn, Intergalactic } from '@semcore/core';
|
|
3
3
|
import type React from 'react';
|
|
4
4
|
|
|
5
5
|
export type TabPanelValue = string | number | boolean;
|
|
6
6
|
|
|
7
|
-
/** @deprecated */
|
|
8
|
-
export interface ITabPanelProps<T extends TabPanelValue = TabPanelValue>
|
|
9
|
-
extends TabPanelProps<T>,
|
|
10
|
-
UnknownProperties {}
|
|
11
7
|
export type TabPanelProps<T extends TabPanelValue = TabPanelValue> = BoxProps & {
|
|
12
8
|
/** Is invoked when changing the selection */
|
|
13
9
|
onChange?:
|
|
@@ -28,8 +24,6 @@ export type TabPanelProps<T extends TabPanelValue = TabPanelValue> = BoxProps &
|
|
|
28
24
|
behavior?: 'auto' | 'manual';
|
|
29
25
|
};
|
|
30
26
|
|
|
31
|
-
/** @deprecated */
|
|
32
|
-
export interface ITabPanelItemProps extends TabPanelItemProps, UnknownProperties {}
|
|
33
27
|
export type TabPanelItemProps = BoxProps & {
|
|
34
28
|
/** Makes a tab selected. This property is determined automatically depending on the value. */
|
|
35
29
|
selected?: boolean;
|
|
@@ -43,14 +37,10 @@ export type TabPanelItemProps = BoxProps & {
|
|
|
43
37
|
addonRight?: React.ElementType;
|
|
44
38
|
};
|
|
45
39
|
|
|
46
|
-
/** @deprecated */
|
|
47
|
-
export interface ITabPanelContext extends TabPanelContext, UnknownProperties {}
|
|
48
40
|
export type TabPanelContext = {
|
|
49
41
|
getItemProps: PropGetterFn;
|
|
50
42
|
};
|
|
51
43
|
|
|
52
|
-
/** @deprecated */
|
|
53
|
-
export interface ITabPanelHandlers extends TabPanelHandlers, UnknownProperties {}
|
|
54
44
|
export type TabPanelHandlers = {
|
|
55
45
|
value: (value: TabPanelValue) => void;
|
|
56
46
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/tab-panel",
|
|
3
3
|
"description": "Semrush TabPanel Component",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "17.0.0-prerelease.17",
|
|
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
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/
|
|
17
|
+
"@semcore/typography": "^16.3.3-prerelease.17"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@semcore/base-components": "^
|
|
20
|
+
"@semcore/base-components": "^17.0.0-prerelease.17"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -25,9 +25,10 @@
|
|
|
25
25
|
"directory": "semcore/tab-panel"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@semcore/core": "
|
|
28
|
+
"@semcore/core": "17.0.0-prerelease.17",
|
|
29
|
+
"@semcore/base-components": "17.0.0-prerelease.17",
|
|
29
30
|
"@semcore/testing-utils": "1.0.0",
|
|
30
|
-
"@semcore/icon": "16.7.2"
|
|
31
|
+
"@semcore/icon": "16.7.2-prerelease.17"
|
|
31
32
|
},
|
|
32
33
|
"scripts": {
|
|
33
34
|
"build": "pnpm semcore-builder --source=js && pnpm vite build"
|