@elliemae/ds-tabs 2.0.0-alpha.1 → 2.0.0-alpha.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 (106) hide show
  1. package/cjs/DSTabs.js +29 -107
  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} +19 -28
  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 +78 -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 +25 -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/utils/hooks/useTabsCallbacks.js +59 -0
  26. package/esm/DSTabs.js +30 -108
  27. package/esm/DSTabsCTX.js +25 -0
  28. package/esm/DSTabsDatatestid.js +14 -0
  29. package/esm/DSTabsTypes.js +1 -0
  30. package/esm/config/useCrossRef.js +13 -0
  31. package/esm/config/useTabs.js +47 -0
  32. package/esm/defaultProps.js +23 -0
  33. package/esm/{PanelContainer.js → exportsRelated/DSTab.js} +11 -23
  34. package/esm/index.js +4 -3
  35. package/esm/parts/carousel/Carousel.js +63 -0
  36. package/esm/parts/carousel/styles.js +49 -0
  37. package/esm/parts/carousel/useCarousel.js +70 -0
  38. package/esm/parts/carousel/useCarouselCallbacks.js +68 -0
  39. package/esm/parts/tabBar/TabBar.js +151 -0
  40. package/esm/parts/tabBar/styles.js +185 -0
  41. package/esm/parts/tabBar/useTabBar.js +90 -0
  42. package/esm/parts/tabsContent/TabsContent.js +40 -0
  43. package/esm/parts/tabsContent/styles.js +7 -0
  44. package/esm/parts/tabsPanel/TabsPanels.js +67 -0
  45. package/esm/parts/tabsPanel/styles.js +17 -0
  46. package/esm/propTypes.js +28 -0
  47. package/esm/utils/constants.js +21 -0
  48. package/esm/utils/helpers.js +37 -0
  49. package/esm/utils/hooks/useKeyboardNavigation.js +57 -0
  50. package/esm/utils/hooks/useTabsCallbacks.js +55 -0
  51. package/package.json +100 -37
  52. package/types/DSTabs.d.ts +10 -60
  53. package/types/DSTabsCTX.d.ts +4 -0
  54. package/types/DSTabsDatatestid.d.ts +12 -0
  55. package/types/DSTabsTypes.d.ts +202 -0
  56. package/types/config/useCrossRef.d.ts +2 -0
  57. package/types/config/useTabs.d.ts +2 -0
  58. package/types/defaultProps.d.ts +2 -0
  59. package/types/exportsRelated/DSTab.d.ts +14 -0
  60. package/types/index.d.ts +4 -3
  61. package/types/parts/carousel/Carousel.d.ts +3 -0
  62. package/types/parts/carousel/styles.d.ts +9 -0
  63. package/types/parts/carousel/useCarousel.d.ts +2 -0
  64. package/types/parts/carousel/useCarouselCallbacks.d.ts +2 -0
  65. package/types/parts/tabBar/TabBar.d.ts +2 -0
  66. package/types/parts/tabBar/styles.d.ts +7 -0
  67. package/types/parts/tabBar/useTabBar.d.ts +2 -0
  68. package/types/parts/tabsContent/TabsContent.d.ts +2 -0
  69. package/types/parts/tabsContent/styles.d.ts +1 -0
  70. package/types/parts/tabsPanel/TabsPanels.d.ts +2 -0
  71. package/types/parts/tabsPanel/styles.d.ts +2 -0
  72. package/types/propTypes.d.ts +54 -0
  73. package/types/tests/{DSTabs.events.test.d.ts → DSTabs.callbacks.test.d.ts} +0 -0
  74. package/types/tests/DSTabs.func.test.d.ts +1 -0
  75. package/types/tests/DSTabs.keyboard.test.d.ts +1 -0
  76. package/types/utils/constants.d.ts +19 -0
  77. package/types/utils/helpers.d.ts +8 -0
  78. package/types/utils/hooks/useKeyboardNavigation.d.ts +2 -0
  79. package/types/utils/hooks/useTabsCallbacks.d.ts +2 -0
  80. package/cjs/Carousel.js +0 -197
  81. package/cjs/DSTab.js +0 -43
  82. package/cjs/SubTabBar.js +0 -45
  83. package/cjs/TabBar.js +0 -410
  84. package/cjs/TabTypes.js +0 -12
  85. package/cjs/TabsImpl.js +0 -114
  86. package/cjs/TabsPanels.js +0 -82
  87. package/cjs/package.json +0 -7
  88. package/cjs/useResize.js +0 -24
  89. package/esm/Carousel.js +0 -186
  90. package/esm/DSTab.js +0 -33
  91. package/esm/SubTabBar.js +0 -39
  92. package/esm/TabBar.js +0 -399
  93. package/esm/TabTypes.js +0 -7
  94. package/esm/TabsImpl.js +0 -107
  95. package/esm/TabsPanels.js +0 -72
  96. package/esm/package.json +0 -7
  97. package/esm/useResize.js +0 -20
  98. package/types/Carousel.d.ts +0 -16
  99. package/types/DSTab.d.ts +0 -22
  100. package/types/PanelContainer.d.ts +0 -20
  101. package/types/SubTabBar.d.ts +0 -23
  102. package/types/TabBar.d.ts +0 -30
  103. package/types/TabTypes.d.ts +0 -5
  104. package/types/TabsImpl.d.ts +0 -37
  105. package/types/TabsPanels.d.ts +0 -5
  106. package/types/useResize.d.ts +0 -1
