@redis-ui/components 51.27.0 → 51.29.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 (142) hide show
  1. package/dist/CodeBlock/CodeBlock.cjs +32 -15
  2. package/dist/CodeBlock/CodeBlock.js +32 -15
  3. package/dist/CodeBlock/CodeBlock.style.d.ts +4 -3
  4. package/dist/CodeBlock/CodeBlock.types.cjs +7 -0
  5. package/dist/CodeBlock/CodeBlock.types.d.ts +9 -1
  6. package/dist/CodeBlock/CodeBlock.types.js +7 -1
  7. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.cjs +29 -0
  8. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.cjs +34 -0
  9. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.d.ts +25 -0
  10. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.js +32 -0
  11. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.d.ts +6 -0
  12. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.js +29 -0
  13. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.d.ts +10 -0
  14. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.js +1 -0
  15. package/dist/index.cjs +1 -0
  16. package/dist/index.js +2 -2
  17. package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.cjs +8 -0
  18. package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +8 -0
  19. package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.cjs +7 -0
  20. package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +7 -0
  21. package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.cjs +12 -0
  22. package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.js +12 -0
  23. package/dist/node_modules/@babel/runtime/helpers/esm/extends.cjs +17 -0
  24. package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
  25. package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.cjs +6 -0
  26. package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +6 -0
  27. package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.cjs +6 -0
  28. package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +6 -0
  29. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.cjs +13 -0
  30. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +13 -0
  31. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.cjs +12 -0
  32. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
  33. package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.cjs +10 -0
  34. package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +10 -0
  35. package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.cjs +14 -0
  36. package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +14 -0
  37. package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.cjs +9 -0
  38. package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +9 -0
  39. package/dist/node_modules/@babel/runtime/helpers/esm/typeof.cjs +16 -0
  40. package/dist/node_modules/@babel/runtime/helpers/esm/typeof.js +11 -0
  41. package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.cjs +11 -0
  42. package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +11 -0
  43. package/dist/node_modules/character-entities-legacy/index.cjs +116 -0
  44. package/dist/node_modules/character-entities-legacy/index.js +116 -0
  45. package/dist/node_modules/character-reference-invalid/index.cjs +38 -0
  46. package/dist/node_modules/character-reference-invalid/index.js +38 -0
  47. package/dist/node_modules/comma-separated-tokens/index.cjs +43 -0
  48. package/dist/node_modules/comma-separated-tokens/index.js +43 -0
  49. package/dist/node_modules/decode-named-character-reference/index.dom.cjs +15 -0
  50. package/dist/node_modules/decode-named-character-reference/index.dom.js +15 -0
  51. package/dist/node_modules/hast-util-parse-selector/lib/index.cjs +76 -0
  52. package/dist/node_modules/hast-util-parse-selector/lib/index.js +76 -0
  53. package/dist/node_modules/hastscript/lib/create-h.cjs +262 -0
  54. package/dist/node_modules/hastscript/lib/create-h.js +262 -0
  55. package/dist/node_modules/hastscript/lib/index.cjs +21 -0
  56. package/dist/node_modules/hastscript/lib/index.js +21 -0
  57. package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.cjs +49 -0
  58. package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js +49 -0
  59. package/dist/node_modules/is-alphabetical/index.cjs +14 -0
  60. package/dist/node_modules/is-alphabetical/index.js +14 -0
  61. package/dist/node_modules/is-alphanumerical/index.cjs +15 -0
  62. package/dist/node_modules/is-alphanumerical/index.js +15 -0
  63. package/dist/node_modules/is-decimal/index.cjs +14 -0
  64. package/dist/node_modules/is-decimal/index.js +14 -0
  65. package/dist/node_modules/is-hexadecimal/index.cjs +14 -0
  66. package/dist/node_modules/is-hexadecimal/index.js +14 -0
  67. package/dist/node_modules/parse-entities/lib/index.cjs +232 -0
  68. package/dist/node_modules/parse-entities/lib/index.js +232 -0
  69. package/dist/node_modules/property-information/index.cjs +27 -0
  70. package/dist/node_modules/property-information/index.js +26 -0
  71. package/dist/node_modules/property-information/lib/aria.cjs +60 -0
  72. package/dist/node_modules/property-information/lib/aria.js +61 -0
  73. package/dist/node_modules/property-information/lib/find.cjs +81 -0
  74. package/dist/node_modules/property-information/lib/find.js +81 -0
  75. package/dist/node_modules/property-information/lib/html.cjs +326 -0
  76. package/dist/node_modules/property-information/lib/html.js +326 -0
  77. package/dist/node_modules/property-information/lib/normalize.cjs +15 -0
  78. package/dist/node_modules/property-information/lib/normalize.js +15 -0
  79. package/dist/node_modules/property-information/lib/svg.cjs +564 -0
  80. package/dist/node_modules/property-information/lib/svg.js +564 -0
  81. package/dist/node_modules/property-information/lib/util/case-insensitive-transform.cjs +15 -0
  82. package/dist/node_modules/property-information/lib/util/case-insensitive-transform.js +15 -0
  83. package/dist/node_modules/property-information/lib/util/case-sensitive-transform.cjs +14 -0
  84. package/dist/node_modules/property-information/lib/util/case-sensitive-transform.js +14 -0
  85. package/dist/node_modules/property-information/lib/util/create.cjs +53 -0
  86. package/dist/node_modules/property-information/lib/util/create.js +53 -0
  87. package/dist/node_modules/property-information/lib/util/defined-info.cjs +49 -0
  88. package/dist/node_modules/property-information/lib/util/defined-info.js +49 -0
  89. package/dist/node_modules/property-information/lib/util/info.cjs +33 -0
  90. package/dist/node_modules/property-information/lib/util/info.js +33 -0
  91. package/dist/node_modules/property-information/lib/util/merge.cjs +26 -0
  92. package/dist/node_modules/property-information/lib/util/merge.js +26 -0
  93. package/dist/node_modules/property-information/lib/util/schema.cjs +27 -0
  94. package/dist/node_modules/property-information/lib/util/schema.js +27 -0
  95. package/dist/node_modules/property-information/lib/util/types.cjs +35 -0
  96. package/dist/node_modules/property-information/lib/util/types.js +24 -0
  97. package/dist/node_modules/property-information/lib/xlink.cjs +18 -0
  98. package/dist/node_modules/property-information/lib/xlink.js +19 -0
  99. package/dist/node_modules/property-information/lib/xml.cjs +14 -0
  100. package/dist/node_modules/property-information/lib/xml.js +15 -0
  101. package/dist/node_modules/property-information/lib/xmlns.cjs +14 -0
  102. package/dist/node_modules/property-information/lib/xmlns.js +14 -0
  103. package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.cjs +6 -0
  104. package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.js +6 -0
  105. package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.cjs +183 -0
  106. package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.js +181 -0
  107. package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.cjs +308 -0
  108. package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.js +306 -0
  109. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.cjs +4 -0
  110. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.js +5 -0
  111. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.cjs +4 -0
  112. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.js +5 -0
  113. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.cjs +4 -0
  114. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.js +5 -0
  115. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.cjs +4 -0
  116. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.js +5 -0
  117. package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.cjs +12 -0
  118. package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.js +12 -0
  119. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.cjs +121 -0
  120. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.js +121 -0
  121. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.cjs +147 -0
  122. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.js +147 -0
  123. package/dist/node_modules/refractor/lang/bash.cjs +190 -0
  124. package/dist/node_modules/refractor/lang/bash.js +190 -0
  125. package/dist/node_modules/refractor/lang/clike.cjs +37 -0
  126. package/dist/node_modules/refractor/lang/clike.js +37 -0
  127. package/dist/node_modules/refractor/lang/javascript.cjs +122 -0
  128. package/dist/node_modules/refractor/lang/javascript.js +122 -0
  129. package/dist/node_modules/refractor/lang/json.cjs +36 -0
  130. package/dist/node_modules/refractor/lang/json.js +36 -0
  131. package/dist/node_modules/refractor/lang/python.cjs +71 -0
  132. package/dist/node_modules/refractor/lang/python.js +71 -0
  133. package/dist/node_modules/refractor/lang/typescript.cjs +55 -0
  134. package/dist/node_modules/refractor/lang/typescript.js +55 -0
  135. package/dist/node_modules/refractor/lib/core.cjs +214 -0
  136. package/dist/node_modules/refractor/lib/core.js +214 -0
  137. package/dist/node_modules/refractor/lib/prism-core.cjs +595 -0
  138. package/dist/node_modules/refractor/lib/prism-core.js +595 -0
  139. package/dist/node_modules/space-separated-tokens/index.cjs +15 -0
  140. package/dist/node_modules/space-separated-tokens/index.js +15 -0
  141. package/package.json +3 -1
  142. package/skills/redis-ui-components/references/CodeBlock.md +27 -6
