@semcore/tab-panel 16.1.0 → 16.1.1
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 +1 -1
- package/lib/cjs/TabPanel.js +30 -54
- package/lib/cjs/TabPanel.js.map +1 -1
- package/lib/cjs/index.d.js +2 -0
- package/lib/cjs/index.d.js.map +1 -0
- package/lib/cjs/index.js +4 -13
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/tab-panel.shadow.css +10 -0
- package/lib/es6/TabPanel.js +27 -51
- package/lib/es6/TabPanel.js.map +1 -1
- package/lib/es6/index.d.js +2 -0
- package/lib/es6/index.d.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 +10 -0
- package/lib/esm/TabPanel.mjs +29 -47
- package/lib/esm/index.mjs +0 -1
- package/lib/esm/style/tab-panel.shadow.css +10 -0
- package/lib/types/index.d.ts +90 -2
- package/package.json +4 -4
- package/lib/cjs/TabPanel.type.js +0 -2
- package/lib/cjs/TabPanel.type.js.map +0 -1
- package/lib/es6/TabPanel.type.js +0 -2
- package/lib/es6/TabPanel.type.js.map +0 -1
- package/lib/esm/TabPanel.type.mjs +0 -1
- package/lib/types/TabPanel.d.ts +0 -6
- package/lib/types/TabPanel.type.d.ts +0 -71
package/CHANGELOG.md
CHANGED
package/lib/cjs/TabPanel.js
CHANGED
|
@@ -12,22 +12,32 @@ 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");
|
|
16
15
|
var _addonTextChildren = _interopRequireDefault(require("@semcore/core/lib/utils/addonTextChildren"));
|
|
17
16
|
var _a11yEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/a11yEnhance"));
|
|
18
|
-
var
|
|
17
|
+
var _flexBox = require("@semcore/flex-box");
|
|
19
18
|
var _react = _interopRequireDefault(require("react"));
|
|
20
19
|
/*!__reshadow-styles__:"./style/tab-panel.shadow.css"*/
|
|
21
|
-
var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
20
|
+
var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___STabPanel_1qj1t_gg_{display:flex;width:100%;max-width:100%}.___STabPanel_1qj1t_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_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanel_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_1qj1t_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_1qj1t_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___STabPanelItem_1qj1t_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___STabPanelItem_1qj1t_gg_ .___SText_1qj1t_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%);font-weight:var(--intergalactic-medium, 500)}.___STabPanelItem_1qj1t_gg_::-moz-focus-inner{border:0;padding:0}.___STabPanelItem_1qj1t_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabPanelItem_1qj1t_gg_:hover{-webkit-text-decoration:none;text-decoration:none;color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}}.___STabPanelItem_1qj1t_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_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_1qj1t_gg_.__disabled_1qj1t_gg_{cursor:default;pointer-events:none}.___STabPanelItem_1qj1t_gg_.__disabled_1qj1t_gg_ .___SAddon_1qj1t_gg_,.___STabPanelItem_1qj1t_gg_.__disabled_1qj1t_gg_ .___SText_1qj1t_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_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_1qj1t_gg_.__selected_1qj1t_gg_{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_gg_{border-color:var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}@media (hover:hover){.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_gg_:hover{color:var(--intergalactic-text-link-hover-active, rgb(33, 89, 215))}}.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_gg_::after{border-bottom:none}.___SText_1qj1t_gg_{display:inline-block;margin:auto var(--intergalactic-spacing-2x, 8px);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___SAddon_1qj1t_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_1qj1t_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1qj1t_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1qj1t_gg_:only-child{margin-right:var(--intergalactic-spacing-2x, 8px);margin-left:var(--intergalactic-spacing-2x, 8px)}", /*__inner_css_end__*/"1qj1t_gg_"),
|
|
22
21
|
/*__reshadow_css_end__*/
|
|
23
22
|
{
|
|
24
|
-
"__SText": "
|
|
25
|
-
"__SAddon": "
|
|
26
|
-
"__STabPanel": "
|
|
27
|
-
"__STabPanelItem": "
|
|
28
|
-
"_disabled": "
|
|
29
|
-
"_selected": "
|
|
23
|
+
"__SText": "___SText_1qj1t_gg_",
|
|
24
|
+
"__SAddon": "___SAddon_1qj1t_gg_",
|
|
25
|
+
"__STabPanel": "___STabPanel_1qj1t_gg_",
|
|
26
|
+
"__STabPanelItem": "___STabPanelItem_1qj1t_gg_",
|
|
27
|
+
"_disabled": "__disabled_1qj1t_gg_",
|
|
28
|
+
"_selected": "__selected_1qj1t_gg_"
|
|
30
29
|
});
|
|
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
|
+
};
|
|
31
41
|
var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
32
42
|
function TabPanelRoot() {
|
|
33
43
|
var _this;
|
|
@@ -36,7 +46,6 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
36
46
|
args[_key] = arguments[_key];
|
|
37
47
|
}
|
|
38
48
|
_this = (0, _callSuper2["default"])(this, TabPanelRoot, [].concat(args));
|
|
39
|
-
(0, _defineProperty2["default"])(_this, "buttonRefsList", []);
|
|
40
49
|
(0, _defineProperty2["default"])(_this, "handleClick", function (value) {
|
|
41
50
|
return function (event) {
|
|
42
51
|
_this.handlers.value(value, event);
|
|
@@ -62,7 +71,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
62
71
|
}
|
|
63
72
|
}, {
|
|
64
73
|
key: "getItemProps",
|
|
65
|
-
value: function getItemProps(props,
|
|
74
|
+
value: function getItemProps(props, _index) {
|
|
66
75
|
var value = this.asProps.value;
|
|
67
76
|
var isSelected = value === props.value;
|
|
68
77
|
return {
|
|
@@ -70,17 +79,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
70
79
|
'onClick': this.handleClick(props.value),
|
|
71
80
|
'onKeyDown': this.handleKeyDown(props.value),
|
|
72
81
|
'tabIndex': isSelected ? 0 : -1,
|
|
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
|
|
82
|
+
'aria-selected': isSelected
|
|
84
83
|
};
|
|
85
84
|
}
|
|
86
85
|
}, {
|
|
@@ -88,7 +87,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
88
87
|
value: function render() {
|
|
89
88
|
var _ref = this.asProps,
|
|
90
89
|
_ref5;
|
|
91
|
-
var STabPanel =
|
|
90
|
+
var STabPanel = _flexBox.Box;
|
|
92
91
|
var styles = this.asProps.styles;
|
|
93
92
|
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(STabPanel, _ref5.cn("STabPanel", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
94
93
|
"role": 'tablist'
|
|
@@ -102,36 +101,20 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
102
101
|
defaultValue: null,
|
|
103
102
|
behavior: 'manual'
|
|
104
103
|
});
|
|
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
|
-
;
|
|
104
|
+
(0, _defineProperty2["default"])(TabPanelRoot, "enhance", [(0, _a11yEnhance["default"])(optionsA11yEnhance)]);
|
|
117
105
|
function TabPanelItem(props) {
|
|
118
106
|
var _ref2 = arguments[0],
|
|
119
107
|
_ref6;
|
|
120
|
-
var STabPanelItem =
|
|
108
|
+
var STabPanelItem = _flexBox.Box;
|
|
121
109
|
var Children = props.Children,
|
|
122
110
|
styles = props.styles,
|
|
123
111
|
addonLeft = props.addonLeft,
|
|
124
|
-
addonRight = props.addonRight
|
|
125
|
-
buttonRefsList = props.buttonRefsList,
|
|
126
|
-
index = props.index;
|
|
127
|
-
var buttonRef = _react["default"].useRef();
|
|
128
|
-
buttonRefsList[index] = buttonRef;
|
|
112
|
+
addonRight = props.addonRight;
|
|
129
113
|
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(STabPanelItem, _ref6.cn("STabPanelItem", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
130
114
|
"type": 'button',
|
|
131
115
|
"tag": 'button',
|
|
132
116
|
"tabIndex": 0,
|
|
133
|
-
"role": 'tab'
|
|
134
|
-
"ref": buttonRef
|
|
117
|
+
"role": 'tab'
|
|
135
118
|
}, _ref2))), addonLeft ? /*#__PURE__*/_react["default"].createElement(TabPanel.Item.Addon, {
|
|
136
119
|
tag: addonLeft
|
|
137
120
|
}) : null, (0, _addonTextChildren["default"])(Children, TabPanel.Item.Text, TabPanel.Item.Addon), addonRight ? /*#__PURE__*/_react["default"].createElement(TabPanel.Item.Addon, {
|
|
@@ -141,23 +124,16 @@ function TabPanelItem(props) {
|
|
|
141
124
|
function Text(props) {
|
|
142
125
|
var _ref3 = arguments[0],
|
|
143
126
|
_ref7;
|
|
144
|
-
var SText =
|
|
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;
|
|
127
|
+
var SText = _flexBox.Box;
|
|
128
|
+
var styles = props.styles;
|
|
150
129
|
return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SText, _ref7.cn("SText", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
151
|
-
"
|
|
152
|
-
"ellipsis": ellipsis,
|
|
153
|
-
"medium": true,
|
|
154
|
-
"hint:triggerRef": buttonRefsList[index]
|
|
130
|
+
"tag": 'span'
|
|
155
131
|
}, _ref3))));
|
|
156
132
|
}
|
|
157
133
|
function Addon(props) {
|
|
158
134
|
var _ref4 = arguments[0],
|
|
159
135
|
_ref8;
|
|
160
|
-
var SAddon =
|
|
136
|
+
var SAddon = _flexBox.Box;
|
|
161
137
|
var styles = props.styles;
|
|
162
138
|
return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref8.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
163
139
|
"tag": 'span'
|
package/lib/cjs/TabPanel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,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AiC,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":[]}
|
|
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,kBAA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O;AAAA;AAAC,IAAAC,QAAA,GAAAF,OAAA,cAElCd,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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/cjs/index.js
CHANGED
|
@@ -4,31 +4,22 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
wrapTabPanel: true
|
|
9
|
-
};
|
|
7
|
+
var _exportNames = {};
|
|
10
8
|
Object.defineProperty(exports, "default", {
|
|
11
9
|
enumerable: true,
|
|
12
10
|
get: function get() {
|
|
13
11
|
return _TabPanel["default"];
|
|
14
12
|
}
|
|
15
13
|
});
|
|
16
|
-
Object.defineProperty(exports, "wrapTabPanel", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function get() {
|
|
19
|
-
return _TabPanel.wrapTabPanel;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
14
|
var _TabPanel = _interopRequireWildcard(require("./TabPanel"));
|
|
23
|
-
|
|
24
|
-
Object.keys(_TabPanel2).forEach(function (key) {
|
|
15
|
+
Object.keys(_TabPanel).forEach(function (key) {
|
|
25
16
|
if (key === "default" || key === "__esModule") return;
|
|
26
17
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
27
|
-
if (key in exports && exports[key] ===
|
|
18
|
+
if (key in exports && exports[key] === _TabPanel[key]) return;
|
|
28
19
|
Object.defineProperty(exports, key, {
|
|
29
20
|
enumerable: true,
|
|
30
21
|
get: function get() {
|
|
31
|
-
return
|
|
22
|
+
return _TabPanel[key];
|
|
32
23
|
}
|
|
33
24
|
});
|
|
34
25
|
});
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_TabPanel","_interopRequireWildcard","require","
|
|
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,IAAA;MAAA,OAAAd,SAAA,CAAAM,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -40,6 +40,12 @@ 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
|
+
|
|
43
49
|
&::-moz-focus-inner {
|
|
44
50
|
border: none;
|
|
45
51
|
padding: 0;
|
|
@@ -90,7 +96,11 @@ STabPanelItem[selected] {
|
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
SText {
|
|
99
|
+
display: inline-block;
|
|
93
100
|
margin: auto var(--intergalactic-spacing-2x, 8px);
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
text-overflow: ellipsis;
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
SAddon {
|
package/lib/es6/TabPanel.js
CHANGED
|
@@ -9,23 +9,33 @@ 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';
|
|
13
12
|
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
14
13
|
import addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';
|
|
15
14
|
import a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';
|
|
16
|
-
import {
|
|
15
|
+
import { Box } from '@semcore/flex-box';
|
|
17
16
|
import React from 'react';
|
|
18
17
|
/*!__reshadow-styles__:"./style/tab-panel.shadow.css"*/
|
|
19
|
-
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
18
|
+
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___STabPanel_1qj1t_gg_{display:flex;width:100%;max-width:100%}.___STabPanel_1qj1t_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_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanel_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_1qj1t_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_1qj1t_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___STabPanelItem_1qj1t_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___STabPanelItem_1qj1t_gg_ .___SText_1qj1t_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%);font-weight:var(--intergalactic-medium, 500)}.___STabPanelItem_1qj1t_gg_::-moz-focus-inner{border:0;padding:0}.___STabPanelItem_1qj1t_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabPanelItem_1qj1t_gg_:hover{-webkit-text-decoration:none;text-decoration:none;color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}}.___STabPanelItem_1qj1t_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_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_1qj1t_gg_.__disabled_1qj1t_gg_{cursor:default;pointer-events:none}.___STabPanelItem_1qj1t_gg_.__disabled_1qj1t_gg_ .___SAddon_1qj1t_gg_,.___STabPanelItem_1qj1t_gg_.__disabled_1qj1t_gg_ .___SText_1qj1t_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_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_1qj1t_gg_.__selected_1qj1t_gg_{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_gg_{border-color:var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}@media (hover:hover){.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_gg_:hover{color:var(--intergalactic-text-link-hover-active, rgb(33, 89, 215))}}.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_gg_::after{border-bottom:none}.___SText_1qj1t_gg_{display:inline-block;margin:auto var(--intergalactic-spacing-2x, 8px);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___SAddon_1qj1t_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_1qj1t_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1qj1t_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1qj1t_gg_:only-child{margin-right:var(--intergalactic-spacing-2x, 8px);margin-left:var(--intergalactic-spacing-2x, 8px)}", /*__inner_css_end__*/"1qj1t_gg_"),
|
|
20
19
|
/*__reshadow_css_end__*/
|
|
21
20
|
{
|
|
22
|
-
"__SText": "
|
|
23
|
-
"__SAddon": "
|
|
24
|
-
"__STabPanel": "
|
|
25
|
-
"__STabPanelItem": "
|
|
26
|
-
"_disabled": "
|
|
27
|
-
"_selected": "
|
|
21
|
+
"__SText": "___SText_1qj1t_gg_",
|
|
22
|
+
"__SAddon": "___SAddon_1qj1t_gg_",
|
|
23
|
+
"__STabPanel": "___STabPanel_1qj1t_gg_",
|
|
24
|
+
"__STabPanelItem": "___STabPanelItem_1qj1t_gg_",
|
|
25
|
+
"_disabled": "__disabled_1qj1t_gg_",
|
|
26
|
+
"_selected": "__selected_1qj1t_gg_"
|
|
28
27
|
});
|
|
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
|
+
};
|
|
29
39
|
var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
30
40
|
function TabPanelRoot() {
|
|
31
41
|
var _this;
|
|
@@ -34,7 +44,6 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
34
44
|
args[_key] = arguments[_key];
|
|
35
45
|
}
|
|
36
46
|
_this = _callSuper(this, TabPanelRoot, [].concat(args));
|
|
37
|
-
_defineProperty(_this, "buttonRefsList", []);
|
|
38
47
|
_defineProperty(_this, "handleClick", function (value) {
|
|
39
48
|
return function (event) {
|
|
40
49
|
_this.handlers.value(value, event);
|
|
@@ -60,7 +69,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
60
69
|
}
|
|
61
70
|
}, {
|
|
62
71
|
key: "getItemProps",
|
|
63
|
-
value: function getItemProps(props,
|
|
72
|
+
value: function getItemProps(props, _index) {
|
|
64
73
|
var value = this.asProps.value;
|
|
65
74
|
var isSelected = value === props.value;
|
|
66
75
|
return {
|
|
@@ -68,17 +77,7 @@ var TabPanelRoot = /*#__PURE__*/function (_Component) {
|
|
|
68
77
|
'onClick': this.handleClick(props.value),
|
|
69
78
|
'onKeyDown': this.handleKeyDown(props.value),
|
|
70
79
|
'tabIndex': isSelected ? 0 : -1,
|
|
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
|
|
80
|
+
'aria-selected': isSelected
|
|
82
81
|
};
|
|
83
82
|
}
|
|
84
83
|
}, {
|
|
@@ -100,18 +99,7 @@ _defineProperty(TabPanelRoot, "defaultProps", {
|
|
|
100
99
|
defaultValue: null,
|
|
101
100
|
behavior: 'manual'
|
|
102
101
|
});
|
|
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
|
-
;
|
|
102
|
+
_defineProperty(TabPanelRoot, "enhance", [a11yEnhance(optionsA11yEnhance)]);
|
|
115
103
|
function TabPanelItem(props) {
|
|
116
104
|
var _ref2 = arguments[0],
|
|
117
105
|
_ref6;
|
|
@@ -119,17 +107,12 @@ function TabPanelItem(props) {
|
|
|
119
107
|
var Children = props.Children,
|
|
120
108
|
styles = props.styles,
|
|
121
109
|
addonLeft = props.addonLeft,
|
|
122
|
-
addonRight = props.addonRight
|
|
123
|
-
buttonRefsList = props.buttonRefsList,
|
|
124
|
-
index = props.index;
|
|
125
|
-
var buttonRef = React.useRef();
|
|
126
|
-
buttonRefsList[index] = buttonRef;
|
|
110
|
+
addonRight = props.addonRight;
|
|
127
111
|
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(STabPanelItem, _ref6.cn("STabPanelItem", _objectSpread({}, _assignProps2({
|
|
128
112
|
"type": 'button',
|
|
129
113
|
"tag": 'button',
|
|
130
114
|
"tabIndex": 0,
|
|
131
|
-
"role": 'tab'
|
|
132
|
-
"ref": buttonRef
|
|
115
|
+
"role": 'tab'
|
|
133
116
|
}, _ref2))), addonLeft ? /*#__PURE__*/React.createElement(TabPanel.Item.Addon, {
|
|
134
117
|
tag: addonLeft
|
|
135
118
|
}) : null, addonTextChildren(Children, TabPanel.Item.Text, TabPanel.Item.Addon), addonRight ? /*#__PURE__*/React.createElement(TabPanel.Item.Addon, {
|
|
@@ -139,17 +122,10 @@ function TabPanelItem(props) {
|
|
|
139
122
|
function Text(props) {
|
|
140
123
|
var _ref3 = arguments[0],
|
|
141
124
|
_ref7;
|
|
142
|
-
var SText =
|
|
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;
|
|
125
|
+
var SText = Box;
|
|
126
|
+
var styles = props.styles;
|
|
148
127
|
return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SText, _ref7.cn("SText", _objectSpread({}, _assignProps3({
|
|
149
|
-
"
|
|
150
|
-
"ellipsis": ellipsis,
|
|
151
|
-
"medium": true,
|
|
152
|
-
"hint:triggerRef": buttonRefsList[index]
|
|
128
|
+
"tag": 'span'
|
|
153
129
|
}, _ref3))));
|
|
154
130
|
}
|
|
155
131
|
function Addon(props) {
|
package/lib/es6/TabPanel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AAAA;AAAA,IAKpBC,YAAY,0BAAAC,UAAA;EAAA,SAAAD,aAAA;IAAA,IAAAE,KAAA;IAAAC,eAAA,OAAAH,YAAA;IAAA,SAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAAC,KAAA,CAAAJ,IAAA,G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,YAAY,GAAG,SAAfA,YAAYA,CAA+BC,OAKpC;EAAA,OAAKA,OAAO;AAAA,CAA+C;AAE/E,eAAef,QAAQ","ignoreList":[]}
|
|
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,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AK,EAAAD,KAAA,CAAAnB,EAAA,UAAAC,aAAA,KAAAoB,aAAA;IAAA,OAAkB;EAAM,GAAAH,KAAA,GAAE,CAAC;AAC1D;AAEA,SAASH,KAAKA,CAACrD,KAAK,EAAE;EAAA,IAAA4D,KAAA,GAAAhB,YAAA;IAAAiB,KAAA;EACpB,IAAMC,MAAM,GAE2BtE,GAAG;EAD1C,IAAQ4C,MAAM,GAAKpC,KAAK,CAAhBoC,MAAM;EACd,OAAAyB,KAAA,GAAOzE,OAAO,CAACgD,MAAM,CAAC,eAAC3C,KAAA,CAAA4C,aAAA,CAACyB,MAAM,EAAAD,KAAA,CAAAvB,EAAA,WAAAC,aAAA,KAAAwB,aAAA;IAAA,OAAkB;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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default
|
|
2
|
-
export * from './TabPanel
|
|
1
|
+
export { default } from './TabPanel';
|
|
2
|
+
export * from './TabPanel';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/lib/es6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default"
|
|
1
|
+
{"version":3,"file":"index.js","names":["default"],"sources":["../../src/index.js"],"sourcesContent":["export { default } from './TabPanel';\nexport * from './TabPanel';\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AACpC,cAAc,YAAY","ignoreList":[]}
|
|
@@ -40,6 +40,12 @@ 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
|
+
|
|
43
49
|
&::-moz-focus-inner {
|
|
44
50
|
border: none;
|
|
45
51
|
padding: 0;
|
|
@@ -90,7 +96,11 @@ STabPanelItem[selected] {
|
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
SText {
|
|
99
|
+
display: inline-block;
|
|
93
100
|
margin: auto var(--intergalactic-spacing-2x, 8px);
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
text-overflow: ellipsis;
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
SAddon {
|
package/lib/esm/TabPanel.mjs
CHANGED
|
@@ -4,30 +4,40 @@ 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 { sstyled, assignProps, Component
|
|
8
|
-
import { Box } from "@semcore/base-components";
|
|
7
|
+
import { sstyled, createComponent, assignProps, Component } from "@semcore/core";
|
|
9
8
|
import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
10
9
|
import a11yEnhance from "@semcore/core/lib/utils/enhances/a11yEnhance";
|
|
11
|
-
import {
|
|
10
|
+
import { Box } from "@semcore/flex-box";
|
|
12
11
|
import React from "react";
|
|
13
12
|
/*!__reshadow-styles__:"./style/tab-panel.shadow.css"*/
|
|
14
13
|
var style = (
|
|
15
14
|
/*__reshadow_css_start__*/
|
|
16
15
|
(sstyled.insert(
|
|
17
16
|
/*__inner_css_start__*/
|
|
18
|
-
'.
|
|
17
|
+
'.___STabPanel_1qj1t_gg_{display:flex;width:100%;max-width:100%}.___STabPanel_1qj1t_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_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanel_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_1qj1t_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_1qj1t_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___STabPanelItem_1qj1t_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___STabPanelItem_1qj1t_gg_ .___SText_1qj1t_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%);font-weight:var(--intergalactic-medium, 500)}.___STabPanelItem_1qj1t_gg_::-moz-focus-inner{border:0;padding:0}.___STabPanelItem_1qj1t_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___STabPanelItem_1qj1t_gg_:hover{-webkit-text-decoration:none;text-decoration:none;color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899))}}.___STabPanelItem_1qj1t_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_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_1qj1t_gg_::after{border-bottom:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___STabPanelItem_1qj1t_gg_.__disabled_1qj1t_gg_{cursor:default;pointer-events:none}.___STabPanelItem_1qj1t_gg_.__disabled_1qj1t_gg_ .___SAddon_1qj1t_gg_,.___STabPanelItem_1qj1t_gg_.__disabled_1qj1t_gg_ .___SText_1qj1t_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_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_1qj1t_gg_.__selected_1qj1t_gg_{border-color:var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_gg_{border-color:var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}@media (hover:hover){.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_gg_:hover{color:var(--intergalactic-text-link-hover-active, rgb(33, 89, 215))}}.___STabPanelItem_1qj1t_gg_.__selected_1qj1t_gg_::after{border-bottom:none}.___SText_1qj1t_gg_{display:inline-block;margin:auto var(--intergalactic-spacing-2x, 8px);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___SAddon_1qj1t_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_1qj1t_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1qj1t_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SAddon_1qj1t_gg_:only-child{margin-right:var(--intergalactic-spacing-2x, 8px);margin-left:var(--intergalactic-spacing-2x, 8px)}',
|
|
19
18
|
/*__inner_css_end__*/
|
|
20
|
-
"
|
|
19
|
+
"1qj1t_gg_"
|
|
21
20
|
), /*__reshadow_css_end__*/
|
|
22
21
|
{
|
|
23
|
-
"__SText": "
|
|
24
|
-
"__SAddon": "
|
|
25
|
-
"__STabPanel": "
|
|
26
|
-
"__STabPanelItem": "
|
|
27
|
-
"_disabled": "
|
|
28
|
-
"_selected": "
|
|
22
|
+
"__SText": "___SText_1qj1t_gg_",
|
|
23
|
+
"__SAddon": "___SAddon_1qj1t_gg_",
|
|
24
|
+
"__STabPanel": "___STabPanel_1qj1t_gg_",
|
|
25
|
+
"__STabPanelItem": "___STabPanelItem_1qj1t_gg_",
|
|
26
|
+
"_disabled": "__disabled_1qj1t_gg_",
|
|
27
|
+
"_selected": "__selected_1qj1t_gg_"
|
|
29
28
|
})
|
|
30
29
|
);
|
|
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
|
+
};
|
|
31
41
|
var TabPanelRoot = /* @__PURE__ */ (function(_Component) {
|
|
32
42
|
function TabPanelRoot2() {
|
|
33
43
|
var _this;
|
|
@@ -36,7 +46,6 @@ var TabPanelRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
36
46
|
args[_key] = arguments[_key];
|
|
37
47
|
}
|
|
38
48
|
_this = _callSuper(this, TabPanelRoot2, [].concat(args));
|
|
39
|
-
_defineProperty(_this, "buttonRefsList", []);
|
|
40
49
|
_defineProperty(_this, "handleClick", function(value) {
|
|
41
50
|
return function(event) {
|
|
42
51
|
_this.handlers.value(value, event);
|
|
@@ -62,7 +71,7 @@ var TabPanelRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
62
71
|
}
|
|
63
72
|
}, {
|
|
64
73
|
key: "getItemProps",
|
|
65
|
-
value: function getItemProps(props,
|
|
74
|
+
value: function getItemProps(props, _index) {
|
|
66
75
|
var value = this.asProps.value;
|
|
67
76
|
var isSelected = value === props.value;
|
|
68
77
|
return {
|
|
@@ -70,17 +79,7 @@ var TabPanelRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
70
79
|
"onClick": this.handleClick(props.value),
|
|
71
80
|
"onKeyDown": this.handleKeyDown(props.value),
|
|
72
81
|
"tabIndex": isSelected ? 0 : -1,
|
|
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
|
|
82
|
+
"aria-selected": isSelected
|
|
84
83
|
};
|
|
85
84
|
}
|
|
86
85
|
}, {
|
|
@@ -101,30 +100,16 @@ _defineProperty(TabPanelRoot, "defaultProps", {
|
|
|
101
100
|
defaultValue: null,
|
|
102
101
|
behavior: "manual"
|
|
103
102
|
});
|
|
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
|
-
;
|
|
103
|
+
_defineProperty(TabPanelRoot, "enhance", [a11yEnhance(optionsA11yEnhance)]);
|
|
116
104
|
function TabPanelItem(props) {
|
|
117
105
|
var _ref2 = arguments[0], _ref6;
|
|
118
106
|
var STabPanelItem = Box;
|
|
119
|
-
var Children = props.Children, styles = props.styles, addonLeft = props.addonLeft, addonRight = props.addonRight
|
|
120
|
-
var buttonRef = React.useRef();
|
|
121
|
-
buttonRefsList[index] = buttonRef;
|
|
107
|
+
var Children = props.Children, styles = props.styles, addonLeft = props.addonLeft, addonRight = props.addonRight;
|
|
122
108
|
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(STabPanelItem, _ref6.cn("STabPanelItem", _objectSpread({}, assignProps({
|
|
123
109
|
"type": "button",
|
|
124
110
|
"tag": "button",
|
|
125
111
|
"tabIndex": 0,
|
|
126
|
-
"role": "tab"
|
|
127
|
-
"ref": buttonRef
|
|
112
|
+
"role": "tab"
|
|
128
113
|
}, _ref2))), addonLeft ? /* @__PURE__ */ React.createElement(TabPanel.Item.Addon, {
|
|
129
114
|
tag: addonLeft
|
|
130
115
|
}) : null, addonTextChildren(Children, TabPanel.Item.Text, TabPanel.Item.Addon), addonRight ? /* @__PURE__ */ React.createElement(TabPanel.Item.Addon, {
|
|
@@ -133,13 +118,10 @@ function TabPanelItem(props) {
|
|
|
133
118
|
}
|
|
134
119
|
function Text(props) {
|
|
135
120
|
var _ref3 = arguments[0], _ref7;
|
|
136
|
-
var SText =
|
|
137
|
-
var styles = props.styles
|
|
121
|
+
var SText = Box;
|
|
122
|
+
var styles = props.styles;
|
|
138
123
|
return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SText, _ref7.cn("SText", _objectSpread({}, assignProps({
|
|
139
|
-
"
|
|
140
|
-
"ellipsis": ellipsis,
|
|
141
|
-
"medium": true,
|
|
142
|
-
"hint:triggerRef": buttonRefsList[index]
|
|
124
|
+
"tag": "span"
|
|
143
125
|
}, _ref3))));
|
|
144
126
|
}
|
|
145
127
|
function Addon(props) {
|
package/lib/esm/index.mjs
CHANGED
|
@@ -40,6 +40,12 @@ 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
|
+
|
|
43
49
|
&::-moz-focus-inner {
|
|
44
50
|
border: none;
|
|
45
51
|
padding: 0;
|
|
@@ -90,7 +96,11 @@ STabPanelItem[selected] {
|
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
SText {
|
|
99
|
+
display: inline-block;
|
|
93
100
|
margin: auto var(--intergalactic-spacing-2x, 8px);
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
text-overflow: ellipsis;
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
SAddon {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,2 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';
|
|
2
|
+
import type { Box, BoxProps } from '@semcore/flex-box';
|
|
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;
|
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.
|
|
4
|
+
"version": "16.1.1",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/flex-box": "16.1.
|
|
17
|
+
"@semcore/flex-box": "16.1.1"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@semcore/base-components": "^16.6.0"
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"directory": "semcore/tab-panel"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@semcore/core": "16.6.0",
|
|
29
28
|
"@semcore/testing-utils": "1.0.0",
|
|
30
|
-
"@semcore/icon": "16.8.
|
|
29
|
+
"@semcore/icon": "16.8.1",
|
|
30
|
+
"@semcore/core": "16.6.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "pnpm semcore-builder --source=js && pnpm vite build"
|
package/lib/cjs/TabPanel.type.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/TabPanel.type.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/lib/types/TabPanel.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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;
|
|
@@ -1,71 +0,0 @@
|
|
|
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 };
|