@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.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-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.
|
|
183
|
-
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"};
|
|
199
|
+
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";
|
|
200
|
+
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"};
|
|
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);
|
|
@@ -349,10 +344,8 @@ var ShowMore = /*#__PURE__*/function (_React$Component) {
|
|
|
349
344
|
}))));
|
|
350
345
|
}
|
|
351
346
|
}]);
|
|
352
|
-
|
|
353
347
|
return ShowMore;
|
|
354
348
|
}(React.Component);
|
|
355
|
-
|
|
356
349
|
_defineProperty(ShowMore, "defaultProps", {
|
|
357
350
|
children: null,
|
|
358
351
|
hasChildSelected: false,
|
|
@@ -363,10 +356,10 @@ _defineProperty(ShowMore, "defaultProps", {
|
|
|
363
356
|
|
|
364
357
|
var TabPanel = function TabPanel(props) {
|
|
365
358
|
var id = props.id,
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
359
|
+
tabId = props.tabId,
|
|
360
|
+
children = props.children,
|
|
361
|
+
_props$hidden = props.hidden,
|
|
362
|
+
hidden = _props$hidden === void 0 ? false : _props$hidden;
|
|
370
363
|
return React.createElement("div", {
|
|
371
364
|
role: "tabpanel",
|
|
372
365
|
id: id,
|
|
@@ -383,23 +376,16 @@ function onTabClick(selected, onClick, originalKey) {
|
|
|
383
376
|
return !selected && onClick(originalKey);
|
|
384
377
|
};
|
|
385
378
|
}
|
|
386
|
-
|
|
387
379
|
var TabInner = /*#__PURE__*/function (_React$Component) {
|
|
388
380
|
_inherits(TabInner, _React$Component);
|
|
389
|
-
|
|
390
381
|
function TabInner() {
|
|
391
382
|
var _getPrototypeOf2;
|
|
392
|
-
|
|
393
383
|
var _this;
|
|
394
|
-
|
|
395
384
|
_classCallCheck(this, TabInner);
|
|
396
|
-
|
|
397
385
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
398
386
|
args[_key] = arguments[_key];
|
|
399
387
|
}
|
|
400
|
-
|
|
401
388
|
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TabInner)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
402
|
-
|
|
403
389
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "blurHandler", function () {
|
|
404
390
|
window.requestAnimationFrame(function () {
|
|
405
391
|
if (_this.tab) {
|
|
@@ -407,15 +393,12 @@ var TabInner = /*#__PURE__*/function (_React$Component) {
|
|
|
407
393
|
}
|
|
408
394
|
});
|
|
409
395
|
});
|
|
410
|
-
|
|
411
396
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTab", function () {
|
|
412
397
|
var children = _this.props.children;
|
|
413
398
|
return children;
|
|
414
399
|
});
|
|
415
|
-
|
|
416
400
|
return _this;
|
|
417
401
|
}
|
|
418
|
-
|
|
419
402
|
_createClass(TabInner, [{
|
|
420
403
|
key: "shouldComponentUpdate",
|
|
421
404
|
value: function shouldComponentUpdate(nextProps) {
|
|
@@ -425,17 +408,16 @@ var TabInner = /*#__PURE__*/function (_React$Component) {
|
|
|
425
408
|
key: "render",
|
|
426
409
|
value: function render() {
|
|
427
410
|
var _this2 = this;
|
|
428
|
-
|
|
429
411
|
var _this$props = this.props,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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;
|
|
439
421
|
return React.createElement("div", {
|
|
440
422
|
ref: function ref(tab) {
|
|
441
423
|
return _this2.tab = tab;
|
|
@@ -456,10 +438,8 @@ var TabInner = /*#__PURE__*/function (_React$Component) {
|
|
|
456
438
|
}, React.createElement("div", null, this.renderTab()));
|
|
457
439
|
}
|
|
458
440
|
}]);
|
|
459
|
-
|
|
460
441
|
return TabInner;
|
|
461
442
|
}(React.Component);
|
|
462
|
-
|
|
463
443
|
_defineProperty(TabInner, "defaultProps", {
|
|
464
444
|
children: null,
|
|
465
445
|
disabled: false
|
|
@@ -471,7 +451,6 @@ var debounce = function debounce(callback, time) {
|
|
|
471
451
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
472
452
|
args[_key] = arguments[_key];
|
|
473
453
|
}
|
|
474
|
-
|
|
475
454
|
clearTimeout(interval);
|
|
476
455
|
interval = setTimeout(function () {
|
|
477
456
|
interval = null;
|
|
@@ -482,28 +461,24 @@ var debounce = function debounce(callback, time) {
|
|
|
482
461
|
|
|
483
462
|
var tabPrefix = 'tab-';
|
|
484
463
|
var panelPrefix = 'panel-';
|
|
485
|
-
|
|
486
464
|
var getTabs = function getTabs(allTabs) {
|
|
487
465
|
return allTabs.reduce(function (result, item) {
|
|
488
466
|
var _item$props = item.props,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
467
|
+
id = _item$props.id,
|
|
468
|
+
header = _item$props.header,
|
|
469
|
+
children = _item$props.children,
|
|
470
|
+
disabled = _item$props.disabled;
|
|
493
471
|
var payload = {
|
|
494
472
|
tabIndex: result.tabIndex,
|
|
495
473
|
disabled: disabled,
|
|
496
474
|
id: id
|
|
497
475
|
};
|
|
498
|
-
|
|
499
476
|
var tabPayload = _extends({}, payload, {
|
|
500
477
|
header: header
|
|
501
478
|
});
|
|
502
|
-
|
|
503
479
|
var panelPayload = _extends({}, payload, {
|
|
504
480
|
children: children
|
|
505
481
|
});
|
|
506
|
-
|
|
507
482
|
result.headers.push(tabPayload);
|
|
508
483
|
result.panels.set(id, panelPayload);
|
|
509
484
|
result.tabIndex += 1;
|
|
@@ -514,25 +489,21 @@ var getTabs = function getTabs(allTabs) {
|
|
|
514
489
|
tabIndex: 0
|
|
515
490
|
});
|
|
516
491
|
};
|
|
517
|
-
|
|
518
492
|
var renderTabHeader = function renderTabHeader(headerProp) {
|
|
519
493
|
var isRenderProp = typeof headerProp === 'function';
|
|
520
|
-
|
|
521
494
|
if (!isRenderProp) {
|
|
522
495
|
return headerProp;
|
|
523
496
|
}
|
|
524
|
-
|
|
525
497
|
return headerProp({
|
|
526
498
|
onResize: function onResize() {}
|
|
527
499
|
});
|
|
528
500
|
};
|
|
529
|
-
|
|
530
501
|
var getTabProps = function getTabProps(_ref) {
|
|
531
502
|
var header = _ref.header,
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
503
|
+
id = _ref.id,
|
|
504
|
+
selected = _ref.selected,
|
|
505
|
+
tabIndex = _ref.tabIndex,
|
|
506
|
+
disabled = _ref.disabled;
|
|
536
507
|
return {
|
|
537
508
|
selected: selected,
|
|
538
509
|
tabIndex: tabIndex,
|
|
@@ -547,10 +518,9 @@ var getTabProps = function getTabProps(_ref) {
|
|
|
547
518
|
classNames: classNames(styles['tabs__header__tab-item'], selected && styles['tabs__header__tab-item--active'], disabled && styles['tabs__header__tab-item--disabled'])
|
|
548
519
|
};
|
|
549
520
|
};
|
|
550
|
-
|
|
551
521
|
var getPanelProps = function getPanelProps(_ref2) {
|
|
552
522
|
var id = _ref2.id,
|
|
553
|
-
|
|
523
|
+
children = _ref2.children;
|
|
554
524
|
return {
|
|
555
525
|
children: children,
|
|
556
526
|
key: panelPrefix + id,
|
|
@@ -558,16 +528,13 @@ var getPanelProps = function getPanelProps(_ref2) {
|
|
|
558
528
|
tabId: tabPrefix + id
|
|
559
529
|
};
|
|
560
530
|
};
|
|
561
|
-
|
|
562
531
|
var TabsPrint = function TabsPrint(props) {
|
|
563
532
|
var allTabs = React.Children.toArray(props.children).filter(function (child) {
|
|
564
533
|
return child.type === Tab;
|
|
565
534
|
});
|
|
566
|
-
|
|
567
535
|
var _getTabs = getTabs(allTabs),
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
536
|
+
headers = _getTabs.headers,
|
|
537
|
+
panels = _getTabs.panels;
|
|
571
538
|
return React.createElement("div", {
|
|
572
539
|
className: classNames(styles['tabs'], props.className)
|
|
573
540
|
}, Array.from(panels.values()).map(function (tab) {
|
|
@@ -587,9 +554,10 @@ var TabsPrint = function TabsPrint(props) {
|
|
|
587
554
|
};
|
|
588
555
|
|
|
589
556
|
var tabPrefix$1 = 'tab-';
|
|
590
|
-
var panelPrefix$1 = 'panel-';
|
|
591
|
-
// and as marker for actual tabs to prevent storing them as huge array
|
|
557
|
+
var panelPrefix$1 = 'panel-';
|
|
592
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
|
|
593
561
|
var Tab = function Tab() {
|
|
594
562
|
return null;
|
|
595
563
|
};
|
|
@@ -599,6 +567,7 @@ Tab.propTypes = {
|
|
|
599
567
|
children: PropTypes.node,
|
|
600
568
|
disabled: PropTypes.bool
|
|
601
569
|
};
|
|
570
|
+
|
|
602
571
|
/**
|
|
603
572
|
* Tabs component is an aggregate root for several content panes
|
|
604
573
|
* (via Tabs.Tab component), each with its own children, and a header
|
|
@@ -623,26 +592,17 @@ Tab.propTypes = {
|
|
|
623
592
|
|
|
624
593
|
var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
625
594
|
_inherits(Tabs, _React$Component);
|
|
626
|
-
|
|
627
595
|
function Tabs() {
|
|
628
596
|
var _getPrototypeOf2;
|
|
629
|
-
|
|
630
597
|
var _this;
|
|
631
|
-
|
|
632
598
|
_classCallCheck(this, Tabs);
|
|
633
|
-
|
|
634
599
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
635
600
|
args[_key] = arguments[_key];
|
|
636
601
|
}
|
|
637
|
-
|
|
638
602
|
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Tabs)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
639
|
-
|
|
640
603
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "tabRefs", new Map());
|
|
641
|
-
|
|
642
604
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "activeTabElement", null);
|
|
643
|
-
|
|
644
605
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "titleWrapper", null);
|
|
645
|
-
|
|
646
606
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
|
|
647
607
|
activeTabId: _this.props.initialActiveTabId,
|
|
648
608
|
cachedTabs: new Set(),
|
|
@@ -654,14 +614,11 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
654
614
|
showMoreWidth: 40,
|
|
655
615
|
focusedTabKey: null
|
|
656
616
|
});
|
|
657
|
-
|
|
658
617
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "isControlledMode", function () {
|
|
659
618
|
return typeof _this.props.activeTabId !== 'undefined';
|
|
660
619
|
});
|
|
661
|
-
|
|
662
620
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "changeTab", function (tabId) {
|
|
663
621
|
var currentActiveTabId = _this.getActiveTabId(_this.getAllTabs());
|
|
664
|
-
|
|
665
622
|
if (_this.props.cacheOpenedTabs) {
|
|
666
623
|
_this.setState(function (state) {
|
|
667
624
|
var cachedTabs = new Set(state.cachedTabs);
|
|
@@ -676,30 +633,27 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
676
633
|
activeTabId: tabId
|
|
677
634
|
});
|
|
678
635
|
}
|
|
679
|
-
|
|
680
636
|
if (typeof _this.props.onActiveTabChanged === 'function') {
|
|
681
637
|
_this.props.onActiveTabChanged(tabId);
|
|
682
638
|
}
|
|
683
639
|
});
|
|
684
|
-
|
|
685
640
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setTabsDimensions", function () {
|
|
686
641
|
window.requestAnimationFrame(function () {
|
|
687
642
|
if (!_this.tabsWrapper) {
|
|
688
643
|
// it shouldn't happens evern. Just paranoic check
|
|
689
644
|
return;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
var blockWidth = _this.tabsWrapper.offsetWidth - _this.props.showMoreWidthBuffer - _this.getTitleWidth(); // calculate width and offset for each tab
|
|
645
|
+
}
|
|
694
646
|
|
|
647
|
+
// initial wrapper width calculation
|
|
648
|
+
var blockWidth = _this.tabsWrapper.offsetWidth - _this.props.showMoreWidthBuffer - _this.getTitleWidth();
|
|
695
649
|
|
|
650
|
+
// calculate width and offset for each tab
|
|
696
651
|
var tabsTotalWidth = 0;
|
|
697
652
|
var tabDimensions = new Map();
|
|
698
653
|
Array.from(_this.tabRefs.entries()).forEach(function (_ref) {
|
|
699
654
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
655
|
+
key = _ref2[0],
|
|
656
|
+
value = _ref2[1];
|
|
703
657
|
if (value) {
|
|
704
658
|
var width = value.tab.offsetWidth;
|
|
705
659
|
tabDimensions.set(key.replace(tabPrefix$1, ''), {
|
|
@@ -709,7 +663,6 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
709
663
|
tabsTotalWidth += width;
|
|
710
664
|
}
|
|
711
665
|
});
|
|
712
|
-
|
|
713
666
|
_this.setState({
|
|
714
667
|
tabDimensions: tabDimensions,
|
|
715
668
|
tabsTotalWidth: tabsTotalWidth,
|
|
@@ -717,7 +670,6 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
717
670
|
});
|
|
718
671
|
});
|
|
719
672
|
});
|
|
720
|
-
|
|
721
673
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "adjustSlider", function () {
|
|
722
674
|
window.requestAnimationFrame(function () {
|
|
723
675
|
if (_this.activeTabElement && _this.activeTabElement.tab) {
|
|
@@ -733,53 +685,42 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
733
685
|
}
|
|
734
686
|
});
|
|
735
687
|
});
|
|
736
|
-
|
|
737
688
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTitleWidth", function () {
|
|
738
689
|
return _this.titleWrapper ? _this.titleWrapper.offsetWidth : 0;
|
|
739
690
|
});
|
|
740
|
-
|
|
741
691
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onResizeThrottled", function (width) {
|
|
742
692
|
_this.setState({
|
|
743
693
|
blockWidth: width - _this.props.showMoreWidthBuffer - _this.getTitleWidth()
|
|
744
694
|
});
|
|
745
|
-
|
|
746
695
|
_this.adjustSlider();
|
|
747
696
|
});
|
|
748
|
-
|
|
749
697
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleHeaderResize", debounce(function () {
|
|
750
698
|
_this.setTabsDimensions();
|
|
751
|
-
|
|
752
699
|
_this.adjustSlider();
|
|
753
700
|
}, 50));
|
|
754
|
-
|
|
755
701
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTabHeader", function (headerProp) {
|
|
756
702
|
var isRenderProp = typeof headerProp === 'function';
|
|
757
|
-
|
|
758
703
|
if (!isRenderProp) {
|
|
759
704
|
return headerProp;
|
|
760
705
|
}
|
|
761
|
-
|
|
762
706
|
return headerProp({
|
|
763
707
|
onResize: _this.handleHeaderResize
|
|
764
708
|
});
|
|
765
709
|
});
|
|
766
|
-
|
|
767
710
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTabs", function (allTabs, shrinkToParent) {
|
|
768
711
|
var _this$state = _this.state,
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
712
|
+
blockWidth = _this$state.blockWidth,
|
|
713
|
+
tabsTotalWidth = _this$state.tabsTotalWidth,
|
|
714
|
+
tabDimensions = _this$state.tabDimensions,
|
|
715
|
+
showMoreWidth = _this$state.showMoreWidth;
|
|
774
716
|
var activeTabId = _this.getActiveTabId(allTabs);
|
|
775
|
-
|
|
776
717
|
var availableWidth = blockWidth - (tabsTotalWidth > blockWidth ? showMoreWidth : 0);
|
|
777
718
|
return allTabs.reduce(function (result, item) {
|
|
778
719
|
var _item$props = item.props,
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
720
|
+
id = _item$props.id,
|
|
721
|
+
header = _item$props.header,
|
|
722
|
+
children = _item$props.children,
|
|
723
|
+
disabled = _item$props.disabled;
|
|
783
724
|
var selected = activeTabId === id;
|
|
784
725
|
var payload = {
|
|
785
726
|
tabIndex: result.tabIndex,
|
|
@@ -787,33 +728,31 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
787
728
|
disabled: disabled,
|
|
788
729
|
id: id
|
|
789
730
|
};
|
|
790
|
-
|
|
791
731
|
var tabPayload = _extends({}, payload, {
|
|
792
732
|
header: header
|
|
793
733
|
});
|
|
794
|
-
|
|
795
734
|
var panelPayload = _extends({}, payload, {
|
|
796
735
|
children: children
|
|
797
736
|
});
|
|
798
|
-
|
|
799
737
|
var tabWidth = tabDimensions.has(id) ? tabDimensions.get(id).width : 0;
|
|
800
|
-
/* eslint-disable no-param-reassign */
|
|
801
738
|
|
|
802
|
-
|
|
803
|
-
!
|
|
804
|
-
|
|
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
|
|
805
746
|
result.availableWidth - tabWidth - showMoreWidth > 0) {
|
|
806
747
|
result.tabsVisible.push(tabPayload);
|
|
807
748
|
} else {
|
|
808
749
|
result.tabsHidden.push(tabPayload);
|
|
809
|
-
|
|
810
750
|
if (selected) {
|
|
811
751
|
result.isSelectedTabHidden = true;
|
|
812
752
|
}
|
|
813
753
|
}
|
|
814
754
|
/* eslint-enable no-param-reassign */
|
|
815
755
|
|
|
816
|
-
|
|
817
756
|
result.panels.set(id, panelPayload);
|
|
818
757
|
result.availableWidth -= tabWidth;
|
|
819
758
|
result.tabIndex += 1;
|
|
@@ -827,36 +766,27 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
827
766
|
availableWidth: availableWidth
|
|
828
767
|
});
|
|
829
768
|
});
|
|
830
|
-
|
|
831
769
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getActiveTabId", function (tabs) {
|
|
832
770
|
var _tabs = _slicedToArray(tabs, 1),
|
|
833
|
-
|
|
834
|
-
|
|
771
|
+
firstTab = _tabs[0];
|
|
835
772
|
if (_this.isControlledMode()) {
|
|
836
773
|
var tabId = _this.props.activeTabId;
|
|
837
|
-
|
|
838
774
|
if (tabId && tabs.some(function (tab) {
|
|
839
775
|
return tab.props.id === tabId;
|
|
840
776
|
})) {
|
|
841
777
|
return tabId;
|
|
842
778
|
}
|
|
843
|
-
|
|
844
779
|
return firstTab.props.id;
|
|
845
780
|
}
|
|
846
|
-
|
|
847
781
|
var activeTabId = _this.state.activeTabId;
|
|
848
|
-
|
|
849
782
|
if (typeof activeTabId === 'undefined') {
|
|
850
783
|
if (!(firstTab && firstTab.props)) {
|
|
851
784
|
return null;
|
|
852
785
|
}
|
|
853
|
-
|
|
854
786
|
return firstTab.props.id || null;
|
|
855
787
|
}
|
|
856
|
-
|
|
857
788
|
return activeTabId;
|
|
858
789
|
});
|
|
859
|
-
|
|
860
790
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onFocusTab", function (focusedTabKey) {
|
|
861
791
|
return function () {
|
|
862
792
|
return _this.setState({
|
|
@@ -864,29 +794,25 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
864
794
|
});
|
|
865
795
|
};
|
|
866
796
|
});
|
|
867
|
-
|
|
868
797
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onBlurTab", function () {
|
|
869
798
|
return _this.setState({
|
|
870
799
|
focusedTabKey: null
|
|
871
800
|
});
|
|
872
801
|
});
|
|
873
|
-
|
|
874
802
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onKeyDown", function (event) {
|
|
875
803
|
if (event.key === 'Enter' && _this.state.focusedTabKey !== null) {
|
|
876
804
|
_this.changeTab(_this.state.focusedTabKey);
|
|
877
805
|
}
|
|
878
806
|
});
|
|
879
|
-
|
|
880
807
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onClick", function (tab) {
|
|
881
808
|
return !tab.disabled && _this.changeTab(tab.id);
|
|
882
809
|
});
|
|
883
|
-
|
|
884
810
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTabProps", function (_ref3) {
|
|
885
811
|
var header = _ref3.header,
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
812
|
+
id = _ref3.id,
|
|
813
|
+
selected = _ref3.selected,
|
|
814
|
+
tabIndex = _ref3.tabIndex,
|
|
815
|
+
disabled = _ref3.disabled;
|
|
890
816
|
return {
|
|
891
817
|
selected: selected,
|
|
892
818
|
tabIndex: tabIndex,
|
|
@@ -897,7 +823,6 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
897
823
|
if (selected) {
|
|
898
824
|
_this.activeTabElement = tab;
|
|
899
825
|
}
|
|
900
|
-
|
|
901
826
|
_this.tabRefs.set(tabPrefix$1 + id, tab);
|
|
902
827
|
},
|
|
903
828
|
originalKey: id,
|
|
@@ -913,10 +838,9 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
913
838
|
classNames: classNames(styles['tabs__header__tab-item'], selected && styles['tabs__header__tab-item--active'], disabled && styles['tabs__header__tab-item--disabled'])
|
|
914
839
|
};
|
|
915
840
|
});
|
|
916
|
-
|
|
917
841
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getPanelProps", function (_ref4) {
|
|
918
842
|
var id = _ref4.id,
|
|
919
|
-
|
|
843
|
+
children = _ref4.children;
|
|
920
844
|
return {
|
|
921
845
|
children: children,
|
|
922
846
|
key: panelPrefix$1 + id,
|
|
@@ -924,54 +848,43 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
924
848
|
tabId: tabPrefix$1 + id
|
|
925
849
|
};
|
|
926
850
|
});
|
|
927
|
-
|
|
928
851
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "showMoreChanged", function (element) {
|
|
929
852
|
if (!element) {
|
|
930
853
|
return;
|
|
931
854
|
}
|
|
932
|
-
|
|
933
855
|
var showMoreWidth = element.offsetWidth;
|
|
934
|
-
|
|
935
856
|
if (_this.state.showMoreWidth === showMoreWidth) {
|
|
936
857
|
return;
|
|
937
858
|
}
|
|
938
|
-
|
|
939
859
|
_this.setState({
|
|
940
860
|
showMoreWidth: showMoreWidth
|
|
941
861
|
});
|
|
942
862
|
});
|
|
943
|
-
|
|
944
863
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getShowMoreProps", function (isSelectedTabHidden) {
|
|
945
864
|
return {
|
|
946
865
|
onShowMoreChanged: _this.showMoreChanged,
|
|
947
866
|
hasChildSelected: isSelectedTabHidden
|
|
948
867
|
};
|
|
949
868
|
});
|
|
950
|
-
|
|
951
869
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getSliderStyle", function (isSelectedTabHidden) {
|
|
952
870
|
return {
|
|
953
871
|
left: isSelectedTabHidden ? '100%' : _this.state.sliderLeft,
|
|
954
872
|
width: isSelectedTabHidden ? '0' : _this.state.sliderWidth
|
|
955
873
|
};
|
|
956
874
|
});
|
|
957
|
-
|
|
958
875
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getAllTabs", function () {
|
|
959
876
|
return React.Children.toArray(_this.props.children).filter(function (child) {
|
|
960
877
|
return child.type === Tab;
|
|
961
878
|
});
|
|
962
879
|
});
|
|
963
|
-
|
|
964
880
|
return _this;
|
|
965
881
|
}
|
|
966
|
-
|
|
967
882
|
_createClass(Tabs, [{
|
|
968
883
|
key: "componentDidMount",
|
|
969
884
|
value: function componentDidMount() {
|
|
970
885
|
var _this2 = this;
|
|
971
|
-
|
|
972
886
|
setTimeout(function () {
|
|
973
887
|
_this2.setTabsDimensions();
|
|
974
|
-
|
|
975
888
|
_this2.adjustSlider();
|
|
976
889
|
}, this.props.tabSizeTimeout);
|
|
977
890
|
}
|
|
@@ -980,11 +893,9 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
980
893
|
value: function componentDidUpdate(previousProps, previousState) {
|
|
981
894
|
var activeTabChanged = this.isControlledMode() ? this.props.activeTabId !== previousProps.activeTabId : this.state.activeTabId !== previousState.activeTabId;
|
|
982
895
|
var blockWidth = this.state.blockWidth;
|
|
983
|
-
|
|
984
896
|
if (activeTabChanged) {
|
|
985
897
|
this.adjustSlider();
|
|
986
898
|
}
|
|
987
|
-
|
|
988
899
|
if (!blockWidth) {
|
|
989
900
|
this.setTabsDimensions();
|
|
990
901
|
}
|
|
@@ -993,42 +904,38 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
993
904
|
key: "shouldComponentUpdate",
|
|
994
905
|
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
995
906
|
var _this$state2 = this.state,
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
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;
|
|
1003
914
|
var _this$props = this.props,
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
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;
|
|
1009
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;
|
|
1010
921
|
}
|
|
1011
922
|
}, {
|
|
1012
923
|
key: "render",
|
|
1013
924
|
value: function render() {
|
|
1014
925
|
var _this3 = this;
|
|
1015
|
-
|
|
1016
926
|
if (this.props.printMode) {
|
|
1017
927
|
return React.createElement(TabsPrint, {
|
|
1018
928
|
className: this.props.className,
|
|
1019
929
|
children: this.props.children
|
|
1020
930
|
});
|
|
1021
931
|
}
|
|
1022
|
-
|
|
1023
932
|
var allTabs = this.getAllTabs();
|
|
1024
933
|
var activeTabId = this.getActiveTabId(allTabs);
|
|
1025
|
-
|
|
1026
934
|
var _this$getTabs = this.getTabs(allTabs, this.props.shrinkToParent),
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
935
|
+
tabsVisible = _this$getTabs.tabsVisible,
|
|
936
|
+
tabsHidden = _this$getTabs.tabsHidden,
|
|
937
|
+
panels = _this$getTabs.panels,
|
|
938
|
+
isSelectedTabHidden = _this$getTabs.isSelectedTabHidden;
|
|
1032
939
|
var activeTab = panels.get(activeTabId) || allTabs[0];
|
|
1033
940
|
return React.createElement("div", {
|
|
1034
941
|
className: classNames(styles['tabs'], this.props.className)
|
|
@@ -1061,17 +968,13 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
1061
968
|
className: styles.tabs__body
|
|
1062
969
|
}, this.props.cacheOpenedTabs ? allTabs.map(function (_ref5) {
|
|
1063
970
|
var id = _ref5.props.id;
|
|
1064
|
-
|
|
1065
971
|
var shouldBeRendered = panels.has(id) && (id === activeTabId || _this3.state.cachedTabs.has(id));
|
|
1066
|
-
|
|
1067
972
|
var isHidden = id !== activeTabId;
|
|
1068
|
-
|
|
1069
973
|
if (shouldBeRendered) {
|
|
1070
974
|
return React.createElement(TabPanel, _extends({}, _this3.getPanelProps(panels.get(id)), {
|
|
1071
975
|
hidden: isHidden
|
|
1072
976
|
}));
|
|
1073
977
|
}
|
|
1074
|
-
|
|
1075
978
|
return null;
|
|
1076
979
|
}) : activeTab && React.createElement(TabPanel, this.getPanelProps(activeTab))), React.createElement(ResizeDetector, {
|
|
1077
980
|
handleWidth: true,
|
|
@@ -1096,14 +999,11 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
|
|
|
1096
999
|
cachedTabs: cachedTabs
|
|
1097
1000
|
});
|
|
1098
1001
|
}
|
|
1099
|
-
|
|
1100
1002
|
return null;
|
|
1101
1003
|
}
|
|
1102
1004
|
}]);
|
|
1103
|
-
|
|
1104
1005
|
return Tabs;
|
|
1105
1006
|
}(React.Component);
|
|
1106
|
-
|
|
1107
1007
|
_defineProperty(Tabs, "defaultProps", {
|
|
1108
1008
|
resizeThrottle: 100,
|
|
1109
1009
|
tabSizeTimeout: 200,
|
|
@@ -1112,7 +1012,6 @@ _defineProperty(Tabs, "defaultProps", {
|
|
|
1112
1012
|
printMode: false,
|
|
1113
1013
|
cacheOpenedTabs: false
|
|
1114
1014
|
});
|
|
1115
|
-
|
|
1116
1015
|
Tabs.Tab = Tab;
|
|
1117
1016
|
|
|
1118
1017
|
exports.Tabs = Tabs;
|