@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.
Files changed (219) hide show
  1. package/lib/components/Buttons/CopyButton.d.ts +8 -3
  2. package/lib/components/Buttons/CopyButton.js +4 -3
  3. package/lib/components/Feedback/Mood.d.ts +2 -2
  4. package/lib/components/Feedback/Mood.js +6 -6
  5. package/lib/components/Feedback/Rating.d.ts +2 -2
  6. package/lib/components/Feedback/Rating.js +6 -6
  7. package/lib/components/Feedback/Scale.d.ts +2 -2
  8. package/lib/components/Feedback/Scale.js +6 -6
  9. package/lib/components/Feedback/Sentiment.d.ts +2 -2
  10. package/lib/components/Feedback/Sentiment.js +6 -6
  11. package/lib/components/Search/SearchDialog.js +8 -8
  12. package/lib/components/Search/SearchFilter.d.ts +3 -2
  13. package/lib/components/Search/SearchFilter.js +2 -2
  14. package/lib/components/Search/SearchFilterField.d.ts +3 -2
  15. package/lib/components/Search/SearchFilterField.js +2 -2
  16. package/lib/components/Search/SearchGroups.d.ts +5 -4
  17. package/lib/components/Search/SearchGroups.js +3 -3
  18. package/lib/components/StatusCode/StatusCode.js +11 -14
  19. package/lib/core/constants/code-walkthrough.d.ts +1 -0
  20. package/lib/core/constants/code-walkthrough.js +5 -0
  21. package/lib/core/constants/index.d.ts +1 -0
  22. package/lib/core/constants/index.js +1 -0
  23. package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.d.ts +2 -0
  24. package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.js +18 -0
  25. package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughStepsContext.d.ts +2 -0
  26. package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughStepsContext.js +11 -0
  27. package/lib/core/contexts/index.d.ts +2 -0
  28. package/lib/core/contexts/index.js +2 -0
  29. package/lib/core/hooks/__mocks__/search/use-search-filter.d.ts +1 -1
  30. package/lib/core/hooks/__mocks__/search/use-search-filter.js +1 -1
  31. package/lib/core/hooks/code-walkthrough/__mocks__/MockIntersectionObserver.d.ts +10 -0
  32. package/lib/core/hooks/code-walkthrough/__mocks__/MockIntersectionObserver.js +55 -0
  33. package/lib/core/hooks/code-walkthrough/use-code-panel.d.ts +6 -0
  34. package/lib/core/hooks/code-walkthrough/use-code-panel.js +93 -0
  35. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.d.ts +22 -0
  36. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.js +183 -0
  37. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.d.ts +16 -0
  38. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.js +117 -0
  39. package/lib/core/hooks/code-walkthrough/use-code-walkthrough.d.ts +14 -0
  40. package/lib/core/hooks/code-walkthrough/use-code-walkthrough.js +22 -0
  41. package/lib/core/hooks/index.d.ts +4 -0
  42. package/lib/core/hooks/index.js +4 -0
  43. package/lib/core/hooks/search/use-search-filter.d.ts +2 -2
  44. package/lib/core/hooks/search/use-search-filter.js +5 -5
  45. package/lib/core/styles/global.js +2 -0
  46. package/lib/core/templates/Markdown.d.ts +8 -2
  47. package/lib/core/templates/Markdown.js +5 -2
  48. package/lib/core/types/hooks.d.ts +3 -0
  49. package/lib/core/types/l10n.d.ts +1 -1
  50. package/lib/core/types/search.d.ts +1 -2
  51. package/lib/core/utils/download-code-walkthrough.d.ts +4 -0
  52. package/lib/core/utils/download-code-walkthrough.js +32 -0
  53. package/lib/core/utils/get-code-walkthrough-file-text.d.ts +4 -0
  54. package/lib/core/utils/get-code-walkthrough-file-text.js +22 -0
  55. package/lib/core/utils/get-file-icon.d.ts +2 -0
  56. package/lib/core/utils/get-file-icon.js +31 -0
  57. package/lib/core/utils/index.d.ts +5 -0
  58. package/lib/core/utils/index.js +5 -0
  59. package/lib/core/utils/js-utils.d.ts +30 -0
  60. package/lib/core/utils/js-utils.js +41 -0
  61. package/lib/core/utils/match-code-walkthrough-conditions.d.ts +4 -0
  62. package/lib/core/utils/match-code-walkthrough-conditions.js +23 -0
  63. package/lib/core/utils/replace-inputs-with-value.d.ts +3 -0
  64. package/lib/core/utils/replace-inputs-with-value.js +16 -0
  65. package/lib/icons/DocumentCssIcon/DocumentCssIcon.d.ts +9 -0
  66. package/lib/icons/DocumentCssIcon/DocumentCssIcon.js +23 -0
  67. package/lib/icons/DocumentCssIcon/index.d.ts +1 -0
  68. package/lib/icons/DocumentCssIcon/index.js +6 -0
  69. package/lib/icons/DocumentGraphqlIcon/DocumentGraphqlIcon.d.ts +9 -0
  70. package/lib/icons/DocumentGraphqlIcon/DocumentGraphqlIcon.js +31 -0
  71. package/lib/icons/DocumentGraphqlIcon/index.d.ts +1 -0
  72. package/lib/icons/DocumentGraphqlIcon/index.js +6 -0
  73. package/lib/icons/DocumentHtmlIcon/DocumentHtmlIcon.d.ts +9 -0
  74. package/lib/icons/DocumentHtmlIcon/DocumentHtmlIcon.js +23 -0
  75. package/lib/icons/DocumentHtmlIcon/index.d.ts +1 -0
  76. package/lib/icons/DocumentHtmlIcon/index.js +6 -0
  77. package/lib/icons/DocumentJsIcon/DocumentJsIcon.d.ts +9 -0
  78. package/lib/icons/DocumentJsIcon/DocumentJsIcon.js +23 -0
  79. package/lib/icons/DocumentJsIcon/index.d.ts +1 -0
  80. package/lib/icons/DocumentJsIcon/index.js +6 -0
  81. package/lib/icons/DocumentJsonIcon/DocumentJsonIcon.d.ts +9 -0
  82. package/lib/icons/DocumentJsonIcon/DocumentJsonIcon.js +23 -0
  83. package/lib/icons/DocumentJsonIcon/index.d.ts +1 -0
  84. package/lib/icons/DocumentJsonIcon/index.js +6 -0
  85. package/lib/icons/DocumentMarkdownIcon/DocumentMarkdownIcon.d.ts +9 -0
  86. package/lib/icons/DocumentMarkdownIcon/DocumentMarkdownIcon.js +23 -0
  87. package/lib/icons/DocumentMarkdownIcon/index.d.ts +1 -0
  88. package/lib/icons/DocumentMarkdownIcon/index.js +6 -0
  89. package/lib/icons/DocumentReactIcon/DocumentReactIcon.d.ts +9 -0
  90. package/lib/icons/DocumentReactIcon/DocumentReactIcon.js +23 -0
  91. package/lib/icons/DocumentReactIcon/index.d.ts +1 -0
  92. package/lib/icons/DocumentReactIcon/index.js +6 -0
  93. package/lib/icons/DocumentTsIcon/DocumentTsIcon.d.ts +9 -0
  94. package/lib/icons/DocumentTsIcon/DocumentTsIcon.js +23 -0
  95. package/lib/icons/DocumentTsIcon/index.d.ts +1 -0
  96. package/lib/icons/DocumentTsIcon/index.js +6 -0
  97. package/lib/icons/DocumentYamlIcon/DocumentYamlIcon.d.ts +9 -0
  98. package/lib/icons/DocumentYamlIcon/DocumentYamlIcon.js +23 -0
  99. package/lib/icons/DocumentYamlIcon/index.d.ts +1 -0
  100. package/lib/icons/DocumentYamlIcon/index.js +6 -0
  101. package/lib/index.d.ts +1 -0
  102. package/lib/index.js +1 -0
  103. package/lib/layouts/CodeWalkthroughLayout.d.ts +5 -0
  104. package/lib/layouts/CodeWalkthroughLayout.js +72 -0
  105. package/lib/markdoc/attributes/code-walkthrough-filesets.d.ts +5 -0
  106. package/lib/markdoc/attributes/code-walkthrough-filesets.js +16 -0
  107. package/lib/markdoc/attributes/code-walkthrough-filters.d.ts +5 -0
  108. package/lib/markdoc/attributes/code-walkthrough-filters.js +16 -0
  109. package/lib/markdoc/components/CodeWalkthrough/CodeContainer.d.ts +5 -0
  110. package/lib/markdoc/components/CodeWalkthrough/CodeContainer.js +81 -0
  111. package/lib/markdoc/components/CodeWalkthrough/CodeFilters.d.ts +12 -0
  112. package/lib/markdoc/components/CodeWalkthrough/CodeFilters.js +58 -0
  113. package/lib/markdoc/components/CodeWalkthrough/CodePanel.d.ts +8 -0
  114. package/lib/markdoc/components/CodeWalkthrough/CodePanel.js +64 -0
  115. package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.d.ts +8 -0
  116. package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.js +155 -0
  117. package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.d.ts +2 -0
  118. package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.js +73 -0
  119. package/lib/markdoc/components/CodeWalkthrough/CodePanelToolbar.d.ts +5 -0
  120. package/lib/markdoc/components/CodeWalkthrough/CodePanelToolbar.js +47 -0
  121. package/lib/markdoc/components/CodeWalkthrough/CodeStep.d.ts +12 -0
  122. package/lib/markdoc/components/CodeWalkthrough/CodeStep.js +128 -0
  123. package/lib/markdoc/components/CodeWalkthrough/CodeToggle.d.ts +9 -0
  124. package/lib/markdoc/components/CodeWalkthrough/CodeToggle.js +69 -0
  125. package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.d.ts +4 -0
  126. package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.js +121 -0
  127. package/lib/markdoc/components/CodeWalkthrough/Input.d.ts +8 -0
  128. package/lib/markdoc/components/CodeWalkthrough/Input.js +99 -0
  129. package/lib/markdoc/components/CodeWalkthrough/variables.d.ts +1 -0
  130. package/lib/markdoc/components/CodeWalkthrough/variables.js +19 -0
  131. package/lib/markdoc/components/default.d.ts +5 -0
  132. package/lib/markdoc/components/default.js +5 -0
  133. package/lib/markdoc/default.js +8 -0
  134. package/lib/markdoc/tags/code-step.d.ts +2 -0
  135. package/lib/markdoc/tags/code-step.js +28 -0
  136. package/lib/markdoc/tags/code-toggle.d.ts +2 -0
  137. package/lib/markdoc/tags/code-toggle.js +40 -0
  138. package/lib/markdoc/tags/code-walkthrough.d.ts +8 -0
  139. package/lib/markdoc/tags/code-walkthrough.js +242 -0
  140. package/lib/markdoc/tags/input.d.ts +2 -0
  141. package/lib/markdoc/tags/input.js +37 -0
  142. package/lib/plugin.d.ts +2 -1
  143. package/lib/plugin.js +2 -4
  144. package/package.json +10 -3
  145. package/src/components/Buttons/CopyButton.tsx +24 -6
  146. package/src/components/Feedback/Mood.tsx +9 -10
  147. package/src/components/Feedback/Rating.tsx +9 -10
  148. package/src/components/Feedback/Scale.tsx +9 -10
  149. package/src/components/Feedback/Sentiment.tsx +9 -10
  150. package/src/components/Search/SearchDialog.tsx +11 -6
  151. package/src/components/Search/SearchFilter.tsx +6 -3
  152. package/src/components/Search/SearchFilterField.tsx +4 -2
  153. package/src/components/Search/SearchGroups.tsx +13 -8
  154. package/src/components/StatusCode/StatusCode.ts +11 -10
  155. package/src/core/constants/code-walkthrough.ts +1 -0
  156. package/src/core/constants/index.ts +1 -0
  157. package/src/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.tsx +21 -0
  158. package/src/core/contexts/CodeWalkthrough/CodeWalkthroughStepsContext.tsx +10 -0
  159. package/src/core/contexts/index.ts +2 -0
  160. package/src/core/hooks/__mocks__/search/use-search-filter.ts +1 -1
  161. package/src/core/hooks/code-walkthrough/__mocks__/MockIntersectionObserver.ts +22 -0
  162. package/src/core/hooks/code-walkthrough/use-code-panel.ts +164 -0
  163. package/src/core/hooks/code-walkthrough/use-code-walkthrough-controls.ts +302 -0
  164. package/src/core/hooks/code-walkthrough/use-code-walkthrough-steps.ts +165 -0
  165. package/src/core/hooks/code-walkthrough/use-code-walkthrough.ts +51 -0
  166. package/src/core/hooks/index.ts +4 -0
  167. package/src/core/hooks/search/use-search-filter.ts +9 -5
  168. package/src/core/styles/global.ts +2 -0
  169. package/src/core/templates/Markdown.tsx +16 -5
  170. package/src/core/types/hooks.ts +3 -0
  171. package/src/core/types/l10n.ts +5 -3
  172. package/src/core/types/search.ts +1 -2
  173. package/src/core/utils/download-code-walkthrough.ts +25 -0
  174. package/src/core/utils/get-code-walkthrough-file-text.ts +32 -0
  175. package/src/core/utils/get-file-icon.ts +35 -0
  176. package/src/core/utils/index.ts +5 -0
  177. package/src/core/utils/js-utils.ts +48 -0
  178. package/src/core/utils/match-code-walkthrough-conditions.ts +29 -0
  179. package/src/core/utils/replace-inputs-with-value.ts +11 -0
  180. package/src/icons/DocumentCssIcon/DocumentCssIcon.tsx +36 -0
  181. package/src/icons/DocumentCssIcon/index.ts +1 -0
  182. package/src/icons/DocumentGraphqlIcon/DocumentGraphqlIcon.tsx +64 -0
  183. package/src/icons/DocumentGraphqlIcon/index.ts +1 -0
  184. package/src/icons/DocumentHtmlIcon/DocumentHtmlIcon.tsx +36 -0
  185. package/src/icons/DocumentHtmlIcon/index.ts +1 -0
  186. package/src/icons/DocumentJsIcon/DocumentJsIcon.tsx +36 -0
  187. package/src/icons/DocumentJsIcon/index.ts +1 -0
  188. package/src/icons/DocumentJsonIcon/DocumentJsonIcon.tsx +36 -0
  189. package/src/icons/DocumentJsonIcon/index.ts +1 -0
  190. package/src/icons/DocumentMarkdownIcon/DocumentMarkdownIcon.tsx +36 -0
  191. package/src/icons/DocumentMarkdownIcon/index.ts +1 -0
  192. package/src/icons/DocumentReactIcon/DocumentReactIcon.tsx +36 -0
  193. package/src/icons/DocumentReactIcon/index.ts +1 -0
  194. package/src/icons/DocumentTsIcon/DocumentTsIcon.tsx +38 -0
  195. package/src/icons/DocumentTsIcon/index.ts +1 -0
  196. package/src/icons/DocumentYamlIcon/DocumentYamlIcon.tsx +36 -0
  197. package/src/icons/DocumentYamlIcon/index.ts +1 -0
  198. package/src/index.ts +1 -0
  199. package/src/layouts/CodeWalkthroughLayout.tsx +78 -0
  200. package/src/markdoc/attributes/code-walkthrough-filesets.ts +9 -0
  201. package/src/markdoc/attributes/code-walkthrough-filters.ts +9 -0
  202. package/src/markdoc/components/CodeWalkthrough/CodeContainer.tsx +76 -0
  203. package/src/markdoc/components/CodeWalkthrough/CodeFilters.tsx +87 -0
  204. package/src/markdoc/components/CodeWalkthrough/CodePanel.tsx +68 -0
  205. package/src/markdoc/components/CodeWalkthrough/CodePanelHeader.tsx +192 -0
  206. package/src/markdoc/components/CodeWalkthrough/CodePanelPreview.tsx +53 -0
  207. package/src/markdoc/components/CodeWalkthrough/CodePanelToolbar.tsx +31 -0
  208. package/src/markdoc/components/CodeWalkthrough/CodeStep.tsx +149 -0
  209. package/src/markdoc/components/CodeWalkthrough/CodeToggle.tsx +63 -0
  210. package/src/markdoc/components/CodeWalkthrough/CodeWalkthrough.tsx +111 -0
  211. package/src/markdoc/components/CodeWalkthrough/Input.tsx +101 -0
  212. package/src/markdoc/components/CodeWalkthrough/variables.ts +16 -0
  213. package/src/markdoc/components/default.ts +5 -0
  214. package/src/markdoc/default.ts +8 -0
  215. package/src/markdoc/tags/code-step.ts +27 -0
  216. package/src/markdoc/tags/code-toggle.ts +37 -0
  217. package/src/markdoc/tags/code-walkthrough.ts +315 -0
  218. package/src/markdoc/tags/input.ts +35 -0
  219. package/src/plugin.js +2 -2
