@semcore/tab-line 3.2.10 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/TabLine.js +111 -84
- package/lib/cjs/TabLine.js.map +1 -1
- package/lib/cjs/style/tab-line.shadow.css +21 -14
- package/lib/es6/TabLine.js +104 -73
- package/lib/es6/TabLine.js.map +1 -1
- package/lib/es6/style/tab-line.shadow.css +21 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [3.3.0] - 2023-02-23
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Fixed underline width glitching by rebuilding internal animation mechanism.
|
|
10
|
+
|
|
5
11
|
## [3.2.10] - 2023-02-21
|
|
6
12
|
|
|
7
13
|
### Changed
|
package/lib/cjs/TabLine.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
+
|
|
12
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
15
|
|
|
14
16
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -17,9 +19,7 @@ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
17
19
|
|
|
18
20
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
21
|
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
22
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
23
23
|
|
|
24
24
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
25
|
|
|
@@ -37,42 +37,28 @@ var _a11yEnhance = _interopRequireDefault(require("@semcore/utils/lib/enhances/a
|
|
|
37
37
|
|
|
38
38
|
var _neighborLocation = _interopRequireDefault(require("@semcore/neighbor-location"));
|
|
39
39
|
|
|
40
|
-
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
|
41
|
-
|
|
42
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
|
-
|
|
44
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
45
|
-
|
|
46
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
47
|
-
|
|
48
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
49
|
-
|
|
50
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
51
|
-
|
|
52
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
|
-
|
|
54
40
|
/*__reshadow-styles__:"./style/tab-line.shadow.css"*/
|
|
55
41
|
var style = (
|
|
56
42
|
/*__reshadow_css_start__*/
|
|
57
43
|
_core.sstyled.insert(
|
|
58
44
|
/*__inner_css_start__*/
|
|
59
|
-
".
|
|
45
|
+
".___STabLine_14v3w_gg_{position:relative;display:flex;width:100%;max-width:100%}.___STabLine_14v3w_gg_.__underlined_14v3w_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabLineItem_14v3w_gg_{display:inline-flex;align-items:center;justify-content:center;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;outline:0;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;border:0;background:0 0;color:var(--intergalactic-text-primary, #191b23);margin-right:var(--intergalactic-spacing-4x, 16px);font-weight:var(--intergalactic-medium, 500)}.___STabLineItem_14v3w_gg_::-moz-focus-inner{border:0;padding:0}.___STabLineItem_14v3w_gg_:active,.___STabLineItem_14v3w_gg_:focus{outline:0;text-decoration:none}@media (hover:hover){.___STabLineItem_14v3w_gg_:hover{outline:0;text-decoration:none}}.___STabLineItem_14v3w_gg_::after,.___STabLineItem_14v3w_gg_::before{content:\"\";position:absolute;left:0;bottom:-1px;height:3px;width:100%;background-color:transparent}.___STabLineItem_14v3w_gg_::before{transition:background-color calc(var(--intergalactic-duration-control, 200)*1ms) ease-in-out}@media (hover:hover){.___STabLineItem_14v3w_gg_:hover::before{background-color:var(--intergalactic-border-primary, #c4c7cf)}}.___STabLineItem_14v3w_gg_.__selected_14v3w_gg_::after{transition-delay:calc(var(--intergalactic-duration-control, 200)*1ms);background-color:var(--intergalactic-border-info-active, #006dca)}.___STabLineItem_14v3w_gg_ .___SAddon_14v3w_gg_:not(:last-child),.___STabLineItem_14v3w_gg_ .___SText_14v3w_gg_:not(:last-child){margin-right:var(--intergalactic-spacing-2x, 8px)}.___SCaret_14v3w_gg_{position:absolute;bottom:-1px;height:3px;background-color:var(--intergalactic-border-info-active, #006dca);transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___STabLineItem_14v3w_gg_.__selected_14v3w_gg_{flex-shrink:0}.___STabLineItem_14v3w_gg_.__disabled_14v3w_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___STabLineItem_14v3w_gg_.__keyboardFocused_14v3w_gg_{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.3))}.___SText_14v3w_gg_{display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___SAddon_14v3w_gg_{display:inline-flex;align-items:center;justify-content:center}.___STabLineItem_14v3w_gg_._size_m_14v3w_gg_{height:28px;min-width:18px}.___STabLineItem_14v3w_gg_._size_m_14v3w_gg_ .___SText_14v3w_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___STabLineItem_14v3w_gg_._size_l_14v3w_gg_{height:40px;min-width:26px}.___STabLineItem_14v3w_gg_._size_l_14v3w_gg_ .___SText_14v3w_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___STabLineItem_14v3w_gg_._neighborLocation_left_14v3w_gg_{margin-right:0}@media (prefers-reduced-motion){.___STabLineItem_14v3w_gg_::after,.___STabLineItem_14v3w_gg_::before{transition:none}.___STabLineItem_14v3w_gg_.__selected_14v3w_gg_::after{transition-delay:0;transition:none}.___SCaret_14v3w_gg_{display:none}}"
|
|
60
46
|
/*__inner_css_end__*/
|
|
61
|
-
, "
|
|
47
|
+
, "14v3w_gg_")
|
|
62
48
|
/*__reshadow_css_end__*/
|
|
63
49
|
, {
|
|
64
|
-
"__STabLine": "
|
|
65
|
-
"_underlined": "
|
|
66
|
-
"__STabLineItem": "
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"_disabled": "
|
|
72
|
-
"_keyboardFocused": "
|
|
73
|
-
"_size_m": "
|
|
74
|
-
"_size_l": "
|
|
75
|
-
"_neighborLocation_left": "
|
|
50
|
+
"__STabLine": "___STabLine_14v3w_gg_",
|
|
51
|
+
"_underlined": "__underlined_14v3w_gg_",
|
|
52
|
+
"__STabLineItem": "___STabLineItem_14v3w_gg_",
|
|
53
|
+
"_selected": "__selected_14v3w_gg_",
|
|
54
|
+
"__SText": "___SText_14v3w_gg_",
|
|
55
|
+
"__SAddon": "___SAddon_14v3w_gg_",
|
|
56
|
+
"__SCaret": "___SCaret_14v3w_gg_",
|
|
57
|
+
"_disabled": "__disabled_14v3w_gg_",
|
|
58
|
+
"_keyboardFocused": "__keyboardFocused_14v3w_gg_",
|
|
59
|
+
"_size_m": "_size_m_14v3w_gg_",
|
|
60
|
+
"_size_l": "_size_l_14v3w_gg_",
|
|
61
|
+
"_neighborLocation_left": "_neighborLocation_left_14v3w_gg_"
|
|
76
62
|
});
|
|
77
63
|
var optionsA11yEnhance = {
|
|
78
64
|
onNeighborChange: function onNeighborChange(neighborElement) {
|
|
@@ -87,41 +73,45 @@ var optionsA11yEnhance = {
|
|
|
87
73
|
var TabLineRoot = /*#__PURE__*/function (_Component) {
|
|
88
74
|
(0, _inherits2["default"])(TabLineRoot, _Component);
|
|
89
75
|
|
|
90
|
-
var _super =
|
|
76
|
+
var _super = (0, _createSuper2["default"])(TabLineRoot);
|
|
91
77
|
|
|
92
|
-
function TabLineRoot(
|
|
78
|
+
function TabLineRoot() {
|
|
93
79
|
var _this;
|
|
94
80
|
|
|
95
81
|
(0, _classCallCheck2["default"])(this, TabLineRoot);
|
|
96
|
-
|
|
97
|
-
(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
82
|
+
|
|
83
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
84
|
+
args[_key] = arguments[_key];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
88
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
89
|
+
animation: null
|
|
90
|
+
});
|
|
91
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "itemRefs", {});
|
|
92
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "containerRef", /*#__PURE__*/_react["default"].createRef());
|
|
93
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "animationStartTimeout", -1);
|
|
94
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleAnimationStart", function () {
|
|
95
|
+
var _this$state$animation;
|
|
96
|
+
|
|
97
|
+
if (((_this$state$animation = _this.state.animation) === null || _this$state$animation === void 0 ? void 0 : _this$state$animation.started) === false) {
|
|
98
|
+
_this.setState({
|
|
99
|
+
animation: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _this.state.animation), {}, {
|
|
100
|
+
started: true
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleAnimationEnd", function () {
|
|
106
|
+
_this.setState({
|
|
107
|
+
animation: null
|
|
108
|
+
});
|
|
109
|
+
});
|
|
101
110
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "bindHandlerClick", function (value) {
|
|
102
111
|
return function (e) {
|
|
103
112
|
_this.handlers.value(value, e);
|
|
104
113
|
};
|
|
105
114
|
});
|
|
106
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "calculateStylesIndicator", function () {
|
|
107
|
-
var indicator = _this.$indicator.current;
|
|
108
|
-
var tabsParent = _this.$tabsParent.current;
|
|
109
|
-
if (!indicator || !tabsParent) return false;
|
|
110
|
-
var tab = Array.from(tabsParent.querySelectorAll('[data-ui-name="TabLine.Item"]')).find(function (node) {
|
|
111
|
-
return node.getAttribute('value') === String(_this.asProps.value);
|
|
112
|
-
});
|
|
113
|
-
if (!tab) return false;
|
|
114
|
-
|
|
115
|
-
_this.$observerTab.observe(tab);
|
|
116
|
-
|
|
117
|
-
var offsetLeft = tab.offsetLeft,
|
|
118
|
-
offsetWidth = tab.offsetWidth;
|
|
119
|
-
var positionLeftParent = tabsParent.clientLeft + parseInt(tabsParent.style.paddingLeft, 10) || 0;
|
|
120
|
-
indicator.style.transform = "translateX(".concat(offsetLeft - positionLeftParent, "px)");
|
|
121
|
-
indicator.style.width = "".concat(offsetWidth, "px");
|
|
122
|
-
});
|
|
123
|
-
_this.$observer = new _resizeObserverPolyfill["default"](_this.calculateStylesIndicator);
|
|
124
|
-
_this.$observerTab = new _resizeObserverPolyfill["default"](_this.calculateStylesIndicator);
|
|
125
115
|
return _this;
|
|
126
116
|
}
|
|
127
117
|
|
|
@@ -132,30 +122,41 @@ var TabLineRoot = /*#__PURE__*/function (_Component) {
|
|
|
132
122
|
value: null
|
|
133
123
|
};
|
|
134
124
|
}
|
|
135
|
-
}, {
|
|
136
|
-
key: "componentDidMount",
|
|
137
|
-
value: function componentDidMount() {
|
|
138
|
-
if (this.$tabsParent.current) {
|
|
139
|
-
this.$observer.observe(this.$tabsParent.current);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
this.calculateStylesIndicator();
|
|
143
|
-
}
|
|
144
125
|
}, {
|
|
145
126
|
key: "componentDidUpdate",
|
|
146
|
-
value: function componentDidUpdate() {
|
|
147
|
-
this
|
|
148
|
-
|
|
127
|
+
value: function componentDidUpdate(prevProps) {
|
|
128
|
+
if (prevProps.value !== null && this.props.value !== null && prevProps.value !== this.props.value) {
|
|
129
|
+
var fromNode = this.itemRefs[prevProps.value];
|
|
130
|
+
var toNode = this.itemRefs[this.props.value];
|
|
131
|
+
var containerNode = this.containerRef.current;
|
|
132
|
+
if (!fromNode || !toNode || !containerNode) return;
|
|
133
|
+
var containerRect = containerNode.getBoundingClientRect();
|
|
134
|
+
var fromRect = fromNode.getBoundingClientRect();
|
|
135
|
+
var toRect = toNode.getBoundingClientRect();
|
|
136
|
+
var animation = {
|
|
137
|
+
fromLeft: fromRect.x - containerRect.x,
|
|
138
|
+
fromWidth: fromRect.width,
|
|
139
|
+
toLeft: toRect.x - containerRect.x,
|
|
140
|
+
toWidth: toRect.width,
|
|
141
|
+
started: false
|
|
142
|
+
};
|
|
143
|
+
this.setState({
|
|
144
|
+
animation: animation
|
|
145
|
+
});
|
|
146
|
+
clearTimeout(this.animationStartTimeout);
|
|
147
|
+
this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);
|
|
148
|
+
}
|
|
149
149
|
}
|
|
150
150
|
}, {
|
|
151
151
|
key: "componentWillUnmount",
|
|
152
152
|
value: function componentWillUnmount() {
|
|
153
|
-
this
|
|
154
|
-
this.$observerTab.disconnect();
|
|
153
|
+
clearTimeout(this.animationStartTimeout);
|
|
155
154
|
}
|
|
156
155
|
}, {
|
|
157
156
|
key: "getItemProps",
|
|
158
157
|
value: function getItemProps(props) {
|
|
158
|
+
var _this2 = this;
|
|
159
|
+
|
|
159
160
|
var _this$asProps = this.asProps,
|
|
160
161
|
value = _this$asProps.value,
|
|
161
162
|
size = _this$asProps.size;
|
|
@@ -166,9 +167,36 @@ var TabLineRoot = /*#__PURE__*/function (_Component) {
|
|
|
166
167
|
onClick: this.bindHandlerClick(props.value),
|
|
167
168
|
tabIndex: isSelected ? 0 : -1,
|
|
168
169
|
'aria-posinset': value,
|
|
169
|
-
'aria-selected': isSelected
|
|
170
|
+
'aria-selected': isSelected,
|
|
171
|
+
ref: function ref(node) {
|
|
172
|
+
return _this2.itemRefs[props.value] = node;
|
|
173
|
+
}
|
|
170
174
|
};
|
|
171
175
|
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "getCaretProps",
|
|
178
|
+
value: function getCaretProps() {
|
|
179
|
+
var animation = this.state.animation;
|
|
180
|
+
if (!animation) return {};
|
|
181
|
+
|
|
182
|
+
if (animation.started) {
|
|
183
|
+
return {
|
|
184
|
+
style: {
|
|
185
|
+
left: animation.toLeft,
|
|
186
|
+
width: animation.toWidth
|
|
187
|
+
},
|
|
188
|
+
onTransitionEnd: this.handleAnimationEnd
|
|
189
|
+
};
|
|
190
|
+
} else {
|
|
191
|
+
return {
|
|
192
|
+
style: {
|
|
193
|
+
left: animation.fromLeft,
|
|
194
|
+
width: animation.fromWidth
|
|
195
|
+
},
|
|
196
|
+
onTransitionEnd: this.handleAnimationEnd
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
172
200
|
}, {
|
|
173
201
|
key: "render",
|
|
174
202
|
value: function render() {
|
|
@@ -176,19 +204,18 @@ var TabLineRoot = /*#__PURE__*/function (_Component) {
|
|
|
176
204
|
_ref5;
|
|
177
205
|
|
|
178
206
|
var STabLine = _flexBox.Box;
|
|
179
|
-
var
|
|
207
|
+
var SCaret = 'div';
|
|
180
208
|
var _this$asProps2 = this.asProps,
|
|
181
209
|
styles = _this$asProps2.styles,
|
|
182
210
|
Children = _this$asProps2.Children,
|
|
183
211
|
controlsLength = _this$asProps2.controlsLength;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
"role": "tablist"
|
|
212
|
+
var animation = this.state.animation;
|
|
213
|
+
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(STabLine, _ref5.cn("STabLine", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
214
|
+
"role": "tablist",
|
|
215
|
+
"ref": this.containerRef
|
|
187
216
|
}, _ref))), /*#__PURE__*/_react["default"].createElement(_neighborLocation["default"], _ref5.cn("NeighborLocation", {
|
|
188
217
|
"controlsLength": controlsLength
|
|
189
|
-
}), /*#__PURE__*/_react["default"].createElement(Children, _ref5.cn("Children", {}))), /*#__PURE__*/_react["default"].createElement(
|
|
190
|
-
"ref": this.$indicator
|
|
191
|
-
})));
|
|
218
|
+
}), /*#__PURE__*/_react["default"].createElement(Children, _ref5.cn("Children", {}))), animation && /*#__PURE__*/_react["default"].createElement(SCaret, _ref5.cn("SCaret", (0, _objectSpread2["default"])({}, this.getCaretProps()))));
|
|
192
219
|
}
|
|
193
220
|
}]);
|
|
194
221
|
return TabLineRoot;
|
|
@@ -216,7 +243,7 @@ function TabLineItem(props) {
|
|
|
216
243
|
}, function (neighborLocation) {
|
|
217
244
|
var _ref6;
|
|
218
245
|
|
|
219
|
-
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(STabLineItem, _ref6.cn("STabLineItem",
|
|
246
|
+
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(STabLineItem, _ref6.cn("STabLineItem", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
220
247
|
"tag": "button",
|
|
221
248
|
"neighborLocation": neighborLocation,
|
|
222
249
|
"type": "button",
|
|
@@ -237,7 +264,7 @@ function Text(props) {
|
|
|
237
264
|
|
|
238
265
|
var styles = props.styles;
|
|
239
266
|
var SText = _flexBox.Box;
|
|
240
|
-
return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SText, _ref7.cn("SText",
|
|
267
|
+
return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SText, _ref7.cn("SText", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
241
268
|
"tag": "span"
|
|
242
269
|
}, _ref3))));
|
|
243
270
|
}
|
|
@@ -248,7 +275,7 @@ function Addon(props) {
|
|
|
248
275
|
|
|
249
276
|
var styles = props.styles;
|
|
250
277
|
var SAddon = _flexBox.Box;
|
|
251
|
-
return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref8.cn("SAddon",
|
|
278
|
+
return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref8.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
252
279
|
"tag": "span"
|
|
253
280
|
}, _ref4))));
|
|
254
281
|
}
|
package/lib/cjs/TabLine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabLine.js","names":["optionsA11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","TabLineRoot","props","React","createRef","value","e","handlers","indicator","$indicator","current","tabsParent","$tabsParent","tab","Array","from","querySelectorAll","find","node","getAttribute","String","asProps","$observerTab","observe","offsetLeft","offsetWidth","positionLeftParent","clientLeft","parseInt","style","paddingLeft","transform","width","$observer","ResizeObserver","calculateStylesIndicator","disconnect","size","isSelected","selected","onClick","bindHandlerClick","tabIndex","STabLine","Box","SIndicator","styles","Children","controlsLength","sstyled","Component","defaultValue","underlined","a11yEnhance","TabLineItem","STabLineItem","addonLeft","addonRight","neighborLocation","addonTextChildren","TabLine","Item","Text","Addon","enhance","keyboardFocusEnhance","SText","SAddon","createComponent"],"sources":["../../src/TabLine.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport a11yEnhance from '@semcore/utils/lib/enhances/a11yEnhance';\nimport NeighborLocation from '@semcore/neighbor-location';\nimport ResizeObserver from 'resize-observer-polyfill';\n\nimport style from './style/tab-line.shadow.css';\n\nconst optionsA11yEnhance = {\n onNeighborChange: (neighborElement) => {\n if (neighborElement) {\n neighborElement.focus();\n neighborElement.click();\n }\n },\n childSelector: ['role', 'tab'],\n};\n\nclass TabLineRoot extends Component {\n static displayName = 'TabLine';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n size: 'm',\n underlined: true,\n };\n static enhance = [a11yEnhance(optionsA11yEnhance)];\n\n $observer;\n $observerTab;\n $indicator = React.createRef();\n $tabsParent = React.createRef();\n\n constructor(props) {\n super(props);\n this.$observer = new ResizeObserver(this.calculateStylesIndicator);\n this.$observerTab = new ResizeObserver(this.calculateStylesIndicator);\n }\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n calculateStylesIndicator = () => {\n const indicator = this.$indicator.current;\n const tabsParent = this.$tabsParent.current;\n if (!indicator || !tabsParent) return false;\n const tab = Array.from(tabsParent.querySelectorAll('[data-ui-name=\"TabLine.Item\"]')).find(\n (node) => node.getAttribute('value') === String(this.asProps.value),\n );\n if (!tab) return false;\n this.$observerTab.observe(tab);\n const { offsetLeft, offsetWidth } = tab;\n const positionLeftParent =\n tabsParent.clientLeft + parseInt(tabsParent.style.paddingLeft, 10) || 0;\n indicator.style.transform = `translateX(${offsetLeft - positionLeftParent}px)`;\n indicator.style.width = `${offsetWidth}px`;\n };\n\n componentDidMount() {\n if (this.$tabsParent.current) {\n this.$observer.observe(this.$tabsParent.current);\n }\n this.calculateStylesIndicator();\n }\n\n componentDidUpdate() {\n this.$observerTab.disconnect();\n this.calculateStylesIndicator();\n }\n\n componentWillUnmount() {\n this.$observer.disconnect();\n this.$observerTab.disconnect();\n }\n\n getItemProps(props) {\n const { value, size } = this.asProps;\n const isSelected = value === props.value;\n return {\n size,\n selected: isSelected,\n onClick: this.bindHandlerClick(props.value),\n tabIndex: isSelected ? 0 : -1,\n 'aria-posinset': value,\n 'aria-selected': isSelected,\n };\n }\n\n render() {\n const STabLine = Root;\n const SIndicator = 'div';\n const { styles, Children, controlsLength } = this.asProps;\n\n return sstyled(styles)(\n <STabLine render={Box} ref={this.$tabsParent} role=\"tablist\">\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n <SIndicator ref={this.$indicator} />\n </STabLine>,\n );\n }\n}\n\nfunction TabLineItem(props) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation } = props;\n\n return (\n <NeighborLocation.Detect neighborLocation={neighborLocation}>\n {(neighborLocation) =>\n sstyled(styles)(\n <STabLineItem\n render={Box}\n tag=\"button\"\n neighborLocation={neighborLocation}\n type=\"button\"\n role=\"tab\"\n >\n {addonLeft ? <TabLine.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabLine.Item.Text, TabLine.Item.Addon)}\n {addonRight ? <TabLine.Item.Addon tag={addonRight} /> : null}\n </STabLineItem>,\n )\n }\n </NeighborLocation.Detect>\n );\n}\n\nTabLineItem.enhance = [keyboardFocusEnhance()];\n\nfunction Text(props) {\n const { styles } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={Box} tag=\"span\" />);\n}\n\nfunction Addon(props) {\n const { styles } = props;\n const SAddon = Root;\n return sstyled(styles)(<SAddon render={Box} tag=\"span\" />);\n}\n\nconst TabLine = createComponent(TabLineRoot, {\n Item: [TabLineItem, { Text, Addon }],\n});\n\nexport default TabLine;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,kBAAkB,GAAG;EACzBC,gBAAgB,EAAE,0BAACC,eAAD,EAAqB;IACrC,IAAIA,eAAJ,EAAqB;MACnBA,eAAe,CAACC,KAAhB;MACAD,eAAe,CAACE,KAAhB;IACD;EACF,CANwB;EAOzBC,aAAa,EAAE,CAAC,MAAD,EAAS,KAAT;AAPU,CAA3B;;IAUMC,W;;;;;EAeJ,qBAAYC,KAAZ,EAAmB;IAAA;;IAAA;IACjB,0BAAMA,KAAN;IADiB;IAAA;IAAA,4GAHNC,iBAAA,CAAMC,SAAN,EAGM;IAAA,6GAFLD,iBAAA,CAAMC,SAAN,EAEK;IAAA,qGAYA,UAACC,KAAD;MAAA,OAAW,UAACC,CAAD,EAAO;QACnC,MAAKC,QAAL,CAAcF,KAAd,CAAoBA,KAApB,EAA2BC,CAA3B;MACD,CAFkB;IAAA,CAZA;IAAA,6GAgBQ,YAAM;MAC/B,IAAME,SAAS,GAAG,MAAKC,UAAL,CAAgBC,OAAlC;MACA,IAAMC,UAAU,GAAG,MAAKC,WAAL,CAAiBF,OAApC;MACA,IAAI,CAACF,SAAD,IAAc,CAACG,UAAnB,EAA+B,OAAO,KAAP;MAC/B,IAAME,GAAG,GAAGC,KAAK,CAACC,IAAN,CAAWJ,UAAU,CAACK,gBAAX,CAA4B,+BAA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Q4C,MAAR;EACA,IAAMqB,MAAM,GAC2BvB,YADvC;EACA,eAAO,IAAAK,aAAA,EAAQH,MAAR,CAAP,eAAuB,gCAAC,MAAD;IAAA,OAAyB;EAAzB,YAAvB;AACD;;AAED,IAAMc,OAAO,GAAG,IAAAQ,gBAAA,EAAgBnE,WAAhB,EAA6B;EAC3C4D,IAAI,EAAE,CAACP,WAAD,EAAc;IAAEQ,IAAI,EAAJA,IAAF;IAAQC,KAAK,EAALA;EAAR,CAAd;AADqC,CAA7B,CAAhB;eAIeH,O"}
|
|
1
|
+
{"version":3,"file":"TabLine.js","names":["optionsA11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","TabLineRoot","animation","React","createRef","state","started","setState","value","e","handlers","prevProps","props","fromNode","itemRefs","toNode","containerNode","containerRef","current","containerRect","getBoundingClientRect","fromRect","toRect","fromLeft","x","fromWidth","width","toLeft","toWidth","clearTimeout","animationStartTimeout","setTimeout","handleAnimationStart","asProps","size","isSelected","selected","onClick","bindHandlerClick","tabIndex","ref","node","style","left","onTransitionEnd","handleAnimationEnd","STabLine","Box","SCaret","styles","Children","controlsLength","sstyled","getCaretProps","Component","defaultValue","underlined","a11yEnhance","TabLineItem","STabLineItem","addonLeft","addonRight","neighborLocation","addonTextChildren","TabLine","Item","Text","Addon","enhance","keyboardFocusEnhance","SText","SAddon","createComponent"],"sources":["../../src/TabLine.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport a11yEnhance from '@semcore/utils/lib/enhances/a11yEnhance';\nimport NeighborLocation from '@semcore/neighbor-location';\n\nimport style from './style/tab-line.shadow.css';\n\nconst optionsA11yEnhance = {\n onNeighborChange: (neighborElement) => {\n if (neighborElement) {\n neighborElement.focus();\n neighborElement.click();\n }\n },\n childSelector: ['role', 'tab'],\n};\n\nclass TabLineRoot extends Component {\n static displayName = 'TabLine';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n size: 'm',\n underlined: true,\n };\n static enhance = [a11yEnhance(optionsA11yEnhance)];\n state = { animation: null };\n itemRefs = {};\n containerRef = React.createRef();\n animationStartTimeout = -1;\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n componentDidUpdate(prevProps) {\n if (\n prevProps.value !== null &&\n this.props.value !== null &&\n prevProps.value !== this.props.value\n ) {\n const fromNode = this.itemRefs[prevProps.value];\n const toNode = this.itemRefs[this.props.value];\n const containerNode = this.containerRef.current;\n\n if (!fromNode || !toNode || !containerNode) return;\n const containerRect = containerNode.getBoundingClientRect();\n const fromRect = fromNode.getBoundingClientRect();\n const toRect = toNode.getBoundingClientRect();\n const animation = {\n fromLeft: fromRect.x - containerRect.x,\n fromWidth: fromRect.width,\n toLeft: toRect.x - containerRect.x,\n toWidth: toRect.width,\n started: false,\n };\n this.setState({ animation });\n clearTimeout(this.animationStartTimeout);\n this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);\n }\n }\n componentWillUnmount() {\n clearTimeout(this.animationStartTimeout);\n }\n\n handleAnimationStart = () => {\n if (this.state.animation?.started === false) {\n this.setState({ animation: { ...this.state.animation, started: true } });\n }\n };\n handleAnimationEnd = () => {\n this.setState({ animation: null });\n };\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props) {\n const { value, size } = this.asProps;\n const isSelected = value === props.value;\n return {\n size,\n selected: isSelected,\n onClick: this.bindHandlerClick(props.value),\n tabIndex: isSelected ? 0 : -1,\n 'aria-posinset': value,\n 'aria-selected': isSelected,\n ref: (node) => (this.itemRefs[props.value] = node),\n };\n }\n\n getCaretProps() {\n const { animation } = this.state;\n if (!animation) return {};\n if (animation.started) {\n return {\n style: {\n left: animation.toLeft,\n width: animation.toWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n } else {\n return {\n style: {\n left: animation.fromLeft,\n width: animation.fromWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n }\n }\n\n render() {\n const STabLine = Root;\n const SCaret = 'div';\n const { styles, Children, controlsLength } = this.asProps;\n const { animation } = this.state;\n\n return sstyled(styles)(\n <STabLine render={Box} role=\"tablist\" ref={this.containerRef}>\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n {animation && <SCaret {...this.getCaretProps()} />}\n </STabLine>,\n );\n }\n}\n\nfunction TabLineItem(props) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation } = props;\n\n return (\n <NeighborLocation.Detect neighborLocation={neighborLocation}>\n {(neighborLocation) =>\n sstyled(styles)(\n <STabLineItem\n render={Box}\n tag=\"button\"\n neighborLocation={neighborLocation}\n type=\"button\"\n role=\"tab\"\n >\n {addonLeft ? <TabLine.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabLine.Item.Text, TabLine.Item.Addon)}\n {addonRight ? <TabLine.Item.Addon tag={addonRight} /> : null}\n </STabLineItem>,\n )\n }\n </NeighborLocation.Detect>\n );\n}\n\nTabLineItem.enhance = [keyboardFocusEnhance()];\n\nfunction Text(props) {\n const { styles } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={Box} tag=\"span\" />);\n}\n\nfunction Addon(props) {\n const { styles } = props;\n const SAddon = Root;\n return sstyled(styles)(<SAddon render={Box} tag=\"span\" />);\n}\n\nconst TabLine = createComponent(TabLineRoot, {\n Item: [TabLineItem, { Text, Addon }],\n});\n\nexport default TabLine;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,kBAAkB,GAAG;EACzBC,gBAAgB,EAAE,0BAACC,eAAD,EAAqB;IACrC,IAAIA,eAAJ,EAAqB;MACnBA,eAAe,CAACC,KAAhB;MACAD,eAAe,CAACE,K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B;AACD;;AAED,SAASkB,KAAT,CAAevD,KAAf,EAAsB;EAAA;EAAA;;EACpB,IAAQqC,MAAR,GAAmBrC,KAAnB,CAAQqC,MAAR;EACA,IAAMsB,MAAM,GAC2BxB,YADvC;EACA,eAAO,IAAAK,aAAA,EAAQH,MAAR,CAAP,eAAuB,gCAAC,MAAD;IAAA,OAAyB;EAAzB,YAAvB;AACD;;AAED,IAAMe,OAAO,GAAG,IAAAQ,gBAAA,EAAgBvE,WAAhB,EAA6B;EAC3CgE,IAAI,EAAE,CAACP,WAAD,EAAc;IAAEQ,IAAI,EAAJA,IAAF;IAAQC,KAAK,EAALA;EAAR,CAAd;AADqC,CAA7B,CAAhB;eAIeH,O"}
|
|
@@ -48,17 +48,26 @@ STabLineItem {
|
|
|
48
48
|
text-decoration: none;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
&::before,
|
|
51
52
|
&::after {
|
|
52
53
|
content: '';
|
|
54
|
+
position: absolute;
|
|
53
55
|
left: 0;
|
|
56
|
+
bottom: -1px;
|
|
57
|
+
height: 3px;
|
|
54
58
|
width: 100%;
|
|
55
59
|
background-color: transparent;
|
|
56
|
-
transition: background-color 0.2s;
|
|
57
60
|
}
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
&::before {
|
|
62
|
+
transition: background-color calc(var(--intergalactic-duration-control, 200) * 1ms) ease-in-out;
|
|
63
|
+
}
|
|
64
|
+
&:hover::before {
|
|
60
65
|
background-color: var(--intergalactic-border-primary, #c4c7cf);
|
|
61
66
|
}
|
|
67
|
+
&[selected]::after {
|
|
68
|
+
transition-delay: calc(var(--intergalactic-duration-control, 200) * 1ms);
|
|
69
|
+
background-color: var(--intergalactic-border-info-active, #006dca);
|
|
70
|
+
}
|
|
62
71
|
|
|
63
72
|
& SText:not(:last-child) {
|
|
64
73
|
margin-right: var(--intergalactic-spacing-2x, 8px);
|
|
@@ -68,19 +77,12 @@ STabLineItem {
|
|
|
68
77
|
margin-right: var(--intergalactic-spacing-2x, 8px);
|
|
69
78
|
}
|
|
70
79
|
}
|
|
71
|
-
|
|
72
|
-
SIndicator,
|
|
73
|
-
STabLineItem::after {
|
|
80
|
+
SCaret {
|
|
74
81
|
position: absolute;
|
|
75
|
-
display: block;
|
|
76
82
|
bottom: -1px;
|
|
77
83
|
height: 3px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
SIndicator {
|
|
81
|
-
transition: transform calc(var(--intergalactic-duration-control, 200) * 1ms) ease-in-out;
|
|
82
84
|
background-color: var(--intergalactic-border-info-active, #006dca);
|
|
83
|
-
|
|
85
|
+
transition: calc(var(--intergalactic-duration-control, 200) * 1ms) all ease-in-out;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
STabLineItem[selected] {
|
|
@@ -134,12 +136,17 @@ STabLineItem[neighborLocation='left'] {
|
|
|
134
136
|
|
|
135
137
|
@media (prefers-reduced-motion) {
|
|
136
138
|
STabLineItem {
|
|
139
|
+
&::before,
|
|
137
140
|
&::after {
|
|
138
141
|
transition: none;
|
|
139
142
|
}
|
|
143
|
+
&[selected]::after {
|
|
144
|
+
transition-delay: 0;
|
|
145
|
+
transition: none;
|
|
146
|
+
}
|
|
140
147
|
}
|
|
141
148
|
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
SCaret {
|
|
150
|
+
display: none;
|
|
144
151
|
}
|
|
145
152
|
}
|
package/lib/es6/TabLine.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
9
9
|
import { assignProps as _assignProps4 } from "@semcore/core";
|
|
10
10
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
11
11
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
12
12
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
13
|
-
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
|
|
18
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
19
|
-
|
|
20
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
-
|
|
22
13
|
import React from 'react';
|
|
23
14
|
import createComponent, { Component, sstyled, Root } from '@semcore/core';
|
|
24
15
|
import { Box } from '@semcore/flex-box';
|
|
@@ -26,30 +17,29 @@ import addonTextChildren from '@semcore/utils/lib/addonTextChildren';
|
|
|
26
17
|
import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
27
18
|
import a11yEnhance from '@semcore/utils/lib/enhances/a11yEnhance';
|
|
28
19
|
import NeighborLocation from '@semcore/neighbor-location';
|
|
29
|
-
import ResizeObserver from 'resize-observer-polyfill';
|
|
30
20
|
|
|
31
21
|
/*__reshadow-styles__:"./style/tab-line.shadow.css"*/
|
|
32
22
|
var style = (
|
|
33
23
|
/*__reshadow_css_start__*/
|
|
34
24
|
_sstyled.insert(
|
|
35
25
|
/*__inner_css_start__*/
|
|
36
|
-
".
|
|
26
|
+
".___STabLine_14v3w_gg_{position:relative;display:flex;width:100%;max-width:100%}.___STabLine_14v3w_gg_.__underlined_14v3w_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___STabLineItem_14v3w_gg_{display:inline-flex;align-items:center;justify-content:center;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;outline:0;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;border:0;background:0 0;color:var(--intergalactic-text-primary, #191b23);margin-right:var(--intergalactic-spacing-4x, 16px);font-weight:var(--intergalactic-medium, 500)}.___STabLineItem_14v3w_gg_::-moz-focus-inner{border:0;padding:0}.___STabLineItem_14v3w_gg_:active,.___STabLineItem_14v3w_gg_:focus{outline:0;text-decoration:none}@media (hover:hover){.___STabLineItem_14v3w_gg_:hover{outline:0;text-decoration:none}}.___STabLineItem_14v3w_gg_::after,.___STabLineItem_14v3w_gg_::before{content:\"\";position:absolute;left:0;bottom:-1px;height:3px;width:100%;background-color:transparent}.___STabLineItem_14v3w_gg_::before{transition:background-color calc(var(--intergalactic-duration-control, 200)*1ms) ease-in-out}@media (hover:hover){.___STabLineItem_14v3w_gg_:hover::before{background-color:var(--intergalactic-border-primary, #c4c7cf)}}.___STabLineItem_14v3w_gg_.__selected_14v3w_gg_::after{transition-delay:calc(var(--intergalactic-duration-control, 200)*1ms);background-color:var(--intergalactic-border-info-active, #006dca)}.___STabLineItem_14v3w_gg_ .___SAddon_14v3w_gg_:not(:last-child),.___STabLineItem_14v3w_gg_ .___SText_14v3w_gg_:not(:last-child){margin-right:var(--intergalactic-spacing-2x, 8px)}.___SCaret_14v3w_gg_{position:absolute;bottom:-1px;height:3px;background-color:var(--intergalactic-border-info-active, #006dca);transition:calc(var(--intergalactic-duration-control, 200)*1ms) all ease-in-out}.___STabLineItem_14v3w_gg_.__selected_14v3w_gg_{flex-shrink:0}.___STabLineItem_14v3w_gg_.__disabled_14v3w_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___STabLineItem_14v3w_gg_.__keyboardFocused_14v3w_gg_{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.3))}.___SText_14v3w_gg_{display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___SAddon_14v3w_gg_{display:inline-flex;align-items:center;justify-content:center}.___STabLineItem_14v3w_gg_._size_m_14v3w_gg_{height:28px;min-width:18px}.___STabLineItem_14v3w_gg_._size_m_14v3w_gg_ .___SText_14v3w_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___STabLineItem_14v3w_gg_._size_l_14v3w_gg_{height:40px;min-width:26px}.___STabLineItem_14v3w_gg_._size_l_14v3w_gg_ .___SText_14v3w_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___STabLineItem_14v3w_gg_._neighborLocation_left_14v3w_gg_{margin-right:0}@media (prefers-reduced-motion){.___STabLineItem_14v3w_gg_::after,.___STabLineItem_14v3w_gg_::before{transition:none}.___STabLineItem_14v3w_gg_.__selected_14v3w_gg_::after{transition-delay:0;transition:none}.___SCaret_14v3w_gg_{display:none}}"
|
|
37
27
|
/*__inner_css_end__*/
|
|
38
|
-
, "
|
|
28
|
+
, "14v3w_gg_")
|
|
39
29
|
/*__reshadow_css_end__*/
|
|
40
30
|
, {
|
|
41
|
-
"__STabLine": "
|
|
42
|
-
"_underlined": "
|
|
43
|
-
"__STabLineItem": "
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"_disabled": "
|
|
49
|
-
"_keyboardFocused": "
|
|
50
|
-
"_size_m": "
|
|
51
|
-
"_size_l": "
|
|
52
|
-
"_neighborLocation_left": "
|
|
31
|
+
"__STabLine": "___STabLine_14v3w_gg_",
|
|
32
|
+
"_underlined": "__underlined_14v3w_gg_",
|
|
33
|
+
"__STabLineItem": "___STabLineItem_14v3w_gg_",
|
|
34
|
+
"_selected": "__selected_14v3w_gg_",
|
|
35
|
+
"__SText": "___SText_14v3w_gg_",
|
|
36
|
+
"__SAddon": "___SAddon_14v3w_gg_",
|
|
37
|
+
"__SCaret": "___SCaret_14v3w_gg_",
|
|
38
|
+
"_disabled": "__disabled_14v3w_gg_",
|
|
39
|
+
"_keyboardFocused": "__keyboardFocused_14v3w_gg_",
|
|
40
|
+
"_size_m": "_size_m_14v3w_gg_",
|
|
41
|
+
"_size_l": "_size_l_14v3w_gg_",
|
|
42
|
+
"_neighborLocation_left": "_neighborLocation_left_14v3w_gg_"
|
|
53
43
|
});
|
|
54
44
|
var optionsA11yEnhance = {
|
|
55
45
|
onNeighborChange: function onNeighborChange(neighborElement) {
|
|
@@ -66,47 +56,51 @@ var TabLineRoot = /*#__PURE__*/function (_Component) {
|
|
|
66
56
|
|
|
67
57
|
var _super = _createSuper(TabLineRoot);
|
|
68
58
|
|
|
69
|
-
function TabLineRoot(
|
|
59
|
+
function TabLineRoot() {
|
|
70
60
|
var _this;
|
|
71
61
|
|
|
72
62
|
_classCallCheck(this, TabLineRoot);
|
|
73
63
|
|
|
74
|
-
|
|
64
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
65
|
+
args[_key] = arguments[_key];
|
|
66
|
+
}
|
|
75
67
|
|
|
76
|
-
|
|
68
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
77
69
|
|
|
78
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
70
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
71
|
+
animation: null
|
|
72
|
+
});
|
|
79
73
|
|
|
80
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
74
|
+
_defineProperty(_assertThisInitialized(_this), "itemRefs", {});
|
|
81
75
|
|
|
82
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
76
|
+
_defineProperty(_assertThisInitialized(_this), "containerRef", /*#__PURE__*/React.createRef());
|
|
83
77
|
|
|
84
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
_defineProperty(_assertThisInitialized(_this), "animationStartTimeout", -1);
|
|
79
|
+
|
|
80
|
+
_defineProperty(_assertThisInitialized(_this), "handleAnimationStart", function () {
|
|
81
|
+
var _this$state$animation;
|
|
82
|
+
|
|
83
|
+
if (((_this$state$animation = _this.state.animation) === null || _this$state$animation === void 0 ? void 0 : _this$state$animation.started) === false) {
|
|
84
|
+
_this.setState({
|
|
85
|
+
animation: _objectSpread(_objectSpread({}, _this.state.animation), {}, {
|
|
86
|
+
started: true
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
88
90
|
});
|
|
89
91
|
|
|
90
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!indicator || !tabsParent) return false;
|
|
94
|
-
var tab = Array.from(tabsParent.querySelectorAll('[data-ui-name="TabLine.Item"]')).find(function (node) {
|
|
95
|
-
return node.getAttribute('value') === String(_this.asProps.value);
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "handleAnimationEnd", function () {
|
|
93
|
+
_this.setState({
|
|
94
|
+
animation: null
|
|
96
95
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
_this.$observerTab.observe(tab);
|
|
96
|
+
});
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
indicator.style.width = "".concat(offsetWidth, "px");
|
|
98
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerClick", function (value) {
|
|
99
|
+
return function (e) {
|
|
100
|
+
_this.handlers.value(value, e);
|
|
101
|
+
};
|
|
106
102
|
});
|
|
107
103
|
|
|
108
|
-
_this.$observer = new ResizeObserver(_this.calculateStylesIndicator);
|
|
109
|
-
_this.$observerTab = new ResizeObserver(_this.calculateStylesIndicator);
|
|
110
104
|
return _this;
|
|
111
105
|
}
|
|
112
106
|
|
|
@@ -117,30 +111,41 @@ var TabLineRoot = /*#__PURE__*/function (_Component) {
|
|
|
117
111
|
value: null
|
|
118
112
|
};
|
|
119
113
|
}
|
|
120
|
-
}, {
|
|
121
|
-
key: "componentDidMount",
|
|
122
|
-
value: function componentDidMount() {
|
|
123
|
-
if (this.$tabsParent.current) {
|
|
124
|
-
this.$observer.observe(this.$tabsParent.current);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
this.calculateStylesIndicator();
|
|
128
|
-
}
|
|
129
114
|
}, {
|
|
130
115
|
key: "componentDidUpdate",
|
|
131
|
-
value: function componentDidUpdate() {
|
|
132
|
-
this
|
|
133
|
-
|
|
116
|
+
value: function componentDidUpdate(prevProps) {
|
|
117
|
+
if (prevProps.value !== null && this.props.value !== null && prevProps.value !== this.props.value) {
|
|
118
|
+
var fromNode = this.itemRefs[prevProps.value];
|
|
119
|
+
var toNode = this.itemRefs[this.props.value];
|
|
120
|
+
var containerNode = this.containerRef.current;
|
|
121
|
+
if (!fromNode || !toNode || !containerNode) return;
|
|
122
|
+
var containerRect = containerNode.getBoundingClientRect();
|
|
123
|
+
var fromRect = fromNode.getBoundingClientRect();
|
|
124
|
+
var toRect = toNode.getBoundingClientRect();
|
|
125
|
+
var animation = {
|
|
126
|
+
fromLeft: fromRect.x - containerRect.x,
|
|
127
|
+
fromWidth: fromRect.width,
|
|
128
|
+
toLeft: toRect.x - containerRect.x,
|
|
129
|
+
toWidth: toRect.width,
|
|
130
|
+
started: false
|
|
131
|
+
};
|
|
132
|
+
this.setState({
|
|
133
|
+
animation: animation
|
|
134
|
+
});
|
|
135
|
+
clearTimeout(this.animationStartTimeout);
|
|
136
|
+
this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);
|
|
137
|
+
}
|
|
134
138
|
}
|
|
135
139
|
}, {
|
|
136
140
|
key: "componentWillUnmount",
|
|
137
141
|
value: function componentWillUnmount() {
|
|
138
|
-
this
|
|
139
|
-
this.$observerTab.disconnect();
|
|
142
|
+
clearTimeout(this.animationStartTimeout);
|
|
140
143
|
}
|
|
141
144
|
}, {
|
|
142
145
|
key: "getItemProps",
|
|
143
146
|
value: function getItemProps(props) {
|
|
147
|
+
var _this2 = this;
|
|
148
|
+
|
|
144
149
|
var _this$asProps = this.asProps,
|
|
145
150
|
value = _this$asProps.value,
|
|
146
151
|
size = _this$asProps.size;
|
|
@@ -151,9 +156,36 @@ var TabLineRoot = /*#__PURE__*/function (_Component) {
|
|
|
151
156
|
onClick: this.bindHandlerClick(props.value),
|
|
152
157
|
tabIndex: isSelected ? 0 : -1,
|
|
153
158
|
'aria-posinset': value,
|
|
154
|
-
'aria-selected': isSelected
|
|
159
|
+
'aria-selected': isSelected,
|
|
160
|
+
ref: function ref(node) {
|
|
161
|
+
return _this2.itemRefs[props.value] = node;
|
|
162
|
+
}
|
|
155
163
|
};
|
|
156
164
|
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "getCaretProps",
|
|
167
|
+
value: function getCaretProps() {
|
|
168
|
+
var animation = this.state.animation;
|
|
169
|
+
if (!animation) return {};
|
|
170
|
+
|
|
171
|
+
if (animation.started) {
|
|
172
|
+
return {
|
|
173
|
+
style: {
|
|
174
|
+
left: animation.toLeft,
|
|
175
|
+
width: animation.toWidth
|
|
176
|
+
},
|
|
177
|
+
onTransitionEnd: this.handleAnimationEnd
|
|
178
|
+
};
|
|
179
|
+
} else {
|
|
180
|
+
return {
|
|
181
|
+
style: {
|
|
182
|
+
left: animation.fromLeft,
|
|
183
|
+
width: animation.fromWidth
|
|
184
|
+
},
|
|
185
|
+
onTransitionEnd: this.handleAnimationEnd
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
157
189
|
}, {
|
|
158
190
|
key: "render",
|
|
159
191
|
value: function render() {
|
|
@@ -161,19 +193,18 @@ var TabLineRoot = /*#__PURE__*/function (_Component) {
|
|
|
161
193
|
_ref5;
|
|
162
194
|
|
|
163
195
|
var STabLine = Box;
|
|
164
|
-
var
|
|
196
|
+
var SCaret = 'div';
|
|
165
197
|
var _this$asProps2 = this.asProps,
|
|
166
198
|
styles = _this$asProps2.styles,
|
|
167
199
|
Children = _this$asProps2.Children,
|
|
168
200
|
controlsLength = _this$asProps2.controlsLength;
|
|
201
|
+
var animation = this.state.animation;
|
|
169
202
|
return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(STabLine, _ref5.cn("STabLine", _objectSpread({}, _assignProps({
|
|
170
|
-
"
|
|
171
|
-
"
|
|
203
|
+
"role": "tablist",
|
|
204
|
+
"ref": this.containerRef
|
|
172
205
|
}, _ref))), /*#__PURE__*/React.createElement(NeighborLocation, _ref5.cn("NeighborLocation", {
|
|
173
206
|
"controlsLength": controlsLength
|
|
174
|
-
}), /*#__PURE__*/React.createElement(Children, _ref5.cn("Children", {}))), /*#__PURE__*/React.createElement(
|
|
175
|
-
"ref": this.$indicator
|
|
176
|
-
})));
|
|
207
|
+
}), /*#__PURE__*/React.createElement(Children, _ref5.cn("Children", {}))), animation && /*#__PURE__*/React.createElement(SCaret, _ref5.cn("SCaret", _objectSpread({}, this.getCaretProps()))));
|
|
177
208
|
}
|
|
178
209
|
}]);
|
|
179
210
|
|
package/lib/es6/TabLine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabLine.js","names":["React","createComponent","Component","sstyled","Root","Box","addonTextChildren","keyboardFocusEnhance","a11yEnhance","NeighborLocation","ResizeObserver","optionsA11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","TabLineRoot","props","createRef","value","e","handlers","indicator","$indicator","current","tabsParent","$tabsParent","tab","Array","from","querySelectorAll","find","node","getAttribute","String","asProps","$observerTab","observe","offsetLeft","offsetWidth","positionLeftParent","clientLeft","parseInt","style","paddingLeft","transform","width","$observer","calculateStylesIndicator","disconnect","size","isSelected","selected","onClick","bindHandlerClick","tabIndex","STabLine","SIndicator","styles","Children","controlsLength","defaultValue","underlined","TabLineItem","STabLineItem","addonLeft","addonRight","neighborLocation","TabLine","Item","Text","Addon","enhance","SText","SAddon"],"sources":["../../src/TabLine.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport a11yEnhance from '@semcore/utils/lib/enhances/a11yEnhance';\nimport NeighborLocation from '@semcore/neighbor-location';\nimport ResizeObserver from 'resize-observer-polyfill';\n\nimport style from './style/tab-line.shadow.css';\n\nconst optionsA11yEnhance = {\n onNeighborChange: (neighborElement) => {\n if (neighborElement) {\n neighborElement.focus();\n neighborElement.click();\n }\n },\n childSelector: ['role', 'tab'],\n};\n\nclass TabLineRoot extends Component {\n static displayName = 'TabLine';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n size: 'm',\n underlined: true,\n };\n static enhance = [a11yEnhance(optionsA11yEnhance)];\n\n $observer;\n $observerTab;\n $indicator = React.createRef();\n $tabsParent = React.createRef();\n\n constructor(props) {\n super(props);\n this.$observer = new ResizeObserver(this.calculateStylesIndicator);\n this.$observerTab = new ResizeObserver(this.calculateStylesIndicator);\n }\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n calculateStylesIndicator = () => {\n const indicator = this.$indicator.current;\n const tabsParent = this.$tabsParent.current;\n if (!indicator || !tabsParent) return false;\n const tab = Array.from(tabsParent.querySelectorAll('[data-ui-name=\"TabLine.Item\"]')).find(\n (node) => node.getAttribute('value') === String(this.asProps.value),\n );\n if (!tab) return false;\n this.$observerTab.observe(tab);\n const { offsetLeft, offsetWidth } = tab;\n const positionLeftParent =\n tabsParent.clientLeft + parseInt(tabsParent.style.paddingLeft, 10) || 0;\n indicator.style.transform = `translateX(${offsetLeft - positionLeftParent}px)`;\n indicator.style.width = `${offsetWidth}px`;\n };\n\n componentDidMount() {\n if (this.$tabsParent.current) {\n this.$observer.observe(this.$tabsParent.current);\n }\n this.calculateStylesIndicator();\n }\n\n componentDidUpdate() {\n this.$observerTab.disconnect();\n this.calculateStylesIndicator();\n }\n\n componentWillUnmount() {\n this.$observer.disconnect();\n this.$observerTab.disconnect();\n }\n\n getItemProps(props) {\n const { value, size } = this.asProps;\n const isSelected = value === props.value;\n return {\n size,\n selected: isSelected,\n onClick: this.bindHandlerClick(props.value),\n tabIndex: isSelected ? 0 : -1,\n 'aria-posinset': value,\n 'aria-selected': isSelected,\n };\n }\n\n render() {\n const STabLine = Root;\n const SIndicator = 'div';\n const { styles, Children, controlsLength } = this.asProps;\n\n return sstyled(styles)(\n <STabLine render={Box} ref={this.$tabsParent} role=\"tablist\">\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n <SIndicator ref={this.$indicator} />\n </STabLine>,\n );\n }\n}\n\nfunction TabLineItem(props) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation } = props;\n\n return (\n <NeighborLocation.Detect neighborLocation={neighborLocation}>\n {(neighborLocation) =>\n sstyled(styles)(\n <STabLineItem\n render={Box}\n tag=\"button\"\n neighborLocation={neighborLocation}\n type=\"button\"\n role=\"tab\"\n >\n {addonLeft ? <TabLine.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabLine.Item.Text, TabLine.Item.Addon)}\n {addonRight ? <TabLine.Item.Addon tag={addonRight} /> : null}\n </STabLineItem>,\n )\n }\n </NeighborLocation.Detect>\n );\n}\n\nTabLineItem.enhance = [keyboardFocusEnhance()];\n\nfunction Text(props) {\n const { styles } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={Box} tag=\"span\" />);\n}\n\nfunction Addon(props) {\n const { styles } = props;\n const SAddon = Root;\n return sstyled(styles)(<SAddon render={Box} tag=\"span\" />);\n}\n\nconst TabLine = createComponent(TabLineRoot, {\n Item: [TabLineItem, { Text, Addon }],\n});\n\nexport default TabLine;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,eAAP,IAA0BC,SAA1B,EAAqCC,OAArC,EAA8CC,IAA9C,QAA0D,eAA1D;AACA,SAASC,GAAT,QAAoB,mBAApB;AACA,OAAOC,iBAAP,MAA8B,sCAA9B;AACA,OAAOC,oBAAP,MAAiC,kDAAjC;AACA,OAAOC,WAAP,MAAwB,yCAAxB;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,cAAP,MAA2B,0BAA3B;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMC,kBAAkB,GAAG;EACzBC,gBAAgB,EAAE,0BAACC,eAAD,EAAqB;IACrC,IAAIA,eAAJ,EAAqB;MACnBA,eAAe,CAACC,KAAhB;MACAD,eAAe,CAACE,KAAhB;IACD;EACF,CANwB;EAOzBC,aAAa,EAAE,CAAC,MAAD,EAAS,KAAT;AAPU,CAA3B;;IAUMC,W;;;;;EAeJ,qBAAYC,KAAZ,EAAmB;IAAA;;IAAA;;IACjB,0BAA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AD,CAAS,IAAT,CAAc,KAAd;MAAoB,GAAG,EAAEA;IAAzB,EAAH,GAA6C,IAT1D,CAFH;EAAA,CADH,CADF;AAmBD;;AAEDH,WAAW,CAACS,OAAZ,GAAsB,CAAClE,oBAAoB,EAArB,CAAtB;;AAEA,SAASgE,IAAT,CAAcrD,KAAd,EAAqB;EAAA;EAAA;;EACnB,IAAQyC,MAAR,GAAmBzC,KAAnB,CAAQyC,MAAR;EACA,IAAMe,KAAK,GAC2BrE,GADtC;EACA,eAAOF,OAAO,CAACwD,MAAD,CAAd,eAAuB,oBAAC,KAAD;IAAA,OAAwB;EAAxB,YAAvB;AACD;;AAED,SAASa,KAAT,CAAetD,KAAf,EAAsB;EAAA;EAAA;;EACpB,IAAQyC,MAAR,GAAmBzC,KAAnB,CAAQyC,MAAR;EACA,IAAMgB,MAAM,GAC2BtE,GADvC;EACA,eAAOF,OAAO,CAACwD,MAAD,CAAd,eAAuB,oBAAC,MAAD;IAAA,OAAyB;EAAzB,YAAvB;AACD;;AAED,IAAMU,OAAO,GAAGpE,eAAe,CAACgB,WAAD,EAAc;EAC3CqD,IAAI,EAAE,CAACN,WAAD,EAAc;IAAEO,IAAI,EAAJA,IAAF;IAAQC,KAAK,EAALA;EAAR,CAAd;AADqC,CAAd,CAA/B;AAIA,eAAeH,OAAf"}
|
|
1
|
+
{"version":3,"file":"TabLine.js","names":["React","createComponent","Component","sstyled","Root","Box","addonTextChildren","keyboardFocusEnhance","a11yEnhance","NeighborLocation","optionsA11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","TabLineRoot","animation","createRef","state","started","setState","value","e","handlers","prevProps","props","fromNode","itemRefs","toNode","containerNode","containerRef","current","containerRect","getBoundingClientRect","fromRect","toRect","fromLeft","x","fromWidth","width","toLeft","toWidth","clearTimeout","animationStartTimeout","setTimeout","handleAnimationStart","asProps","size","isSelected","selected","onClick","bindHandlerClick","tabIndex","ref","node","style","left","onTransitionEnd","handleAnimationEnd","STabLine","SCaret","styles","Children","controlsLength","getCaretProps","defaultValue","underlined","TabLineItem","STabLineItem","addonLeft","addonRight","neighborLocation","TabLine","Item","Text","Addon","enhance","SText","SAddon"],"sources":["../../src/TabLine.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport a11yEnhance from '@semcore/utils/lib/enhances/a11yEnhance';\nimport NeighborLocation from '@semcore/neighbor-location';\n\nimport style from './style/tab-line.shadow.css';\n\nconst optionsA11yEnhance = {\n onNeighborChange: (neighborElement) => {\n if (neighborElement) {\n neighborElement.focus();\n neighborElement.click();\n }\n },\n childSelector: ['role', 'tab'],\n};\n\nclass TabLineRoot extends Component {\n static displayName = 'TabLine';\n static style = style;\n static defaultProps = {\n defaultValue: null,\n size: 'm',\n underlined: true,\n };\n static enhance = [a11yEnhance(optionsA11yEnhance)];\n state = { animation: null };\n itemRefs = {};\n containerRef = React.createRef();\n animationStartTimeout = -1;\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n componentDidUpdate(prevProps) {\n if (\n prevProps.value !== null &&\n this.props.value !== null &&\n prevProps.value !== this.props.value\n ) {\n const fromNode = this.itemRefs[prevProps.value];\n const toNode = this.itemRefs[this.props.value];\n const containerNode = this.containerRef.current;\n\n if (!fromNode || !toNode || !containerNode) return;\n const containerRect = containerNode.getBoundingClientRect();\n const fromRect = fromNode.getBoundingClientRect();\n const toRect = toNode.getBoundingClientRect();\n const animation = {\n fromLeft: fromRect.x - containerRect.x,\n fromWidth: fromRect.width,\n toLeft: toRect.x - containerRect.x,\n toWidth: toRect.width,\n started: false,\n };\n this.setState({ animation });\n clearTimeout(this.animationStartTimeout);\n this.animationStartTimeout = setTimeout(this.handleAnimationStart, 0);\n }\n }\n componentWillUnmount() {\n clearTimeout(this.animationStartTimeout);\n }\n\n handleAnimationStart = () => {\n if (this.state.animation?.started === false) {\n this.setState({ animation: { ...this.state.animation, started: true } });\n }\n };\n handleAnimationEnd = () => {\n this.setState({ animation: null });\n };\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props) {\n const { value, size } = this.asProps;\n const isSelected = value === props.value;\n return {\n size,\n selected: isSelected,\n onClick: this.bindHandlerClick(props.value),\n tabIndex: isSelected ? 0 : -1,\n 'aria-posinset': value,\n 'aria-selected': isSelected,\n ref: (node) => (this.itemRefs[props.value] = node),\n };\n }\n\n getCaretProps() {\n const { animation } = this.state;\n if (!animation) return {};\n if (animation.started) {\n return {\n style: {\n left: animation.toLeft,\n width: animation.toWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n } else {\n return {\n style: {\n left: animation.fromLeft,\n width: animation.fromWidth,\n },\n onTransitionEnd: this.handleAnimationEnd,\n };\n }\n }\n\n render() {\n const STabLine = Root;\n const SCaret = 'div';\n const { styles, Children, controlsLength } = this.asProps;\n const { animation } = this.state;\n\n return sstyled(styles)(\n <STabLine render={Box} role=\"tablist\" ref={this.containerRef}>\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n {animation && <SCaret {...this.getCaretProps()} />}\n </STabLine>,\n );\n }\n}\n\nfunction TabLineItem(props) {\n const STabLineItem = Root;\n const { Children, styles, addonLeft, addonRight, neighborLocation } = props;\n\n return (\n <NeighborLocation.Detect neighborLocation={neighborLocation}>\n {(neighborLocation) =>\n sstyled(styles)(\n <STabLineItem\n render={Box}\n tag=\"button\"\n neighborLocation={neighborLocation}\n type=\"button\"\n role=\"tab\"\n >\n {addonLeft ? <TabLine.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, TabLine.Item.Text, TabLine.Item.Addon)}\n {addonRight ? <TabLine.Item.Addon tag={addonRight} /> : null}\n </STabLineItem>,\n )\n }\n </NeighborLocation.Detect>\n );\n}\n\nTabLineItem.enhance = [keyboardFocusEnhance()];\n\nfunction Text(props) {\n const { styles } = props;\n const SText = Root;\n return sstyled(styles)(<SText render={Box} tag=\"span\" />);\n}\n\nfunction Addon(props) {\n const { styles } = props;\n const SAddon = Root;\n return sstyled(styles)(<SAddon render={Box} tag=\"span\" />);\n}\n\nconst TabLine = createComponent(TabLineRoot, {\n Item: [TabLineItem, { Text, Addon }],\n});\n\nexport default TabLine;\n"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,eAAP,IAA0BC,SAA1B,EAAqCC,OAArC,EAA8CC,IAA9C,QAA0D,eAA1D;AACA,SAASC,GAAT,QAAoB,mBAApB;AACA,OAAOC,iBAAP,MAA8B,sCAA9B;AACA,OAAOC,oBAAP,MAAiC,kDAAjC;AACA,OAAOC,WAAP,MAAwB,yCAAxB;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMC,kBAAkB,GAAG;EACzBC,gBAAgB,EAAE,0BAACC,eAAD,EAAqB;IACrC,IAAIA,eAAJ,EAAqB;MACnBA,eAAe,CAACC,KAAhB;MACAD,eAAe,CAACE,KAAhB;IACD;EACF,CANwB;EAOzBC,aAAa,EAAE,CAAC,MAAD,EAAS,KAAT;AAPU,CAA3B;;IAUMC,W;;;;;;;;;;;;;;;;4DASI;MAAEC,SAAS,EAAE;IAAb,C;;+DACG,E;;gFACIjB,KAAK,CAACkB,SAAN,E;;4EACS,CAAC,C;;2EAsCF,YAAM;MAAA;;MAC3B,IAAI,gCAAKC,KAAL,CAAWF,SAAX,gFAAsBG,OAAtB,MAAkC,KAAtC,EAA6C;QAC3C,MAAKC,QAAL,CAAc;UAAEJ,SAAS,kCAAO,MAAKE,KAAL,CAAWF,SAAlB;YAA6BG,OAAO,EAAE;UAAtC;QAAX,CAAd;MACD;IACF,C;;yEACoB,YAAM;MACzB,MAAKC,QAAL,CAAc;QAAEJ,SAAS,EAAE;MAAb,CAAd;IACD,C;;uEAEk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::before,
|
|
51
52
|
&::after {
|
|
52
53
|
content: '';
|
|
54
|
+
position: absolute;
|
|
53
55
|
left: 0;
|
|
56
|
+
bottom: -1px;
|
|
57
|
+
height: 3px;
|
|
54
58
|
width: 100%;
|
|
55
59
|
background-color: transparent;
|
|
56
|
-
transition: background-color 0.2s;
|
|
57
60
|
}
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
&::before {
|
|
62
|
+
transition: background-color calc(var(--intergalactic-duration-control, 200) * 1ms) ease-in-out;
|
|
63
|
+
}
|
|
64
|
+
&:hover::before {
|
|
60
65
|
background-color: var(--intergalactic-border-primary, #c4c7cf);
|
|
61
66
|
}
|
|
67
|
+
&[selected]::after {
|
|
68
|
+
transition-delay: calc(var(--intergalactic-duration-control, 200) * 1ms);
|
|
69
|
+
background-color: var(--intergalactic-border-info-active, #006dca);
|
|
70
|
+
}
|
|
62
71
|
|
|
63
72
|
& SText:not(:last-child) {
|
|
64
73
|
margin-right: var(--intergalactic-spacing-2x, 8px);
|
|
@@ -68,19 +77,12 @@ STabLineItem {
|
|
|
68
77
|
margin-right: var(--intergalactic-spacing-2x, 8px);
|
|
69
78
|
}
|
|
70
79
|
}
|
|
71
|
-
|
|
72
|
-
SIndicator,
|
|
73
|
-
STabLineItem::after {
|
|
80
|
+
SCaret {
|
|
74
81
|
position: absolute;
|
|
75
|
-
display: block;
|
|
76
82
|
bottom: -1px;
|
|
77
83
|
height: 3px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
SIndicator {
|
|
81
|
-
transition: transform calc(var(--intergalactic-duration-control, 200) * 1ms) ease-in-out;
|
|
82
84
|
background-color: var(--intergalactic-border-info-active, #006dca);
|
|
83
|
-
|
|
85
|
+
transition: calc(var(--intergalactic-duration-control, 200) * 1ms) all ease-in-out;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
STabLineItem[selected] {
|
|
@@ -134,12 +136,17 @@ STabLineItem[neighborLocation='left'] {
|
|
|
134
136
|
|
|
135
137
|
@media (prefers-reduced-motion) {
|
|
136
138
|
STabLineItem {
|
|
139
|
+
&::before,
|
|
137
140
|
&::after {
|
|
138
141
|
transition: none;
|
|
139
142
|
}
|
|
143
|
+
&[selected]::after {
|
|
144
|
+
transition-delay: 0;
|
|
145
|
+
transition: none;
|
|
146
|
+
}
|
|
140
147
|
}
|
|
141
148
|
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
SCaret {
|
|
150
|
+
display: none;
|
|
144
151
|
}
|
|
145
152
|
}
|