@elliemae/ds-tabs 2.0.0-rc.1 → 2.0.0-rc.13

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.
Files changed (105) hide show
  1. package/cjs/DSTabs.js +27 -108
  2. package/cjs/DSTabsCTX.js +30 -0
  3. package/cjs/DSTabsDatatestid.js +18 -0
  4. package/cjs/DSTabsTypes.js +2 -0
  5. package/cjs/config/useCrossRef.js +17 -0
  6. package/cjs/config/useTabs.js +51 -0
  7. package/cjs/defaultProps.js +27 -0
  8. package/cjs/{PanelContainer.js → exportsRelated/DSTab.js} +14 -30
  9. package/cjs/index.js +5 -5
  10. package/cjs/parts/carousel/Carousel.js +71 -0
  11. package/cjs/parts/carousel/styles.js +60 -0
  12. package/cjs/parts/carousel/useCarousel.js +91 -0
  13. package/cjs/parts/carousel/useCarouselCallbacks.js +72 -0
  14. package/cjs/parts/tabBar/TabBar.js +160 -0
  15. package/cjs/parts/tabBar/styles.js +199 -0
  16. package/cjs/parts/tabBar/useTabBar.js +98 -0
  17. package/cjs/parts/tabsContent/TabsContent.js +49 -0
  18. package/cjs/parts/tabsContent/styles.js +15 -0
  19. package/cjs/parts/tabsPanel/TabsPanels.js +77 -0
  20. package/cjs/parts/tabsPanel/styles.js +30 -0
  21. package/cjs/propTypes.js +33 -0
  22. package/cjs/utils/constants.js +29 -0
  23. package/cjs/utils/helpers.js +47 -0
  24. package/cjs/utils/hooks/useKeyboardNavigation.js +61 -0
  25. package/cjs/{useResize.js → utils/hooks/useResize.js} +8 -4
  26. package/cjs/utils/hooks/useTabsCallbacks.js +59 -0
  27. package/esm/DSTabs.js +29 -110
  28. package/esm/DSTabsCTX.js +25 -0
  29. package/esm/DSTabsDatatestid.js +14 -0
  30. package/esm/DSTabsTypes.js +1 -0
  31. package/esm/config/useCrossRef.js +13 -0
  32. package/esm/config/useTabs.js +47 -0
  33. package/esm/defaultProps.js +23 -0
  34. package/esm/{PanelContainer.js → exportsRelated/DSTab.js} +7 -26
  35. package/esm/index.js +4 -3
  36. package/esm/parts/carousel/Carousel.js +63 -0
  37. package/esm/parts/carousel/styles.js +49 -0
  38. package/esm/parts/carousel/useCarousel.js +87 -0
  39. package/esm/parts/carousel/useCarouselCallbacks.js +68 -0
  40. package/esm/parts/tabBar/TabBar.js +151 -0
  41. package/esm/parts/tabBar/styles.js +185 -0
  42. package/esm/parts/tabBar/useTabBar.js +90 -0
  43. package/esm/parts/tabsContent/TabsContent.js +40 -0
  44. package/esm/parts/tabsContent/styles.js +7 -0
  45. package/esm/parts/tabsPanel/TabsPanels.js +67 -0
  46. package/esm/parts/tabsPanel/styles.js +22 -0
  47. package/esm/propTypes.js +28 -0
  48. package/esm/utils/constants.js +21 -0
  49. package/esm/utils/helpers.js +37 -0
  50. package/esm/utils/hooks/useKeyboardNavigation.js +57 -0
  51. package/esm/{useResize.js → utils/hooks/useResize.js} +9 -5
  52. package/esm/utils/hooks/useTabsCallbacks.js +55 -0
  53. package/package.json +103 -36
  54. package/types/DSTabs.d.ts +10 -60
  55. package/types/DSTabsCTX.d.ts +4 -0
  56. package/types/DSTabsDatatestid.d.ts +12 -0
  57. package/types/DSTabsTypes.d.ts +202 -0
  58. package/types/config/useCrossRef.d.ts +2 -0
  59. package/types/config/useTabs.d.ts +2 -0
  60. package/types/defaultProps.d.ts +2 -0
  61. package/types/exportsRelated/DSTab.d.ts +14 -0
  62. package/types/index.d.ts +4 -3
  63. package/types/parts/carousel/Carousel.d.ts +3 -0
  64. package/types/parts/carousel/styles.d.ts +9 -0
  65. package/types/parts/carousel/useCarousel.d.ts +2 -0
  66. package/types/parts/carousel/useCarouselCallbacks.d.ts +2 -0
  67. package/types/parts/tabBar/TabBar.d.ts +2 -0
  68. package/types/parts/tabBar/styles.d.ts +7 -0
  69. package/types/parts/tabBar/useTabBar.d.ts +2 -0
  70. package/types/parts/tabsContent/TabsContent.d.ts +2 -0
  71. package/types/parts/tabsContent/styles.d.ts +1 -0
  72. package/types/parts/tabsPanel/TabsPanels.d.ts +2 -0
  73. package/types/parts/tabsPanel/styles.d.ts +2 -0
  74. package/types/propTypes.d.ts +54 -0
  75. package/types/tests/{DSTabs.events.test.d.ts → DSTabs.callbacks.test.d.ts} +0 -0
  76. package/types/tests/DSTabs.func.test.d.ts +1 -0
  77. package/types/tests/DSTabs.keyboard.test.d.ts +1 -0
  78. package/types/utils/constants.d.ts +19 -0
  79. package/types/utils/helpers.d.ts +8 -0
  80. package/types/utils/hooks/useKeyboardNavigation.d.ts +2 -0
  81. package/types/utils/hooks/useResize.d.ts +2 -0
  82. package/types/utils/hooks/useTabsCallbacks.d.ts +2 -0
  83. package/cjs/Carousel.js +0 -205
  84. package/cjs/DSTab.js +0 -46
  85. package/cjs/SubTabBar.js +0 -54
  86. package/cjs/TabBar.js +0 -421
  87. package/cjs/TabTypes.js +0 -15
  88. package/cjs/TabsImpl.js +0 -120
  89. package/cjs/TabsPanels.js +0 -85
  90. package/esm/Carousel.js +0 -196
  91. package/esm/DSTab.js +0 -36
  92. package/esm/SubTabBar.js +0 -48
  93. package/esm/TabBar.js +0 -410
  94. package/esm/TabTypes.js +0 -10
  95. package/esm/TabsImpl.js +0 -113
  96. package/esm/TabsPanels.js +0 -75
  97. package/types/Carousel.d.ts +0 -16
  98. package/types/DSTab.d.ts +0 -22
  99. package/types/PanelContainer.d.ts +0 -20
  100. package/types/SubTabBar.d.ts +0 -23
  101. package/types/TabBar.d.ts +0 -30
  102. package/types/TabTypes.d.ts +0 -5
  103. package/types/TabsImpl.d.ts +0 -37
  104. package/types/TabsPanels.d.ts +0 -5
  105. package/types/useResize.d.ts +0 -1
