@redocly/theme 0.48.0 → 0.48.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/lib/components/DatePicker/variables.js +1 -1
  2. package/lib/components/Feedback/Mood.js +14 -9
  3. package/lib/components/Search/SearchDialog.js +9 -3
  4. package/lib/components/Search/variables.js +4 -0
  5. package/lib/components/Segmented/Segmented.d.ts +4 -4
  6. package/lib/components/Segmented/Segmented.js +4 -7
  7. package/lib/components/Tag/Tag.d.ts +1 -0
  8. package/lib/components/Tag/Tag.js +3 -2
  9. package/lib/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.js +2 -6
  10. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.d.ts +7 -10
  11. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.js +63 -97
  12. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.d.ts +1 -2
  13. package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.js +20 -15
  14. package/lib/core/hooks/code-walkthrough/use-code-walkthrough.d.ts +2 -7
  15. package/lib/core/hooks/code-walkthrough/use-code-walkthrough.js +10 -3
  16. package/lib/core/hooks/code-walkthrough/use-renderable-files.d.ts +9 -0
  17. package/lib/core/hooks/code-walkthrough/use-renderable-files.js +28 -0
  18. package/lib/core/hooks/index.d.ts +1 -0
  19. package/lib/core/hooks/index.js +1 -0
  20. package/lib/core/styles/global.js +18 -0
  21. package/lib/core/types/l10n.d.ts +1 -1
  22. package/lib/core/utils/download-code-walkthrough.d.ts +4 -2
  23. package/lib/core/utils/download-code-walkthrough.js +9 -1
  24. package/lib/core/utils/find-closest-common-directory.d.ts +6 -0
  25. package/lib/core/utils/find-closest-common-directory.js +51 -0
  26. package/lib/core/utils/get-code-walkthrough-file-text.d.ts +4 -2
  27. package/lib/core/utils/get-file-icon.js +6 -0
  28. package/lib/core/utils/index.d.ts +1 -0
  29. package/lib/core/utils/index.js +1 -0
  30. package/lib/core/utils/replace-inputs-with-value.d.ts +1 -1
  31. package/lib/core/utils/replace-inputs-with-value.js +9 -10
  32. package/lib/icons/DocumentJavaIcon/DocumentJavaIcon.d.ts +9 -0
  33. package/lib/icons/DocumentJavaIcon/DocumentJavaIcon.js +22 -0
  34. package/lib/icons/DocumentJavaIcon/index.d.ts +1 -0
  35. package/lib/icons/DocumentJavaIcon/index.js +6 -0
  36. package/lib/icons/DocumentPythonIcon/DocumentPythonIcon.d.ts +9 -0
  37. package/lib/icons/DocumentPythonIcon/DocumentPythonIcon.js +23 -0
  38. package/lib/icons/DocumentPythonIcon/index.d.ts +1 -0
  39. package/lib/icons/DocumentPythonIcon/index.js +6 -0
  40. package/lib/icons/DocumentShellIcon/DocumentShellIcon.d.ts +9 -0
  41. package/lib/icons/DocumentShellIcon/DocumentShellIcon.js +22 -0
  42. package/lib/icons/DocumentShellIcon/index.d.ts +1 -0
  43. package/lib/icons/DocumentShellIcon/index.js +6 -0
  44. package/lib/icons/__tests__/IconTestUtils.d.ts +7 -0
  45. package/lib/icons/__tests__/IconTestUtils.js +33 -0
  46. package/lib/layouts/CodeWalkthroughLayout.js +4 -1
  47. package/lib/markdoc/components/CodeWalkthrough/CodeContainer.js +25 -4
  48. package/lib/markdoc/components/CodeWalkthrough/CodeFilters.d.ts +5 -4
  49. package/lib/markdoc/components/CodeWalkthrough/CodeFilters.js +15 -2
  50. package/lib/markdoc/components/CodeWalkthrough/CodePanel.js +1 -1
  51. package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.js +29 -23
  52. package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.js +1 -1
  53. package/lib/markdoc/components/CodeWalkthrough/CodePanelToolbar.js +1 -1
  54. package/lib/markdoc/components/CodeWalkthrough/CodeStep.js +5 -2
  55. package/lib/markdoc/components/CodeWalkthrough/CodeToggle.js +5 -5
  56. package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.js +3 -3
  57. package/lib/markdoc/components/CodeWalkthrough/Input.js +7 -5
  58. package/lib/markdoc/tags/code-walkthrough.js +5 -0
  59. package/package.json +3 -3
  60. package/src/components/DatePicker/variables.ts +1 -1
  61. package/src/components/Feedback/Mood.tsx +16 -7
  62. package/src/components/Search/SearchDialog.tsx +52 -36
  63. package/src/components/Search/variables.ts +4 -0
  64. package/src/components/Segmented/Segmented.tsx +10 -10
  65. package/src/components/Tag/Tag.tsx +1 -1
  66. package/src/core/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.tsx +2 -8
  67. package/src/core/hooks/code-walkthrough/use-code-walkthrough-controls.ts +90 -142
  68. package/src/core/hooks/code-walkthrough/use-code-walkthrough-steps.ts +30 -18
  69. package/src/core/hooks/code-walkthrough/use-code-walkthrough.ts +13 -13
  70. package/src/core/hooks/code-walkthrough/use-renderable-files.ts +51 -0
  71. package/src/core/hooks/index.ts +1 -0
  72. package/src/core/styles/global.ts +18 -0
  73. package/src/core/types/l10n.ts +3 -1
  74. package/src/core/utils/download-code-walkthrough.ts +16 -4
  75. package/src/core/utils/find-closest-common-directory.ts +51 -0
  76. package/src/core/utils/get-code-walkthrough-file-text.ts +3 -3
  77. package/src/core/utils/get-file-icon.ts +7 -0
  78. package/src/core/utils/index.ts +1 -0
  79. package/src/core/utils/replace-inputs-with-value.ts +12 -9
  80. package/src/icons/DocumentJavaIcon/DocumentJavaIcon.tsx +33 -0
  81. package/src/icons/DocumentJavaIcon/index.ts +1 -0
  82. package/src/icons/DocumentPythonIcon/DocumentPythonIcon.tsx +37 -0
  83. package/src/icons/DocumentPythonIcon/index.ts +1 -0
  84. package/src/icons/DocumentShellIcon/DocumentShellIcon.tsx +33 -0
  85. package/src/icons/DocumentShellIcon/index.ts +1 -0
  86. package/src/icons/__tests__/IconTestUtils.tsx +31 -0
  87. package/src/layouts/CodeWalkthroughLayout.tsx +5 -1
  88. package/src/markdoc/components/CodeWalkthrough/CodeContainer.tsx +28 -3
  89. package/src/markdoc/components/CodeWalkthrough/CodeFilters.tsx +21 -4
  90. package/src/markdoc/components/CodeWalkthrough/CodePanel.tsx +1 -1
  91. package/src/markdoc/components/CodeWalkthrough/CodePanelHeader.tsx +64 -47
  92. package/src/markdoc/components/CodeWalkthrough/CodePanelPreview.tsx +1 -1
  93. package/src/markdoc/components/CodeWalkthrough/CodePanelToolbar.tsx +1 -1
  94. package/src/markdoc/components/CodeWalkthrough/CodeStep.tsx +5 -1
  95. package/src/markdoc/components/CodeWalkthrough/CodeToggle.tsx +5 -5
  96. package/src/markdoc/components/CodeWalkthrough/CodeWalkthrough.tsx +11 -5
  97. package/src/markdoc/components/CodeWalkthrough/Input.tsx +8 -6
  98. package/src/markdoc/tags/code-walkthrough.ts +5 -0