@@ -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
@@ -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,2 @@
1
+ import type { MarkdocSchemaWrapper } from '../../markdoc/tags/types';
2
+ export declare const codeStep: MarkdocSchemaWrapper;
@@ -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,2 @@
1
+ import type { MarkdocSchemaWrapper } from '../../markdoc/tags/types';
2
+ export declare const toggle: MarkdocSchemaWrapper;
@@ -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[];
@@ -0,0 +1,242 @@
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.codeWalkthrough = void 0;
7
+ exports.collectStepsFromChildren = collectStepsFromChildren;
8
+ exports.collectTogglesFromChildren = collectTogglesFromChildren;
9
+ exports.collectInputsFromChildren = collectInputsFromChildren;
10
+ exports.validateCodeWalkthroughCondition = validateCodeWalkthroughCondition;
11
+ const markdoc_1 = __importDefault(require("@markdoc/markdoc"));
12
+ const code_walkthrough_filesets_1 = require("../../markdoc/attributes/code-walkthrough-filesets");
13
+ const code_walkthrough_filters_1 = require("../../markdoc/attributes/code-walkthrough-filters");
14
+ const utils_1 = require("../../core/utils");
15
+ exports.codeWalkthrough = {
16
+ tagName: 'code-walkthrough',
17
+ schema: {
18
+ attributes: {
19
+ filesets: {
20
+ type: code_walkthrough_filesets_1.CodeWalkthroughFilesets,
21
+ render: false,
22
+ required: true,
23
+ },
24
+ resolvedFilesets: {
25
+ type: Array,
26
+ render: false,
27
+ required: false,
28
+ },
29
+ filters: {
30
+ type: code_walkthrough_filters_1.CodeWalkthroughFilters,
31
+ render: false,
32
+ required: false,
33
+ },
34
+ inputs: {
35
+ type: Object,
36
+ render: false,
37
+ required: false,
38
+ },
39
+ toggles: {
40
+ type: Array,
41
+ render: false,
42
+ required: false,
43
+ },
44
+ },
45
+ slots: {
46
+ preview: { required: false, render: true },
47
+ },
48
+ transform: (node, config) => {
49
+ const attributes = node.transformAttributes(config);
50
+ const children = node.transformChildren(config);
51
+ const steps = collectStepsFromChildren(children);
52
+ const inputs = collectInputsFromChildren(children);
53
+ const toggles = collectTogglesFromChildren(node.children);
54
+ return new markdoc_1.default.Tag('CodeWalkthrough', Object.assign(Object.assign({}, attributes), { filters: node.attributes.filters || {}, filesets: node.attributes.resolvedFilesets || [], steps: steps.map((step) => {
55
+ return Object.assign({}, ((step === null || step === void 0 ? void 0 : step.attributes) || {}));
56
+ }), inputs,
57
+ toggles }), children);
58
+ },
59
+ validate(node) {
60
+ const errors = [];
61
+ // code-walk-todo: validate when/unless for steps, toggles, inputs, and chunks
62
+ const toggleIds = Object.keys(collectTogglesFromChildren(node.children));
63
+ if ((0, utils_1.isObject)(node.attributes.filters)) {
64
+ Object.entries(node.attributes.filters).forEach(([id, filter]) => {
65
+ var _a;
66
+ if (!(0, utils_1.isObject)(filter)) {
67
+ errors.push({
68
+ id: 'filter-elements-type-invalid',
69
+ level: 'error',
70
+ message: 'The "filters" attribute elements must be of type object.',
71
+ });
72
+ }
73
+ else if (!((_a = filter.items) === null || _a === void 0 ? void 0 : _a.length)) {
74
+ errors.push({
75
+ id: 'filter-required',
76
+ level: 'error',
77
+ message: `The "filters" items attribute for the filter ${id} should have at least one item.`,
78
+ });
79
+ }
80
+ });
81
+ }
82
+ else if (node.attributes.filters) {
83
+ errors.push({
84
+ id: 'filter-type-invalid',
85
+ level: 'error',
86
+ message: 'The "filters" attribute must be of type object.',
87
+ });
88
+ }
89
+ if (Array.isArray(node.attributes.filesets)) {
90
+ node.attributes.filesets.forEach((fileset, idx) => {
91
+ if (fileset.when) {
92
+ const whenErrors = validateCodeWalkthroughCondition(fileset.when, node.attributes.filters || {}, toggleIds);
93
+ if (whenErrors.length > 0) {
94
+ errors.push({
95
+ id: 'fileset-when-invalid',
96
+ level: 'error',
97
+ message: `Invalid condition at 'filesets.${idx}.when':\n${whenErrors.join('\n')}`,
98
+ });
99
+ }
100
+ }
101
+ if (fileset.unless) {
102
+ const unlessErrors = validateCodeWalkthroughCondition(fileset.unless, node.attributes.filters || {}, toggleIds);
103
+ if (unlessErrors.length > 0) {
104
+ errors.push({
105
+ id: 'fileset-when-invalid',
106
+ level: 'error',
107
+ message: `Invalid condition at 'filesets.${idx}.unless':\n${unlessErrors.join('\n')}`,
108
+ });
109
+ }
110
+ }
111
+ });
112
+ if (!node.attributes.filesets.length) {
113
+ errors.push({
114
+ id: 'filesets-required',
115
+ level: 'error',
116
+ message: 'The "filesets" attribute should have at least one item.',
117
+ });
118
+ }
119
+ }
120
+ else {
121
+ errors.push({
122
+ id: 'filesets-type-invalid',
123
+ level: 'error',
124
+ message: 'The "filesets" attribute must be of type array.',
125
+ });
126
+ }
127
+ node.children.forEach((child) => {
128
+ if (child.tag === 'step') {
129
+ const isValidFilter = validateStepFilters(node.attributes.filters || {}, child.attributes);
130
+ if (!isValidFilter) {
131
+ errors.push({
132
+ id: 'step-filter-invalid',
133
+ level: 'error',
134
+ message: 'The "step" tag contains invalid filter attributes. Ensure "when" and "unless" conditions reference valid filters.',
135
+ });
136
+ }
137
+ }
138
+ });
139
+ return errors;
140
+ },
141
+ render: 'CodeWalkthrough',
142
+ },
143
+ };
144
+ function collectStepsFromChildren(children, idx = 0) {
145
+ return children.flatMap((child) => {
146
+ if (child instanceof markdoc_1.default.Tag && child.name === 'CodeStep') {
147
+ child.attributes.stepKey = idx++;
148
+ return [child];
149
+ }
150
+ if (child instanceof markdoc_1.default.Tag) {
151
+ return collectStepsFromChildren(child.children, idx);
152
+ }
153
+ return [];
154
+ });
155
+ }
156
+ function collectTogglesFromChildren(children, toggles = {}) {
157
+ for (const child of children) {
158
+ if (child.tag === 'toggle') {
159
+ const id = child.attributes.id;
160
+ if (id) {
161
+ toggles[id] = {
162
+ when: child.attributes.when,
163
+ unless: child.attributes.unless,
164
+ };
165
+ }
166
+ }
167
+ collectTogglesFromChildren(child.children, toggles);
168
+ }
169
+ return toggles;
170
+ }
171
+ function collectInputsFromChildren(children, inputs = {}) {
172
+ for (const child of children) {
173
+ if (child instanceof markdoc_1.default.Tag && child.name === 'Input') {
174
+ const id = child.attributes.id;
175
+ if (id) {
176
+ inputs[id] = {
177
+ value: child.attributes.value || '',
178
+ when: child.attributes.when,
179
+ unless: child.attributes.unless,
180
+ };
181
+ }
182
+ continue;
183
+ }
184
+ if (child instanceof markdoc_1.default.Tag) {
185
+ collectInputsFromChildren(child.children, inputs);
186
+ }
187
+ }
188
+ return inputs;
189
+ }
190
+ function validateCodeWalkthroughCondition(conditions, filters, allToggles) {
191
+ var _a;
192
+ const errors = [];
193
+ for (const [filterId, filterValue] of Object.entries(conditions)) {
194
+ if (!filters[filterId] && !allToggles.includes(filterId)) {
195
+ errors.push('Unknown filter: ' + filterId);
196
+ }
197
+ else if (filterValue) {
198
+ const invalidFilterItems = getInvalidFilterValues(filterValue, ((_a = filters[filterId]) === null || _a === void 0 ? void 0 : _a.items) || []);
199
+ if (invalidFilterItems.length > 0) {
200
+ errors.push(`Filter item(s) are not defined on the filter '${filterId}': ${invalidFilterItems.join(', ')}`);
201
+ }
202
+ }
203
+ }
204
+ return errors;
205
+ }
206
+ function getInvalidFilterValues(filterConditionValue, definedValues) {
207
+ const togglesArray = Array.isArray(filterConditionValue)
208
+ ? filterConditionValue
209
+ : [filterConditionValue];
210
+ const items = definedValues.map((item) => item.value);
211
+ return togglesArray.filter((toggle) => typeof toggle !== 'boolean' && !items.includes(toggle));
212
+ }
213
+ function validateStepFilters(filters, obj) {
214
+ function isValidFilter(filterKey, filterValue) {
215
+ if (!Object.prototype.hasOwnProperty.call(filters, filterKey)) {
216
+ return true;
217
+ }
218
+ const validItems = filters[filterKey].items.map((item) => item.value);
219
+ if (Array.isArray(filterValue)) {
220
+ return filterValue.every((value) => validItems.includes(value));
221
+ }
222
+ else {
223
+ return validItems.includes(filterValue);
224
+ }
225
+ }
226
+ if (obj.when) {
227
+ for (const [key, value] of Object.entries(obj.when)) {
228
+ if (!isValidFilter(key, value)) {
229
+ return false;
230
+ }
231
+ }
232
+ }
233
+ if (obj.unless) {
234
+ for (const [key, value] of Object.entries(obj.unless)) {
235
+ if (!isValidFilter(key, value)) {
236
+ return false;
237
+ }
238
+ }
239
+ }
240
+ return true;
241
+ }
242
+ //# sourceMappingURL=code-walkthrough.js.map
@@ -0,0 +1,2 @@
1
+ import type { MarkdocSchemaWrapper } from '../../markdoc/tags/types';
2
+ export declare const input: MarkdocSchemaWrapper;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.input = void 0;
4
+ exports.input = {
5
+ tagName: 'input',
6
+ schema: {
7
+ attributes: {
8
+ id: {
9
+ type: String,
10
+ required: true,
11
+ },
12
+ label: {
13
+ type: String,
14
+ required: false,
15
+ },
16
+ placeholder: {
17
+ type: String,
18
+ required: false,
19
+ },
20
+ value: {
21
+ type: String,
22
+ required: false,
23
+ },
24
+ unless: {
25
+ type: Object,
26
+ required: false,
27
+ },
28
+ when: {
29
+ type: Object,
30
+ required: false,
31
+ },
32
+ },
33
+ selfClosing: true,
34
+ render: 'Input',
35
+ },
36
+ };
37
+ //# sourceMappingURL=input.js.map
package/lib/plugin.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export default function plugin(): {
1
+ declare function _exports(): {
2
2
  id: string;
3
3
  };
4
+ export = _exports;
package/lib/plugin.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = plugin;
4
- function plugin() {
2
+ module.exports = function plugin() {
5
3
  return { id: 'default-theme' };
6
- }
4
+ };
7
5
  //# sourceMappingURL=plugin.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.47.0",
3
+ "version": "0.48.0",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -26,6 +26,7 @@
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@markdoc/markdoc": "0.4.0",
29
+ "lodash.debounce": "^4.0.8",
29
30
  "lodash.throttle": "^4.1.1",
30
31
  "react": "^17.0.0 || ^18.0.0",
31
32
  "react-dom": "^17.0.0 || ^18.0.0",
@@ -35,16 +36,19 @@
35
36
  },