@@ -1,6 +1,6 @@
1
1
  # CodeBlock
2
2
 
3
- A multi-line code block for snippets, commands and JSON, with an optional copy button. Use `Typography.Code` for inline code.
3
+ A multi-line code block for snippets, commands and JSON, with optional syntax highlighting and a copy button. Use `Typography.Code` for inline code.
4
4
 
5
5
  ## Import
6
6
  ```tsx
@@ -11,23 +11,26 @@ import { CodeBlock } from '@redis-ui/components';
11
11
  | Prop | Type | Default | Description |
12
12
  |------|------|---------|-------------|
13
13
  | code | `string` | *required* | Text rendered in the block and copied by the copy button |
14
+ | language | `'bash' \| 'json' \| 'python' \| 'typescript'` | - | Highlights the code's syntax. Without it, the code is plain text |
14
15
  | copyLabel | `string` | - | Shows a copy button and is used as its accessible name |
16
+ | onCopy | `(text: string) => void` | - | Called with the code after the copy button writes it to the clipboard, e.g. to show a toast |
17
+ | onCopyError | `(error: unknown) => void` | - | Called when the clipboard write fails |
15
18
  | overflow | `'scroll' \| 'wrap' \| 'ellipsis'` | `'scroll'` | How long lines behave: scroll horizontally, wrap (use for commands and prompts), or truncate with an ellipsis |
16
19
  | maxHeight | `string` | - | Scrolls vertically past this height (any CSS length, e.g. `'19rem'`) |
17
20
  | size | `'M' \| 'S'` | `'M'` | Text size. `S` is the compact size |
18
- | native div props | `Omit<HTMLAttributes<HTMLDivElement>, 'children'>` | - | Passed to the root element. `aria-label` names the block when it scrolls (defaults to `Code`) |
21
+ | native div props | `Omit<HTMLAttributes<HTMLDivElement>, 'children' \| 'onCopy'>` | - | Passed to the root element. `aria-label` names the block when it scrolls (defaults to `Code`) |
19
22
 
20
23
  ## Examples
21
24
 
22
25
  ### Playground
23
26
 
24
27
  ```tsx
