@redis-ui/components 51.26.0 → 51.28.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 (187) hide show
  1. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.cjs +17 -8
  2. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.js +17 -8
  3. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.d.ts +5 -1
  4. package/dist/CodeBlock/CodeBlock.cjs +29 -14
  5. package/dist/CodeBlock/CodeBlock.js +29 -14
  6. package/dist/CodeBlock/CodeBlock.style.d.ts +4 -3
  7. package/dist/CodeBlock/CodeBlock.types.cjs +7 -0
  8. package/dist/CodeBlock/CodeBlock.types.d.ts +4 -0
  9. package/dist/CodeBlock/CodeBlock.types.js +7 -1
  10. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.cjs +29 -0
  11. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.cjs +34 -0
  12. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.d.ts +25 -0
  13. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.js +32 -0
  14. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.d.ts +6 -0
  15. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.js +29 -0
  16. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.d.ts +10 -0
  17. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.js +1 -0
  18. package/dist/Inputs/Input/Input.cjs +9 -2
  19. package/dist/Inputs/Input/Input.d.ts +4 -1
  20. package/dist/Inputs/Input/Input.js +9 -2
  21. package/dist/Inputs/Input/Input.types.d.ts +5 -1
  22. package/dist/Inputs/PasswordInput/components/Compose/Compose.types.d.ts +1 -1
  23. package/dist/Inputs/TextArea/TextArea.cjs +16 -6
  24. package/dist/Inputs/TextArea/TextArea.d.ts +3 -1
  25. package/dist/Inputs/TextArea/TextArea.js +16 -6
  26. package/dist/Inputs/TextArea/TextArea.types.d.ts +4 -1
  27. package/dist/Inputs/TextArea/components/CopyButton/CopyButton.cjs +7 -0
  28. package/dist/Inputs/TextArea/components/CopyButton/CopyButton.d.ts +2 -0
  29. package/dist/Inputs/TextArea/components/CopyButton/CopyButton.js +7 -0
  30. package/dist/Inputs/TextArea/components/CopyButton/CopyButton.style.cjs +17 -0
  31. package/dist/Inputs/TextArea/components/CopyButton/CopyButton.style.d.ts +1 -0
  32. package/dist/Inputs/TextArea/components/CopyButton/CopyButton.style.js +15 -0
  33. package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.cjs +3 -1
  34. package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.js +4 -2
  35. package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.style.cjs +8 -1
  36. package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.style.js +8 -1
  37. package/dist/Inputs/components/Compose/CommonCompose.cjs +23 -18
  38. package/dist/Inputs/components/Compose/CommonCompose.d.ts +1 -1
  39. package/dist/Inputs/components/Compose/CommonCompose.js +24 -19
  40. package/dist/Inputs/components/Compose/CommonCompose.types.d.ts +2 -0
  41. package/dist/Inputs/components/Compose/Compose.style.cjs +7 -0
  42. package/dist/Inputs/components/Compose/Compose.style.js +7 -0
  43. package/dist/Inputs/components/Compose/NumericCompose.types.d.ts +1 -1
  44. package/dist/Inputs/components/CopyButton/CopyButton.cjs +15 -0
  45. package/dist/Inputs/components/CopyButton/CopyButton.d.ts +2 -0
  46. package/dist/Inputs/components/CopyButton/CopyButton.js +15 -0
  47. package/dist/Inputs/components/CopyButton/CopyButton.style.cjs +17 -0
  48. package/dist/Inputs/components/CopyButton/CopyButton.style.d.ts +1 -0
  49. package/dist/Inputs/components/CopyButton/CopyButton.style.js +15 -0
  50. package/dist/Inputs/components/CopyButton/CopyButton.types.d.ts +6 -0
  51. package/dist/Inputs/components/CopyButton/CopyButton.types.js +1 -0
  52. package/dist/Inputs/components/InputTag/InputTag.cjs +3 -1
  53. package/dist/Inputs/components/InputTag/InputTag.js +4 -2
  54. package/dist/Inputs/components/InputTag/InputTag.style.cjs +1 -1
  55. package/dist/Inputs/components/InputTag/InputTag.style.js +1 -1
  56. package/dist/index.cjs +1 -0
  57. package/dist/index.js +2 -2
  58. package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.cjs +8 -0
  59. package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +8 -0
  60. package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.cjs +7 -0
  61. package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +7 -0
  62. package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.cjs +12 -0
  63. package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.js +12 -0
  64. package/dist/node_modules/@babel/runtime/helpers/esm/extends.cjs +17 -0
  65. package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
  66. package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.cjs +6 -0
  67. package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +6 -0
  68. package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.cjs +6 -0
  69. package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +6 -0
  70. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.cjs +13 -0
  71. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +13 -0
  72. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.cjs +12 -0
  73. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
  74. package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.cjs +10 -0
  75. package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +10 -0
  76. package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.cjs +14 -0
  77. package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +14 -0
  78. package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.cjs +9 -0
  79. package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +9 -0
  80. package/dist/node_modules/@babel/runtime/helpers/esm/typeof.cjs +16 -0
  81. package/dist/node_modules/@babel/runtime/helpers/esm/typeof.js +11 -0
  82. package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.cjs +11 -0
  83. package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +11 -0
  84. package/dist/node_modules/character-entities-legacy/index.cjs +116 -0
  85. package/dist/node_modules/character-entities-legacy/index.js +116 -0
  86. package/dist/node_modules/character-reference-invalid/index.cjs +38 -0
  87. package/dist/node_modules/character-reference-invalid/index.js +38 -0
  88. package/dist/node_modules/comma-separated-tokens/index.cjs +43 -0
  89. package/dist/node_modules/comma-separated-tokens/index.js +43 -0
  90. package/dist/node_modules/decode-named-character-reference/index.dom.cjs +15 -0
  91. package/dist/node_modules/decode-named-character-reference/index.dom.js +15 -0
  92. package/dist/node_modules/hast-util-parse-selector/lib/index.cjs +76 -0
  93. package/dist/node_modules/hast-util-parse-selector/lib/index.js +76 -0
  94. package/dist/node_modules/hastscript/lib/create-h.cjs +262 -0
  95. package/dist/node_modules/hastscript/lib/create-h.js +262 -0
  96. package/dist/node_modules/hastscript/lib/index.cjs +21 -0
  97. package/dist/node_modules/hastscript/lib/index.js +21 -0
  98. package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.cjs +49 -0
  99. package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js +49 -0
  100. package/dist/node_modules/is-alphabetical/index.cjs +14 -0
  101. package/dist/node_modules/is-alphabetical/index.js +14 -0
  102. package/dist/node_modules/is-alphanumerical/index.cjs +15 -0
  103. package/dist/node_modules/is-alphanumerical/index.js +15 -0
  104. package/dist/node_modules/is-decimal/index.cjs +14 -0
  105. package/dist/node_modules/is-decimal/index.js +14 -0
  106. package/dist/node_modules/is-hexadecimal/index.cjs +14 -0
  107. package/dist/node_modules/is-hexadecimal/index.js +14 -0
  108. package/dist/node_modules/parse-entities/lib/index.cjs +232 -0
  109. package/dist/node_modules/parse-entities/lib/index.js +232 -0
  110. package/dist/node_modules/property-information/index.cjs +27 -0
  111. package/dist/node_modules/property-information/index.js +26 -0
  112. package/dist/node_modules/property-information/lib/aria.cjs +60 -0
  113. package/dist/node_modules/property-information/lib/aria.js +61 -0
  114. package/dist/node_modules/property-information/lib/find.cjs +81 -0
  115. package/dist/node_modules/property-information/lib/find.js +81 -0
  116. package/dist/node_modules/property-information/lib/html.cjs +326 -0
  117. package/dist/node_modules/property-information/lib/html.js +326 -0
  118. package/dist/node_modules/property-information/lib/normalize.cjs +15 -0
  119. package/dist/node_modules/property-information/lib/normalize.js +15 -0
  120. package/dist/node_modules/property-information/lib/svg.cjs +564 -0
  121. package/dist/node_modules/property-information/lib/svg.js +564 -0
  122. package/dist/node_modules/property-information/lib/util/case-insensitive-transform.cjs +15 -0
  123. package/dist/node_modules/property-information/lib/util/case-insensitive-transform.js +15 -0
  124. package/dist/node_modules/property-information/lib/util/case-sensitive-transform.cjs +14 -0
  125. package/dist/node_modules/property-information/lib/util/case-sensitive-transform.js +14 -0
  126. package/dist/node_modules/property-information/lib/util/create.cjs +53 -0
  127. package/dist/node_modules/property-information/lib/util/create.js +53 -0
  128. package/dist/node_modules/property-information/lib/util/defined-info.cjs +49 -0
  129. package/dist/node_modules/property-information/lib/util/defined-info.js +49 -0
  130. package/dist/node_modules/property-information/lib/util/info.cjs +33 -0
  131. package/dist/node_modules/property-information/lib/util/info.js +33 -0
  132. package/dist/node_modules/property-information/lib/util/merge.cjs +26 -0
  133. package/dist/node_modules/property-information/lib/util/merge.js +26 -0
  134. package/dist/node_modules/property-information/lib/util/schema.cjs +27 -0
  135. package/dist/node_modules/property-information/lib/util/schema.js +27 -0
  136. package/dist/node_modules/property-information/lib/util/types.cjs +35 -0
  137. package/dist/node_modules/property-information/lib/util/types.js +24 -0
  138. package/dist/node_modules/property-information/lib/xlink.cjs +18 -0
  139. package/dist/node_modules/property-information/lib/xlink.js +19 -0
  140. package/dist/node_modules/property-information/lib/xml.cjs +14 -0
  141. package/dist/node_modules/property-information/lib/xml.js +15 -0
  142. package/dist/node_modules/property-information/lib/xmlns.cjs +14 -0
  143. package/dist/node_modules/property-information/lib/xmlns.js +14 -0
  144. package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.cjs +6 -0
  145. package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.js +6 -0
  146. package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.cjs +183 -0
  147. package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.js +181 -0
  148. package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.cjs +308 -0
  149. package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.js +306 -0
  150. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.cjs +4 -0
  151. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.js +5 -0
  152. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.cjs +4 -0
  153. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.js +5 -0
  154. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.cjs +4 -0
  155. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.js +5 -0
  156. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.cjs +4 -0
  157. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.js +5 -0
  158. package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.cjs +12 -0
  159. package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.js +12 -0
  160. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.cjs +121 -0
  161. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.js +121 -0
  162. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.cjs +147 -0
  163. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.js +147 -0
  164. package/dist/node_modules/refractor/lang/bash.cjs +190 -0
  165. package/dist/node_modules/refractor/lang/bash.js +190 -0
  166. package/dist/node_modules/refractor/lang/clike.cjs +37 -0
  167. package/dist/node_modules/refractor/lang/clike.js +37 -0
  168. package/dist/node_modules/refractor/lang/javascript.cjs +122 -0
  169. package/dist/node_modules/refractor/lang/javascript.js +122 -0
  170. package/dist/node_modules/refractor/lang/json.cjs +36 -0
  171. package/dist/node_modules/refractor/lang/json.js +36 -0
  172. package/dist/node_modules/refractor/lang/python.cjs +71 -0
  173. package/dist/node_modules/refractor/lang/python.js +71 -0
  174. package/dist/node_modules/refractor/lang/typescript.cjs +55 -0
  175. package/dist/node_modules/refractor/lang/typescript.js +55 -0
  176. package/dist/node_modules/refractor/lib/core.cjs +214 -0
  177. package/dist/node_modules/refractor/lib/core.js +214 -0
  178. package/dist/node_modules/refractor/lib/prism-core.cjs +595 -0
  179. package/dist/node_modules/refractor/lib/prism-core.js +595 -0
  180. package/dist/node_modules/space-separated-tokens/index.cjs +15 -0
  181. package/dist/node_modules/space-separated-tokens/index.js +15 -0
  182. package/package.json +4 -2
  183. package/skills/redis-ui-components/references/CodeBlock.md +23 -5
  184. package/skills/redis-ui-components/references/CopyToClipboardButton.md +23 -1
  185. package/skills/redis-ui-components/references/Input.md +39 -2
  186. package/skills/redis-ui-components/references/SearchInput.md +1 -1
  187. package/skills/redis-ui-components/references/TextArea.md +19 -1
