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