@targetprocess/tabs 12.18.0 → 12.18.2-alpha.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/ShowMore.jsx +21 -19
- package/Tabs.jsx +15 -2
- package/dist/tabs.es.js +162 -249
- package/dist/tabs.js +162 -249
- package/package.json +4 -4
- package/style/index.css +15 -0
package/dist/tabs.js
CHANGED
|
@@ -12,29 +12,57 @@ var icons = require('@targetprocess/icons');
|
|
|
12
12
|
var button = require('@targetprocess/button');
|
|
13
13
|
var Popover = _interopDefault(require('@targetprocess/popover'));
|
|
14
14
|
|
|
15
|
+
function _iterableToArrayLimit(r, l) {
|
|
16
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
17
|
+
if (null != t) {
|
|
18
|
+
var e,
|
|
19
|
+
n,
|
|
20
|
+
i,
|
|
21
|
+
u,
|
|
22
|
+
a = [],
|
|
23
|
+
f = !0,
|
|
24
|
+
o = !1;
|
|
25
|
+
try {
|
|
26
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
27
|
+
if (Object(t) !== t) return;
|
|
28
|
+
f = !1;
|
|
29
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
30
|
+
} catch (r) {
|
|
31
|
+
o = !0, n = r;
|
|
32
|
+
} finally {
|
|
33
|
+
try {
|
|
34
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
35
|
+
} finally {
|
|
36
|
+
if (o) throw n;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return a;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
15
42
|
function _classCallCheck(instance, Constructor) {
|
|
16
43
|
if (!(instance instanceof Constructor)) {
|
|
17
44
|
throw new TypeError("Cannot call a class as a function");
|
|
18
45
|
}
|
|
19
46
|
}
|
|
20
|
-
|
|
21
47
|
function _defineProperties(target, props) {
|
|
22
48
|
for (var i = 0; i < props.length; i++) {
|
|
23
49
|
var descriptor = props[i];
|
|
24
50
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
25
51
|
descriptor.configurable = true;
|
|
26
52
|
if ("value" in descriptor) descriptor.writable = true;
|
|
27
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
53
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
28
54
|
}
|
|
29
55
|
}
|
|
30
|
-
|
|
31
56
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
32
57
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
33
58
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
59
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
60
|
+
writable: false
|
|
61
|
+
});
|
|
34
62
|
return Constructor;
|
|
35
63
|
}
|
|
36
|
-
|
|
37
64
|
function _defineProperty(obj, key, value) {
|
|
65
|
+
key = _toPropertyKey(key);
|
|
38
66
|
if (key in obj) {
|
|
39
67
|
Object.defineProperty(obj, key, {
|
|
40
68
|
value: value,
|
|
@@ -45,33 +73,26 @@ function _defineProperty(obj, key, value) {
|
|
|
45
73
|
} else {
|
|
46
74
|
obj[key] = value;
|
|
47
75
|
}
|
|
48
|
-
|
|
49
76
|
return obj;
|
|
50
77
|
}
|
|
51
|
-
|
|
52
78
|
function _extends() {
|
|
53
|
-
_extends = Object.assign
|
|
79
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
54
80
|
for (var i = 1; i < arguments.length; i++) {
|
|
55
81
|
var source = arguments[i];
|
|
56
|
-
|
|
57
82
|
for (var key in source) {
|
|
58
83
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
59
84
|
target[key] = source[key];
|
|
60
85
|
}
|
|
61
86
|
}
|
|
62
87
|
}
|
|
63
|
-
|
|
64
88
|
return target;
|
|
65
89
|
};
|
|
66
|
-
|
|
67
90
|
return _extends.apply(this, arguments);
|
|
68
91
|
}
|
|
69
|
-
|
|
70
92
|
function _inherits(subClass, superClass) {
|
|
71
93
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
72
94
|
throw new TypeError("Super expression must either be null or a function");
|
|
73
95
|
}
|
|
74
|
-
|
|
75
96
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
76
97
|
constructor: {
|
|
77
98
|
value: subClass,
|
|
@@ -79,77 +100,73 @@ function _inherits(subClass, superClass) {
|
|
|
79
100
|
configurable: true
|
|
80
101
|
}
|
|
81
102
|
});
|
|
103
|
+
Object.defineProperty(subClass, "prototype", {
|
|
104
|
+
writable: false
|
|
105
|
+
});
|
|
82
106
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
83
107
|
}
|
|
84
|
-
|
|
85
108
|
function _getPrototypeOf(o) {
|
|
86
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
109
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
87
110
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
88
111
|
};
|
|
89
112
|
return _getPrototypeOf(o);
|
|
90
113
|
}
|
|
91
|
-
|
|
92
114
|
function _setPrototypeOf(o, p) {
|
|
93
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
115
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
94
116
|
o.__proto__ = p;
|
|
95
117
|
return o;
|
|
96
118
|
};
|
|
97
|
-
|
|
98
119
|
return _setPrototypeOf(o, p);
|
|
99
120
|
}
|
|
100
|
-
|
|
101
121
|
function _assertThisInitialized(self) {
|
|
102
122
|
if (self === void 0) {
|
|
103
123
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
104
124
|
}
|
|
105
|
-
|
|
106
125
|
return self;
|
|
107
126
|
}
|
|
108
|
-
|
|
109
127
|
function _possibleConstructorReturn(self, call) {
|
|
110
128
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
111
129
|
return call;
|
|
130
|
+
} else if (call !== void 0) {
|
|
131
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
112
132
|
}
|
|
113
|
-
|
|
114
133
|
return _assertThisInitialized(self);
|
|
115
134
|
}
|
|
116
|
-
|
|
117
135
|
function _slicedToArray(arr, i) {
|
|
118
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
|
136
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
119
137
|
}
|
|
120
|
-
|
|
121
138
|
function _arrayWithHoles(arr) {
|
|
122
139
|
if (Array.isArray(arr)) return arr;
|
|
123
140
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
} catch (err) {
|
|
138
|
-
_d = true;
|
|
139
|
-
_e = err;
|
|
140
|
-
} finally {
|
|
141
|
-
try {
|
|
142
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
143
|
-
} finally {
|
|
144
|
-
if (_d) throw _e;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return _arr;
|
|
141
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
142
|
+
if (!o) return;
|
|
143
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
144
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
145
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
146
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
147
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
148
|
+
}
|
|
149
|
+
function _arrayLikeToArray(arr, len) {
|
|
150
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
151
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
152
|
+
return arr2;
|
|
149
153
|
}
|
|
150
|
-
|
|
151
154
|
function _nonIterableRest() {
|
|
152
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
155
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
156
|
+
}
|
|
157
|
+
function _toPrimitive(input, hint) {
|
|
158
|
+
if (typeof input !== "object" || input === null) return input;
|
|
159
|
+
var prim = input[Symbol.toPrimitive];
|
|
160
|
+
if (prim !== undefined) {
|
|
161
|
+
var res = prim.call(input, hint || "default");
|
|
162
|
+
if (typeof res !== "object") return res;
|
|
163
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
164
|
+
}
|
|
165
|
+
return (hint === "string" ? String : Number)(input);
|
|
166
|
+
}
|
|
167
|
+
function _toPropertyKey(arg) {
|
|
168
|
+
var key = _toPrimitive(arg, "string");
|
|
169
|
+
return typeof key === "symbol" ? key : String(key);
|
|
153
170
|
}
|
|
154
171
|
|
|
155
172
|
function styleInject(css, ref) {
|
|
@@ -179,12 +196,11 @@ function styleInject(css, ref) {
|
|
|
179
196
|
}
|
|
180
197
|
}
|
|
181
198
|
|
|
182
|
-
var css = ".tabs__header__tabs__12-18-
|
|
183
|
-
var styles = {"tabs__header":"tabs__header__tabs__12-18-
|
|
199
|
+
var css = ".tabs__header__tabs__12-18-2-alpha-1 {\r\n font-size: var(--FontSizeDefault, 13px);\r\n line-height: 1.23;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-orient: vertical;\r\n -webkit-box-direction: normal;\r\n -ms-flex-direction: column;\r\n flex-direction: column;\r\n }\r\n\r\n .tabs__header__title__tabs__12-18-2-alpha-1 {\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n padding-right: var(--SpaceSM, 12px);\r\n }\r\n\r\n .tabs__header__container__tabs__12-18-2-alpha-1 {\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n position: relative;\r\n }\r\n\r\n .tabs__header__line__tabs__12-18-2-alpha-1 {\r\n height: 1px;\r\n position: relative;\r\n background-color: var(--ControlBorderColorDefault, rgba(64, 66, 73, 0.2));\r\n }\r\n\r\n .tabs__header__line__slider__tabs__12-18-2-alpha-1 {\r\n height: 1px;\r\n position: absolute;\r\n background-color: var(--DrBlack, #000000);\r\n -webkit-transition: left 0.3s, width 0.3s, right 0.3s, width 0.3s;\r\n transition: left 0.3s, width 0.3s, right 0.3s, width 0.3s;\r\n }\r\n\r\n .tabs__header__tab-item__tabs__12-18-2-alpha-1 {\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n font-weight: var(--FontWeightSemibold, 600);\r\n color: var(--FontColorLightGray, rgba(0, 0, 0, 0.4));\r\n cursor: pointer;\r\n outline: none;\r\n white-space: nowrap;\r\n padding: var(--SpaceS, 8px);\r\n }\r\n\r\n .tabs__header__tab-item__tabs__12-18-2-alpha-1:first-child {\r\n padding-left: 0;\r\n }\r\n\r\n .tabs__header__tab-item__tabs__12-18-2-alpha-1:not(:first-child) {\r\n padding-left: var(--SpaceSM, 12px);\r\n }\r\n\r\n .tabs__header__tab-item__tabs__12-18-2-alpha-1:not(:last-child) {\r\n padding-right: var(--SpaceSM, 12px);\r\n }\r\n\r\n .tabs__header__tab-item__tabs__12-18-2-alpha-1:hover,\r\n .tabs__header__tab-item--active__tabs__12-18-2-alpha-1 {\r\n color: var(--DrBlack, #000000);\r\n }\r\n\r\n .tabs__header__tab-item--disabled__tabs__12-18-2-alpha-1 {\r\n color: var(--FontColorLightGray, rgba(0, 0, 0, 0.4));\r\n cursor: default;\r\n }\r\n\r\n .tabs__header__tabs__showmore__wrapper__tabs__12-18-2-alpha-1 {\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n width: 100%;\r\n height: 100%;\r\n }\r\n\r\n .tabs__header__tabs__showmore__tabs__12-18-2-alpha-1 {\r\n padding: 0;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n outline: none;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n cursor: pointer;\r\n white-space: nowrap;\r\n position: relative;\r\n width: var(--ControlHeightLarge, 28px);\r\n }\r\n\r\n .tabs__header__tabs__showmore__label__tabs__12-18-2-alpha-1 {\r\n border-radius: var(--BorderRadiusDefault, 3px);\r\n width: var(--ControlHeightLarge, 28px);\r\n height: var(--ControlHeightLarge, 28px);\r\n z-index: 1;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-flex: 1;\r\n -ms-flex: 1 0 auto;\r\n flex: 1 0 auto;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n -webkit-box-pack: center;\r\n -ms-flex-pack: center;\r\n justify-content: center;\r\n }\r\n\r\n .tabs__header__tabs__showmore__label__tabs__12-18-2-alpha-1:hover {\r\n background-color: var(--ButtonBackgroundHover, #ECECED);\r\n }\r\n\r\n .tabs__header__tabs__showmore__label--selected__tabs__12-18-2-alpha-1 svg * {\r\n fill: var(--DrBlack, #000000);\r\n }\r\n\r\n .tabs__header__tabs__showmore-menu__tabs__12-18-2-alpha-1 {\r\n outline: none;\r\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n border-radius: var(--BorderRadiusL, 4px);\r\n position: absolute;\r\n right: 0;\r\n padding: var(--SpaceXS, 4px) 0;\r\n left: auto;\r\n top: calc(100% + var(--SpaceXS, 4px)/2);\r\n bottom: auto;\r\n z-index: 11;\r\n background: var(--MrWhite, #FFFFFF);\r\n display: none;\r\n }\r\n\r\n .tabs__header__tabs__showmore-menu--opened__tabs__12-18-2-alpha-1 {\r\n display: block;\r\n }\r\n\r\n .tabs__header__tabs__showmore-menu__tabs__12-18-2-alpha-1 .tabs__header__tab-item__tabs__12-18-2-alpha-1 {\r\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px);\r\n }\r\n\r\n .tabs__header__tabs__showmore-menu__tabs__12-18-2-alpha-1 .tabs__header__tab-item__tabs__12-18-2-alpha-1:hover:not(.tabs__header__tab-item--active__tabs__12-18-2-alpha-1) {\r\n background: var(--Active100, #FCF5DB);\r\n }\r\n\r\n .tabs__header__tabs__showmore-menu__tabs__12-18-2-alpha-1 .tabs__header__tab-item--active__tabs__12-18-2-alpha-1 {\r\n background: var(--Active300, #F7E292);\r\n }\r\n";
|
|
200
|
+
var styles = {"tabs__header":"tabs__header__tabs__12-18-2-alpha-1","tabs__header__title":"tabs__header__title__tabs__12-18-2-alpha-1","tabs__header__container":"tabs__header__container__tabs__12-18-2-alpha-1","tabs__header__line":"tabs__header__line__tabs__12-18-2-alpha-1","tabs__header__line__slider":"tabs__header__line__slider__tabs__12-18-2-alpha-1","tabs__header__tab-item":"tabs__header__tab-item__tabs__12-18-2-alpha-1","tabs__header__tab-item--active":"tabs__header__tab-item--active__tabs__12-18-2-alpha-1","tabs__header__tab-item--disabled":"tabs__header__tab-item--disabled__tabs__12-18-2-alpha-1","tabs__header__tabs__showmore__wrapper":"tabs__header__tabs__showmore__wrapper__tabs__12-18-2-alpha-1","tabs__header__tabs__showmore":"tabs__header__tabs__showmore__tabs__12-18-2-alpha-1","tabs__header__tabs__showmore__label":"tabs__header__tabs__showmore__label__tabs__12-18-2-alpha-1","tabs__header__tabs__showmore__label--selected":"tabs__header__tabs__showmore__label--selected__tabs__12-18-2-alpha-1","tabs__header__tabs__showmore-menu":"tabs__header__tabs__showmore-menu__tabs__12-18-2-alpha-1","tabs__header__tabs__showmore-menu--opened":"tabs__header__tabs__showmore-menu--opened__tabs__12-18-2-alpha-1"};
|
|
184
201
|
styleInject(css);
|
|
185
202
|
|
|
186
203
|
/* should be the same for Popover, all props are cut after build, so we needed to copy them */
|
|
187
|
-
|
|
188
204
|
var showMorePopoverProps = PropTypes.shape({
|
|
189
205
|
trackScroll: PropTypes.bool,
|
|
190
206
|
getContainerElement: PropTypes.func
|
|
@@ -192,42 +208,32 @@ var showMorePopoverProps = PropTypes.shape({
|
|
|
192
208
|
|
|
193
209
|
var ShowMore = /*#__PURE__*/function (_React$Component) {
|
|
194
210
|
_inherits(ShowMore, _React$Component);
|
|
195
|
-
|
|
196
211
|
function ShowMore() {
|
|
197
212
|
var _getPrototypeOf2;
|
|
198
|
-
|
|
199
213
|
var _this;
|
|
200
|
-
|
|
201
214
|
_classCallCheck(this, ShowMore);
|
|
202
|
-
|
|
203
215
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
204
216
|
args[_key] = arguments[_key];
|
|
205
217
|
}
|
|
206
|
-
|
|
207
218
|
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(ShowMore)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
208
|
-
|
|
209
219
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
|
|
210
220
|
isFocused: false,
|
|
211
221
|
isHidden: true
|
|
212
222
|
});
|
|
213
|
-
|
|
214
223
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onFocus", function () {
|
|
215
224
|
return _this.setState({
|
|
216
225
|
isFocused: true
|
|
217
226
|
});
|
|
218
227
|
});
|
|
219
|
-
|
|
220
228
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onBlur", function () {
|
|
221
229
|
return _this.setState({
|
|
222
230
|
isFocused: false
|
|
223
231
|
});
|
|
224
232
|
});
|
|
225
|
-
|
|
226
233
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onKeyDown", function (event) {
|
|
227
234
|
var _this$state = _this.state,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
235
|
+
isFocused = _this$state.isFocused,
|
|
236
|
+
isHidden = _this$state.isHidden;
|
|
231
237
|
if (event.key === 'Enter') {
|
|
232
238
|
if (isFocused) {
|
|
233
239
|
_this.setState({
|
|
@@ -240,20 +246,16 @@ var ShowMore = /*#__PURE__*/function (_React$Component) {
|
|
|
240
246
|
}
|
|
241
247
|
}
|
|
242
248
|
});
|
|
243
|
-
|
|
244
249
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "close", function () {
|
|
245
250
|
var isHidden = _this.state.isHidden;
|
|
246
|
-
|
|
247
251
|
if (!isHidden) {
|
|
248
252
|
_this.setState({
|
|
249
253
|
isHidden: true
|
|
250
254
|
});
|
|
251
255
|
}
|
|
252
256
|
});
|
|
253
|
-
|
|
254
257
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "toggleVisibility", function (event) {
|
|
255
258
|
event.stopPropagation();
|
|
256
|
-
|
|
257
259
|
_this.setState(function (_ref) {
|
|
258
260
|
var isHidden = _ref.isHidden;
|
|
259
261
|
return {
|
|
@@ -261,20 +263,15 @@ var ShowMore = /*#__PURE__*/function (_React$Component) {
|
|
|
261
263
|
};
|
|
262
264
|
});
|
|
263
265
|
});
|
|
264
|
-
|
|
265
266
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getShowMorePopoverProps", function () {
|
|
266
267
|
var popoverProps = _extends({}, _this.props.showMorePopoverProps);
|
|
267
|
-
|
|
268
268
|
if (_this.props.showMorePopoverProps && _this.props.showMorePopoverProps.getContainerElement) {
|
|
269
269
|
showMorePopoverProps.trackScroll = false;
|
|
270
270
|
}
|
|
271
|
-
|
|
272
271
|
return popoverProps;
|
|
273
272
|
});
|
|
274
|
-
|
|
275
273
|
return _this;
|
|
276
274
|
}
|
|
277
|
-
|
|
278
275
|
_createClass(ShowMore, [{
|
|
279
276
|
key: "componentWillMount",
|
|
280
277
|
value: function componentWillMount() {
|
|
@@ -287,8 +284,8 @@ var ShowMore = /*#__PURE__*/function (_React$Component) {
|
|
|
287
284
|
key: "shouldComponentUpdate",
|
|
288
285
|
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
289
286
|
var _this$props = this.props,
|
|
290
|
-
|
|
291
|
-
|
|
287
|
+
children = _this$props.children,
|
|
288
|
+
hasChildSelected = _this$props.hasChildSelected;
|
|
292
289
|
return children.length !== nextProps.children.length || hasChildSelected !== nextProps.hasChildSelected || this.state !== nextState;
|
|
293
290
|
}
|
|
294
291
|
}, {
|
|
@@ -303,15 +300,13 @@ var ShowMore = /*#__PURE__*/function (_React$Component) {
|
|
|
303
300
|
key: "render",
|
|
304
301
|
value: function render() {
|
|
305
302
|
var _this$props2 = this.props,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
303
|
+
children = _this$props2.children,
|
|
304
|
+
onShowMoreChanged = _this$props2.onShowMoreChanged,
|
|
305
|
+
hasChildSelected = _this$props2.hasChildSelected;
|
|
309
306
|
var isHidden = this.state.isHidden;
|
|
310
|
-
|
|
311
307
|
if (!children || !children.length) {
|
|
312
308
|
return null;
|
|
313
309
|
}
|
|
314
|
-
|
|
315
310
|
var isListHidden = isHidden;
|
|
316
311
|
var showMoreStyles = classNames(styles['tabs__header__tabs__showmore'], hasChildSelected && styles['tabs__header__tabs__showmore--selected']);
|
|
317
312
|
var listStyles = classNames(styles['tabs__header__tabs__showmore-menu'], !isListHidden && styles['tabs__header__tabs__showmore-menu--opened'], this.props.showMorePopoverClassName);
|
|
@@ -328,6 +323,8 @@ var ShowMore = /*#__PURE__*/function (_React$Component) {
|
|
|
328
323
|
role: "menu"
|
|
329
324
|
}, children)
|
|
330
325
|
}), React.createElement("div", {
|
|
326
|
+
className: styles.tabs__header__tabs__showmore__wrapper
|
|
327
|
+
}, React.createElement("div", {
|
|
331
328
|
ref: onShowMoreChanged,
|
|
332
329
|
className: showMoreStyles,
|
|
333
330
|
role: "navigation",
|
|
@@ -344,13 +341,11 @@ var ShowMore = /*#__PURE__*/function (_React$Component) {
|
|
|
344
341
|
"data-title": "More tabs",
|
|
345
342
|
noBackground: true,
|
|
346
343
|
isWide: true
|
|
347
|
-
})));
|
|
344
|
+
}))));
|
|
348
345
|
}
|
|
349
346
|
}]);
|
|
350
|
-
|
|
351
347
|
return ShowMore;
|
|
352
348
|
}(React.Component);
|
|
353
|
-
|
|
354
349
|
_defineProperty(ShowMore, "defaultProps", {
|
|
355
350
|
children: null,
|
|
356
351
|
hasChildSelected: false,
|
|
@@ -361,10 +356,10 @@ _defineProperty(ShowMore, "defaultProps", {
|
|
|
361
356
|
|
|
362
357
|
var TabPanel = function TabPanel(props) {
|
|
363
358
|
var id = props.id,
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
359
|
+
tabId = props.tabId,
|
|
360
|
+
children = props.children,
|
|
361
|
+
_props$hidden = props.hidden,
|
|
362
|
+
hidden = _props$hidden === void 0 ? false : _props$hidden;
|
|
368
363
|
return React.createElement("div", {
|
|
369
364
|
role: "tabpanel",
|
|
370
365
|
id: id,
|
|
@@ -381,23 +376,16 @@ function onTabClick(selected, onClick, originalKey) {
|
|
|
381
376
|
return !selected && onClick(originalKey);
|
|
382
377
|
};
|
|
383
378
|
}
|
|
384
|
-
|
|
385
379
|
var TabInner = /*#__PURE__*/function (_React$Component) {
|
|
386
380
|
_inherits(TabInner, _React$Component);
|
|
387
|
-
|
|
388
381
|
function TabInner() {
|
|
389
382
|
var _getPrototypeOf2;
|
|
390
|
-
|
|
391
383
|
var _this;
|
|
392
|
-
|
|
393
384
|
_classCallCheck(this, TabInner);
|
|
394
|
-
|
|
395
385
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
396
386
|
args[_key] = arguments[_key];
|
|
397
387
|
}
|
|
398
|
-
|
|
399
388
|
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TabInner)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
400
|
-
|
|
401
389
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "blurHandler", function () {
|
|
402
390
|
window.requestAnimationFrame(function () {
|
|
403
391
|
if (_this.tab) {
|
|
@@ -405,15 +393,12 @@ var TabInner = /*#__PURE__*/function (_React$Component) {
|
|
|
405
393
|
}
|
|
406
394
|
});
|
|
407
395
|
});
|
|
408
|
-
|
|
409
396
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTab", function () {
|
|
410
397
|
var children = _this.props.children;
|
|
411
398
|
return children;
|
|
412
399
|
});
|
|
413
|
-
|
|
414
400
|
return _this;
|
|
415
401
|
}
|
|
416
|
-
|
|
417
402
|
_createClass(TabInner, [{
|
|
418
403
|
key: "shouldComponentUpdate",
|
|
419
404
|
value: function shouldComponentUpdate(nextProps) {
|
|
@@ -423,17 +408,16 @@ var TabInner = /*#__PURE__*/function (_React$Component) {
|
|
|
423
408
|
key: "render",
|
|
424
409
|
value: function render() {
|
|
425
410
|
var _this2 = this;
|
|
426
|
-
|
|
427
411
|
var _this$props = this.props,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
412
|
+
id = _this$props.id,
|
|
413
|
+
selected = _this$props.selected,
|
|
414
|
+
disabled = _this$props.disabled,
|
|
415
|
+
panelId = _this$props.panelId,
|
|
416
|
+
onClick = _this$props.onClick,
|
|
417
|
+
getOnFocusCallback = _this$props.getOnFocusCallback,
|
|
418
|
+
onBlur = _this$props.onBlur,
|
|
419
|
+
originalKey = _this$props.originalKey,
|
|
420
|
+
classNames$$1 = _this$props.classNames;
|
|
437
421
|
return React.createElement("div", {
|
|
438
422
|
ref: function ref(tab) {
|
|
439
423
|
return _this2.tab = tab;
|
|
@@ -454,10 +438,8 @@ var TabInner = /*#__PURE__*/function (_React$Component) {
|
|
|
454
438
|
}, React.createElement("div", null, this.renderTab()));
|
|
455
439
|
}
|
|
456
440
|
}]);
|
|
457
|
-
|
|
458
441
|
return TabInner;
|
|
459
442
|
}(React.Component);
|
|
460
|
-
|
|
461
443
|
_defineProperty(TabInner, "defaultProps", {
|
|
462
444
|
children: null,
|
|
463
445
|
disabled: false
|
|
@@ -469,7 +451,6 @@ var debounce = function debounce(callback, time) {
|
|
|
469
451
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
470
452
|
args[_key] = arguments[_key];
|
|
471
453
|
}
|
|
472
|
-
|
|
473
454
|
clearTimeout(interval);
|
|
474
455
|
interval = setTimeout(function () {
|
|
475
456
|
interval = null;
|
|
@@ -480,28 +461,24 @@ var debounce = function debounce(callback, time) {
|
|
|
480
461
|
|
|
481
462
|
var tabPrefix = 'tab-';
|
|
482
463
|
var panelPrefix = 'panel-';
|
|
483
|
-
|
|
484
464
|
var getTabs = function getTabs(allTabs) {
|
|
485
465
|
return allTabs.reduce(function (result, item) {
|
|
486
466
|
var _item$props = item.props,
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
467
|
+
id = _item$props.id,
|
|
468
|
+
header = _item$props.header,
|
|
469
|
+
children = _item$props.children,
|
|
470
|
+
disabled = _item$props.disabled;
|
|
491
471
|
var payload = {
|
|
492
472
|
tabIndex: result.tabIndex,
|
|
493
473
|
disabled: disabled,
|
|
494
474
|
id: id
|
|
495
475
|
};
|
|
496
|
-
|
|
497
476
|
var tabPayload = _extends({}, payload, {
|
|
498
477
|
header: header
|
|
499
478
|
});
|
|
500
|
-
|
|
501
479
|
var panelPayload = _extends({}, payload, {
|
|
502
480
|
children: children
|
|
503
481
|
});
|
|
504
|
-
|
|
505
482
|
result.headers.push(tabPayload);
|
|
506
483
|
result.panels.set(id, panelPayload);
|
|
507
484
|
result.tabIndex += 1;
|
|
@@ -512,25 +489,21 @@ var getTabs = function getTabs(allTabs) {
|
|
|
512
489
|
tabIndex: 0
|
|
513
490
|
});
|
|
514
491
|
};
|
|
515
|
-
|
|
516
492
|
var renderTabHeader = function renderTabHeader(headerProp) {
|
|
517
493
|
var isRenderProp = typeof headerProp === 'function';
|
|
518
|
-
|
|
519
494
|
if (!isRenderProp) {
|
|
520
495
|
return headerProp;
|
|
521
496
|
}
|
|
522
|
-
|
|
523
497
|
return headerProp({
|
|
524
498
|
onResize: function onResize() {}
|
|
525
499
|
});
|
|
526
500
|
};
|
|
527
|
-
|
|
528
501
|
var getTabProps = function getTabProps(_ref) {
|
|
529
502
|
var header = _ref.header,
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
503
|
+
id = _ref.id,
|
|
504
|
+
selected = _ref.selected,
|
|
505
|
+
tabIndex = _ref.tabIndex,
|
|
506
|
+
disabled = _ref.disabled;
|
|
534
507
|
return {
|
|
535
508
|
selected: selected,
|
|
536
509
|
tabIndex: tabIndex,
|
|
@@ -545,10 +518,9 @@ var getTabProps = function getTabProps(_ref) {
|
|
|
545
518
|
classNames: classNames(styles['tabs__header__tab-item'], selected && styles['tabs__header__tab-item--active'], disabled && styles['tabs__header__tab-item--disabled'])
|
|
546
519
|
};
|
|
547
520
|
};
|
|
548
|
-
|
|
549
521
|
var getPanelProps = function getPanelProps(_ref2) {
|
|
550
522
|
var id = _ref2.id,
|
|
551
|
-
|
|
523
|
+
children = _ref2.children;
|
|
552
524
|
return {
|
|
553
525
|
children: children,
|
|
554
526
|
key: panelPrefix + id,
|
|
@@ -556,16 +528,13 @@ var getPanelProps = function getPanelProps(_ref2) {
|
|
|
556
528
|
tabId: tabPrefix + id
|
|
557
529
|
};
|
|
558
530
|
};
|
|
559
|
-
|
|
560
531
|
var TabsPrint = function TabsPrint(props) {
|
|
561
532
|
var allTabs = React.Children.toArray(props.children).filter(function (child) {
|
|
562
533
|
return child.type === Tab;
|
|
563
534
|
});
|
|
564
|
-
|
|
565
535
|
var _getTabs = getTabs(allTabs),
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
536
|
+
headers = _getTabs.headers,
|
|
537
|
+
panels = _getTabs.panels;
|
|
569
538
|
return React.createElement("div", {
|
|
570
539
|
className: classNames(styles['tabs'], props.className)
|
|
571
540
|
}, Array.from(panels.values()).map(function (tab) {
|
|
@@ -585,9 +554,10 @@ var TabsPrint = function TabsPrint(props) {
|
|
|
585
554
|
};
|
|
586
555
|
|
|
587
556
|
var tabPrefix$1 = 'tab-';
|
|
588
|
-
var panelPrefix$1 = 'panel-';
|
|
589
|
-
// and as marker for actual tabs to prevent storing them as huge array
|
|
557
|
+
var panelPrefix$1 = 'panel-';
|
|
590
558
|
|
|
559
|
+
// By itself, Tab is just a dummy component that is used for a cleaner Tabs API
|
|
560
|
+
// and as marker for actual tabs to prevent storing them as huge array
|
|
591
561
|
var Tab = function Tab() {
|
|
592
562
|
return null;
|
|
593
563
|
};
|
|
@@ -597,6 +567,7 @@ Tab.propTypes = {
|
|
|
597
567
|
children: PropTypes.node,
|
|
598
568
|
disabled: PropTypes.bool
|
|
599
569
|
};
|
|
570
|
+
|
|
600
571
|
/**
|
|
601
572
|
* Tabs component is an aggregate root for several content panes
|
|
602
573
|
* (via Tabs.Tab component), each with its own children, and a header
|
|
@@ -621,24 +592,17 @@ Tab.propTypes = {
|
|
|
621
592
|
|
|
622
593
|
var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
623
594
|
_inherits(Tabs, _React$Component);
|
|
624
|
-
|
|
625
595
|
function Tabs() {
|
|
626
596
|
var _getPrototypeOf2;
|
|
627
|
-
|
|
628
597
|
var _this;
|
|
629
|
-
|
|
630
598
|
_classCallCheck(this, Tabs);
|
|
631
|
-
|
|
632
599
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
633
600
|
args[_key] = arguments[_key];
|
|
634
601
|
}
|
|
635
|
-
|
|
636
602
|
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Tabs)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
637
|
-
|
|
638
603
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "tabRefs", new Map());
|
|
639
|
-
|
|
640
604
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "activeTabElement", null);
|
|
641
|
-
|
|
605
|
+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "titleWrapper", null);
|
|
642
606
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
|
|
643
607
|
activeTabId: _this.props.initialActiveTabId,
|
|
644
608
|
cachedTabs: new Set(),
|
|
@@ -650,14 +614,11 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
650
614
|
showMoreWidth: 40,
|
|
651
615
|
focusedTabKey: null
|
|
652
616
|
});
|
|
653
|
-
|
|
654
617
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "isControlledMode", function () {
|
|
655
618
|
return typeof _this.props.activeTabId !== 'undefined';
|
|
656
619
|
});
|
|
657
|
-
|
|
658
620
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "changeTab", function (tabId) {
|
|
659
621
|
var currentActiveTabId = _this.getActiveTabId(_this.getAllTabs());
|
|
660
|
-
|
|
661
622
|
if (_this.props.cacheOpenedTabs) {
|
|
662
623
|
_this.setState(function (state) {
|
|
663
624
|
var cachedTabs = new Set(state.cachedTabs);
|
|
@@ -672,29 +633,27 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
672
633
|
activeTabId: tabId
|
|
673
634
|
});
|
|
674
635
|
}
|
|
675
|
-
|
|
676
636
|
if (typeof _this.props.onActiveTabChanged === 'function') {
|
|
677
637
|
_this.props.onActiveTabChanged(tabId);
|
|
678
638
|
}
|
|
679
639
|
});
|
|
680
|
-
|
|
681
640
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setTabsDimensions", function () {
|
|
682
641
|
window.requestAnimationFrame(function () {
|
|
683
642
|
if (!_this.tabsWrapper) {
|
|
684
643
|
// it shouldn't happens evern. Just paranoic check
|
|
685
644
|
return;
|
|
686
|
-
}
|
|
687
|
-
|
|
645
|
+
}
|
|
688
646
|
|
|
689
|
-
|
|
647
|
+
// initial wrapper width calculation
|
|
648
|
+
var blockWidth = _this.tabsWrapper.offsetWidth - _this.props.showMoreWidthBuffer - _this.getTitleWidth();
|
|
690
649
|
|
|
650
|
+
// calculate width and offset for each tab
|
|
691
651
|
var tabsTotalWidth = 0;
|
|
692
652
|
var tabDimensions = new Map();
|
|
693
653
|
Array.from(_this.tabRefs.entries()).forEach(function (_ref) {
|
|
694
654
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
655
|
+
key = _ref2[0],
|
|
656
|
+
value = _ref2[1];
|
|
698
657
|
if (value) {
|
|
699
658
|
var width = value.tab.offsetWidth;
|
|
700
659
|
tabDimensions.set(key.replace(tabPrefix$1, ''), {
|
|
@@ -704,7 +663,6 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
704
663
|
tabsTotalWidth += width;
|
|
705
664
|
}
|
|
706
665
|
});
|
|
707
|
-
|
|
708
666
|
_this.setState({
|
|
709
667
|
tabDimensions: tabDimensions,
|
|
710
668
|
tabsTotalWidth: tabsTotalWidth,
|
|
@@ -712,7 +670,6 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
712
670
|
});
|
|
713
671
|
});
|
|
714
672
|
});
|
|
715
|
-
|
|
716
673
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "adjustSlider", function () {
|
|
717
674
|
window.requestAnimationFrame(function () {
|
|
718
675
|
if (_this.activeTabElement && _this.activeTabElement.tab) {
|
|
@@ -728,49 +685,42 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
728
685
|
}
|
|
729
686
|
});
|
|
730
687
|
});
|
|
731
|
-
|
|
688
|
+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTitleWidth", function () {
|
|
689
|
+
return _this.titleWrapper ? _this.titleWrapper.offsetWidth : 0;
|
|
690
|
+
});
|
|
732
691
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onResizeThrottled", function (width) {
|
|
733
692
|
_this.setState({
|
|
734
|
-
blockWidth: width - _this.props.showMoreWidthBuffer
|
|
693
|
+
blockWidth: width - _this.props.showMoreWidthBuffer - _this.getTitleWidth()
|
|
735
694
|
});
|
|
736
|
-
|
|
737
695
|
_this.adjustSlider();
|
|
738
696
|
});
|
|
739
|
-
|
|
740
697
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleHeaderResize", debounce(function () {
|
|
741
698
|
_this.setTabsDimensions();
|
|
742
|
-
|
|
743
699
|
_this.adjustSlider();
|
|
744
700
|
}, 50));
|
|
745
|
-
|
|
746
701
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTabHeader", function (headerProp) {
|
|
747
702
|
var isRenderProp = typeof headerProp === 'function';
|
|
748
|
-
|
|
749
703
|
if (!isRenderProp) {
|
|
750
704
|
return headerProp;
|
|
751
705
|
}
|
|
752
|
-
|
|
753
706
|
return headerProp({
|
|
754
707
|
onResize: _this.handleHeaderResize
|
|
755
708
|
});
|
|
756
709
|
});
|
|
757
|
-
|
|
758
710
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTabs", function (allTabs, shrinkToParent) {
|
|
759
711
|
var _this$state = _this.state,
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
712
|
+
blockWidth = _this$state.blockWidth,
|
|
713
|
+
tabsTotalWidth = _this$state.tabsTotalWidth,
|
|
714
|
+
tabDimensions = _this$state.tabDimensions,
|
|
715
|
+
showMoreWidth = _this$state.showMoreWidth;
|
|
765
716
|
var activeTabId = _this.getActiveTabId(allTabs);
|
|
766
|
-
|
|
767
717
|
var availableWidth = blockWidth - (tabsTotalWidth > blockWidth ? showMoreWidth : 0);
|
|
768
718
|
return allTabs.reduce(function (result, item) {
|
|
769
719
|
var _item$props = item.props,
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
720
|
+
id = _item$props.id,
|
|
721
|
+
header = _item$props.header,
|
|
722
|
+
children = _item$props.children,
|
|
723
|
+
disabled = _item$props.disabled;
|
|
774
724
|
var selected = activeTabId === id;
|
|
775
725
|
var payload = {
|
|
776
726
|
tabIndex: result.tabIndex,
|
|
@@ -778,33 +728,31 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
778
728
|
disabled: disabled,
|
|
779
729
|
id: id
|
|
780
730
|
};
|
|
781
|
-
|
|
782
731
|
var tabPayload = _extends({}, payload, {
|
|
783
732
|
header: header
|
|
784
733
|
});
|
|
785
|
-
|
|
786
734
|
var panelPayload = _extends({}, payload, {
|
|
787
735
|
children: children
|
|
788
736
|
});
|
|
789
|
-
|
|
790
737
|
var tabWidth = tabDimensions.has(id) ? tabDimensions.get(id).width : 0;
|
|
791
|
-
/* eslint-disable no-param-reassign */
|
|
792
738
|
|
|
793
|
-
|
|
794
|
-
!
|
|
795
|
-
|
|
739
|
+
/* eslint-disable no-param-reassign */
|
|
740
|
+
if (!shrinkToParent ||
|
|
741
|
+
// initial call
|
|
742
|
+
!blockWidth ||
|
|
743
|
+
// all tabs are fit into the block
|
|
744
|
+
blockWidth > tabsTotalWidth ||
|
|
745
|
+
// current tab fit into the block
|
|
796
746
|
result.availableWidth - tabWidth - showMoreWidth > 0) {
|
|
797
747
|
result.tabsVisible.push(tabPayload);
|
|
798
748
|
} else {
|
|
799
749
|
result.tabsHidden.push(tabPayload);
|
|
800
|
-
|
|
801
750
|
if (selected) {
|
|
802
751
|
result.isSelectedTabHidden = true;
|
|
803
752
|
}
|
|
804
753
|
}
|
|
805
754
|
/* eslint-enable no-param-reassign */
|
|
806
755
|
|
|
807
|
-
|
|
808
756
|
result.panels.set(id, panelPayload);
|
|
809
757
|
result.availableWidth -= tabWidth;
|
|
810
758
|
result.tabIndex += 1;
|
|
@@ -818,36 +766,27 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
818
766
|
availableWidth: availableWidth
|
|
819
767
|
});
|
|
820
768
|
});
|
|
821
|
-
|
|
822
769
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getActiveTabId", function (tabs) {
|
|
823
770
|
var _tabs = _slicedToArray(tabs, 1),
|
|
824
|
-
|
|
825
|
-
|
|
771
|
+
firstTab = _tabs[0];
|
|
826
772
|
if (_this.isControlledMode()) {
|
|
827
773
|
var tabId = _this.props.activeTabId;
|
|
828
|
-
|
|
829
774
|
if (tabId && tabs.some(function (tab) {
|
|
830
775
|
return tab.props.id === tabId;
|
|
831
776
|
})) {
|
|
832
777
|
return tabId;
|
|
833
778
|
}
|
|
834
|
-
|
|
835
779
|
return firstTab.props.id;
|
|
836
780
|
}
|
|
837
|
-
|
|
838
781
|
var activeTabId = _this.state.activeTabId;
|
|
839
|
-
|
|
840
782
|
if (typeof activeTabId === 'undefined') {
|
|
841
783
|
if (!(firstTab && firstTab.props)) {
|
|
842
784
|
return null;
|
|
843
785
|
}
|
|
844
|
-
|
|
845
786
|
return firstTab.props.id || null;
|
|
846
787
|
}
|
|
847
|
-
|
|
848
788
|
return activeTabId;
|
|
849
789
|
});
|
|
850
|
-
|
|
851
790
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onFocusTab", function (focusedTabKey) {
|
|
852
791
|
return function () {
|
|
853
792
|
return _this.setState({
|
|
@@ -855,29 +794,25 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
855
794
|
});
|
|
856
795
|
};
|
|
857
796
|
});
|
|
858
|
-
|
|
859
797
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onBlurTab", function () {
|
|
860
798
|
return _this.setState({
|
|
861
799
|
focusedTabKey: null
|
|
862
800
|
});
|
|
863
801
|
});
|
|
864
|
-
|
|
865
802
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onKeyDown", function (event) {
|
|
866
803
|
if (event.key === 'Enter' && _this.state.focusedTabKey !== null) {
|
|
867
804
|
_this.changeTab(_this.state.focusedTabKey);
|
|
868
805
|
}
|
|
869
806
|
});
|
|
870
|
-
|
|
871
807
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onClick", function (tab) {
|
|
872
808
|
return !tab.disabled && _this.changeTab(tab.id);
|
|
873
809
|
});
|
|
874
|
-
|
|
875
810
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTabProps", function (_ref3) {
|
|
876
811
|
var header = _ref3.header,
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
812
|
+
id = _ref3.id,
|
|
813
|
+
selected = _ref3.selected,
|
|
814
|
+
tabIndex = _ref3.tabIndex,
|
|
815
|
+
disabled = _ref3.disabled;
|
|
881
816
|
return {
|
|
882
817
|
selected: selected,
|
|
883
818
|
tabIndex: tabIndex,
|
|
@@ -888,7 +823,6 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
888
823
|
if (selected) {
|
|
889
824
|
_this.activeTabElement = tab;
|
|
890
825
|
}
|
|
891
|
-
|
|
892
826
|
_this.tabRefs.set(tabPrefix$1 + id, tab);
|
|
893
827
|
},
|
|
894
828
|
originalKey: id,
|
|
@@ -904,10 +838,9 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
904
838
|
classNames: classNames(styles['tabs__header__tab-item'], selected && styles['tabs__header__tab-item--active'], disabled && styles['tabs__header__tab-item--disabled'])
|
|
905
839
|
};
|
|
906
840
|
});
|
|
907
|
-
|
|
908
841
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getPanelProps", function (_ref4) {
|
|
909
842
|
var id = _ref4.id,
|
|
910
|
-
|
|
843
|
+
children = _ref4.children;
|
|
911
844
|
return {
|
|
912
845
|
children: children,
|
|
913
846
|
key: panelPrefix$1 + id,
|
|
@@ -915,54 +848,43 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
915
848
|
tabId: tabPrefix$1 + id
|
|
916
849
|
};
|
|
917
850
|
});
|
|
918
|
-
|
|
919
851
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "showMoreChanged", function (element) {
|
|
920
852
|
if (!element) {
|
|
921
853
|
return;
|
|
922
854
|
}
|
|
923
|
-
|
|
924
855
|
var showMoreWidth = element.offsetWidth;
|
|
925
|
-
|
|
926
856
|
if (_this.state.showMoreWidth === showMoreWidth) {
|
|
927
857
|
return;
|
|
928
858
|
}
|
|
929
|
-
|
|
930
859
|
_this.setState({
|
|
931
860
|
showMoreWidth: showMoreWidth
|
|
932
861
|
});
|
|
933
862
|
});
|
|
934
|
-
|
|
935
863
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getShowMoreProps", function (isSelectedTabHidden) {
|
|
936
864
|
return {
|
|
937
865
|
onShowMoreChanged: _this.showMoreChanged,
|
|
938
866
|
hasChildSelected: isSelectedTabHidden
|
|
939
867
|
};
|
|
940
868
|
});
|
|
941
|
-
|
|
942
869
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getSliderStyle", function (isSelectedTabHidden) {
|
|
943
870
|
return {
|
|
944
871
|
left: isSelectedTabHidden ? '100%' : _this.state.sliderLeft,
|
|
945
872
|
width: isSelectedTabHidden ? '0' : _this.state.sliderWidth
|
|
946
873
|
};
|
|
947
874
|
});
|
|
948
|
-
|
|
949
875
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getAllTabs", function () {
|
|
950
876
|
return React.Children.toArray(_this.props.children).filter(function (child) {
|
|
951
877
|
return child.type === Tab;
|
|
952
878
|
});
|
|
953
879
|
});
|
|
954
|
-
|
|
955
880
|
return _this;
|
|
956
881
|
}
|
|
957
|
-
|
|
958
882
|
_createClass(Tabs, [{
|
|
959
883
|
key: "componentDidMount",
|
|
960
884
|
value: function componentDidMount() {
|
|
961
885
|
var _this2 = this;
|
|
962
|
-
|
|
963
886
|
setTimeout(function () {
|
|
964
887
|
_this2.setTabsDimensions();
|
|
965
|
-
|
|
966
888
|
_this2.adjustSlider();
|
|
967
889
|
}, this.props.tabSizeTimeout);
|
|
968
890
|
}
|
|
@@ -971,11 +893,9 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
971
893
|
value: function componentDidUpdate(previousProps, previousState) {
|
|
972
894
|
var activeTabChanged = this.isControlledMode() ? this.props.activeTabId !== previousProps.activeTabId : this.state.activeTabId !== previousState.activeTabId;
|
|
973
895
|
var blockWidth = this.state.blockWidth;
|
|
974
|
-
|
|
975
896
|
if (activeTabChanged) {
|
|
976
897
|
this.adjustSlider();
|
|
977
898
|
}
|
|
978
|
-
|
|
979
899
|
if (!blockWidth) {
|
|
980
900
|
this.setTabsDimensions();
|
|
981
901
|
}
|
|
@@ -984,42 +904,38 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
984
904
|
key: "shouldComponentUpdate",
|
|
985
905
|
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
986
906
|
var _this$state2 = this.state,
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
907
|
+
activeTabId = _this$state2.activeTabId,
|
|
908
|
+
blockWidth = _this$state2.blockWidth,
|
|
909
|
+
showMoreWidth = _this$state2.showMoreWidth,
|
|
910
|
+
sliderLeft = _this$state2.sliderLeft,
|
|
911
|
+
sliderWidth = _this$state2.sliderWidth,
|
|
912
|
+
tabsTotalWidth = _this$state2.tabsTotalWidth,
|
|
913
|
+
focusedTabKey = _this$state2.focusedTabKey;
|
|
994
914
|
var _this$props = this.props,
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
915
|
+
initialActiveTabId = _this$props.initialActiveTabId,
|
|
916
|
+
onActiveTabChanged = _this$props.onActiveTabChanged,
|
|
917
|
+
resizeThrottle = _this$props.resizeThrottle,
|
|
918
|
+
tabSizeTimeout = _this$props.tabSizeTimeout,
|
|
919
|
+
children = _this$props.children;
|
|
1000
920
|
return nextState.blockWidth !== blockWidth || nextState.showMoreWidth !== showMoreWidth || nextState.sliderLeft !== sliderLeft || nextState.sliderWidth !== sliderWidth || nextState.tabsTotalWidth !== tabsTotalWidth || nextState.focusedTabKey !== focusedTabKey || nextState.activeTabId !== activeTabId || nextProps.initialActiveTabId !== initialActiveTabId || nextProps.onActiveTabChanged !== onActiveTabChanged || nextProps.resizeThrottle !== resizeThrottle || nextProps.tabSizeTimeout !== tabSizeTimeout || nextProps.children !== children;
|
|
1001
921
|
}
|
|
1002
922
|
}, {
|
|
1003
923
|
key: "render",
|
|
1004
924
|
value: function render() {
|
|
1005
925
|
var _this3 = this;
|
|
1006
|
-
|
|
1007
926
|
if (this.props.printMode) {
|
|
1008
927
|
return React.createElement(TabsPrint, {
|
|
1009
928
|
className: this.props.className,
|
|
1010
929
|
children: this.props.children
|
|
1011
930
|
});
|
|
1012
931
|
}
|
|
1013
|
-
|
|
1014
932
|
var allTabs = this.getAllTabs();
|
|
1015
933
|
var activeTabId = this.getActiveTabId(allTabs);
|
|
1016
|
-
|
|
1017
934
|
var _this$getTabs = this.getTabs(allTabs, this.props.shrinkToParent),
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
935
|
+
tabsVisible = _this$getTabs.tabsVisible,
|
|
936
|
+
tabsHidden = _this$getTabs.tabsHidden,
|
|
937
|
+
panels = _this$getTabs.panels,
|
|
938
|
+
isSelectedTabHidden = _this$getTabs.isSelectedTabHidden;
|
|
1023
939
|
var activeTab = panels.get(activeTabId) || allTabs[0];
|
|
1024
940
|
return React.createElement("div", {
|
|
1025
941
|
className: classNames(styles['tabs'], this.props.className)
|
|
@@ -1031,7 +947,12 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
1031
947
|
},
|
|
1032
948
|
onKeyDown: this.onKeyDown,
|
|
1033
949
|
className: styles.tabs__header__container
|
|
1034
|
-
},
|
|
950
|
+
}, this.props.title ? React.createElement("div", {
|
|
951
|
+
className: styles.tabs__header__title,
|
|
952
|
+
ref: function ref(titleWrapper) {
|
|
953
|
+
return _this3.titleWrapper = titleWrapper;
|
|
954
|
+
}
|
|
955
|
+
}, this.props.title) : null, tabsVisible.map(function (tab) {
|
|
1035
956
|
return React.createElement(TabInner, _this3.getTabProps(tab));
|
|
1036
957
|
}), React.createElement(ShowMore, _extends({}, this.getShowMoreProps(isSelectedTabHidden), {
|
|
1037
958
|
showMorePopoverClassName: this.props.showMorePopoverClassName,
|
|
@@ -1047,17 +968,13 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
1047
968
|
className: styles.tabs__body
|
|
1048
969
|
}, this.props.cacheOpenedTabs ? allTabs.map(function (_ref5) {
|
|
1049
970
|
var id = _ref5.props.id;
|
|
1050
|
-
|
|
1051
971
|
var shouldBeRendered = panels.has(id) && (id === activeTabId || _this3.state.cachedTabs.has(id));
|
|
1052
|
-
|
|
1053
972
|
var isHidden = id !== activeTabId;
|
|
1054
|
-
|
|
1055
973
|
if (shouldBeRendered) {
|
|
1056
974
|
return React.createElement(TabPanel, _extends({}, _this3.getPanelProps(panels.get(id)), {
|
|
1057
975
|
hidden: isHidden
|
|
1058
976
|
}));
|
|
1059
977
|
}
|
|
1060
|
-
|
|
1061
978
|
return null;
|
|
1062
979
|
}) : activeTab && React.createElement(TabPanel, this.getPanelProps(activeTab))), React.createElement(ResizeDetector, {
|
|
1063
980
|
handleWidth: true,
|
|
@@ -1082,14 +999,11 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
1082
999
|
cachedTabs: cachedTabs
|
|
1083
1000
|
});
|
|
1084
1001
|
}
|
|
1085
|
-
|
|
1086
1002
|
return null;
|
|
1087
1003
|
}
|
|
1088
1004
|
}]);
|
|
1089
|
-
|
|
1090
1005
|
return Tabs;
|
|
1091
1006
|
}(React.Component);
|
|
1092
|
-
|
|
1093
1007
|
_defineProperty(Tabs, "defaultProps", {
|
|
1094
1008
|
resizeThrottle: 100,
|
|
1095
1009
|
tabSizeTimeout: 200,
|
|
@@ -1098,7 +1012,6 @@ _defineProperty(Tabs, "defaultProps", {
|
|
|
1098
1012
|
printMode: false,
|
|
1099
1013
|
cacheOpenedTabs: false
|
|
1100
1014
|
});
|
|
1101
|
-
|
|
1102
1015
|
Tabs.Tab = Tab;
|
|
1103
1016
|
|
|
1104
1017
|
exports.Tabs = Tabs;
|