@elliemae/ds-tabs 2.1.0 → 2.2.0-alpha.3
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 +58 -40
- package/cjs/DSTabs.js.map +7 -0
- package/cjs/DSTabsCTX.js +51 -25
- package/cjs/DSTabsCTX.js.map +7 -0
- package/cjs/DSTabsDatatestid.js +42 -14
- package/cjs/DSTabsDatatestid.js.map +7 -0
- package/cjs/DSTabsTypes.js +27 -2
- package/cjs/DSTabsTypes.js.map +7 -0
- package/cjs/config/useCrossRef.js +38 -11
- package/cjs/config/useCrossRef.js.map +7 -0
- package/cjs/config/useTabs.js +53 -36
- package/cjs/config/useTabs.js.map +7 -0
- package/cjs/defaultProps.js +39 -13
- package/cjs/defaultProps.js.map +7 -0
- package/cjs/exportsRelated/DSTab.js +46 -32
- package/cjs/exportsRelated/DSTab.js.map +7 -0
- package/cjs/index.js +38 -17
- package/cjs/index.js.map +7 -0
- package/cjs/parts/carousel/Carousel.js +61 -53
- package/cjs/parts/carousel/Carousel.js.map +7 -0
- package/cjs/parts/carousel/styles.js +77 -63
- package/cjs/parts/carousel/styles.js.map +7 -0
- package/cjs/parts/carousel/useCarousel.js +51 -49
- package/cjs/parts/carousel/useCarousel.js.map +7 -0
- package/cjs/parts/carousel/useCarouselCallbacks.js +53 -36
- package/cjs/parts/carousel/useCarouselCallbacks.js.map +7 -0
- package/cjs/parts/tabBar/TabBar.js +124 -120
- package/cjs/parts/tabBar/TabBar.js.map +7 -0
- package/cjs/parts/tabBar/styles.js +289 -195
- package/cjs/parts/tabBar/styles.js.map +7 -0
- package/cjs/parts/tabBar/useTabBar.js +67 -55
- package/cjs/parts/tabBar/useTabBar.js.map +7 -0
- package/cjs/parts/tabsContent/TabsContent.js +49 -45
- package/cjs/parts/tabsContent/TabsContent.js.map +7 -0
- package/cjs/parts/tabsContent/styles.js +39 -15
- package/cjs/parts/tabsContent/styles.js.map +7 -0
- package/cjs/parts/tabsPanel/TabsPanels.js +60 -58
- package/cjs/parts/tabsPanel/TabsPanels.js.map +7 -0
- package/cjs/parts/tabsPanel/styles.js +43 -23
- package/cjs/parts/tabsPanel/styles.js.map +7 -0
- package/cjs/propTypes.js +54 -29
- package/cjs/propTypes.js.map +7 -0
- package/cjs/utils/constants.js +44 -16
- package/cjs/utils/constants.js.map +7 -0
- package/cjs/utils/helpers.js +46 -22
- package/cjs/utils/helpers.js.map +7 -0
- package/cjs/utils/hooks/useKeyboardNavigation.js +59 -43
- package/cjs/utils/hooks/useKeyboardNavigation.js.map +7 -0
- package/cjs/utils/hooks/useTabsCallbacks.js +49 -33
- package/cjs/utils/hooks/useTabsCallbacks.js.map +7 -0
- package/esm/DSTabs.js +24 -25
- package/esm/DSTabs.js.map +7 -0
- package/esm/DSTabsCTX.js +22 -20
- package/esm/DSTabsCTX.js.map +7 -0
- package/esm/DSTabsDatatestid.js +13 -10
- package/esm/DSTabsDatatestid.js.map +7 -0
- package/esm/DSTabsTypes.js +2 -1
- package/esm/DSTabsTypes.js.map +7 -0
- package/esm/config/useCrossRef.js +6 -4
- package/esm/config/useCrossRef.js.map +7 -0
- package/esm/config/useTabs.js +14 -22
- package/esm/config/useTabs.js.map +7 -0
- package/esm/defaultProps.js +9 -8
- package/esm/defaultProps.js.map +7 -0
- package/esm/exportsRelated/DSTab.js +15 -19
- package/esm/exportsRelated/DSTab.js.map +7 -0
- package/esm/index.js +9 -4
- package/esm/index.js.map +7 -0
- package/esm/parts/carousel/Carousel.js +25 -38
- package/esm/parts/carousel/Carousel.js.map +7 -0
- package/esm/parts/carousel/styles.js +48 -52
- package/esm/parts/carousel/styles.js.map +7 -0
- package/esm/parts/carousel/useCarousel.js +15 -34
- package/esm/parts/carousel/useCarousel.js.map +7 -0
- package/esm/parts/carousel/useCarouselCallbacks.js +20 -28
- package/esm/parts/carousel/useCarouselCallbacks.js.map +7 -0
- package/esm/parts/tabBar/TabBar.js +93 -102
- package/esm/parts/tabBar/TabBar.js.map +7 -0
- package/esm/parts/tabBar/styles.js +262 -183
- package/esm/parts/tabBar/styles.js.map +7 -0
- package/esm/parts/tabBar/useTabBar.js +27 -36
- package/esm/parts/tabBar/useTabBar.js.map +7 -0
- package/esm/parts/tabsContent/TabsContent.js +19 -35
- package/esm/parts/tabsContent/TabsContent.js.map +7 -0
- package/esm/parts/tabsContent/styles.js +10 -7
- package/esm/parts/tabsContent/styles.js.map +7 -0
- package/esm/parts/tabsPanel/TabsPanels.js +28 -45
- package/esm/parts/tabsPanel/TabsPanels.js.map +7 -0
- package/esm/parts/tabsPanel/styles.js +14 -15
- package/esm/parts/tabsPanel/styles.js.map +7 -0
- package/esm/propTypes.js +25 -24
- package/esm/propTypes.js.map +7 -0
- package/esm/utils/constants.js +15 -8
- package/esm/utils/constants.js.map +7 -0
- package/esm/utils/helpers.js +16 -11
- package/esm/utils/helpers.js.map +7 -0
- package/esm/utils/hooks/useKeyboardNavigation.js +30 -39
- package/esm/utils/hooks/useKeyboardNavigation.js.map +7 -0
- package/esm/utils/hooks/useTabsCallbacks.js +18 -27
- package/esm/utils/hooks/useTabsCallbacks.js.map +7 -0
- package/package.json +6 -6
- package/types/DSTabs.d.ts +2 -2
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { useContext } from 'react';
|
|
9
|
-
import { TabsPanels } from '../tabsPanel/TabsPanels.js';
|
|
10
|
-
import { TabBar } from '../tabBar/TabBar.js';
|
|
11
|
-
import { StyledTabBarContainer } from './styles.js';
|
|
12
|
-
import { DSTabsContext } from '../../DSTabsCTX.js';
|
|
13
|
-
import { DSTabsDatatestid } from '../../DSTabsDatatestid.js';
|
|
14
|
-
import { jsxs } from 'react/jsx-runtime';
|
|
15
|
-
|
|
16
|
-
var _TabBar, _TabsPanels;
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useContext } from "react";
|
|
3
|
+
import { TabsPanels } from "../tabsPanel/TabsPanels";
|
|
4
|
+
import { TabBar } from "../tabBar/TabBar";
|
|
5
|
+
import { StyledTabBarContainer } from "./styles";
|
|
6
|
+
import { DSTabsContext } from "../../DSTabsCTX";
|
|
7
|
+
import { DSTabsDatatestid } from "../../DSTabsDatatestid";
|
|
21
8
|
const TabsContent = () => {
|
|
22
9
|
const {
|
|
23
|
-
props: {
|
|
24
|
-
containerProps,
|
|
25
|
-
innerRef,
|
|
26
|
-
tabsListAriaLabel,
|
|
27
|
-
tabBarExtraContent
|
|
28
|
-
}
|
|
10
|
+
props: { containerProps, innerRef, tabsListAriaLabel, tabBarExtraContent }
|
|
29
11
|
} = useContext(DSTabsContext);
|
|
30
|
-
return
|
|
12
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
13
|
+
...containerProps,
|
|
31
14
|
ref: innerRef,
|
|
32
|
-
"data-testid": DSTabsDatatestid.TABS_CONTAINER
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}));
|
|
15
|
+
"data-testid": DSTabsDatatestid.TABS_CONTAINER
|
|
16
|
+
}, /* @__PURE__ */ React2.createElement(StyledTabBarContainer, {
|
|
17
|
+
"aria-label": tabsListAriaLabel,
|
|
18
|
+
role: "tablist"
|
|
19
|
+
}, /* @__PURE__ */ React2.createElement(TabBar, null), tabBarExtraContent), /* @__PURE__ */ React2.createElement(TabsPanels, null));
|
|
38
20
|
};
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
export {
|
|
22
|
+
TabsContent
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=TabsContent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/tabsContent/TabsContent.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { TabsPanels } from '../tabsPanel/TabsPanels';\nimport { TabBar } from '../tabBar/TabBar';\nimport { StyledTabBarContainer } from './styles';\nimport { DSTabsContext } from '../../DSTabsCTX';\nimport { DSTabsDatatestid } from '../../DSTabsDatatestid';\n\nexport const TabsContent = (): JSX.Element => {\n const {\n props: { containerProps, innerRef, tabsListAriaLabel, tabBarExtraContent },\n } = useContext(DSTabsContext);\n\n return (\n <div {...containerProps} ref={innerRef} data-testid={DSTabsDatatestid.TABS_CONTAINER}>\n <StyledTabBarContainer aria-label={tabsListAriaLabel} role=\"tablist\">\n <TabBar />\n {tabBarExtraContent}\n </StyledTabBarContainer>\n <TabsPanels />\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAM,cAAc,MAAmB;AAC5C,QAAM;AAAA,IACJ,OAAO,EAAE,gBAAgB,UAAU,mBAAmB;AAAA,MACpD,WAAW;AAEf,SACE,qCAAC,OAAD;AAAA,OAAS;AAAA,IAAgB,KAAK;AAAA,IAAU,eAAa,iBAAiB;AAAA,KACpE,qCAAC,uBAAD;AAAA,IAAuB,cAAY;AAAA,IAAmB,MAAK;AAAA,KACzD,qCAAC,QAAD,OACC,qBAEH,qCAAC,YAAD;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const StyledTabBarContainer =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
const StyledTabBarContainer = styled.div`
|
|
4
|
+
display: flex;
|
|
5
|
+
overflow-x: hidden;
|
|
6
|
+
`;
|
|
7
|
+
export {
|
|
8
|
+
StyledTabBarContainer
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/tabsContent/styles.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import styled from 'styled-components';\n\nexport const StyledTabBarContainer = styled.div`\n display: flex;\n overflow-x: hidden;\n`;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEO,MAAM,wBAAwB,OAAO;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,67 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { DSTabsContext } from '../../DSTabsCTX.js';
|
|
9
|
-
import { useTabsCallbacks } from '../../utils/hooks/useTabsCallbacks.js';
|
|
10
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
11
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useMemo, useContext, useCallback } from "react";
|
|
3
|
+
import SwipeableViews from "react-swipeable-views";
|
|
4
|
+
import { getIdByIndex, getIndexById } from "../../utils/helpers";
|
|
5
|
+
import { StyledPanelContainer } from "./styles";
|
|
6
|
+
import { DSTabsContext } from "../../DSTabsCTX";
|
|
7
|
+
import { useTabsCallbacks } from "../../utils/hooks/useTabsCallbacks";
|
|
12
8
|
const TabsPanels = () => {
|
|
13
9
|
const {
|
|
14
10
|
actualActiveTab,
|
|
15
11
|
focusableTabsRef,
|
|
16
|
-
props: {
|
|
17
|
-
animated,
|
|
18
|
-
enableMouseEvents,
|
|
19
|
-
onlyRenderActiveTab,
|
|
20
|
-
children: tabs,
|
|
21
|
-
isDSMobile
|
|
22
|
-
}
|
|
12
|
+
props: { animated, enableMouseEvents, onlyRenderActiveTab, children: tabs, isDSMobile }
|
|
23
13
|
} = useContext(DSTabsContext);
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
handleOnMouseDown
|
|
27
|
-
} = useTabsCallbacks();
|
|
28
|
-
const handleOnChangeIndex = useCallback(index => {
|
|
14
|
+
const { handleOnTabChange, handleOnMouseDown } = useTabsCallbacks();
|
|
15
|
+
const handleOnChangeIndex = useCallback((index) => {
|
|
29
16
|
handleOnTabChange(getIdByIndex(tabs, index));
|
|
30
|
-
if (focusableTabsRef.current)
|
|
17
|
+
if (focusableTabsRef.current)
|
|
18
|
+
focusableTabsRef.current[index].click();
|
|
31
19
|
}, [focusableTabsRef, handleOnTabChange, tabs]);
|
|
32
|
-
const panels = useMemo(() =>
|
|
33
|
-
const {
|
|
34
|
-
tabId: panelId = '',
|
|
35
|
-
style,
|
|
36
|
-
children: content
|
|
37
|
-
} = tab.props;
|
|
20
|
+
const panels = useMemo(() => React2.Children.map(tabs, (tab) => {
|
|
21
|
+
const { tabId: panelId = "", style, children: content } = tab.props;
|
|
38
22
|
const isActive = actualActiveTab === panelId;
|
|
39
23
|
const shouldRender = !onlyRenderActiveTab || isActive;
|
|
40
|
-
return shouldRender &&
|
|
24
|
+
return shouldRender && /* @__PURE__ */ React2.createElement(StyledPanelContainer, {
|
|
25
|
+
key: panelId,
|
|
41
26
|
id: panelId,
|
|
42
|
-
"aria-labelledby":
|
|
27
|
+
"aria-labelledby": `${panelId}-label`,
|
|
43
28
|
"aria-hidden": !isActive,
|
|
44
29
|
"data-panel-id": panelId,
|
|
45
30
|
"data-testid": "ds-tabs-tab-panel",
|
|
46
31
|
hidden: !isActive,
|
|
47
32
|
onMouseDown: handleOnMouseDown,
|
|
48
33
|
role: "tabpanel",
|
|
49
|
-
style
|
|
50
|
-
isDSMobile
|
|
51
|
-
},
|
|
34
|
+
style,
|
|
35
|
+
isDSMobile
|
|
36
|
+
}, content);
|
|
52
37
|
}), [actualActiveTab, handleOnMouseDown, isDSMobile, onlyRenderActiveTab, tabs]);
|
|
53
|
-
|
|
54
38
|
if (animated) {
|
|
55
|
-
return
|
|
56
|
-
enableMouseEvents
|
|
39
|
+
return /* @__PURE__ */ React2.createElement(SwipeableViews, {
|
|
40
|
+
enableMouseEvents,
|
|
57
41
|
index: getIndexById(tabs, actualActiveTab),
|
|
58
42
|
onChangeIndex: handleOnChangeIndex
|
|
59
|
-
},
|
|
43
|
+
}, panels);
|
|
60
44
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
45
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, panels);
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
TabsPanels
|
|
65
49
|
};
|
|
66
|
-
|
|
67
|
-
export { TabsPanels };
|
|
50
|
+
//# sourceMappingURL=TabsPanels.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/tabsPanel/TabsPanels.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\nimport React, { useMemo, useContext, useCallback } from 'react';\nimport SwipeableViews from 'react-swipeable-views';\nimport { getIdByIndex, getIndexById } from '../../utils/helpers';\nimport { StyledPanelContainer } from './styles';\nimport { DSTabsContext } from '../../DSTabsCTX';\nimport { useTabsCallbacks } from '../../utils/hooks/useTabsCallbacks';\nimport { DSTabPropsWithDefaultT } from '../../DSTabsTypes';\n\nexport const TabsPanels = (): JSX.Element => {\n const {\n actualActiveTab,\n focusableTabsRef,\n props: { animated, enableMouseEvents, onlyRenderActiveTab, children: tabs, isDSMobile },\n } = useContext(DSTabsContext);\n\n const { handleOnTabChange, handleOnMouseDown } = useTabsCallbacks();\n\n const handleOnChangeIndex = useCallback(\n (index: number) => {\n handleOnTabChange(getIdByIndex(tabs, index));\n\n if (focusableTabsRef.current) focusableTabsRef.current[index].click();\n },\n [focusableTabsRef, handleOnTabChange, tabs],\n );\n\n const panels = useMemo(\n () =>\n React.Children.map(tabs, (tab: React.ReactElement<DSTabPropsWithDefaultT>) => {\n const { tabId: panelId = '', style, children: content } = tab.props;\n const isActive = actualActiveTab === panelId;\n const shouldRender = !onlyRenderActiveTab || isActive;\n return (\n shouldRender && (\n <StyledPanelContainer\n key={panelId}\n id={panelId}\n aria-labelledby={`${panelId}-label`}\n aria-hidden={!isActive}\n data-panel-id={panelId}\n data-testid=\"ds-tabs-tab-panel\"\n hidden={!isActive}\n onMouseDown={handleOnMouseDown}\n role=\"tabpanel\"\n style={style}\n isDSMobile={isDSMobile}\n >\n {content}\n </StyledPanelContainer>\n )\n );\n }),\n [actualActiveTab, handleOnMouseDown, isDSMobile, onlyRenderActiveTab, tabs],\n );\n\n if (animated) {\n return (\n <SwipeableViews\n enableMouseEvents={enableMouseEvents}\n index={getIndexById(tabs, actualActiveTab)}\n onChangeIndex={handleOnChangeIndex}\n >\n {panels}\n </SwipeableViews>\n );\n }\n\n return <>{panels}</>;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AAGO,MAAM,aAAa,MAAmB;AAC3C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO,EAAE,UAAU,mBAAmB,qBAAqB,UAAU,MAAM;AAAA,MACzE,WAAW;AAEf,QAAM,EAAE,mBAAmB,sBAAsB;AAEjD,QAAM,sBAAsB,YAC1B,CAAC,UAAkB;AACjB,sBAAkB,aAAa,MAAM;AAErC,QAAI,iBAAiB;AAAS,uBAAiB,QAAQ,OAAO;AAAA,KAEhE,CAAC,kBAAkB,mBAAmB;AAGxC,QAAM,SAAS,QACb,MACE,OAAM,SAAS,IAAI,MAAM,CAAC,QAAoD;AAC5E,UAAM,EAAE,OAAO,UAAU,IAAI,OAAO,UAAU,YAAY,IAAI;AAC9D,UAAM,WAAW,oBAAoB;AACrC,UAAM,eAAe,CAAC,uBAAuB;AAC7C,WACE,gBACE,qCAAC,sBAAD;AAAA,MACE,KAAK;AAAA,MACL,IAAI;AAAA,MACJ,mBAAiB,GAAG;AAAA,MACpB,eAAa,CAAC;AAAA,MACd,iBAAe;AAAA,MACf,eAAY;AAAA,MACZ,QAAQ,CAAC;AAAA,MACT,aAAa;AAAA,MACb,MAAK;AAAA,MACL;AAAA,MACA;AAAA,OAEC;AAAA,MAKX,CAAC,iBAAiB,mBAAmB,YAAY,qBAAqB;AAGxE,MAAI,UAAU;AACZ,WACE,qCAAC,gBAAD;AAAA,MACE;AAAA,MACA,OAAO,aAAa,MAAM;AAAA,MAC1B,eAAe;AAAA,OAEd;AAAA;AAKP,SAAO,4DAAG;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
const StyledPanelContainer = styled.div`
|
|
4
|
+
padding-top: 8px;
|
|
5
|
+
&:focus {
|
|
6
|
+
outline: none;
|
|
7
|
+
}
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
componentId: "sc-oxw5jq-0"
|
|
5
|
-
})(["padding-top:8px;&:focus{outline:none;}", " ", ""], _ref => {
|
|
6
|
-
let {
|
|
7
|
-
hidden
|
|
8
|
-
} = _ref;
|
|
9
|
-
return hidden ? 'visibility: hidden;' : '';
|
|
10
|
-
}, _ref2 => {
|
|
11
|
-
let {
|
|
12
|
-
isDSMobile
|
|
13
|
-
} = _ref2;
|
|
14
|
-
return isDSMobile ? "padding-top: 0;" : "";
|
|
15
|
-
});
|
|
9
|
+
${({ hidden }) => hidden ? "visibility: hidden;" : ""}
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
${({ isDSMobile }) => isDSMobile ? `padding-top: 0;` : ``}
|
|
12
|
+
`;
|
|
13
|
+
export {
|
|
14
|
+
StyledPanelContainer
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/tabsPanel/styles.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import styled from 'styled-components';\nimport type { StyledPanelContainerPropsT } from '../../DSTabsTypes';\n\nexport const StyledPanelContainer = styled.div<StyledPanelContainerPropsT>`\n padding-top: 8px;\n &:focus {\n outline: none;\n }\n\n ${({ hidden }) => (hidden ? 'visibility: hidden;' : '')}\n\n ${({ isDSMobile }) => (isDSMobile ? `padding-top: 0;` : ``)}\n`;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAGO,MAAM,uBAAuB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMvC,CAAC,EAAE,aAAc,SAAS,wBAAwB;AAAA;AAAA,IAElD,CAAC,EAAE,iBAAkB,aAAa,oBAAoB;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/propTypes.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes } from "react-desc";
|
|
3
|
+
import { TabTypesValuesAsArray } from "./utils/constants";
|
|
4
4
|
const tabPropTypes = {
|
|
5
|
-
tabId: PropTypes.string.description(
|
|
6
|
-
title: PropTypes.string.description(
|
|
7
|
-
required: PropTypes.bool.description(
|
|
8
|
-
disabled: PropTypes.bool.description(
|
|
5
|
+
tabId: PropTypes.string.description("Unique Tab id.").defaultValue(""),
|
|
6
|
+
title: PropTypes.string.description("Tab title.").defaultValue(""),
|
|
7
|
+
required: PropTypes.bool.description("Show a required mark next to the title.").defaultValue(false),
|
|
8
|
+
disabled: PropTypes.bool.description("Disables Tab.").defaultValue(false)
|
|
9
9
|
};
|
|
10
10
|
const tabsPropTypes = {
|
|
11
|
-
animated: PropTypes.bool.description(
|
|
12
|
-
enableMouseEvents: PropTypes.bool.description(
|
|
13
|
-
allowTextSelection: PropTypes.bool.description(
|
|
14
|
-
onTabChange: PropTypes.func.description(
|
|
15
|
-
type: PropTypes.oneOf(TabTypesValuesAsArray).description(
|
|
16
|
-
tabBarExtraContent: PropTypes.element.description(
|
|
17
|
-
onlyRenderActiveTab: PropTypes.bool.description(
|
|
18
|
-
withCarousel: PropTypes.bool.description(
|
|
19
|
-
activeTab: PropTypes.string.description(
|
|
20
|
-
children: PropTypes.node.description(
|
|
21
|
-
tabsListAriaLabel: PropTypes.string.description(
|
|
22
|
-
containerProps: PropTypes.object.description(
|
|
23
|
-
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
24
|
-
current: PropTypes.any
|
|
25
|
-
})]).description('Ref to the container.').defaultValue(undefined)
|
|
11
|
+
animated: PropTypes.bool.description("Whether the Tab transition should animate or not.").defaultValue(true),
|
|
12
|
+
enableMouseEvents: PropTypes.bool.description("Enables Tab transition with mouse drag events.").defaultValue(false),
|
|
13
|
+
allowTextSelection: PropTypes.bool.description("Allows text selection when mouse drag events are active.").defaultValue(false),
|
|
14
|
+
onTabChange: PropTypes.func.description("Handler when a user clicks on a different Tab.").defaultValue("() => {}"),
|
|
15
|
+
type: PropTypes.oneOf(TabTypesValuesAsArray).description("Tab type.").defaultValue(TabTypesValuesAsArray[0]),
|
|
16
|
+
tabBarExtraContent: PropTypes.element.description("Extra content next to the Tab Bar.").defaultValue(void 0),
|
|
17
|
+
onlyRenderActiveTab: PropTypes.bool.description("Only renders the active Tab in the DOM.").defaultValue(false),
|
|
18
|
+
withCarousel: PropTypes.bool.description("Activate carousel behavior.").defaultValue(false),
|
|
19
|
+
activeTab: PropTypes.string.description("Passing a value makes DSTabs a controlled component.").defaultValue("First DSTab children."),
|
|
20
|
+
children: PropTypes.node.description("Use DSTab component as children.").isRequired,
|
|
21
|
+
tabsListAriaLabel: PropTypes.string.description("Aria label for the list.").defaultValue("Tab list."),
|
|
22
|
+
containerProps: PropTypes.object.description("Additional properties for the container.").defaultValue({}),
|
|
23
|
+
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description("Ref to the container.").defaultValue(void 0)
|
|
26
24
|
};
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
export {
|
|
26
|
+
tabPropTypes,
|
|
27
|
+
tabsPropTypes
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=propTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/propTypes.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\nimport { TabTypesValuesAsArray } from './utils/constants';\n\nexport const tabPropTypes = {\n tabId: PropTypes.string.description('Unique Tab id.').defaultValue(''),\n title: PropTypes.string.description('Tab title.').defaultValue(''),\n required: PropTypes.bool.description('Show a required mark next to the title.').defaultValue(false),\n disabled: PropTypes.bool.description('Disables Tab.').defaultValue(false),\n};\n\nexport const tabsPropTypes = {\n animated: PropTypes.bool.description('Whether the Tab transition should animate or not.').defaultValue(true),\n enableMouseEvents: PropTypes.bool.description('Enables Tab transition with mouse drag events.').defaultValue(false),\n allowTextSelection: PropTypes.bool\n .description('Allows text selection when mouse drag events are active.')\n .defaultValue(false),\n onTabChange: PropTypes.func.description('Handler when a user clicks on a different Tab.').defaultValue('() => {}'),\n type: PropTypes.oneOf(TabTypesValuesAsArray).description('Tab type.').defaultValue(TabTypesValuesAsArray[0]),\n tabBarExtraContent: PropTypes.element.description('Extra content next to the Tab Bar.').defaultValue(undefined),\n onlyRenderActiveTab: PropTypes.bool.description('Only renders the active Tab in the DOM.').defaultValue(false),\n withCarousel: PropTypes.bool.description('Activate carousel behavior.').defaultValue(false),\n activeTab: PropTypes.string\n .description('Passing a value makes DSTabs a controlled component.')\n .defaultValue('First DSTab children.'),\n children: PropTypes.node.description('Use DSTab component as children.').isRequired,\n tabsListAriaLabel: PropTypes.string.description('Aria label for the list.').defaultValue('Tab list.'),\n containerProps: PropTypes.object.description('Additional properties for the container.').defaultValue({}),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })])\n .description('Ref to the container.')\n .defaultValue(undefined),\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEO,MAAM,eAAe;AAAA,EAC1B,OAAO,UAAU,OAAO,YAAY,kBAAkB,aAAa;AAAA,EACnE,OAAO,UAAU,OAAO,YAAY,cAAc,aAAa;AAAA,EAC/D,UAAU,UAAU,KAAK,YAAY,2CAA2C,aAAa;AAAA,EAC7F,UAAU,UAAU,KAAK,YAAY,iBAAiB,aAAa;AAAA;AAG9D,MAAM,gBAAgB;AAAA,EAC3B,UAAU,UAAU,KAAK,YAAY,qDAAqD,aAAa;AAAA,EACvG,mBAAmB,UAAU,KAAK,YAAY,kDAAkD,aAAa;AAAA,EAC7G,oBAAoB,UAAU,KAC3B,YAAY,4DACZ,aAAa;AAAA,EAChB,aAAa,UAAU,KAAK,YAAY,kDAAkD,aAAa;AAAA,EACvG,MAAM,UAAU,MAAM,uBAAuB,YAAY,aAAa,aAAa,sBAAsB;AAAA,EACzG,oBAAoB,UAAU,QAAQ,YAAY,sCAAsC,aAAa;AAAA,EACrG,qBAAqB,UAAU,KAAK,YAAY,2CAA2C,aAAa;AAAA,EACxG,cAAc,UAAU,KAAK,YAAY,+BAA+B,aAAa;AAAA,EACrF,WAAW,UAAU,OAClB,YAAY,wDACZ,aAAa;AAAA,EAChB,UAAU,UAAU,KAAK,YAAY,oCAAoC;AAAA,EACzE,mBAAmB,UAAU,OAAO,YAAY,4BAA4B,aAAa;AAAA,EACzF,gBAAgB,UAAU,OAAO,YAAY,4CAA4C,aAAa;AAAA,EACtG,UAAU,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,MAAM,EAAE,SAAS,UAAU,SACjF,YAAY,yBACZ,aAAa;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/utils/constants.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
const TabTypes = {
|
|
2
|
-
NORMAL:
|
|
3
|
-
NORMAL_SMALL:
|
|
4
|
-
SUBTABS:
|
|
3
|
+
NORMAL: "normal",
|
|
4
|
+
NORMAL_SMALL: "normal_small",
|
|
5
|
+
SUBTABS: "subtabs"
|
|
5
6
|
};
|
|
6
7
|
const TabTypesValuesAsArray = Object.values(TabTypes);
|
|
7
8
|
const MOBILE_GRADIENT_WIDTH = 24;
|
|
8
9
|
const defaultIndicatorStyles = {
|
|
9
|
-
left:
|
|
10
|
-
width:
|
|
11
|
-
backgroundWithTransparent:
|
|
10
|
+
left: "0px",
|
|
11
|
+
width: "0px",
|
|
12
|
+
backgroundWithTransparent: ""
|
|
12
13
|
};
|
|
13
14
|
const gradientOffsetsAccordingType = {
|
|
14
15
|
normal_small: 14,
|
|
@@ -16,5 +17,11 @@ const gradientOffsetsAccordingType = {
|
|
|
16
17
|
subtabs: 16,
|
|
17
18
|
fixedTabsHeaders: 0
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
export {
|
|
21
|
+
MOBILE_GRADIENT_WIDTH,
|
|
22
|
+
TabTypes,
|
|
23
|
+
TabTypesValuesAsArray,
|
|
24
|
+
defaultIndicatorStyles,
|
|
25
|
+
gradientOffsetsAccordingType
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/constants.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const TabTypes = {\n NORMAL: 'normal' as const,\n NORMAL_SMALL: 'normal_small' as const,\n SUBTABS: 'subtabs' as const,\n};\n\nexport const TabTypesValuesAsArray = Object.values(TabTypes);\n\nexport const MOBILE_GRADIENT_WIDTH = 24;\n\nexport const defaultIndicatorStyles = {\n left: '0px',\n width: '0px',\n backgroundWithTransparent: '',\n};\n\nexport const gradientOffsetsAccordingType = {\n normal_small: 14,\n normal: 16,\n subtabs: 16,\n fixedTabsHeaders: 0,\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,WAAW;AAAA,EACtB,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,SAAS;AAAA;AAGJ,MAAM,wBAAwB,OAAO,OAAO;AAE5C,MAAM,wBAAwB;AAE9B,MAAM,yBAAyB;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,2BAA2B;AAAA;AAGtB,MAAM,+BAA+B;AAAA,EAC1C,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,kBAAkB;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/utils/helpers.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { MOBILE_GRADIENT_WIDTH } from "./constants";
|
|
3
3
|
const isElementVisible = (tab, tabList) => {
|
|
4
4
|
const tabDimensions = tab.getBoundingClientRect();
|
|
5
5
|
const tabListDimensions = tabList.getBoundingClientRect();
|
|
6
6
|
return tabDimensions.left <= tabListDimensions.left ? tabListDimensions.left - tabDimensions.left <= tabDimensions.width : tabDimensions.right - tabListDimensions.right <= tabDimensions.width;
|
|
7
7
|
};
|
|
8
|
-
const isElementVisibleCarousel =
|
|
9
|
-
let firstOrLastItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
10
|
-
|
|
8
|
+
const isElementVisibleCarousel = (tab, tabContainer, firstOrLastItem = true) => {
|
|
11
9
|
if (tab && tabContainer) {
|
|
12
10
|
const tabDimensions = tab.getBoundingClientRect();
|
|
13
11
|
const tabContainerDimensions = tabContainer.getBoundingClientRect();
|
|
@@ -18,7 +16,6 @@ const isElementVisibleCarousel = function (tab, tabContainer) {
|
|
|
18
16
|
const tabContainerDimensionsRight = Math.floor(tabContainerDimensions.right);
|
|
19
17
|
return tabDimensionsLeft >= tabContainerDimensionsLeft && tabDimensionsRight <= tabContainerDimensionsRight;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
return false;
|
|
23
20
|
};
|
|
24
21
|
const getVisibleDimensions = (node, referenceNode) => {
|
|
@@ -29,9 +26,17 @@ const getVisibleDimensions = (node, referenceNode) => {
|
|
|
29
26
|
height: Math.min(node.clientHeight, referenceNodeDimensions.top + referenceNode.clientHeight - nodeDimensions.top, node.clientHeight - (referenceNodeDimensions.top - nodeDimensions.top))
|
|
30
27
|
};
|
|
31
28
|
};
|
|
32
|
-
const getIndexById = (children, activeId) => children && children.findIndex(item => item.props.tabId === activeId);
|
|
33
|
-
const getIdByIndex = (children, index) => children && children[index].props.tabId ||
|
|
34
|
-
const shouldHaveLeftGradient = scrollLeft => Math.abs(scrollLeft) > MOBILE_GRADIENT_WIDTH;
|
|
29
|
+
const getIndexById = (children, activeId) => children && children.findIndex((item) => item.props.tabId === activeId);
|
|
30
|
+
const getIdByIndex = (children, index) => children && children[index].props.tabId || "";
|
|
31
|
+
const shouldHaveLeftGradient = (scrollLeft) => Math.abs(scrollLeft) > MOBILE_GRADIENT_WIDTH;
|
|
35
32
|
const shouldHaveRightGradient = (scrollLeft, clientWidth, scrollWidth) => Math.abs(scrollLeft) <= scrollWidth - (clientWidth + MOBILE_GRADIENT_WIDTH);
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
export {
|
|
34
|
+
getIdByIndex,
|
|
35
|
+
getIndexById,
|
|
36
|
+
getVisibleDimensions,
|
|
37
|
+
isElementVisible,
|
|
38
|
+
isElementVisibleCarousel,
|
|
39
|
+
shouldHaveLeftGradient,
|
|
40
|
+
shouldHaveRightGradient
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSTabPropsWithDefaultT, VisibleDimensionsT } from '../DSTabsTypes';\nimport { MOBILE_GRADIENT_WIDTH } from './constants';\n\nexport const isElementVisible = (tab: HTMLElement, tabList: HTMLElement): boolean => {\n const tabDimensions = tab.getBoundingClientRect();\n const tabListDimensions = tabList.getBoundingClientRect();\n\n return tabDimensions.left <= tabListDimensions.left\n ? tabListDimensions.left - tabDimensions.left <= tabDimensions.width\n : tabDimensions.right - tabListDimensions.right <= tabDimensions.width;\n};\n\nexport const isElementVisibleCarousel = (\n tab: HTMLElement | null,\n tabContainer: HTMLDivElement | null,\n firstOrLastItem = true,\n): boolean => {\n if (tab && tabContainer) {\n const tabDimensions = tab.getBoundingClientRect();\n const tabContainerDimensions = tabContainer.getBoundingClientRect();\n\n const offset = firstOrLastItem ? 16 : 32;\n const tabDimensionsLeft = Math.floor(tabDimensions.left - offset);\n const tabDimensionsRight = Math.floor(tabDimensions.right + offset);\n\n const tabContainerDimensionsLeft = Math.floor(tabContainerDimensions.left);\n const tabContainerDimensionsRight = Math.floor(tabContainerDimensions.right);\n\n return tabDimensionsLeft >= tabContainerDimensionsLeft && tabDimensionsRight <= tabContainerDimensionsRight;\n }\n return false;\n};\n\nexport const getVisibleDimensions = (node: HTMLElement, referenceNode: HTMLElement): VisibleDimensionsT => {\n const nodeDimensions = node.getBoundingClientRect();\n const referenceNodeDimensions = referenceNode.getBoundingClientRect();\n\n return {\n width: Math.min(\n node.clientWidth,\n referenceNodeDimensions.left + referenceNode.clientWidth - nodeDimensions.left,\n node.clientWidth - (referenceNodeDimensions.left - nodeDimensions.left),\n ),\n height: Math.min(\n node.clientHeight,\n referenceNodeDimensions.top + referenceNode.clientHeight - nodeDimensions.top,\n node.clientHeight - (referenceNodeDimensions.top - nodeDimensions.top),\n ),\n };\n};\n\nexport const getIndexById = (children: React.ReactElement<DSTabPropsWithDefaultT>[], activeId?: string): number =>\n children && children.findIndex((item: React.ReactElement<DSTabPropsWithDefaultT>) => item.props.tabId === activeId);\n\nexport const getIdByIndex = (children: React.ReactElement<DSTabPropsWithDefaultT>[], index: number): string =>\n (children && children[index].props.tabId) || '';\n\nexport const shouldHaveLeftGradient = (scrollLeft: number): boolean => Math.abs(scrollLeft) > MOBILE_GRADIENT_WIDTH;\n\nexport const shouldHaveRightGradient = (scrollLeft: number, clientWidth: number, scrollWidth: number): boolean =>\n Math.abs(scrollLeft) <= scrollWidth - (clientWidth + MOBILE_GRADIENT_WIDTH);\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAEO,MAAM,mBAAmB,CAAC,KAAkB,YAAkC;AACnF,QAAM,gBAAgB,IAAI;AAC1B,QAAM,oBAAoB,QAAQ;AAElC,SAAO,cAAc,QAAQ,kBAAkB,OAC3C,kBAAkB,OAAO,cAAc,QAAQ,cAAc,QAC7D,cAAc,QAAQ,kBAAkB,SAAS,cAAc;AAAA;AAG9D,MAAM,2BAA2B,CACtC,KACA,cACA,kBAAkB,SACN;AACZ,MAAI,OAAO,cAAc;AACvB,UAAM,gBAAgB,IAAI;AAC1B,UAAM,yBAAyB,aAAa;AAE5C,UAAM,SAAS,kBAAkB,KAAK;AACtC,UAAM,oBAAoB,KAAK,MAAM,cAAc,OAAO;AAC1D,UAAM,qBAAqB,KAAK,MAAM,cAAc,QAAQ;AAE5D,UAAM,6BAA6B,KAAK,MAAM,uBAAuB;AACrE,UAAM,8BAA8B,KAAK,MAAM,uBAAuB;AAEtE,WAAO,qBAAqB,8BAA8B,sBAAsB;AAAA;AAElF,SAAO;AAAA;AAGF,MAAM,uBAAuB,CAAC,MAAmB,kBAAmD;AACzG,QAAM,iBAAiB,KAAK;AAC5B,QAAM,0BAA0B,cAAc;AAE9C,SAAO;AAAA,IACL,OAAO,KAAK,IACV,KAAK,aACL,wBAAwB,OAAO,cAAc,cAAc,eAAe,MAC1E,KAAK,cAAe,yBAAwB,OAAO,eAAe;AAAA,IAEpE,QAAQ,KAAK,IACX,KAAK,cACL,wBAAwB,MAAM,cAAc,eAAe,eAAe,KAC1E,KAAK,eAAgB,yBAAwB,MAAM,eAAe;AAAA;AAAA;AAKjE,MAAM,eAAe,CAAC,UAAwD,aACnF,YAAY,SAAS,UAAU,CAAC,SAAqD,KAAK,MAAM,UAAU;AAErG,MAAM,eAAe,CAAC,UAAwD,UAClF,YAAY,SAAS,OAAO,MAAM,SAAU;AAExC,MAAM,yBAAyB,CAAC,eAAgC,KAAK,IAAI,cAAc;AAEvF,MAAM,0BAA0B,CAAC,YAAoB,aAAqB,gBAC/E,KAAK,IAAI,eAAe,cAAe,eAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,57 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/* eslint-disable max-statements */
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useContext } from "react";
|
|
3
|
+
import { DSTabsContext, DSTabsCrossRefContext } from "../../DSTabsCTX";
|
|
5
4
|
const useKeyboardNavigation = () => {
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
firstSubtabInternalRef,
|
|
11
|
-
lastTabInternalRef
|
|
12
|
-
} = useContext(DSTabsCrossRefContext);
|
|
13
|
-
const handleOnKeyDown = useCallback(e => {
|
|
14
|
-
if (e.key === 'ArrowRight' && focusableTabsRef.current) {
|
|
15
|
-
var _focusableTabsRef$cur, _focusableTabsRef$cur2;
|
|
16
|
-
|
|
5
|
+
const { focusableTabsRef } = useContext(DSTabsContext);
|
|
6
|
+
const { firstSubtabInternalRef, lastTabInternalRef } = useContext(DSTabsCrossRefContext);
|
|
7
|
+
const handleOnKeyDown = useCallback((e) => {
|
|
8
|
+
if (e.key === "ArrowRight" && focusableTabsRef.current) {
|
|
17
9
|
e.preventDefault();
|
|
18
10
|
e.stopPropagation();
|
|
19
|
-
const nextTab = focusableTabsRef.current[
|
|
20
|
-
if (nextTab)
|
|
21
|
-
|
|
11
|
+
const nextTab = focusableTabsRef.current[focusableTabsRef?.current?.indexOf?.(e.target) + 1];
|
|
12
|
+
if (nextTab)
|
|
13
|
+
nextTab.focus();
|
|
14
|
+
if (!nextTab)
|
|
15
|
+
return;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
|
-
if (e.key === 'ArrowLeft' && focusableTabsRef.current) {
|
|
25
|
-
var _focusableTabsRef$cur3, _focusableTabsRef$cur4;
|
|
26
|
-
|
|
17
|
+
if (e.key === "ArrowLeft" && focusableTabsRef.current) {
|
|
27
18
|
e.preventDefault();
|
|
28
19
|
e.stopPropagation();
|
|
29
|
-
const prevTab = focusableTabsRef.current[
|
|
30
|
-
if (prevTab)
|
|
31
|
-
|
|
20
|
+
const prevTab = focusableTabsRef.current[focusableTabsRef?.current?.indexOf?.(e.target) - 1];
|
|
21
|
+
if (prevTab)
|
|
22
|
+
prevTab.focus();
|
|
23
|
+
if (!prevTab)
|
|
24
|
+
return;
|
|
32
25
|
}
|
|
33
|
-
|
|
34
|
-
if (e.key === 'ArrowDown') {
|
|
35
|
-
var _firstSubtabInternalR;
|
|
36
|
-
|
|
26
|
+
if (e.key === "ArrowDown") {
|
|
37
27
|
e.preventDefault();
|
|
38
28
|
e.stopPropagation();
|
|
39
|
-
const canFocusCrossTabs =
|
|
40
|
-
if (canFocusCrossTabs)
|
|
29
|
+
const canFocusCrossTabs = firstSubtabInternalRef?.current && lastTabInternalRef?.current;
|
|
30
|
+
if (canFocusCrossTabs)
|
|
31
|
+
firstSubtabInternalRef.current?.focus();
|
|
41
32
|
}
|
|
42
|
-
|
|
43
|
-
if (e.key === 'ArrowUp') {
|
|
44
|
-
var _lastTabInternalRef$c;
|
|
45
|
-
|
|
33
|
+
if (e.key === "ArrowUp") {
|
|
46
34
|
e.preventDefault();
|
|
47
35
|
e.stopPropagation();
|
|
48
|
-
const canFocusCrossTabs =
|
|
49
|
-
if (canFocusCrossTabs)
|
|
36
|
+
const canFocusCrossTabs = firstSubtabInternalRef?.current && lastTabInternalRef?.current;
|
|
37
|
+
if (canFocusCrossTabs)
|
|
38
|
+
lastTabInternalRef.current?.focus();
|
|
50
39
|
}
|
|
51
40
|
}, [firstSubtabInternalRef, lastTabInternalRef, focusableTabsRef]);
|
|
52
41
|
return {
|
|
53
42
|
handleOnKeyDown
|
|
54
43
|
};
|
|
55
44
|
};
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
export {
|
|
46
|
+
useKeyboardNavigation
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=useKeyboardNavigation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/utils/hooks/useKeyboardNavigation.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport React, { useCallback, useContext } from 'react';\nimport { DSTabsContext, DSTabsCrossRefContext } from '../../DSTabsCTX';\nimport type { UseKeyboardNavigationReturnTypeT } from '../../DSTabsTypes';\n\nexport const useKeyboardNavigation = (): UseKeyboardNavigationReturnTypeT => {\n const { focusableTabsRef } = useContext(DSTabsContext);\n const { firstSubtabInternalRef, lastTabInternalRef } = useContext(DSTabsCrossRefContext);\n\n const handleOnKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowRight' && focusableTabsRef.current) {\n e.preventDefault();\n e.stopPropagation();\n const nextTab =\n focusableTabsRef.current[focusableTabsRef?.current?.indexOf?.(e.target as HTMLButtonElement) + 1];\n if (nextTab) nextTab.focus();\n if (!nextTab) return;\n }\n\n if (e.key === 'ArrowLeft' && focusableTabsRef.current) {\n e.preventDefault();\n e.stopPropagation();\n const prevTab =\n focusableTabsRef.current[focusableTabsRef?.current?.indexOf?.(e.target as HTMLButtonElement) - 1];\n if (prevTab) prevTab.focus();\n if (!prevTab) return;\n }\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n const canFocusCrossTabs = firstSubtabInternalRef?.current && lastTabInternalRef?.current;\n if (canFocusCrossTabs) firstSubtabInternalRef.current?.focus();\n }\n\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n const canFocusCrossTabs = firstSubtabInternalRef?.current && lastTabInternalRef?.current;\n if (canFocusCrossTabs) lastTabInternalRef.current?.focus();\n }\n },\n [firstSubtabInternalRef, lastTabInternalRef, focusableTabsRef],\n );\n\n return {\n handleOnKeyDown,\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACEA;AACA;AAGO,MAAM,wBAAwB,MAAwC;AAC3E,QAAM,EAAE,qBAAqB,WAAW;AACxC,QAAM,EAAE,wBAAwB,uBAAuB,WAAW;AAElE,QAAM,kBAAkB,YACtB,CAAC,MAA2B;AAC1B,QAAI,EAAE,QAAQ,gBAAgB,iBAAiB,SAAS;AACtD,QAAE;AACF,QAAE;AACF,YAAM,UACJ,iBAAiB,QAAQ,kBAAkB,SAAS,UAAU,EAAE,UAA+B;AACjG,UAAI;AAAS,gBAAQ;AACrB,UAAI,CAAC;AAAS;AAAA;AAGhB,QAAI,EAAE,QAAQ,eAAe,iBAAiB,SAAS;AACrD,QAAE;AACF,QAAE;AACF,YAAM,UACJ,iBAAiB,QAAQ,kBAAkB,SAAS,UAAU,EAAE,UAA+B;AACjG,UAAI;AAAS,gBAAQ;AACrB,UAAI,CAAC;AAAS;AAAA;AAGhB,QAAI,EAAE,QAAQ,aAAa;AACzB,QAAE;AACF,QAAE;AACF,YAAM,oBAAoB,wBAAwB,WAAW,oBAAoB;AACjF,UAAI;AAAmB,+BAAuB,SAAS;AAAA;AAGzD,QAAI,EAAE,QAAQ,WAAW;AACvB,QAAE;AACF,QAAE;AACF,YAAM,oBAAoB,wBAAwB,WAAW,oBAAoB;AACjF,UAAI;AAAmB,2BAAmB,SAAS;AAAA;AAAA,KAGvD,CAAC,wBAAwB,oBAAoB;AAG/C,SAAO;AAAA,IACL;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,55 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useContext } from "react";
|
|
3
|
+
import { DSTabsContext } from "../../DSTabsCTX";
|
|
4
4
|
const useTabsCallbacks = () => {
|
|
5
5
|
const {
|
|
6
6
|
setInternalActiveTab,
|
|
7
7
|
tabsListRef,
|
|
8
|
-
props: {
|
|
9
|
-
onTabChange,
|
|
10
|
-
isDSMobile,
|
|
11
|
-
allowTextSelection,
|
|
12
|
-
fixedTabsHeaders
|
|
13
|
-
}
|
|
8
|
+
props: { onTabChange, isDSMobile, allowTextSelection, fixedTabsHeaders }
|
|
14
9
|
} = useContext(DSTabsContext);
|
|
15
|
-
const centerTabWhenTabChangeMobile = useCallback(e => {
|
|
10
|
+
const centerTabWhenTabChangeMobile = useCallback((e) => {
|
|
16
11
|
if (tabsListRef.current) {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
width: tabWidth
|
|
22
|
-
} = (e === null || e === void 0 ? void 0 : e.target).getBoundingClientRect();
|
|
23
|
-
const {
|
|
24
|
-
width: listWidth
|
|
25
|
-
} = tabsListRef.current.getBoundingClientRect();
|
|
12
|
+
const { offsetLeft } = e?.target;
|
|
13
|
+
const { width: tabWidth } = (e?.target).getBoundingClientRect();
|
|
14
|
+
const { width: listWidth } = tabsListRef.current.getBoundingClientRect();
|
|
26
15
|
const extraSideSpace = listWidth - tabWidth;
|
|
27
16
|
const leftOffsetToCenter = extraSideSpace > 0 ? extraSideSpace / 2 : 0;
|
|
28
17
|
const centeredLeftOffset = offsetLeft > leftOffsetToCenter ? offsetLeft - leftOffsetToCenter : 0;
|
|
29
18
|
tabsListRef.current.scrollTo({
|
|
30
19
|
top: 0,
|
|
31
20
|
left: centeredLeftOffset,
|
|
32
|
-
behavior:
|
|
21
|
+
behavior: "smooth"
|
|
33
22
|
});
|
|
34
|
-
e
|
|
23
|
+
e?.preventDefault();
|
|
35
24
|
}
|
|
36
25
|
}, [tabsListRef]);
|
|
37
26
|
const handleOnTabChange = useCallback((tabId, e) => {
|
|
38
27
|
setInternalActiveTab(tabId);
|
|
39
28
|
onTabChange(tabId, e);
|
|
40
|
-
|
|
41
29
|
if (isDSMobile && !fixedTabsHeaders && e) {
|
|
42
30
|
centerTabWhenTabChangeMobile(e);
|
|
43
31
|
}
|
|
44
32
|
}, [centerTabWhenTabChangeMobile, fixedTabsHeaders, isDSMobile, onTabChange, setInternalActiveTab]);
|
|
45
|
-
const handleOnMouseDown = useCallback(e => {
|
|
46
|
-
const role = e.target.getAttribute(
|
|
47
|
-
if (role !==
|
|
33
|
+
const handleOnMouseDown = useCallback((e) => {
|
|
34
|
+
const role = e.target.getAttribute("role");
|
|
35
|
+
if (role !== "tabpanel" && allowTextSelection)
|
|
36
|
+
e.stopPropagation();
|
|
48
37
|
}, [allowTextSelection]);
|
|
49
38
|
return {
|
|
50
39
|
handleOnTabChange,
|
|
51
40
|
handleOnMouseDown
|
|
52
41
|
};
|
|
53
42
|
};
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
export {
|
|
44
|
+
useTabsCallbacks
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=useTabsCallbacks.js.map
|