@@ -8,7 +8,7 @@ react = require_runtime.__toESM(react, 1);
8
8
  let _redislabsdev_redis_ui_icons = require("@redis-ui/icons");
9
9
  //#region src/Button/CopyToClipboardButton/CopyToClipboardButton.tsx
10
10
  var COPIED_STATE_DURATION = 1500;
11
- var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel, variant = "default", ...restProps }, ref) => {
11
+ var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel, variant = "default", onCopy, onCopyError, ...restProps }, ref) => {
12
12
  const { iconSize } = (0, _redislabsdev_redis_ui_styles.useTheme)().components.copyToClipboardButton.variants.outline;
13
13
  const iconProps = variant === "outline" ? { customSize: iconSize } : { size: "L" };
14
14
  const [isCopied, setIsCopied] = (0, react.useState)(false);
@@ -21,13 +21,21 @@ var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel,
21
21
  const handleClick = (0, react.useCallback)(async () => {
22
22
  try {
23
23
  await navigator.clipboard.writeText(textToCopy);
24
- setIsCopied(true);
25
- if (timeoutRef.current) clearTimeout(timeoutRef.current);
26
- timeoutRef.current = setTimeout(() => {
27
- setIsCopied(false);
28
- }, COPIED_STATE_DURATION);
29
- } catch {}
30
- }, [textToCopy]);
24
+ } catch (error) {
25
+ onCopyError?.(error);
26
+ return;
27
+ }
28
+ setIsCopied(true);
29
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
30
+ timeoutRef.current = setTimeout(() => {
31
+ setIsCopied(false);
32
+ }, COPIED_STATE_DURATION);
33
+ onCopy?.(textToCopy);
34
+ }, [
35
+ textToCopy,
36
+ onCopy,
37
+ onCopyError
38
+ ]);
31
39
  const ariaLabel = isCopied && copiedLabel ? copiedLabel : restProps["aria-label"] || "Copy";