package/esm/TabsImpl.js DELETED
@@ -1,113 +0,0 @@
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 _jsx from '@babel/runtime/helpers/esm/jsx';
8
- import 'core-js/modules/web.dom-collections.iterator.js';
9
- import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
10
- import { aggregatedClasses } from '@elliemae/ds-classnames';
11
- import TabsPanels from './TabsPanels.js';
12
- import TabBar from './TabBar.js';
13
- import SubTabBar from './SubTabBar.js';
14
- import { TabTypes } from './TabTypes.js';
15
- import { jsxs } from 'react/jsx-runtime';
16
-
17
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
18
-
19
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
20
- const blockName = 'tabs';
21
- const StyledTabsContainer = aggregatedClasses('div')(blockName);
22
- const StyledTabBarContainer = aggregatedClasses('div')(blockName, 'tab-bar-container');
23
- const TabBarComponentsByType = {
24
- [TabTypes.NORMAL]: TabBar,
25
- [TabTypes.SUBTABS]: SubTabBar
26
- };
27
-
28
- const TabsImpl = props => {
29
- var _tabs$, _tabs$$props, _TabsPanels, _StyledTabBarContaine;
30
-
31
- const {
32
- animated,
33
- children: tabs,
34
- type,
35
- tabBarExtraContent,
36
- onTabChange,
37
- enableMouseEvents,
38
- innerRef,
39
- onlyRenderActiveTab,
40
- containerProps,
41
- allowTextSelection,
42
- tabsListAriaLabel,
43
- activeTab,
44
- firstSubtabRef,
45
- lastTabRef,
46
- withCarousel,
47
- flexibleTabsHeaders,
48
- fixedTabsHeaders,
49
- isDSMobile
50
- } = props;
51
- const [actualActiveTab, setActualActiveTab] = useState(activeTab || (tabs === null || tabs === void 0 ? void 0 : (_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : (_tabs$$props = _tabs$.props) === null || _tabs$$props === void 0 ? void 0 : _tabs$$props.tabId));
52
- const firstTabRefByParent = useRef(null);
53
- const lastTabRefByParent = useRef(null);
54
- useEffect(() => {
55
- if (activeTab) {
56
- setActualActiveTab(activeTab);
57
- }
58
- }, [activeTab]);
59
- const handleTabClick = useCallback(tab => {
60
- setActualActiveTab(tab);
61
- onTabChange(tab);
62
- }, [onTabChange]);
63
- const handleDownArrow = useCallback(e => {
64
- var _firstTabRefByParent$;
65
-
66
- e.preventDefault();
67
- e.stopPropagation();
68
- if (firstTabRefByParent !== null && firstTabRefByParent !== void 0 && firstTabRefByParent.current) (_firstTabRefByParent$ = firstTabRefByParent.current) === null || _firstTabRefByParent$ === void 0 ? void 0 : _firstTabRefByParent$.focus();
69
- }, [firstTabRefByParent]);
70
- const handleUpArrow = useCallback(e => {
71
- var _lastTabRef$current;
72
-
73
- e.preventDefault();
74
- e.stopPropagation();
75
- if (lastTabRef !== null && lastTabRef !== void 0 && lastTabRef.current) (_lastTabRef$current = lastTabRef.current) === null || _lastTabRef$current === void 0 ? void 0 : _lastTabRef$current.focus();
76
- }, [lastTabRef]);
77
- const PureTabBarComponent = useMemo(() => {
78
- const TabBarComponent = TabBarComponentsByType[type] || TabBar;
79
- return /*#__PURE__*/_jsx(TabBarComponent, {
80
- withCarousel: withCarousel,
81
- activeTab: actualActiveTab,
82
- onTabClick: handleTabClick,
83
- tabs: tabs,
84
- firstSubtabRef: firstSubtabRef,
85
- lastTabRef: lastTabRefByParent,
86
- handleDownArrow: handleDownArrow,
87
- handleUpArrow: handleUpArrow,
88
- isDSMobile: isDSMobile,
89
- flexibleTabsHeaders: flexibleTabsHeaders,
90
- fixedTabsHeaders: fixedTabsHeaders
91
- });
92
- }, [type, withCarousel, actualActiveTab, handleTabClick, tabs, firstSubtabRef, lastTabRefByParent, handleDownArrow, handleUpArrow, isDSMobile]);
93
- const PureTabsPanels = useMemo(() => _TabsPanels || (_TabsPanels = /*#__PURE__*/_jsx(TabsPanels, {
94
- activeTab: actualActiveTab,
95
- allowTextSelection: allowTextSelection,
96
- animated: animated,
97
- enableMouseEvents: enableMouseEvents,
98
- onlyRenderActiveTab: onlyRenderActiveTab,
99
- onTabChange: handleTabClick,
100
- tabsComponents: tabs,
101
- lastTabRef: lastTabRefByParent,
102
- firstTabRefByParent: firstTabRefByParent
103
- })), [actualActiveTab, allowTextSelection, animated, enableMouseEvents, onlyRenderActiveTab, handleTabClick, tabs, lastTabRefByParent, firstTabRefByParent]);
104
- const PureTabsImpl = useMemo(() => /*#__PURE__*/jsxs(StyledTabsContainer, _objectSpread(_objectSpread({}, containerProps), {}, {
105
- "aria-label": tabsListAriaLabel,
106
- innerRef: innerRef,
107
- role: "tablist",
108
- children: [_StyledTabBarContaine || (_StyledTabBarContaine = /*#__PURE__*/_jsx(StyledTabBarContainer, {}, void 0, PureTabBarComponent, tabBarExtraContent)), PureTabsPanels]
109
- })), [containerProps, tabsListAriaLabel, innerRef, PureTabBarComponent, tabBarExtraContent, PureTabsPanels]);
110
- return PureTabsImpl;
111
- };
112
-
113
- export { TabsImpl as default };
package/esm/TabsPanels.js DELETED
@@ -1,75 +0,0 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
- import 'core-js/modules/web.dom-collections.iterator.js';
4
- import 'core-js/modules/esnext.async-iterator.map.js';
5
- import 'core-js/modules/esnext.iterator.map.js';
6
- import React, { Component } from 'react';
7
- import memoizeOne from 'memoize-one';
8
- import { aggregatedClasses } from '@elliemae/ds-classnames';
9
- import SwipeableViews from 'react-swipeable-views';
10
- import PanelContainer from './PanelContainer.js';
11
-
12
- const blockName = 'tabs-panels';
13
- const Panels = aggregatedClasses('div')(blockName);
14
-
15
- const getIndexById = (children, activeId) => children && children.findIndex(item => item.props.tabId === activeId);
16
-
17
- const getIdByIndex = (children, index) => children && children[index].props.tabId;
18
-
19
- class TabsPanels extends Component {
20
- constructor() {
21
- super(...arguments);
22
-
23
- _defineProperty(this, "renderPanels", memoizeOne((activeTab, tabsComponents) => {
24
- const {
25
- animated,
26
- onlyRenderActiveTab,
27
- allowTextSelection
28
- } = this.props;
29
- return React.Children.map(tabsComponents, tab => {
30
- const {
31
- tabId: panelId,
32
- style,
33
- children: content
34
- } = tab.props;
35
- const isActive = activeTab === panelId;
36
- const shouldRender = !onlyRenderActiveTab || isActive;
37
- return /*#__PURE__*/_jsx(PanelContainer, {
38
- "aria-labelledby": "".concat(panelId, "-label"),
39
- lastTabRef: this.props.lastTabRef,
40
- firstSubtabRef: this.props.firstTabRefByParent,
41
- classProps: {
42
- isActive
43
- },
44
- "data-panel-id": panelId,
45
- hidden: !animated && !isActive,
46
- onMouseDown: e => {
47
- const role = e.target.getAttribute('role');
48
- if (role !== 'tabpanel' && allowTextSelection) e.stopPropagation();
49
- },
50
- role: "tabpanel",
51
- style: style
52
- }, panelId, shouldRender && content);
53
- }, null);
54
- }));
55
- }
56
-
57
- render() {
58
- const {
59
- activeTab,
60
- tabsComponents,
61
- animated,
62
- onTabChange,
63
- enableMouseEvents
64
- } = this.props;
65
- const panels = animated ? /*#__PURE__*/_jsx(SwipeableViews, {
66
- enableMouseEvents: enableMouseEvents,
67
- index: getIndexById(tabsComponents, activeTab),
68
- onChangeIndex: index => onTabChange(getIdByIndex(tabsComponents, index))
69
- }, void 0, this.renderPanels(activeTab, tabsComponents)) : this.renderPanels(activeTab, tabsComponents);
70
- return /*#__PURE__*/_jsx(Panels, {}, void 0, panels);
71
- }
72
-
73
- }
74
-
75
- export { TabsPanels as default };
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- import PropTypes from 'prop-types';
3
- declare const Carousel: {
4
- ({ children, onScroll }: {
5
- children: any;
6
- onScroll: any;
7
- }): JSX.Element;
8
- defaultProps: {
9
- onScroll: () => null;
10
- };
11
- propTypes: {
12
- children: PropTypes.Validator<(PropTypes.ReactElementLike | null | undefined)[]>;
13
- onScroll: PropTypes.Requireable<(...args: any[]) => any>;
14
- };
15
- };
16
- export default Carousel;
package/types/DSTab.d.ts DELETED
@@ -1,22 +0,0 @@
1
- /// <reference types="react" />
2
- declare const DSTab: {
3
- ({ tabId, title, required }: {
4
- tabId?: string | undefined;
5
- title?: string | undefined;
6
- required?: boolean | undefined;
7
- }): JSX.Element;
8
- displayName: string;
9
- propTypes: {
10
- /** unique id for tab */
11
- tabId: any;
12
- /** tab title */
13
- title: any;
14
- /** Show a required mark next to the title */
15
- required: any;
16
- /** Whether or not it's a ds-tab from DSMobile tabs */
17
- isDSMobile: any;
18
- };
19
- };
20
- declare const DSTabWithSchema: any;
21
- export { DSTab, DSTabWithSchema };
22
- export default DSTab;
@@ -1,20 +0,0 @@
1
- /// <reference types="react" />
2
- import PropTypes from 'prop-types';
3
- declare const PanelContainer: {
4
- ({ children, lastTabRef, firstSubtabRef, ...rest }: {
5
- [x: string]: any;
6
- children: any;
7
- lastTabRef: any;
8
- firstSubtabRef: any;
9
- }): JSX.Element;
10
- propTypes: {
11
- children: PropTypes.Requireable<any>;
12
- firstSubtabRef: PropTypes.Requireable<((...args: any[]) => any) | PropTypes.InferProps<{
13
- current: PropTypes.Requireable<any>;
14
- }>>;
15
- lastTabRef: PropTypes.Requireable<((...args: any[]) => any) | PropTypes.InferProps<{
16
- current: PropTypes.Requireable<any>;
17
- }>>;
18
- };
19
- };
20
- export default PanelContainer;
@@ -1,23 +0,0 @@
1
- /// <reference types="react" />
2
- import PropTypes from 'prop-types';
3
- declare const SubTabBar: {
4
- ({ withCarousel, tabs, activeTab, onTabClick, firstSubtabRef, handleUpArrow, }: {
5
- withCarousel: any;
6
- tabs?: never[] | undefined;
7
- activeTab?: string | undefined;
8
- onTabClick?: (() => null) | undefined;
9
- firstSubtabRef: any;
10
- handleUpArrow: any;
11
- }): JSX.Element;
12
- propTypes: {
13
- tabs: PropTypes.Validator<(PropTypes.ReactElementLike | null | undefined)[]>;
14
- activeTab: PropTypes.Requireable<string>;
15
- onTabClick: PropTypes.Validator<(...args: any[]) => any>;
16
- withCarousel: PropTypes.Requireable<boolean>;
17
- handleUpArrow: PropTypes.Requireable<(...args: any[]) => any>;
18
- firstSubtabRef: PropTypes.Requireable<((...args: any[]) => any) | PropTypes.InferProps<{
19
- current: PropTypes.Requireable<any>;
20
- }>>;
21
- };
22
- };
23
- export default SubTabBar;
package/types/TabBar.d.ts DELETED
@@ -1,30 +0,0 @@
1
- /// <reference types="lodash" />
2
- import { Component } from 'react';
3
- declare class TabBar extends Component {
4
- constructor(props: any);
5
- componentDidMount(): void;
6
- componentDidUpdate(prevProps: any): void;
7
- componentWillUnmount(): void;
8
- handleGradients(): void;
9
- shouldHaveLeftGradient(scrollLeft: any, gWidth: any): boolean;
10
- shouldHaveRightGradient(scrollLeft: any, gWidth: any, clientWidth: any, scrollWidth: any): boolean;
11
- setIndicatorStyle(): void;
12
- getActiveTabElement(activeTab: any): any;
13
- isElementVisible(el: any, holder: any): boolean;
14
- getVisibleDimensions(node: any, referenceNode: any): {
15
- width: number;
16
- height: number;
17
- };
18
- getIndicatorStyles(activeTab: any): {
19
- height: any;
20
- left: string;
21
- top: string;
22
- width: any;
23
- } | null;
24
- handleTabClick: (tabId: any, e: any) => void;
25
- handleKeyPress: (tabId: any, e: any, index: any) => void;
26
- handleTabsHeadersHorizontalScroll: import("lodash").DebouncedFunc<() => void>;
27
- renderTabs: (this: any, activeTab: any, tabs: any) => any;
28
- render(): any;
29
- }
30
- export default TabBar;
@@ -1,5 +0,0 @@
1
- export declare const TabTypes: {
2
- NORMAL: string;
3
- SUBTABS: string;
4
- };
5
- export declare const getTabTypes: () => any[];
@@ -1,37 +0,0 @@
1
- /// <reference types="react" />
2
- import PropTypes from 'prop-types';
3
- declare const TabsImpl: {
4
- (props: any): JSX.Element;
5
- propTypes: {
6
- animated: PropTypes.Requireable<boolean>;
7
- enableMouseEvents: PropTypes.Requireable<boolean>;
8
- allowTextSelection: PropTypes.Requireable<boolean>;
9
- onTabChange: PropTypes.Requireable<(...args: any[]) => any>;
10
- type: PropTypes.Requireable<string>;
11
- tabBarExtraContent: PropTypes.Requireable<PropTypes.ReactElementLike>;
12
- onlyRenderActiveTab: PropTypes.Requireable<boolean>;
13
- withCarousel: PropTypes.Requireable<boolean>;
14
- activeTab: PropTypes.Requireable<string>;
15
- children: PropTypes.Validator<(PropTypes.InferProps<{
16
- type: PropTypes.Requireable<any>;
17
- }> | null | undefined)[]>;
18
- tabsListAriaLabel: PropTypes.Requireable<string>;
19
- containerProps: PropTypes.Requireable<object>;
20
- innerRef: PropTypes.Requireable<((...args: any[]) => any) | PropTypes.InferProps<{
21
- current: PropTypes.Requireable<any>;
22
- }>>;
23
- firstSubtabRef: PropTypes.Requireable<((...args: any[]) => any) | PropTypes.InferProps<{
24
- current: PropTypes.Requireable<any>;
25
- }>>;
26
- lastTabRef: PropTypes.Requireable<((...args: any[]) => any) | PropTypes.InferProps<{
27
- current: PropTypes.Requireable<any>;
28
- }>>;
29
- /** Whether or not it's a ds-tab from DSMobile tabs */
30
- isDSMobile: PropTypes.Requireable<boolean>;
31
- /** DSMobile only flexible tabs mode */
32
- flexibleTabsHeaders: PropTypes.Requireable<boolean>;
33
- /** DSMobile only fixed tabs mode */
34
- fixedTabsHeaders: PropTypes.Requireable<boolean>;
35
- };
36
- };
37
- export default TabsImpl;
@@ -1,5 +0,0 @@
1
- import { Component } from 'react';
2
- export default class TabsPanels extends Component {
3
- renderPanels: (this: any, activeTab: any, tabsComponents: any) => any;
4
- render(): JSX.Element;
5
- }
@@ -1 +0,0 @@
1
- export declare function useResize(ref: any, callback: any): void;