1 | import _typeof from 'babel-runtime/helpers/typeof';
|
2 | import React from 'react';
|
3 |
|
4 | export var triggerEvents = {
|
5 | CLICK: 'click',
|
6 | HOVER: 'hover'
|
7 | };
|
8 |
|
9 | export function getOffsetWH(node, tabPosition) {
|
10 | var prop = 'width';
|
11 | if (tabPosition === 'left' || tabPosition === 'right') {
|
12 | prop = 'height';
|
13 | }
|
14 | return node ? node.getBoundingClientRect()[prop] : 0;
|
15 | }
|
16 |
|
17 | export function getOffsetLT(node, tabPosition) {
|
18 | var prop = 'left';
|
19 | if (tabPosition === 'left' || tabPosition === 'right') {
|
20 | prop = 'top';
|
21 | }
|
22 | return node.getBoundingClientRect()[prop];
|
23 | }
|
24 |
|
25 | export function isTransformSupported(style) {
|
26 | return 'transform' in style || 'webkitTransform' in style || 'MozTransform' in style;
|
27 | }
|
28 |
|
29 | export function toArray(children) {
|
30 | var ret = [];
|
31 | React.Children.forEach(children, function (child, index) {
|
32 | if (React.isValidElement(child)) {
|
33 | ret.push(React.cloneElement(child, {
|
34 | key: child.key || index,
|
35 | title: child.props.title || child.props.tab
|
36 | }));
|
37 | }
|
38 | });
|
39 | return ret;
|
40 | }
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | export function tabsArrayShallowEqual(arrA, arrB) {
|
52 |
|
53 | if (arrA === arrB) {
|
54 | return true;
|
55 | }
|
56 |
|
57 |
|
58 | if (!arrA || !arrB || (typeof arrA === 'undefined' ? 'undefined' : _typeof(arrA)) + (typeof arrB === 'undefined' ? 'undefined' : _typeof(arrB)) !== 'objectobject' || arrA.length !== arrB.length) {
|
59 | return false;
|
60 | }
|
61 |
|
62 |
|
63 | for (var i = 0; i < arrA.length; i++) {
|
64 | if (arrA[i].key !== arrB[i].key || arrA[i].props.title !== arrB[i].props.title) {
|
65 | return false;
|
66 | }
|
67 | }
|
68 | return true;
|
69 | } |
\ | No newline at end of file |