36
37
  "devDependencies": {
37
38
  "@markdoc/markdoc": "0.4.0",
39
+ "@shikijs/types": "1.24.2",
38
40
  "@testing-library/jest-dom": "6.1.5",
39
41
  "@testing-library/react": "14.1.2",
40
42
  "@testing-library/user-event": "14.5.1",
43
+ "@types/file-saver": "2.0.7",
41
44
  "@types/highlight-words-core": "1.2.3",
42
45
  "@types/jest": "29.5.11",
43
46
  "@types/jest-when": "3.5.5",
47
+ "@types/lodash.debounce": "4.0.9",
44
48
  "@types/lodash.throttle": "4.1.9",
45
49
  "@types/node": "18.19.3",
46
50
  "@types/react": "18.3.9",
47
- "@types/react-dom": "18.2.25",
51
+ "@types/react-dom": "18.3.5",
48
52
  "@types/styled-components": "5.1.34",
49
53
  "@types/styled-system": "5.1.22",
50
54
  "@types/nprogress": "0.2.3",
@@ -54,6 +58,7 @@
54
58
  "jest-styled-components": "7.2.0",
55
59
  "jest-when": "3.6.0",
56
60
  "json-schema-to-ts": "2.7.2",
61
+ "lodash.debounce": "4.0.8",
57
62
  "lodash.throttle": "4.1.1",
58
63
  "npm-run-all2": "5.0.2",
59
64
  "react-refresh": "0.14.2",
@@ -72,14 +77,16 @@
72
77
  },
73
78
  "dependencies": {
74
79
  "copy-to-clipboard": "3.3.3",
80
+ "file-saver": "2.0.5",
75
81
  "highlight-words-core": "1.2.2",
76
82
  "hotkeys-js": "3.10.1",
83
+ "jszip": "3.10.1",
77
84
  "react-calendar": "4.2.1",
78
85
  "react-date-picker": "10.0.3",
79
86
  "timeago.js": "4.0.2",
80
87
  "i18next": "22.4.15",
81
88
  "nprogress": "0.2.0",
82
- "@redocly/config": "0.19.4"
89
+ "@redocly/config": "0.20.0"
83
90
  },
84
91
  "scripts": {
85
92
  "watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",