@elliemae/ds-tabs 3.0.0-alpha.0 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/config/useTabs.js +8 -2
- package/dist/cjs/config/useTabs.js.map +2 -2
- package/dist/cjs/exportsRelated/DSTab.js +15 -3
- package/dist/cjs/exportsRelated/DSTab.js.map +1 -1
- package/dist/cjs/parts/tabBar/TabBar.js +9 -9
- package/dist/cjs/parts/tabBar/TabBar.js.map +2 -2
- package/dist/cjs/parts/tabsContent/TabsContent.js +19 -3
- package/dist/cjs/parts/tabsContent/TabsContent.js.map +1 -1
- package/dist/cjs/parts/tabsPanel/TabsPanels.js +24 -8
- package/dist/cjs/parts/tabsPanel/TabsPanels.js.map +2 -2
- package/dist/cjs/utils/helpers.js +0 -4
- package/dist/cjs/utils/helpers.js.map +2 -2
- package/dist/esm/config/useTabs.js +8 -2
- package/dist/esm/config/useTabs.js.map +2 -2
- package/dist/esm/exportsRelated/DSTab.js +17 -3
- package/dist/esm/exportsRelated/DSTab.js.map +1 -1
- package/dist/esm/parts/tabBar/TabBar.js +9 -9
- package/dist/esm/parts/tabBar/TabBar.js.map +2 -2
- package/dist/esm/parts/tabsContent/TabsContent.js +21 -3
- package/dist/esm/parts/tabsContent/TabsContent.js.map +1 -1
- package/dist/esm/parts/tabsPanel/TabsPanels.js +24 -8
- package/dist/esm/parts/tabsPanel/TabsPanels.js.map +2 -2
- package/dist/esm/utils/helpers.js +0 -4
- package/dist/esm/utils/helpers.js.map +2 -2
- package/package.json +7 -6
- package/dist/types/DSTabs.d.ts +0 -14
- package/dist/types/DSTabsCTX.d.ts +0 -4
- package/dist/types/DSTabsDatatestid.d.ts +0 -12
- package/dist/types/DSTabsTypes.d.ts +0 -205
- package/dist/types/config/useCrossRef.d.ts +0 -2
- package/dist/types/config/useTabs.d.ts +0 -2
- package/dist/types/defaultProps.d.ts +0 -2
- package/dist/types/exportsRelated/DSTab.d.ts +0 -14
- package/dist/types/index.d.ts +0 -5
- package/dist/types/parts/carousel/Carousel.d.ts +0 -3
- package/dist/types/parts/carousel/styles.d.ts +0 -9
- package/dist/types/parts/carousel/useCarousel.d.ts +0 -2
- package/dist/types/parts/carousel/useCarouselCallbacks.d.ts +0 -2
- package/dist/types/parts/tabBar/TabBar.d.ts +0 -2
- package/dist/types/parts/tabBar/styles.d.ts +0 -7
- package/dist/types/parts/tabBar/useTabBar.d.ts +0 -2
- package/dist/types/parts/tabsContent/TabsContent.d.ts +0 -2
- package/dist/types/parts/tabsContent/styles.d.ts +0 -1
- package/dist/types/parts/tabsPanel/TabsPanels.d.ts +0 -2
- package/dist/types/parts/tabsPanel/styles.d.ts +0 -2
- package/dist/types/propTypes.d.ts +0 -54
- package/dist/types/tests/DSTabs.callbacks.test.d.ts +0 -1
- package/dist/types/tests/DSTabs.func.test.d.ts +0 -1
- package/dist/types/tests/DSTabs.keyboard.test.d.ts +0 -1
- package/dist/types/tests/DSTabs.test.d.ts +0 -1
- package/dist/types/utils/constants.d.ts +0 -18
- package/dist/types/utils/helpers.d.ts +0 -9
- package/dist/types/utils/hooks/useKeyboardNavigation.d.ts +0 -2
- package/dist/types/utils/hooks/useTabsCallbacks.d.ts +0 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React2, { useMemo, useContext, useCallback } from "react";
|
|
3
3
|
import SwipeableViews from "react-swipeable-views";
|
|
4
|
-
import { getIdByIndex, getIndexById } from "../../utils/helpers";
|
|
5
4
|
import { StyledPanelContainer } from "./styles";
|
|
6
5
|
import { DSTabsContext } from "../../DSTabsCTX";
|
|
7
6
|
import { useTabsCallbacks } from "../../utils/hooks/useTabsCallbacks";
|
|
@@ -12,15 +11,32 @@ const TabsPanels = () => {
|
|
|
12
11
|
props: { animated, enableMouseEvents, onlyRenderActiveTab, children: tabs, isDSMobile }
|
|
13
12
|
} = useContext(DSTabsContext);
|
|
14
13
|
const { handleOnTabChange, handleOnMouseDown } = useTabsCallbacks();
|
|
15
|
-
const handleOnChangeIndex = useCallback((index) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const handleOnChangeIndex = useCallback((index, indexLatest) => {
|
|
15
|
+
if (!focusableTabsRef.current)
|
|
16
|
+
return;
|
|
17
|
+
const offset = index - indexLatest;
|
|
18
|
+
if (focusableTabsRef.current) {
|
|
19
|
+
const currentIndexFocusable = focusableTabsRef.current?.findIndex((el) => el.dataset.tabId === actualActiveTab);
|
|
20
|
+
const newFocusableIndex = currentIndexFocusable >= 0 ? currentIndexFocusable + offset : -1;
|
|
21
|
+
if (newFocusableIndex < 0 || newFocusableIndex > focusableTabsRef.current?.length || !focusableTabsRef.current?.[newFocusableIndex])
|
|
22
|
+
return;
|
|
23
|
+
handleOnTabChange(focusableTabsRef.current[newFocusableIndex].dataset?.tabId);
|
|
24
|
+
focusableTabsRef.current[newFocusableIndex].click();
|
|
25
|
+
}
|
|
26
|
+
}, [actualActiveTab, focusableTabsRef, handleOnTabChange]);
|
|
27
|
+
const firstSlideToShow = useMemo(() => {
|
|
28
|
+
const childrenArray = React2.Children.toArray(tabs);
|
|
29
|
+
const index = childrenArray.filter((tab) => tab.props.disabled !== true).findIndex((tab) => tab.props.tabId === actualActiveTab);
|
|
30
|
+
if (index === -1)
|
|
31
|
+
return 0;
|
|
32
|
+
return index;
|
|
33
|
+
}, [actualActiveTab, tabs]);
|
|
20
34
|
const panels = useMemo(() => React2.Children.map(tabs, (tab) => {
|
|
21
|
-
const { tabId: panelId = "", style, children: content } = tab.props;
|
|
35
|
+
const { tabId: panelId = "", style, children: content, disabled } = tab.props;
|
|
22
36
|
const isActive = actualActiveTab === panelId;
|
|
23
37
|
const shouldRender = !onlyRenderActiveTab || isActive;
|
|
38
|
+
if (disabled)
|
|
39
|
+
return null;
|
|
24
40
|
return shouldRender && /* @__PURE__ */ React2.createElement(StyledPanelContainer, {
|
|
25
41
|
key: panelId,
|
|
26
42
|
id: panelId,
|
|
@@ -38,7 +54,7 @@ const TabsPanels = () => {
|
|
|
38
54
|
if (animated) {
|
|
39
55
|
return /* @__PURE__ */ React2.createElement(SwipeableViews, {
|
|
40
56
|
enableMouseEvents,
|
|
41
|
-
index:
|
|
57
|
+
index: firstSlideToShow,
|
|
42
58
|
onChangeIndex: handleOnChangeIndex
|
|
43
59
|
}, panels);
|
|
44
60
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 {
|
|
5
|
-
"mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;
|
|
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 { 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, indexLatest: number) => {\n if (!focusableTabsRef.current) return;\n\n const offset = index - indexLatest;\n\n if (focusableTabsRef.current) {\n const currentIndexFocusable = focusableTabsRef.current?.findIndex((el) => el.dataset.tabId === actualActiveTab);\n\n const newFocusableIndex = currentIndexFocusable >= 0 ? currentIndexFocusable + offset : -1;\n\n if (\n newFocusableIndex < 0 ||\n newFocusableIndex > focusableTabsRef.current?.length ||\n !focusableTabsRef.current?.[newFocusableIndex]\n )\n return;\n handleOnTabChange(focusableTabsRef.current[newFocusableIndex].dataset?.tabId as string);\n\n // swiping does not trigger centerTab function inside handleOnTabChange because there is no event\n // by clicking we are manually forcing to center the tab\n\n focusableTabsRef.current[newFocusableIndex].click();\n }\n },\n [actualActiveTab, focusableTabsRef, handleOnTabChange],\n );\n\n const firstSlideToShow = useMemo(() => {\n const childrenArray = React.Children.toArray(tabs) as React.ReactElement<DSTabPropsWithDefaultT>[];\n const index = childrenArray\n .filter((tab) => tab.props.disabled !== true)\n .findIndex((tab) => tab.props.tabId === actualActiveTab);\n\n if (index === -1) return 0;\n return index;\n }, [actualActiveTab, tabs]);\n\n const panels = useMemo(\n () =>\n React.Children.map(tabs, (tab: React.ReactElement<DSTabPropsWithDefaultT>) => {\n const { tabId: panelId = '', style, children: content, disabled } = tab.props;\n const isActive = actualActiveTab === panelId;\n const shouldRender = !onlyRenderActiveTab || isActive;\n\n if (disabled) return null;\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={firstSlideToShow}\n onChangeIndex={handleOnChangeIndex}\n >\n {panels}\n </SwipeableViews>\n );\n }\n\n return <>{panels}</>;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;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,OAAe,gBAAwB;AACtC,QAAI,CAAC,iBAAiB;AAAS;AAE/B,UAAM,SAAS,QAAQ;AAEvB,QAAI,iBAAiB,SAAS;AAC5B,YAAM,wBAAwB,iBAAiB,SAAS,UAAU,CAAC,OAAO,GAAG,QAAQ,UAAU;AAE/F,YAAM,oBAAoB,yBAAyB,IAAI,wBAAwB,SAAS;AAExF,UACE,oBAAoB,KACpB,oBAAoB,iBAAiB,SAAS,UAC9C,CAAC,iBAAiB,UAAU;AAE5B;AACF,wBAAkB,iBAAiB,QAAQ,mBAAmB,SAAS;AAKvE,uBAAiB,QAAQ,mBAAmB;AAAA;AAAA,KAGhD,CAAC,iBAAiB,kBAAkB;AAGtC,QAAM,mBAAmB,QAAQ,MAAM;AACrC,UAAM,gBAAgB,OAAM,SAAS,QAAQ;AAC7C,UAAM,QAAQ,cACX,OAAO,CAAC,QAAQ,IAAI,MAAM,aAAa,MACvC,UAAU,CAAC,QAAQ,IAAI,MAAM,UAAU;AAE1C,QAAI,UAAU;AAAI,aAAO;AACzB,WAAO;AAAA,KACN,CAAC,iBAAiB;AAErB,QAAM,SAAS,QACb,MACE,OAAM,SAAS,IAAI,MAAM,CAAC,QAAoD;AAC5E,UAAM,EAAE,OAAO,UAAU,IAAI,OAAO,UAAU,SAAS,aAAa,IAAI;AACxE,UAAM,WAAW,oBAAoB;AACrC,UAAM,eAAe,CAAC,uBAAuB;AAE7C,QAAI;AAAU,aAAO;AACrB,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,MACP,eAAe;AAAA,OAEd;AAAA;AAKP,SAAO,4DAAG;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -42,14 +42,10 @@ const getVisibleDimensions = (node, referenceNode) => {
|
|
|
42
42
|
height: Math.min(node.clientHeight, referenceNodeDimensions.top + referenceNode.clientHeight - nodeDimensions.top, node.clientHeight - (referenceNodeDimensions.top - nodeDimensions.top))
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
|
-
const getIndexById = (children, activeId) => children && children.findIndex((item) => item.props.tabId === activeId);
|
|
46
|
-
const getIdByIndex = (children, index) => children && children[index].props.tabId || "";
|
|
47
45
|
const shouldHaveLeftGradient = (scrollLeft) => Math.abs(scrollLeft) > MOBILE_GRADIENT_WIDTH;
|
|
48
46
|
const shouldHaveRightGradient = (scrollLeft, clientWidth, scrollWidth) => Math.abs(scrollLeft) <= scrollWidth - (clientWidth + MOBILE_GRADIENT_WIDTH);
|
|
49
47
|
export {
|
|
50
48
|
centerTab,
|
|
51
|
-
getIdByIndex,
|
|
52
|
-
getIndexById,
|
|
53
49
|
getVisibleDimensions,
|
|
54
50
|
isElementVisible,
|
|
55
51
|
isElementVisibleCarousel,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { CenterTabPropsT,
|
|
5
|
-
"mappings": "AAAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport type { CenterTabPropsT, 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 centerTab = ({ e, listRef }: CenterTabPropsT) => {\n if (listRef.current) {\n const { offsetLeft } = e?.target as HTMLButtonElement;\n const { width: tabWidth } = (e?.target as HTMLButtonElement).getBoundingClientRect();\n const { width: listWidth } = listRef.current.getBoundingClientRect();\n const extraSideSpace = listWidth - tabWidth;\n const leftOffsetToCenter = extraSideSpace > 0 ? extraSideSpace / 2 : 0;\n const centeredLeftOffset = offsetLeft > leftOffsetToCenter ? offsetLeft - leftOffsetToCenter : 0;\n listRef.current.scrollTo({\n top: 0,\n left: centeredLeftOffset,\n behavior: 'smooth',\n });\n\n e?.preventDefault();\n }\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 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;ACEA;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,YAAY,CAAC,EAAE,GAAG,cAA+B;AAC5D,MAAI,QAAQ,SAAS;AACnB,UAAM,EAAE,eAAe,GAAG;AAC1B,UAAM,EAAE,OAAO,aAAc,IAAG,QAA6B;AAC7D,UAAM,EAAE,OAAO,cAAc,QAAQ,QAAQ;AAC7C,UAAM,iBAAiB,YAAY;AACnC,UAAM,qBAAqB,iBAAiB,IAAI,iBAAiB,IAAI;AACrE,UAAM,qBAAqB,aAAa,qBAAqB,aAAa,qBAAqB;AAC/F,YAAQ,QAAQ,SAAS;AAAA,MACvB,KAAK;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA;AAGZ,OAAG;AAAA;AAAA;AAIA,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,yBAAyB,CAAC,eAAgC,KAAK,IAAI,cAAc;AAEvF,MAAM,0BAA0B,CAAC,YAAoB,aAAqB,gBAC/E,KAAK,IAAI,eAAe,cAAe,eAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-tabs",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Tabs",
|
|
6
6
|
"files": [
|
|
@@ -131,11 +131,11 @@
|
|
|
131
131
|
"indent": 4
|
|
132
132
|
},
|
|
133
133
|
"dependencies": {
|
|
134
|
-
"@elliemae/ds-button": "3.0.0-alpha.
|
|
135
|
-
"@elliemae/ds-icon": "3.0.0-alpha.
|
|
136
|
-
"@elliemae/ds-icons": "3.0.0-alpha.
|
|
137
|
-
"@elliemae/ds-props-helpers": "3.0.0-alpha.
|
|
138
|
-
"@elliemae/ds-system": "3.0.0-alpha.
|
|
134
|
+
"@elliemae/ds-button": "3.0.0-alpha.1",
|
|
135
|
+
"@elliemae/ds-icon": "3.0.0-alpha.1",
|
|
136
|
+
"@elliemae/ds-icons": "3.0.0-alpha.1",
|
|
137
|
+
"@elliemae/ds-props-helpers": "3.0.0-alpha.1",
|
|
138
|
+
"@elliemae/ds-system": "3.0.0-alpha.1",
|
|
139
139
|
"@react-hook/resize-observer": "~1.2.5",
|
|
140
140
|
"prop-types": "~15.7.2",
|
|
141
141
|
"react-desc": "~4.1.3",
|
|
@@ -161,6 +161,7 @@
|
|
|
161
161
|
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
162
162
|
"test": "node ../../scripts/testing/test.mjs",
|
|
163
163
|
"lint": "node ../../scripts/lint.mjs",
|
|
164
|
+
"dts": "node ../../scripts/dts.mjs",
|
|
164
165
|
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
165
166
|
}
|
|
166
167
|
}
|
package/dist/types/DSTabs.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { DSTabsPropsT } from './DSTabsTypes';
|
|
4
|
-
declare const DSTabs: {
|
|
5
|
-
(props: DSTabsPropsT): JSX.Element;
|
|
6
|
-
propTypes: React.WeakValidationMap<unknown>;
|
|
7
|
-
};
|
|
8
|
-
declare const DSTabsWithSchema: {
|
|
9
|
-
(props?: DSTabsPropsT | undefined): JSX.Element;
|
|
10
|
-
propTypes: unknown;
|
|
11
|
-
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
12
|
-
};
|
|
13
|
-
export { DSTabs, DSTabsWithSchema };
|
|
14
|
-
export default DSTabs;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { DSTabsUseCrossRefContextT, DSTabsUseTabsContextT } from './DSTabsTypes';
|
|
3
|
-
export declare const DSTabsContext: import("react").Context<DSTabsUseTabsContextT>;
|
|
4
|
-
export declare const DSTabsCrossRefContext: import("react").Context<DSTabsUseCrossRefContextT>;
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { TabTypes } from './utils/constants';
|
|
3
|
-
declare type TabTypesT = typeof TabTypes[keyof typeof TabTypes];
|
|
4
|
-
export interface DSTabsPropsT {
|
|
5
|
-
containerProps?: Record<string, unknown>;
|
|
6
|
-
innerRef?: React.MutableRefObject<HTMLDivElement>;
|
|
7
|
-
animated?: boolean;
|
|
8
|
-
enableMouseEvents?: boolean;
|
|
9
|
-
allowTextSelection?: boolean;
|
|
10
|
-
onTabChange?: (tabId: string, e?: React.MouseEvent) => void;
|
|
11
|
-
tabsListAriaLabel?: string;
|
|
12
|
-
type?: TabTypesT;
|
|
13
|
-
tabBarExtraContent?: React.ReactNode;
|
|
14
|
-
children: React.ReactElement<DSTabPropsWithDefaultT>[];
|
|
15
|
-
onlyRenderActiveTab?: boolean;
|
|
16
|
-
activeTab?: string;
|
|
17
|
-
withCarousel?: boolean;
|
|
18
|
-
firstSubtabRef?: React.MutableRefObject<HTMLElement>;
|
|
19
|
-
lastTabRef?: React.MutableRefObject<HTMLElement>;
|
|
20
|
-
fixedTabsHeaders?: boolean;
|
|
21
|
-
isDSMobile?: boolean;
|
|
22
|
-
showSelectionIndicator?: boolean;
|
|
23
|
-
showSeparator?: boolean;
|
|
24
|
-
}
|
|
25
|
-
export interface DSTabsPropsWithDefaultsT {
|
|
26
|
-
containerProps: Record<string, unknown>;
|
|
27
|
-
innerRef?: React.MutableRefObject<HTMLDivElement>;
|
|
28
|
-
animated: boolean;
|
|
29
|
-
enableMouseEvents: boolean;
|
|
30
|
-
allowTextSelection: boolean;
|
|
31
|
-
onTabChange: (tabId: string, e?: React.MouseEvent) => void;
|
|
32
|
-
tabsListAriaLabel: string;
|
|
33
|
-
type: TabTypesT;
|
|
34
|
-
tabBarExtraContent?: React.ReactNode;
|
|
35
|
-
children: React.ReactElement<DSTabPropsWithDefaultT>[];
|
|
36
|
-
onlyRenderActiveTab: boolean;
|
|
37
|
-
activeTab?: string;
|
|
38
|
-
withCarousel: boolean;
|
|
39
|
-
firstSubtabRef?: React.MutableRefObject<HTMLElement>;
|
|
40
|
-
lastTabRef?: React.MutableRefObject<HTMLElement>;
|
|
41
|
-
fixedTabsHeaders: boolean;
|
|
42
|
-
isDSMobile: boolean;
|
|
43
|
-
showSelectionIndicator: boolean;
|
|
44
|
-
showSeparator: boolean;
|
|
45
|
-
}
|
|
46
|
-
export interface DSTabsDefaultPropsT {
|
|
47
|
-
containerProps: Record<string, unknown>;
|
|
48
|
-
animated: boolean;
|
|
49
|
-
enableMouseEvents: boolean;
|
|
50
|
-
allowTextSelection: boolean;
|
|
51
|
-
onTabChange: (tabId: string, e?: React.MouseEvent) => void;
|
|
52
|
-
tabsListAriaLabel: string;
|
|
53
|
-
type: TabTypesT;
|
|
54
|
-
onlyRenderActiveTab: boolean;
|
|
55
|
-
fixedTabsHeaders: boolean;
|
|
56
|
-
children: React.ReactElement<DSTabPropsWithDefaultT>[];
|
|
57
|
-
withCarousel: boolean;
|
|
58
|
-
isDSMobile: boolean;
|
|
59
|
-
showSelectionIndicator: boolean;
|
|
60
|
-
showSeparator: boolean;
|
|
61
|
-
}
|
|
62
|
-
export interface CarouselPropsT {
|
|
63
|
-
children: React.ReactNode[];
|
|
64
|
-
updateIndicatorStyle?: () => void;
|
|
65
|
-
}
|
|
66
|
-
export interface DSTabPropsT {
|
|
67
|
-
tabId: string;
|
|
68
|
-
title?: string;
|
|
69
|
-
required?: boolean;
|
|
70
|
-
children?: React.ReactNode;
|
|
71
|
-
style?: Record<string, unknown>;
|
|
72
|
-
disabled?: boolean;
|
|
73
|
-
ref?: React.MutableRefObject<HTMLButtonElement>;
|
|
74
|
-
onClick?: (tabId: string, e: React.MouseEvent) => null | void;
|
|
75
|
-
onKeyDown?: (e: React.KeyboardEvent) => null | void;
|
|
76
|
-
}
|
|
77
|
-
export interface DSTabPropsWithDefaultT {
|
|
78
|
-
tabId: string;
|
|
79
|
-
title: string;
|
|
80
|
-
required: boolean;
|
|
81
|
-
children?: React.ReactNode;
|
|
82
|
-
style?: Record<string, unknown>;
|
|
83
|
-
disabled: boolean;
|
|
84
|
-
ref?: React.MutableRefObject<HTMLButtonElement>;
|
|
85
|
-
onClick?: (tabId: string, e: React.MouseEvent) => null | void;
|
|
86
|
-
onKeyDown?: (e: React.KeyboardEvent) => null | void;
|
|
87
|
-
}
|
|
88
|
-
export interface CarouselButtonsPropsT {
|
|
89
|
-
leftButtonOnClick: () => void;
|
|
90
|
-
rightButtonOnClick: () => void;
|
|
91
|
-
showChevrons: ShowChevronsT;
|
|
92
|
-
type: TabTypesT;
|
|
93
|
-
}
|
|
94
|
-
export interface DSTabsUseCrossRefContextT {
|
|
95
|
-
lastTabInternalRef: React.MutableRefObject<HTMLButtonElement | null | undefined>;
|
|
96
|
-
firstSubtabInternalRef: React.MutableRefObject<HTMLButtonElement | null | undefined>;
|
|
97
|
-
}
|
|
98
|
-
export interface DSTabsUseTabsContextT {
|
|
99
|
-
props: DSTabsPropsWithDefaultsT;
|
|
100
|
-
tabsRef: React.MutableRefObject<Record<number, HTMLButtonElement> | null>;
|
|
101
|
-
focusableTabsRef: React.MutableRefObject<HTMLButtonElement[] | null>;
|
|
102
|
-
tabsListRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
103
|
-
tabsRefAsArray: React.MutableRefObject<HTMLButtonElement[] | null>;
|
|
104
|
-
actualActiveTabRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
105
|
-
carouselOnlyListRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
106
|
-
setInternalActiveTab: React.Dispatch<React.SetStateAction<string>>;
|
|
107
|
-
actualActiveTab: string;
|
|
108
|
-
}
|
|
109
|
-
export interface UseRezisePropsT {
|
|
110
|
-
ref: React.MutableRefObject<HTMLDivElement | null>;
|
|
111
|
-
callback: () => void;
|
|
112
|
-
}
|
|
113
|
-
export interface UseCarouselPropsT {
|
|
114
|
-
updateIndicatorStyle?: () => void;
|
|
115
|
-
}
|
|
116
|
-
export interface ShowChevronsT {
|
|
117
|
-
right: boolean;
|
|
118
|
-
left: boolean;
|
|
119
|
-
}
|
|
120
|
-
export interface MobileGradientsT {
|
|
121
|
-
right: boolean;
|
|
122
|
-
left: boolean;
|
|
123
|
-
}
|
|
124
|
-
export interface IndicatorStyleT {
|
|
125
|
-
left: string;
|
|
126
|
-
width: string;
|
|
127
|
-
backgroundWithTransparent: string;
|
|
128
|
-
}
|
|
129
|
-
export interface UseCarouselReturnTypeT {
|
|
130
|
-
showChevrons: ShowChevronsT;
|
|
131
|
-
leftButtonOnClick: () => void;
|
|
132
|
-
rightButtonOnClick: () => void;
|
|
133
|
-
handleOnClick: (e: React.MouseEvent) => void;
|
|
134
|
-
handleOnScroll: (e: React.UIEvent) => void;
|
|
135
|
-
}
|
|
136
|
-
export interface UseCarouselCallbacksPropsT {
|
|
137
|
-
getVisibleItemsOffset: () => number;
|
|
138
|
-
recalcChevrons: () => void;
|
|
139
|
-
updateIndicatorStyle?: () => void;
|
|
140
|
-
}
|
|
141
|
-
export interface UseCarouselCallbacksReturnTypeT {
|
|
142
|
-
leftButtonOnClick: () => void;
|
|
143
|
-
rightButtonOnClick: () => void;
|
|
144
|
-
handleOnClick: (e: React.MouseEvent) => void;
|
|
145
|
-
handleOnScroll: (e: React.UIEvent) => void;
|
|
146
|
-
}
|
|
147
|
-
export interface UseKeyboardNavigationReturnTypeT {
|
|
148
|
-
handleOnKeyDown: (e: React.KeyboardEvent) => void;
|
|
149
|
-
}
|
|
150
|
-
export interface UseTabsCallbacksReturnTypeT {
|
|
151
|
-
handleOnTabChange: (tabId: string, e?: React.MouseEvent) => void;
|
|
152
|
-
handleOnMouseDown: (e: React.MouseEvent) => void;
|
|
153
|
-
}
|
|
154
|
-
export interface UseTabBarReturnTypeT {
|
|
155
|
-
updateIndicatorStyle: () => void;
|
|
156
|
-
updateMobileGradients: () => void;
|
|
157
|
-
setIndicatorStyle: React.Dispatch<React.SetStateAction<IndicatorStyleT>>;
|
|
158
|
-
indicatorStyle: IndicatorStyleT;
|
|
159
|
-
mobileGradients: MobileGradientsT;
|
|
160
|
-
}
|
|
161
|
-
export interface VisibleDimensionsT {
|
|
162
|
-
width: number;
|
|
163
|
-
height: number;
|
|
164
|
-
}
|
|
165
|
-
export interface CenterTabPropsT {
|
|
166
|
-
e?: React.MouseEvent | React.FocusEvent;
|
|
167
|
-
listRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
168
|
-
}
|
|
169
|
-
export interface StyledTabWrapperPropsT {
|
|
170
|
-
isDSMobile: boolean;
|
|
171
|
-
fixedTabsHeaders: boolean;
|
|
172
|
-
}
|
|
173
|
-
export interface StyledTabListPropsT {
|
|
174
|
-
withCarousel: boolean;
|
|
175
|
-
isDSMobile: boolean;
|
|
176
|
-
fixedTabsHeaders: boolean;
|
|
177
|
-
mobileGradients: MobileGradientsT;
|
|
178
|
-
indicatorStyle: IndicatorStyleT;
|
|
179
|
-
tabType: TabTypesT;
|
|
180
|
-
}
|
|
181
|
-
export interface StyledSubTabsListPropsT {
|
|
182
|
-
withCarousel: boolean;
|
|
183
|
-
}
|
|
184
|
-
export interface StyledTabButtonPropsT {
|
|
185
|
-
isActive: boolean;
|
|
186
|
-
disabled: boolean;
|
|
187
|
-
showSeparator: boolean;
|
|
188
|
-
isDSMobile: boolean;
|
|
189
|
-
fixedTabsHeaders: boolean;
|
|
190
|
-
withCarousel: boolean;
|
|
191
|
-
tabType: TabTypesT;
|
|
192
|
-
}
|
|
193
|
-
export interface StyledCarouselButtonWrapperPropsT {
|
|
194
|
-
right?: boolean;
|
|
195
|
-
tabType: TabTypesT;
|
|
196
|
-
}
|
|
197
|
-
export interface StyledPanelContainerPropsT {
|
|
198
|
-
hidden: boolean;
|
|
199
|
-
isDSMobile: boolean;
|
|
200
|
-
}
|
|
201
|
-
export interface StyledSelectionIndicatoPropsT {
|
|
202
|
-
isDSMobile: boolean;
|
|
203
|
-
tabType: TabTypesT;
|
|
204
|
-
}
|
|
205
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { DSTabPropsT } from '../DSTabsTypes';
|
|
4
|
-
declare const DSTab: {
|
|
5
|
-
(props: DSTabPropsT): JSX.Element;
|
|
6
|
-
propTypes: React.WeakValidationMap<unknown>;
|
|
7
|
-
};
|
|
8
|
-
declare const DSTabWithSchema: {
|
|
9
|
-
(props?: DSTabPropsT | undefined): JSX.Element;
|
|
10
|
-
propTypes: unknown;
|
|
11
|
-
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
12
|
-
};
|
|
13
|
-
export { DSTab, DSTabWithSchema };
|
|
14
|
-
export default DSTab;
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { StyledCarouselButtonWrapperPropsT } from '../../DSTabsTypes';
|
|
3
|
-
export declare const StyledCarouselBtn: import("styled-components").StyledComponent<{
|
|
4
|
-
(props: import("@elliemae/ds-button/dist/types/v2/propTypes").DSButtonPropsT): JSX.Element;
|
|
5
|
-
propTypes: import("react").WeakValidationMap<unknown>;
|
|
6
|
-
}, import("styled-components").DefaultTheme, {}, never>;
|
|
7
|
-
export declare const StyledCarouselWrapper: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
8
|
-
export declare const StyledChildrenWrap: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
9
|
-
export declare const StyledCarouselButtonWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledCarouselButtonWrapperPropsT, never>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { StyledSelectionIndicatoPropsT, StyledSubTabsListPropsT, StyledTabListPropsT, StyledTabButtonPropsT, StyledTabWrapperPropsT } from '../../DSTabsTypes';
|
|
2
|
-
export declare const StyledSelectionIndicator: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledSelectionIndicatoPropsT, never>;
|
|
3
|
-
export declare const StyledTabWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledTabWrapperPropsT, never>;
|
|
4
|
-
export declare const StyledTabButton: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, StyledTabButtonPropsT, never>;
|
|
5
|
-
export declare const StyledSubTabsList: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledSubTabsListPropsT, never>;
|
|
6
|
-
export declare const StyledTabList: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledTabListPropsT, never>;
|
|
7
|
-
export declare const StyledRequiredMark: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const StyledTabBarContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
-
export declare const tabPropTypes: {
|
|
3
|
-
tabId: {
|
|
4
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
5
|
-
};
|
|
6
|
-
title: {
|
|
7
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
8
|
-
};
|
|
9
|
-
required: {
|
|
10
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
11
|
-
};
|
|
12
|
-
disabled: {
|
|
13
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare const tabsPropTypes: {
|
|
17
|
-
animated: {
|
|
18
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
19
|
-
};
|
|
20
|
-
enableMouseEvents: {
|
|
21
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
22
|
-
};
|
|
23
|
-
allowTextSelection: {
|
|
24
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
25
|
-
};
|
|
26
|
-
onTabChange: {
|
|
27
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
28
|
-
};
|
|
29
|
-
type: {
|
|
30
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
31
|
-
};
|
|
32
|
-
tabBarExtraContent: {
|
|
33
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
34
|
-
};
|
|
35
|
-
onlyRenderActiveTab: {
|
|
36
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
37
|
-
};
|
|
38
|
-
withCarousel: {
|
|
39
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
40
|
-
};
|
|
41
|
-
activeTab: {
|
|
42
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
43
|
-
};
|
|
44
|
-
children: import("react-desc").PropTypesDescValue;
|
|
45
|
-
tabsListAriaLabel: {
|
|
46
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
47
|
-
};
|
|
48
|
-
containerProps: {
|
|
49
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
50
|
-
};
|
|
51
|
-
innerRef: {
|
|
52
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare const TabTypes: {
|
|
2
|
-
NORMAL: "normal";
|
|
3
|
-
NORMAL_SMALL: "normal_small";
|
|
4
|
-
SUBTABS: "subtabs";
|
|
5
|
-
};
|
|
6
|
-
export declare const TabTypesValuesAsArray: ("normal" | "normal_small" | "subtabs")[];
|
|
7
|
-
export declare const MOBILE_GRADIENT_WIDTH = 24;
|
|
8
|
-
export declare const defaultIndicatorStyles: {
|
|
9
|
-
left: string;
|
|
10
|
-
width: string;
|
|
11
|
-
backgroundWithTransparent: string;
|
|
12
|
-
};
|
|
13
|
-
export declare const gradientOffsetsAccordingType: {
|
|
14
|
-
normal_small: number;
|
|
15
|
-
normal: number;
|
|
16
|
-
subtabs: number;
|
|
17
|
-
fixedTabsHeaders: number;
|
|
18
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { CenterTabPropsT, DSTabPropsWithDefaultT, VisibleDimensionsT } from '../DSTabsTypes';
|
|
2
|
-
export declare const isElementVisible: (tab: HTMLElement, tabList: HTMLElement) => boolean;
|
|
3
|
-
export declare const isElementVisibleCarousel: (tab: HTMLElement | null, tabContainer: HTMLDivElement | null, firstOrLastItem?: boolean) => boolean;
|
|
4
|
-
export declare const centerTab: ({ e, listRef }: CenterTabPropsT) => void;
|
|
5
|
-
export declare const getVisibleDimensions: (node: HTMLElement, referenceNode: HTMLElement) => VisibleDimensionsT;
|
|
6
|
-
export declare const getIndexById: (children: React.ReactElement<DSTabPropsWithDefaultT>[], activeId?: string | undefined) => number;
|
|
7
|
-
export declare const getIdByIndex: (children: React.ReactElement<DSTabPropsWithDefaultT>[], index: number) => string;
|
|
8
|
-
export declare const shouldHaveLeftGradient: (scrollLeft: number) => boolean;
|
|
9
|
-
export declare const shouldHaveRightGradient: (scrollLeft: number, clientWidth: number, scrollWidth: number) => boolean;
|