32
40
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CopyToClipboardButton_style.CopyToClipboardWrapper, { children: [
33
41
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyToClipboardButton_style.CopyToClipboardButton, {
@@ -35,6 +43,7 @@ var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel,
35
43
  ref,
36
44
  onClick: handleClick,
37
45
  $isCopied: isCopied,
46
+ "data-copied": isCopied ? "" : void 0,
38
47
  $variant: variant,
39
48
  ...restProps,
40
49
  "aria-label": ariaLabel,
@@ -6,7 +6,7 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
6
6
  import { CopyIcon, ToastCheckIcon } from "@redis-ui/icons";
7
7
  //#region src/Button/CopyToClipboardButton/CopyToClipboardButton.tsx
8
8
  var COPIED_STATE_DURATION = 1500;
9
- var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, variant = "default", ...restProps }, ref) => {
9
+ var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, variant = "default", onCopy, onCopyError, ...restProps }, ref) => {
10
10
  const { iconSize } = useTheme().components.copyToClipboardButton.variants.outline;
11
11
  const iconProps = variant === "outline" ? { customSize: iconSize } : { size: "L" };
12
12
  const [isCopied, setIsCopied] = useState(false);
@@ -19,13 +19,21 @@ var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, variant
19
19
  const handleClick = useCallback(async () => {
20
20
  try {
21
21
  await navigator.clipboard.writeText(textToCopy);
22
- setIsCopied(true);
23
- if (timeoutRef.current) clearTimeout(timeoutRef.current);
24
- timeoutRef.current = setTimeout(() => {
25
- setIsCopied(false);
26
- }, COPIED_STATE_DURATION);
27
- } catch {}
28
- }, [textToCopy]);
22
+ } catch (error) {
23
+ onCopyError?.(error);
24
+ return;
25
+ }
26
+ setIsCopied(true);
27
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
28
+ timeoutRef.current = setTimeout(() => {
29
+ setIsCopied(false);
30
+ }, COPIED_STATE_DURATION);
31
+ onCopy?.(textToCopy);
32
+ }, [
33
+ textToCopy,
34
+ onCopy,
35
+ onCopyError
36
+ ]);
29
37
  const ariaLabel = isCopied && copiedLabel ? copiedLabel : restProps["aria-label"] || "Copy";