@@ -0,0 +1,202 @@
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
+ backgroundWithTransparentAndWhite: string;
128
+ backgroundWithTransparent: string;
129
+ }
130
+ export interface UseCarouselReturnTypeT {
131
+ showChevrons: ShowChevronsT;
132
+ leftButtonOnClick: () => void;
133
+ rightButtonOnClick: () => void;
134
+ handleOnClick: (e: React.MouseEvent) => void;
135
+ handleOnScroll: (e: React.UIEvent) => void;
136
+ }
137
+ export interface UseCarouselCallbacksPropsT {
138
+ getVisibleItemsOffset: () => number;
139
+ recalcChevrons: () => void;
140
+ updateIndicatorStyle?: () => void;
141
+ }
142
+ export interface UseCarouselCallbacksReturnTypeT {
143
+ leftButtonOnClick: () => void;
144
+ rightButtonOnClick: () => void;
145
+ handleOnClick: (e: React.MouseEvent) => void;
146
+ handleOnScroll: (e: React.UIEvent) => void;
147
+ }
148
+ export interface UseKeyboardNavigationReturnTypeT {
149
+ handleOnKeyDown: (e: React.KeyboardEvent) => void;
150
+ }
151
+ export interface UseTabsCallbacksReturnTypeT {
152
+ handleOnTabChange: (tabId: string, e?: React.MouseEvent) => void;
153
+ handleOnMouseDown: (e: React.MouseEvent) => void;
154
+ }
155
+ export interface UseTabBarReturnTypeT {
156
+ updateIndicatorStyle: () => void;
157
+ updateMobileGradients: () => void;
158
+ setIndicatorStyle: React.Dispatch<React.SetStateAction<IndicatorStyleT>>;
159
+ indicatorStyle: IndicatorStyleT;
160
+ mobileGradients: MobileGradientsT;
161
+ }
162
+ export interface VisibleDimensionsT {
163
+ width: number;
164
+ height: number;
165
+ }
166
+ export interface StyledTabWrapperPropsT {
167
+ isDSMobile: boolean;
168
+ fixedTabsHeaders: boolean;
169
+ }
170
+ export interface StyledTabListPropsT {
171
+ withCarousel: boolean;
172
+ isDSMobile: boolean;
173
+ fixedTabsHeaders: boolean;
174
+ mobileGradients: MobileGradientsT;
175
+ indicatorStyle: IndicatorStyleT;
176
+ tabType: TabTypesT;
177
+ }
178
+ export interface StyledSubTabsListPropsT {
179
+ withCarousel: boolean;
180
+ }
181
+ export interface StyledTabButtonPropsT {
182
+ isActive: boolean;
183
+ disabled: boolean;
184
+ showSeparator: boolean;
185
+ isDSMobile: boolean;
186
+ fixedTabsHeaders: boolean;
187
+ withCarousel: boolean;
188
+ tabType: TabTypesT;
189
+ }
190
+ export interface StyledCarouselButtonWrapperPropsT {
191
+ right?: boolean;
192
+ tabType: TabTypesT;
193
+ }
194
+ export interface StyledPanelContainerPropsT {
195
+ hidden: boolean;
196
+ isDSMobile: boolean;
197
+ }
198
+ export interface StyledSelectionIndicatoPropsT {
199
+ isDSMobile: boolean;
200
+ tabType: TabTypesT;
201
+ }
202
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { DSTabsUseCrossRefContextT } from '../DSTabsTypes';
2
+ export declare const useCrossRef: () => DSTabsUseCrossRefContextT;
@@ -0,0 +1,2 @@
1
+ import type { DSTabsPropsT, DSTabsUseTabsContextT } from '../DSTabsTypes';
2
+ export declare const useTabs: (props: DSTabsPropsT) => DSTabsUseTabsContextT;
@@ -0,0 +1,2 @@
1
+ import type { DSTabsDefaultPropsT } from './DSTabsTypes';
2
+ export declare const tabsDefaultProps: DSTabsDefaultPropsT;
@@ -0,0 +1,14 @@
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/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export * from './DSTab';
1
+ export * from './exportsRelated/DSTab';
2
2
  export * from './DSTabs';
