@semcore/tab-panel 16.1.0-prerelease.3 → 16.1.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/lib/cjs/TabPanel.js +54 -30
- package/lib/cjs/TabPanel.js.map +1 -1
- package/lib/cjs/TabPanel.type.js +2 -0
- package/lib/cjs/TabPanel.type.js.map +1 -0
- package/lib/cjs/index.js +13 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/tab-panel.shadow.css +0 -10
- package/lib/es6/TabPanel.js +51 -27
- package/lib/es6/TabPanel.js.map +1 -1
- package/lib/es6/TabPanel.type.js +2 -0
- package/lib/es6/TabPanel.type.js.map +1 -0
- package/lib/es6/index.js +2 -2
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/tab-panel.shadow.css +0 -10
- package/lib/esm/TabPanel.mjs +47 -29
- package/lib/esm/TabPanel.type.mjs +1 -0
- package/lib/esm/index.mjs +1 -0
- package/lib/esm/style/tab-panel.shadow.css +0 -10
- package/lib/types/TabPanel.d.ts +6 -0
- package/lib/types/TabPanel.type.d.ts +71 -0
- package/lib/types/index.d.ts +2 -90
- package/package.json +5 -5
- 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/lib/cjs/TabPanel.js
CHANGED
|
@@ -12,32 +12,22 @@ var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSup
|
|
|
12
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
14
|
var _core = require("@semcore/core");
|
|
15
|
+
var _baseComponents = require("@semcore/base-components");
|
|
15
16
|
var _addonTextChildren = _interopRequireDefault(require("@semcore/core/lib/utils/addonTextChildren"));
|
|
16
17
|
var _a11yEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/a11yEnhance"));
|
|
17
|
-
var
|
|
18
|
+
var _typography = require("@semcore/typography");
|
|
18
19
|
var _react = _interopRequireDefault(require("react"));
|
|
19
20
|
/*!__reshadow-styles__:"./style/tab-panel.shadow.css"*/
|
|
20
|
-
var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
21
|
+
var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___STabPanel_13pnv_gg_{display:flex;width:100%;max-width:100%}.___STabPanel_13pnv_gg_::after{content:\"\";position:relative;bottom:-1px;flex:1;border-top:1px solid transparent;border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@supports (color:color(display-p3 0 0 0%)){.___STabPanel_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanel_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_13pnv_gg_{position:relative;bottom:-1px;display:inline-flex;min-width:0;height:32px;color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));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}@supports (color:color(display-p3 0 0 0%)){.___STabPanelItem_13pnv_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___STabPanelItem_13pnv_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___STabPanelItem_13pnv_gg_::-moz-focus-inner{border:0;padding:0}.___STabPanelItem_13pnv_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabPanelItem_13pnv_gg_:hover{-webkit-text-decoration:none;text-decoration:none;color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}}.___STabPanelItem_13pnv_gg_::after{content:\"\";position:absolute;left:-1px;bottom:0;width:calc(100% + 2px);border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@supports (color:color(display-p3 0 0 0%)){.___STabPanelItem_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_13pnv_gg_.__disabled_13pnv_gg_{cursor:default;pointer-events:none}.___STabPanelItem_13pnv_gg_.__disabled_13pnv_gg_ .___SAddon_13pnv_gg_,.___STabPanelItem_13pnv_gg_.__disabled_13pnv_gg_ .___SText_13pnv_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_{color:var(--intergalactic-text-link, rgb(35, 95, 226));border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161));flex-shrink:0}@supports (color:color(display-p3 0 0 0%)){.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_{border-color:var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}@media (hover:hover){.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_:hover{color:var(--intergalactic-text-link-hover-active, rgb(33, 89, 215))}}.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_::after{border-bottom:none}.___SText_13pnv_gg_{margin:auto var(--intergalactic-spacing-2x, 8px)}.___SAddon_13pnv_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_13pnv_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SAddon_13pnv_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SAddon_13pnv_gg_:only-child{margin-right:var(--intergalactic-spacing-2x, 8px);margin-left:var(--intergalactic-spacing-2x, 8px)}", /*__inner_css_end__*/"13pnv_gg_"),
|
|
21
22
|
/*__reshadow_css_end__*/
|
|
22
23
|
{
|
|
23
|
-
"__SText": "
|
|
24
|
-
"__SAddon": "
|
|
25
|
-
"__STabPanel": "
|
|
26
|
-
"__STabPanelItem": "
|
|
27
|
-
"_disabled": "
|
|
28
|
-
"_selected": "
|
|
24
|
+
"__SText": "___SText_13pnv_gg_",
|
|
25
|
+
"__SAddon": "___SAddon_13pnv_gg_",
|
|
26
|
+
"__STabPanel": "___STabPanel_13pnv_gg_",
|
|
27
|
+
"__STabPanelItem": "___STabPanelItem_13pnv_gg_",
|
|
28
|
+
"_disabled": "__disabled_13pnv_gg_",
|
|
29
|
+
"_selected": "__selected_13pnv_gg_"
|
|
29
30
|
});
|
|
30
|
-
var optionsA11yEnhance = {
|
|
31
|
-
onNeighborChange: function 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
|
var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
42
32
|
function TabPanelRoot() {
|
|
43
33
|
var _this;
|
|
@@ -46,6 +36,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
46
36
|
args[_key] = arguments[_key];
|
|
47
37
|
}
|
|
48
38
|
_this = (0, _callSuper2["default"])(this, TabPanelRoot, [].concat(args));
|
|
39
|
+
(0, _defineProperty2["default"])(_this, "buttonRefsList", []);
|
|
49
40
|
(0, _defineProperty2["default"])(_this, "handleClick", function (value) {
|
|
50
41
|
return function (event) {
|
|
51
42
|
_this.handlers.value(value, event);
|
|
@@ -71,7 +62,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
71
62
|
}
|
|
72
63
|
}, {
|
|
73
64
|
key: "getItemProps",
|
|
74
|
-
value: function getItemProps(props,
|
|
65
|
+
value: function getItemProps(props, index) {
|
|
75
66
|
var value = this.asProps.value;
|
|
76
67
|
var isSelected = value === props.value;
|
|
77
68
|
return {
|
|
@@ -79,7 +70,17 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
79
70
|
'onClick': this.handleClick(props.value),
|
|
80
71
|
'onKeyDown': this.handleKeyDown(props.value),
|
|
81
72
|
'tabIndex': isSelected ? 0 : -1,
|
|
82
|
-
'aria-selected': isSelected
|
|
73
|
+
'aria-selected': isSelected,
|
|
74
|
+
'buttonRefsList': this.buttonRefsList,
|
|
75
|
+
index: index
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
key: "getItemTextProps",
|
|
80
|
+
value: function getItemTextProps(_, index) {
|
|
81
|
+
return {
|
|
82
|
+
buttonRefsList: this.buttonRefsList,
|
|
83
|
+
index: index
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
}, {
|
|
@@ -87,7 +88,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
87
88
|
value: function render() {
|
|
88
89
|
var _ref = this.asProps,
|
|
89
90
|
_ref5;
|
|
90
|
-
var STabPanel =
|
|
91
|
+
var STabPanel = _baseComponents.Box;
|
|
91
92
|
var styles = this.asProps.styles;
|
|
92
93
|
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(STabPanel, _ref5.cn("STabPanel", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
93
94
|
"role": 'tablist'
|
|
@@ -101,20 +102,36 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
101
102
|
defaultValue: null,
|
|
102
103
|
behavior: 'manual'
|
|
103
104
|
});
|
|
104
|
-
(0, _defineProperty2["default"])(TabPanelRoot, "enhance", [(0, _a11yEnhance["default"])(
|
|
105
|
+
(0, _defineProperty2["default"])(TabPanelRoot, "enhance", [(0, _a11yEnhance["default"])({
|
|
106
|
+
onNeighborChange: function onNeighborChange(neighborElement, props) {
|
|
107
|
+
if (neighborElement) {
|
|
108
|
+
neighborElement.focus();
|
|
109
|
+
if (props.behavior === 'auto') {
|
|
110
|
+
neighborElement.click();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
childSelector: ['role', 'tab']
|
|
115
|
+
})]);
|
|
116
|
+
;
|
|
105
117
|
function TabPanelItem(props) {
|
|
106
118
|
var _ref2 = arguments[0],
|
|
107
119
|
_ref6;
|
|
108
|
-
var STabPanelItem =
|
|
120
|
+
var STabPanelItem = _baseComponents.Box;
|
|
109
121
|
var Children = props.Children,
|
|
110
122
|
styles = props.styles,
|
|
111
123
|
addonLeft = props.addonLeft,
|
|
112
|
-
addonRight = props.addonRight
|
|
124
|
+
addonRight = props.addonRight,
|
|
125
|
+
buttonRefsList = props.buttonRefsList,
|
|
126
|
+
index = props.index;
|
|
127
|
+
var buttonRef = _react["default"].useRef();
|
|
128
|
+
buttonRefsList[index] = buttonRef;
|
|
113
129
|
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(STabPanelItem, _ref6.cn("STabPanelItem", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
114
130
|
"type": 'button',
|
|
115
131
|
"tag": 'button',
|
|
116
132
|
"tabIndex": 0,
|
|
117
|
-
"role": 'tab'
|
|
133
|
+
"role": 'tab',
|
|
134
|
+
"ref": buttonRef
|
|
118
135
|
}, _ref2))), addonLeft ? /*#__PURE__*/_react["default"].createElement(TabPanel.Item.Addon, {
|
|
119
136
|
tag: addonLeft
|
|
120
137
|
}) : null, (0, _addonTextChildren["default"])(Children, TabPanel.Item.Text, TabPanel.Item.Addon), addonRight ? /*#__PURE__*/_react["default"].createElement(TabPanel.Item.Addon, {
|
|
@@ -124,16 +141,23 @@ function TabPanelItem(props) {
|
|
|
124
141
|
function Text(props) {
|
|
125
142
|
var _ref3 = arguments[0],
|
|
126
143
|
_ref7;
|
|
127
|
-
var SText =
|
|
128
|
-
var styles = props.styles
|
|
144
|
+
var SText = _typography.Text;
|
|
145
|
+
var styles = props.styles,
|
|
146
|
+
_props$ellipsis = props.ellipsis,
|
|
147
|
+
ellipsis = _props$ellipsis === void 0 ? true : _props$ellipsis,
|
|
148
|
+
buttonRefsList = props.buttonRefsList,
|
|
149
|
+
index = props.index;
|
|
129
150
|
return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SText, _ref7.cn("SText", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
130
|
-
"
|
|
151
|
+
"size": 200,
|
|
152
|
+
"ellipsis": ellipsis,
|
|
153
|
+
"medium": true,
|
|
154
|
+
"hint:triggerRef": buttonRefsList[index]
|
|
131
155
|
}, _ref3))));
|
|
132
156
|
}
|
|
133
157
|
function Addon(props) {
|
|
134
158
|
var _ref4 = arguments[0],
|
|
135
159
|
_ref8;
|
|
136
|
-
var SAddon =
|
|
160
|
+
var SAddon = _baseComponents.Box;
|
|
137
161
|
var styles = props.styles;
|
|
138
162
|
return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref8.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
139
163
|
"tag": 'span'
|
package/lib/cjs/TabPanel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabPanel.js","names":["_core","require","_addonTextChildren","_interopRequireDefault","_a11yEnhance","_flexBox","_react","style","sstyled","insert","optionsA11yEnhance","onNeighborChange","neighborElement","props","focus","behavior","click","childSelector","TabPanelRoot","_Component","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","_callSuper2","concat","_defineProperty2","value","event","handlers","key","preventDefault","_inherits2","_createClass2","uncontrolledProps","getItemProps","_index","asProps","isSelected","handleClick","handleKeyDown","render","_ref","_ref5","STabPanel","Box","styles","createElement","cn","_objectSpread2","assignProps","Component","defaultValue","a11yEnhance","TabPanelItem","_ref2","arguments[0]","_ref6","STabPanelItem","Children","addonLeft","addonRight","TabPanel","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","SText","_ref4","_ref8","SAddon","createComponent","wrapTabPanel","exports","wrapper","_default"],"sources":["../../src/TabPanel.jsx"],"sourcesContent":["import { 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 { Box } from '@semcore/flex-box';\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 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 };\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 } = props;\n\n return sstyled(styles)(\n <STabPanelItem render={Box} type='button' tag='button' tabIndex={0} role='tab'>\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 } = props;\n return sstyled(styles)(<SText render={Box} tag='span' />);\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,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AAA0B;AAAA,IAAAM,KAAA,8BAAAP,KAAA,CAAAQ,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI1B,IAAMC,kBAAkB,GAAG;EACzBC,gBAAgB,EAAE,SAAlBA,gBAAgBA,CAAGC,eAAe,EAAEC,KAAK,EAAK;IAC5C,IAAID,eAAe,EAAE;MACnBA,eAAe,CAACE,KAAK,CAAC,CAAC;MACvB,IAAID,KAAK,CAACE,QAAQ,KAAK,MAAM,EAAE;QAC7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AAAsD,WAAA;IAAA,OAAkB;EAAM,GAAAkB,KAAA,GAAE,CAAC;AAC1D;AAEA,SAASJ,KAAKA,CAACvD,KAAK,EAAE;EAAA,IAAA8D,KAAA,GAAAf,YAAA;IAAAgB,KAAA;EACpB,IAAMC,MAAM,GAE2B5B,YAAG;EAD1C,IAAQC,MAAM,GAAKrC,KAAK,CAAhBqC,MAAM;EACd,OAAA0B,KAAA,GAAO,IAAApE,aAAO,EAAC0C,MAAM,CAAC,eAAC5C,MAAA,YAAA6C,aAAA,CAAC0B,MAAM,EAAAD,KAAA,CAAAxB,EAAA,eAAAC,cAAA,qBAAArD,KAAA,CAAAsD,WAAA;IAAA,OAAkB;EAAM,GAAAqB,KAAA,GAAE,CAAC;AAC3D;AAEA,IAAMT,QAAQ,GAAG,IAAAY,qBAAe,EAAC5D,YAAY,EAAE;EAC7CiD,IAAI,EAAE,CAACT,YAAY,EAAE;IAAEa,IAAI,EAAJA,IAAI;IAAEH,KAAK,EAALA;EAAM,CAAC;AACtC,CAAC,CAAC;AAEK,IAAMW,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,SAAfA,YAAYA,CAAIE,OAAO;EAAA,OAAKA,OAAO;AAAA;AAAC,IAAAC,QAAA,GAAAF,OAAA,cAElCd,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"TabPanel.js","names":["_core","require","_baseComponents","_addonTextChildren","_interopRequireDefault","_a11yEnhance","_typography","_react","style","sstyled","insert","TabPanelRoot","_Component","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","_callSuper2","concat","_defineProperty2","value","event","handlers","key","preventDefault","_inherits2","_createClass2","uncontrolledProps","getItemProps","props","index","asProps","isSelected","handleClick","handleKeyDown","buttonRefsList","getItemTextProps","_","render","_ref","_ref5","STabPanel","Box","styles","createElement","cn","_objectSpread2","assignProps","Component","defaultValue","behavior","a11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","TabPanelItem","_ref2","arguments[0]","_ref6","STabPanelItem","Children","addonLeft","addonRight","buttonRef","React","useRef","TabPanel","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","SText","UikitText","_props$ellipsis","ellipsis","_ref4","_ref8","SAddon","createComponent","wrapTabPanel","exports","wrapper","_default"],"sources":["../../src/TabPanel.tsx"],"sourcesContent":["import { 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 UikitText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/tab-panel.shadow.css';\nimport type { NSTabPanel } from './TabPanel.type';\n\nclass TabPanelRoot extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSTabPanel.Component>,\n typeof TabPanelRoot.enhance,\n NSTabPanel.Handlers\n> {\n static displayName = 'TabPanel';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n behavior: 'manual',\n };\n\n static enhance = [\n 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 }),\n ] as const;\n\n buttonRefsList: Array<React.MutableRefObject<HTMLButtonElement | undefined>> = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n handleClick = (value: NSTabPanel.Props['value']) => (event: React.MouseEvent<HTMLButtonElement>) => {\n this.handlers.value(value, event);\n };\n\n handleKeyDown = (value: NSTabPanel.Props['value']) => (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handlers.value(value, event);\n }\n };\n\n getItemProps(props: NSTabPanel.Item.Props, index: number) {\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(_: NSTabPanel.Item.Text.Props, index: number) {\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(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabPanel.Item.Component,\n typeof TabPanelRoot,\n 'Item'\n >,\n) {\n const STabPanelItem = Root;\n const { Children, styles, addonLeft, addonRight, buttonRefsList, index } = props;\n const buttonRef = React.useRef<HTMLButtonElement>();\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(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabPanel.Item.Text.Component,\n typeof TabPanelRoot,\n 'ItemText'\n >,\n) {\n const SText = Root;\n const { styles, ellipsis = true, buttonRefsList, index } = props;\n return sstyled(styles)(<SText render={UikitText} size={200} ellipsis={ellipsis} medium hint:triggerRef={buttonRefsList[index]} />);\n}\n\nfunction Addon(\n props: Intergalactic.InternalTypings.InferComponentProps<NSTabPanel.Item.Addon.Component>,\n) {\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}) as unknown as NSTabPanel.Component;\n\nexport const wrapTabPanel = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSTabPanel.WrapperComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSTabPanel.WrapperComponent<PropsExtending>;\n\nexport default TabPanel;\n"],"mappings":";;;;;;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA0B;AAAA,IAAAO,KAAA,8BAAAR,KAAA,CAAAS,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,IAKpBC,YAAY,0BAAAC,UAAA;EAAA,SAAAD,aAAA;IAAA,IAAAE,KAAA;IAAA,IAAAC,gBAAA,mBAAAH,YAAA;IAAA,SAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAAF,IAAA,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAAAP,KAAA,OAAAQ,WAAA,mBAAAV,YAAA,KAAAW,MAAA,CAAAJ,IAAA;IAAA,IAAAK,gBAAA,aAAAV,KAAA,oBA0B+D,EAAE;IAAA,IAAAU,gBAAA,aAAAV,KAAA,iBAQnE,UAACW,KAAgC;MAAA,OAAK,UAACC,KAA0C,EAAK;QAClGZ,KAAA,CAAKa,QAAQ,CAACF,KAAK,CAACA,KAAK,EAAEC,KAAK,CAAC;MACnC,CAAC;IAAA;IAAA,IAAAF,gBAAA,aAAAV,KAAA,mBAEe,UAACW,KAAgC;MAAA,OAAK,UAACC,KAA6C,EAAK;QACvG,IAAIA,KAAK,CAACE,GAAG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AA,GAAO,IAAAtE,aAAO,EAACsC,MAAM,CAAC,eAACxC,MAAA,YAAAyC,aAAA,CAACgC,KAAK,EAAAD,KAAA,CAAA9B,EAAA,cAAAC,cAAA,qBAAAlD,KAAA,CAAAmD,WAAA;IAAA,QAA0B,GAAG;IAAA,YAAYgC,QAAQ;IAAA;IAAA,mBAA0B5C,cAAc,CAACL,KAAK;EAAC,GAAA4C,KAAA,GAAG,CAAC;AACnI;AAEA,SAASJ,KAAKA,CACZzC,KAAyF,EACzF;EAAA,IAAAmD,KAAA,GAAArB,YAAA;IAAAsB,KAAA;EACA,IAAMC,MAAM,GAE2BxC,mBAAG;EAD1C,IAAQC,MAAM,GAAKd,KAAK,CAAhBc,MAAM;EACd,OAAAsC,KAAA,GAAO,IAAA5E,aAAO,EAACsC,MAAM,CAAC,eAACxC,MAAA,YAAAyC,aAAA,CAACsC,MAAM,EAAAD,KAAA,CAAApC,EAAA,eAAAC,cAAA,qBAAAlD,KAAA,CAAAmD,WAAA;IAAA,OAAkB;EAAM,GAAAiC,KAAA,GAAE,CAAC;AAC3D;AAEA,IAAMZ,QAAQ,GAAG,IAAAe,qBAAe,EAAC5E,YAAY,EAAE;EAC7C8D,IAAI,EAAE,CAACZ,YAAY,EAAE;IAAEgB,IAAI,EAAJA,IAAI;IAAEH,KAAK,EAALA;EAAM,CAAC;AACtC,CAAC,CAAoC;AAE9B,IAAMc,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,SAAfA,YAAYA,CAA+BE,OAKpC;EAAA,OAAKA,OAAO;AAAA,CAA+C;AAAC,IAAAC,QAAA,GAAAF,OAAA,cAEjEjB,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabPanel.type.js","names":[],"sources":["../../src/TabPanel.type.ts"],"sourcesContent":["import type { Box, BoxProps } from '@semcore/base-components';\nimport type { Intergalactic, PropGetterFn } from '@semcore/core';\nimport type { NSText } from '@semcore/typography';\n\ndeclare namespace NSTabPanel {\n type Value = string | number | boolean;\n type Props<V extends NSTabPanel.Value = NSTabPanel.Value> = BoxProps & {\n /** Is invoked when changing the selection */\n onChange?:\n | ((value: V, e?: React.SyntheticEvent<HTMLButtonElement>) => void)\n | React.Dispatch<React.SetStateAction<V>>;\n /** Value of the selected tab */\n value?: V;\n /** Default value of the selected tab\n * @default null\n * */\n defaultValue?: V;\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 /** 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?: NSTabPanel.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: NSTabPanel.Handlers]> & {\n Text: Text.Component;\n Addon: Addon.Component;\n };\n }\n\n type WrapperComponent<PropsExtending = {}> = (<\n V extends NSTabPanel.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) & 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 TabPanelValue = NSTabPanel.Value;\n/** @deprecated It will be removed in v18. */\nexport type TabPanelProps<T extends TabPanelValue = TabPanelValue> = NSTabPanel.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type TabPanelItemProps = NSTabPanel.Item.Props;\n/** @deprecated It will be removed in v18. */\nexport type TabPanelContext = NSTabPanel.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type TabPanelHandlers = NSTabPanel.Handlers;\n\nexport type { NSTabPanel };\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
|
+
wrapTabPanel: true
|
|
9
|
+
};
|
|
8
10
|
Object.defineProperty(exports, "default", {
|
|
9
11
|
enumerable: true,
|
|
10
12
|
get: function get() {
|
|
11
13
|
return _TabPanel["default"];
|
|
12
14
|
}
|
|
13
15
|
});
|
|
16
|
+
Object.defineProperty(exports, "wrapTabPanel", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return _TabPanel.wrapTabPanel;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
14
22
|
var _TabPanel = _interopRequireWildcard(require("./TabPanel"));
|
|
15
|
-
|
|
23
|
+
var _TabPanel2 = require("./TabPanel.type");
|
|
24
|
+
Object.keys(_TabPanel2).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] === _TabPanel2[key]) return;
|
|
19
28
|
Object.defineProperty(exports, key, {
|
|
20
29
|
enumerable: true,
|
|
21
30
|
get: function get() {
|
|
22
|
-
return
|
|
31
|
+
return _TabPanel2[key];
|
|
23
32
|
}
|
|
24
33
|
});
|
|
25
34
|
});
|
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.
|
|
1
|
+
{"version":3,"file":"index.js","names":["_TabPanel","_interopRequireWildcard","require","_TabPanel2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.ts"],"sourcesContent":["export { default, wrapTabPanel } from './TabPanel';\nexport * from './TabPanel.type';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,UAAA,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,UAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAZ,UAAA,CAAAI,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
|
@@ -9,33 +9,23 @@ import { assignProps as _assignProps4 } from "@semcore/core";
|
|
|
9
9
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
10
10
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
11
11
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
12
|
+
import { Box } from '@semcore/base-components';
|
|
12
13
|
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
13
14
|
import addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';
|
|
14
15
|
import a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';
|
|
15
|
-
import {
|
|
16
|
+
import { Text as UikitText } from '@semcore/typography';
|
|
16
17
|
import React from 'react';
|
|
17
18
|
/*!__reshadow-styles__:"./style/tab-panel.shadow.css"*/
|
|
18
|
-
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
19
|
+
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___STabPanel_13pnv_gg_{display:flex;width:100%;max-width:100%}.___STabPanel_13pnv_gg_::after{content:\"\";position:relative;bottom:-1px;flex:1;border-top:1px solid transparent;border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@supports (color:color(display-p3 0 0 0%)){.___STabPanel_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanel_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_13pnv_gg_{position:relative;bottom:-1px;display:inline-flex;min-width:0;height:32px;color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));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}@supports (color:color(display-p3 0 0 0%)){.___STabPanelItem_13pnv_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___STabPanelItem_13pnv_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___STabPanelItem_13pnv_gg_::-moz-focus-inner{border:0;padding:0}.___STabPanelItem_13pnv_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabPanelItem_13pnv_gg_:hover{-webkit-text-decoration:none;text-decoration:none;color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}}.___STabPanelItem_13pnv_gg_::after{content:\"\";position:absolute;left:-1px;bottom:0;width:calc(100% + 2px);border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@supports (color:color(display-p3 0 0 0%)){.___STabPanelItem_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_13pnv_gg_.__disabled_13pnv_gg_{cursor:default;pointer-events:none}.___STabPanelItem_13pnv_gg_.__disabled_13pnv_gg_ .___SAddon_13pnv_gg_,.___STabPanelItem_13pnv_gg_.__disabled_13pnv_gg_ .___SText_13pnv_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_{color:var(--intergalactic-text-link, rgb(35, 95, 226));border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161));flex-shrink:0}@supports (color:color(display-p3 0 0 0%)){.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_{border-color:var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}@media (hover:hover){.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_:hover{color:var(--intergalactic-text-link-hover-active, rgb(33, 89, 215))}}.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_::after{border-bottom:none}.___SText_13pnv_gg_{margin:auto var(--intergalactic-spacing-2x, 8px)}.___SAddon_13pnv_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_13pnv_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SAddon_13pnv_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SAddon_13pnv_gg_:only-child{margin-right:var(--intergalactic-spacing-2x, 8px);margin-left:var(--intergalactic-spacing-2x, 8px)}", /*__inner_css_end__*/"13pnv_gg_"),
|
|
19
20
|
/*__reshadow_css_end__*/
|
|
20
21
|
{
|
|
21
|
-
"__SText": "
|
|
22
|
-
"__SAddon": "
|
|
23
|
-
"__STabPanel": "
|
|
24
|
-
"__STabPanelItem": "
|
|
25
|
-
"_disabled": "
|
|
26
|
-
"_selected": "
|
|
22
|
+
"__SText": "___SText_13pnv_gg_",
|
|
23
|
+
"__SAddon": "___SAddon_13pnv_gg_",
|
|
24
|
+
"__STabPanel": "___STabPanel_13pnv_gg_",
|
|
25
|
+
"__STabPanelItem": "___STabPanelItem_13pnv_gg_",
|
|
26
|
+
"_disabled": "__disabled_13pnv_gg_",
|
|
27
|
+
"_selected": "__selected_13pnv_gg_"
|
|
27
28
|
});
|
|
28
|
-
var optionsA11yEnhance = {
|
|
29
|
-
onNeighborChange: function onNeighborChange(neighborElement, props) {
|
|
30
|
-
if (neighborElement) {
|
|
31
|
-
neighborElement.focus();
|
|
32
|
-
if (props.behavior === 'auto') {
|
|
33
|
-
neighborElement.click();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
childSelector: ['role', 'tab']
|
|
38
|
-
};
|
|
39
29
|
var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
40
30
|
function TabPanelRoot() {
|
|
41
31
|
var _this;
|
|
@@ -44,6 +34,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
44
34
|
args[_key] = arguments[_key];
|
|
45
35
|
}
|
|
46
36
|
_this = _callSuper(this, TabPanelRoot, [].concat(args));
|
|
37
|
+
_defineProperty(_this, "buttonRefsList", []);
|
|
47
38
|
_defineProperty(_this, "handleClick", function (value) {
|
|
48
39
|
return function (event) {
|
|
49
40
|
_this.handlers.value(value, event);
|
|
@@ -69,7 +60,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
69
60
|
}
|
|
70
61
|
}, {
|
|
71
62
|
key: "getItemProps",
|
|
72
|
-
value: function getItemProps(props,
|
|
63
|
+
value: function getItemProps(props, index) {
|
|
73
64
|
var value = this.asProps.value;
|
|
74
65
|
var isSelected = value === props.value;
|
|
75
66
|
return {
|
|
@@ -77,7 +68,17 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
77
68
|
'onClick': this.handleClick(props.value),
|
|
78
69
|
'onKeyDown': this.handleKeyDown(props.value),
|
|
79
70
|
'tabIndex': isSelected ? 0 : -1,
|
|
80
|
-
'aria-selected': isSelected
|
|
71
|
+
'aria-selected': isSelected,
|
|
72
|
+
'buttonRefsList': this.buttonRefsList,
|
|
73
|
+
index: index
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "getItemTextProps",
|
|
78
|
+
value: function getItemTextProps(_, index) {
|
|
79
|
+
return {
|
|
80
|
+
buttonRefsList: this.buttonRefsList,
|
|
81
|
+
index: index
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
}, {
|
|
@@ -99,7 +100,18 @@ _defineProperty(TabPanelRoot, "defaultProps", {
|
|
|
99
100
|
defaultValue: null,
|
|
100
101
|
behavior: 'manual'
|
|
101
102
|
});
|
|
102
|
-
_defineProperty(TabPanelRoot, "enhance", [a11yEnhance(
|
|
103
|
+
_defineProperty(TabPanelRoot, "enhance", [a11yEnhance({
|
|
104
|
+
onNeighborChange: function onNeighborChange(neighborElement, props) {
|
|
105
|
+
if (neighborElement) {
|
|
106
|
+
neighborElement.focus();
|
|
107
|
+
if (props.behavior === 'auto') {
|
|
108
|
+
neighborElement.click();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
childSelector: ['role', 'tab']
|
|
113
|
+
})]);
|
|
114
|
+
;
|
|
103
115
|
function TabPanelItem(props) {
|
|
104
116
|
var _ref2 = arguments[0],
|
|
105
117
|
_ref6;
|
|
@@ -107,12 +119,17 @@ function TabPanelItem(props) {
|
|
|
107
119
|
var Children = props.Children,
|
|
108
120
|
styles = props.styles,
|
|
109
121
|
addonLeft = props.addonLeft,
|
|
110
|
-
addonRight = props.addonRight
|
|
122
|
+
addonRight = props.addonRight,
|
|
123
|
+
buttonRefsList = props.buttonRefsList,
|
|
124
|
+
index = props.index;
|
|
125
|
+
var buttonRef = React.useRef();
|
|
126
|
+
buttonRefsList[index] = buttonRef;
|
|
111
127
|
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(STabPanelItem, _ref6.cn("STabPanelItem", _objectSpread({}, _assignProps2({
|
|
112
128
|
"type": 'button',
|
|
113
129
|
"tag": 'button',
|
|
114
130
|
"tabIndex": 0,
|
|
115
|
-
"role": 'tab'
|
|
131
|
+
"role": 'tab',
|
|
132
|
+
"ref": buttonRef
|
|
116
133
|
}, _ref2))), addonLeft ? /*#__PURE__*/React.createElement(TabPanel.Item.Addon, {
|
|
117
134
|
tag: addonLeft
|
|
118
135
|
}) : null, addonTextChildren(Children, TabPanel.Item.Text, TabPanel.Item.Addon), addonRight ? /*#__PURE__*/React.createElement(TabPanel.Item.Addon, {
|
|
@@ -122,10 +139,17 @@ function TabPanelItem(props) {
|
|
|
122
139
|
function Text(props) {
|
|
123
140
|
var _ref3 = arguments[0],
|
|
124
141
|
_ref7;
|
|
125
|
-
var SText =
|
|
126
|
-
var styles = props.styles
|
|
142
|
+
var SText = UikitText;
|
|
143
|
+
var styles = props.styles,
|
|
144
|
+
_props$ellipsis = props.ellipsis,
|
|
145
|
+
ellipsis = _props$ellipsis === void 0 ? true : _props$ellipsis,
|
|
146
|
+
buttonRefsList = props.buttonRefsList,
|
|
147
|
+
index = props.index;
|
|
127
148
|
return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SText, _ref7.cn("SText", _objectSpread({}, _assignProps3({
|
|
128
|
-
"
|
|
149
|
+
"size": 200,
|
|
150
|
+
"ellipsis": ellipsis,
|
|
151
|
+
"medium": true,
|
|
152
|
+
"hint:triggerRef": buttonRefsList[index]
|
|
129
153
|
}, _ref3))));
|
|
130
154
|
}
|
|
131
155
|
function Addon(props) {
|
package/lib/es6/TabPanel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabPanel.js","names":["createComponent","Component","sstyled","Root","addonTextChildren","a11yEnhance","Box","React","style","_sstyled","insert","optionsA11yEnhance","onNeighborChange","neighborElement","props","focus","behavior","click","childSelector","TabPanelRoot","_Component","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","value","event","handlers","key","preventDefault","_inherits","_createClass","uncontrolledProps","getItemProps","_index","asProps","isSelected","handleClick","handleKeyDown","render","_ref","_ref5","STabPanel","styles","createElement","cn","_objectSpread","_assignProps","defaultValue","TabPanelItem","_ref2","arguments[0]","_ref6","STabPanelItem","Children","addonLeft","addonRight","_assignProps2","TabPanel","Item","Addon","tag","Text","_ref3","_ref7","SText","_assignProps3","_ref4","_ref8","SAddon","_assignProps4","wrapTabPanel","wrapper"],"sources":["../../src/TabPanel.jsx"],"sourcesContent":["import { 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 { Box } from '@semcore/flex-box';\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 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 };\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 } = props;\n\n return sstyled(styles)(\n <STabPanelItem render={Box} type='button' tag='button' tabIndex={0} role='tab'>\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 } = props;\n return sstyled(styles)(<SText render={Box} tag='span' />);\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,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,GAAG,QAAQ,mBAAmB;AACvC,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,IAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI1B,IAAMC,kBAAkB,GAAG;EACzBC,gBAAgB,EAAE,SAAlBA,gBAAgBA,CAAGC,eAAe,EAAEC,KAAK,EAAK;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;AAAC,IAEIC,YAAY,0BAAAC,UAAA;EAAA,SAAAD,aAAA;IAAA,IAAAE,KAAA;IAAAC,eAAA,OAAAH,YAAA;IAAA,SAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAA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kB;EAAM,GAAAH,KAAA,GAAE,CAAC;AAC3D;AAEA,IAAMT,QAAQ,GAAGjE,eAAe,CAACmB,YAAY,EAAE;EAC7C+C,IAAI,EAAE,CAACV,YAAY,EAAE;IAAEa,IAAI,EAAJA,IAAI;IAAEF,KAAK,EAALA;EAAM,CAAC;AACtC,CAAC,CAAC;AAEF,OAAO,IAAMW,YAAY,GAAG,SAAfA,YAAYA,CAAIC,OAAO;EAAA,OAAKA,OAAO;AAAA;AAEhD,eAAed,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"TabPanel.js","names":["Box","createComponent","Component","sstyled","Root","addonTextChildren","a11yEnhance","Text","UikitText","React","style","_sstyled","insert","TabPanelRoot","_Component","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","value","event","handlers","key","preventDefault","_inherits","_createClass","uncontrolledProps","getItemProps","props","index","asProps","isSelected","handleClick","handleKeyDown","buttonRefsList","getItemTextProps","_","render","_ref","_ref5","STabPanel","styles","createElement","cn","_objectSpread","_assignProps","defaultValue","behavior","onNeighborChange","neighborElement","focus","click","childSelector","TabPanelItem","_ref2","arguments[0]","_ref6","STabPanelItem","Children","addonLeft","addonRight","buttonRef","useRef","_assignProps2","TabPanel","Item","Addon","tag","_ref3","_ref7","SText","_props$ellipsis","ellipsis","_assignProps3","_ref4","_ref8","SAddon","_assignProps4","wrapTabPanel","wrapper"],"sources":["../../src/TabPanel.tsx"],"sourcesContent":["import { 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 UikitText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/tab-panel.shadow.css';\nimport type { NSTabPanel } from './TabPanel.type';\n\nclass TabPanelRoot extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSTabPanel.Component>,\n typeof TabPanelRoot.enhance,\n NSTabPanel.Handlers\n> {\n static displayName = 'TabPanel';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n behavior: 'manual',\n };\n\n static enhance = [\n 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 }),\n ] as const;\n\n buttonRefsList: Array<React.MutableRefObject<HTMLButtonElement | undefined>> = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n handleClick = (value: NSTabPanel.Props['value']) => (event: React.MouseEvent<HTMLButtonElement>) => {\n this.handlers.value(value, event);\n };\n\n handleKeyDown = (value: NSTabPanel.Props['value']) => (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handlers.value(value, event);\n }\n };\n\n getItemProps(props: NSTabPanel.Item.Props, index: number) {\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(_: NSTabPanel.Item.Text.Props, index: number) {\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(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabPanel.Item.Component,\n typeof TabPanelRoot,\n 'Item'\n >,\n) {\n const STabPanelItem = Root;\n const { Children, styles, addonLeft, addonRight, buttonRefsList, index } = props;\n const buttonRef = React.useRef<HTMLButtonElement>();\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(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSTabPanel.Item.Text.Component,\n typeof TabPanelRoot,\n 'ItemText'\n >,\n) {\n const SText = Root;\n const { styles, ellipsis = true, buttonRefsList, index } = props;\n return sstyled(styles)(<SText render={UikitText} size={200} ellipsis={ellipsis} medium hint:triggerRef={buttonRefsList[index]} />);\n}\n\nfunction Addon(\n props: Intergalactic.InternalTypings.InferComponentProps<NSTabPanel.Item.Addon.Component>,\n) {\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}) as unknown as NSTabPanel.Component;\n\nexport const wrapTabPanel = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSTabPanel.WrapperComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSTabPanel.WrapperComponent<PropsExtending>;\n\nexport default TabPanel;\n"],"mappings":";;;;;;;;;;;AAAA,SAASA,GAAG,QAAQ,0BAA0B;AAE9C,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,IAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AA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;AAEA,IAAMV,QAAQ,GAAGtE,eAAe,CAACY,YAAY,EAAE;EAC7C2D,IAAI,EAAE,CAACZ,YAAY,EAAE;IAAErD,IAAI,EAAJA,IAAI;IAAEkE,KAAK,EAALA;EAAM,CAAC;AACtC,CAAC,CAAoC;AAErC,OAAO,IAAMY,YAAY,GAAG,SAAfA,YAAYA,CAA+BC,OAKpC;EAAA,OAAKA,OAAO;AAAA,CAA+C;AAE/E,eAAef,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabPanel.type.js","names":[],"sources":["../../src/TabPanel.type.ts"],"sourcesContent":["import type { Box, BoxProps } from '@semcore/base-components';\nimport type { Intergalactic, PropGetterFn } from '@semcore/core';\nimport type { NSText } from '@semcore/typography';\n\ndeclare namespace NSTabPanel {\n type Value = string | number | boolean;\n type Props<V extends NSTabPanel.Value = NSTabPanel.Value> = BoxProps & {\n /** Is invoked when changing the selection */\n onChange?:\n | ((value: V, e?: React.SyntheticEvent<HTMLButtonElement>) => void)\n | React.Dispatch<React.SetStateAction<V>>;\n /** Value of the selected tab */\n value?: V;\n /** Default value of the selected tab\n * @default null\n * */\n defaultValue?: V;\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 /** 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?: NSTabPanel.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: NSTabPanel.Handlers]> & {\n Text: Text.Component;\n Addon: Addon.Component;\n };\n }\n\n type WrapperComponent<PropsExtending = {}> = (<\n V extends NSTabPanel.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) & 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 TabPanelValue = NSTabPanel.Value;\n/** @deprecated It will be removed in v18. */\nexport type TabPanelProps<T extends TabPanelValue = TabPanelValue> = NSTabPanel.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type TabPanelItemProps = NSTabPanel.Item.Props;\n/** @deprecated It will be removed in v18. */\nexport type TabPanelContext = NSTabPanel.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type TabPanelHandlers = NSTabPanel.Handlers;\n\nexport type { NSTabPanel };\n"],"mappings":"","ignoreList":[]}
|
package/lib/es6/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default } from './TabPanel';
|
|
2
|
-
export * from './TabPanel';
|
|
1
|
+
export { default, wrapTabPanel } from './TabPanel';
|
|
2
|
+
export * from './TabPanel.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","wrapTabPanel"],"sources":["../../src/index.ts"],"sourcesContent":["export { default, wrapTabPanel } from './TabPanel';\nexport * from './TabPanel.type';\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,YAAY,QAAQ,YAAY;AAClD,cAAc,iBAAiB","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
|
@@ -4,40 +4,30 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
4
4
|
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
-
import {
|
|
7
|
+
import { sstyled, assignProps, Component, createComponent } from "@semcore/core";
|
|
8
|
+
import { Box } from "@semcore/base-components";
|
|
8
9
|
import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
9
10
|
import a11yEnhance from "@semcore/core/lib/utils/enhances/a11yEnhance";
|
|
10
|
-
import {
|
|
11
|
+
import { Text as Text$1 } from "@semcore/typography";
|
|
11
12
|
import React from "react";
|
|
12
13
|
/*!__reshadow-styles__:"./style/tab-panel.shadow.css"*/
|
|
13
14
|
var style = (
|
|
14
15
|
/*__reshadow_css_start__*/
|
|
15
16
|
(sstyled.insert(
|
|
16
17
|
/*__inner_css_start__*/
|
|
17
|
-
'.
|
|
18
|
+
'.___STabPanel_13pnv_gg_{display:flex;width:100%;max-width:100%}.___STabPanel_13pnv_gg_::after{content:"";position:relative;bottom:-1px;flex:1;border-top:1px solid transparent;border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@supports (color:color(display-p3 0 0 0%)){.___STabPanel_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanel_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_13pnv_gg_{position:relative;bottom:-1px;display:inline-flex;min-width:0;height:32px;color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));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}@supports (color:color(display-p3 0 0 0%)){.___STabPanelItem_13pnv_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___STabPanelItem_13pnv_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___STabPanelItem_13pnv_gg_::-moz-focus-inner{border:0;padding:0}.___STabPanelItem_13pnv_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabPanelItem_13pnv_gg_:hover{-webkit-text-decoration:none;text-decoration:none;color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}}.___STabPanelItem_13pnv_gg_::after{content:"";position:absolute;left:-1px;bottom:0;width:calc(100% + 2px);border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@supports (color:color(display-p3 0 0 0%)){.___STabPanelItem_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_13pnv_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_13pnv_gg_.__disabled_13pnv_gg_{cursor:default;pointer-events:none}.___STabPanelItem_13pnv_gg_.__disabled_13pnv_gg_ .___SAddon_13pnv_gg_,.___STabPanelItem_13pnv_gg_.__disabled_13pnv_gg_ .___SText_13pnv_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_{color:var(--intergalactic-text-link, rgb(35, 95, 226));border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161));flex-shrink:0}@supports (color:color(display-p3 0 0 0%)){.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_{border-color:var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}@media (hover:hover){.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_:hover{color:var(--intergalactic-text-link-hover-active, rgb(33, 89, 215))}}.___STabPanelItem_13pnv_gg_.__selected_13pnv_gg_::after{border-bottom:none}.___SText_13pnv_gg_{margin:auto var(--intergalactic-spacing-2x, 8px)}.___SAddon_13pnv_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_13pnv_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SAddon_13pnv_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SAddon_13pnv_gg_:only-child{margin-right:var(--intergalactic-spacing-2x, 8px);margin-left:var(--intergalactic-spacing-2x, 8px)}',
|
|
18
19
|
/*__inner_css_end__*/
|
|
19
|
-
"
|
|
20
|
+
"13pnv_gg_"
|
|
20
21
|
), /*__reshadow_css_end__*/
|
|
21
22
|
{
|
|
22
|
-
"__SText": "
|
|
23
|
-
"__SAddon": "
|
|
24
|
-
"__STabPanel": "
|
|
25
|
-
"__STabPanelItem": "
|
|
26
|
-
"_disabled": "
|
|
27
|
-
"_selected": "
|
|
23
|
+
"__SText": "___SText_13pnv_gg_",
|
|
24
|
+
"__SAddon": "___SAddon_13pnv_gg_",
|
|
25
|
+
"__STabPanel": "___STabPanel_13pnv_gg_",
|
|
26
|
+
"__STabPanelItem": "___STabPanelItem_13pnv_gg_",
|
|
27
|
+
"_disabled": "__disabled_13pnv_gg_",
|
|
28
|
+
"_selected": "__selected_13pnv_gg_"
|
|
28
29
|
})
|
|
29
30
|
);
|
|
30
|
-
var optionsA11yEnhance = {
|
|
31
|
-
onNeighborChange: function 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
|
var TabPanelRoot = /* @__PURE__ */ (function(_Component) {
|
|
42
32
|
function TabPanelRoot2() {
|
|
43
33
|
var _this;
|
|
@@ -46,6 +36,7 @@ var TabPanelRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
46
36
|
args[_key] = arguments[_key];
|
|
47
37
|
}
|
|
48
38
|
_this = _callSuper(this, TabPanelRoot2, [].concat(args));
|
|
39
|
+
_defineProperty(_this, "buttonRefsList", []);
|
|
49
40
|
_defineProperty(_this, "handleClick", function(value) {
|
|
50
41
|
return function(event) {
|
|
51
42
|
_this.handlers.value(value, event);
|
|
@@ -71,7 +62,7 @@ var TabPanelRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
71
62
|
}
|
|
72
63
|
}, {
|
|
73
64
|
key: "getItemProps",
|
|
74
|
-
value: function getItemProps(props,
|
|
65
|
+
value: function getItemProps(props, index) {
|
|
75
66
|
var value = this.asProps.value;
|
|
76
67
|
var isSelected = value === props.value;
|
|
77
68
|
return {
|
|
@@ -79,7 +70,17 @@ var TabPanelRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
79
70
|
"onClick": this.handleClick(props.value),
|
|
80
71
|
"onKeyDown": this.handleKeyDown(props.value),
|
|
81
72
|
"tabIndex": isSelected ? 0 : -1,
|
|
82
|
-
"aria-selected": isSelected
|
|
73
|
+
"aria-selected": isSelected,
|
|
74
|
+
"buttonRefsList": this.buttonRefsList,
|
|
75
|
+
index
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
key: "getItemTextProps",
|
|
80
|
+
value: function getItemTextProps(_, index) {
|
|
81
|
+
return {
|
|
82
|
+
buttonRefsList: this.buttonRefsList,
|
|
83
|
+
index
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
}, {
|
|
@@ -100,16 +101,30 @@ _defineProperty(TabPanelRoot, "defaultProps", {
|
|
|
100
101
|
defaultValue: null,
|
|
101
102
|
behavior: "manual"
|
|
102
103
|
});
|
|
103
|
-
_defineProperty(TabPanelRoot, "enhance", [a11yEnhance(
|
|
104
|
+
_defineProperty(TabPanelRoot, "enhance", [a11yEnhance({
|
|
105
|
+
onNeighborChange: function onNeighborChange(neighborElement, props) {
|
|
106
|
+
if (neighborElement) {
|
|
107
|
+
neighborElement.focus();
|
|
108
|
+
if (props.behavior === "auto") {
|
|
109
|
+
neighborElement.click();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
childSelector: ["role", "tab"]
|
|
114
|
+
})]);
|
|
115
|
+
;
|
|
104
116
|
function TabPanelItem(props) {
|
|
105
117
|
var _ref2 = arguments[0], _ref6;
|
|
106
118
|
var STabPanelItem = Box;
|
|
107
|
-
var Children = props.Children, styles = props.styles, addonLeft = props.addonLeft, addonRight = props.addonRight;
|
|
119
|
+
var Children = props.Children, styles = props.styles, addonLeft = props.addonLeft, addonRight = props.addonRight, buttonRefsList = props.buttonRefsList, index = props.index;
|
|
120
|
+
var buttonRef = React.useRef();
|
|
121
|
+
buttonRefsList[index] = buttonRef;
|
|
108
122
|
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(STabPanelItem, _ref6.cn("STabPanelItem", _objectSpread({}, assignProps({
|
|
109
123
|
"type": "button",
|
|
110
124
|
"tag": "button",
|
|
111
125
|
"tabIndex": 0,
|
|
112
|
-
"role": "tab"
|
|
126
|
+
"role": "tab",
|
|
127
|
+
"ref": buttonRef
|
|
113
128
|
}, _ref2))), addonLeft ? /* @__PURE__ */ React.createElement(TabPanel.Item.Addon, {
|
|
114
129
|
tag: addonLeft
|
|
115
130
|
}) : null, addonTextChildren(Children, TabPanel.Item.Text, TabPanel.Item.Addon), addonRight ? /* @__PURE__ */ React.createElement(TabPanel.Item.Addon, {
|
|
@@ -118,10 +133,13 @@ function TabPanelItem(props) {
|
|
|
118
133
|
}
|
|
119
134
|
function Text(props) {
|
|
120
135
|
var _ref3 = arguments[0], _ref7;
|
|
121
|
-
var SText =
|
|
122
|
-
var styles = props.styles;
|
|
136
|
+
var SText = Text$1;
|
|
137
|
+
var styles = props.styles, _props$ellipsis = props.ellipsis, ellipsis = _props$ellipsis === void 0 ? true : _props$ellipsis, buttonRefsList = props.buttonRefsList, index = props.index;
|
|
123
138
|
return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SText, _ref7.cn("SText", _objectSpread({}, assignProps({
|
|
124
|
-
"
|
|
139
|
+
"size": 200,
|
|
140
|
+
"ellipsis": ellipsis,
|
|
141
|
+
"medium": true,
|
|
142
|
+
"hint:triggerRef": buttonRefsList[index]
|
|
125
143
|
}, _ref3))));
|
|
126
144
|
}
|
|
127
145
|
function Addon(props) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/lib/esm/index.mjs
CHANGED
|
@@ -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 {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Intergalactic } from '@semcore/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { NSTabPanel } from './TabPanel.type';
|
|
4
|
+
declare const TabPanel: NSTabPanel.Component;
|
|
5
|
+
export declare const wrapTabPanel: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.UntypeRefAndTag<Intergalactic.InternalTypings.ComponentPropsNesting<NSTabPanel.WrapperComponent>> & PropsExtending) => React.ReactNode) => NSTabPanel.WrapperComponent<PropsExtending>;
|
|
6
|
+
export default TabPanel;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Box, BoxProps } from '@semcore/base-components';
|
|
2
|
+
import type { Intergalactic, PropGetterFn } from '@semcore/core';
|
|
3
|
+
import type { NSText } from '@semcore/typography';
|
|
4
|
+
declare namespace NSTabPanel {
|
|
5
|
+
type Value = string | number | boolean;
|
|
6
|
+
type Props<V extends NSTabPanel.Value = NSTabPanel.Value> = BoxProps & {
|
|
7
|
+
/** Is invoked when changing the selection */
|
|
8
|
+
onChange?: ((value: V, e?: React.SyntheticEvent<HTMLButtonElement>) => void) | React.Dispatch<React.SetStateAction<V>>;
|
|
9
|
+
/** Value of the selected tab */
|
|
10
|
+
value?: V;
|
|
11
|
+
/** Default value of the selected tab
|
|
12
|
+
* @default null
|
|
13
|
+
* */
|
|
14
|
+
defaultValue?: V;
|
|
15
|
+
/**
|
|
16
|
+
* Behavior of tabs.
|
|
17
|
+
* In `auto`, changes the tab immediately when press arrow.
|
|
18
|
+
* In `manual`, needs to press `space` or `enter` for select a choice.
|
|
19
|
+
* @default 'auto'
|
|
20
|
+
*/
|
|
21
|
+
behavior?: 'auto' | 'manual';
|
|
22
|
+
};
|
|
23
|
+
type Ctx = {
|
|
24
|
+
getItemProps: PropGetterFn;
|
|
25
|
+
};
|
|
26
|
+
type Handlers = {
|
|
27
|
+
value: null;
|
|
28
|
+
};
|
|
29
|
+
namespace Item {
|
|
30
|
+
type Props = BoxProps & {
|
|
31
|
+
/** Makes a tab selected. This property is determined automatically depending on the value. */
|
|
32
|
+
selected?: boolean;
|
|
33
|
+
/** Disabled state */
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/** Tab value */
|
|
36
|
+
value?: NSTabPanel.Value;
|
|
37
|
+
/** Left addon tag */
|
|
38
|
+
addonLeft?: React.ElementType;
|
|
39
|
+
/** Right addon tag */
|
|
40
|
+
addonRight?: React.ElementType;
|
|
41
|
+
};
|
|
42
|
+
namespace Text {
|
|
43
|
+
type Props = NSText.Props;
|
|
44
|
+
type Component = NSText.Component;
|
|
45
|
+
}
|
|
46
|
+
namespace Addon {
|
|
47
|
+
type Component = typeof Box;
|
|
48
|
+
}
|
|
49
|
+
type Component = Intergalactic.Component<'div', Props, {}, [handlers: NSTabPanel.Handlers]> & {
|
|
50
|
+
Text: Text.Component;
|
|
51
|
+
Addon: Addon.Component;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
type WrapperComponent<PropsExtending = {}> = (<V extends NSTabPanel.Value, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', Props<V>, Ctx, [
|
|
55
|
+
handlers: Handlers
|
|
56
|
+
]> & PropsExtending) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;
|
|
57
|
+
type Component = WrapperComponent & {
|
|
58
|
+
Item: Item.Component;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** @deprecated It will be removed in v18. */
|
|
62
|
+
export type TabPanelValue = NSTabPanel.Value;
|
|
63
|
+
/** @deprecated It will be removed in v18. */
|
|
64
|
+
export type TabPanelProps<T extends TabPanelValue = TabPanelValue> = NSTabPanel.Props<T>;
|
|
65
|
+
/** @deprecated It will be removed in v18. */
|
|
66
|
+
export type TabPanelItemProps = NSTabPanel.Item.Props;
|
|
67
|
+
/** @deprecated It will be removed in v18. */
|
|
68
|
+
export type TabPanelContext = NSTabPanel.Ctx;
|
|
69
|
+
/** @deprecated It will be removed in v18. */
|
|
70
|
+
export type TabPanelHandlers = NSTabPanel.Handlers;
|
|
71
|
+
export type { NSTabPanel };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,90 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type React from 'react';
|
|
4
|
-
|
|
5
|
-
export type TabPanelValue = string | number | boolean;
|
|
6
|
-
|
|
7
|
-
/** @deprecated */
|
|
8
|
-
export interface ITabPanelProps<T extends TabPanelValue = TabPanelValue>
|
|
9
|
-
extends TabPanelProps<T>,
|
|
10
|
-
UnknownProperties {}
|
|
11
|
-
export type TabPanelProps<T extends TabPanelValue = TabPanelValue> = BoxProps & {
|
|
12
|
-
/** Is invoked when changing the selection */
|
|
13
|
-
onChange?:
|
|
14
|
-
| ((value: T, e?: React.SyntheticEvent<HTMLButtonElement>) => void)
|
|
15
|
-
| React.Dispatch<React.SetStateAction<T>>;
|
|
16
|
-
/** Value of the selected tab */
|
|
17
|
-
value?: T;
|
|
18
|
-
/** Default value of the selected tab
|
|
19
|
-
* @default null
|
|
20
|
-
* */
|
|
21
|
-
defaultValue?: T;
|
|
22
|
-
/**
|
|
23
|
-
* Behavior of tabs.
|
|
24
|
-
* In `auto`, changes the tab immediately when press arrow.
|
|
25
|
-
* In `manual`, needs to press `space` or `enter` for select a choice.
|
|
26
|
-
* @default 'auto'
|
|
27
|
-
*/
|
|
28
|
-
behavior?: 'auto' | 'manual';
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/** @deprecated */
|
|
32
|
-
export interface ITabPanelItemProps extends TabPanelItemProps, UnknownProperties {}
|
|
33
|
-
export type TabPanelItemProps = BoxProps & {
|
|
34
|
-
/** Makes a tab selected. This property is determined automatically depending on the value. */
|
|
35
|
-
selected?: boolean;
|
|
36
|
-
/** Disabled state */
|
|
37
|
-
disabled?: boolean;
|
|
38
|
-
/** Tab value */
|
|
39
|
-
value?: TabPanelValue;
|
|
40
|
-
/** Left addon tag */
|
|
41
|
-
addonLeft?: React.ElementType;
|
|
42
|
-
/** Right addon tag */
|
|
43
|
-
addonRight?: React.ElementType;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/** @deprecated */
|
|
47
|
-
export interface ITabPanelContext extends TabPanelContext, UnknownProperties {}
|
|
48
|
-
export type TabPanelContext = {
|
|
49
|
-
getItemProps: PropGetterFn;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/** @deprecated */
|
|
53
|
-
export interface ITabPanelHandlers extends TabPanelHandlers, UnknownProperties {}
|
|
54
|
-
export type TabPanelHandlers = {
|
|
55
|
-
value: (value: TabPanelValue) => void;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type IntergalacticTabPanelComponent<PropsExtending = {}> = (<
|
|
59
|
-
Value extends TabPanelValue,
|
|
60
|
-
Tag extends Intergalactic.Tag = 'div',
|
|
61
|
-
>(
|
|
62
|
-
props: Intergalactic.InternalTypings.ComponentProps<
|
|
63
|
-
Tag,
|
|
64
|
-
'div',
|
|
65
|
-
TabPanelProps<Value>,
|
|
66
|
-
TabPanelContext,
|
|
67
|
-
[handlers: TabPanelHandlers]
|
|
68
|
-
> &
|
|
69
|
-
PropsExtending,
|
|
70
|
-
) => Intergalactic.InternalTypings.ComponentRenderingResults) &
|
|
71
|
-
Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', TabPanelProps>;
|
|
72
|
-
|
|
73
|
-
declare const TabPanel: IntergalacticTabPanelComponent & {
|
|
74
|
-
Item: Intergalactic.Component<'div', TabPanelItemProps, {}, [handlers: TabPanelHandlers]> & {
|
|
75
|
-
Text: typeof Box;
|
|
76
|
-
Addon: typeof Box;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
declare const wrapTabPanel: <PropsExtending extends {}>(
|
|
81
|
-
wrapper: (
|
|
82
|
-
props: Intergalactic.InternalTypings.UntypeRefAndTag<
|
|
83
|
-
Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticTabPanelComponent>
|
|
84
|
-
> &
|
|
85
|
-
PropsExtending,
|
|
86
|
-
) => React.ReactNode,
|
|
87
|
-
) => IntergalacticTabPanelComponent<PropsExtending>;
|
|
88
|
-
export { wrapTabPanel };
|
|
89
|
-
|
|
90
|
-
export default TabPanel;
|
|
1
|
+
export { default, wrapTabPanel } from './TabPanel';
|
|
2
|
+
export * from './TabPanel.type';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/tab-panel",
|
|
3
3
|
"description": "Semrush TabPanel Component",
|
|
4
|
-
"version": "16.1.0
|
|
4
|
+
"version": "16.1.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
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/flex-box": "16.1.0
|
|
17
|
+
"@semcore/flex-box": "16.1.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@semcore/base-components": "^16.6.0
|
|
20
|
+
"@semcore/base-components": "^16.6.0"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"directory": "semcore/tab-panel"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
+
"@semcore/core": "16.6.0",
|
|
28
29
|
"@semcore/testing-utils": "1.0.0",
|
|
29
|
-
"@semcore/
|
|
30
|
-
"@semcore/icon": "16.8.0-prerelease.3"
|
|
30
|
+
"@semcore/icon": "16.8.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "pnpm semcore-builder --source=js && pnpm vite build"
|
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 { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport type { Box, BoxProps } from '@semcore/flex-box';\nimport type React from 'react';\n\nexport type TabPanelValue = string | number | boolean;\n\n/** @deprecated */\nexport interface ITabPanelProps<T extends TabPanelValue = TabPanelValue>\n extends TabPanelProps<T>,\n UnknownProperties {}\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\n/** @deprecated */\nexport interface ITabPanelItemProps extends TabPanelItemProps, UnknownProperties {}\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\n/** @deprecated */\nexport interface ITabPanelContext extends TabPanelContext, UnknownProperties {}\nexport type TabPanelContext = {\n getItemProps: PropGetterFn;\n};\n\n/** @deprecated */\nexport interface ITabPanelHandlers extends TabPanelHandlers, UnknownProperties {}\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/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 { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport type { Box, BoxProps } from '@semcore/flex-box';\nimport type React from 'react';\n\nexport type TabPanelValue = string | number | boolean;\n\n/** @deprecated */\nexport interface ITabPanelProps<T extends TabPanelValue = TabPanelValue>\n extends TabPanelProps<T>,\n UnknownProperties {}\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\n/** @deprecated */\nexport interface ITabPanelItemProps extends TabPanelItemProps, UnknownProperties {}\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\n/** @deprecated */\nexport interface ITabPanelContext extends TabPanelContext, UnknownProperties {}\nexport type TabPanelContext = {\n getItemProps: PropGetterFn;\n};\n\n/** @deprecated */\nexport interface ITabPanelHandlers extends TabPanelHandlers, UnknownProperties {}\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":[]}
|