@@ -13,20 +13,20 @@ export type CodeToggleProps = React.PropsWithChildren<{
13
13
 
14
14
  export function CodeToggle(props: CodeToggleProps) {
15
15
  const { id, label, description, children } = props;
16
- const { getToggleState, changeToggleState } = useContext(CodeWalkthroughControlsStateContext);
16
+ const { getControlState, changeControlState } = useContext(CodeWalkthroughControlsStateContext);
17
17
 
18
- const toggleState = getToggleState(id);
18
+ const toggleState = getControlState(id);
19
19
 
20
- if (!(toggleState && toggleState.render)) {
20
+ if (!(toggleState && toggleState.render && typeof toggleState.value === 'boolean')) {
21
21
  return null;
22
22
  }
23
23
  const checked = toggleState.value;
24
24
 
25
25
  return (
26
- <ToggleWrapper>
26
+ <ToggleWrapper data-component-name="Markdoc/CodeWalkthrough/CodeToggle">
27
27
  <ToggleContentWrapper>
28
28
  <ToggleSubtitle>
29
- <Switch value={checked} onChange={(newValue) => changeToggleState(id, newValue)} />
29
+ <Switch value={checked} onChange={(newValue) => changeControlState(id, newValue)} />
30
30
  <div>{label}</div>
31
31
  </ToggleSubtitle>
32
32
  {description ? (
@@ -9,7 +9,10 @@ import {
9
9
  } from '@redocly/theme/core/contexts';
10
10
  import { CodePanel } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodePanel';
11
11
  import { useCodeWalkthrough } from '@redocly/theme/core/hooks';
12
- import { CodeFilters } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodeFilters';
12
+ import {
13
+ CodeFilters,
14
+ GetFilterState,
15
+ } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodeFilters';
13
16
  import { StepWrapper } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodeStep';
14
17
 
15
18
  export type CodeWalkthroughProps = PropsWithChildren<CodeWalkthroughAttr>;
@@ -22,18 +25,21 @@ export function CodeWalkthrough({ children, steps, preview, ...attributes }: Cod
22
25
  initialSteps,
23
26
  attributes,
24
27
  );
25
- const { activeFilters, getFilterState, changeFilterState } = controlsState;
28
+ const { activeFilters, getControlState, changeControlState } = controlsState;
26
29
  const { filtersElementRef } = stepsState;
27
30
 
28
31
  return (
29
32
  <CodeWalkthroughStepsContext.Provider value={stepsState}>
30
33
  <CodeWalkthroughControlsStateContext.Provider value={controlsState}>
31
- <CodeWalkthroughWrapper className="code-walkthrough">
34
+ <CodeWalkthroughWrapper
35
+ className="code-walkthrough"
36
+ data-component-name="Markdoc/CodeWalkthrough/CodeWalkthrough"
37
+ >
32
38
  <DocsPanel>
33
39
  <CodeFilters
34
40
  filters={activeFilters}
35
- getFilterState={getFilterState}
36
- handleFilterSelect={changeFilterState}
41
+ getFilterState={getControlState as GetFilterState}
42
+ handleFilterSelect={changeControlState}
37
43
  filtersElementRef={filtersElementRef}
38
44
  />
39
45
  <ContentWrapper>{children}</ContentWrapper>
@@ -15,16 +15,16 @@ const DEBOUNCE_TIME = 500;
15
15
 
16
16
  export function Input(props: InputProps) {
17
17
  const { id, label, placeholder } = props;
18
- const { getInputState, changeInputState } = useContext(CodeWalkthroughControlsStateContext);
18
+ const { getControlState, changeControlState } = useContext(CodeWalkthroughControlsStateContext);
19
19
 
20
- const inputState = getInputState(id);
20
+ const inputState = getControlState(id);
21
21
 
22
22
  const [value, setValue] = useState(inputState?.value || '');
23
23
 
24
24
  // eslint-disable-next-line react-hooks/exhaustive-deps
25
25
  const debouncedSave = useCallback(
26
26
  debounce((id: string, value: string) => {
27
- changeInputState(id, value);
27
+ changeControlState(id, value);
28
28
  }, DEBOUNCE_TIME),
29
29
  [],
30
30
  );
@@ -41,11 +41,11 @@ export function Input(props: InputProps) {
41
41
  };
42
42
 
43
43
  return (
44
- <InputWrapper>
44
+ <InputWrapper data-component-name="Markdoc/CodeWalkthrough/Input">
45
45
  {label && <Label>{label}</Label>}
46
46
  <StyledInput
47
47
  id={id}
48
- value={value}
48
+ value={value as string}
49
49
  onChange={handleChange}
50
50
  aria-label={label}
51
51
  placeholder={placeholder}
@@ -57,7 +57,8 @@ export function Input(props: InputProps) {
57
57
  const InputWrapper = styled.div`
58
58
  display: flex;
59
59
  flex-direction: column;
60
- margin: var(--md-paragraph-margin);
60
+ margin-top: var(--spacing-base);
61
+ margin-bottom: var(--spacing-base);
61
62
  `;
62
63
 
63
64
  const Label = styled.p`
@@ -66,6 +67,7 @@ const Label = styled.p`
66
67
  line-height: var(--line-height-base);
67
68
  font-family: var(--font-family-base);
68
69
  font-weight: var(--font-weight-medium);
70
+ margin-bottom: var(--spacing-xxs) !important;
69
71
  `;
70
72
 
71
73
  const StyledInput = styled.input`
@@ -44,6 +44,11 @@ export const codeWalkthrough: MarkdocSchemaWrapper = {
44
44
  render: false,
45
45
  required: false,
46
46
  },
47
+ __idx: {
48
+ type: Number,
49
+ render: true,
50
+ required: false,
51
+ },
47
52
  },
48
53
  slots: {
49
54
  preview: { required: false, render: true },