25
- import { CodeBlock, codeBlockOverflows, codeBlockSizes } from '@redis-ui/components';
28
+ import { CodeBlock } from '@redis-ui/components';
26
29
 
27
- <CodeBlock code={lensSnippet} copyLabel="Copy code" overflow="scroll" size="M" />
30
+ <CodeBlock code={lensSnippet} language="typescript" copyLabel="Copy code" overflow="scroll" size="M" />
28
31
  ```
29
32
 
30
- `codeBlockOverflows` and `codeBlockSizes` list the allowed `overflow` and `size` values, e.g. for controls.
33
+ `codeBlockLanguages`, `codeBlockOverflows` and `codeBlockSizes` list the allowed `language`, `overflow` and `size` values, e.g. for controls.
31
34
 
32
35
  ### Default
33
36
 
@@ -40,6 +43,7 @@ import { CodeBlock, codeBlockOverflows, codeBlockSizes } from '@redis-ui/compone
40
43
  ```tsx
41
44
  <CodeBlock code={installCommand} copyLabel="Copy install command" />
42
45
  <CodeBlock code={lensSnippet} copyLabel="Copy code" />
46
+ <CodeBlock code={lensSnippet} copyLabel="Copy code" onCopy={() => showToast('Code copied')} />
43
47
  ```
44
48
 
45
49
  ### WrappedCommand
@@ -86,8 +90,25 @@ import { CodeBlock, codeBlockSizes } from '@redis-ui/components';
86
90
  ))}
87
91
  ```
88
92
 
93
+ ### Languages
94
+
95
+ > `language` highlights the syntax of bash, JSON, Python or TypeScript code.
96
+
97
+ ```tsx
98
+ import { CodeBlock, codeBlockLanguages } from '@redis-ui/components';
99
+
100
+ {codeBlockLanguages.map((language) => (
101
+ <CodeBlock
102
+ key={language}
103
+ code={languageSnippets[language]}
104
+ language={language}
105
+ copyLabel="Copy code"
106
+ />
107
+ ))}
108
+ ```
109
+
89
110
  ## Notes
90
111
  - The component forwards refs to the root element.
91
112
  - When the content scrolls, the block becomes keyboard-focusable so it can be scrolled with the keyboard. Truncated lines (`overflow="ellipsis"`) don't count.
92
113
  - The copy button is `CopyToClipboardButton`, centered on the first code line in the top-right corner.
93
- - No syntax highlighting: `code` is rendered as plain text.
114
+ - Without `language`, `code` is rendered as plain text. With it, the syntax is highlighted with the VS palette in light themes and VS Code Dark+ in dark themes, and bash commands, including `npx` and `pip`, are colored as keywords.