@redocly/theme 0.58.1 → 0.59.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Accordion/Accordion.d.ts +12 -0
- package/lib/components/Accordion/Accordion.js +75 -0
- package/lib/components/Accordion/AccordionBody.d.ts +8 -0
- package/lib/components/Accordion/AccordionBody.js +63 -0
- package/lib/components/Accordion/AccordionHeader.d.ts +10 -0
- package/lib/components/Accordion/AccordionHeader.js +37 -0
- package/lib/components/Accordion/AccordionTitle.d.ts +6 -0
- package/lib/components/Accordion/AccordionTitle.js +20 -0
- package/lib/components/Accordion/variables.d.ts +1 -0
- package/lib/components/Accordion/variables.js +59 -0
- package/lib/components/Buttons/AIAssistantButton.d.ts +2 -0
- package/lib/components/Buttons/AIAssistantButton.js +125 -0
- package/lib/components/Buttons/variables.d.ts +1 -0
- package/lib/components/Buttons/variables.dark.d.ts +1 -0
- package/lib/components/Buttons/variables.dark.js +10 -0
- package/lib/components/Buttons/variables.js +51 -0
- package/lib/components/Catalog/Catalog.js +3 -3
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +1 -1
- package/lib/components/Catalog/CatalogFilter/CatalogFilter.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilter.js +35 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.js +142 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.d.ts +13 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.js +92 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterDateRange.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterDateRange.js +111 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterSelect.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterSelect.js +116 -0
- package/lib/components/Catalog/CatalogSelector.js +0 -1
- package/lib/components/Catalog/variables.js +0 -1
- package/lib/components/Filter/FilterInput.d.ts +1 -0
- package/lib/components/Filter/FilterInput.js +2 -2
- package/lib/components/Filter/FilterOptions.js +2 -0
- package/lib/components/Filter/variables.js +7 -4
- package/lib/components/Search/SearchAiDialog.js +2 -3
- package/lib/components/Search/SearchAiResponse.js +2 -3
- package/lib/components/Search/SearchDialog.d.ts +2 -1
- package/lib/components/Search/SearchDialog.js +2 -2
- package/lib/components/Tag/Tag.d.ts +3 -2
- package/lib/components/Tag/Tag.js +21 -5
- package/lib/components/Tag/variables.dark.js +135 -0
- package/lib/components/Tag/variables.js +120 -58
- package/lib/core/hooks/use-tabs.d.ts +11 -6
- package/lib/core/hooks/use-tabs.js +117 -207
- package/lib/core/styles/dark.js +29 -26
- package/lib/core/styles/global.js +64 -59
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/utils/index.d.ts +1 -0
- package/lib/core/utils/index.js +1 -0
- package/lib/core/utils/tabs.d.ts +1 -0
- package/lib/core/utils/tabs.js +8 -0
- package/lib/icons/RedoclyIcon/RedoclyIcon.d.ts +9 -0
- package/lib/icons/RedoclyIcon/RedoclyIcon.js +27 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/layouts/RootLayout.js +6 -1
- package/lib/markdoc/components/Tabs/Tab.js +1 -1
- package/lib/markdoc/components/Tabs/TabList.d.ts +2 -14
- package/lib/markdoc/components/Tabs/TabList.js +63 -16
- package/lib/markdoc/components/Tabs/Tabs.d.ts +2 -2
- package/lib/markdoc/components/Tabs/Tabs.js +11 -87
- package/lib/markdoc/tags/tabs.js +5 -0
- package/package.json +2 -2
- package/src/components/Accordion/Accordion.tsx +100 -0
- package/src/components/Accordion/AccordionBody.tsx +65 -0
- package/src/components/Accordion/AccordionHeader.tsx +68 -0
- package/src/components/Accordion/AccordionTitle.tsx +26 -0
- package/src/components/Accordion/variables.ts +56 -0
- package/src/components/Buttons/AIAssistantButton.tsx +141 -0
- package/src/components/Buttons/variables.dark.ts +7 -0
- package/src/components/Buttons/variables.ts +48 -0
- package/src/components/Catalog/Catalog.tsx +3 -2
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +1 -1
- package/src/components/Catalog/CatalogFilter/CatalogFilter.tsx +56 -0
- package/src/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.tsx +169 -0
- package/src/components/Catalog/CatalogFilter/CatalogFilterContent.tsx +121 -0
- package/src/components/Catalog/CatalogFilter/CatalogFilterDateRange.tsx +147 -0
- package/src/components/Catalog/CatalogFilter/CatalogFilterSelect.tsx +136 -0
- package/src/components/Catalog/CatalogSelector.tsx +0 -1
- package/src/components/Catalog/variables.ts +0 -1
- package/src/components/Filter/FilterInput.tsx +3 -2
- package/src/components/Filter/FilterOptions.tsx +2 -0
- package/src/components/Filter/variables.ts +7 -4
- package/src/components/Search/SearchAiDialog.tsx +2 -2
- package/src/components/Search/SearchAiResponse.tsx +2 -2
- package/src/components/Search/SearchDialog.tsx +7 -2
- package/src/components/Tag/Tag.tsx +33 -8
- package/src/components/Tag/variables.dark.ts +135 -0
- package/src/components/Tag/variables.ts +120 -58
- package/src/core/hooks/use-tabs.ts +160 -238
- package/src/core/styles/dark.ts +11 -8
- package/src/core/styles/global.ts +7 -2
- package/src/core/types/l10n.ts +1 -0
- package/src/core/utils/index.ts +1 -0
- package/src/core/utils/tabs.ts +4 -0
- package/src/icons/RedoclyIcon/RedoclyIcon.tsx +44 -0
- package/src/index.ts +2 -0
- package/src/layouts/RootLayout.tsx +6 -0
- package/src/markdoc/components/Tabs/Tab.tsx +1 -0
- package/src/markdoc/components/Tabs/TabList.tsx +84 -30
- package/src/markdoc/components/Tabs/Tabs.tsx +12 -125
- package/src/markdoc/tags/tabs.ts +5 -0
|
@@ -1,98 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useActiveTab = void 0;
|
|
3
4
|
exports.useTabs = useTabs;
|
|
4
5
|
const react_1 = require("react");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const [
|
|
6
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
7
|
+
const MORE_BUTTON_WIDTH = 80;
|
|
8
|
+
const TABS_GAP = 8;
|
|
9
|
+
function useTabs({ activeTab, onTabChange, totalTabs, containerRef }) {
|
|
10
|
+
const [tabs, setTabs] = (0, react_1.useState)({
|
|
11
|
+
visible: Array.from({ length: totalTabs }, (_, i) => i),
|
|
12
|
+
overflow: [],
|
|
13
|
+
});
|
|
10
14
|
const tabRefs = (0, react_1.useRef)([]);
|
|
15
|
+
const tabWidthsRef = (0, react_1.useRef)([]);
|
|
11
16
|
const tabLabelsRef = (0, react_1.useRef)([]);
|
|
12
|
-
const
|
|
13
|
-
const [ready, setReady] = (0, react_1.useState)(false);
|
|
14
|
-
const hasCalculatedOnce = (0, react_1.useRef)(false);
|
|
15
|
-
const lastWidthRef = (0, react_1.useRef)(0);
|
|
16
|
-
const originalOrderRef = (0, react_1.useRef)([]);
|
|
17
|
-
(0, react_1.useEffect)(() => {
|
|
18
|
-
originalOrderRef.current = Array.from({ length: totalTabs }, (_, i) => i);
|
|
19
|
-
}, [totalTabs]);
|
|
17
|
+
const allTabsHidden = (0, react_1.useMemo)(() => tabs.visible.length === 0, [tabs.visible]);
|
|
20
18
|
const setTabRef = (0, react_1.useCallback)((element, index) => {
|
|
21
19
|
tabRefs.current[index] = element;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const width = element === null || element === void 0 ? void 0 : element.offsetWidth;
|
|
21
|
+
if (width) {
|
|
22
|
+
tabWidthsRef.current[index] = width;
|
|
23
|
+
}
|
|
24
|
+
const label = element === null || element === void 0 ? void 0 : element.getAttribute('data-label');
|
|
25
|
+
if (label) {
|
|
26
|
+
tabLabelsRef.current[index] = label;
|
|
27
27
|
}
|
|
28
|
-
}, []);
|
|
29
|
-
const getTabId = (0, react_1.useCallback)((label, index) => {
|
|
30
|
-
const cleanLabel = label.replace(/\s+/g, '-').toLowerCase();
|
|
31
|
-
return `${cleanLabel}-${index}`;
|
|
32
28
|
}, []);
|
|
33
29
|
const focusTab = (index) => {
|
|
34
30
|
const currentElement = tabRefs.current[index];
|
|
35
|
-
|
|
36
|
-
currentElement.focus();
|
|
37
|
-
}
|
|
31
|
+
currentElement === null || currentElement === void 0 ? void 0 : currentElement.focus();
|
|
38
32
|
};
|
|
39
33
|
const onTabSelect = (0, react_1.useCallback)((index) => {
|
|
40
34
|
var _a;
|
|
41
35
|
focusTab(index);
|
|
42
36
|
const label = (_a = tabRefs.current[index]) === null || _a === void 0 ? void 0 : _a.getAttribute('data-label');
|
|
43
37
|
if (label)
|
|
44
|
-
|
|
45
|
-
}, []);
|
|
46
|
-
const onTabClick = (0, react_1.useCallback)((labelOrIndex) => {
|
|
47
|
-
var _a;
|
|
48
|
-
let clickedIndex;
|
|
49
|
-
if (typeof labelOrIndex === 'string') {
|
|
50
|
-
clickedIndex = tabRefs.current.findIndex((ref) => (ref === null || ref === void 0 ? void 0 : ref.getAttribute('data-label')) === labelOrIndex);
|
|
51
|
-
if (clickedIndex === -1)
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
clickedIndex = labelOrIndex;
|
|
56
|
-
}
|
|
57
|
-
if (allTabsHidden) {
|
|
58
|
-
const label = tabLabelsRef.current[clickedIndex];
|
|
59
|
-
if (label) {
|
|
60
|
-
setActiveTab(label);
|
|
61
|
-
focusTab(clickedIndex);
|
|
62
|
-
}
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (overflowTabs.includes(clickedIndex)) {
|
|
66
|
-
const newVisibleTabs = [...visibleTabs];
|
|
67
|
-
const newOverflowTabs = [...overflowTabs];
|
|
68
|
-
const clickedIdxInOverflow = newOverflowTabs.indexOf(clickedIndex);
|
|
69
|
-
if (clickedIdxInOverflow !== -1) {
|
|
70
|
-
newOverflowTabs.splice(clickedIdxInOverflow, 1);
|
|
71
|
-
}
|
|
72
|
-
const lastVisible = newVisibleTabs.pop();
|
|
73
|
-
if (lastVisible !== undefined) {
|
|
74
|
-
newOverflowTabs.unshift(lastVisible);
|
|
75
|
-
}
|
|
76
|
-
newVisibleTabs.push(clickedIndex);
|
|
77
|
-
setVisibleTabs(newVisibleTabs);
|
|
78
|
-
setOverflowTabs(newOverflowTabs);
|
|
79
|
-
requestAnimationFrame(() => {
|
|
80
|
-
var _a;
|
|
81
|
-
const label = (_a = tabRefs.current[clickedIndex]) === null || _a === void 0 ? void 0 : _a.getAttribute('data-label');
|
|
82
|
-
if (label) {
|
|
83
|
-
setActiveTab(label);
|
|
84
|
-
focusTab(clickedIndex);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
const label = (_a = tabRefs.current[clickedIndex]) === null || _a === void 0 ? void 0 : _a.getAttribute('data-label');
|
|
90
|
-
if (label) {
|
|
91
|
-
setActiveTab(label);
|
|
92
|
-
focusTab(clickedIndex);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}, [visibleTabs, overflowTabs, allTabsHidden]);
|
|
38
|
+
onTabChange(label);
|
|
39
|
+
}, [onTabChange]);
|
|
96
40
|
const handleKeyboard = (0, react_1.useCallback)((event, index) => {
|
|
97
41
|
let newIndex = index;
|
|
98
42
|
if (event.key === 'ArrowRight') {
|
|
@@ -114,168 +58,134 @@ function useTabs({ initialTab, totalTabs, containerRef }) {
|
|
|
114
58
|
}
|
|
115
59
|
onTabSelect(newIndex);
|
|
116
60
|
}, [totalTabs, onTabSelect]);
|
|
61
|
+
const replaceLastVisibleTabWithClickedOverflowTab = (0, react_1.useCallback)((clickedIndex) => {
|
|
62
|
+
const { visible: visibleTabs, overflow: overflowTabs } = tabs;
|
|
63
|
+
// Indexes of visible tabs should be sorted(asc), to replace the last visible tab with the clicked tab
|
|
64
|
+
const newVisibleTabs = [...visibleTabs].sort((a, b) => a - b);
|
|
65
|
+
const newOverflowTabs = [...overflowTabs];
|
|
66
|
+
const clickedIdxInOverflow = newOverflowTabs.indexOf(clickedIndex);
|
|
67
|
+
if (clickedIdxInOverflow !== -1) {
|
|
68
|
+
const lastVisible = newVisibleTabs[newVisibleTabs.length - 1];
|
|
69
|
+
newOverflowTabs.splice(clickedIdxInOverflow, 1);
|
|
70
|
+
newOverflowTabs.unshift(lastVisible);
|
|
71
|
+
newVisibleTabs.splice(newVisibleTabs.length - 1, 1);
|
|
72
|
+
newVisibleTabs.unshift(clickedIndex);
|
|
73
|
+
}
|
|
74
|
+
setTabs({
|
|
75
|
+
visible: newVisibleTabs,
|
|
76
|
+
overflow: newOverflowTabs,
|
|
77
|
+
});
|
|
78
|
+
}, [tabs]);
|
|
79
|
+
const onTabClick = (0, react_1.useCallback)((labelOrIndex) => {
|
|
80
|
+
const clickedIndex = typeof labelOrIndex === 'string'
|
|
81
|
+
? tabRefs.current.findIndex((ref) => (ref === null || ref === void 0 ? void 0 : ref.getAttribute('data-label')) === labelOrIndex)
|
|
82
|
+
: labelOrIndex;
|
|
83
|
+
if (clickedIndex === -1)
|
|
84
|
+
return;
|
|
85
|
+
const hasOverflowTabs = tabs.overflow.length > 0;
|
|
86
|
+
if (hasOverflowTabs && !allTabsHidden && tabs.overflow.includes(clickedIndex)) {
|
|
87
|
+
replaceLastVisibleTabWithClickedOverflowTab(clickedIndex);
|
|
88
|
+
}
|
|
89
|
+
const label = tabLabelsRef.current[clickedIndex];
|
|
90
|
+
if (label) {
|
|
91
|
+
onTabChange(label);
|
|
92
|
+
focusTab(clickedIndex);
|
|
93
|
+
}
|
|
94
|
+
}, [allTabsHidden, tabs.overflow, onTabChange, replaceLastVisibleTabWithClickedOverflowTab]);
|
|
117
95
|
const calculateVisibleTabs = (0, react_1.useCallback)(() => {
|
|
118
96
|
const container = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
119
97
|
if (!container)
|
|
120
98
|
return;
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
setVisibleTabs(Array.from({ length: totalTabs }, (_, i) => i));
|
|
124
|
-
setOverflowTabs([]);
|
|
125
|
-
setAllTabsHidden(false);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const containerWidth = container.offsetWidth - 60;
|
|
129
|
-
const tabElements = container.querySelectorAll('[role="tab"]');
|
|
130
|
-
const moreButtonWidth = 80;
|
|
131
|
-
const safetyMargin = 20;
|
|
132
|
-
const tabWidths = Array.from(tabElements).map((el) => el.offsetWidth);
|
|
133
|
-
const tabLabels = Array.from(tabElements).map((el) => el.getAttribute('data-label') || '');
|
|
134
|
-
const tabTypes = Array.from(tabElements).map((el) => el.getAttribute('data-type') || '');
|
|
135
|
-
const hasLongLabels = tabLabels.some((label) => label.length > 30);
|
|
136
|
-
const minVisibleTabs = hasLongLabels ? 1 : 2;
|
|
99
|
+
const containerWidth = container.offsetWidth;
|
|
100
|
+
const tabWidths = tabWidthsRef.current;
|
|
137
101
|
const activeTabIndex = tabRefs.current.findIndex((ref) => (ref === null || ref === void 0 ? void 0 : ref.getAttribute('data-label')) === activeTab);
|
|
138
|
-
|
|
139
|
-
|
|
102
|
+
// Active tab should always be visible, so we include it at the beginning of the array
|
|
103
|
+
let tabsWidth = activeTabIndex !== -1 ? tabWidths[activeTabIndex] : 0;
|
|
104
|
+
const visible = activeTabIndex !== -1 ? [activeTabIndex] : [];
|
|
140
105
|
const overflow = [];
|
|
141
|
-
let
|
|
142
|
-
|
|
143
|
-
if (i
|
|
144
|
-
|
|
106
|
+
for (let i = 0; i < tabWidths.length; i++) {
|
|
107
|
+
// Skip active tab, it was added initially
|
|
108
|
+
if (i === activeTabIndex) {
|
|
109
|
+
continue;
|
|
145
110
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const tabsByType = new Map();
|
|
154
|
-
Array.from({ length: totalTabs }).forEach((_, i) => {
|
|
155
|
-
var _a;
|
|
156
|
-
const type = tabTypes[i] || 'default';
|
|
157
|
-
if (!tabsByType.has(type)) {
|
|
158
|
-
tabsByType.set(type, []);
|
|
111
|
+
const tabWidthWithGap = tabWidths[i] + TABS_GAP;
|
|
112
|
+
const projectedWidth = tabsWidth + tabWidthWithGap;
|
|
113
|
+
if (projectedWidth <= containerWidth) {
|
|
114
|
+
visible.push(i);
|
|
115
|
+
tabsWidth += tabWidthWithGap;
|
|
159
116
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const projectedWidth = typeCurrentWidth +
|
|
169
|
-
tabWidth +
|
|
170
|
-
(typeVisible.length > 0 ? moreButtonWidth + safetyMargin : 0);
|
|
171
|
-
if (projectedWidth <= containerWidth) {
|
|
172
|
-
typeVisible.push(tabIndex);
|
|
173
|
-
typeCurrentWidth += tabWidth;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
typeOverflow.push(tabIndex);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
tabIndices.slice(minVisibleTabs).forEach((tabIndex) => {
|
|
180
|
-
const tabWidth = tabWidths[tabIndex];
|
|
181
|
-
const projectedWidth = typeCurrentWidth + tabWidth + moreButtonWidth + safetyMargin;
|
|
182
|
-
if (projectedWidth <= containerWidth) {
|
|
183
|
-
typeVisible.push(tabIndex);
|
|
184
|
-
typeCurrentWidth += tabWidth;
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
typeOverflow.push(tabIndex);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
visible.push(...typeVisible);
|
|
191
|
-
overflow.push(...typeOverflow);
|
|
192
|
-
currentWidth = typeCurrentWidth;
|
|
193
|
-
});
|
|
194
|
-
if (activeTabIndex !== -1 && !visible.includes(activeTabIndex)) {
|
|
195
|
-
if (visible.length > 0) {
|
|
117
|
+
else {
|
|
118
|
+
overflow.push(i);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (overflow.length > 0) {
|
|
122
|
+
tabsWidth += MORE_BUTTON_WIDTH;
|
|
123
|
+
// Remove tabs starting from the end of the array until the width of the visible tabs is less than the container width
|
|
124
|
+
while (tabsWidth > containerWidth && visible.length) {
|
|
196
125
|
const removed = visible.pop();
|
|
197
126
|
if (removed !== undefined) {
|
|
198
127
|
overflow.unshift(removed);
|
|
128
|
+
tabsWidth -= tabWidths[removed];
|
|
199
129
|
}
|
|
200
130
|
}
|
|
201
|
-
visible.push(activeTabIndex);
|
|
202
|
-
const activeOverflowIndex = overflow.indexOf(activeTabIndex);
|
|
203
|
-
if (activeOverflowIndex !== -1)
|
|
204
|
-
overflow.splice(activeOverflowIndex, 1);
|
|
205
131
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}, [containerRef,
|
|
132
|
+
setTabs({
|
|
133
|
+
visible,
|
|
134
|
+
overflow,
|
|
135
|
+
});
|
|
136
|
+
}, [containerRef, activeTab]);
|
|
211
137
|
(0, react_1.useEffect)(() => {
|
|
212
138
|
if (!(containerRef === null || containerRef === void 0 ? void 0 : containerRef.current))
|
|
213
139
|
return;
|
|
214
|
-
|
|
215
|
-
const allTabsReady = tabRefs.current.length === totalTabs && tabRefs.current.every((tab) => tab === null || tab === void 0 ? void 0 : tab.offsetWidth);
|
|
216
|
-
if (!allTabsReady) {
|
|
217
|
-
resizeTimeoutRef.current = requestAnimationFrame(ensureTabsReady);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
calculateVisibleTabs();
|
|
221
|
-
hasCalculatedOnce.current = true;
|
|
222
|
-
};
|
|
223
|
-
resizeTimeoutRef.current = requestAnimationFrame(ensureTabsReady);
|
|
224
|
-
let resizeTimeout;
|
|
140
|
+
let resizeTimeout = requestAnimationFrame(calculateVisibleTabs);
|
|
225
141
|
const handleResize = () => {
|
|
226
|
-
if (!hasCalculatedOnce.current)
|
|
227
|
-
return;
|
|
228
142
|
if (resizeTimeout) {
|
|
229
143
|
cancelAnimationFrame(resizeTimeout);
|
|
230
144
|
}
|
|
231
|
-
resizeTimeout = requestAnimationFrame(
|
|
232
|
-
if (resizeTimeoutRef.current) {
|
|
233
|
-
cancelAnimationFrame(resizeTimeoutRef.current);
|
|
234
|
-
}
|
|
235
|
-
resizeTimeoutRef.current = requestAnimationFrame(() => {
|
|
236
|
-
const container = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
237
|
-
if (!container)
|
|
238
|
-
return;
|
|
239
|
-
const currentWidth = container.offsetWidth;
|
|
240
|
-
if (Math.abs(lastWidthRef.current - currentWidth) > 5) {
|
|
241
|
-
lastWidthRef.current = currentWidth;
|
|
242
|
-
calculateVisibleTabs();
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
});
|
|
145
|
+
resizeTimeout = requestAnimationFrame(calculateVisibleTabs);
|
|
246
146
|
};
|
|
247
|
-
const resizeObserver = new ResizeObserver(handleResize);
|
|
248
|
-
resizeObserver.observe(containerRef.current);
|
|
249
147
|
window.addEventListener('resize', handleResize);
|
|
250
148
|
return () => {
|
|
251
|
-
resizeObserver.disconnect();
|
|
252
149
|
window.removeEventListener('resize', handleResize);
|
|
253
|
-
|
|
254
|
-
cancelAnimationFrame(resizeTimeoutRef.current);
|
|
255
|
-
}
|
|
256
|
-
if (resizeTimeout) {
|
|
257
|
-
cancelAnimationFrame(resizeTimeout);
|
|
258
|
-
}
|
|
150
|
+
cancelAnimationFrame(resizeTimeout);
|
|
259
151
|
};
|
|
260
152
|
}, [containerRef, totalTabs, calculateVisibleTabs]);
|
|
261
|
-
(0, react_1.useEffect)(() => {
|
|
262
|
-
const raf = requestAnimationFrame(() => {
|
|
263
|
-
setReady(true);
|
|
264
|
-
calculateVisibleTabs();
|
|
265
|
-
});
|
|
266
|
-
return () => cancelAnimationFrame(raf);
|
|
267
|
-
}, [calculateVisibleTabs]);
|
|
268
153
|
return {
|
|
269
|
-
activeTab,
|
|
270
|
-
setActiveTab,
|
|
271
154
|
setTabRef,
|
|
272
155
|
onTabClick,
|
|
273
156
|
handleKeyboard,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
overflowTabs,
|
|
277
|
-
ready,
|
|
157
|
+
visibleTabs: tabs.visible,
|
|
158
|
+
overflowTabs: tabs.overflow,
|
|
278
159
|
allTabsHidden,
|
|
279
160
|
};
|
|
280
161
|
}
|
|
162
|
+
const useActiveTab = ({ initialTab, tabsId }) => {
|
|
163
|
+
const [searchParams, setSearchParams] = (0, react_router_dom_1.useSearchParams)();
|
|
164
|
+
const [activeTab, setActiveTab] = (0, react_1.useState)(getInitialTab({ initialTab, searchParams, tabsId }));
|
|
165
|
+
const prevActiveTabRef = (0, react_1.useRef)(activeTab);
|
|
166
|
+
(0, react_1.useEffect)(() => {
|
|
167
|
+
const hasActiveTabChanged = prevActiveTabRef.current !== activeTab;
|
|
168
|
+
if (!tabsId || !hasActiveTabChanged) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
prevActiveTabRef.current = activeTab;
|
|
172
|
+
setSearchParams((searchParams) => {
|
|
173
|
+
searchParams.set(tabsId, activeTab);
|
|
174
|
+
return searchParams;
|
|
175
|
+
});
|
|
176
|
+
}, [activeTab, setSearchParams, tabsId]);
|
|
177
|
+
return {
|
|
178
|
+
activeTab,
|
|
179
|
+
setActiveTab,
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
exports.useActiveTab = useActiveTab;
|
|
183
|
+
const getInitialTab = ({ initialTab, searchParams, tabsId }) => {
|
|
184
|
+
let resultTab = initialTab;
|
|
185
|
+
if (tabsId) {
|
|
186
|
+
const tabFromUrl = searchParams.get(tabsId);
|
|
187
|
+
resultTab = tabFromUrl ? tabFromUrl : resultTab;
|
|
188
|
+
}
|
|
189
|
+
return resultTab;
|
|
190
|
+
};
|
|
281
191
|
//# sourceMappingURL=use-tabs.js.map
|
package/lib/core/styles/dark.js
CHANGED
|
@@ -6,15 +6,16 @@ const variables_dark_1 = require("../../components/Scorecard/variables.dark");
|
|
|
6
6
|
const variables_dark_2 = require("../../markdoc/components/Mermaid/variables.dark");
|
|
7
7
|
const variables_dark_3 = require("../../components/Menu/variables.dark");
|
|
8
8
|
const variables_dark_4 = require("../../components/Button/variables.dark");
|
|
9
|
-
const variables_dark_5 = require("../../components/
|
|
10
|
-
const variables_dark_6 = require("../../
|
|
11
|
-
const variables_dark_7 = require("../../
|
|
12
|
-
const variables_dark_8 = require("../../components/
|
|
13
|
-
const variables_dark_9 = require("../../components/
|
|
14
|
-
const variables_dark_10 = require("../../
|
|
15
|
-
const variables_dark_11 = require("../../components/
|
|
16
|
-
const variables_dark_12 = require("../../components/
|
|
17
|
-
const variables_dark_13 = require("../../components/
|
|
9
|
+
const variables_dark_5 = require("../../components/Buttons/variables.dark");
|
|
10
|
+
const variables_dark_6 = require("../../components/Segmented/variables.dark");
|
|
11
|
+
const variables_dark_7 = require("../../icons/CheckboxIcon/variables.dark");
|
|
12
|
+
const variables_dark_8 = require("../../components/Tag/variables.dark");
|
|
13
|
+
const variables_dark_9 = require("../../components/StatusCode/variables.dark");
|
|
14
|
+
const variables_dark_10 = require("../../components/Switch/variables.dark");
|
|
15
|
+
const variables_dark_11 = require("../../markdoc/components/Cards/variables.dark");
|
|
16
|
+
const variables_dark_12 = require("../../components/Catalog/variables.dark");
|
|
17
|
+
const variables_dark_13 = require("../../components/PageActions/variables.dark");
|
|
18
|
+
const variables_dark_14 = require("../../components/Tooltip/variables.dark");
|
|
18
19
|
const replayDarkMode = (0, styled_components_1.css) `
|
|
19
20
|
/**
|
|
20
21
|
* @tokens Replay Colors
|
|
@@ -136,14 +137,15 @@ exports.darkMode = (0, styled_components_1.css) `
|
|
|
136
137
|
|
|
137
138
|
--color-green-1: #1a4d40;
|
|
138
139
|
--color-green-2: #195848;
|
|
139
|
-
--color-green-3: #
|
|
140
|
-
--color-green-4: #
|
|
141
|
-
--color-green-5: #
|
|
142
|
-
--color-green-6: #
|
|
143
|
-
--color-green-7: #
|
|
144
|
-
--color-green-8: #
|
|
145
|
-
--color-green-9: #
|
|
146
|
-
--color-green-10: #
|
|
140
|
+
--color-green-3: #136a4d;
|
|
141
|
+
--color-green-4: #0e8450;
|
|
142
|
+
--color-green-5: #149e53;
|
|
143
|
+
--color-green-6: #1cb854;
|
|
144
|
+
--color-green-7: #4dd470;
|
|
145
|
+
--color-green-8: #72e985;
|
|
146
|
+
--color-green-9: #a3f7a9;
|
|
147
|
+
--color-green-10: #d2fbd0;
|
|
148
|
+
--color-green-11: #edfbec;
|
|
147
149
|
|
|
148
150
|
--color-grass-1: #1f4d2d;
|
|
149
151
|
--color-grass-2: #164f29;
|
|
@@ -306,20 +308,21 @@ exports.darkMode = (0, styled_components_1.css) `
|
|
|
306
308
|
--plus-square-outlined-icon: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.20312 5.3125H4.6875V6.79687C4.6875 6.83984 4.72266 6.875 4.76562 6.875H5.23438C5.27734 6.875 5.3125 6.83984 5.3125 6.79687V5.3125H6.79688C6.83984 5.3125 6.875 5.27734 6.875 5.23437V4.76562C6.875 4.72266 6.83984 4.6875 6.79688 4.6875H5.3125V3.20312C5.3125 3.16016 5.27734 3.125 5.23438 3.125H4.76562C4.72266 3.125 4.6875 3.16016 4.6875 3.20312V4.6875H3.20312C3.16016 4.6875 3.125 4.72266 3.125 4.76562V5.23437C3.125 5.27734 3.16016 5.3125 3.20312 5.3125Z' fill='%239B9CA8'/%3E%3Cpath d='M8.59375 1.09375H1.40625C1.2334 1.09375 1.09375 1.2334 1.09375 1.40625V8.59375C1.09375 8.7666 1.2334 8.90625 1.40625 8.90625H8.59375C8.7666 8.90625 8.90625 8.7666 8.90625 8.59375V1.40625C8.90625 1.2334 8.7666 1.09375 8.59375 1.09375ZM8.20312 8.20312H1.79688V1.79687H8.20312V8.20312Z' fill='%239B9CA8'/%3E%3C/svg%3E%0A");
|
|
307
309
|
--minus-square-outlined-icon: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.20312 5.3125H6.79688C6.83984 5.3125 6.875 5.27734 6.875 5.23437V4.76562C6.875 4.72266 6.83984 4.6875 6.79688 4.6875H3.20312C3.16016 4.6875 3.125 4.72266 3.125 4.76562V5.23437C3.125 5.27734 3.16016 5.3125 3.20312 5.3125Z' fill='%239B9CA8'/%3E%3Cpath d='M8.59375 1.09375H1.40625C1.2334 1.09375 1.09375 1.2334 1.09375 1.40625V8.59375C1.09375 8.7666 1.2334 8.90625 1.40625 8.90625H8.59375C8.7666 8.90625 8.90625 8.7666 8.90625 8.59375V1.40625C8.90625 1.2334 8.7666 1.09375 8.59375 1.09375ZM8.20312 8.20312H1.79688V1.79687H8.20312V8.20312Z' fill='%239B9CA8'/%3E%3C/svg%3E%0A");
|
|
308
310
|
|
|
309
|
-
${
|
|
311
|
+
${variables_dark_6.segmentedButtonsDarkMode}
|
|
310
312
|
${variables_dark_4.buttonDarkMode}
|
|
311
|
-
${
|
|
312
|
-
${variables_dark_7.
|
|
313
|
-
${variables_dark_8.
|
|
313
|
+
${variables_dark_5.aiAssistantButtonDarkMode}
|
|
314
|
+
${variables_dark_7.checkboxDarkMode}
|
|
315
|
+
${variables_dark_8.tagDarkMode}
|
|
316
|
+
${variables_dark_9.statusCodeDarkMode}
|
|
314
317
|
${variables_dark_3.menuDarkMode}
|
|
315
318
|
${variables_dark_2.mermaidDarkMode}
|
|
316
319
|
${variables_dark_1.scorecardDarkMode}
|
|
317
320
|
${replayDarkMode}
|
|
318
|
-
${
|
|
319
|
-
${
|
|
320
|
-
${
|
|
321
|
-
${
|
|
322
|
-
${
|
|
321
|
+
${variables_dark_10.switcherDarkMode}
|
|
322
|
+
${variables_dark_11.cardsDarkMode}
|
|
323
|
+
${variables_dark_12.catalogDarkMode}
|
|
324
|
+
${variables_dark_13.pageActionsDarkMode}
|
|
325
|
+
${variables_dark_14.tooltipDarkMode}
|
|
323
326
|
|
|
324
327
|
/**
|
|
325
328
|
* @tokens Dark Theme Scrollbar Config
|
|
@@ -13,34 +13,36 @@ const variables_8 = require("../../components/Catalog/variables");
|
|
|
13
13
|
const variables_9 = require("../../components/Filter/variables");
|
|
14
14
|
const variables_10 = require("../../components/CatalogClassic/variables");
|
|
15
15
|
const variables_11 = require("../../components/Panel/variables");
|
|
16
|
-
const variables_12 = require("../../components/
|
|
17
|
-
const variables_13 = require("../../components/
|
|
18
|
-
const variables_14 = require("../../components/
|
|
19
|
-
const variables_15 = require("../../
|
|
20
|
-
const variables_16 = require("../../
|
|
21
|
-
const variables_17 = require("../../components/
|
|
22
|
-
const variables_18 = require("../../components/
|
|
23
|
-
const variables_19 = require("../../components/
|
|
24
|
-
const variables_20 = require("../../components/
|
|
25
|
-
const variables_21 = require("../../components/
|
|
26
|
-
const variables_22 = require("../../components/
|
|
27
|
-
const variables_23 = require("../../components/
|
|
28
|
-
const variables_24 = require("../../components/
|
|
29
|
-
const variables_25 = require("../../
|
|
30
|
-
const variables_26 = require("../../
|
|
31
|
-
const variables_27 = require("../../components/
|
|
32
|
-
const variables_28 = require("../../components/
|
|
33
|
-
const variables_29 = require("../../components/
|
|
34
|
-
const variables_30 = require("../../components/
|
|
35
|
-
const variables_31 = require("../../components/
|
|
36
|
-
const variables_32 = require("../../components/
|
|
37
|
-
const variables_33 = require("../../components/
|
|
38
|
-
const variables_34 = require("../../components/
|
|
39
|
-
const variables_35 = require("../../components/
|
|
40
|
-
const variables_36 = require("../../
|
|
41
|
-
const variables_37 = require("../../
|
|
42
|
-
const variables_38 = require("../../components/
|
|
43
|
-
const variables_39 = require("../../components/
|
|
16
|
+
const variables_12 = require("../../components/Accordion/variables");
|
|
17
|
+
const variables_13 = require("../../components/Select/variables");
|
|
18
|
+
const variables_14 = require("../../components/Dropdown/variables");
|
|
19
|
+
const variables_15 = require("../../components/Tooltip/variables");
|
|
20
|
+
const variables_16 = require("../../icons/CheckboxIcon/variables");
|
|
21
|
+
const variables_17 = require("../../components/Admonition/variables");
|
|
22
|
+
const variables_18 = require("../../components/Footer/variables");
|
|
23
|
+
const variables_19 = require("../../components/Button/variables");
|
|
24
|
+
const variables_20 = require("../../components/Buttons/variables");
|
|
25
|
+
const variables_21 = require("../../components/Navbar/variables");
|
|
26
|
+
const variables_22 = require("../../components/Search/variables");
|
|
27
|
+
const variables_23 = require("../../components/Menu/variables");
|
|
28
|
+
const variables_24 = require("../../components/CodeBlock/variables");
|
|
29
|
+
const variables_25 = require("../../components/Product/variables");
|
|
30
|
+
const variables_26 = require("../../components/Markdown/variables");
|
|
31
|
+
const variables_27 = require("../../markdoc/components/Tabs/variables");
|
|
32
|
+
const variables_28 = require("../../markdoc/components/Mermaid/variables");
|
|
33
|
+
const variables_29 = require("../../components/LastUpdated/variables");
|
|
34
|
+
const variables_30 = require("../../components/Logo/variables");
|
|
35
|
+
const variables_31 = require("../../components/StatusCode/variables");
|
|
36
|
+
const variables_32 = require("../../components/Segmented/variables");
|
|
37
|
+
const variables_33 = require("../../components/UserMenu/variables");
|
|
38
|
+
const variables_34 = require("../../components/Tags/variables");
|
|
39
|
+
const variables_35 = require("../../components/VersionPicker/variables");
|
|
40
|
+
const variables_36 = require("../../components/DatePicker/variables");
|
|
41
|
+
const variables_37 = require("../../components/Switch/variables");
|
|
42
|
+
const variables_38 = require("../../markdoc/components/Cards/variables");
|
|
43
|
+
const variables_39 = require("../../markdoc/components/CodeWalkthrough/variables");
|
|
44
|
+
const variables_40 = require("../../components/SkipContent/variables");
|
|
45
|
+
const variables_41 = require("../../components/PageActions/variables");
|
|
44
46
|
const dark_1 = require("./dark");
|
|
45
47
|
const themeColors = (0, styled_components_1.css) `
|
|
46
48
|
/* === Palette === */
|
|
@@ -141,8 +143,9 @@ const themeColors = (0, styled_components_1.css) `
|
|
|
141
143
|
--color-green-6: #1cb854;
|
|
142
144
|
--color-green-7: #149e53;
|
|
143
145
|
--color-green-8: #0e8450;
|
|
144
|
-
--color-green-9: #
|
|
145
|
-
--color-green-10: #
|
|
146
|
+
--color-green-9: #136a4d;
|
|
147
|
+
--color-green-10: #195848;
|
|
148
|
+
--color-green-11: #1a4d40;
|
|
146
149
|
|
|
147
150
|
--color-grass-1: #f0faeb;
|
|
148
151
|
--color-grass-2: #e3fad6;
|
|
@@ -1204,68 +1207,70 @@ const replay = (0, styled_components_1.css) `
|
|
|
1204
1207
|
`;
|
|
1205
1208
|
exports.styles = (0, styled_components_1.css) `
|
|
1206
1209
|
:root {
|
|
1207
|
-
${
|
|
1210
|
+
${variables_12.accordion}
|
|
1211
|
+
${variables_17.admonition}
|
|
1208
1212
|
${apiReferenceDocs}
|
|
1209
1213
|
${variables_11.apiReferencePanels}
|
|
1210
1214
|
${badges}
|
|
1211
1215
|
${borders}
|
|
1212
1216
|
${variables_5.breadcrumbs}
|
|
1213
|
-
${
|
|
1214
|
-
${
|
|
1217
|
+
${variables_19.button}
|
|
1218
|
+
${variables_20.aiAssistantButton}
|
|
1219
|
+
${variables_38.cards}
|
|
1215
1220
|
${variables_8.catalog}
|
|
1216
1221
|
${variables_10.catalogClassic}
|
|
1217
|
-
${
|
|
1218
|
-
${
|
|
1222
|
+
${variables_24.code}
|
|
1223
|
+
${variables_39.codeWalkthrough}
|
|
1219
1224
|
${docsDropdown}
|
|
1220
|
-
${
|
|
1225
|
+
${variables_14.dropdown}
|
|
1221
1226
|
${error}
|
|
1222
1227
|
${variables_9.filter}
|
|
1223
|
-
${
|
|
1228
|
+
${variables_18.footer}
|
|
1224
1229
|
${headingsTypography}
|
|
1225
|
-
${
|
|
1230
|
+
${variables_34.httpTag}
|
|
1226
1231
|
${inputs}
|
|
1227
1232
|
${variables_1.languagePicker}
|
|
1228
|
-
${
|
|
1233
|
+
${variables_29.lastUpdated}
|
|
1229
1234
|
${links}
|
|
1230
1235
|
${loadProgressBar}
|
|
1231
|
-
${
|
|
1232
|
-
${
|
|
1233
|
-
${
|
|
1234
|
-
${
|
|
1235
|
-
${
|
|
1236
|
-
${
|
|
1236
|
+
${variables_30.logo}
|
|
1237
|
+
${variables_26.markdown}
|
|
1238
|
+
${variables_27.markdownTabs}
|
|
1239
|
+
${variables_28.mermaid}
|
|
1240
|
+
${variables_23.menu}
|
|
1241
|
+
${variables_23.mobileMenu}
|
|
1237
1242
|
${modal}
|
|
1238
|
-
${
|
|
1243
|
+
${variables_21.navbar}
|
|
1239
1244
|
${pages}
|
|
1240
|
-
${
|
|
1245
|
+
${variables_25.productPicker}
|
|
1241
1246
|
${variables_11.responsePanelColors}
|
|
1242
|
-
${
|
|
1243
|
-
${
|
|
1247
|
+
${variables_22.search}
|
|
1248
|
+
${variables_13.select}
|
|
1244
1249
|
${variables_4.sidebar}
|
|
1245
1250
|
${sizeAndSpace}
|
|
1246
1251
|
${variables_6.tag}
|
|
1247
1252
|
${themeColors}
|
|
1248
1253
|
${tile}
|
|
1249
1254
|
${variables_7.toc}
|
|
1250
|
-
${
|
|
1255
|
+
${variables_15.tooltip}
|
|
1251
1256
|
${typography}
|
|
1252
|
-
${
|
|
1253
|
-
${
|
|
1257
|
+
${variables_33.userMenu}
|
|
1258
|
+
${variables_35.versionPicker}
|
|
1254
1259
|
${zIndexDepth}
|
|
1255
1260
|
${scorecardColors}
|
|
1256
|
-
${
|
|
1261
|
+
${variables_31.statusCode}
|
|
1257
1262
|
${tab}
|
|
1258
1263
|
${icon}
|
|
1259
1264
|
${tree}
|
|
1260
|
-
${
|
|
1261
|
-
${
|
|
1262
|
-
${
|
|
1265
|
+
${variables_32.segmented}
|
|
1266
|
+
${variables_37.switcher}
|
|
1267
|
+
${variables_16.checkbox}
|
|
1263
1268
|
${variables_3.feedback}
|
|
1264
1269
|
${variables_2.scorecard}
|
|
1265
|
-
${
|
|
1270
|
+
${variables_36.datePicker}
|
|
1266
1271
|
${replay}
|
|
1267
|
-
${
|
|
1268
|
-
${
|
|
1272
|
+
${variables_40.skipContent}
|
|
1273
|
+
${variables_41.pageActions}
|
|
1269
1274
|
|
|
1270
1275
|
background-color: var(--bg-color);
|
|
1271
1276
|
color: var(--text-color-primary);
|