@redocly/theme 0.59.0-next.4 → 0.59.0-rc.2
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/LICENSE +1 -7
- package/lib/components/Buttons/AIAssistantButton.js +1 -5
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +1 -1
- package/lib/components/Catalog/CatalogTagsWithTooltip.js +1 -1
- package/lib/components/Dropdown/Dropdown.d.ts +2 -16
- package/lib/components/Dropdown/Dropdown.js +5 -5
- package/lib/components/Menu/MenuItem.js +1 -1
- package/lib/components/Navbar/NavbarItem.js +3 -3
- package/lib/components/OpenApiDocs/hooks/AdditionalOverviewInfo.d.ts +1 -0
- package/lib/components/OpenApiDocs/hooks/AdditionalOverviewInfo.js +11 -0
- package/lib/components/OpenApiDocs/hooks/AfterOpenApiDescription.d.ts +1 -0
- package/lib/components/OpenApiDocs/hooks/AfterOpenApiDescription.js +5 -0
- package/lib/components/Search/FilterFields/SearchFilterFieldTags.js +2 -1
- package/lib/components/Search/SearchAiConversationInput.d.ts +1 -2
- package/lib/components/Search/SearchAiConversationInput.js +3 -11
- package/lib/components/Search/SearchDialog.js +3 -15
- package/lib/components/Search/SearchGroups.js +2 -2
- package/lib/components/Search/variables.js +1 -5
- package/lib/components/Select/SelectInput.js +1 -1
- package/lib/components/Select/variables.js +2 -2
- package/lib/components/Tag/Tag.d.ts +1 -2
- package/lib/components/Tag/Tag.js +17 -66
- package/lib/components/Tag/variables.dark.js +36 -135
- package/lib/components/Tag/variables.js +61 -78
- package/lib/core/constants/search.d.ts +4 -5
- package/lib/core/constants/search.js +5 -4
- package/lib/core/hooks/use-page-actions.d.ts +1 -1
- package/lib/core/hooks/use-page-actions.js +24 -1
- package/lib/core/hooks/use-tabs.d.ts +2 -3
- package/lib/core/hooks/use-tabs.js +57 -115
- package/lib/core/hooks/use-telemetry-fallback.d.ts +0 -1
- package/lib/core/hooks/use-telemetry-fallback.js +0 -1
- package/lib/core/types/hooks.d.ts +2 -2
- package/lib/ext/process-scorecard.d.ts +5 -0
- package/lib/ext/process-scorecard.js +11 -0
- package/lib/icons/AiStarsIcon/AiStarsIcon.js +2 -11
- package/lib/icons/RedoclyIcon/RedoclyIcon.js +7 -4
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/markdoc/components/Tabs/TabList.d.ts +1 -3
- package/lib/markdoc/components/Tabs/TabList.js +47 -197
- package/lib/markdoc/components/Tabs/Tabs.d.ts +1 -2
- package/lib/markdoc/components/Tabs/Tabs.js +12 -57
- package/package.json +5 -5
- package/src/components/Buttons/AIAssistantButton.tsx +1 -5
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +1 -1
- package/src/components/Catalog/CatalogTagsWithTooltip.tsx +5 -1
- package/src/components/Dropdown/Dropdown.tsx +79 -84
- package/src/components/Menu/MenuItem.tsx +0 -1
- package/src/components/Navbar/NavbarItem.tsx +5 -6
- package/src/components/OpenApiDocs/hooks/AdditionalOverviewInfo.tsx +9 -0
- package/src/components/OpenApiDocs/hooks/AfterOpenApiDescription.tsx +1 -0
- package/src/components/Search/FilterFields/SearchFilterFieldTags.tsx +3 -3
- package/src/components/Search/SearchAiConversationInput.tsx +2 -12
- package/src/components/Search/SearchDialog.tsx +3 -15
- package/src/components/Search/SearchGroups.tsx +0 -2
- package/src/components/Search/variables.ts +1 -5
- package/src/components/Select/SelectInput.tsx +0 -1
- package/src/components/Select/variables.ts +2 -2
- package/src/components/Tag/Tag.tsx +19 -35
- package/src/components/Tag/variables.dark.ts +36 -135
- package/src/components/Tag/variables.ts +61 -78
- package/src/core/constants/search.ts +4 -8
- package/src/core/hooks/use-page-actions.ts +33 -2
- package/src/core/hooks/use-tabs.ts +86 -168
- package/src/core/hooks/use-telemetry-fallback.ts +0 -1
- package/src/core/types/hooks.ts +1 -5
- package/src/ext/process-scorecard.ts +13 -0
- package/src/icons/AiStarsIcon/AiStarsIcon.tsx +2 -11
- package/src/icons/RedoclyIcon/RedoclyIcon.tsx +22 -4
- package/src/index.ts +2 -0
- package/src/markdoc/components/Tabs/TabList.tsx +105 -312
- package/src/markdoc/components/Tabs/Tabs.tsx +11 -136
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, { useState, useEffect
|
|
2
|
-
import
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
4
3
|
|
|
5
4
|
import type { JSX } from 'react';
|
|
6
5
|
|
|
@@ -27,26 +26,6 @@ type TabsProps = {
|
|
|
27
26
|
className?: string;
|
|
28
27
|
size: TabsSize;
|
|
29
28
|
initialTab?: string;
|
|
30
|
-
forceReady?: boolean;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
type UseActiveTabFn = (
|
|
34
|
-
initialTab: string,
|
|
35
|
-
tabsId: string | undefined,
|
|
36
|
-
childrenArray: React.ReactElement<TabItemProps>[],
|
|
37
|
-
) => {
|
|
38
|
-
activeTab: string;
|
|
39
|
-
setActiveTab: (tab: string) => void;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
type TabsViewProps = Omit<TabsProps, 'children'> & {
|
|
43
|
-
childrenArray: React.ReactElement<TabItemProps>[];
|
|
44
|
-
initialTab: string;
|
|
45
|
-
isReady: boolean;
|
|
46
|
-
labelsHash: string;
|
|
47
|
-
useActiveTab: UseActiveTabFn;
|
|
48
|
-
containerRef: React.RefObject<HTMLUListElement | null>;
|
|
49
|
-
onReadyChange: (ready: boolean) => void;
|
|
50
29
|
};
|
|
51
30
|
|
|
52
31
|
export function Tabs({
|
|
@@ -55,72 +34,25 @@ export function Tabs({
|
|
|
55
34
|
className,
|
|
56
35
|
size,
|
|
57
36
|
initialTab: propInitialTab,
|
|
58
|
-
forceReady = false,
|
|
59
37
|
}: TabsProps): JSX.Element {
|
|
60
|
-
const childrenArray = React.
|
|
61
|
-
|
|
62
|
-
|
|
38
|
+
const [childrenArray, setChildrenArray] = useState<React.ReactElement<TabItemProps>[]>(
|
|
39
|
+
React.Children.toArray(children) as React.ReactElement<TabItemProps>[],
|
|
40
|
+
);
|
|
63
41
|
|
|
64
42
|
const initialTab = propInitialTab ?? childrenArray[0]?.props.label ?? '';
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const handleReadyChange = useCallback((ready: boolean) => {
|
|
68
|
-
setIsReady(ready);
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
|
-
// Reset isReady when children change (new page/tabs)
|
|
72
|
-
// Use useLayoutEffect to run synchronously before paint
|
|
73
|
-
useLayoutEffect(() => {
|
|
74
|
-
setIsReady(false);
|
|
75
|
-
}, [labelsHash]);
|
|
76
|
-
|
|
77
|
-
const inRouter = useInRouterContext();
|
|
43
|
+
const { activeTab, setActiveTab } = useActiveTab({ tabsId: id, initialTab });
|
|
78
44
|
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
className={className}
|
|
83
|
-
size={size}
|
|
84
|
-
childrenArray={childrenArray}
|
|
85
|
-
initialTab={initialTab}
|
|
86
|
-
useActiveTab={inRouter ? useActiveTabWithRouter : useActiveTabWithoutRouter}
|
|
87
|
-
isReady={isReady || forceReady}
|
|
88
|
-
labelsHash={labelsHash}
|
|
89
|
-
containerRef={containerRef}
|
|
90
|
-
onReadyChange={handleReadyChange}
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function TabsView({
|
|
96
|
-
id,
|
|
97
|
-
className,
|
|
98
|
-
size,
|
|
99
|
-
childrenArray,
|
|
100
|
-
useActiveTab,
|
|
101
|
-
initialTab,
|
|
102
|
-
isReady,
|
|
103
|
-
labelsHash,
|
|
104
|
-
containerRef,
|
|
105
|
-
onReadyChange,
|
|
106
|
-
}: TabsViewProps): JSX.Element {
|
|
107
|
-
const { activeTab, setActiveTab } = useActiveTab(initialTab, id, childrenArray);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
setChildrenArray(React.Children.toArray(children) as React.ReactElement<TabItemProps>[]);
|
|
47
|
+
}, [children]);
|
|
108
48
|
|
|
109
49
|
return (
|
|
110
|
-
<TabsContainer
|
|
111
|
-
data-component-name="Markdoc/Tabs/Tabs"
|
|
112
|
-
className={className}
|
|
113
|
-
key={id}
|
|
114
|
-
$isReady={isReady}
|
|
115
|
-
>
|
|
50
|
+
<TabsContainer data-component-name="Markdoc/Tabs/Tabs" className={className} key={id}>
|
|
116
51
|
<TabList
|
|
117
|
-
key={labelsHash}
|
|
118
52
|
size={size}
|
|
119
53
|
childrenArray={childrenArray}
|
|
120
54
|
activeTab={activeTab}
|
|
121
55
|
onTabChange={setActiveTab}
|
|
122
|
-
containerRef={containerRef}
|
|
123
|
-
onReadyChange={onReadyChange}
|
|
124
56
|
/>
|
|
125
57
|
{childrenArray.map((child, index) => {
|
|
126
58
|
const { label } = child.props;
|
|
@@ -140,56 +72,7 @@ function TabsView({
|
|
|
140
72
|
</TabsContainer>
|
|
141
73
|
);
|
|
142
74
|
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Validates that the active tab exists in children and resets to initial tab if not found.
|
|
146
|
-
* Ensures tab state remains consistent when tab structure changes.
|
|
147
|
-
*/
|
|
148
|
-
function useValidateActiveTab(
|
|
149
|
-
activeTab: string,
|
|
150
|
-
setActiveTab: (tab: string) => void,
|
|
151
|
-
childrenArray: React.ReactElement<TabItemProps>[],
|
|
152
|
-
initialTab: string,
|
|
153
|
-
) {
|
|
154
|
-
useEffect(() => {
|
|
155
|
-
const availableLabels = childrenArray.map((child) => child.props.label);
|
|
156
|
-
if (activeTab && !availableLabels.includes(activeTab) && availableLabels.length > 0) {
|
|
157
|
-
setActiveTab(initialTab);
|
|
158
|
-
}
|
|
159
|
-
}, [childrenArray, activeTab, initialTab, setActiveTab]);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const useActiveTabWithRouter = (
|
|
163
|
-
initialTab: string,
|
|
164
|
-
tabsId: string | undefined,
|
|
165
|
-
childrenArray: React.ReactElement<TabItemProps>[],
|
|
166
|
-
) => {
|
|
167
|
-
const { activeTab, setActiveTab } = useActiveTab({ initialTab, tabsId });
|
|
168
|
-
|
|
169
|
-
useValidateActiveTab(activeTab, setActiveTab, childrenArray, initialTab);
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
activeTab,
|
|
173
|
-
setActiveTab,
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const useActiveTabWithoutRouter = (
|
|
178
|
-
initialTab: string,
|
|
179
|
-
_tabsId: string | undefined,
|
|
180
|
-
childrenArray: React.ReactElement<TabItemProps>[],
|
|
181
|
-
) => {
|
|
182
|
-
const [activeTab, setActiveTab] = useState(initialTab);
|
|
183
|
-
|
|
184
|
-
useValidateActiveTab(activeTab, setActiveTab, childrenArray, initialTab);
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
activeTab,
|
|
188
|
-
setActiveTab,
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const TabsContainer = styled.div<{ $isReady: boolean }>`
|
|
75
|
+
const TabsContainer = styled.div`
|
|
193
76
|
position: relative;
|
|
194
77
|
color: var(--md-tabs-container-text-color);
|
|
195
78
|
font-size: var(--md-tabs-container-font-size);
|
|
@@ -205,14 +88,6 @@ const TabsContainer = styled.div<{ $isReady: boolean }>`
|
|
|
205
88
|
margin: 0;
|
|
206
89
|
padding: 0;
|
|
207
90
|
}
|
|
208
|
-
|
|
209
|
-
${({ $isReady }) =>
|
|
210
|
-
!$isReady &&
|
|
211
|
-
css`
|
|
212
|
-
opacity: 0;
|
|
213
|
-
pointer-events: none;
|
|
214
|
-
overflow: hidden;
|
|
215
|
-
`}
|
|
216
91
|
`;
|
|
217
92
|
|
|
218
93
|
export const TabContent = styled.div`
|