@elliemae/ds-tabs 2.2.0-alpha.2 → 2.2.0-beta.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/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 +120 -124
- package/cjs/parts/tabBar/styles.js +195 -289
- package/cjs/parts/tabBar/useTabBar.js +55 -67
- 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 +22 -46
- package/cjs/utils/hooks/useKeyboardNavigation.js +43 -59
- package/cjs/utils/hooks/useTabsCallbacks.js +33 -49
- 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 +102 -93
- package/esm/parts/tabBar/styles.js +183 -262
- package/esm/parts/tabBar/useTabBar.js +36 -27
- 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 +11 -16
- package/esm/utils/hooks/useKeyboardNavigation.js +39 -30
- package/esm/utils/hooks/useTabsCallbacks.js +27 -18
- package/package.json +6 -6
- package/types/DSTabs.d.ts +2 -2
- 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
|
@@ -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,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
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 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 DSTabsCTX = require('../../DSTabsCTX.js');
|
|
7
|
+
|
|
35
8
|
const useTabsCallbacks = () => {
|
|
36
9
|
const {
|
|
37
10
|
setInternalActiveTab,
|
|
38
11
|
tabsListRef,
|
|
39
|
-
props: {
|
|
40
|
-
|
|
41
|
-
|
|
12
|
+
props: {
|
|
13
|
+
onTabChange,
|
|
14
|
+
isDSMobile,
|
|
15
|
+
allowTextSelection,
|
|
16
|
+
fixedTabsHeaders
|
|
17
|
+
}
|
|
18
|
+
} = React.useContext(DSTabsCTX.DSTabsContext);
|
|
19
|
+
const centerTabWhenTabChangeMobile = React.useCallback(e => {
|
|
42
20
|
if (tabsListRef.current) {
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
const {
|
|
22
|
+
offsetLeft
|
|
23
|
+
} = e === null || e === void 0 ? void 0 : e.target;
|
|
24
|
+
const {
|
|
25
|
+
width: tabWidth
|
|
26
|
+
} = (e === null || e === void 0 ? void 0 : e.target).getBoundingClientRect();
|
|
27
|
+
const {
|
|
28
|
+
width: listWidth
|
|
29
|
+
} = tabsListRef.current.getBoundingClientRect();
|
|
46
30
|
const extraSideSpace = listWidth - tabWidth;
|
|
47
31
|
const leftOffsetToCenter = extraSideSpace > 0 ? extraSideSpace / 2 : 0;
|
|
48
32
|
const centeredLeftOffset = offsetLeft > leftOffsetToCenter ? offsetLeft - leftOffsetToCenter : 0;
|
|
49
33
|
tabsListRef.current.scrollTo({
|
|
50
34
|
top: 0,
|
|
51
35
|
left: centeredLeftOffset,
|
|
52
|
-
behavior:
|
|
36
|
+
behavior: 'smooth'
|
|
53
37
|
});
|
|
54
|
-
e
|
|
38
|
+
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
55
39
|
}
|
|
56
40
|
}, [tabsListRef]);
|
|
57
|
-
const handleOnTabChange =
|
|
41
|
+
const handleOnTabChange = React.useCallback((tabId, e) => {
|
|
58
42
|
setInternalActiveTab(tabId);
|
|
59
43
|
onTabChange(tabId, e);
|
|
44
|
+
|
|
60
45
|
if (isDSMobile && !fixedTabsHeaders && e) {
|
|
61
46
|
centerTabWhenTabChangeMobile(e);
|
|
62
47
|
}
|
|
63
48
|
}, [centerTabWhenTabChangeMobile, fixedTabsHeaders, isDSMobile, onTabChange, setInternalActiveTab]);
|
|
64
|
-
const handleOnMouseDown =
|
|
65
|
-
const role = e.target.getAttribute(
|
|
66
|
-
if (role !==
|
|
67
|
-
e.stopPropagation();
|
|
49
|
+
const handleOnMouseDown = React.useCallback(e => {
|
|
50
|
+
const role = e.target.getAttribute('role');
|
|
51
|
+
if (role !== 'tabpanel' && allowTextSelection) e.stopPropagation();
|
|
68
52
|
}, [allowTextSelection]);
|
|
69
53
|
return {
|
|
70
54
|
handleOnTabChange,
|
|
71
55
|
handleOnMouseDown
|
|
72
56
|
};
|
|
73
57
|
};
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
|
|
59
|
+
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';
|
|
@@ -1,48 +1,61 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useContext } from
|
|
3
|
-
import { DSIconSizes } from
|
|
4
|
-
import { BUTTON_TYPES } from
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useCarousel } from
|
|
8
|
-
import { DSTabsContext } from
|
|
9
|
-
import { DSTabsDatatestid } from
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { DSIconSizes } from '@elliemae/ds-icon';
|
|
4
|
+
import { BUTTON_TYPES } from '@elliemae/ds-button';
|
|
5
|
+
import { ChevronLeft, ChevronRight } from '@elliemae/ds-icons';
|
|
6
|
+
import { StyledCarouselWrapper, StyledCarouselButtonWrapper, StyledCarouselBtn, StyledChildrenWrap } from './styles.js';
|
|
7
|
+
import { useCarousel } from './useCarousel.js';
|
|
8
|
+
import { DSTabsContext } from '../../DSTabsCTX.js';
|
|
9
|
+
import { DSTabsDatatestid } from '../../DSTabsDatatestid.js';
|
|
10
|
+
import { jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
const Carousel = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
updateIndicatorStyle
|
|
16
|
+
} = _ref;
|
|
17
|
+
const {
|
|
18
|
+
showChevrons,
|
|
19
|
+
leftButtonOnClick,
|
|
20
|
+
rightButtonOnClick,
|
|
21
|
+
handleOnClick,
|
|
22
|
+
handleOnScroll
|
|
23
|
+
} = useCarousel({
|
|
12
24
|
updateIndicatorStyle
|
|
13
25
|
});
|
|
14
26
|
const {
|
|
15
27
|
carouselOnlyListRef,
|
|
16
|
-
props: {
|
|
28
|
+
props: {
|
|
29
|
+
type
|
|
30
|
+
}
|
|
17
31
|
} = useContext(DSTabsContext);
|
|
18
|
-
return
|
|
32
|
+
return /*#__PURE__*/_jsx(StyledCarouselWrapper, {}, void 0, showChevrons.left && /*#__PURE__*/_jsx(StyledCarouselButtonWrapper, {
|
|
19
33
|
tabType: type
|
|
20
|
-
},
|
|
34
|
+
}, void 0, /*#__PURE__*/_jsx(StyledCarouselBtn, {
|
|
21
35
|
size: "s",
|
|
22
36
|
onClick: leftButtonOnClick,
|
|
23
37
|
tabIndex: -1,
|
|
24
38
|
"data-testid": DSTabsDatatestid.CAROUSEL.BUTTON_LEFT,
|
|
25
39
|
buttonType: BUTTON_TYPES.ICON
|
|
26
|
-
},
|
|
40
|
+
}, void 0, /*#__PURE__*/_jsx(ChevronLeft, {
|
|
27
41
|
size: DSIconSizes.S
|
|
28
|
-
}))), showChevrons.right &&
|
|
42
|
+
}))), showChevrons.right && /*#__PURE__*/_jsx(StyledCarouselButtonWrapper, {
|
|
29
43
|
tabType: type,
|
|
30
44
|
right: showChevrons.right
|
|
31
|
-
},
|
|
45
|
+
}, void 0, /*#__PURE__*/_jsx(StyledCarouselBtn, {
|
|
32
46
|
size: "s",
|
|
33
47
|
onClick: rightButtonOnClick,
|
|
34
48
|
tabIndex: -1,
|
|
35
49
|
"data-testid": DSTabsDatatestid.CAROUSEL.BUTTON_RIGHT,
|
|
36
50
|
buttonType: BUTTON_TYPES.ICON
|
|
37
|
-
},
|
|
51
|
+
}, void 0, /*#__PURE__*/_jsx(ChevronRight, {
|
|
38
52
|
size: DSIconSizes.S
|
|
39
|
-
}))),
|
|
53
|
+
}))), /*#__PURE__*/jsx(StyledChildrenWrap, {
|
|
40
54
|
ref: carouselOnlyListRef,
|
|
41
55
|
onClick: handleOnClick,
|
|
42
|
-
onScroll: handleOnScroll
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
export {
|
|
46
|
-
Carousel
|
|
56
|
+
onScroll: handleOnScroll,
|
|
57
|
+
children: children
|
|
58
|
+
}));
|
|
47
59
|
};
|
|
48
|
-
|
|
60
|
+
|
|
61
|
+
export { Carousel };
|