@redocly/theme 0.59.0-next.0 → 0.59.0-next.10
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 +7 -1
- package/lib/components/Accordion/Accordion.d.ts +12 -0
- package/lib/components/Accordion/Accordion.js +85 -0
- package/lib/components/Accordion/AccordionBody.d.ts +8 -0
- package/lib/components/Accordion/AccordionBody.js +73 -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/Admonition/Admonition.js +17 -7
- package/lib/components/Badge/Badge.js +17 -7
- package/lib/components/Breadcrumbs/Breadcrumb.js +17 -7
- package/lib/components/Breadcrumbs/BreadcrumbDropdown.js +17 -7
- package/lib/components/Button/Button.js +17 -7
- package/lib/components/Buttons/AIAssistantButton.d.ts +2 -0
- package/lib/components/Buttons/AIAssistantButton.js +139 -0
- package/lib/components/Buttons/CopyButton.js +17 -7
- 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.d.ts +6 -0
- package/lib/components/Catalog/Catalog.js +9 -8
- package/lib/components/Catalog/CatalogEntities.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityInfoBar.js +1 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +17 -7
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +17 -7
- package/lib/components/Catalog/CatalogEntityIcon.js +2 -1
- package/lib/components/Catalog/CatalogFilter/CatalogFilter.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilter.js +39 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterCheckboxes.js +152 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.d.ts +13 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterContent.js +102 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterDateRange.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterDateRange.js +121 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterSelect.d.ts +6 -0
- package/lib/components/Catalog/CatalogFilter/CatalogFilterSelect.js +126 -0
- package/lib/components/Catalog/CatalogSelector.js +0 -1
- package/lib/components/Catalog/CatalogSortButton.js +17 -7
- package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.js +17 -7
- package/lib/components/Catalog/CatalogViewModeToggle.js +17 -7
- package/lib/components/Catalog/variables.js +1 -2
- package/lib/components/CatalogClassic/CatalogClassicActions.js +17 -7
- package/lib/components/CatalogClassic/CatalogClassicCard.js +17 -7
- package/lib/components/CatalogClassic/CatalogClassicHighlight.js +17 -7
- package/lib/components/CatalogClassic/CatalogClassicVirtualizedGroups.js +17 -7
- package/lib/components/CodeBlock/CodeBlock.js +17 -7
- package/lib/components/CodeBlock/CodeBlockContainer.js +17 -7
- package/lib/components/CodeBlock/CodeBlockTabs.js +17 -7
- package/lib/components/Dropdown/Dropdown.d.ts +16 -2
- package/lib/components/Dropdown/Dropdown.js +22 -12
- package/lib/components/Dropdown/DropdownMenuItem.js +17 -7
- package/lib/components/Feedback/Comment.js +17 -7
- package/lib/components/Feedback/Feedback.js +17 -7
- package/lib/components/Feedback/Mood.js +17 -7
- package/lib/components/Feedback/Rating.js +17 -7
- package/lib/components/Feedback/Reasons.js +17 -7
- package/lib/components/Feedback/Scale.js +17 -7
- package/lib/components/Feedback/Sentiment.js +17 -7
- package/lib/components/Feedback/Stars.js +17 -7
- package/lib/components/Filter/FilterContent.js +17 -7
- package/lib/components/Filter/FilterInput.d.ts +1 -0
- package/lib/components/Filter/FilterInput.js +19 -9
- package/lib/components/Filter/FilterOptions.js +2 -0
- package/lib/components/Filter/variables.js +7 -4
- package/lib/components/Image/Image.js +17 -7
- package/lib/components/JsonViewer/JsonViewer.js +17 -7
- package/lib/components/JsonViewer/helpers.js +17 -7
- package/lib/components/LastUpdated/LastUpdated.js +17 -7
- package/lib/components/Link/Link.js +17 -7
- package/lib/components/Markdown/Markdown.js +17 -7
- package/lib/components/Marker/Marker.js +17 -7
- package/lib/components/Menu/MenuContainer.js +17 -7
- package/lib/components/Menu/MenuItem.js +18 -8
- package/lib/components/Menu/MenuMobile.js +17 -7
- package/lib/components/Navbar/NavbarItem.js +3 -3
- package/lib/components/PageActions/PageActions.js +17 -7
- package/lib/components/PageNavigation/NextButton.js +17 -7
- package/lib/components/Panel/Panel.js +17 -7
- package/lib/components/Panel/PanelBody.js +17 -7
- package/lib/components/Search/FilterFields/SearchFilterFieldSelect.js +17 -7
- package/lib/components/Search/FilterFields/SearchFilterFieldTags.js +1 -2
- package/lib/components/Search/SearchAiActionButtons.d.ts +10 -0
- package/lib/components/Search/SearchAiActionButtons.js +43 -0
- package/lib/components/Search/SearchAiConversationInput.d.ts +3 -1
- package/lib/components/Search/SearchAiConversationInput.js +56 -14
- package/lib/components/Search/SearchAiDialog.d.ts +3 -6
- package/lib/components/Search/SearchAiDialog.js +39 -19
- package/lib/components/Search/SearchAiMessage.d.ts +9 -5
- package/lib/components/Search/SearchAiMessage.js +146 -22
- package/lib/components/Search/SearchAiNegativeFeedbackForm.d.ts +8 -0
- package/lib/components/Search/SearchAiNegativeFeedbackForm.js +169 -0
- package/lib/components/Search/SearchAiResponse.js +2 -3
- package/lib/components/Search/SearchDialog.d.ts +2 -1
- package/lib/components/Search/SearchDialog.js +55 -14
- package/lib/components/Search/SearchFilter.js +17 -7
- package/lib/components/Search/SearchGroups.js +19 -9
- package/lib/components/Search/SearchHighlight.js +17 -7
- package/lib/components/Search/SearchItem.js +17 -7
- package/lib/components/Search/SearchRecent.js +17 -7
- package/lib/components/Search/SearchShortcut.js +17 -7
- package/lib/components/Search/SearchSuggestedPages.js +17 -7
- package/lib/components/Search/SearchTrigger.js +17 -7
- package/lib/components/Search/variables.js +36 -64
- package/lib/components/Segmented/Segmented.js +17 -7
- package/lib/components/Select/Select.js +17 -7
- package/lib/components/Select/SelectInput.js +18 -8
- package/lib/components/Sidebar/Sidebar.js +17 -7
- package/lib/components/SidebarActions/styled.js +17 -7
- package/lib/components/SkipContent/SkipContent.js +17 -7
- package/lib/components/Switch/Switch.js +17 -7
- package/lib/components/TableOfContent/TableOfContent.js +17 -7
- package/lib/components/Tag/Tag.d.ts +2 -1
- package/lib/components/Tag/Tag.js +67 -18
- package/lib/components/Tag/variables.dark.js +137 -38
- package/lib/components/Tag/variables.js +78 -61
- package/lib/components/Tooltip/Tooltip.js +17 -7
- package/lib/components/VersionPicker/VersionPicker.js +17 -7
- package/lib/core/constants/search.d.ts +5 -4
- package/lib/core/constants/search.js +4 -5
- package/lib/core/contexts/CodeSnippetContext.js +17 -7
- package/lib/core/hooks/index.d.ts +1 -0
- package/lib/core/hooks/index.js +1 -0
- package/lib/core/hooks/menu/use-nested-menu.js +1 -1
- package/lib/core/hooks/search/use-feedback-tooltip.d.ts +6 -0
- package/lib/core/hooks/search/use-feedback-tooltip.js +26 -0
- package/lib/core/hooks/use-product-picker.js +2 -1
- package/lib/core/hooks/use-tabs.d.ts +3 -2
- package/lib/core/hooks/use-tabs.js +115 -57
- package/lib/core/hooks/use-telemetry-fallback.d.ts +10 -8
- package/lib/core/hooks/use-telemetry-fallback.js +10 -8
- package/lib/core/styles/dark.js +33 -26
- package/lib/core/styles/global.js +68 -59
- package/lib/core/templates/Markdown.js +17 -7
- package/lib/core/types/hooks.d.ts +6 -3
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/types/search.d.ts +11 -4
- package/lib/core/types/search.js +6 -0
- package/lib/core/utils/download-code-walkthrough.js +17 -7
- package/lib/core/utils/frontmatter-translate.d.ts +6 -0
- package/lib/core/utils/frontmatter-translate.js +14 -0
- package/lib/core/utils/get-file-icon.js +17 -7
- package/lib/core/utils/index.d.ts +1 -0
- package/lib/core/utils/index.js +1 -0
- package/lib/icons/AiStarsGradientIcon/AiStarsGradientIcon.js +44 -4
- package/lib/icons/AiStarsIcon/AiStarsIcon.js +11 -2
- package/lib/icons/CubeIcon/CubeIcon.d.ts +9 -0
- package/lib/icons/CubeIcon/CubeIcon.js +17 -0
- package/lib/icons/GenericIcon/GenericIcon.js +17 -7
- package/lib/icons/HashtagIcon/HashtagIcon.d.ts +9 -0
- package/lib/icons/HashtagIcon/HashtagIcon.js +22 -0
- package/lib/icons/RedoclyIcon/RedoclyIcon.d.ts +9 -0
- package/lib/icons/RedoclyIcon/RedoclyIcon.js +24 -0
- package/lib/icons/Spinner/Spinner.js +17 -7
- package/lib/icons/ThumbDownFilledIcon/ThumbDownFilledIcon.d.ts +9 -0
- package/lib/icons/ThumbDownFilledIcon/ThumbDownFilledIcon.js +34 -0
- package/lib/icons/ThumbUpFilledIcon/ThumbUpFilledIcon.d.ts +9 -0
- package/lib/icons/ThumbUpFilledIcon/ThumbUpFilledIcon.js +34 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +20 -7
- package/lib/layouts/OIDCForbidden.js +17 -7
- package/lib/layouts/RootLayout.js +6 -1
- package/lib/layouts/ThreePanelLayout.js +17 -7
- package/lib/markdoc/components/Cards/Card.js +1 -28
- package/lib/markdoc/components/Cards/Cards.js +17 -7
- package/lib/markdoc/components/CodeGroup/CodeGroup.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodeContainer.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodePanel.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodePanelToolbar.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodeStep.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodeToggle.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.js +17 -7
- package/lib/markdoc/components/CodeWalkthrough/Input.js +17 -7
- package/lib/markdoc/components/Heading/Heading.js +17 -7
- package/lib/markdoc/components/HtmlBlock/HtmlBlock.js +17 -7
- package/lib/markdoc/components/InlineSvg/InlineSvg.js +17 -7
- package/lib/markdoc/components/MarkdocExample/MarkdocExample.js +17 -7
- package/lib/markdoc/components/Tabs/TabList.d.ts +3 -1
- package/lib/markdoc/components/Tabs/TabList.js +214 -54
- package/lib/markdoc/components/Tabs/Tabs.d.ts +2 -1
- package/lib/markdoc/components/Tabs/Tabs.js +74 -19
- package/lib/markdoc/default.d.ts +104 -1
- package/lib/markdoc/default.js +17 -7
- package/lib/markdoc/tags/card.js +0 -1
- package/package.json +8 -8
- 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 +145 -0
- package/src/components/Buttons/variables.dark.ts +7 -0
- package/src/components/Buttons/variables.ts +48 -0
- package/src/components/Catalog/Catalog.tsx +18 -6
- package/src/components/Catalog/CatalogEntity/CatalogEntityInfoBar.tsx +1 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +1 -1
- package/src/components/Catalog/CatalogEntityIcon.tsx +2 -1
- package/src/components/Catalog/CatalogFilter/CatalogFilter.tsx +61 -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 +1 -2
- package/src/components/Dropdown/Dropdown.tsx +84 -79
- 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/Menu/MenuItem.tsx +1 -0
- package/src/components/Navbar/NavbarItem.tsx +6 -5
- package/src/components/Search/FilterFields/SearchFilterFieldTags.tsx +3 -3
- package/src/components/Search/SearchAiActionButtons.tsx +76 -0
- package/src/components/Search/SearchAiConversationInput.tsx +61 -18
- package/src/components/Search/SearchAiDialog.tsx +54 -25
- package/src/components/Search/SearchAiMessage.tsx +172 -43
- package/src/components/Search/SearchAiNegativeFeedbackForm.tsx +210 -0
- package/src/components/Search/SearchAiResponse.tsx +2 -2
- package/src/components/Search/SearchDialog.tsx +56 -15
- package/src/components/Search/SearchGroups.tsx +2 -0
- package/src/components/Search/variables.ts +36 -64
- package/src/components/Select/SelectInput.tsx +1 -0
- package/src/components/Tag/Tag.tsx +36 -20
- package/src/components/Tag/variables.dark.ts +137 -38
- package/src/components/Tag/variables.ts +78 -61
- package/src/core/constants/search.ts +8 -4
- package/src/core/hooks/index.ts +1 -0
- package/src/core/hooks/menu/use-nested-menu.ts +2 -2
- package/src/core/hooks/search/use-feedback-tooltip.ts +32 -0
- package/src/core/hooks/use-product-picker.ts +2 -1
- package/src/core/hooks/use-tabs.ts +168 -86
- package/src/core/hooks/use-telemetry-fallback.ts +10 -8
- package/src/core/styles/dark.ts +15 -8
- package/src/core/styles/global.ts +11 -2
- package/src/core/types/hooks.ts +6 -1
- package/src/core/types/l10n.ts +6 -0
- package/src/core/types/search.ts +13 -4
- package/src/core/utils/frontmatter-translate.ts +9 -0
- package/src/core/utils/index.ts +1 -0
- package/src/icons/AiStarsGradientIcon/AiStarsGradientIcon.tsx +13 -4
- package/src/icons/AiStarsIcon/AiStarsIcon.tsx +11 -2
- package/src/icons/CubeIcon/CubeIcon.tsx +27 -0
- package/src/icons/HashtagIcon/HashtagIcon.tsx +23 -0
- package/src/icons/RedoclyIcon/RedoclyIcon.tsx +26 -0
- package/src/icons/ThumbDownFilledIcon/ThumbDownFilledIcon.tsx +38 -0
- package/src/icons/ThumbUpFilledIcon/ThumbUpFilledIcon.tsx +35 -0
- package/src/index.ts +3 -0
- package/src/layouts/RootLayout.tsx +6 -0
- package/src/markdoc/components/Cards/Card.tsx +1 -28
- package/src/markdoc/components/Tabs/TabList.tsx +312 -105
- package/src/markdoc/components/Tabs/Tabs.tsx +136 -11
- package/src/markdoc/tags/card.ts +0 -1
|
@@ -15,21 +15,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
28
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
36
|
exports.TabContent = exports.TabsSize = void 0;
|
|
30
37
|
exports.Tabs = Tabs;
|
|
31
38
|
const react_1 = __importStar(require("react"));
|
|
32
|
-
const
|
|
39
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
40
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
33
41
|
const hooks_1 = require("../../../core/hooks");
|
|
34
42
|
const TabList_1 = require("../../../markdoc/components/Tabs/TabList");
|
|
35
43
|
const utils_1 = require("../../../core/utils");
|
|
@@ -38,22 +46,62 @@ var TabsSize;
|
|
|
38
46
|
TabsSize["SMALL"] = "small";
|
|
39
47
|
TabsSize["MEDIUM"] = "medium";
|
|
40
48
|
})(TabsSize || (exports.TabsSize = TabsSize = {}));
|
|
41
|
-
function Tabs({ id, children, className, size, initialTab: propInitialTab, }) {
|
|
49
|
+
function Tabs({ id, children, className, size, initialTab: propInitialTab, forceReady = false, }) {
|
|
42
50
|
var _a, _b;
|
|
43
|
-
const
|
|
51
|
+
const childrenArray = react_1.default.Children.toArray(children);
|
|
52
|
+
const [isReady, setIsReady] = (0, react_1.useState)(false);
|
|
53
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
44
54
|
const initialTab = (_b = propInitialTab !== null && propInitialTab !== void 0 ? propInitialTab : (_a = childrenArray[0]) === null || _a === void 0 ? void 0 : _a.props.label) !== null && _b !== void 0 ? _b : '';
|
|
45
|
-
const
|
|
46
|
-
(0, react_1.
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
const labelsHash = childrenArray.map((c) => c.props.label).join('|');
|
|
56
|
+
const handleReadyChange = (0, react_1.useCallback)((ready) => {
|
|
57
|
+
setIsReady(ready);
|
|
58
|
+
}, []);
|
|
59
|
+
// Reset isReady when children change (new page/tabs)
|
|
60
|
+
// Use useLayoutEffect to run synchronously before paint
|
|
61
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
62
|
+
setIsReady(false);
|
|
63
|
+
}, [labelsHash]);
|
|
64
|
+
const inRouter = (0, react_router_dom_1.useInRouterContext)();
|
|
65
|
+
return (react_1.default.createElement(TabsView, { id: id, className: className, size: size, childrenArray: childrenArray, initialTab: initialTab, useActiveTab: inRouter ? useActiveTabWithRouter : useActiveTabWithoutRouter, isReady: isReady || forceReady, labelsHash: labelsHash, containerRef: containerRef, onReadyChange: handleReadyChange }));
|
|
66
|
+
}
|
|
67
|
+
function TabsView({ id, className, size, childrenArray, useActiveTab, initialTab, isReady, labelsHash, containerRef, onReadyChange, }) {
|
|
68
|
+
const { activeTab, setActiveTab } = useActiveTab(initialTab, id, childrenArray);
|
|
69
|
+
return (react_1.default.createElement(TabsContainer, { "data-component-name": "Markdoc/Tabs/Tabs", className: className, key: id, "$isReady": isReady },
|
|
70
|
+
react_1.default.createElement(TabList_1.TabList, { key: labelsHash, size: size, childrenArray: childrenArray, activeTab: activeTab, onTabChange: setActiveTab, containerRef: containerRef, onReadyChange: onReadyChange }),
|
|
51
71
|
childrenArray.map((child, index) => {
|
|
52
72
|
const { label } = child.props;
|
|
53
73
|
const tabId = (0, utils_1.getTabId)(label, index);
|
|
54
74
|
return label === activeTab ? (react_1.default.createElement(exports.TabContent, { key: `content-${tabId}`, id: `panel-${tabId}`, "aria-labelledby": `tab-${tabId}`, tabIndex: 0, role: "tabpanel" }, child.props.children)) : null;
|
|
55
75
|
})));
|
|
56
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Validates that the active tab exists in children and resets to initial tab if not found.
|
|
79
|
+
* Ensures tab state remains consistent when tab structure changes.
|
|
80
|
+
*/
|
|
81
|
+
function useValidateActiveTab(activeTab, setActiveTab, childrenArray, initialTab) {
|
|
82
|
+
(0, react_1.useEffect)(() => {
|
|
83
|
+
const availableLabels = childrenArray.map((child) => child.props.label);
|
|
84
|
+
if (activeTab && !availableLabels.includes(activeTab) && availableLabels.length > 0) {
|
|
85
|
+
setActiveTab(initialTab);
|
|
86
|
+
}
|
|
87
|
+
}, [childrenArray, activeTab, initialTab, setActiveTab]);
|
|
88
|
+
}
|
|
89
|
+
const useActiveTabWithRouter = (initialTab, tabsId, childrenArray) => {
|
|
90
|
+
const { activeTab, setActiveTab } = (0, hooks_1.useActiveTab)({ initialTab, tabsId });
|
|
91
|
+
useValidateActiveTab(activeTab, setActiveTab, childrenArray, initialTab);
|
|
92
|
+
return {
|
|
93
|
+
activeTab,
|
|
94
|
+
setActiveTab,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
const useActiveTabWithoutRouter = (initialTab, _tabsId, childrenArray) => {
|
|
98
|
+
const [activeTab, setActiveTab] = (0, react_1.useState)(initialTab);
|
|
99
|
+
useValidateActiveTab(activeTab, setActiveTab, childrenArray, initialTab);
|
|
100
|
+
return {
|
|
101
|
+
activeTab,
|
|
102
|
+
setActiveTab,
|
|
103
|
+
};
|
|
104
|
+
};
|
|
57
105
|
const TabsContainer = styled_components_1.default.div `
|
|
58
106
|
position: relative;
|
|
59
107
|
color: var(--md-tabs-container-text-color);
|
|
@@ -70,6 +118,13 @@ const TabsContainer = styled_components_1.default.div `
|
|
|
70
118
|
margin: 0;
|
|
71
119
|
padding: 0;
|
|
72
120
|
}
|
|
121
|
+
|
|
122
|
+
${({ $isReady }) => !$isReady &&
|
|
123
|
+
(0, styled_components_1.css) `
|
|
124
|
+
opacity: 0;
|
|
125
|
+
pointer-events: none;
|
|
126
|
+
overflow: hidden;
|
|
127
|
+
`}
|
|
73
128
|
`;
|
|
74
129
|
exports.TabContent = styled_components_1.default.div `
|
|
75
130
|
color: var(--md-tabs-content-text-color);
|
package/lib/markdoc/default.d.ts
CHANGED
|
@@ -4,8 +4,111 @@ export * from '../markdoc/attributes/img-srcset';
|
|
|
4
4
|
export * from '../markdoc/attributes/relative-path';
|
|
5
5
|
export * from '../markdoc/attributes/svg-content';
|
|
6
6
|
export * as components from '../markdoc/components/default';
|
|
7
|
+
import { admonition } from '../markdoc/tags/admonition';
|
|
8
|
+
import { html } from '../markdoc/tags/html';
|
|
9
|
+
import { markdocExample } from '../markdoc/tags/markdoc-example';
|
|
10
|
+
import { partial } from '../markdoc/tags/partial';
|
|
11
|
+
import { tab } from '../markdoc/tags/tab';
|
|
12
|
+
import { tabs } from '../markdoc/tags/tabs';
|
|
13
|
+
import { debug } from '../markdoc/tags/debug';
|
|
14
|
+
import { codeSnippet } from '../markdoc/tags/code-snippet';
|
|
15
|
+
import { inlineSvg } from '../markdoc/tags/inline-svg';
|
|
16
|
+
import { cards } from '../markdoc/tags/cards';
|
|
17
|
+
import { card } from '../markdoc/tags/card';
|
|
18
|
+
import { img } from '../markdoc/tags/img';
|
|
19
|
+
import { codeWalkthrough } from '../markdoc/tags/code-walkthrough';
|
|
20
|
+
import { codeStep } from '../markdoc/tags/code-step';
|
|
21
|
+
import { input } from '../markdoc/tags/input';
|
|
22
|
+
import { toggle } from '../markdoc/tags/code-toggle';
|
|
23
|
+
import { codeGroup } from '../markdoc/tags/code-group';
|
|
24
|
+
import { icon } from '../markdoc/tags/icon';
|
|
7
25
|
export declare const tags: {
|
|
8
|
-
[
|
|
26
|
+
[admonition.tagName]: import("@markdoc/markdoc").Schema & {
|
|
27
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
28
|
+
resolver?: string;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
[debug.tagName]: import("@markdoc/markdoc").Schema & {
|
|
32
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
33
|
+
resolver?: string;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
[html.tagName]: import("@markdoc/markdoc").Schema & {
|
|
37
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
38
|
+
resolver?: string;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
[markdocExample.tagName]: import("@markdoc/markdoc").Schema & {
|
|
42
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
43
|
+
resolver?: string;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
46
|
+
[partial.tagName]: import("@markdoc/markdoc").Schema & {
|
|
47
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
48
|
+
resolver?: string;
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
[tab.tagName]: import("@markdoc/markdoc").Schema & {
|
|
52
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
53
|
+
resolver?: string;
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
56
|
+
[tabs.tagName]: import("@markdoc/markdoc").Schema & {
|
|
57
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
58
|
+
resolver?: string;
|
|
59
|
+
}>;
|
|
60
|
+
};
|
|
61
|
+
[codeSnippet.tagName]: import("@markdoc/markdoc").Schema & {
|
|
62
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
63
|
+
resolver?: string;
|
|
64
|
+
}>;
|
|
65
|
+
};
|
|
66
|
+
[inlineSvg.tagName]: import("@markdoc/markdoc").Schema & {
|
|
67
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
68
|
+
resolver?: string;
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
[cards.tagName]: import("@markdoc/markdoc").Schema & {
|
|
72
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
73
|
+
resolver?: string;
|
|
74
|
+
}>;
|
|
75
|
+
};
|
|
76
|
+
[card.tagName]: import("@markdoc/markdoc").Schema & {
|
|
77
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
78
|
+
resolver?: string;
|
|
79
|
+
}>;
|
|
80
|
+
};
|
|
81
|
+
[img.tagName]: import("@markdoc/markdoc").Schema & {
|
|
82
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
83
|
+
resolver?: string;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
[codeWalkthrough.tagName]: import("@markdoc/markdoc").Schema & {
|
|
87
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
88
|
+
resolver?: string;
|
|
89
|
+
}>;
|
|
90
|
+
};
|
|
91
|
+
[codeStep.tagName]: import("@markdoc/markdoc").Schema & {
|
|
92
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
93
|
+
resolver?: string;
|
|
94
|
+
}>;
|
|
95
|
+
};
|
|
96
|
+
[toggle.tagName]: import("@markdoc/markdoc").Schema & {
|
|
97
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
98
|
+
resolver?: string;
|
|
99
|
+
}>;
|
|
100
|
+
};
|
|
101
|
+
[input.tagName]: import("@markdoc/markdoc").Schema & {
|
|
102
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
103
|
+
resolver?: string;
|
|
104
|
+
}>;
|
|
105
|
+
};
|
|
106
|
+
[codeGroup.tagName]: import("@markdoc/markdoc").Schema & {
|
|
107
|
+
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
108
|
+
resolver?: string;
|
|
109
|
+
}>;
|
|
110
|
+
};
|
|
111
|
+
[icon.tagName]: import("@markdoc/markdoc").Schema & {
|
|
9
112
|
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute & {
|
|
10
113
|
resolver?: string;
|
|
11
114
|
}>;
|
package/lib/markdoc/default.js
CHANGED
|
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
18
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
20
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
39
|
exports.tags = exports.components = void 0;
|
|
30
40
|
/* Attributes */
|
package/lib/markdoc/tags/card.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.59.0-next.
|
|
3
|
+
"version": "0.59.0-next.10",
|
|
4
4
|
"description": "Shared UI components lib",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theme",
|
|
7
7
|
"redocly"
|
|
8
8
|
],
|
|
9
9
|
"author": "team@redocly.com",
|
|
10
|
-
"license": "
|
|
10
|
+
"license": "MIT",
|
|
11
11
|
"main": "lib/index.js",
|
|
12
12
|
"types": "lib/index.d.ts",
|
|
13
13
|
"exports": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@types/highlight-words-core": "1.2.3",
|
|
45
45
|
"@types/lodash.debounce": "4.0.9",
|
|
46
46
|
"@types/lodash.throttle": "4.1.9",
|
|
47
|
-
"@types/node": "22.
|
|
47
|
+
"@types/node": "22.18.13",
|
|
48
48
|
"@types/nprogress": "0.2.3",
|
|
49
49
|
"@types/react": "^19.1.4",
|
|
50
50
|
"@types/react-dom": "^19.1.4",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"styled-system": "5.1.5",
|
|
64
64
|
"ts-node": "10.9.2",
|
|
65
65
|
"ts-node-dev": "2.0.0",
|
|
66
|
-
"tsc-alias": "1.8.
|
|
66
|
+
"tsc-alias": "1.8.16",
|
|
67
67
|
"tsconfig-paths": "4.2.0",
|
|
68
68
|
"tsconfig-paths-webpack-plugin": "3.5.2",
|
|
69
|
-
"typescript": "5.
|
|
69
|
+
"typescript": "5.9.3",
|
|
70
70
|
"vitest": "3.2.4",
|
|
71
71
|
"vitest-when": "0.6.2",
|
|
72
72
|
"webpack": "5.94.0"
|
|
@@ -84,11 +84,11 @@
|
|
|
84
84
|
"lodash.debounce": "^4.0.8",
|
|
85
85
|
"lodash.throttle": "4.1.1",
|
|
86
86
|
"nprogress": "0.2.0",
|
|
87
|
-
"openapi-sampler": "1.6.
|
|
87
|
+
"openapi-sampler": "1.6.2",
|
|
88
88
|
"react-calendar": "5.1.0",
|
|
89
89
|
"react-date-picker": "11.0.0",
|
|
90
|
-
"@redocly/config": "0.
|
|
91
|
-
"@redocly/realm-asyncapi-sdk": "0.5.0-next.
|
|
90
|
+
"@redocly/config": "0.36.2",
|
|
91
|
+
"@redocly/realm-asyncapi-sdk": "0.5.0-next.3"
|
|
92
92
|
},
|
|
93
93
|
"scripts": {
|
|
94
94
|
"watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { BaseSyntheticEvent, PropsWithChildren, ReactNode, JSX } from 'react';
|
|
5
|
+
import type { AccordionHeaderProps } from '@redocly/theme/components/Accordion/AccordionHeader';
|
|
6
|
+
|
|
7
|
+
import { AccordionBody } from '@redocly/theme/components/Accordion/AccordionBody';
|
|
8
|
+
import { AccordionHeader } from '@redocly/theme/components/Accordion/AccordionHeader';
|
|
9
|
+
import { AccordionTitle } from '@redocly/theme/components/Accordion/AccordionTitle';
|
|
10
|
+
import { ChevronDownIcon } from '@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon';
|
|
11
|
+
import { ChevronRightIcon } from '@redocly/theme/icons/ChevronRightIcon/ChevronRightIcon';
|
|
12
|
+
|
|
13
|
+
export type AccordionProps = {
|
|
14
|
+
expanded?: boolean;
|
|
15
|
+
isExpandable?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
renderChildrenHidden?: boolean;
|
|
18
|
+
header?: ReactNode | ((props: AccordionHeaderProps) => ReactNode);
|
|
19
|
+
onToggle?: (expanded: boolean) => void;
|
|
20
|
+
dataTestId?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function Accordion({
|
|
24
|
+
expanded = true,
|
|
25
|
+
isExpandable = true,
|
|
26
|
+
renderChildrenHidden = false,
|
|
27
|
+
header,
|
|
28
|
+
className,
|
|
29
|
+
children,
|
|
30
|
+
onToggle,
|
|
31
|
+
dataTestId,
|
|
32
|
+
}: PropsWithChildren<AccordionProps>): JSX.Element {
|
|
33
|
+
const [isExpanded, setExpanded] = useState(expanded);
|
|
34
|
+
const [animate, setAnimate] = useState(false);
|
|
35
|
+
|
|
36
|
+
const toggle = ({ target }: BaseSyntheticEvent): void => {
|
|
37
|
+
if (target instanceof HTMLAnchorElement || !isExpandable) return;
|
|
38
|
+
setAnimate(true);
|
|
39
|
+
setExpanded(!isExpanded);
|
|
40
|
+
onToggle?.(!isExpanded);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
useEffect(() => setExpanded(expanded), [expanded]);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<AccordionWrapper
|
|
47
|
+
className={className}
|
|
48
|
+
data-testid={dataTestId}
|
|
49
|
+
data-component-name="Accordion/Accordion"
|
|
50
|
+
>
|
|
51
|
+
{header &&
|
|
52
|
+
(typeof header === 'function' ? (
|
|
53
|
+
header({ expanded: isExpanded })
|
|
54
|
+
) : (
|
|
55
|
+
<AccordionHeader
|
|
56
|
+
data-testid="accordion-header"
|
|
57
|
+
onClick={toggle}
|
|
58
|
+
expanded={isExpanded}
|
|
59
|
+
isExpandable={isExpandable}
|
|
60
|
+
>
|
|
61
|
+
<HeaderContent>
|
|
62
|
+
<AccordionTitle data-testid="title">{header}</AccordionTitle>
|
|
63
|
+
{isExpandable &&
|
|
64
|
+
(isExpanded ? (
|
|
65
|
+
<ChevronDownIcon color="--accordion-chevron-icon-color" />
|
|
66
|
+
) : (
|
|
67
|
+
<ChevronRightIcon color="--accordion-chevron-icon-color" />
|
|
68
|
+
))}
|
|
69
|
+
</HeaderContent>
|
|
70
|
+
</AccordionHeader>
|
|
71
|
+
))}
|
|
72
|
+
|
|
73
|
+
{(isExpanded || renderChildrenHidden) && (
|
|
74
|
+
<AccordionBody data-testid="accordion-body" hidden={!isExpanded} animate={animate}>
|
|
75
|
+
{children}
|
|
76
|
+
</AccordionBody>
|
|
77
|
+
)}
|
|
78
|
+
</AccordionWrapper>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const AccordionWrapper = styled.div`
|
|
83
|
+
background-color: transparent;
|
|
84
|
+
font-family: var(--accordion-font-family);
|
|
85
|
+
font-size: var(--accordion-font-size);
|
|
86
|
+
font-weight: var(--accordion-font-weight);
|
|
87
|
+
border-radius: var(--accordion-border-radius);
|
|
88
|
+
border: var(--accordion-border);
|
|
89
|
+
|
|
90
|
+
&:not(:last-child) {
|
|
91
|
+
margin-bottom: var(--accordion-gap);
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
const HeaderContent = styled.div`
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
width: 100%;
|
|
99
|
+
gap: var(--spacing-xs);
|
|
100
|
+
`;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled, { keyframes, css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { JSX, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
type AccordionBodyWrapperProps = {
|
|
7
|
+
$animate?: boolean;
|
|
8
|
+
$hidden?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AccordionBodyProps = {
|
|
12
|
+
animate?: boolean;
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function AccordionBody({
|
|
19
|
+
animate,
|
|
20
|
+
hidden,
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
}: AccordionBodyProps): JSX.Element {
|
|
24
|
+
return (
|
|
25
|
+
<AccordionBodyWrapper
|
|
26
|
+
className={className}
|
|
27
|
+
$animate={animate}
|
|
28
|
+
$hidden={hidden}
|
|
29
|
+
data-component-name="Accordion/AccordionBody"
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</AccordionBodyWrapper>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const showAccordion = keyframes`
|
|
37
|
+
0% {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
transform: translateY(-5px);
|
|
40
|
+
}
|
|
41
|
+
100% {
|
|
42
|
+
opacity: 1;
|
|
43
|
+
transform: translateY(0);
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const showAccordionAnimation = css`
|
|
48
|
+
animation: ${showAccordion} 0.15s ease-out;
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const AccordionBodyWrapper = styled.div<AccordionBodyWrapperProps>`
|
|
52
|
+
${({ $animate }) => $animate && showAccordionAnimation};
|
|
53
|
+
${({ $hidden }) => $hidden && 'visibility: hidden'};
|
|
54
|
+
|
|
55
|
+
background-color: var(--accordion-body-bg-color);
|
|
56
|
+
|
|
57
|
+
font-family: var(--accordion-body-font-family);
|
|
58
|
+
font-size: var(--accordion-body-font-size);
|
|
59
|
+
font-weight: var(--accordion-body-font-weight);
|
|
60
|
+
border: var(--accordion-body-border);
|
|
61
|
+
padding: var(--accordion-body-padding);
|
|
62
|
+
color: var(--accordion-body-text-color);
|
|
63
|
+
|
|
64
|
+
border-radius: var(--accordion-border-radius);
|
|
65
|
+
`;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { BaseSyntheticEvent, JSX, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
export type AccordionHeaderProps = {
|
|
7
|
+
isExpandable?: boolean;
|
|
8
|
+
expanded?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
onClick?: (e: BaseSyntheticEvent) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type AccordionHeaderWrapperProps = {
|
|
16
|
+
$isExpandable?: boolean;
|
|
17
|
+
$expanded?: boolean;
|
|
18
|
+
$disabled?: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function AccordionHeader({
|
|
22
|
+
isExpandable,
|
|
23
|
+
expanded,
|
|
24
|
+
disabled,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
onClick,
|
|
28
|
+
}: AccordionHeaderProps): JSX.Element {
|
|
29
|
+
return (
|
|
30
|
+
<AccordionHeaderWrapper
|
|
31
|
+
className={className}
|
|
32
|
+
$isExpandable={isExpandable}
|
|
33
|
+
$expanded={expanded}
|
|
34
|
+
$disabled={disabled}
|
|
35
|
+
onClick={onClick}
|
|
36
|
+
data-component-name="Accordion/AccordionHeader"
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</AccordionHeaderWrapper>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const AccordionHeaderWrapper = styled.div<AccordionHeaderWrapperProps>`
|
|
44
|
+
display: flex;
|
|
45
|
+
gap: var(--spacing-xs);
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: space-between;
|
|
48
|
+
min-height: 32px;
|
|
49
|
+
color: var(--accordion-header-text-color);
|
|
50
|
+
|
|
51
|
+
cursor: ${({ $isExpandable = true }) => ($isExpandable ? 'pointer' : 'default')};
|
|
52
|
+
|
|
53
|
+
line-height: var(--accordion-header-line-height);
|
|
54
|
+
font-size: var(--accordion-header-font-size);
|
|
55
|
+
font-family: var(--accordion-header-font-family);
|
|
56
|
+
font-weight: var(--accordion-header-font-weight);
|
|
57
|
+
padding: var(--accordion-header-padding);
|
|
58
|
+
border: var(--accordion-header-border);
|
|
59
|
+
background-color: var(--accordion-header-bg-color);
|
|
60
|
+
border-radius: var(--accordion-border-radius);
|
|
61
|
+
|
|
62
|
+
pointer-events: ${({ $disabled }) => ($disabled ? 'none' : 'auto')};
|
|
63
|
+
|
|
64
|
+
&:hover {
|
|
65
|
+
color: ${({ $isExpandable = true }) =>
|
|
66
|
+
$isExpandable ? 'var(--text-color-primary)' : 'var(--accordion-header-text-color)'};
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { JSX, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
export type AccordionTitleProps = {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function AccordionTitle({ children, className }: AccordionTitleProps): JSX.Element {
|
|
12
|
+
return (
|
|
13
|
+
<AccordionTitleWrapper className={className} data-component-name="Accordion/AccordionTitle">
|
|
14
|
+
{children}
|
|
15
|
+
</AccordionTitleWrapper>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const AccordionTitleWrapper = styled.span`
|
|
20
|
+
font-weight: var(--accordion-header-font-weight);
|
|
21
|
+
line-height: var(--line-height-base);
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
text-overflow: ellipsis;
|
|
24
|
+
color: var(--accordion-header-text-color);
|
|
25
|
+
flex: 1;
|
|
26
|
+
`;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const accordion = css`
|
|
4
|
+
/**
|
|
5
|
+
* @tokens Accordion spacing
|
|
6
|
+
* @presenter Spacing
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
--accordion-gap: var(--spacing-base);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @tokens Accordion common
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
--accordion-border-radius: var(--border-radius); // @presenter BorderRadius
|
|
16
|
+
--accordion-border: none; // @presenter Border
|
|
17
|
+
|
|
18
|
+
--accordion-line-height: var(--line-height-base); // @presenter LineHeight
|
|
19
|
+
--accordion-font-size: var(--font-size-base); // @presenter FontSize
|
|
20
|
+
--accordion-font-family: var(--font-family-base); // @presenter FontFamily
|
|
21
|
+
--accordion-font-weight: var(--font-weight-regular); // @presenter FontWeight
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @tokens Accordion header common
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
--accordion-header-font-family: var(--font-family-base); // @presenter FontFamily
|
|
28
|
+
--accordion-header-font-size: var(--font-size-base); // @presenter FontSize
|
|
29
|
+
--accordion-header-font-weight: var(--font-weight-medium, 500); // @presenter FontWeight
|
|
30
|
+
--accordion-header-text-color: var(--text-color-primary);
|
|
31
|
+
--accordion-header-padding: var(--spacing-sm) var(--spacing-base);
|
|
32
|
+
--accordion-header-line-height: var(--line-height-base); // @presenter LineHeight
|
|
33
|
+
--accordion-header-bg-color: transparent; // @presenter Color
|
|
34
|
+
--accordion-header-border: none; // @presenter Border
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @tokens Accordion body common
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
--accordion-body-font-family: var(--font-family-base); // @presenter FontFamily
|
|
41
|
+
--accordion-body-font-size: var(--font-size-base); // @presenter FontSize
|
|
42
|
+
--accordion-body-font-weight: var(--font-weight-regular); // @presenter FontWeight
|
|
43
|
+
--accordion-body-text-color: var(--text-color-secondary);
|
|
44
|
+
--accordion-body-padding: 0 var(--spacing-xs) var(--spacing-sm);
|
|
45
|
+
--accordion-body-bg-color: transparent; // @presenter Color
|
|
46
|
+
--accordion-body-border: none; // @presenter Border
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @tokens Accordion chevron icon
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
--accordion-chevron-icon-color: var(--text-color-secondary); // @presenter Color
|
|
53
|
+
--accordion-chevron-icon-size: 16px;
|
|
54
|
+
|
|
55
|
+
// @tokens End
|
|
56
|
+
`;
|