@redocly/theme 0.54.1 → 0.54.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Button/Button.d.ts +1 -0
- package/lib/markdoc/components/Tabs/TabList.d.ts +1 -4
- package/lib/markdoc/components/Tabs/TabList.js +16 -36
- package/lib/markdoc/components/Tabs/Tabs.js +3 -7
- package/package.json +1 -1
- package/src/components/Button/Button.tsx +1 -1
- package/src/markdoc/components/Tabs/TabList.tsx +38 -69
- package/src/markdoc/components/Tabs/Tabs.tsx +3 -7
|
@@ -18,6 +18,7 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
18
18
|
title?: string;
|
|
19
19
|
tabIndex?: number;
|
|
20
20
|
onClick?: (e?: any) => void;
|
|
21
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
21
22
|
type?: 'button' | 'submit' | 'reset';
|
|
22
23
|
}
|
|
23
24
|
export declare function generateClassName({ variant, tone, size, extraClass, }: ButtonProps): string;
|
|
@@ -26,8 +26,5 @@ export declare const TabItem: import("styled-components").StyledComponent<"li",
|
|
|
26
26
|
size: TabsSize;
|
|
27
27
|
tabIndex?: number;
|
|
28
28
|
}, never>;
|
|
29
|
-
export declare const TabButtonLink: import("styled-components").StyledComponent<"
|
|
30
|
-
size: TabsSize;
|
|
31
|
-
disabled?: boolean;
|
|
32
|
-
}, never>;
|
|
29
|
+
export declare const TabButtonLink: import("styled-components").StyledComponent<React.FC<import("../../../components/Button/Button").ButtonProps>, any, import("../../../components/Button/Button").ButtonProps, never>;
|
|
33
30
|
export {};
|
|
@@ -22,25 +22,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.TabButtonLink = exports.TabItem = exports.TabListContainer = void 0;
|
|
27
30
|
exports.TabList = TabList;
|
|
28
|
-
const react_1 =
|
|
31
|
+
const react_1 = __importDefault(require("react"));
|
|
29
32
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
30
33
|
const Tab_1 = require("../../../markdoc/components/Tabs/Tab");
|
|
31
34
|
const Dropdown_1 = require("../../../components/Dropdown/Dropdown");
|
|
32
35
|
const DropdownMenu_1 = require("../../../components/Dropdown/DropdownMenu");
|
|
33
36
|
const DropdownMenuItem_1 = require("../../../components/Dropdown/DropdownMenuItem");
|
|
34
|
-
const
|
|
35
|
-
const ChevronUpIcon_1 = require("../../../icons/ChevronUpIcon/ChevronUpIcon");
|
|
37
|
+
const Button_1 = require("../../../components/Button/Button");
|
|
36
38
|
function TabList({ childrenArray, size, overflowTabs, visibleTabs, setTabRef, onTabClick, handleKeyboard, getTabId, activeTab, isAnimating, highlightStyle, allTabsHidden, tabsContainerRef, }) {
|
|
37
|
-
const [isDropdownOpen, setIsDropdownOpen] = (0, react_1.useState)(false);
|
|
38
|
-
const handleDropdownOpen = (0, react_1.useCallback)(() => {
|
|
39
|
-
setIsDropdownOpen(true);
|
|
40
|
-
}, []);
|
|
41
|
-
const handleDropdownClose = (0, react_1.useCallback)(() => {
|
|
42
|
-
setIsDropdownOpen(false);
|
|
43
|
-
}, []);
|
|
44
39
|
return (react_1.default.createElement(exports.TabListContainer, { role: "tablist", ref: tabsContainerRef, "data-animating": isAnimating },
|
|
45
40
|
react_1.default.createElement(HighlightBar, { size: size, style: { left: highlightStyle.left, width: highlightStyle.width } },
|
|
46
41
|
react_1.default.createElement("div", null)),
|
|
@@ -59,20 +54,16 @@ function TabList({ childrenArray, size, overflowTabs, visibleTabs, setTabRef, on
|
|
|
59
54
|
onTabClick(label);
|
|
60
55
|
} }));
|
|
61
56
|
}),
|
|
62
|
-
react_1.default.createElement(exports.TabItem, { size: size, active: overflowTabs.some((index) => activeTab === childrenArray[index].props.label), tabIndex: 0 }, overflowTabs.length > 0 && (react_1.default.createElement(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
react_1.default.createElement(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
onTabClick(index);
|
|
73
|
-
handleDropdownClose();
|
|
74
|
-
}, disabled: childrenArray[index].props.disable }, label));
|
|
75
|
-
}))))))));
|
|
57
|
+
react_1.default.createElement(exports.TabItem, { size: size, active: overflowTabs.some((index) => activeTab === childrenArray[index].props.label), tabIndex: 0 }, overflowTabs.length > 0 && (react_1.default.createElement(Dropdown_1.Dropdown, { trigger: react_1.default.createElement(exports.TabButtonLink, { size: size, className: overflowTabs.some((index) => activeTab === childrenArray[index].props.label)
|
|
58
|
+
? 'active'
|
|
59
|
+
: undefined }, allTabsHidden ? activeTab : 'More'), alignment: "start", withArrow: true },
|
|
60
|
+
react_1.default.createElement(DropdownMenu_1.DropdownMenu, null, overflowTabs.map((index) => {
|
|
61
|
+
const { label } = childrenArray[index].props;
|
|
62
|
+
const tabId = getTabId(label, index);
|
|
63
|
+
return (react_1.default.createElement(DropdownMenuItem_1.DropdownMenuItem, { key: `more-${tabId}`, active: activeTab === label, onAction: () => {
|
|
64
|
+
onTabClick(index);
|
|
65
|
+
}, disabled: childrenArray[index].props.disable }, label));
|
|
66
|
+
})))))));
|
|
76
67
|
}
|
|
77
68
|
exports.TabListContainer = styled_components_1.default.ul `
|
|
78
69
|
position: relative;
|
|
@@ -166,22 +157,11 @@ const HighlightBar = styled_components_1.default.div `
|
|
|
166
157
|
border-radius: var(--md-tabs-${({ size }) => size}-active-tab-border-radius);
|
|
167
158
|
}
|
|
168
159
|
`;
|
|
169
|
-
exports.TabButtonLink = styled_components_1.default.
|
|
170
|
-
all: unset;
|
|
171
|
-
flex-grow: 1;
|
|
172
|
-
cursor: pointer;
|
|
173
|
-
width: 100%;
|
|
174
|
-
text-align: center;
|
|
160
|
+
exports.TabButtonLink = (0, styled_components_1.default)(Button_1.Button) `
|
|
175
161
|
color: var(--md-tabs-tab-text-color);
|
|
176
162
|
font-family: var(--md-tabs-tab-font-family);
|
|
177
163
|
font-style: var(--md-tabs-tab-font-style);
|
|
178
164
|
background-color: var(--md-tabs-tab-bg-color);
|
|
179
|
-
white-space: nowrap;
|
|
180
|
-
display: inline-flex;
|
|
181
|
-
align-items: center;
|
|
182
|
-
justify-content: center;
|
|
183
|
-
gap: var(--spacing-xxs);
|
|
184
|
-
z-index: 2;
|
|
185
165
|
|
|
186
166
|
transition:
|
|
187
167
|
background-color 300ms ease-in-out,
|
|
@@ -92,14 +92,10 @@ function Tabs({ children, className, size }) {
|
|
|
92
92
|
else {
|
|
93
93
|
setHighlightStyle({ left: offsetLeft, width: offsetWidth });
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
setIsAnimating(false);
|
|
100
|
-
}, 300);
|
|
95
|
+
if (visibleTabs.includes(activeIndex)) {
|
|
96
|
+
activeTabElement === null || activeTabElement === void 0 ? void 0 : activeTabElement.classList.add('active');
|
|
97
|
+
}
|
|
101
98
|
return () => {
|
|
102
|
-
clearTimeout(timeoutId);
|
|
103
99
|
container.querySelectorAll('[data-label]').forEach((el) => {
|
|
104
100
|
el.classList.remove('active');
|
|
105
101
|
});
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
|
|
4
4
|
import type { JSX } from 'react';
|
|
@@ -8,8 +8,7 @@ import { TabItemProps, TabsSize } from '@redocly/theme/markdoc/components/Tabs/T
|
|
|
8
8
|
import { Dropdown } from '@redocly/theme/components/Dropdown/Dropdown';
|
|
9
9
|
import { DropdownMenu } from '@redocly/theme/components/Dropdown/DropdownMenu';
|
|
10
10
|
import { DropdownMenuItem } from '@redocly/theme/components/Dropdown/DropdownMenuItem';
|
|
11
|
-
import {
|
|
12
|
-
import { ChevronUpIcon } from '@redocly/theme/icons/ChevronUpIcon/ChevronUpIcon';
|
|
11
|
+
import { Button } from '@redocly/theme/components/Button/Button';
|
|
13
12
|
|
|
14
13
|
type TabListProps = {
|
|
15
14
|
childrenArray: React.ReactElement<TabItemProps>[];
|
|
@@ -42,16 +41,6 @@ export function TabList({
|
|
|
42
41
|
allTabsHidden,
|
|
43
42
|
tabsContainerRef,
|
|
44
43
|
}: TabListProps): JSX.Element {
|
|
45
|
-
const [isDropdownOpen, setIsDropdownOpen] = useState<boolean>(false);
|
|
46
|
-
|
|
47
|
-
const handleDropdownOpen = useCallback(() => {
|
|
48
|
-
setIsDropdownOpen(true);
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
const handleDropdownClose = useCallback(() => {
|
|
52
|
-
setIsDropdownOpen(false);
|
|
53
|
-
}, []);
|
|
54
|
-
|
|
55
44
|
return (
|
|
56
45
|
<TabListContainer role="tablist" ref={tabsContainerRef} data-animating={isAnimating}>
|
|
57
46
|
<HighlightBar size={size} style={{ left: highlightStyle.left, width: highlightStyle.width }}>
|
|
@@ -88,47 +77,41 @@ export function TabList({
|
|
|
88
77
|
tabIndex={0}
|
|
89
78
|
>
|
|
90
79
|
{overflowTabs.length > 0 && (
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
</DropdownMenuItem>
|
|
127
|
-
);
|
|
128
|
-
})}
|
|
129
|
-
</DropdownMenu>
|
|
130
|
-
</Dropdown>
|
|
131
|
-
</div>
|
|
80
|
+
<Dropdown
|
|
81
|
+
trigger={
|
|
82
|
+
<TabButtonLink
|
|
83
|
+
size={size}
|
|
84
|
+
className={
|
|
85
|
+
overflowTabs.some((index) => activeTab === childrenArray[index].props.label)
|
|
86
|
+
? 'active'
|
|
87
|
+
: undefined
|
|
88
|
+
}
|
|
89
|
+
>
|
|
90
|
+
{allTabsHidden ? activeTab : 'More'}
|
|
91
|
+
</TabButtonLink>
|
|
92
|
+
}
|
|
93
|
+
alignment="start"
|
|
94
|
+
withArrow={true}
|
|
95
|
+
>
|
|
96
|
+
<DropdownMenu>
|
|
97
|
+
{overflowTabs.map((index) => {
|
|
98
|
+
const { label } = childrenArray[index].props;
|
|
99
|
+
const tabId = getTabId(label, index);
|
|
100
|
+
return (
|
|
101
|
+
<DropdownMenuItem
|
|
102
|
+
key={`more-${tabId}`}
|
|
103
|
+
active={activeTab === label}
|
|
104
|
+
onAction={() => {
|
|
105
|
+
onTabClick(index);
|
|
106
|
+
}}
|
|
107
|
+
disabled={childrenArray[index].props.disable}
|
|
108
|
+
>
|
|
109
|
+
{label}
|
|
110
|
+
</DropdownMenuItem>
|
|
111
|
+
);
|
|
112
|
+
})}
|
|
113
|
+
</DropdownMenu>
|
|
114
|
+
</Dropdown>
|
|
132
115
|
)}
|
|
133
116
|
</TabItem>
|
|
134
117
|
</TabListContainer>
|
|
@@ -231,25 +214,11 @@ const HighlightBar = styled.div<{ size: TabsSize }>`
|
|
|
231
214
|
}
|
|
232
215
|
`;
|
|
233
216
|
|
|
234
|
-
export const TabButtonLink = styled
|
|
235
|
-
size: TabsSize;
|
|
236
|
-
disabled?: boolean;
|
|
237
|
-
}>`
|
|
238
|
-
all: unset;
|
|
239
|
-
flex-grow: 1;
|
|
240
|
-
cursor: pointer;
|
|
241
|
-
width: 100%;
|
|
242
|
-
text-align: center;
|
|
217
|
+
export const TabButtonLink = styled(Button)`
|
|
243
218
|
color: var(--md-tabs-tab-text-color);
|
|
244
219
|
font-family: var(--md-tabs-tab-font-family);
|
|
245
220
|
font-style: var(--md-tabs-tab-font-style);
|
|
246
221
|
background-color: var(--md-tabs-tab-bg-color);
|
|
247
|
-
white-space: nowrap;
|
|
248
|
-
display: inline-flex;
|
|
249
|
-
align-items: center;
|
|
250
|
-
justify-content: center;
|
|
251
|
-
gap: var(--spacing-xxs);
|
|
252
|
-
z-index: 2;
|
|
253
222
|
|
|
254
223
|
transition:
|
|
255
224
|
background-color 300ms ease-in-out,
|
|
@@ -105,15 +105,11 @@ export function Tabs({ children, className, size }: TabsProps): JSX.Element {
|
|
|
105
105
|
setHighlightStyle({ left: offsetLeft, width: offsetWidth });
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
setIsAnimating(false);
|
|
113
|
-
}, 300);
|
|
108
|
+
if (visibleTabs.includes(activeIndex)) {
|
|
109
|
+
activeTabElement?.classList.add('active');
|
|
110
|
+
}
|
|
114
111
|
|
|
115
112
|
return () => {
|
|
116
|
-
clearTimeout(timeoutId);
|
|
117
113
|
container.querySelectorAll('[data-label]').forEach((el) => {
|
|
118
114
|
el.classList.remove('active');
|
|
119
115
|
});
|