docusaurus-theme-openapi-docs 0.0.0-845 → 0.0.0-849
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.
|
@@ -72,18 +72,29 @@ function TabList({
|
|
|
72
72
|
tabValues,
|
|
73
73
|
}) {
|
|
74
74
|
const tabRefs = (0, react_1.useRef)([]);
|
|
75
|
+
const tabsScrollContainerRef = (0, react_1.useRef)();
|
|
75
76
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
76
77
|
internal_1.useScrollPositionBlocker)();
|
|
77
78
|
(0, react_1.useEffect)(() => {
|
|
78
79
|
const activeTab = tabRefs.current.find(
|
|
79
80
|
(tab) => tab?.getAttribute("aria-selected") === "true"
|
|
80
81
|
);
|
|
81
|
-
if (activeTab) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
if (activeTab && tabsScrollContainerRef.current) {
|
|
83
|
+
const container = tabsScrollContainerRef.current;
|
|
84
|
+
const containerRect = container.getBoundingClientRect();
|
|
85
|
+
const activeTabRect = activeTab.getBoundingClientRect();
|
|
86
|
+
// Calculate the distance to scroll to align active tab to the left
|
|
87
|
+
const glowOffset = 3;
|
|
88
|
+
const scrollOffset =
|
|
89
|
+
activeTabRect.left -
|
|
90
|
+
containerRect.left +
|
|
91
|
+
container.scrollLeft -
|
|
92
|
+
glowOffset;
|
|
93
|
+
// Check if the active tab is not already at the left position
|
|
94
|
+
if (Math.abs(scrollOffset - container.scrollLeft) > 4) {
|
|
95
|
+
// Adjust the scroll of the container
|
|
96
|
+
container.scrollLeft = scrollOffset;
|
|
97
|
+
}
|
|
87
98
|
}
|
|
88
99
|
}, []);
|
|
89
100
|
const handleTabChange = (event) => {
|
|
@@ -155,6 +166,7 @@ function TabList({
|
|
|
155
166
|
},
|
|
156
167
|
className
|
|
157
168
|
),
|
|
169
|
+
ref: tabsScrollContainerRef,
|
|
158
170
|
},
|
|
159
171
|
tabValues.map(({ value, label, attributes }) =>
|
|
160
172
|
react_1.default.createElement(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-849",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"clsx": "^1.1.1",
|
|
43
43
|
"copy-text-to-clipboard": "^3.1.0",
|
|
44
44
|
"crypto-js": "^4.1.1",
|
|
45
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
45
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-849",
|
|
46
46
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
47
47
|
"file-saver": "^2.0.5",
|
|
48
48
|
"lodash": "^4.17.20",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=14"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "cb92722ebee6fe516b1ba535821567bd75bc5281"
|
|
74
74
|
}
|
|
@@ -44,6 +44,7 @@ function TabList({
|
|
|
44
44
|
tabValues,
|
|
45
45
|
}: CodeTabsProps & ReturnType<typeof useTabs>) {
|
|
46
46
|
const tabRefs = useRef<(HTMLLIElement | null)[]>([]);
|
|
47
|
+
const tabsScrollContainerRef = useRef<any>();
|
|
47
48
|
const { blockElementScrollPositionUntilNextRender } =
|
|
48
49
|
useScrollPositionBlocker();
|
|
49
50
|
|
|
@@ -51,12 +52,26 @@ function TabList({
|
|
|
51
52
|
const activeTab = tabRefs.current.find(
|
|
52
53
|
(tab) => tab?.getAttribute("aria-selected") === "true"
|
|
53
54
|
);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
|
|
56
|
+
if (activeTab && tabsScrollContainerRef.current) {
|
|
57
|
+
const container = tabsScrollContainerRef.current;
|
|
58
|
+
const containerRect = container.getBoundingClientRect();
|
|
59
|
+
const activeTabRect = activeTab.getBoundingClientRect();
|
|
60
|
+
|
|
61
|
+
// Calculate the distance to scroll to align active tab to the left
|
|
62
|
+
const glowOffset = 3;
|
|
63
|
+
const scrollOffset =
|
|
64
|
+
activeTabRect.left -
|
|
65
|
+
containerRect.left +
|
|
66
|
+
container.scrollLeft -
|
|
67
|
+
glowOffset;
|
|
68
|
+
|
|
69
|
+
// Check if the active tab is not already at the left position
|
|
70
|
+
|
|
71
|
+
if (Math.abs(scrollOffset - container.scrollLeft) > 4) {
|
|
72
|
+
// Adjust the scroll of the container
|
|
73
|
+
container.scrollLeft = scrollOffset;
|
|
74
|
+
}
|
|
60
75
|
}
|
|
61
76
|
}, []);
|
|
62
77
|
|
|
@@ -139,6 +154,7 @@ function TabList({
|
|
|
139
154
|
},
|
|
140
155
|
className
|
|
141
156
|
)}
|
|
157
|
+
ref={tabsScrollContainerRef}
|
|
142
158
|
>
|
|
143
159
|
{tabValues.map(({ value, label, attributes }) => (
|
|
144
160
|
<li
|