@elliemae/ds-tabs 2.0.0-rc.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/DSTabs.js +27 -108
- package/cjs/DSTabsCTX.js +30 -0
- package/cjs/DSTabsDatatestid.js +18 -0
- package/cjs/DSTabsTypes.js +2 -0
- package/cjs/config/useCrossRef.js +17 -0
- package/cjs/config/useTabs.js +51 -0
- package/cjs/defaultProps.js +27 -0
- package/cjs/{PanelContainer.js → exportsRelated/DSTab.js} +14 -30
- package/cjs/index.js +5 -5
- package/cjs/parts/carousel/Carousel.js +71 -0
- package/cjs/parts/carousel/styles.js +60 -0
- package/cjs/parts/carousel/useCarousel.js +78 -0
- package/cjs/parts/carousel/useCarouselCallbacks.js +72 -0
- package/cjs/parts/tabBar/TabBar.js +160 -0
- package/cjs/parts/tabBar/styles.js +199 -0
- package/cjs/parts/tabBar/useTabBar.js +98 -0
- package/cjs/parts/tabsContent/TabsContent.js +49 -0
- package/cjs/parts/tabsContent/styles.js +15 -0
- package/cjs/parts/tabsPanel/TabsPanels.js +77 -0
- package/cjs/parts/tabsPanel/styles.js +25 -0
- package/cjs/propTypes.js +33 -0
- package/cjs/utils/constants.js +29 -0
- package/cjs/utils/helpers.js +47 -0
- package/cjs/utils/hooks/useKeyboardNavigation.js +61 -0
- package/cjs/utils/hooks/useTabsCallbacks.js +59 -0
- package/esm/DSTabs.js +29 -110
- package/esm/DSTabsCTX.js +25 -0
- package/esm/DSTabsDatatestid.js +14 -0
- package/esm/DSTabsTypes.js +1 -0
- package/esm/config/useCrossRef.js +13 -0
- package/esm/config/useTabs.js +47 -0
- package/esm/defaultProps.js +23 -0
- package/esm/{PanelContainer.js → exportsRelated/DSTab.js} +7 -26
- package/esm/index.js +4 -3
- package/esm/parts/carousel/Carousel.js +63 -0
- package/esm/parts/carousel/styles.js +49 -0
- package/esm/parts/carousel/useCarousel.js +70 -0
- package/esm/parts/carousel/useCarouselCallbacks.js +68 -0
- package/esm/parts/tabBar/TabBar.js +151 -0
- package/esm/parts/tabBar/styles.js +185 -0
- package/esm/parts/tabBar/useTabBar.js +90 -0
- package/esm/parts/tabsContent/TabsContent.js +40 -0
- package/esm/parts/tabsContent/styles.js +7 -0
- package/esm/parts/tabsPanel/TabsPanels.js +67 -0
- package/esm/parts/tabsPanel/styles.js +17 -0
- package/esm/propTypes.js +28 -0
- package/esm/utils/constants.js +21 -0
- package/esm/utils/helpers.js +37 -0
- package/esm/utils/hooks/useKeyboardNavigation.js +57 -0
- package/esm/utils/hooks/useTabsCallbacks.js +55 -0
- package/package.json +91 -35
- package/types/DSTabs.d.ts +6 -165
- package/types/DSTabsCTX.d.ts +4 -0
- package/types/DSTabsDatatestid.d.ts +12 -0
- package/types/DSTabsTypes.d.ts +202 -0
- package/types/config/useCrossRef.d.ts +2 -0
- package/types/config/useTabs.d.ts +2 -0
- package/types/defaultProps.d.ts +2 -0
- package/types/exportsRelated/DSTab.d.ts +14 -0
- package/types/index.d.ts +4 -3
- package/types/parts/carousel/Carousel.d.ts +3 -0
- package/types/parts/carousel/styles.d.ts +9 -0
- package/types/parts/carousel/useCarousel.d.ts +2 -0
- package/types/parts/carousel/useCarouselCallbacks.d.ts +2 -0
- package/types/parts/tabBar/TabBar.d.ts +2 -0
- package/types/parts/tabBar/styles.d.ts +7 -0
- package/types/parts/tabBar/useTabBar.d.ts +2 -0
- package/types/parts/tabsContent/TabsContent.d.ts +2 -0
- package/types/parts/tabsContent/styles.d.ts +1 -0
- package/types/parts/tabsPanel/TabsPanels.d.ts +2 -0
- package/types/parts/tabsPanel/styles.d.ts +2 -0
- package/types/propTypes.d.ts +54 -0
- package/types/tests/{DSTabs.events.test.d.ts → DSTabs.callbacks.test.d.ts} +0 -0
- package/types/tests/DSTabs.func.test.d.ts +1 -0
- package/types/tests/DSTabs.keyboard.test.d.ts +1 -0
- package/types/utils/constants.d.ts +19 -0
- package/types/utils/helpers.d.ts +8 -0
- package/types/utils/hooks/useKeyboardNavigation.d.ts +2 -0
- package/types/utils/hooks/useTabsCallbacks.d.ts +2 -0
- package/cjs/Carousel.js +0 -205
- package/cjs/DSTab.js +0 -46
- package/cjs/SubTabBar.js +0 -54
- package/cjs/TabBar.js +0 -421
- package/cjs/TabTypes.js +0 -15
- package/cjs/TabsImpl.js +0 -120
- package/cjs/TabsPanels.js +0 -85
- package/cjs/useResize.js +0 -24
- package/esm/Carousel.js +0 -196
- package/esm/DSTab.js +0 -36
- package/esm/SubTabBar.js +0 -48
- package/esm/TabBar.js +0 -410
- package/esm/TabTypes.js +0 -10
- package/esm/TabsImpl.js +0 -113
- package/esm/TabsPanels.js +0 -75
- package/esm/useResize.js +0 -20
- package/types/Carousel.d.ts +0 -16
- package/types/DSTab.d.ts +0 -51
- package/types/PanelContainer.d.ts +0 -20
- package/types/SubTabBar.d.ts +0 -23
- package/types/TabBar.d.ts +0 -30
- package/types/TabTypes.d.ts +0 -5
- package/types/TabsImpl.d.ts +0 -37
- package/types/TabsPanels.d.ts +0 -5
- 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,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
|
|
4
|
-
export
|
|
3
|
+
export { TabTypes } from './utils/constants';
|
|
4
|
+
export * from './DSTabsDatatestid';
|
|
5
|
+
export type { DSTabsPropsT, DSTabPropsT } from './DSTabsTypes';
|
|
@@ -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,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 @@
|
|
|
1
|
+
export declare const StyledTabBarContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, 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
|
+
};
|
|
File without changes
|
|
@@ -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;
|
package/cjs/Carousel.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.reduce.js');
|
|
8
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
10
|
-
var React = require('react');
|
|
11
|
-
var dsIcons = require('@elliemae/ds-icons');
|
|
12
|
-
var styled = require('styled-components');
|
|
13
|
-
var DSButton = require('@elliemae/ds-button');
|
|
14
|
-
var useResize = require('./useResize.js');
|
|
15
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
-
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
20
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
22
|
-
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
23
|
-
|
|
24
|
-
const CarouselBtn = /*#__PURE__*/styled__default["default"](DSButton__default["default"]).withConfig({
|
|
25
|
-
componentId: "sc-1317h31-0"
|
|
26
|
-
})(["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], _ref => {
|
|
27
|
-
let {
|
|
28
|
-
theme
|
|
29
|
-
} = _ref;
|
|
30
|
-
return theme.breakpoints.medium;
|
|
31
|
-
}, props => props.right ? 'right: 0;' : 'left: 0;');
|
|
32
|
-
const CarouselWrapper = /*#__PURE__*/styled__default["default"].span.withConfig({
|
|
33
|
-
componentId: "sc-1317h31-1"
|
|
34
|
-
})(["position:relative;padding:0 16px;width:100%;"]);
|
|
35
|
-
const ChildrenWrap = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
36
|
-
componentId: "sc-1317h31-2"
|
|
37
|
-
})(["display:flex;flex-wrap:nowrap;flex:1;overflow:hidden;"]);
|
|
38
|
-
|
|
39
|
-
function isVisibleElement(el, container) {
|
|
40
|
-
const rect = el.getBoundingClientRect();
|
|
41
|
-
const cRect = container.getBoundingClientRect();
|
|
42
|
-
const elemLeft = rect.left + 3;
|
|
43
|
-
const elemRight = rect.right - 3; // Only completely visible elements return true:
|
|
44
|
-
|
|
45
|
-
const isVisible = elemLeft >= cRect.left && elemRight <= cRect.right;
|
|
46
|
-
return isVisible;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const Carousel = _ref2 => {
|
|
50
|
-
let {
|
|
51
|
-
children,
|
|
52
|
-
onScroll
|
|
53
|
-
} = _ref2;
|
|
54
|
-
const itemsRef = React.useRef([]);
|
|
55
|
-
const wrapRef = React.useRef(null);
|
|
56
|
-
const leftRef = React.useRef(null);
|
|
57
|
-
const rightRef = React.useRef(null);
|
|
58
|
-
|
|
59
|
-
const shouldShowLeft = () => children && children[0] && wrapRef.current && itemsRef.current[0] && !isVisibleElement(itemsRef.current[0], wrapRef.current);
|
|
60
|
-
|
|
61
|
-
const shouldShowRight = () => children && children[children.length - 1] && wrapRef.current && itemsRef.current[children.length - 1] && !isVisibleElement(itemsRef.current[children.length - 1], wrapRef.current);
|
|
62
|
-
|
|
63
|
-
const [{
|
|
64
|
-
right,
|
|
65
|
-
left,
|
|
66
|
-
CHEVRON_FOCUS_FLAG
|
|
67
|
-
}, setShow] = React.useState({
|
|
68
|
-
right: false,
|
|
69
|
-
left: false,
|
|
70
|
-
CHEVRON_FOCUS_FLAG: false // flag to replace lack of callback in useState hook
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const recalcChevrons = () => setShow({
|
|
75
|
-
right: shouldShowRight(),
|
|
76
|
-
left: shouldShowLeft()
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
React.useEffect(() => {
|
|
80
|
-
recalcChevrons();
|
|
81
|
-
}, []);
|
|
82
|
-
React.useEffect(() => {
|
|
83
|
-
if (CHEVRON_FOCUS_FLAG) {
|
|
84
|
-
// focus opposite chevron when current one hides
|
|
85
|
-
if (!left && right && rightRef.current) {
|
|
86
|
-
rightRef.current.focus();
|
|
87
|
-
} else if (!right && left && leftRef.current) {
|
|
88
|
-
leftRef.current.focus();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
setShow({
|
|
92
|
-
right,
|
|
93
|
-
left,
|
|
94
|
-
CHEVRON_FOCUS_FLAG: false
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}, [CHEVRON_FOCUS_FLAG]);
|
|
98
|
-
useResize.useResize(wrapRef, recalcChevrons);
|
|
99
|
-
|
|
100
|
-
const getVisibleItemsOffset = () => itemsRef.current.reduce((acc, c) => {
|
|
101
|
-
if (isVisibleElement(c, wrapRef.current)) {
|
|
102
|
-
const styles = window.getComputedStyle(c);
|
|
103
|
-
const width = c.offsetWidth;
|
|
104
|
-
const margin = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
|
105
|
-
return acc + (width + margin);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return acc;
|
|
109
|
-
}, 0);
|
|
110
|
-
|
|
111
|
-
const rightClick = () => {
|
|
112
|
-
wrapRef.current.scrollLeft += getVisibleItemsOffset();
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const leftClick = () => {
|
|
116
|
-
wrapRef.current.scrollLeft -= getVisibleItemsOffset();
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const handleScroll = e => {
|
|
120
|
-
// forces render when element.scrollTop is changed (out of react flow)
|
|
121
|
-
setShow({
|
|
122
|
-
right: shouldShowRight(),
|
|
123
|
-
left: shouldShowLeft(),
|
|
124
|
-
// to trigger focus logic at effect above
|
|
125
|
-
CHEVRON_FOCUS_FLAG: true
|
|
126
|
-
});
|
|
127
|
-
onScroll(e);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const handleClick = function (e) {
|
|
131
|
-
let onClick = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => {};
|
|
132
|
-
const tabListDomEl = wrapRef.current;
|
|
133
|
-
const el = e.target;
|
|
134
|
-
const rect = el.getBoundingClientRect();
|
|
135
|
-
const cRect = tabListDomEl.getBoundingClientRect();
|
|
136
|
-
|
|
137
|
-
if (!isVisibleElement(el, tabListDomEl)) {
|
|
138
|
-
const containerWidth = cRect.width;
|
|
139
|
-
const halfContainer = containerWidth / 2;
|
|
140
|
-
const elementScrollPosition = rect.left - cRect.left;
|
|
141
|
-
const positionInContainer = elementScrollPosition % containerWidth;
|
|
142
|
-
const width = el.offsetWidth; // align to right
|
|
143
|
-
|
|
144
|
-
if (positionInContainer > halfContainer) {
|
|
145
|
-
wrapRef.current.scrollLeft += width + positionInContainer - containerWidth;
|
|
146
|
-
} else {
|
|
147
|
-
// align left
|
|
148
|
-
wrapRef.current.scrollLeft += positionInContainer;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
recalcChevrons();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
onClick(e);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
return /*#__PURE__*/_jsx__default["default"](CarouselWrapper, {}, void 0, left && /*#__PURE__*/_jsx__default["default"](CarouselBtn, {
|
|
158
|
-
"data-testid": "chevron-left",
|
|
159
|
-
buttonType: "link",
|
|
160
|
-
innerRef: leftRef,
|
|
161
|
-
size: "s",
|
|
162
|
-
icon: /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronLeft, {
|
|
163
|
-
size: "s",
|
|
164
|
-
color: ['brand-primary', '600']
|
|
165
|
-
}),
|
|
166
|
-
onClick: leftClick,
|
|
167
|
-
tabIndex: -1
|
|
168
|
-
}), right && /*#__PURE__*/_jsx__default["default"](CarouselBtn, {
|
|
169
|
-
"data-testid": "chevron-right",
|
|
170
|
-
innerRef: rightRef,
|
|
171
|
-
right: true,
|
|
172
|
-
size: "s",
|
|
173
|
-
buttonType: "link",
|
|
174
|
-
icon: /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronRight, {
|
|
175
|
-
size: "s",
|
|
176
|
-
color: ['brand-primary', '600']
|
|
177
|
-
}),
|
|
178
|
-
onClick: rightClick,
|
|
179
|
-
tabIndex: -1
|
|
180
|
-
}), /*#__PURE__*/jsxRuntime.jsx(ChildrenWrap, {
|
|
181
|
-
onScroll: handleScroll,
|
|
182
|
-
ref: wrapRef,
|
|
183
|
-
children: React__default["default"].Children.map(children, (child, idx) => /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
184
|
-
onClick: e => {
|
|
185
|
-
var _child$props;
|
|
186
|
-
|
|
187
|
-
return handleClick(e, (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.onClick);
|
|
188
|
-
},
|
|
189
|
-
key: 'carousel'.concat(idx),
|
|
190
|
-
ref: el => {
|
|
191
|
-
itemsRef.current[idx] = el; // keep old refs
|
|
192
|
-
|
|
193
|
-
if (typeof child.ref === 'function') {
|
|
194
|
-
child.ref(el);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}))
|
|
198
|
-
}));
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
Carousel.defaultProps = {
|
|
202
|
-
onScroll: () => null
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
module.exports = Carousel;
|
package/cjs/DSTab.js
DELETED
|
@@ -1,46 +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 = _ref => {
|
|
14
|
-
let {
|
|
15
|
-
tabId = '',
|
|
16
|
-
title = '',
|
|
17
|
-
required = false
|
|
18
|
-
} = _ref;
|
|
19
|
-
return /*#__PURE__*/_jsx__default["default"]("div", {
|
|
20
|
-
"aria-labelledby": "".concat(tabId, "-label"),
|
|
21
|
-
tabId: tabId,
|
|
22
|
-
title: title,
|
|
23
|
-
required: required
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
DSTab.displayName = 'DSTab';
|
|
28
|
-
const props = {
|
|
29
|
-
/** unique id for tab */
|
|
30
|
-
tabId: reactDesc.PropTypes.string.description('unique id for tab'),
|
|
31
|
-
|
|
32
|
-
/** tab title */
|
|
33
|
-
title: reactDesc.PropTypes.string.description('tab title'),
|
|
34
|
-
|
|
35
|
-
/** Show a required mark next to the title */
|
|
36
|
-
required: reactDesc.PropTypes.bool.description('Show a required mark next to the title'),
|
|
37
|
-
|
|
38
|
-
/** Whether or not it's a ds-tab from DSMobile tabs */
|
|
39
|
-
isDSMobile: reactDesc.PropTypes.bool.description("Whether or not it's a ds-tab from DSMobile tabs")
|
|
40
|
-
};
|
|
41
|
-
const DSTabWithSchema = reactDesc.describe(DSTab);
|
|
42
|
-
DSTabWithSchema.propTypes = props;
|
|
43
|
-
|
|
44
|
-
exports.DSTab = DSTab;
|
|
45
|
-
exports.DSTabWithSchema = DSTabWithSchema;
|
|
46
|
-
exports["default"] = DSTab;
|