3
- export * from './TabTypes';
4
- export { default } from './DSTabs';
3
+ export { TabTypes } from './utils/constants';
4
+ export * from './DSTabsDatatestid';
5
+ export type { DSTabsPropsT, DSTabPropsT } from './DSTabsTypes';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { CarouselPropsT } from '../../DSTabsTypes';
3
+ export declare const Carousel: ({ children, updateIndicatorStyle }: CarouselPropsT) => JSX.Element;
@@ -0,0 +1,9 @@
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/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>;
@@ -0,0 +1,2 @@
1
+ import type { UseCarouselPropsT, UseCarouselReturnTypeT } from '../../DSTabsTypes';
2
+ export declare const useCarousel: ({ updateIndicatorStyle }: UseCarouselPropsT) => UseCarouselReturnTypeT;
@@ -0,0 +1,2 @@
1
+ import type { UseCarouselCallbacksPropsT, UseCarouselCallbacksReturnTypeT } from '../../DSTabsTypes';
2
+ export declare const useCarouselCallbacks: ({ getVisibleItemsOffset, updateIndicatorStyle, recalcChevrons, }: UseCarouselCallbacksPropsT) => UseCarouselCallbacksReturnTypeT;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const TabBar: () => JSX.Element;
@@ -0,0 +1,7 @@
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>;
@@ -0,0 +1,2 @@
1
+ import type { UseTabBarReturnTypeT } from '../../DSTabsTypes';
2
+ export declare const useTabBar: () => UseTabBarReturnTypeT;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const TabsContent: () => JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const StyledTabBarContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const TabsPanels: () => JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { StyledPanelContainerPropsT } from '../../DSTabsTypes';
2
+ export declare const StyledPanelContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledPanelContainerPropsT, never>;
@@ -0,0 +1,54 @@
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").PropTypesDescValidator;
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
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
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
+ backgroundWithTransparentAndWhite: string;
12
+ backgroundWithTransparent: string;
13
+ };
14
+ export declare const gradientOffsetsAccordingType: {
15
+ normal_small: number;
16
+ normal: number;
17
+ subtabs: number;
18
+ fixedTabsHeaders: number;
19
+ };
@@ -0,0 +1,8 @@
1
+ import type { 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 getVisibleDimensions: (node: HTMLElement, referenceNode: HTMLElement) => VisibleDimensionsT;
5
+ export declare const getIndexById: (children: React.ReactElement<DSTabPropsWithDefaultT>[], activeId?: string | undefined) => number;
6
+ export declare const getIdByIndex: (children: React.ReactElement<DSTabPropsWithDefaultT>[], index: number) => string;
7
+ export declare const shouldHaveLeftGradient: (scrollLeft: number) => boolean;
8
+ export declare const shouldHaveRightGradient: (scrollLeft: number, clientWidth: number, scrollWidth: number) => boolean;
@@ -0,0 +1,2 @@
1
+ import type { UseKeyboardNavigationReturnTypeT } from '../../DSTabsTypes';
2
+ export declare const useKeyboardNavigation: () => UseKeyboardNavigationReturnTypeT;
@@ -0,0 +1,2 @@
1
+ import type { UseTabsCallbacksReturnTypeT } from '../../DSTabsTypes';
2
+ export declare const useTabsCallbacks: () => UseTabsCallbacksReturnTypeT;
package/cjs/Carousel.js DELETED
@@ -1,197 +0,0 @@
1
- 'use strict';
2
-
3
- var _jsx = require('@babel/runtime/helpers/jsx');
4
- var React = require('react');
5
- var ChevronRight = require('@elliemae/ds-icons/ChevronRight');
6
- var ChevronLeft = require('@elliemae/ds-icons/ChevronLeft');
7
- var styled = require('styled-components');
8
- var DSButton = require('@elliemae/ds-button');
9
- var useResize = require('./useResize.js');
10
- var jsxRuntime = require('react/jsx-runtime');
11
-
12
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
-
14
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
15
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
16
- var ChevronRight__default = /*#__PURE__*/_interopDefaultLegacy(ChevronRight);
17
- var ChevronLeft__default = /*#__PURE__*/_interopDefaultLegacy(ChevronLeft);
18
- var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
19
- var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
20
-
21
- const CarouselBtn = /*#__PURE__*/styled__default['default'](DSButton__default['default']).withConfig({
22
- componentId: "sc-1317h31-0"
23
- })(["position:absolute;z-index:1;margin:0;&:focus{& span{background-color:", ";background-size:90%;border-radius:2px;border-color:transparent;}}&&{width:16px;height:calc(100% - 2px);@media (min-width:", "){height:calc(100% - 4px);&:focus{& span{background-color:unset;}}}}", " && .em-ds-icon{height:16px;width:16px;}"], props => props.theme.colors.brand[200], ({
24
- theme
25
- }) => theme.breakpoints.medium, props => props.right ? 'right: 0;' : 'left: 0;');
26
- const CarouselWrapper = /*#__PURE__*/styled__default['default'].span.withConfig({
27
- componentId: "sc-1317h31-1"
28
- })(["position:relative;padding:0 16px;width:100%;"]);
29
- const ChildrenWrap = /*#__PURE__*/styled__default['default'].div.withConfig({
30
- componentId: "sc-1317h31-2"
31
- })(["display:flex;flex-wrap:nowrap;flex:1;overflow:hidden;"]);
32
-
33
- function isVisibleElement(el, container) {
34
- const rect = el.getBoundingClientRect();
35
- const cRect = container.getBoundingClientRect();
36
- const elemLeft = rect.left + 3;
37
- const elemRight = rect.right - 3; // Only completely visible elements return true:
38
-
39
- const isVisible = elemLeft >= cRect.left && elemRight <= cRect.right;
40
- return isVisible;
41
- }
42
-
43
- const Carousel = ({
44
- children,
45
- onScroll
46
- }) => {
47
- const itemsRef = React.useRef([]);
48
- const wrapRef = React.useRef(null);
49
- const leftRef = React.useRef(null);
50
- const rightRef = React.useRef(null);
51
-
52
- const shouldShowLeft = () => children && children[0] && wrapRef.current && itemsRef.current[0] && !isVisibleElement(itemsRef.current[0], wrapRef.current);
53
-
54
- const shouldShowRight = () => children && children[children.length - 1] && wrapRef.current && itemsRef.current[children.length - 1] && !isVisibleElement(itemsRef.current[children.length - 1], wrapRef.current);
55
-
56
- const [{
57
- right,
58
- left,
59
- CHEVRON_FOCUS_FLAG
60
- }, setShow] = React.useState({
61
- right: false,
62
- left: false,
63
- CHEVRON_FOCUS_FLAG: false // flag to replace lack of callback in useState hook
64
-
65
- });
66
-
67
- const recalcChevrons = () => setShow({
68
- right: shouldShowRight(),
69
- left: shouldShowLeft()
70
- });
71
-
72
- React.useEffect(() => {
73
- recalcChevrons();
74
- }, []);
75
- React.useEffect(() => {
76
- if (CHEVRON_FOCUS_FLAG) {
77
- // focus opposite chevron when current one hides
78
- if (!left && right && rightRef.current) {
79
- rightRef.current.focus();
80
- } else if (!right && left && leftRef.current) {
81
- leftRef.current.focus();
82
- }
83
-
84
- setShow({
85
- right,
86
- left,
87
- CHEVRON_FOCUS_FLAG: false
88
- });
89
- }
90
- }, [CHEVRON_FOCUS_FLAG]);
91
- useResize.useResize(wrapRef, recalcChevrons);
92
-
93
- const getVisibleItemsOffset = () => itemsRef.current.reduce((acc, c) => {
94
- if (isVisibleElement(c, wrapRef.current)) {
95
- const styles = window.getComputedStyle(c);
96
- const width = c.offsetWidth;
97
- const margin = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
98
- return acc + (width + margin);
99
- }
100
-
101
- return acc;
102
- }, 0);
103
-
104
- const rightClick = () => {
105
- wrapRef.current.scrollLeft += getVisibleItemsOffset();
106
- };
107
-
108
- const leftClick = () => {
109
- wrapRef.current.scrollLeft -= getVisibleItemsOffset();
110
- };
111
-
112
- const handleScroll = e => {
113
- // forces render when element.scrollTop is changed (out of react flow)
114
- setShow({
115
- right: shouldShowRight(),
116
- left: shouldShowLeft(),
117
- // to trigger focus logic at effect above
118
- CHEVRON_FOCUS_FLAG: true
119
- });
120
- onScroll(e);
121
- };
122
-
123
- const handleClick = (e, onClick = () => {}) => {
124
- const tabListDomEl = wrapRef.current;
125
- const el = e.target;
126
- const rect = el.getBoundingClientRect();
127
- const cRect = tabListDomEl.getBoundingClientRect();
128
-
129
- if (!isVisibleElement(el, tabListDomEl)) {
130
- const containerWidth = cRect.width;
131
- const halfContainer = containerWidth / 2;
132
- const elementScrollPosition = rect.left - cRect.left;
133
- const positionInContainer = elementScrollPosition % containerWidth;
134
- const width = el.offsetWidth; // align to right
135
-
136
- if (positionInContainer > halfContainer) {
137
- wrapRef.current.scrollLeft += width + positionInContainer - containerWidth;
138
- } else {
139
- // align left
140
- wrapRef.current.scrollLeft += positionInContainer;
141
- }
142
-
143
- recalcChevrons();
144
- }
145
-
146
- onClick(e);
147
- };
148
-
149
- return /*#__PURE__*/_jsx__default['default'](CarouselWrapper, {}, void 0, left && /*#__PURE__*/_jsx__default['default'](CarouselBtn, {
150
- "data-testid": "chevron-left",
151
- buttonType: "link",
152
- innerRef: leftRef,
153
- size: "s",
154
- icon: /*#__PURE__*/_jsx__default['default'](ChevronLeft__default['default'], {
155
- size: "s",
156
- color: ['brand-primary', '600']
157
- }),
158
- onClick: leftClick,
159
- tabIndex: -1
160
- }), right && /*#__PURE__*/_jsx__default['default'](CarouselBtn, {
161
- "data-testid": "chevron-right",
162
- innerRef: rightRef,
163
- right: true,
164
- size: "s",
165
- buttonType: "link",
166
- icon: /*#__PURE__*/_jsx__default['default'](ChevronRight__default['default'], {
167
- size: "s",
168
- color: ['brand-primary', '600']
169
- }),
170
- onClick: rightClick,
171
- tabIndex: -1
172
- }), /*#__PURE__*/jsxRuntime.jsx(ChildrenWrap, {
173
- onScroll: handleScroll,
174
- ref: wrapRef,
175
- children: React__default['default'].Children.map(children, (child, idx) => /*#__PURE__*/React__default['default'].cloneElement(child, {
176
- onClick: e => {
177
- var _child$props;
178
-
179
- return handleClick(e, (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.onClick);
180
- },
181
- key: 'carousel'.concat(idx),
182
- ref: el => {
183
- itemsRef.current[idx] = el; // keep old refs
184
-
185
- if (typeof child.ref === 'function') {
186
- child.ref(el);
187
- }
188
- }
189
- }))
190
- }));
191
- };
192
-
193
- Carousel.defaultProps = {
194
- onScroll: () => null
195
- };
196
-
197
- module.exports = Carousel;
package/cjs/DSTab.js DELETED
@@ -1,43 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _jsx = require('@babel/runtime/helpers/jsx');
6
- require('react');
7
- var reactDesc = require('react-desc');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
12
-
13
- const DSTab = ({
14
- tabId = '',
15
- title = '',
16
- required = false
17
- }) => /*#__PURE__*/_jsx__default['default']("div", {
18
- "aria-labelledby": `${tabId}-label`,
19
- tabId: tabId,
20
- title: title,
21
- required: required
22
- });
23
-
24
- DSTab.displayName = 'DSTab';
25
- const props = {
26
- /** unique id for tab */
27
- tabId: reactDesc.PropTypes.string.description('unique id for tab'),
28
-
29
- /** tab title */
30
- title: reactDesc.PropTypes.string.description('tab title'),
31
-
32
- /** Show a required mark next to the title */
33
- required: reactDesc.PropTypes.bool.description('Show a required mark next to the title'),
34
-
35
- /** Whether or not it's a ds-tab from DSMobile tabs */
36
- isDSMobile: reactDesc.PropTypes.bool.description("Whether or not it's a ds-tab from DSMobile tabs")
37
- };
38
- const DSTabWithSchema = reactDesc.describe(DSTab);
39
- DSTabWithSchema.propTypes = props;
40
-
41
- exports.DSTab = DSTab;
42
- exports.DSTabWithSchema = DSTabWithSchema;
43
- exports['default'] = DSTab;