@redocly/theme 0.47.0 → 0.48.0
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/Buttons/CopyButton.d.ts +8 -3
- package/lib/components/Buttons/CopyButton.js +4 -3
- package/lib/components/Feedback/Mood.d.ts +2 -2
- package/lib/components/Feedback/Mood.js +6 -6
- package/lib/components/Feedback/Rating.d.ts +2 -2
- package/lib/components/Feedback/Rating.js +6 -6
- package/lib/components/Feedback/Scale.d.ts +2 -2
- package/lib/components/Feedback/Scale.js +6 -6
- package/lib/components/Feedback/Sentiment.d.ts +2 -2
- package/lib/components/Feedback/Sentiment.js +6 -6
- package/lib/components/Search/SearchDialog.js +8 -8
- package/lib/components/Search/SearchFilter.d.ts +3 -2
- package/lib/components/Search/SearchFilter.js +2 -2
- package/lib/components/Search/SearchFilterField.d.ts +3 -2
- package/lib/components/Search/SearchFilterField.js +2 -2
- package/lib/components/Search/SearchGroups.d.ts +5 -4
- package/lib/components/Search/SearchGroups.js +3 -3
- package/lib/components/StatusCode/StatusCode.js +11 -14
- package/lib/core/constants/code-walkthrough.d.ts +1 -0
- package/lib/core/constants/code-walkthrough.js +5 -0
- package/lib/core/constants/index.d.ts +1 -0
- package/lib/core/constants/index.js +1 -0
- package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.d.ts +2 -0
- package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.js +18 -0
- package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughStepsContext.d.ts +2 -0
- package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughStepsContext.js +11 -0
- package/lib/core/contexts/index.d.ts +2 -0
- package/lib/core/contexts/index.js +2 -0
- package/lib/core/hooks/__mocks__/search/use-search-filter.d.ts +1 -1
- package/lib/core/hooks/__mocks__/search/use-search-filter.js +1 -1
- package/lib/core/hooks/code-walkthrough/__mocks__/MockIntersectionObserver.d.ts +10 -0
- package/lib/core/hooks/code-walkthrough/__mocks__/MockIntersectionObserver.js +55 -0
- package/lib/core/hooks/code-walkthrough/use-code-panel.d.ts +6 -0
- package/lib/core/hooks/code-walkthrough/use-code-panel.js +93 -0
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.d.ts +22 -0
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.js +183 -0
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.d.ts +16 -0
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.js +117 -0
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough.d.ts +14 -0
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough.js +22 -0
- package/lib/core/hooks/index.d.ts +4 -0
- package/lib/core/hooks/index.js +4 -0
- package/lib/core/hooks/search/use-search-filter.d.ts +2 -2
- package/lib/core/hooks/search/use-search-filter.js +5 -5
- package/lib/core/styles/global.js +2 -0
- package/lib/core/templates/Markdown.d.ts +8 -2
- package/lib/core/templates/Markdown.js +5 -2
- package/lib/core/types/hooks.d.ts +3 -0
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/types/search.d.ts +1 -2
- package/lib/core/utils/download-code-walkthrough.d.ts +4 -0
- package/lib/core/utils/download-code-walkthrough.js +32 -0
- package/lib/core/utils/get-code-walkthrough-file-text.d.ts +4 -0
- package/lib/core/utils/get-code-walkthrough-file-text.js +22 -0
- package/lib/core/utils/get-file-icon.d.ts +2 -0
- package/lib/core/utils/get-file-icon.js +31 -0
- package/lib/core/utils/index.d.ts +5 -0
- package/lib/core/utils/index.js +5 -0
- package/lib/core/utils/js-utils.d.ts +30 -0
- package/lib/core/utils/js-utils.js +41 -0
- package/lib/core/utils/match-code-walkthrough-conditions.d.ts +4 -0
- package/lib/core/utils/match-code-walkthrough-conditions.js +23 -0
- package/lib/core/utils/replace-inputs-with-value.d.ts +3 -0
- package/lib/core/utils/replace-inputs-with-value.js +16 -0
- package/lib/icons/DocumentCssIcon/DocumentCssIcon.d.ts +9 -0
- package/lib/icons/DocumentCssIcon/DocumentCssIcon.js +23 -0
- package/lib/icons/DocumentCssIcon/index.d.ts +1 -0
- package/lib/icons/DocumentCssIcon/index.js +6 -0
- package/lib/icons/DocumentGraphqlIcon/DocumentGraphqlIcon.d.ts +9 -0
- package/lib/icons/DocumentGraphqlIcon/DocumentGraphqlIcon.js +31 -0
- package/lib/icons/DocumentGraphqlIcon/index.d.ts +1 -0
- package/lib/icons/DocumentGraphqlIcon/index.js +6 -0
- package/lib/icons/DocumentHtmlIcon/DocumentHtmlIcon.d.ts +9 -0
- package/lib/icons/DocumentHtmlIcon/DocumentHtmlIcon.js +23 -0
- package/lib/icons/DocumentHtmlIcon/index.d.ts +1 -0
- package/lib/icons/DocumentHtmlIcon/index.js +6 -0
- package/lib/icons/DocumentJsIcon/DocumentJsIcon.d.ts +9 -0
- package/lib/icons/DocumentJsIcon/DocumentJsIcon.js +23 -0
- package/lib/icons/DocumentJsIcon/index.d.ts +1 -0
- package/lib/icons/DocumentJsIcon/index.js +6 -0
- package/lib/icons/DocumentJsonIcon/DocumentJsonIcon.d.ts +9 -0
- package/lib/icons/DocumentJsonIcon/DocumentJsonIcon.js +23 -0
- package/lib/icons/DocumentJsonIcon/index.d.ts +1 -0
- package/lib/icons/DocumentJsonIcon/index.js +6 -0
- package/lib/icons/DocumentMarkdownIcon/DocumentMarkdownIcon.d.ts +9 -0
- package/lib/icons/DocumentMarkdownIcon/DocumentMarkdownIcon.js +23 -0
- package/lib/icons/DocumentMarkdownIcon/index.d.ts +1 -0
- package/lib/icons/DocumentMarkdownIcon/index.js +6 -0
- package/lib/icons/DocumentReactIcon/DocumentReactIcon.d.ts +9 -0
- package/lib/icons/DocumentReactIcon/DocumentReactIcon.js +23 -0
- package/lib/icons/DocumentReactIcon/index.d.ts +1 -0
- package/lib/icons/DocumentReactIcon/index.js +6 -0
- package/lib/icons/DocumentTsIcon/DocumentTsIcon.d.ts +9 -0
- package/lib/icons/DocumentTsIcon/DocumentTsIcon.js +23 -0
- package/lib/icons/DocumentTsIcon/index.d.ts +1 -0
- package/lib/icons/DocumentTsIcon/index.js +6 -0
- package/lib/icons/DocumentYamlIcon/DocumentYamlIcon.d.ts +9 -0
- package/lib/icons/DocumentYamlIcon/DocumentYamlIcon.js +23 -0
- package/lib/icons/DocumentYamlIcon/index.d.ts +1 -0
- package/lib/icons/DocumentYamlIcon/index.js +6 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/layouts/CodeWalkthroughLayout.d.ts +5 -0
- package/lib/layouts/CodeWalkthroughLayout.js +72 -0
- package/lib/markdoc/attributes/code-walkthrough-filesets.d.ts +5 -0
- package/lib/markdoc/attributes/code-walkthrough-filesets.js +16 -0
- package/lib/markdoc/attributes/code-walkthrough-filters.d.ts +5 -0
- package/lib/markdoc/attributes/code-walkthrough-filters.js +16 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeContainer.d.ts +5 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeContainer.js +81 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeFilters.d.ts +12 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeFilters.js +58 -0
- package/lib/markdoc/components/CodeWalkthrough/CodePanel.d.ts +8 -0
- package/lib/markdoc/components/CodeWalkthrough/CodePanel.js +64 -0
- package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.d.ts +8 -0
- package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.js +155 -0
- package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.d.ts +2 -0
- package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.js +73 -0
- package/lib/markdoc/components/CodeWalkthrough/CodePanelToolbar.d.ts +5 -0
- package/lib/markdoc/components/CodeWalkthrough/CodePanelToolbar.js +47 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeStep.d.ts +12 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeStep.js +128 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeToggle.d.ts +9 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeToggle.js +69 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.d.ts +4 -0
- package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.js +121 -0
- package/lib/markdoc/components/CodeWalkthrough/Input.d.ts +8 -0
- package/lib/markdoc/components/CodeWalkthrough/Input.js +99 -0
- package/lib/markdoc/components/CodeWalkthrough/variables.d.ts +1 -0
- package/lib/markdoc/components/CodeWalkthrough/variables.js +19 -0
- package/lib/markdoc/components/default.d.ts +5 -0
- package/lib/markdoc/components/default.js +5 -0
- package/lib/markdoc/default.js +8 -0
- package/lib/markdoc/tags/code-step.d.ts +2 -0
- package/lib/markdoc/tags/code-step.js +28 -0
- package/lib/markdoc/tags/code-toggle.d.ts +2 -0
- package/lib/markdoc/tags/code-toggle.js +40 -0
- package/lib/markdoc/tags/code-walkthrough.d.ts +8 -0
- package/lib/markdoc/tags/code-walkthrough.js +242 -0
- package/lib/markdoc/tags/input.d.ts +2 -0
- package/lib/markdoc/tags/input.js +37 -0
- package/lib/plugin.d.ts +2 -1
- package/lib/plugin.js +2 -4
- package/package.json +10 -3
- package/src/components/Buttons/CopyButton.tsx +24 -6
- package/src/components/Feedback/Mood.tsx +9 -10
- package/src/components/Feedback/Rating.tsx +9 -10
- package/src/components/Feedback/Scale.tsx +9 -10
- package/src/components/Feedback/Sentiment.tsx +9 -10
- package/src/components/Search/SearchDialog.tsx +11 -6
- package/src/components/Search/SearchFilter.tsx +6 -3
- package/src/components/Search/SearchFilterField.tsx +4 -2
- package/src/components/Search/SearchGroups.tsx +13 -8
- package/src/components/StatusCode/StatusCode.ts +11 -10
- package/src/core/constants/code-walkthrough.ts +1 -0
- package/src/core/constants/index.ts +1 -0
- package/src/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.tsx +21 -0
- package/src/core/contexts/CodeWalkthrough/CodeWalkthroughStepsContext.tsx +10 -0
- package/src/core/contexts/index.ts +2 -0
- package/src/core/hooks/__mocks__/search/use-search-filter.ts +1 -1
- package/src/core/hooks/code-walkthrough/__mocks__/MockIntersectionObserver.ts +22 -0
- package/src/core/hooks/code-walkthrough/use-code-panel.ts +164 -0
- package/src/core/hooks/code-walkthrough/use-code-walkthrough-controls.ts +302 -0
- package/src/core/hooks/code-walkthrough/use-code-walkthrough-steps.ts +165 -0
- package/src/core/hooks/code-walkthrough/use-code-walkthrough.ts +51 -0
- package/src/core/hooks/index.ts +4 -0
- package/src/core/hooks/search/use-search-filter.ts +9 -5
- package/src/core/styles/global.ts +2 -0
- package/src/core/templates/Markdown.tsx +16 -5
- package/src/core/types/hooks.ts +3 -0
- package/src/core/types/l10n.ts +5 -3
- package/src/core/types/search.ts +1 -2
- package/src/core/utils/download-code-walkthrough.ts +25 -0
- package/src/core/utils/get-code-walkthrough-file-text.ts +32 -0
- package/src/core/utils/get-file-icon.ts +35 -0
- package/src/core/utils/index.ts +5 -0
- package/src/core/utils/js-utils.ts +48 -0
- package/src/core/utils/match-code-walkthrough-conditions.ts +29 -0
- package/src/core/utils/replace-inputs-with-value.ts +11 -0
- package/src/icons/DocumentCssIcon/DocumentCssIcon.tsx +36 -0
- package/src/icons/DocumentCssIcon/index.ts +1 -0
- package/src/icons/DocumentGraphqlIcon/DocumentGraphqlIcon.tsx +64 -0
- package/src/icons/DocumentGraphqlIcon/index.ts +1 -0
- package/src/icons/DocumentHtmlIcon/DocumentHtmlIcon.tsx +36 -0
- package/src/icons/DocumentHtmlIcon/index.ts +1 -0
- package/src/icons/DocumentJsIcon/DocumentJsIcon.tsx +36 -0
- package/src/icons/DocumentJsIcon/index.ts +1 -0
- package/src/icons/DocumentJsonIcon/DocumentJsonIcon.tsx +36 -0
- package/src/icons/DocumentJsonIcon/index.ts +1 -0
- package/src/icons/DocumentMarkdownIcon/DocumentMarkdownIcon.tsx +36 -0
- package/src/icons/DocumentMarkdownIcon/index.ts +1 -0
- package/src/icons/DocumentReactIcon/DocumentReactIcon.tsx +36 -0
- package/src/icons/DocumentReactIcon/index.ts +1 -0
- package/src/icons/DocumentTsIcon/DocumentTsIcon.tsx +38 -0
- package/src/icons/DocumentTsIcon/index.ts +1 -0
- package/src/icons/DocumentYamlIcon/DocumentYamlIcon.tsx +36 -0
- package/src/icons/DocumentYamlIcon/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/layouts/CodeWalkthroughLayout.tsx +78 -0
- package/src/markdoc/attributes/code-walkthrough-filesets.ts +9 -0
- package/src/markdoc/attributes/code-walkthrough-filters.ts +9 -0
- package/src/markdoc/components/CodeWalkthrough/CodeContainer.tsx +76 -0
- package/src/markdoc/components/CodeWalkthrough/CodeFilters.tsx +87 -0
- package/src/markdoc/components/CodeWalkthrough/CodePanel.tsx +68 -0
- package/src/markdoc/components/CodeWalkthrough/CodePanelHeader.tsx +192 -0
- package/src/markdoc/components/CodeWalkthrough/CodePanelPreview.tsx +53 -0
- package/src/markdoc/components/CodeWalkthrough/CodePanelToolbar.tsx +31 -0
- package/src/markdoc/components/CodeWalkthrough/CodeStep.tsx +149 -0
- package/src/markdoc/components/CodeWalkthrough/CodeToggle.tsx +63 -0
- package/src/markdoc/components/CodeWalkthrough/CodeWalkthrough.tsx +111 -0
- package/src/markdoc/components/CodeWalkthrough/Input.tsx +101 -0
- package/src/markdoc/components/CodeWalkthrough/variables.ts +16 -0
- package/src/markdoc/components/default.ts +5 -0
- package/src/markdoc/default.ts +8 -0
- package/src/markdoc/tags/code-step.ts +27 -0
- package/src/markdoc/tags/code-toggle.ts +37 -0
- package/src/markdoc/tags/code-walkthrough.ts +315 -0
- package/src/markdoc/tags/input.ts +35 -0
- package/src/plugin.js +2 -2
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.CodePanelHeader = CodePanelHeader;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
29
|
+
const hooks_1 = require("../../../core/hooks");
|
|
30
|
+
const utils_1 = require("../../../core/utils");
|
|
31
|
+
const OverflowMenuVerticalIcon_1 = require("../../../icons/OverflowMenuVerticalIcon/OverflowMenuVerticalIcon");
|
|
32
|
+
const Dropdown_1 = require("../../../components/Dropdown/Dropdown");
|
|
33
|
+
const DropdownMenu_1 = require("../../../components/Dropdown/DropdownMenu");
|
|
34
|
+
const DropdownMenuItem_1 = require("../../../components/Dropdown/DropdownMenuItem");
|
|
35
|
+
const DownloadIcon_1 = require("../../../icons/DownloadIcon/DownloadIcon");
|
|
36
|
+
const Button_1 = require("../../../components/Button/Button");
|
|
37
|
+
function CodePanelHeader({ files, handleTabSwitch, activeTabName, onDownloadCode, }) {
|
|
38
|
+
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
39
|
+
const { translate } = useTranslate();
|
|
40
|
+
const tabRefs = (0, react_1.useRef)([]);
|
|
41
|
+
const tabsWrapperRef = (0, react_1.useRef)(null);
|
|
42
|
+
const [hiddenFiles, setHiddenFiles] = (0, react_1.useState)([]);
|
|
43
|
+
(0, react_1.useEffect)(() => {
|
|
44
|
+
const activeTab = tabRefs.current.find((tab) => (tab === null || tab === void 0 ? void 0 : tab.dataset.name) === activeTabName);
|
|
45
|
+
if (activeTab) {
|
|
46
|
+
activeTab.scrollIntoView({ block: 'nearest', inline: 'center' });
|
|
47
|
+
}
|
|
48
|
+
}, [activeTabName]);
|
|
49
|
+
(0, react_1.useEffect)(() => {
|
|
50
|
+
const calculateHiddenFiles = () => {
|
|
51
|
+
if (!tabsWrapperRef.current)
|
|
52
|
+
return;
|
|
53
|
+
const { left: wrapperLeft, right: wrapperRight } = tabsWrapperRef.current.getBoundingClientRect();
|
|
54
|
+
const hidden = files.filter((_, i) => {
|
|
55
|
+
const tab = tabRefs.current[i];
|
|
56
|
+
if (!tab)
|
|
57
|
+
return false;
|
|
58
|
+
const { left: tabLeft, right: tabRight } = tab.getBoundingClientRect();
|
|
59
|
+
return tabLeft < wrapperLeft || tabRight > wrapperRight;
|
|
60
|
+
});
|
|
61
|
+
setHiddenFiles(hidden);
|
|
62
|
+
};
|
|
63
|
+
calculateHiddenFiles();
|
|
64
|
+
window.addEventListener('resize', calculateHiddenFiles);
|
|
65
|
+
return () => window.removeEventListener('resize', calculateHiddenFiles);
|
|
66
|
+
}, [files]);
|
|
67
|
+
const getFileTypeIcon = (0, react_1.useCallback)((basename) => {
|
|
68
|
+
var _a;
|
|
69
|
+
const extension = ((_a = basename.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
|
|
70
|
+
return (0, utils_1.getFileIconByExt)(extension);
|
|
71
|
+
}, []);
|
|
72
|
+
return (react_1.default.createElement(CodePanelHeaderWrapper, { "data-component-name": "Markdoc/CodeWalkthrough/CodePanelHeader" },
|
|
73
|
+
react_1.default.createElement(TabsWrapper, { ref: tabsWrapperRef },
|
|
74
|
+
react_1.default.createElement(Tabs, null, files.map(({ path, basename }, i) => {
|
|
75
|
+
const FileIcon = getFileTypeIcon(basename);
|
|
76
|
+
return (react_1.default.createElement(Tab, { ref: (el) => (tabRefs.current[i] = el), "data-name": path, active: path === activeTabName, key: i, onClick: () => handleTabSwitch(path) },
|
|
77
|
+
react_1.default.createElement(FileIcon, null),
|
|
78
|
+
basename));
|
|
79
|
+
})),
|
|
80
|
+
react_1.default.createElement(Gradient, null)),
|
|
81
|
+
react_1.default.createElement(ActionBar, null,
|
|
82
|
+
hiddenFiles.length ? (react_1.default.createElement(Dropdown_1.Dropdown, { trigger: react_1.default.createElement(StyledOverflowMenuVerticalIcon, { size: "14px" }), alignment: "end" },
|
|
83
|
+
react_1.default.createElement(StyledDropdownMenu, null, hiddenFiles.map(({ path, basename }, i) => {
|
|
84
|
+
const FileIcon = getFileTypeIcon(basename);
|
|
85
|
+
return (react_1.default.createElement(DropdownMenuItem_1.DropdownMenuItem, { active: path === activeTabName, key: i, onAction: () => handleTabSwitch(path), prefix: react_1.default.createElement(FileIcon, null), content: basename }));
|
|
86
|
+
})))) : null,
|
|
87
|
+
react_1.default.createElement(Button_1.Button, { variant: "text", icon: react_1.default.createElement(DownloadIcon_1.DownloadIcon, null), onClick: onDownloadCode, size: "small" }, translate('codeWalkthrough.download', 'Download')))));
|
|
88
|
+
}
|
|
89
|
+
const CodePanelHeaderWrapper = styled_components_1.default.div `
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
justify-content: space-between;
|
|
93
|
+
|
|
94
|
+
padding: var(--spacing-xs) var(--spacing-xs) var(--spacing-xs) var(--spacing-sm);
|
|
95
|
+
max-width: 100%;
|
|
96
|
+
`;
|
|
97
|
+
const TabsWrapper = styled_components_1.default.div `
|
|
98
|
+
display: flex;
|
|
99
|
+
position: relative;
|
|
100
|
+
min-width: 0;
|
|
101
|
+
`;
|
|
102
|
+
const Gradient = styled_components_1.default.div `
|
|
103
|
+
position: absolute;
|
|
104
|
+
right: 0;
|
|
105
|
+
width: var(--spacing-base);
|
|
106
|
+
height: var(--code-panel-header-height);
|
|
107
|
+
background: var(--bg-raised-gradient);
|
|
108
|
+
`;
|
|
109
|
+
const Tabs = styled_components_1.default.div `
|
|
110
|
+
display: flex;
|
|
111
|
+
overflow-x: auto;
|
|
112
|
+
padding-right: var(--spacing-base);
|
|
113
|
+
|
|
114
|
+
&::-webkit-scrollbar {
|
|
115
|
+
display: none;
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
const ActionBar = styled_components_1.default.div `
|
|
119
|
+
display: flex;
|
|
120
|
+
`;
|
|
121
|
+
const Tab = styled_components_1.default.button `
|
|
122
|
+
display: inline-flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
padding: 0 var(--spacing-sm);
|
|
125
|
+
background-color: transparent;
|
|
126
|
+
height: var(--code-panel-header-height);
|
|
127
|
+
border-radius: var(--border-radius);
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
gap: var(--spacing-xs);
|
|
130
|
+
color: var(--text-color-secondary);
|
|
131
|
+
white-space: nowrap;
|
|
132
|
+
|
|
133
|
+
${({ active }) => active
|
|
134
|
+
? (0, styled_components_1.css) `
|
|
135
|
+
color: var(--text-color-primary);
|
|
136
|
+
background-color: var(--tab-bg-color-filled);
|
|
137
|
+
`
|
|
138
|
+
: (0, styled_components_1.css) `
|
|
139
|
+
&:hover {
|
|
140
|
+
color: var(--text-color-primary);
|
|
141
|
+
}
|
|
142
|
+
`}
|
|
143
|
+
`;
|
|
144
|
+
// code-walk-todo: figure it our why we could not do it differently
|
|
145
|
+
const StyledDropdownMenu = (0, styled_components_1.default)(DropdownMenu_1.DropdownMenu) `
|
|
146
|
+
--md-list-left-padding: var(--dropdown-menu-padding);
|
|
147
|
+
`;
|
|
148
|
+
const StyledOverflowMenuVerticalIcon = (0, styled_components_1.default)(OverflowMenuVerticalIcon_1.OverflowMenuVerticalIcon) `
|
|
149
|
+
&& {
|
|
150
|
+
outline: none;
|
|
151
|
+
box-sizing: content-box;
|
|
152
|
+
padding: 5px;
|
|
153
|
+
}
|
|
154
|
+
`;
|
|
155
|
+
//# sourceMappingURL=CodePanelHeader.js.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CodePanelPreview = CodePanelPreview;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const hooks_1 = require("../../../core/hooks");
|
|
33
|
+
const ChevronUpIcon_1 = require("../../../icons/ChevronUpIcon/ChevronUpIcon");
|
|
34
|
+
const ChevronDownIcon_1 = require("../../../icons/ChevronDownIcon/ChevronDownIcon");
|
|
35
|
+
function CodePanelPreview({ children }) {
|
|
36
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
37
|
+
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
38
|
+
const { translate } = useTranslate();
|
|
39
|
+
return (react_1.default.createElement(CodePanelPreviewWrapper, null,
|
|
40
|
+
react_1.default.createElement(PreviewDropdown, { onClick: () => setIsOpen(!isOpen) },
|
|
41
|
+
translate('codeWalkthrough.preview', 'Preview'),
|
|
42
|
+
isOpen ? react_1.default.createElement(ChevronUpIcon_1.ChevronUpIcon, null) : react_1.default.createElement(ChevronDownIcon_1.ChevronDownIcon, null)),
|
|
43
|
+
react_1.default.createElement(PreviewContentWrapper, { isOpen: isOpen }, children)));
|
|
44
|
+
}
|
|
45
|
+
const CodePanelPreviewWrapper = styled_components_1.default.div `
|
|
46
|
+
width: 100%;
|
|
47
|
+
padding: var(--spacing-xs) var(--spacing-xs) var(--spacing-xs) var(--spacing-sm);
|
|
48
|
+
border-bottom: 1px solid var(--border-color-secondary);
|
|
49
|
+
`;
|
|
50
|
+
const PreviewDropdown = styled_components_1.default.div `
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
|
|
54
|
+
gap: (--spacing-xxs);
|
|
55
|
+
|
|
56
|
+
user-select: none;
|
|
57
|
+
|
|
58
|
+
font-size: var(--font-size-base);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
`;
|
|
61
|
+
const PreviewContentWrapper = styled_components_1.default.div `
|
|
62
|
+
display: ${({ isOpen }) => (isOpen ? 'grid' : 'none')};
|
|
63
|
+
place-items: center;
|
|
64
|
+
|
|
65
|
+
margin: auto 0;
|
|
66
|
+
|
|
67
|
+
max-height: 50vh;
|
|
68
|
+
width: 100%;
|
|
69
|
+
max-width: 100%;
|
|
70
|
+
|
|
71
|
+
overflow: auto;
|
|
72
|
+
`;
|
|
73
|
+
//# sourceMappingURL=CodePanelPreview.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CodePanelToolbar = CodePanelToolbar;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const contexts_1 = require("../../../core/contexts");
|
|
33
|
+
const CopyButton_1 = require("../../../components/Buttons/CopyButton");
|
|
34
|
+
function CodePanelToolbar({ file }) {
|
|
35
|
+
const { getFileText } = (0, react_1.useContext)(contexts_1.CodeWalkthroughControlsStateContext);
|
|
36
|
+
const fileContent = getFileText(file);
|
|
37
|
+
return (react_1.default.createElement(CodeToolbarWrapper, null,
|
|
38
|
+
react_1.default.createElement(CopyButton_1.CopyButton, { data: fileContent, type: "compound", variant: "secondary", size: "medium" })));
|
|
39
|
+
}
|
|
40
|
+
const CodeToolbarWrapper = styled_components_1.default.div `
|
|
41
|
+
display: flex;
|
|
42
|
+
position: absolute;
|
|
43
|
+
bottom: var(--spacing-sm);
|
|
44
|
+
right: var(--spacing-sm);
|
|
45
|
+
gap: var(--spacing-xs);
|
|
46
|
+
`;
|
|
47
|
+
//# sourceMappingURL=CodePanelToolbar.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { type PropsWithChildren } from 'react';
|
|
2
|
+
import type { WithConditions } from '@redocly/config';
|
|
3
|
+
export type CodeStepProps = WithConditions<{
|
|
4
|
+
id: string;
|
|
5
|
+
stepKey: number;
|
|
6
|
+
heading?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function CodeStep({ id, heading, stepKey, when, unless, children, }: PropsWithChildren<CodeStepProps>): React.JSX.Element | null;
|
|
9
|
+
export declare const StepWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
10
|
+
isActive: boolean;
|
|
11
|
+
scrollMarginTop: number;
|
|
12
|
+
}, never>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.StepWrapper = void 0;
|
|
30
|
+
exports.CodeStep = CodeStep;
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
|
+
const contexts_1 = require("../../../core/contexts");
|
|
34
|
+
function CodeStep({ id, heading, stepKey, when, unless, children, }) {
|
|
35
|
+
const compRef = (0, react_1.useRef)(null);
|
|
36
|
+
const { areConditionsMet } = (0, react_1.useContext)(contexts_1.CodeWalkthroughControlsStateContext);
|
|
37
|
+
const { activeStep, setActiveStep, register, unregister, lockObserver, filtersElementRef } = (0, react_1.useContext)(contexts_1.CodeWalkthroughStepsContext);
|
|
38
|
+
const isActive = activeStep === id;
|
|
39
|
+
const [scrollMarginTop, setScrollMarginTop] = (0, react_1.useState)(0);
|
|
40
|
+
const handleActivateStep = () => {
|
|
41
|
+
if (lockObserver) {
|
|
42
|
+
lockObserver.current = true;
|
|
43
|
+
if (compRef.current) {
|
|
44
|
+
compRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
45
|
+
}
|
|
46
|
+
setActiveStep(id);
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
lockObserver.current = false;
|
|
49
|
+
}, 1000);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
(0, react_1.useEffect)(() => {
|
|
53
|
+
// If the step is active during first render, scroll to it
|
|
54
|
+
// This is to ensure that the step is visible when the page is loaded
|
|
55
|
+
if (isActive) {
|
|
56
|
+
handleActivateStep();
|
|
57
|
+
}
|
|
58
|
+
// Ignore dependency array because we only need to run this once
|
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
}, []);
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const currentCompRef = compRef.current;
|
|
64
|
+
if (currentCompRef) {
|
|
65
|
+
currentCompRef
|
|
66
|
+
.querySelectorAll('a, button, input, textarea, select, [tabindex]')
|
|
67
|
+
.forEach((el) => {
|
|
68
|
+
el.setAttribute('tabindex', '-1');
|
|
69
|
+
});
|
|
70
|
+
register(currentCompRef);
|
|
71
|
+
}
|
|
72
|
+
const filtersElementHeight = ((_a = filtersElementRef === null || filtersElementRef === void 0 ? void 0 : filtersElementRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0;
|
|
73
|
+
const navbarHeight = ((_b = document.querySelector('nav')) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0;
|
|
74
|
+
setScrollMarginTop(filtersElementHeight + navbarHeight);
|
|
75
|
+
return () => {
|
|
76
|
+
if (currentCompRef) {
|
|
77
|
+
unregister(currentCompRef);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [activeStep, register, unregister, filtersElementRef]);
|
|
81
|
+
if (!areConditionsMet({ when, unless })) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return (react_1.default.createElement(exports.StepWrapper, { ref: compRef, isActive: isActive, scrollMarginTop: scrollMarginTop, "data-step-key": stepKey, "data-step-active": isActive, onClick: handleActivateStep, onFocus: handleActivateStep, tabIndex: 0 },
|
|
85
|
+
react_1.default.createElement(StepContent, { isActive: isActive },
|
|
86
|
+
heading ? react_1.default.createElement(StepHeading, null, heading) : null,
|
|
87
|
+
children)));
|
|
88
|
+
}
|
|
89
|
+
const StepContent = styled_components_1.default.div `
|
|
90
|
+
margin: var(--spacing-xs) 0px var(--spacing-xs) calc(var(--spacing-unit) * 3.5);
|
|
91
|
+
padding: var(--spacing-md) var(--spacing-lg);
|
|
92
|
+
background: ${({ isActive }) => (isActive ? 'var(--layer-color)' : 'none')};
|
|
93
|
+
border-radius: var(--border-radius);
|
|
94
|
+
|
|
95
|
+
&:hover {
|
|
96
|
+
background-color: ${({ isActive }) => isActive ? 'var(--code-step-bg-active-hover)' : 'var(--code-step-bg-hover)'};
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
const StepHeading = styled_components_1.default.p `
|
|
100
|
+
font-weight: var(--font-weight-semibold);
|
|
101
|
+
`;
|
|
102
|
+
exports.StepWrapper = styled_components_1.default.div `
|
|
103
|
+
position: relative;
|
|
104
|
+
scroll-margin-top: ${({ scrollMarginTop }) => scrollMarginTop}px;
|
|
105
|
+
|
|
106
|
+
&::before {
|
|
107
|
+
content: '';
|
|
108
|
+
position: absolute;
|
|
109
|
+
width: 6px;
|
|
110
|
+
height: 100%;
|
|
111
|
+
background-color: ${({ isActive }) => isActive ? 'var(--code-step-vertical-line-bg-active)' : 'none'};
|
|
112
|
+
border-radius: var(--border-radius-lg);
|
|
113
|
+
}
|
|
114
|
+
&:hover::before {
|
|
115
|
+
background-color: ${({ isActive }) => isActive
|
|
116
|
+
? 'var(--code-step-vertical-line-bg-active)'
|
|
117
|
+
: 'var(--code-step-vertical-line-bg-hover)'};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&:hover::before {
|
|
121
|
+
width: ${({ isActive }) => (isActive ? '8px' : '6px')};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&:hover ${StepContent} {
|
|
125
|
+
background-color: ${({ isActive }) => isActive ? 'var(--code-step-bg-active-hover)' : 'var(--code-step-bg-hover)'};
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
//# sourceMappingURL=CodeStep.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type CodeToggleProps = React.PropsWithChildren<{
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: React.ReactNode[];
|
|
6
|
+
}>;
|
|
7
|
+
export declare function CodeToggle(props: CodeToggleProps): React.JSX.Element | null;
|
|
8
|
+
export declare const ToggleWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const ToggleSubtitle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ToggleSubtitle = exports.ToggleWrapper = void 0;
|
|
30
|
+
exports.CodeToggle = CodeToggle;
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
|
+
const contexts_1 = require("../../../core/contexts");
|
|
34
|
+
const CodeStep_1 = require("../../../markdoc/components/CodeWalkthrough/CodeStep");
|
|
35
|
+
const Switch_1 = require("../../../components/Switch/Switch");
|
|
36
|
+
function CodeToggle(props) {
|
|
37
|
+
const { id, label, description, children } = props;
|
|
38
|
+
const { getToggleState, changeToggleState } = (0, react_1.useContext)(contexts_1.CodeWalkthroughControlsStateContext);
|
|
39
|
+
const toggleState = getToggleState(id);
|
|
40
|
+
if (!(toggleState && toggleState.render)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const checked = toggleState.value;
|
|
44
|
+
return (react_1.default.createElement(exports.ToggleWrapper, null,
|
|
45
|
+
react_1.default.createElement(ToggleContentWrapper, null,
|
|
46
|
+
react_1.default.createElement(exports.ToggleSubtitle, null,
|
|
47
|
+
react_1.default.createElement(Switch_1.Switch, { value: checked, onChange: (newValue) => changeToggleState(id, newValue) }),
|
|
48
|
+
react_1.default.createElement("div", null, label)),
|
|
49
|
+
description ? (react_1.default.createElement("div", null, description.map((paragraph, idx) => (react_1.default.createElement(react_1.default.Fragment, { key: idx }, paragraph))))) : null),
|
|
50
|
+
checked ? children : null));
|
|
51
|
+
}
|
|
52
|
+
exports.ToggleWrapper = styled_components_1.default.div `
|
|
53
|
+
${CodeStep_1.StepWrapper} {
|
|
54
|
+
margin-left: 0;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
exports.ToggleSubtitle = styled_components_1.default.div `
|
|
58
|
+
display: flex;
|
|
59
|
+
gap: var(--spacing-sm);
|
|
60
|
+
align-items: center;
|
|
61
|
+
font-weight: var(--font-weight-bold);
|
|
62
|
+
`;
|
|
63
|
+
const ToggleContentWrapper = styled_components_1.default.div `
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
gap: var(--spacing-xs);
|
|
67
|
+
padding: var(--spacing-xs) 0;
|
|
68
|
+
`;
|
|
69
|
+
//# sourceMappingURL=CodeToggle.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React, { type PropsWithChildren } from 'react';
|
|
2
|
+
import type { CodeWalkthroughAttr } from '@redocly/config';
|
|
3
|
+
export type CodeWalkthroughProps = PropsWithChildren<CodeWalkthroughAttr>;
|
|
4
|
+
export declare function CodeWalkthrough({ children, steps, preview, ...attributes }: CodeWalkthroughProps): React.JSX.Element;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.CodeWalkthrough = CodeWalkthrough;
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
43
|
+
const contexts_1 = require("../../../core/contexts");
|
|
44
|
+
const CodePanel_1 = require("../../../markdoc/components/CodeWalkthrough/CodePanel");
|
|
45
|
+
const hooks_1 = require("../../../core/hooks");
|
|
46
|
+
const CodeFilters_1 = require("../../../markdoc/components/CodeWalkthrough/CodeFilters");
|
|
47
|
+
const CodeStep_1 = require("../../../markdoc/components/CodeWalkthrough/CodeStep");
|
|
48
|
+
function CodeWalkthrough(_a) {
|
|
49
|
+
var { children, steps, preview } = _a, attributes = __rest(_a, ["children", "steps", "preview"]);
|
|
50
|
+
// Steps are being modified causing the observer to be recreated in the useCodeWalkthrough hook
|
|
51
|
+
// This is a workaround to prevent the observer from being recreated
|
|
52
|
+
const [initialSteps] = (0, react_1.useState)([...steps]);
|
|
53
|
+
const { controlsState, stepsState, files, downloadAssociatedFiles } = (0, hooks_1.useCodeWalkthrough)(initialSteps, attributes);
|
|
54
|
+
const { activeFilters, getFilterState, changeFilterState } = controlsState;
|
|
55
|
+
const { filtersElementRef } = stepsState;
|
|
56
|
+
return (react_1.default.createElement(contexts_1.CodeWalkthroughStepsContext.Provider, { value: stepsState },
|
|
57
|
+
react_1.default.createElement(contexts_1.CodeWalkthroughControlsStateContext.Provider, { value: controlsState },
|
|
58
|
+
react_1.default.createElement(CodeWalkthroughWrapper, { className: "code-walkthrough" },
|
|
59
|
+
react_1.default.createElement(DocsPanel, null,
|
|
60
|
+
react_1.default.createElement(CodeFilters_1.CodeFilters, { filters: activeFilters, getFilterState: getFilterState, handleFilterSelect: changeFilterState, filtersElementRef: filtersElementRef }),
|
|
61
|
+
react_1.default.createElement(ContentWrapper, null, children)),
|
|
62
|
+
react_1.default.createElement(CodePanel_1.CodePanel, { files: files, downloadAssociatedFiles: downloadAssociatedFiles, preview: preview })))));
|
|
63
|
+
}
|
|
64
|
+
const CodeWalkthroughWrapper = styled_components_1.default.div `
|
|
65
|
+
display: grid;
|
|
66
|
+
grid-template-columns: 4fr 6fr;
|
|
67
|
+
|
|
68
|
+
padding-right: var(--spacing-xl);
|
|
69
|
+
|
|
70
|
+
border-top: 1px solid var(--border-color-secondary);
|
|
71
|
+
border-bottom: 1px solid var(--border-color-secondary);
|
|
72
|
+
|
|
73
|
+
&:first-child {
|
|
74
|
+
border-top: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:last-child {
|
|
78
|
+
border-bottom: none;
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
const DocsPanel = styled_components_1.default.div `
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
|
|
85
|
+
min-height: 0;
|
|
86
|
+
min-height: calc(100vh - var(--navbar-height));
|
|
87
|
+
|
|
88
|
+
padding-right: var(--spacing-xs);
|
|
89
|
+
padding-bottom: calc(var(--spacing-xs) + var(--spacing-xl));
|
|
90
|
+
gap: var(--spacing-xl);
|
|
91
|
+
`;
|
|
92
|
+
const ContentWrapper = styled_components_1.default.div `
|
|
93
|
+
flex-grow: 1;
|
|
94
|
+
|
|
95
|
+
min-height: 0;
|
|
96
|
+
max-width: var(--md-content-max-width);
|
|
97
|
+
|
|
98
|
+
& > *:not(${CodeStep_1.StepWrapper}) {
|
|
99
|
+
padding-left: var(--spacing-xl);
|
|
100
|
+
}
|
|
101
|
+
overflow-y: scroll;
|
|
102
|
+
|
|
103
|
+
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
104
|
+
&::-webkit-scrollbar {
|
|
105
|
+
display: none;
|
|
106
|
+
}
|
|
107
|
+
/* Hide scrollbar for IE, Edge and Firefox */
|
|
108
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
109
|
+
scrollbar-width: none; /* Firefox */
|
|
110
|
+
|
|
111
|
+
&:first-child {
|
|
112
|
+
padding-top: var(--spacing-sm);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&:not(:first-child) {
|
|
116
|
+
& > *:first-child {
|
|
117
|
+
margin-top: 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
121
|
+
//# sourceMappingURL=CodeWalkthrough.js.map
|