@redocly/theme 0.47.0 → 0.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Buttons/CopyButton.d.ts +8 -3
- package/lib/components/Buttons/CopyButton.js +4 -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/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/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 +2 -0
- package/lib/core/types/l10n.d.ts +1 -1
- 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 +9 -2
- package/src/components/Buttons/CopyButton.tsx +24 -6
- 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/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/styles/global.ts +2 -0
- package/src/core/templates/Markdown.tsx +16 -5
- package/src/core/types/hooks.ts +2 -0
- package/src/core/types/l10n.ts +3 -1
- 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,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
|
|
@@ -0,0 +1,99 @@
|
|
|
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.Input = Input;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const lodash_debounce_1 = __importDefault(require("lodash.debounce"));
|
|
33
|
+
const contexts_1 = require("../../../core/contexts");
|
|
34
|
+
const DEBOUNCE_TIME = 500;
|
|
35
|
+
function Input(props) {
|
|
36
|
+
const { id, label, placeholder } = props;
|
|
37
|
+
const { getInputState, changeInputState } = (0, react_1.useContext)(contexts_1.CodeWalkthroughControlsStateContext);
|
|
38
|
+
const inputState = getInputState(id);
|
|
39
|
+
const [value, setValue] = (0, react_1.useState)((inputState === null || inputState === void 0 ? void 0 : inputState.value) || '');
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
const debouncedSave = (0, react_1.useCallback)((0, lodash_debounce_1.default)((id, value) => {
|
|
42
|
+
changeInputState(id, value);
|
|
43
|
+
}, DEBOUNCE_TIME), []);
|
|
44
|
+
if (!(inputState === null || inputState === void 0 ? void 0 : inputState.render)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const handleChange = (event) => {
|
|
48
|
+
const inputValue = event.target.value;
|
|
49
|
+
setValue(inputValue);
|
|
50
|
+
debouncedSave(id, inputValue);
|
|
51
|
+
};
|
|
52
|
+
return (react_1.default.createElement(InputWrapper, null,
|
|
53
|
+
label && react_1.default.createElement(Label, null, label),
|
|
54
|
+
react_1.default.createElement(StyledInput, { id: id, value: value, onChange: handleChange, "aria-label": label, placeholder: placeholder })));
|
|
55
|
+
}
|
|
56
|
+
const InputWrapper = styled_components_1.default.div `
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
margin: var(--md-paragraph-margin);
|
|
60
|
+
`;
|
|
61
|
+
const Label = styled_components_1.default.p `
|
|
62
|
+
color: var(--text-color-secondary);
|
|
63
|
+
font-size: var(--font-size-base);
|
|
64
|
+
line-height: var(--line-height-base);
|
|
65
|
+
font-family: var(--font-family-base);
|
|
66
|
+
font-weight: var(--font-weight-medium);
|
|
67
|
+
`;
|
|
68
|
+
const StyledInput = styled_components_1.default.input `
|
|
69
|
+
border: 1px solid var(--border-color-primary);
|
|
70
|
+
width: 224px;
|
|
71
|
+
outline: none;
|
|
72
|
+
padding: var(--input-padding) var(--spacing-sm);
|
|
73
|
+
border-radius: var(--input-border-radius);
|
|
74
|
+
background-color: var(--input-bg-color);
|
|
75
|
+
color: var(--text-color-secondary);
|
|
76
|
+
font-family: var(--font-family-base);
|
|
77
|
+
font-size: var(--font-size-base);
|
|
78
|
+
line-height: var(--input-line-height);
|
|
79
|
+
|
|
80
|
+
&::placeholder {
|
|
81
|
+
opacity: 1;
|
|
82
|
+
color: var(--input-content-placeholder-color);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&:hover {
|
|
86
|
+
color: var(--text-color-primary);
|
|
87
|
+
border: 1px solid var(--border-color-primary);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&:focus {
|
|
91
|
+
color: var(--text-color-primary);
|
|
92
|
+
border: 1px solid var(--border-color-primary);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&:-webkit-autofill {
|
|
96
|
+
background-color: var(--input-bg-color);
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const codeWalkthrough: import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.codeWalkthrough = void 0;
|
|
4
|
+
const styled_components_1 = require("styled-components");
|
|
5
|
+
exports.codeWalkthrough = (0, styled_components_1.css) `
|
|
6
|
+
--code-step-vertical-line-bg-active: var(--color-blue-6);
|
|
7
|
+
--code-step-vertical-line-bg-hover: var(--color-hover-base);
|
|
8
|
+
|
|
9
|
+
--code-step-bg-active: var(--layer-color);
|
|
10
|
+
--code-step-bg-hover: var(--color-hover-base);
|
|
11
|
+
--code-step-bg-active-hover: var(--layer-color-hover);
|
|
12
|
+
|
|
13
|
+
--code-panel-bg-color: var(--layer-color);
|
|
14
|
+
--code-panel-line-numbering-color: var(--text-color-disabled);
|
|
15
|
+
--code-panel-header-height: var(--spacing-lg);
|
|
16
|
+
--code-panel-border-color: var(--border-color-secondary);
|
|
17
|
+
--code-panel-border-radius: var(--border-radius);
|
|
18
|
+
`;
|
|
19
|
+
//# sourceMappingURL=variables.js.map
|
|
@@ -12,3 +12,8 @@ export * from '../../markdoc/components/Cards/Card';
|
|
|
12
12
|
export * from '../../markdoc/components/Cards/CardIcon';
|
|
13
13
|
export * from '../../markdoc/components/Cards/CardImage';
|
|
14
14
|
export * from '../../markdoc/components/Image/Image';
|
|
15
|
+
export * from '../../markdoc/components/CodeWalkthrough/CodeWalkthrough';
|
|
16
|
+
export * from '../../markdoc/components/CodeWalkthrough/CodeStep';
|
|
17
|
+
export * from '../../markdoc/components/CodeWalkthrough/Input';
|
|
18
|
+
export * from '../../markdoc/components/CodeWalkthrough/CodeToggle';
|
|
19
|
+
export * from '../../markdoc/components/CodeWalkthrough/CodeContainer';
|
|
@@ -28,4 +28,9 @@ __exportStar(require("../../markdoc/components/Cards/Card"), exports);
|
|
|
28
28
|
__exportStar(require("../../markdoc/components/Cards/CardIcon"), exports);
|
|
29
29
|
__exportStar(require("../../markdoc/components/Cards/CardImage"), exports);
|
|
30
30
|
__exportStar(require("../../markdoc/components/Image/Image"), exports);
|
|
31
|
+
__exportStar(require("../../markdoc/components/CodeWalkthrough/CodeWalkthrough"), exports);
|
|
32
|
+
__exportStar(require("../../markdoc/components/CodeWalkthrough/CodeStep"), exports);
|
|
33
|
+
__exportStar(require("../../markdoc/components/CodeWalkthrough/Input"), exports);
|
|
34
|
+
__exportStar(require("../../markdoc/components/CodeWalkthrough/CodeToggle"), exports);
|
|
35
|
+
__exportStar(require("../../markdoc/components/CodeWalkthrough/CodeContainer"), exports);
|
|
31
36
|
//# sourceMappingURL=default.js.map
|
package/lib/markdoc/default.js
CHANGED
|
@@ -48,6 +48,10 @@ const inline_svg_1 = require("../markdoc/tags/inline-svg");
|
|
|
48
48
|
const cards_1 = require("../markdoc/tags/cards");
|
|
49
49
|
const card_1 = require("../markdoc/tags/card");
|
|
50
50
|
const img_1 = require("../markdoc/tags/img");
|
|
51
|
+
const code_walkthrough_1 = require("../markdoc/tags/code-walkthrough");
|
|
52
|
+
const code_step_1 = require("../markdoc/tags/code-step");
|
|
53
|
+
const input_1 = require("../markdoc/tags/input");
|
|
54
|
+
const code_toggle_1 = require("../markdoc/tags/code-toggle");
|
|
51
55
|
exports.tags = {
|
|
52
56
|
[admonition_1.admonition.tagName]: admonition_1.admonition.schema,
|
|
53
57
|
[debug_1.debug.tagName]: debug_1.debug.schema,
|
|
@@ -61,5 +65,9 @@ exports.tags = {
|
|
|
61
65
|
[cards_1.cards.tagName]: cards_1.cards.schema,
|
|
62
66
|
[card_1.card.tagName]: card_1.card.schema,
|
|
63
67
|
[img_1.img.tagName]: img_1.img.schema,
|
|
68
|
+
[code_walkthrough_1.codeWalkthrough.tagName]: code_walkthrough_1.codeWalkthrough.schema,
|
|
69
|
+
[code_step_1.codeStep.tagName]: code_step_1.codeStep.schema,
|
|
70
|
+
[code_toggle_1.toggle.tagName]: code_toggle_1.toggle.schema,
|
|
71
|
+
[input_1.input.tagName]: input_1.input.schema,
|
|
64
72
|
};
|
|
65
73
|
//# sourceMappingURL=default.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.codeStep = void 0;
|
|
4
|
+
exports.codeStep = {
|
|
5
|
+
tagName: 'step',
|
|
6
|
+
schema: {
|
|
7
|
+
attributes: {
|
|
8
|
+
id: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: true,
|
|
11
|
+
},
|
|
12
|
+
heading: {
|
|
13
|
+
type: String,
|
|
14
|
+
},
|
|
15
|
+
when: {
|
|
16
|
+
type: Object,
|
|
17
|
+
},
|
|
18
|
+
unless: {
|
|
19
|
+
type: Object,
|
|
20
|
+
},
|
|
21
|
+
stepKey: {
|
|
22
|
+
type: Number, // internal
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
render: 'CodeStep',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=code-step.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.toggle = void 0;
|
|
7
|
+
const markdoc_1 = __importDefault(require("@markdoc/markdoc"));
|
|
8
|
+
exports.toggle = {
|
|
9
|
+
tagName: 'toggle',
|
|
10
|
+
schema: {
|
|
11
|
+
attributes: {
|
|
12
|
+
id: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
label: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
unless: {
|
|
21
|
+
type: Object,
|
|
22
|
+
required: false,
|
|
23
|
+
},
|
|
24
|
+
when: {
|
|
25
|
+
type: Object,
|
|
26
|
+
required: false,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
slots: {
|
|
30
|
+
description: { required: false, render: true },
|
|
31
|
+
},
|
|
32
|
+
transform: (node, config) => {
|
|
33
|
+
const attributes = node.transformAttributes(config);
|
|
34
|
+
const children = node.transformChildren(config);
|
|
35
|
+
return new markdoc_1.default.Tag('CodeToggle', attributes, children);
|
|
36
|
+
},
|
|
37
|
+
render: 'CodeToggle',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=code-toggle.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Node, RenderableTreeNode } from '@markdoc/markdoc';
|
|
2
|
+
import type { MarkdocSchemaWrapper } from '../../markdoc/tags/types';
|
|
3
|
+
import type { CodeWalkthroughConditions, CodeWalkthroughFilter, TogglesMarkdocAttr, InputsMarkdocAttr } from '@redocly/config';
|
|
4
|
+
export declare const codeWalkthrough: MarkdocSchemaWrapper;
|
|
5
|
+
export declare function collectStepsFromChildren(children: RenderableTreeNode[], idx?: number): RenderableTreeNode[];
|
|
6
|
+
export declare function collectTogglesFromChildren(children: Node[], toggles?: TogglesMarkdocAttr): TogglesMarkdocAttr;
|
|
7
|
+
export declare function collectInputsFromChildren(children: RenderableTreeNode[], inputs?: InputsMarkdocAttr): InputsMarkdocAttr;
|
|
8
|
+
export declare function validateCodeWalkthroughCondition(conditions: CodeWalkthroughConditions, filters: Record<string, CodeWalkthroughFilter>, allToggles: string[]): string[];
|