@elliemae/ds-tabs 2.2.0-alpha.3 → 2.2.0-next.2
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/cjs/DSTabs.js +40 -58
- package/cjs/DSTabsCTX.js +25 -51
- package/cjs/DSTabsDatatestid.js +14 -42
- package/cjs/DSTabsTypes.js +2 -27
- package/cjs/config/useCrossRef.js +11 -38
- package/cjs/config/useTabs.js +36 -53
- package/cjs/defaultProps.js +13 -39
- package/cjs/exportsRelated/DSTab.js +32 -46
- package/cjs/index.js +17 -38
- package/cjs/parts/carousel/Carousel.js +53 -61
- package/cjs/parts/carousel/styles.js +63 -77
- package/cjs/parts/carousel/useCarousel.js +49 -51
- package/cjs/parts/carousel/useCarouselCallbacks.js +36 -53
- package/cjs/parts/tabBar/TabBar.js +128 -124
- package/cjs/parts/tabBar/styles.js +195 -289
- package/cjs/parts/tabBar/useTabBar.js +53 -74
- package/cjs/parts/tabsContent/TabsContent.js +45 -49
- package/cjs/parts/tabsContent/styles.js +15 -39
- package/cjs/parts/tabsPanel/TabsPanels.js +58 -60
- package/cjs/parts/tabsPanel/styles.js +23 -43
- package/cjs/propTypes.js +29 -54
- package/cjs/utils/constants.js +16 -44
- package/cjs/utils/helpers.js +50 -46
- package/cjs/utils/hooks/useKeyboardNavigation.js +43 -59
- package/cjs/utils/hooks/useTabsCallbacks.js +26 -60
- package/esm/DSTabs.js +25 -24
- package/esm/DSTabsCTX.js +20 -22
- package/esm/DSTabsDatatestid.js +10 -13
- package/esm/DSTabsTypes.js +1 -2
- package/esm/config/useCrossRef.js +4 -6
- package/esm/config/useTabs.js +22 -14
- package/esm/defaultProps.js +8 -9
- package/esm/exportsRelated/DSTab.js +19 -15
- package/esm/index.js +4 -9
- package/esm/parts/carousel/Carousel.js +38 -25
- package/esm/parts/carousel/styles.js +52 -48
- package/esm/parts/carousel/useCarousel.js +34 -15
- package/esm/parts/carousel/useCarouselCallbacks.js +28 -20
- package/esm/parts/tabBar/TabBar.js +110 -93
- package/esm/parts/tabBar/styles.js +183 -262
- package/esm/parts/tabBar/useTabBar.js +35 -35
- package/esm/parts/tabsContent/TabsContent.js +35 -19
- package/esm/parts/tabsContent/styles.js +7 -10
- package/esm/parts/tabsPanel/TabsPanels.js +45 -28
- package/esm/parts/tabsPanel/styles.js +15 -14
- package/esm/propTypes.js +24 -25
- package/esm/utils/constants.js +8 -15
- package/esm/utils/helpers.js +38 -16
- package/esm/utils/hooks/useKeyboardNavigation.js +39 -30
- package/esm/utils/hooks/useTabsCallbacks.js +21 -30
- package/package.json +6 -6
- package/types/DSTabs.d.ts +2 -2
- package/types/DSTabsTypes.d.ts +4 -0
- package/types/utils/helpers.d.ts +2 -1
- package/cjs/DSTabs.js.map +0 -7
- package/cjs/DSTabsCTX.js.map +0 -7
- package/cjs/DSTabsDatatestid.js.map +0 -7
- package/cjs/DSTabsTypes.js.map +0 -7
- package/cjs/config/useCrossRef.js.map +0 -7
- package/cjs/config/useTabs.js.map +0 -7
- package/cjs/defaultProps.js.map +0 -7
- package/cjs/exportsRelated/DSTab.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/parts/carousel/Carousel.js.map +0 -7
- package/cjs/parts/carousel/styles.js.map +0 -7
- package/cjs/parts/carousel/useCarousel.js.map +0 -7
- package/cjs/parts/carousel/useCarouselCallbacks.js.map +0 -7
- package/cjs/parts/tabBar/TabBar.js.map +0 -7
- package/cjs/parts/tabBar/styles.js.map +0 -7
- package/cjs/parts/tabBar/useTabBar.js.map +0 -7
- package/cjs/parts/tabsContent/TabsContent.js.map +0 -7
- package/cjs/parts/tabsContent/styles.js.map +0 -7
- package/cjs/parts/tabsPanel/TabsPanels.js.map +0 -7
- package/cjs/parts/tabsPanel/styles.js.map +0 -7
- package/cjs/propTypes.js.map +0 -7
- package/cjs/utils/constants.js.map +0 -7
- package/cjs/utils/helpers.js.map +0 -7
- package/cjs/utils/hooks/useKeyboardNavigation.js.map +0 -7
- package/cjs/utils/hooks/useTabsCallbacks.js.map +0 -7
- package/esm/DSTabs.js.map +0 -7
- package/esm/DSTabsCTX.js.map +0 -7
- package/esm/DSTabsDatatestid.js.map +0 -7
- package/esm/DSTabsTypes.js.map +0 -7
- package/esm/config/useCrossRef.js.map +0 -7
- package/esm/config/useTabs.js.map +0 -7
- package/esm/defaultProps.js.map +0 -7
- package/esm/exportsRelated/DSTab.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/parts/carousel/Carousel.js.map +0 -7
- package/esm/parts/carousel/styles.js.map +0 -7
- package/esm/parts/carousel/useCarousel.js.map +0 -7
- package/esm/parts/carousel/useCarouselCallbacks.js.map +0 -7
- package/esm/parts/tabBar/TabBar.js.map +0 -7
- package/esm/parts/tabBar/styles.js.map +0 -7
- package/esm/parts/tabBar/useTabBar.js.map +0 -7
- package/esm/parts/tabsContent/TabsContent.js.map +0 -7
- package/esm/parts/tabsContent/styles.js.map +0 -7
- package/esm/parts/tabsPanel/TabsPanels.js.map +0 -7
- package/esm/parts/tabsPanel/styles.js.map +0 -7
- package/esm/propTypes.js.map +0 -7
- package/esm/utils/constants.js.map +0 -7
- package/esm/utils/helpers.js.map +0 -7
- package/esm/utils/hooks/useKeyboardNavigation.js.map +0 -7
- package/esm/utils/hooks/useTabsCallbacks.js.map +0 -7
package/cjs/utils/helpers.js
CHANGED
|
@@ -1,48 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var helpers_exports = {};
|
|
29
|
-
__export(helpers_exports, {
|
|
30
|
-
getIdByIndex: () => getIdByIndex,
|
|
31
|
-
getIndexById: () => getIndexById,
|
|
32
|
-
getVisibleDimensions: () => getVisibleDimensions,
|
|
33
|
-
isElementVisible: () => isElementVisible,
|
|
34
|
-
isElementVisibleCarousel: () => isElementVisibleCarousel,
|
|
35
|
-
shouldHaveLeftGradient: () => shouldHaveLeftGradient,
|
|
36
|
-
shouldHaveRightGradient: () => shouldHaveRightGradient
|
|
37
|
-
});
|
|
38
|
-
var React = __toESM(require("react"));
|
|
39
|
-
var import_constants = __toESM(require("./constants"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var constants = require('./constants.js');
|
|
6
|
+
|
|
40
7
|
const isElementVisible = (tab, tabList) => {
|
|
41
8
|
const tabDimensions = tab.getBoundingClientRect();
|
|
42
9
|
const tabListDimensions = tabList.getBoundingClientRect();
|
|
43
10
|
return tabDimensions.left <= tabListDimensions.left ? tabListDimensions.left - tabDimensions.left <= tabDimensions.width : tabDimensions.right - tabListDimensions.right <= tabDimensions.width;
|
|
44
11
|
};
|
|
45
|
-
const isElementVisibleCarousel = (tab, tabContainer
|
|
12
|
+
const isElementVisibleCarousel = function (tab, tabContainer) {
|
|
13
|
+
let firstOrLastItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
14
|
+
|
|
46
15
|
if (tab && tabContainer) {
|
|
47
16
|
const tabDimensions = tab.getBoundingClientRect();
|
|
48
17
|
const tabContainerDimensions = tabContainer.getBoundingClientRect();
|
|
@@ -53,8 +22,36 @@ const isElementVisibleCarousel = (tab, tabContainer, firstOrLastItem = true) =>
|
|
|
53
22
|
const tabContainerDimensionsRight = Math.floor(tabContainerDimensions.right);
|
|
54
23
|
return tabDimensionsLeft >= tabContainerDimensionsLeft && tabDimensionsRight <= tabContainerDimensionsRight;
|
|
55
24
|
}
|
|
25
|
+
|
|
56
26
|
return false;
|
|
57
27
|
};
|
|
28
|
+
const centerTab = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
e,
|
|
31
|
+
listRef
|
|
32
|
+
} = _ref;
|
|
33
|
+
|
|
34
|
+
if (listRef.current) {
|
|
35
|
+
const {
|
|
36
|
+
offsetLeft
|
|
37
|
+
} = e === null || e === void 0 ? void 0 : e.target;
|
|
38
|
+
const {
|
|
39
|
+
width: tabWidth
|
|
40
|
+
} = (e === null || e === void 0 ? void 0 : e.target).getBoundingClientRect();
|
|
41
|
+
const {
|
|
42
|
+
width: listWidth
|
|
43
|
+
} = listRef.current.getBoundingClientRect();
|
|
44
|
+
const extraSideSpace = listWidth - tabWidth;
|
|
45
|
+
const leftOffsetToCenter = extraSideSpace > 0 ? extraSideSpace / 2 : 0;
|
|
46
|
+
const centeredLeftOffset = offsetLeft > leftOffsetToCenter ? offsetLeft - leftOffsetToCenter : 0;
|
|
47
|
+
listRef.current.scrollTo({
|
|
48
|
+
top: 0,
|
|
49
|
+
left: centeredLeftOffset,
|
|
50
|
+
behavior: 'smooth'
|
|
51
|
+
});
|
|
52
|
+
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
58
55
|
const getVisibleDimensions = (node, referenceNode) => {
|
|
59
56
|
const nodeDimensions = node.getBoundingClientRect();
|
|
60
57
|
const referenceNodeDimensions = referenceNode.getBoundingClientRect();
|
|
@@ -63,9 +60,16 @@ const getVisibleDimensions = (node, referenceNode) => {
|
|
|
63
60
|
height: Math.min(node.clientHeight, referenceNodeDimensions.top + referenceNode.clientHeight - nodeDimensions.top, node.clientHeight - (referenceNodeDimensions.top - nodeDimensions.top))
|
|
64
61
|
};
|
|
65
62
|
};
|
|
66
|
-
const getIndexById = (children, activeId) => children && children.findIndex(
|
|
67
|
-
const getIdByIndex = (children, index) => children && children[index].props.tabId ||
|
|
68
|
-
const shouldHaveLeftGradient =
|
|
69
|
-
const shouldHaveRightGradient = (scrollLeft, clientWidth, scrollWidth) => Math.abs(scrollLeft) <= scrollWidth - (clientWidth +
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
const getIndexById = (children, activeId) => children && children.findIndex(item => item.props.tabId === activeId);
|
|
64
|
+
const getIdByIndex = (children, index) => children && children[index].props.tabId || '';
|
|
65
|
+
const shouldHaveLeftGradient = scrollLeft => Math.abs(scrollLeft) > constants.MOBILE_GRADIENT_WIDTH;
|
|
66
|
+
const shouldHaveRightGradient = (scrollLeft, clientWidth, scrollWidth) => Math.abs(scrollLeft) <= scrollWidth - (clientWidth + constants.MOBILE_GRADIENT_WIDTH);
|
|
67
|
+
|
|
68
|
+
exports.centerTab = centerTab;
|
|
69
|
+
exports.getIdByIndex = getIdByIndex;
|
|
70
|
+
exports.getIndexById = getIndexById;
|
|
71
|
+
exports.getVisibleDimensions = getVisibleDimensions;
|
|
72
|
+
exports.isElementVisible = isElementVisible;
|
|
73
|
+
exports.isElementVisibleCarousel = isElementVisibleCarousel;
|
|
74
|
+
exports.shouldHaveLeftGradient = shouldHaveLeftGradient;
|
|
75
|
+
exports.shouldHaveRightGradient = shouldHaveRightGradient;
|
|
@@ -1,77 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useKeyboardNavigation_exports = {};
|
|
29
|
-
__export(useKeyboardNavigation_exports, {
|
|
30
|
-
useKeyboardNavigation: () => useKeyboardNavigation
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = __toESM(require("react"));
|
|
34
|
-
var import_DSTabsCTX = __toESM(require("../../DSTabsCTX"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var DSTabsCTX = require('../../DSTabsCTX.js');
|
|
7
|
+
|
|
8
|
+
/* eslint-disable max-statements */
|
|
35
9
|
const useKeyboardNavigation = () => {
|
|
36
|
-
const {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
10
|
+
const {
|
|
11
|
+
focusableTabsRef
|
|
12
|
+
} = React.useContext(DSTabsCTX.DSTabsContext);
|
|
13
|
+
const {
|
|
14
|
+
firstSubtabInternalRef,
|
|
15
|
+
lastTabInternalRef
|
|
16
|
+
} = React.useContext(DSTabsCTX.DSTabsCrossRefContext);
|
|
17
|
+
const handleOnKeyDown = React.useCallback(e => {
|
|
18
|
+
if (e.key === 'ArrowRight' && focusableTabsRef.current) {
|
|
19
|
+
var _focusableTabsRef$cur, _focusableTabsRef$cur2;
|
|
20
|
+
|
|
40
21
|
e.preventDefault();
|
|
41
22
|
e.stopPropagation();
|
|
42
|
-
const nextTab = focusableTabsRef.current[focusableTabsRef
|
|
43
|
-
if (nextTab)
|
|
44
|
-
|
|
45
|
-
if (!nextTab)
|
|
46
|
-
return;
|
|
23
|
+
const nextTab = focusableTabsRef.current[(focusableTabsRef === null || focusableTabsRef === void 0 ? void 0 : (_focusableTabsRef$cur = focusableTabsRef.current) === null || _focusableTabsRef$cur === void 0 ? void 0 : (_focusableTabsRef$cur2 = _focusableTabsRef$cur.indexOf) === null || _focusableTabsRef$cur2 === void 0 ? void 0 : _focusableTabsRef$cur2.call(_focusableTabsRef$cur, e.target)) + 1];
|
|
24
|
+
if (nextTab) nextTab.focus();
|
|
25
|
+
if (!nextTab) return;
|
|
47
26
|
}
|
|
48
|
-
|
|
27
|
+
|
|
28
|
+
if (e.key === 'ArrowLeft' && focusableTabsRef.current) {
|
|
29
|
+
var _focusableTabsRef$cur3, _focusableTabsRef$cur4;
|
|
30
|
+
|
|
49
31
|
e.preventDefault();
|
|
50
32
|
e.stopPropagation();
|
|
51
|
-
const prevTab = focusableTabsRef.current[focusableTabsRef
|
|
52
|
-
if (prevTab)
|
|
53
|
-
|
|
54
|
-
if (!prevTab)
|
|
55
|
-
return;
|
|
33
|
+
const prevTab = focusableTabsRef.current[(focusableTabsRef === null || focusableTabsRef === void 0 ? void 0 : (_focusableTabsRef$cur3 = focusableTabsRef.current) === null || _focusableTabsRef$cur3 === void 0 ? void 0 : (_focusableTabsRef$cur4 = _focusableTabsRef$cur3.indexOf) === null || _focusableTabsRef$cur4 === void 0 ? void 0 : _focusableTabsRef$cur4.call(_focusableTabsRef$cur3, e.target)) - 1];
|
|
34
|
+
if (prevTab) prevTab.focus();
|
|
35
|
+
if (!prevTab) return;
|
|
56
36
|
}
|
|
57
|
-
|
|
37
|
+
|
|
38
|
+
if (e.key === 'ArrowDown') {
|
|
39
|
+
var _firstSubtabInternalR;
|
|
40
|
+
|
|
58
41
|
e.preventDefault();
|
|
59
42
|
e.stopPropagation();
|
|
60
|
-
const canFocusCrossTabs = firstSubtabInternalRef
|
|
61
|
-
if (canFocusCrossTabs)
|
|
62
|
-
firstSubtabInternalRef.current?.focus();
|
|
43
|
+
const canFocusCrossTabs = (firstSubtabInternalRef === null || firstSubtabInternalRef === void 0 ? void 0 : firstSubtabInternalRef.current) && (lastTabInternalRef === null || lastTabInternalRef === void 0 ? void 0 : lastTabInternalRef.current);
|
|
44
|
+
if (canFocusCrossTabs) (_firstSubtabInternalR = firstSubtabInternalRef.current) === null || _firstSubtabInternalR === void 0 ? void 0 : _firstSubtabInternalR.focus();
|
|
63
45
|
}
|
|
64
|
-
|
|
46
|
+
|
|
47
|
+
if (e.key === 'ArrowUp') {
|
|
48
|
+
var _lastTabInternalRef$c;
|
|
49
|
+
|
|
65
50
|
e.preventDefault();
|
|
66
51
|
e.stopPropagation();
|
|
67
|
-
const canFocusCrossTabs = firstSubtabInternalRef
|
|
68
|
-
if (canFocusCrossTabs)
|
|
69
|
-
lastTabInternalRef.current?.focus();
|
|
52
|
+
const canFocusCrossTabs = (firstSubtabInternalRef === null || firstSubtabInternalRef === void 0 ? void 0 : firstSubtabInternalRef.current) && (lastTabInternalRef === null || lastTabInternalRef === void 0 ? void 0 : lastTabInternalRef.current);
|
|
53
|
+
if (canFocusCrossTabs) (_lastTabInternalRef$c = lastTabInternalRef.current) === null || _lastTabInternalRef$c === void 0 ? void 0 : _lastTabInternalRef$c.focus();
|
|
70
54
|
}
|
|
71
55
|
}, [firstSubtabInternalRef, lastTabInternalRef, focusableTabsRef]);
|
|
72
56
|
return {
|
|
73
57
|
handleOnKeyDown
|
|
74
58
|
};
|
|
75
59
|
};
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
|
|
61
|
+
exports.useKeyboardNavigation = useKeyboardNavigation;
|
|
@@ -1,75 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useTabsCallbacks_exports = {};
|
|
29
|
-
__export(useTabsCallbacks_exports, {
|
|
30
|
-
useTabsCallbacks: () => useTabsCallbacks
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = __toESM(require("react"));
|
|
34
|
-
var import_DSTabsCTX = __toESM(require("../../DSTabsCTX"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var helpers = require('../helpers.js');
|
|
7
|
+
var DSTabsCTX = require('../../DSTabsCTX.js');
|
|
8
|
+
|
|
35
9
|
const useTabsCallbacks = () => {
|
|
36
10
|
const {
|
|
37
11
|
setInternalActiveTab,
|
|
38
12
|
tabsListRef,
|
|
39
|
-
props: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const { width: tabWidth } = (e?.target).getBoundingClientRect();
|
|
45
|
-
const { width: listWidth } = tabsListRef.current.getBoundingClientRect();
|
|
46
|
-
const extraSideSpace = listWidth - tabWidth;
|
|
47
|
-
const leftOffsetToCenter = extraSideSpace > 0 ? extraSideSpace / 2 : 0;
|
|
48
|
-
const centeredLeftOffset = offsetLeft > leftOffsetToCenter ? offsetLeft - leftOffsetToCenter : 0;
|
|
49
|
-
tabsListRef.current.scrollTo({
|
|
50
|
-
top: 0,
|
|
51
|
-
left: centeredLeftOffset,
|
|
52
|
-
behavior: "smooth"
|
|
53
|
-
});
|
|
54
|
-
e?.preventDefault();
|
|
13
|
+
props: {
|
|
14
|
+
onTabChange,
|
|
15
|
+
isDSMobile,
|
|
16
|
+
allowTextSelection,
|
|
17
|
+
fixedTabsHeaders
|
|
55
18
|
}
|
|
56
|
-
}
|
|
57
|
-
const handleOnTabChange =
|
|
19
|
+
} = React.useContext(DSTabsCTX.DSTabsContext);
|
|
20
|
+
const handleOnTabChange = React.useCallback((tabId, e) => {
|
|
58
21
|
setInternalActiveTab(tabId);
|
|
59
22
|
onTabChange(tabId, e);
|
|
23
|
+
|
|
60
24
|
if (isDSMobile && !fixedTabsHeaders && e) {
|
|
61
|
-
|
|
25
|
+
helpers.centerTab({
|
|
26
|
+
e,
|
|
27
|
+
listRef: tabsListRef
|
|
28
|
+
});
|
|
62
29
|
}
|
|
63
|
-
}, [
|
|
64
|
-
const handleOnMouseDown =
|
|
65
|
-
const role = e.target.getAttribute(
|
|
66
|
-
if (role !==
|
|
67
|
-
e.stopPropagation();
|
|
30
|
+
}, [fixedTabsHeaders, isDSMobile, onTabChange, setInternalActiveTab, tabsListRef]);
|
|
31
|
+
const handleOnMouseDown = React.useCallback(e => {
|
|
32
|
+
const role = e.target.getAttribute('role');
|
|
33
|
+
if (role !== 'tabpanel' && allowTextSelection) e.stopPropagation();
|
|
68
34
|
}, [allowTextSelection]);
|
|
69
35
|
return {
|
|
70
36
|
handleOnTabChange,
|
|
71
37
|
handleOnMouseDown
|
|
72
38
|
};
|
|
73
39
|
};
|
|
74
|
-
|
|
75
|
-
|
|
40
|
+
|
|
41
|
+
exports.useTabsCallbacks = useTabsCallbacks;
|
package/esm/DSTabs.js
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { describe } from 'react-desc';
|
|
3
|
+
import { tabsPropTypes } from './propTypes.js';
|
|
4
|
+
import { DSTabsContext, DSTabsCrossRefContext } from './DSTabsCTX.js';
|
|
5
|
+
import { TabsContent } from './parts/tabsContent/TabsContent.js';
|
|
6
|
+
import { useTabs } from './config/useTabs.js';
|
|
7
|
+
import { useCrossRef } from './config/useCrossRef.js';
|
|
8
|
+
import { TabTypes } from './utils/constants.js';
|
|
9
|
+
|
|
10
|
+
var _TabsContent, _TabsContent2;
|
|
11
|
+
|
|
12
|
+
const DSTabs = props => {
|
|
11
13
|
const ctx = useTabs(props);
|
|
12
14
|
const crossRefsCtx = useCrossRef();
|
|
13
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
type
|
|
17
|
+
} = props;
|
|
18
|
+
|
|
14
19
|
if (type === TabTypes.SUBTABS) {
|
|
15
|
-
return
|
|
20
|
+
return /*#__PURE__*/_jsx(DSTabsContext.Provider, {
|
|
16
21
|
value: ctx
|
|
17
|
-
},
|
|
22
|
+
}, void 0, _TabsContent || (_TabsContent = /*#__PURE__*/_jsx(TabsContent, {})));
|
|
18
23
|
}
|
|
19
|
-
|
|
24
|
+
|
|
25
|
+
return /*#__PURE__*/_jsx(DSTabsCrossRefContext.Provider, {
|
|
20
26
|
value: crossRefsCtx
|
|
21
|
-
},
|
|
27
|
+
}, void 0, /*#__PURE__*/_jsx(DSTabsContext.Provider, {
|
|
22
28
|
value: ctx
|
|
23
|
-
},
|
|
29
|
+
}, void 0, _TabsContent2 || (_TabsContent2 = /*#__PURE__*/_jsx(TabsContent, {}))));
|
|
24
30
|
};
|
|
25
|
-
|
|
31
|
+
|
|
26
32
|
const DSTabsWithSchema = describe(DSTabs);
|
|
27
33
|
DSTabsWithSchema.propTypes = tabsPropTypes;
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
DSTabs,
|
|
31
|
-
DSTabsWithSchema,
|
|
32
|
-
DSTabs_default as default
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=DSTabs.js.map
|
|
34
|
+
|
|
35
|
+
export { DSTabs, DSTabsWithSchema, DSTabs as default };
|
package/esm/DSTabsCTX.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
import { createContext, createRef } from 'react';
|
|
2
|
+
import { tabsDefaultProps } from './defaultProps.js';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5
|
+
const noop = () => {};
|
|
6
|
+
|
|
6
7
|
const defaultContext = {
|
|
7
|
-
props:
|
|
8
|
-
tabsRef: createRef(),
|
|
9
|
-
tabsListRef: createRef(),
|
|
10
|
-
carouselOnlyListRef: createRef(),
|
|
11
|
-
focusableTabsRef: createRef(),
|
|
12
|
-
tabsRefAsArray: createRef(),
|
|
13
|
-
actualActiveTabRef: createRef(),
|
|
8
|
+
props: tabsDefaultProps,
|
|
9
|
+
tabsRef: /*#__PURE__*/createRef(),
|
|
10
|
+
tabsListRef: /*#__PURE__*/createRef(),
|
|
11
|
+
carouselOnlyListRef: /*#__PURE__*/createRef(),
|
|
12
|
+
focusableTabsRef: /*#__PURE__*/createRef(),
|
|
13
|
+
tabsRefAsArray: /*#__PURE__*/createRef(),
|
|
14
|
+
actualActiveTabRef: /*#__PURE__*/createRef(),
|
|
14
15
|
setInternalActiveTab: noop,
|
|
15
|
-
actualActiveTab:
|
|
16
|
+
actualActiveTab: ''
|
|
16
17
|
};
|
|
17
18
|
const defaultCrossRefsContext = {
|
|
18
|
-
lastTabInternalRef: createRef(),
|
|
19
|
-
firstSubtabInternalRef: createRef()
|
|
20
|
-
};
|
|
21
|
-
const DSTabsContext = createContext(defaultContext);
|
|
22
|
-
const DSTabsCrossRefContext = createContext(defaultCrossRefsContext);
|
|
23
|
-
export {
|
|
24
|
-
DSTabsContext,
|
|
25
|
-
DSTabsCrossRefContext
|
|
19
|
+
lastTabInternalRef: /*#__PURE__*/createRef(),
|
|
20
|
+
firstSubtabInternalRef: /*#__PURE__*/createRef()
|
|
26
21
|
};
|
|
27
|
-
|
|
22
|
+
const DSTabsContext = /*#__PURE__*/createContext(defaultContext);
|
|
23
|
+
const DSTabsCrossRefContext = /*#__PURE__*/createContext(defaultCrossRefsContext);
|
|
24
|
+
|
|
25
|
+
export { DSTabsContext, DSTabsCrossRefContext };
|
package/esm/DSTabsDatatestid.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
const DSTabsDatatestid = {
|
|
3
|
-
TABS_CONTAINER:
|
|
4
|
-
TAB_BUTTON:
|
|
5
|
-
SUBTAB_BUTTON:
|
|
6
|
-
TAB_PANEL:
|
|
7
|
-
SUB_TAB_LIST:
|
|
8
|
-
TAB_LIST:
|
|
2
|
+
TABS_CONTAINER: 'ds-tabs-container',
|
|
3
|
+
TAB_BUTTON: 'ds-tabs-tab-button',
|
|
4
|
+
SUBTAB_BUTTON: 'ds-tabs-subtab-button',
|
|
5
|
+
TAB_PANEL: 'ds-tabs-tab-panel',
|
|
6
|
+
SUB_TAB_LIST: 'subtabs-list',
|
|
7
|
+
TAB_LIST: 'tab-list',
|
|
9
8
|
CAROUSEL: {
|
|
10
|
-
BUTTON_RIGHT:
|
|
11
|
-
BUTTON_LEFT:
|
|
9
|
+
BUTTON_RIGHT: 'chevron-right',
|
|
10
|
+
BUTTON_LEFT: 'chevron-left'
|
|
12
11
|
}
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=DSTabsDatatestid.js.map
|
|
13
|
+
|
|
14
|
+
export { DSTabsDatatestid };
|
package/esm/DSTabsTypes.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=DSTabsTypes.js.map
|
|
1
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { useRef, useMemo } from 'react';
|
|
2
|
+
|
|
3
3
|
const useCrossRef = () => {
|
|
4
4
|
const firstSubtabInternalRef = useRef();
|
|
5
5
|
const lastTabInternalRef = useRef();
|
|
@@ -9,7 +9,5 @@ const useCrossRef = () => {
|
|
|
9
9
|
}), []);
|
|
10
10
|
return ctx;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=useCrossRef.js.map
|
|
12
|
+
|
|
13
|
+
export { useCrossRef };
|
package/esm/config/useTabs.js
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
5
|
+
import { useRef, useState, useMemo, useEffect } from 'react';
|
|
6
|
+
import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
7
|
+
import { tabsDefaultProps } from '../defaultProps.js';
|
|
8
|
+
|
|
9
|
+
const useTabs = props => {
|
|
10
|
+
var _children$, _children$$props;
|
|
11
|
+
|
|
6
12
|
const propsWithDefaults = useMemoMergePropsWithDefault(props, tabsDefaultProps);
|
|
7
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
activeTab,
|
|
15
|
+
children
|
|
16
|
+
} = propsWithDefaults;
|
|
8
17
|
const tabsRef = useRef({});
|
|
9
18
|
const tabsRefAsArray = useRef([]);
|
|
10
19
|
const focusableTabsRef = useRef([]);
|
|
11
20
|
const carouselOnlyListRef = useRef(null);
|
|
12
21
|
const tabsListRef = useRef(null);
|
|
13
22
|
const actualActiveTabRef = useRef(null);
|
|
14
|
-
const [internalActiveTab, setInternalActiveTab] = useState(children
|
|
23
|
+
const [internalActiveTab, setInternalActiveTab] = useState(children === null || children === void 0 ? void 0 : (_children$ = children[0]) === null || _children$ === void 0 ? void 0 : (_children$$props = _children$.props) === null || _children$$props === void 0 ? void 0 : _children$$props.tabId);
|
|
15
24
|
const actualActiveTab = useMemo(() => {
|
|
16
|
-
if (activeTab !==
|
|
17
|
-
return activeTab;
|
|
25
|
+
if (activeTab !== undefined) return activeTab;
|
|
18
26
|
return internalActiveTab;
|
|
19
27
|
}, [activeTab, internalActiveTab]);
|
|
20
28
|
useEffect(() => {
|
|
21
|
-
|
|
29
|
+
var _focusableTabsRef$cur;
|
|
30
|
+
|
|
31
|
+
actualActiveTabRef.current = (_focusableTabsRef$cur = focusableTabsRef.current.find(el => el.dataset.tabId === actualActiveTab)) !== null && _focusableTabsRef$cur !== void 0 ? _focusableTabsRef$cur : null;
|
|
22
32
|
}, [actualActiveTab]);
|
|
23
33
|
const ctx = useMemo(() => ({
|
|
24
34
|
props: propsWithDefaults,
|
|
@@ -33,7 +43,5 @@ const useTabs = (props) => {
|
|
|
33
43
|
}), [actualActiveTab, propsWithDefaults]);
|
|
34
44
|
return ctx;
|
|
35
45
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=useTabs.js.map
|
|
46
|
+
|
|
47
|
+
export { useTabs };
|
package/esm/defaultProps.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
1
|
+
import { TabTypes } from './utils/constants.js';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4
|
+
const noop = () => {};
|
|
5
|
+
|
|
5
6
|
const tabsDefaultProps = {
|
|
6
7
|
containerProps: {},
|
|
7
8
|
animated: true,
|
|
8
9
|
enableMouseEvents: false,
|
|
9
10
|
allowTextSelection: false,
|
|
10
11
|
onTabChange: noop,
|
|
11
|
-
tabsListAriaLabel:
|
|
12
|
+
tabsListAriaLabel: 'Tab list',
|
|
12
13
|
type: TabTypes.NORMAL,
|
|
13
14
|
onlyRenderActiveTab: false,
|
|
14
15
|
withCarousel: false,
|
|
@@ -18,7 +19,5 @@ const tabsDefaultProps = {
|
|
|
18
19
|
fixedTabsHeaders: false,
|
|
19
20
|
showSeparator: true
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=defaultProps.js.map
|
|
22
|
+
|
|
23
|
+
export { tabsDefaultProps };
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { describe } from 'react-desc';
|
|
9
|
+
import { tabPropTypes } from '../propTypes.js';
|
|
10
|
+
import { jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
|
|
16
|
+
const DSTab = props => /*#__PURE__*/jsx(React.Fragment, _objectSpread({}, props));
|
|
17
|
+
|
|
9
18
|
const DSTabWithSchema = describe(DSTab);
|
|
10
19
|
DSTabWithSchema.propTypes = tabPropTypes;
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
DSTab,
|
|
14
|
-
DSTabWithSchema,
|
|
15
|
-
DSTab_default as default
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=DSTab.js.map
|
|
20
|
+
|
|
21
|
+
export { DSTab, DSTabWithSchema, DSTab as default };
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
export * from "./DSTabsDatatestid";
|
|
6
|
-
export {
|
|
7
|
-
TabTypes
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { DSTab, DSTabWithSchema } from './exportsRelated/DSTab.js';
|
|
2
|
+
export { DSTabs, DSTabsWithSchema } from './DSTabs.js';
|
|
3
|
+
export { TabTypes } from './utils/constants.js';
|
|
4
|
+
export { DSTabsDatatestid } from './DSTabsDatatestid.js';
|