30
38
  return /* @__PURE__ */ jsxs(CopyToClipboardWrapper, { children: [
31
39
  /* @__PURE__ */ jsx(CopyToClipboardButton$1, {
@@ -33,6 +41,7 @@ var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, variant
33
41
  ref,
34
42
  onClick: handleClick,
35
43
  $isCopied: isCopied,
44
+ "data-copied": isCopied ? "" : void 0,
36
45
  $variant: variant,
37
46
  ...restProps,
38
47
  "aria-label": ariaLabel,
@@ -1,8 +1,12 @@
1
1
  import { ButtonHTMLAttributes } from 'react';
2
2
  export declare const copyToClipboardButtonVariants: readonly ["default", "outline"];
3
3
  export type CopyToClipboardButtonVariant = (typeof copyToClipboardButtonVariants)[number];
4
- export interface CopyToClipboardButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> {
4
+ export interface CopyToClipboardButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onCopy'> {
5
5
  textToCopy: string;
6
6
  copiedLabel?: string;
7
7
  variant?: CopyToClipboardButtonVariant;
8
+ /** Called with the copied text after it is written to the clipboard. */
9
+ onCopy?: (text: string) => void;
10
+ /** Called when writing to the clipboard fails. */
11
+ onCopyError?: (error: unknown) => void;
8
12
  }
@@ -1,9 +1,10 @@
1
1
  const require_CopyToClipboardButton = require("../Button/CopyToClipboardButton/CopyToClipboardButton.cjs");
2
2
  const require_CodeBlock_style = require("./CodeBlock.style.cjs");
3
+ const require_HighlightedCode = require("./components/HighlightedCode/HighlightedCode.cjs");
3
4
  let react_jsx_runtime = require("react/jsx-runtime");
4
5
  let react = require("react");
5
6
  //#region src/CodeBlock/CodeBlock.tsx
6
- var useIsScrollable = (code, overflow, maxHeight) => {
7
+ var useIsScrollable = ({ code, overflow, maxHeight, language }) => {
7
8
  const ref = (0, react.useRef)(null);
8
9
  const [isScrollable, setIsScrollable] = (0, react.useState)(false);
9
10
  (0, react.useLayoutEffect)(() => {
@@ -18,26 +19,40 @@ var useIsScrollable = (code, overflow, maxHeight) => {
18
19
  }, [
19
20
  code,
20
21
  overflow,
21
- maxHeight
22
+ maxHeight,
23
+ language
22
24
  ]);
23
25
  return [ref, isScrollable];
24
26
  };
25
- var CodeBlock = (0, react.forwardRef)(({ code, copyLabel, overflow = "scroll", maxHeight, size = "M", "aria-label": ariaLabel = "Code", ...restProps }, ref) => {
26
- const [preRef, isScrollable] = useIsScrollable(code, overflow, maxHeight);
27
+ var CodeBlock = (0, react.forwardRef)(({ code, language, copyLabel, overflow = "scroll", maxHeight, size = "M", "aria-label": ariaLabel = "Code", ...restProps }, ref) => {
28
+ const [preRef, isScrollable] = useIsScrollable({
29
+ code,
30
+ overflow,
31
+ maxHeight,
32
+ language
33
+ });
34
+ const preProps = {
35
+ $size: size,
36
+ $overflow: overflow,
37
+ $maxHeight: maxHeight,
38
+ $withCopy: Boolean(copyLabel),
39
+ ...isScrollable && {
40
+ tabIndex: 0,
41
+ role: "region",
42
+ "aria-label": ariaLabel
43
+ }
44
+ };
27
45
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CodeBlock_style.CodeBlock, {
28
46
  ref,
29
47
  ...restProps,
30
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockPre, {
48
+ children: [language ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_HighlightedCode.default, {
31
49
  ref: preRef,
32
- $size: size,
33
- $overflow: overflow,
34
- $maxHeight: maxHeight,
35
- $withCopy: Boolean(copyLabel),
36
- ...isScrollable && {
37
- tabIndex: 0,
38
- role: "region",
39
- "aria-label": ariaLabel
40
- },
50
+ code,
51
+ language,
52
+ ...preProps
53
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockPre, {
54
+ ref: preRef,
55
+ ...preProps,
41
56
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockCode, { children: code })
42
57
  }), copyLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockCopy, {
43
58
  $size: size,
@@ -1,9 +1,10 @@
1
1
  import CopyToClipboardButton from "../Button/CopyToClipboardButton/CopyToClipboardButton.js";
2
2
  import { CodeBlock as CodeBlock$1, CodeBlockCode, CodeBlockCopy, CodeBlockPre } from "./CodeBlock.style.js";
3
+ import HighlightedCode from "./components/HighlightedCode/HighlightedCode.js";
3
4
  import { jsx, jsxs } from "react/jsx-runtime";
4
5
  import { forwardRef, useLayoutEffect, useRef, useState } from "react";
5
6
  //#region src/CodeBlock/CodeBlock.tsx
6
- var useIsScrollable = (code, overflow, maxHeight) => {
7
+ var useIsScrollable = ({ code, overflow, maxHeight, language }) => {
7
8
  const ref = useRef(null);
8
9
  const [isScrollable, setIsScrollable] = useState(false);
9
10
  useLayoutEffect(() => {
@@ -18,26 +19,40 @@ var useIsScrollable = (code, overflow, maxHeight) => {
18
19
  }, [
19
20
  code,
20
21
  overflow,
21
- maxHeight
22
+ maxHeight,
23
+ language
22
24
  ]);
23
25
  return [ref, isScrollable];
24
26
  };
25
- var CodeBlock = forwardRef(({ code, copyLabel, overflow = "scroll", maxHeight, size = "M", "aria-label": ariaLabel = "Code", ...restProps }, ref) => {
26
- const [preRef, isScrollable] = useIsScrollable(code, overflow, maxHeight);
27
+ var CodeBlock = forwardRef(({ code, language, copyLabel, overflow = "scroll", maxHeight, size = "M", "aria-label": ariaLabel = "Code", ...restProps }, ref) => {
28
+ const [preRef, isScrollable] = useIsScrollable({
29
+ code,
30
+ overflow,
31
+ maxHeight,
32
+ language
33
+ });
34
+ const preProps = {
35
+ $size: size,
36
+ $overflow: overflow,
37
+ $maxHeight: maxHeight,
38
+ $withCopy: Boolean(copyLabel),
39
+ ...isScrollable && {
40
+ tabIndex: 0,
41
+ role: "region",
42
+ "aria-label": ariaLabel
43
+ }
44
+ };
27
45
  return /* @__PURE__ */ jsxs(CodeBlock$1, {
28
46
  ref,
29
47
  ...restProps,
30
- children: [/* @__PURE__ */ jsx(CodeBlockPre, {
48
+ children: [language ? /* @__PURE__ */ jsx(HighlightedCode, {
31
49
  ref: preRef,
32
- $size: size,
33
- $overflow: overflow,
34
- $maxHeight: maxHeight,
35
- $withCopy: Boolean(copyLabel),
36
- ...isScrollable && {
37
- tabIndex: 0,
38
- role: "region",
39
- "aria-label": ariaLabel
40
- },
50
+ code,
51
+ language,
52
+ ...preProps
53
+ }) : /* @__PURE__ */ jsx(CodeBlockPre, {
54
+ ref: preRef,
55
+ ...preProps,
41
56
  children: /* @__PURE__ */ jsx(CodeBlockCode, { children: code })
42
57
  }), copyLabel && /* @__PURE__ */ jsx(CodeBlockCopy, {
43
58
  $size: size,
@@ -1,11 +1,12 @@
1
1
  import { CodeBlockOverflow, CodeBlockSize } from './CodeBlock.types';
2
- export declare const CodeBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export declare const CodeBlockPre: import("styled-components").StyledComponent<"pre", any, {
2
+ export type CodeBlockPreStyleProps = {
4
3
  $size: CodeBlockSize;
5
4
  $overflow: CodeBlockOverflow;
6
5
  $maxHeight?: string;
7
6
  $withCopy: boolean;
8
- }, never>;
7
+ };
8
+ export declare const CodeBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
9
+ export declare const CodeBlockPre: import("styled-components").StyledComponent<"pre", any, CodeBlockPreStyleProps, never>;
9
10
  export declare const CodeBlockCode: import("styled-components").StyledComponent<"code", any, {}, never>;
10
11
  /** Spans the first code line, so the button centers on it */
11
12
  export declare const CodeBlockCopy: import("styled-components").StyledComponent<"div", any, {
@@ -5,6 +5,13 @@ var codeBlockOverflows = [
5
5
  "wrap",
6
6
  "ellipsis"
7
7
  ];
8
+ var codeBlockLanguages = [
9
+ "bash",
10
+ "json",
11
+ "python",
12
+ "typescript"
13
+ ];
8
14
  //#endregion
15
+ exports.codeBlockLanguages = codeBlockLanguages;
9
16
  exports.codeBlockOverflows = codeBlockOverflows;
10
17
  exports.codeBlockSizes = codeBlockSizes;
@@ -3,8 +3,12 @@ export declare const codeBlockSizes: readonly ["M", "S"];
3
3
  export type CodeBlockSize = (typeof codeBlockSizes)[number];
4
4
  export declare const codeBlockOverflows: readonly ["scroll", "wrap", "ellipsis"];
5
5
  export type CodeBlockOverflow = (typeof codeBlockOverflows)[number];
6
+ export declare const codeBlockLanguages: readonly ["bash", "json", "python", "typescript"];
7
+ export type CodeBlockLanguage = (typeof codeBlockLanguages)[number];
6
8
  export type OwnCodeBlockProps = {
7
9
  code: string;
10
+ /** Highlights the code's syntax */
11
+ language?: CodeBlockLanguage;
8
12
  /** Shows a copy button and is used as its accessible name */
9
13
  copyLabel?: string;
10
14
  /** How long lines behave: scroll horizontally, wrap, or truncate with an ellipsis */
@@ -5,5 +5,11 @@ var codeBlockOverflows = [
5
5
  "wrap",
6
6
  "ellipsis"
7
7
  ];
8
+ var codeBlockLanguages = [
9
+ "bash",
10
+ "json",
11
+ "python",
12
+ "typescript"
13
+ ];
8
14
  //#endregion
9
- export { codeBlockOverflows, codeBlockSizes };
15
+ export { codeBlockLanguages, codeBlockOverflows, codeBlockSizes };
@@ -0,0 +1,29 @@
1
+ const require_prism_light = require("../../../node_modules/react-syntax-highlighter/dist/esm/prism-light.cjs");
2
+ const require_CodeBlock_style = require("../../CodeBlock.style.cjs");
3
+ const require_HighlightedCode_constants = require("./HighlightedCode.constants.cjs");
4
+ let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ let react = require("react");
7
+ //#region src/CodeBlock/components/HighlightedCode/HighlightedCode.tsx
8
+ Object.entries(require_HighlightedCode_constants.grammars).forEach(([name, grammar]) => require_prism_light.default.registerLanguage(name, grammar));
9
+ require_prism_light.default.registerLanguage(require_HighlightedCode_constants.bashCommands.displayName, require_HighlightedCode_constants.bashCommands);
10
+ var HighlightedPre = ({ preRef, ...restProps }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockPre, {
11
+ ref: preRef,
12
+ ...restProps
13
+ });
14
+ var HighlightedCode = (0, react.forwardRef)(({ code, language, ...preProps }, ref) => {
15
+ const { mode } = (0, _redislabsdev_redis_ui_styles.useTheme)();
16
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_prism_light.default, {
17
+ language,
18
+ style: require_HighlightedCode_constants.syntaxStyles[mode],
19
+ wrapLongLines: preProps.$overflow === "wrap",
20
+ PreTag: HighlightedPre,
21
+ CodeTag: require_CodeBlock_style.CodeBlockCode,
22
+ preRef: ref,
23
+ ...preProps,
24
+ children: code
25
+ });
26
+ });
27
+ HighlightedCode.displayName = "HighlightedCode";
28
+ //#endregion
29
+ exports.default = HighlightedCode;
@@ -0,0 +1,34 @@
1
+ const require_bash = require("../../../node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.cjs");
2
+ const require_json = require("../../../node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.cjs");
3
+ const require_python = require("../../../node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.cjs");
4
+ const require_typescript = require("../../../node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.cjs");
5
+ const require_vs = require("../../../node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.cjs");
6
+ const require_vsc_dark_plus = require("../../../node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.cjs");
7
+ //#region src/CodeBlock/components/HighlightedCode/HighlightedCode.constants.ts
8
+ var grammars = {
9
+ bash: require_bash.default,
10
+ json: require_json.default,
11
+ python: require_python.default,
12
+ typescript: require_typescript.default
13
+ };
14
+ /** Colors bash commands, including `npx` and `pip`, as keywords */
15
+ var bashCommands = Object.assign((prism) => {
16
+ prism.languages.insertBefore("bash", "function", { "package-manager": {
17
+ pattern: /(^|[\s;|&]|[<>]\()(?:npx|pip)(?=$|[)\s;|&])/,
18
+ lookbehind: true,
19
+ alias: "keyword"
20
+ } });
21
+ prism.languages.bash.function.alias = "keyword";
22
+ }, { displayName: "bash-commands" });
23
+ var tokenColors = (style) => ({
24
+ ...Object.fromEntries(Object.entries(style).filter(([selector]) => !selector.includes("language-"))),
25
+ "pre[class*=\"language-\"]": {}
26
+ });
27
+ var syntaxStyles = {
28
+ light: tokenColors(require_vs.default),
29
+ dark: tokenColors(require_vsc_dark_plus.default)
30
+ };
31
+ //#endregion
32
+ exports.bashCommands = bashCommands;
33
+ exports.grammars = grammars;
34
+ exports.syntaxStyles = syntaxStyles;
@@ -0,0 +1,25 @@
1
+ import { CSSProperties } from 'react';
2
+ import { ThemeMode } from '@redis-ui/styles';
3
+ type Prism = {
4
+ languages: {
5
+ insertBefore: (inside: string, before: string, insert: Record<string, unknown>) => void;
6
+ bash: {
7
+ function: {
8
+ alias?: string;
9
+ };
10
+ };
11
+ };
12
+ };
13
+ type SyntaxStyle = Record<string, CSSProperties>;
14
+ export declare const grammars: {
15
+ bash: any;
16
+ json: any;
17
+ python: any;
18
+ typescript: any;
19
+ };
20
+ /** Colors bash commands, including `npx` and `pip`, as keywords */
21
+ export declare const bashCommands: ((prism: Prism) => void) & {
22
+ displayName: string;
23
+ };
24
+ export declare const syntaxStyles: Record<ThemeMode, SyntaxStyle>;
25
+ export {};
@@ -0,0 +1,32 @@
1
+ import bash_default from "../../../node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.js";
2
+ import json_default from "../../../node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.js";
3
+ import python_default from "../../../node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.js";
4
+ import typescript_default from "../../../node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.js";
5
+ import vs_default from "../../../node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.js";
6
+ import vsc_dark_plus_default from "../../../node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.js";
7
+ //#region src/CodeBlock/components/HighlightedCode/HighlightedCode.constants.ts
8
+ var grammars = {
9
+ bash: bash_default,
10
+ json: json_default,
11
+ python: python_default,
12
+ typescript: typescript_default
13
+ };
14
+ /** Colors bash commands, including `npx` and `pip`, as keywords */
15
+ var bashCommands = Object.assign((prism) => {
16
+ prism.languages.insertBefore("bash", "function", { "package-manager": {
17
+ pattern: /(^|[\s;|&]|[<>]\()(?:npx|pip)(?=$|[)\s;|&])/,
18
+ lookbehind: true,
19
+ alias: "keyword"
20
+ } });
21
+ prism.languages.bash.function.alias = "keyword";
22
+ }, { displayName: "bash-commands" });
23
+ var tokenColors = (style) => ({
24
+ ...Object.fromEntries(Object.entries(style).filter(([selector]) => !selector.includes("language-"))),
25
+ "pre[class*=\"language-\"]": {}
26
+ });
27
+ var syntaxStyles = {
28
+ light: tokenColors(vs_default),
29
+ dark: tokenColors(vsc_dark_plus_default)
30
+ };
31
+ //#endregion
32
+ export { bashCommands, grammars, syntaxStyles };
@@ -0,0 +1,6 @@
1
+ import * as S from '../../CodeBlock.style';
2
+ declare const HighlightedCode: import("react").ForwardRefExoticComponent<S.CodeBlockPreStyleProps & Omit<import("react").HTMLAttributes<HTMLPreElement>, "style" | "children"> & {
3
+ code: string;
4
+ language: import("../..").CodeBlockLanguage;
5
+ } & import("react").RefAttributes<HTMLPreElement>>;
6
+ export default HighlightedCode;
@@ -0,0 +1,29 @@
1
+ import SyntaxHighlighter from "../../../node_modules/react-syntax-highlighter/dist/esm/prism-light.js";
2
+ import { CodeBlockCode, CodeBlockPre } from "../../CodeBlock.style.js";
3
+ import { bashCommands, grammars, syntaxStyles } from "./HighlightedCode.constants.js";
4
+ import { useTheme } from "@redis-ui/styles";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { forwardRef } from "react";
7
+ //#region src/CodeBlock/components/HighlightedCode/HighlightedCode.tsx
8
+ Object.entries(grammars).forEach(([name, grammar]) => SyntaxHighlighter.registerLanguage(name, grammar));
9
+ SyntaxHighlighter.registerLanguage(bashCommands.displayName, bashCommands);
10
+ var HighlightedPre = ({ preRef, ...restProps }) => /* @__PURE__ */ jsx(CodeBlockPre, {
11
+ ref: preRef,
12
+ ...restProps
13
+ });
14
+ var HighlightedCode = forwardRef(({ code, language, ...preProps }, ref) => {
15
+ const { mode } = useTheme();
16
+ return /* @__PURE__ */ jsx(SyntaxHighlighter, {
17
+ language,
18
+ style: syntaxStyles[mode],
19
+ wrapLongLines: preProps.$overflow === "wrap",
20
+ PreTag: HighlightedPre,
21
+ CodeTag: CodeBlockCode,
22
+ preRef: ref,
23
+ ...preProps,
24
+ children: code
25
+ });
26
+ });
27
+ HighlightedCode.displayName = "HighlightedCode";
28
+ //#endregion
29
+ export { HighlightedCode as default };
@@ -0,0 +1,10 @@
1
+ import { HTMLAttributes, Ref } from 'react';
2
+ import { CodeBlockLanguage } from '../../CodeBlock.types';
3
+ import { CodeBlockPreStyleProps } from '../../CodeBlock.style';
4
+ export type HighlightedPreProps = CodeBlockPreStyleProps & HTMLAttributes<HTMLPreElement> & {
5
+ preRef: Ref<HTMLPreElement>;
6
+ };
7
+ export type HighlightedCodeProps = CodeBlockPreStyleProps & Omit<HTMLAttributes<HTMLPreElement>, 'children' | 'style'> & {
8
+ code: string;
9
+ language: CodeBlockLanguage;
10
+ };
@@ -3,11 +3,12 @@ const require_StatusIndicator = require("../components/StatusIndicator/StatusInd
3
3
  const require_LoadingIndicator = require("../components/LoadingIndicator/LoadingIndicator.cjs");
4
4
  const require_Compose_style = require("../components/Compose/Compose.style.cjs");
5
5
  const require_ResetButton = require("../components/ResetButton/ResetButton.cjs");
6
+ const require_CopyButton = require("../components/CopyButton/CopyButton.cjs");
6
7
  const require_TextCompose = require("../components/Compose/TextCompose.cjs");
7
8
  let react_jsx_runtime = require("react/jsx-runtime");
8
9
  let react = require("react");
9
10
  //#region src/Inputs/Input/Input.tsx
10
- var Input = Object.assign((0, react.forwardRef)(({ id, className, style, readOnly, loading, variant, error, valid, value, defaultValue, onChange, parser, formatter, allowReset = false, ...restProps }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Input.Compose, {
11
+ var Input = Object.assign((0, react.forwardRef)(({ id, className, style, readOnly, loading, variant, error, valid, value, defaultValue, onChange, parser, formatter, allowReset = false, showCopyButton = false, copyButtonProps, ...restProps }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Input.Compose, {
11
12
  id,
12
13
  className,
13
14
  style,
@@ -21,12 +22,17 @@ var Input = Object.assign((0, react.forwardRef)(({ id, className, style, readOnl
21
22
  parser,
22
23
  formatter,
23
24
  readonlyProps: restProps,
25
+ boxedReadonly: showCopyButton,
24
26
  children: [
25
27
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.Tag, {
26
28
  ref,
27
29
  ...restProps
28
30
  }),
29
31
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.ResetButton, { allowReset }),
32
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.CopyButton, {
33
+ ...copyButtonProps,
34
+ showCopyButton
35
+ }),
30
36
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.StatusIndicator, {}),
31
37
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.LoadingIndicator, { loading })
32
38
  ]
@@ -36,7 +42,8 @@ var Input = Object.assign((0, react.forwardRef)(({ id, className, style, readOnl
36
42
  LoadingIndicator: require_LoadingIndicator.default,
37
43
  Tag: require_InputTag.default,
38
44
  ReadonlyValue: require_Compose_style.ReadonlyValue,
39
- ResetButton: require_ResetButton.ResetButton
45
+ ResetButton: require_ResetButton.ResetButton,
46
+ CopyButton: require_CopyButton.CopyButton
40
47
  });
41
48
  //#endregion
42
49
  exports.default = Input;
@@ -1,5 +1,7 @@
1
1
  import { RestInputProps } from './Input.types';
2
- declare const Input: import("react").ForwardRefExoticComponent<import("../components/Compose/CommonCompose.types").CommonInputComposeProps & Omit<import("../components/Context/InputValueProvider").InputValueProviderProps, "children"> & import("../components/InputTag/InputTag.types").InputTagProps & import("../components/LoadingIndicator/LoadingIndicator.types").LoadingIndicatorProps & import("../components/ResetButton/ResetButton.types").ResetButtonProps & RestInputProps & import("react").RefAttributes<HTMLInputElement>> & {
2
+ declare const Input: import("react").ForwardRefExoticComponent<import("../components/Compose/CommonCompose.types").CommonInputComposeProps & Omit<import("../components/Context/InputValueProvider").InputValueProviderProps, "children"> & import("../components/InputTag/InputTag.types").InputTagProps & import("../components/LoadingIndicator/LoadingIndicator.types").LoadingIndicatorProps & import("../components/ResetButton/ResetButton.types").ResetButtonProps & import("../components/CopyButton/CopyButton.types").CopyButtonProps & {
3
+ copyButtonProps?: import("../components/CopyButton/CopyButton.types").RestCopyButtonProps;
4
+ } & RestInputProps & import("react").RefAttributes<HTMLInputElement>> & {
3
5
  StatusIndicator: ({ className, style, size, ...restProps }: import("@redis-ui/icons").MonochromeIconProps & Pick<import("react").HTMLAttributes<unknown>, "className" | "style">) => import("react/jsx-runtime").JSX.Element | null;
4
6
  Compose: ({ value, defaultValue, onChange, parser, formatter, ...restProps }: import("../components/Compose/TextCompose.types").TextInputComposeProps & import("../components/Compose/TextCompose.types").RestTextInputComposeProps) => import("react/jsx-runtime").JSX.Element;
5
7
  LoadingIndicator: ({ loading, ...restProps }: import("../components/LoadingIndicator/LoadingIndicator.types").LoadingIndicatorProps & import("../components/LoadingIndicator/LoadingIndicator.types").RestLoadingIndicatorProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -8,5 +10,6 @@ declare const Input: import("react").ForwardRefExoticComponent<import("../compon
8
10
  readOnly: boolean;
9
11
  }, "readOnly">;
10
12
  ResetButton: ({ size, icon, allowReset, onClick, onMouseDown, ...restProps }: import("../components/ResetButton/ResetButton.types").RestResetButtonProps & import("../components/ResetButton/ResetButton.types").ResetButtonProps) => import("react/jsx-runtime").JSX.Element | null;
13
+ CopyButton: ({ showCopyButton, textToCopy, onMouseDown, ...restProps }: import("../components/CopyButton/CopyButton.types").RestCopyButtonProps & import("../components/CopyButton/CopyButton.types").CopyButtonProps) => import("react/jsx-runtime").JSX.Element | null;
11
14
  };
12
15
  export default Input;
@@ -3,11 +3,12 @@ import StatusIndicator from "../components/StatusIndicator/StatusIndicator.js";
3
3
  import LoadingIndicator from "../components/LoadingIndicator/LoadingIndicator.js";
4
4
  import { ReadonlyValue } from "../components/Compose/Compose.style.js";
5
5
  import { ResetButton } from "../components/ResetButton/ResetButton.js";
6
+ import { CopyButton } from "../components/CopyButton/CopyButton.js";
6
7
  import TextInputCompose from "../components/Compose/TextCompose.js";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
9
  import { forwardRef } from "react";
9
10
  //#region src/Inputs/Input/Input.tsx
10
- var Input = Object.assign(forwardRef(({ id, className, style, readOnly, loading, variant, error, valid, value, defaultValue, onChange, parser, formatter, allowReset = false, ...restProps }, ref) => /* @__PURE__ */ jsxs(Input.Compose, {
11
+ var Input = Object.assign(forwardRef(({ id, className, style, readOnly, loading, variant, error, valid, value, defaultValue, onChange, parser, formatter, allowReset = false, showCopyButton = false, copyButtonProps, ...restProps }, ref) => /* @__PURE__ */ jsxs(Input.Compose, {
11
12
  id,
12
13
  className,
13
14
  style,
@@ -21,12 +22,17 @@ var Input = Object.assign(forwardRef(({ id, className, style, readOnly, loading,
21
22
  parser,
22
23
  formatter,
23
24
  readonlyProps: restProps,
25
+ boxedReadonly: showCopyButton,
24
26
  children: [
25
27
  /* @__PURE__ */ jsx(Input.Tag, {
26
28
  ref,
27
29
  ...restProps
28
30
  }),
29
31
  /* @__PURE__ */ jsx(Input.ResetButton, { allowReset }),
32
+ /* @__PURE__ */ jsx(Input.CopyButton, {
33
+ ...copyButtonProps,
34
+ showCopyButton
35
+ }),
30
36
  /* @__PURE__ */ jsx(Input.StatusIndicator, {}),
31
37
  /* @__PURE__ */ jsx(Input.LoadingIndicator, { loading })
32
38
  ]
@@ -36,7 +42,8 @@ var Input = Object.assign(forwardRef(({ id, className, style, readOnly, loading,
36
42
  LoadingIndicator,
37
43
  Tag: InputTag,
38
44
  ReadonlyValue,
39
- ResetButton
45
+ ResetButton,
46
+ CopyButton
40
47
  });
41
48
  //#endregion
42
49
  export { Input as default };
@@ -3,5 +3,9 @@ import { TextInputComposeProps } from '../components/Compose/TextCompose.types';
3
3
  import { InputTagProps } from '../components/InputTag/InputTag.types';
4
4
  import { LoadingIndicatorProps } from '../components/LoadingIndicator/LoadingIndicator.types';
5
5
  import { ResetButtonProps } from '../components/ResetButton/ResetButton.types';
6
- export type InputProps = TextInputComposeProps & InputTagProps & LoadingIndicatorProps & ResetButtonProps;
6
+ import { CopyButtonProps, RestCopyButtonProps } from '../components/CopyButton/CopyButton.types';
7
+ export type InputProps = TextInputComposeProps & InputTagProps & LoadingIndicatorProps & ResetButtonProps & CopyButtonProps & {
8
+ /** Props of the copy button rendered when `showCopyButton` is set, for example `aria-label` or `onCopy`. */
9
+ copyButtonProps?: RestCopyButtonProps;
10
+ };
7
11
  export type RestInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'children' | 'defaultValue' | 'value' | 'onChange' | 'readOnly'>;
@@ -1,4 +1,4 @@
1
1
  import { RestTextInputComposeProps, TextInputComposeProps } from '../../../components/Compose/TextCompose.types';
2
2
  import { PasswordExposureProps } from '../PasswordInput.context.types';
3
3
  export type PasswordInputComposeProps = Omit<TextInputComposeProps, 'parser' | 'formatter'> & PasswordExposureProps;
4
- export type RestPasswordInputComposeProps = Omit<RestTextInputComposeProps, 'readonlyRender'>;
4
+ export type RestPasswordInputComposeProps = Omit<RestTextInputComposeProps, 'readonlyRender' | 'boxedReadonly'>;