@redis-ui/components 51.15.0 → 51.16.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 (42) hide show
  1. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.cjs +27 -15
  2. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.js +27 -15
  3. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.cjs +28 -1
  4. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.d.ts +2 -0
  5. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.js +29 -2
  6. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.cjs +4 -0
  7. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.d.ts +3 -0
  8. package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.js +4 -1
  9. package/dist/CodeBlock/CodeBlock.cjs +47 -0
  10. package/dist/CodeBlock/CodeBlock.d.ts +2 -0
  11. package/dist/CodeBlock/CodeBlock.js +47 -0
  12. package/dist/CodeBlock/CodeBlock.style.cjs +49 -0
  13. package/dist/CodeBlock/CodeBlock.style.d.ts +10 -0
  14. package/dist/CodeBlock/CodeBlock.style.js +44 -0
  15. package/dist/CodeBlock/CodeBlock.types.cjs +4 -0
  16. package/dist/CodeBlock/CodeBlock.types.d.ts +15 -0
  17. package/dist/CodeBlock/CodeBlock.types.js +4 -0
  18. package/dist/CodeBlock/index.d.ts +2 -0
  19. package/dist/CodeBlock/index.js +2 -0
  20. package/dist/Drawer/components/Description/Description.cjs +1 -1
  21. package/dist/Drawer/components/Description/Description.js +1 -1
  22. package/dist/Drawer/components/Header/components/Title/Title.cjs +1 -1
  23. package/dist/Drawer/components/Header/components/Title/Title.js +1 -1
  24. package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.cjs +1 -1
  25. package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.js +1 -1
  26. package/dist/Inputs/components/InputTag/InputTag.cjs +1 -1
  27. package/dist/Inputs/components/InputTag/InputTag.js +1 -1
  28. package/dist/Modal/components/Content/components/Description/Description.cjs +1 -1
  29. package/dist/Modal/components/Content/components/Description/Description.js +1 -1
  30. package/dist/Modal/components/Content/components/Header/components/Title/Title.cjs +1 -1
  31. package/dist/Modal/components/Content/components/Header/components/Title/Title.js +1 -1
  32. package/dist/Select/components/Trigger/components/Compose/Compose.cjs +1 -1
  33. package/dist/Select/components/Trigger/components/Compose/Compose.js +1 -1
  34. package/dist/SideBar/components/CollapseButton/CollapseButton.cjs +1 -1
  35. package/dist/SideBar/components/CollapseButton/CollapseButton.js +1 -1
  36. package/dist/index.cjs +7 -1
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.js +5 -2
  39. package/package.json +2 -2
  40. package/skills/redis-ui-components/SKILL.md +1 -0
  41. package/skills/redis-ui-components/references/CodeBlock.md +79 -0
  42. package/skills/redis-ui-components/references/CopyToClipboardButton.md +37 -1
@@ -1,12 +1,16 @@
1
1
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_ScreenReaderAnnounce = require("../../ScreenReaderAnnounce/ScreenReaderAnnounce.cjs");
2
3
  const require_CopyToClipboardButton_style = require("./CopyToClipboardButton.style.cjs");
4
+ let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
3
5
  let react_jsx_runtime = require("react/jsx-runtime");
4
6
  let react = require("react");
5
7
  react = require_runtime.__toESM(react, 1);
6
8
  let _redislabsdev_redis_ui_icons = require("@redis-ui/icons");
7
9
  //#region src/Button/CopyToClipboardButton/CopyToClipboardButton.tsx
8
10
  var COPIED_STATE_DURATION = 1500;
9
- var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel, ...restProps }, ref) => {
11
+ var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel, variant = "default", ...restProps }, ref) => {
12
+ const { iconSize } = (0, _redislabsdev_redis_ui_styles.useTheme)().components.copyToClipboardButton.variants.outline;
13
+ const iconProps = variant === "outline" ? { customSize: iconSize } : { size: "L" };
10
14
  const [isCopied, setIsCopied] = (0, react.useState)(false);
11
15
  const timeoutRef = (0, react.useRef)();
12
16
  (0, react.useEffect)(() => {
@@ -25,21 +29,29 @@ var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel,
25
29
  } catch {}
26
30
  }, [textToCopy]);
27
31
  const ariaLabel = isCopied && copiedLabel ? copiedLabel : restProps["aria-label"] || "Copy";
28
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CopyToClipboardButton_style.CopyToClipboardWrapper, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyToClipboardButton_style.CopyToClipboardButton, {
29
- type: "button",
30
- ref,
31
- onClick: handleClick,
32
- $isCopied: isCopied,
33
- ...restProps,
34
- "aria-label": ariaLabel,
35
- children: isCopied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_redislabsdev_redis_ui_icons.ToastCheckIcon, {
36
- size: "L",
37
- "aria-hidden": true
38
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_redislabsdev_redis_ui_icons.CopyIcon, {
39
- size: "L",
40
- "aria-hidden": true
32
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CopyToClipboardButton_style.CopyToClipboardWrapper, { children: [
33
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyToClipboardButton_style.CopyToClipboardButton, {
34
+ type: "button",
35
+ ref,
36
+ onClick: handleClick,
37
+ $isCopied: isCopied,
38
+ $variant: variant,
39
+ ...restProps,
40
+ "aria-label": ariaLabel,
41
+ children: isCopied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_redislabsdev_redis_ui_icons.ToastCheckIcon, {
42
+ ...iconProps,
43
+ "aria-hidden": true
44
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_redislabsdev_redis_ui_icons.CopyIcon, {
45
+ ...iconProps,
46
+ "aria-hidden": true
47
+ })
48
+ }),
49
+ isCopied && copiedLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyToClipboardButton_style.CopiedLabel, { children: copiedLabel }),
50
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ScreenReaderAnnounce.ScreenReaderAnnounce, {
51
+ text: isCopied ? copiedLabel || "Copied" : "",
52
+ role: "status"
41
53
  })
42
- }), isCopied && copiedLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyToClipboardButton_style.CopiedLabel, { children: copiedLabel })] });
54
+ ] });
43
55
  });
44
56
  //#endregion
45
57
  exports.default = CopyToClipboardButton;
@@ -1,10 +1,14 @@
1
+ import { ScreenReaderAnnounce } from "../../ScreenReaderAnnounce/ScreenReaderAnnounce.js";
1
2
  import { CopiedLabel, CopyToClipboardButton as CopyToClipboardButton$1, CopyToClipboardWrapper } from "./CopyToClipboardButton.style.js";
3
+ import { useTheme } from "@redis-ui/styles";
2
4
  import { jsx, jsxs } from "react/jsx-runtime";
3
5
  import React, { useCallback, useEffect, useRef, useState } from "react";
4
6
  import { CopyIcon, ToastCheckIcon } from "@redis-ui/icons";
5
7
  //#region src/Button/CopyToClipboardButton/CopyToClipboardButton.tsx
6
8
  var COPIED_STATE_DURATION = 1500;
7
- var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, ...restProps }, ref) => {
9
+ var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, variant = "default", ...restProps }, ref) => {
10
+ const { iconSize } = useTheme().components.copyToClipboardButton.variants.outline;
11
+ const iconProps = variant === "outline" ? { customSize: iconSize } : { size: "L" };
8
12
  const [isCopied, setIsCopied] = useState(false);
9
13
  const timeoutRef = useRef();
10
14
  useEffect(() => {
@@ -23,21 +27,29 @@ var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, ...rest
23
27
  } catch {}
24
28
  }, [textToCopy]);
25
29
  const ariaLabel = isCopied && copiedLabel ? copiedLabel : restProps["aria-label"] || "Copy";
26
- return /* @__PURE__ */ jsxs(CopyToClipboardWrapper, { children: [/* @__PURE__ */ jsx(CopyToClipboardButton$1, {
27
- type: "button",
28
- ref,
29
- onClick: handleClick,
30
- $isCopied: isCopied,
31
- ...restProps,
32
- "aria-label": ariaLabel,
33
- children: isCopied ? /* @__PURE__ */ jsx(ToastCheckIcon, {
34
- size: "L",
35
- "aria-hidden": true
36
- }) : /* @__PURE__ */ jsx(CopyIcon, {
37
- size: "L",
38
- "aria-hidden": true
30
+ return /* @__PURE__ */ jsxs(CopyToClipboardWrapper, { children: [
31
+ /* @__PURE__ */ jsx(CopyToClipboardButton$1, {
32
+ type: "button",
33
+ ref,
34
+ onClick: handleClick,
35
+ $isCopied: isCopied,
36
+ $variant: variant,
37
+ ...restProps,
38
+ "aria-label": ariaLabel,
39
+ children: isCopied ? /* @__PURE__ */ jsx(ToastCheckIcon, {
40
+ ...iconProps,
41
+ "aria-hidden": true
42
+ }) : /* @__PURE__ */ jsx(CopyIcon, {
43
+ ...iconProps,
44
+ "aria-hidden": true
45
+ })
46
+ }),
47
+ isCopied && copiedLabel && /* @__PURE__ */ jsx(CopiedLabel, { children: copiedLabel }),
48
+ /* @__PURE__ */ jsx(ScreenReaderAnnounce, {
49
+ text: isCopied ? copiedLabel || "Copied" : "",
50
+ role: "status"
39
51
  })
40
- }), isCopied && copiedLabel && /* @__PURE__ */ jsx(CopiedLabel, { children: copiedLabel })] });
52
+ ] });
41
53
  });
42
54
  //#endregion
43
55
  export { CopyToClipboardButton as default };
@@ -18,11 +18,38 @@ var CopyToClipboardButton = styled_components.default.button.withConfig({
18
18
  ";}&:active:not(:disabled){background-color:",
19
19
  ";}&:disabled{cursor:not-allowed;color:",
20
20
  ";}",
21
+ " ",
21
22
  ""
22
23
  ], () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.iconButton.borderRadius, ({ $isCopied }) => {
23
24
  const theme = (0, _redislabsdev_redis_ui_styles.useTheme)();
24
25
  return $isCopied ? theme.semantic.color.icon.success500 : theme.components.iconButton.states?.normal?.textColor;
25
- }, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.iconButton.states?.hover?.bgColor, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.iconButton.states?.active?.bgColor, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.iconButton.states?.disabled?.textColor, (0, _redislabsdev_redis_ui_styles.getFocusStyle)());
26
+ }, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.iconButton.states?.hover?.bgColor, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.iconButton.states?.active?.bgColor, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.iconButton.states?.disabled?.textColor, (0, _redislabsdev_redis_ui_styles.getFocusStyle)(), ({ $variant, $isCopied }) => {
27
+ const { size, borderRadius, states } = (0, _redislabsdev_redis_ui_styles.useTheme)().components.copyToClipboardButton.variants.outline;
28
+ if ($variant !== "outline") return;
29
+ const state = $isCopied ? states.copied : states.normal;
30
+ const hover = $isCopied ? states.copied : states.hover;
31
+ return styled_components.css`
32
+ width: ${size};
33
+ height: ${size};
34
+ border: 1px solid ${state.borderColor};
35
+ border-radius: ${borderRadius};
36
+ background-color: ${state.bgColor};
37
+ color: ${state.iconColor};
38
+
39
+ &:hover:not(:disabled),
40
+ &:active:not(:disabled) {
41
+ border-color: ${hover.borderColor};
42
+ background-color: ${hover.bgColor};
43
+ color: ${hover.iconColor};
44
+ }
45
+
46
+ &:disabled {
47
+ border-color: ${states.disabled.borderColor};
48
+ background-color: ${states.disabled.bgColor};
49
+ color: ${states.disabled.iconColor};
50
+ }
51
+ `;
52
+ });
26
53
  var CopiedLabel = (0, styled_components.default)(require_Typography.default.Body).attrs({
27
54
  component: "span",
28
55
  size: "S"
@@ -1,6 +1,8 @@
1
+ import { CopyToClipboardButtonVariant } from './CopyToClipboardButton.types';
1
2
  export declare const CopyToClipboardWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
3
  export declare const CopyToClipboardButton: import("styled-components").StyledComponent<"button", any, {
3
4
  $isCopied?: boolean;
5
+ $variant: CopyToClipboardButtonVariant;
4
6
  }, never>;
5
7
  export declare const CopiedLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../..").TypographyBodyProps & import("react").RefAttributes<HTMLElement>>, any, {
6
8
  component: "span";
@@ -1,5 +1,5 @@
1
1
  import Typography from "../../Typography/Typography.js";
2
- import _styled from "styled-components";
2
+ import _styled, { css } from "styled-components";
3
3
  import { getFocusStyle, useTheme } from "@redis-ui/styles";
4
4
  //#region src/Button/CopyToClipboardButton/CopyToClipboardButton.style.ts
5
5
  var CopyToClipboardWrapper = _styled.div.withConfig({
@@ -16,11 +16,38 @@ var CopyToClipboardButton = _styled.button.withConfig({
16
16
  ";}&:active:not(:disabled){background-color:",
17
17
  ";}&:disabled{cursor:not-allowed;color:",
18
18
  ";}",
19
+ " ",
19
20
  ""
20
21
  ], () => useTheme().components.iconButton.borderRadius, ({ $isCopied }) => {
21
22
  const theme = useTheme();
22
23
  return $isCopied ? theme.semantic.color.icon.success500 : theme.components.iconButton.states?.normal?.textColor;
23
- }, () => useTheme().components.iconButton.states?.hover?.bgColor, () => useTheme().components.iconButton.states?.active?.bgColor, () => useTheme().components.iconButton.states?.disabled?.textColor, getFocusStyle());
24
+ }, () => useTheme().components.iconButton.states?.hover?.bgColor, () => useTheme().components.iconButton.states?.active?.bgColor, () => useTheme().components.iconButton.states?.disabled?.textColor, getFocusStyle(), ({ $variant, $isCopied }) => {
25
+ const { size, borderRadius, states } = useTheme().components.copyToClipboardButton.variants.outline;
26
+ if ($variant !== "outline") return;
27
+ const state = $isCopied ? states.copied : states.normal;
28
+ const hover = $isCopied ? states.copied : states.hover;
29
+ return css`
30
+ width: ${size};
31
+ height: ${size};
32
+ border: 1px solid ${state.borderColor};
33
+ border-radius: ${borderRadius};
34
+ background-color: ${state.bgColor};
35
+ color: ${state.iconColor};
36
+
37
+ &:hover:not(:disabled),
38
+ &:active:not(:disabled) {
39
+ border-color: ${hover.borderColor};
40
+ background-color: ${hover.bgColor};
41
+ color: ${hover.iconColor};
42
+ }
43
+
44
+ &:disabled {
45
+ border-color: ${states.disabled.borderColor};
46
+ background-color: ${states.disabled.bgColor};
47
+ color: ${states.disabled.iconColor};
48
+ }
49
+ `;
50
+ });
24
51
  var CopiedLabel = _styled(Typography.Body).attrs({
25
52
  component: "span",
26
53
  size: "S"
@@ -0,0 +1,4 @@
1
+ //#region src/Button/CopyToClipboardButton/CopyToClipboardButton.types.ts
2
+ var copyToClipboardButtonVariants = ["default", "outline"];
3
+ //#endregion
4
+ exports.copyToClipboardButtonVariants = copyToClipboardButtonVariants;
@@ -1,5 +1,8 @@
1
1
  import { ButtonHTMLAttributes } from 'react';
2
+ export declare const copyToClipboardButtonVariants: readonly ["default", "outline"];
3
+ export type CopyToClipboardButtonVariant = (typeof copyToClipboardButtonVariants)[number];
2
4
  export interface CopyToClipboardButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> {
3
5
  textToCopy: string;
4
6
  copiedLabel?: string;
7
+ variant?: CopyToClipboardButtonVariant;
5
8
  }
@@ -1 +1,4 @@
1
- export {};
1
+ //#region src/Button/CopyToClipboardButton/CopyToClipboardButton.types.ts
2
+ var copyToClipboardButtonVariants = ["default", "outline"];
3
+ //#endregion
4
+ export { copyToClipboardButtonVariants };
@@ -0,0 +1,47 @@
1
+ const require_CopyToClipboardButton = require("../Button/CopyToClipboardButton/CopyToClipboardButton.cjs");
2
+ const require_CodeBlock_style = require("./CodeBlock.style.cjs");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ let react = require("react");
5
+ //#region src/CodeBlock/CodeBlock.tsx
6
+ var useIsScrollable = (code, maxHeight) => {
7
+ const ref = (0, react.useRef)(null);
8
+ const [isScrollable, setIsScrollable] = (0, react.useState)(false);
9
+ (0, react.useLayoutEffect)(() => {
10
+ const el = ref.current;
11
+ if (!el) return;
12
+ const update = () => setIsScrollable(el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth);
13
+ update();
14
+ if (typeof ResizeObserver === "undefined") return;
15
+ const observer = new ResizeObserver(update);
16
+ observer.observe(el);
17
+ return () => observer.disconnect();
18
+ }, [code, maxHeight]);
19
+ return [ref, isScrollable];
20
+ };
21
+ var CodeBlock = (0, react.forwardRef)(({ code, copyLabel, wrap = false, maxHeight, size = "M", "aria-label": ariaLabel = "Code", ...restProps }, ref) => {
22
+ const [preRef, isScrollable] = useIsScrollable(code, maxHeight);
23
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CodeBlock_style.CodeBlock, {
24
+ ref,
25
+ ...restProps,
26
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockPre, {
27
+ ref: preRef,
28
+ $size: size,
29
+ $wrap: wrap,
30
+ $maxHeight: maxHeight,
31
+ $withCopy: Boolean(copyLabel),
32
+ ...isScrollable && {
33
+ tabIndex: 0,
34
+ role: "region",
35
+ "aria-label": ariaLabel
36
+ },
37
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockCode, { children: code })
38
+ }), copyLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockCopy, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyToClipboardButton.default, {
39
+ textToCopy: code,
40
+ "aria-label": copyLabel,
41
+ variant: "outline"
42
+ }) })]
43
+ });
44
+ });
45
+ CodeBlock.displayName = "CodeBlock";
46
+ //#endregion
47
+ exports.default = CodeBlock;
@@ -0,0 +1,2 @@
1
+ declare const CodeBlock: import("react").ForwardRefExoticComponent<import("./CodeBlock.types").OwnCodeBlockProps & import("./CodeBlock.types").RestCodeBlockProps & import("react").RefAttributes<HTMLDivElement>>;
2
+ export default CodeBlock;
@@ -0,0 +1,47 @@
1
+ import CopyToClipboardButton from "../Button/CopyToClipboardButton/CopyToClipboardButton.js";
2
+ import { CodeBlock as CodeBlock$1, CodeBlockCode, CodeBlockCopy, CodeBlockPre } from "./CodeBlock.style.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { forwardRef, useLayoutEffect, useRef, useState } from "react";
5
+ //#region src/CodeBlock/CodeBlock.tsx
6
+ var useIsScrollable = (code, maxHeight) => {
7
+ const ref = useRef(null);
8
+ const [isScrollable, setIsScrollable] = useState(false);
9
+ useLayoutEffect(() => {
10
+ const el = ref.current;
11
+ if (!el) return;
12
+ const update = () => setIsScrollable(el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth);
13
+ update();
14
+ if (typeof ResizeObserver === "undefined") return;
15
+ const observer = new ResizeObserver(update);
16
+ observer.observe(el);
17
+ return () => observer.disconnect();
18
+ }, [code, maxHeight]);
19
+ return [ref, isScrollable];
20
+ };
21
+ var CodeBlock = forwardRef(({ code, copyLabel, wrap = false, maxHeight, size = "M", "aria-label": ariaLabel = "Code", ...restProps }, ref) => {
22
+ const [preRef, isScrollable] = useIsScrollable(code, maxHeight);
23
+ return /* @__PURE__ */ jsxs(CodeBlock$1, {
24
+ ref,
25
+ ...restProps,
26
+ children: [/* @__PURE__ */ jsx(CodeBlockPre, {
27
+ ref: preRef,
28
+ $size: size,
29
+ $wrap: wrap,
30
+ $maxHeight: maxHeight,
31
+ $withCopy: Boolean(copyLabel),
32
+ ...isScrollable && {
33
+ tabIndex: 0,
34
+ role: "region",
35
+ "aria-label": ariaLabel
36
+ },
37
+ children: /* @__PURE__ */ jsx(CodeBlockCode, { children: code })
38
+ }), copyLabel && /* @__PURE__ */ jsx(CodeBlockCopy, { children: /* @__PURE__ */ jsx(CopyToClipboardButton, {
39
+ textToCopy: code,
40
+ "aria-label": copyLabel,
41
+ variant: "outline"
42
+ }) })]
43
+ });
44
+ });
45
+ CodeBlock.displayName = "CodeBlock";
46
+ //#endregion
47
+ export { CodeBlock as default };
@@ -0,0 +1,49 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ let styled_components = require("styled-components");
3
+ styled_components = require_runtime.__toESM(styled_components, 1);
4
+ let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
5
+ //#region src/CodeBlock/CodeBlock.style.ts
6
+ var CodeBlock = styled_components.default.div.withConfig({
7
+ displayName: "CodeBlockstyle__CodeBlock",
8
+ componentId: "RedisUI__sc-16pq9cs-0"
9
+ })(["position:relative;min-width:0;"]);
10
+ var CodeBlockPre = styled_components.default.pre.withConfig({
11
+ displayName: "CodeBlockstyle__CodeBlockPre",
12
+ componentId: "RedisUI__sc-16pq9cs-1"
13
+ })(["", ""], ({ $size, $wrap, $maxHeight, $withCopy }) => {
14
+ const theme = (0, _redislabsdev_redis_ui_styles.useTheme)().components.codeBlock;
15
+ return styled_components.css`
16
+ margin: 0;
17
+ padding: ${$withCopy ? theme.paddingWithCopy : theme.padding};
18
+ background-color: ${theme.bgColor};
19
+ color: ${theme.textColor};
20
+ border-radius: ${theme.borderRadius};
21
+ font-family: ${theme.fontFamily};
22
+ font-size: ${theme.sizes[$size].fontSize};
23
+ line-height: ${theme.lineHeight};
24
+ text-align: left;
25
+ overflow: auto;
26
+ max-height: ${$maxHeight ?? "none"};
27
+ white-space: ${$wrap ? "pre-wrap" : "pre"};
28
+ overflow-wrap: ${$wrap ? "anywhere" : "normal"};
29
+
30
+ ${(0, _redislabsdev_redis_ui_styles.getFocusStyle)()}
31
+ `;
32
+ });
33
+ var CodeBlockCode = styled_components.default.code.withConfig({
34
+ displayName: "CodeBlockstyle__CodeBlockCode",
35
+ componentId: "RedisUI__sc-16pq9cs-2"
36
+ })(["font:inherit;"]);
37
+ var CodeBlockCopy = styled_components.default.div.withConfig({
38
+ displayName: "CodeBlockstyle__CodeBlockCopy",
39
+ componentId: "RedisUI__sc-16pq9cs-3"
40
+ })([
41
+ "position:absolute;top:",
42
+ ";right:",
43
+ ";display:flex;"
44
+ ], () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.codeBlock.copyButtonOffset, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.codeBlock.copyButtonOffset);
45
+ //#endregion
46
+ exports.CodeBlock = CodeBlock;
47
+ exports.CodeBlockCode = CodeBlockCode;
48
+ exports.CodeBlockCopy = CodeBlockCopy;
49
+ exports.CodeBlockPre = CodeBlockPre;
@@ -0,0 +1,10 @@
1
+ import { 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, {
4
+ $size: CodeBlockSize;
5
+ $wrap: boolean;
6
+ $maxHeight?: string;
7
+ $withCopy: boolean;
8
+ }, never>;
9
+ export declare const CodeBlockCode: import("styled-components").StyledComponent<"code", any, {}, never>;
10
+ export declare const CodeBlockCopy: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,44 @@
1
+ import _styled, { css } from "styled-components";
2
+ import { getFocusStyle, useTheme } from "@redis-ui/styles";
3
+ //#region src/CodeBlock/CodeBlock.style.ts
4
+ var CodeBlock = _styled.div.withConfig({
5
+ displayName: "CodeBlockstyle__CodeBlock",
6
+ componentId: "RedisUI__sc-16pq9cs-0"
7
+ })(["position:relative;min-width:0;"]);
8
+ var CodeBlockPre = _styled.pre.withConfig({
9
+ displayName: "CodeBlockstyle__CodeBlockPre",
10
+ componentId: "RedisUI__sc-16pq9cs-1"
11
+ })(["", ""], ({ $size, $wrap, $maxHeight, $withCopy }) => {
12
+ const theme = useTheme().components.codeBlock;
13
+ return css`
14
+ margin: 0;
15
+ padding: ${$withCopy ? theme.paddingWithCopy : theme.padding};
16
+ background-color: ${theme.bgColor};
17
+ color: ${theme.textColor};
18
+ border-radius: ${theme.borderRadius};
19
+ font-family: ${theme.fontFamily};
20
+ font-size: ${theme.sizes[$size].fontSize};
21
+ line-height: ${theme.lineHeight};
22
+ text-align: left;
23
+ overflow: auto;
24
+ max-height: ${$maxHeight ?? "none"};
25
+ white-space: ${$wrap ? "pre-wrap" : "pre"};
26
+ overflow-wrap: ${$wrap ? "anywhere" : "normal"};
27
+
28
+ ${getFocusStyle()}
29
+ `;
30
+ });
31
+ var CodeBlockCode = _styled.code.withConfig({
32
+ displayName: "CodeBlockstyle__CodeBlockCode",
33
+ componentId: "RedisUI__sc-16pq9cs-2"
34
+ })(["font:inherit;"]);
35
+ var CodeBlockCopy = _styled.div.withConfig({
36
+ displayName: "CodeBlockstyle__CodeBlockCopy",
37
+ componentId: "RedisUI__sc-16pq9cs-3"
38
+ })([
39
+ "position:absolute;top:",
40
+ ";right:",
41
+ ";display:flex;"
42
+ ], () => useTheme().components.codeBlock.copyButtonOffset, () => useTheme().components.codeBlock.copyButtonOffset);
43
+ //#endregion
44
+ export { CodeBlock, CodeBlockCode, CodeBlockCopy, CodeBlockPre };
@@ -0,0 +1,4 @@
1
+ //#region src/CodeBlock/CodeBlock.types.ts
2
+ var codeBlockSizes = ["M", "S"];
3
+ //#endregion
4
+ exports.codeBlockSizes = codeBlockSizes;
@@ -0,0 +1,15 @@
1
+ import { HTMLAttributes } from 'react';
2
+ export declare const codeBlockSizes: readonly ["M", "S"];
3
+ export type CodeBlockSize = (typeof codeBlockSizes)[number];
4
+ export type OwnCodeBlockProps = {
5
+ code: string;
6
+ /** Shows a copy button and is used as its accessible name */
7
+ copyLabel?: string;
8
+ /** Wraps long lines instead of scrolling horizontally */
9
+ wrap?: boolean;
10
+ /** Scrolls vertically past this height */
11
+ maxHeight?: string;
12
+ size?: CodeBlockSize;
13
+ };
14
+ export type RestCodeBlockProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
15
+ export type CodeBlockProps = OwnCodeBlockProps & RestCodeBlockProps;
@@ -0,0 +1,4 @@
1
+ //#region src/CodeBlock/CodeBlock.types.ts
2
+ var codeBlockSizes = ["M", "S"];
3
+ //#endregion
4
+ export { codeBlockSizes };
@@ -0,0 +1,2 @@
1
+ export { default as CodeBlock } from './CodeBlock';
2
+ export * from './CodeBlock.types';
@@ -0,0 +1,2 @@
1
+ export { default as CodeBlock } from './CodeBlock';
2
+ export * from './CodeBlock.types';
@@ -1,5 +1,5 @@
1
- const require_react_utils = require("../../../Helpers/react.utils.cjs");
2
1
  const require_index = require("../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs");
2
+ const require_react_utils = require("../../../Helpers/react.utils.cjs");
3
3
  const require_index$1 = require("../../../node_modules/@radix-ui/react-dialog/dist/index.cjs");
4
4
  const require_Text = require("./components/Text/Text.cjs");
5
5
  const require_Description_style = require("./Description.style.cjs");
@@ -1,5 +1,5 @@
1
- import { childrenToString } from "../../../Helpers/react.utils.js";
2
1
  import { VisuallyHidden } from "../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.js";
2
+ import { childrenToString } from "../../../Helpers/react.utils.js";
3
3
  import { Description as Description$1 } from "../../../node_modules/@radix-ui/react-dialog/dist/index.js";
4
4
  import Text from "./components/Text/Text.js";
5
5
  import { DescriptionContainer } from "./Description.style.js";
@@ -1,5 +1,5 @@
1
- const require_react_utils = require("../../../../../Helpers/react.utils.cjs");
2
1
  const require_index = require("../../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs");
2
+ const require_react_utils = require("../../../../../Helpers/react.utils.cjs");
3
3
  const require_index$1 = require("../../../../../node_modules/@radix-ui/react-dialog/dist/index.cjs");
4
4
  const require_Title_style = require("./Title.style.cjs");
5
5
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -1,5 +1,5 @@
1
- import { childrenToString } from "../../../../../Helpers/react.utils.js";
2
1
  import { VisuallyHidden } from "../../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.js";
2
+ import { childrenToString } from "../../../../../Helpers/react.utils.js";
3
3
  import { Title as Title$1 } from "../../../../../node_modules/@radix-ui/react-dialog/dist/index.js";
4
4
  import { Title as Title$2 } from "./Title.style.js";
5
5
  import { jsx } from "react/jsx-runtime";
@@ -1,6 +1,6 @@
1
1
  const require_index = require("../../../../node_modules/@radix-ui/react-id/dist/index.cjs");
2
- const require_SharedId_context = require("../../../../Helpers/contexts/SharedId.context.cjs");
3
2
  const require_index$1 = require("../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs");
3
+ const require_SharedId_context = require("../../../../Helpers/contexts/SharedId.context.cjs");
4
4
  const require_Field_context = require("../../../components/Context/Field.context.cjs");
5
5
  const require_InputValue_context = require("../../../components/Context/InputValue.context.cjs");
6
6
  const require_FormField_context = require("../../../../FormField/FormField.context.cjs");
@@ -1,6 +1,6 @@
1
1
  import { useId } from "../../../../node_modules/@radix-ui/react-id/dist/index.js";
2
- import { useSharedId } from "../../../../Helpers/contexts/SharedId.context.js";
3
2
  import { VisuallyHidden } from "../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.js";
3
+ import { useSharedId } from "../../../../Helpers/contexts/SharedId.context.js";
4
4
  import { useErrorContent, useFieldDisabled } from "../../../components/Context/Field.context.js";
5
5
  import { useInputValueProps } from "../../../components/Context/InputValue.context.js";
6
6
  import { useFieldAdditionTextId, useFieldRequired, useFieldStatus } from "../../../../FormField/FormField.context.js";
@@ -1,6 +1,6 @@
1
1
  const require_index = require("../../../node_modules/@radix-ui/react-id/dist/index.cjs");
2
- const require_SharedId_context = require("../../../Helpers/contexts/SharedId.context.cjs");
3
2
  const require_index$1 = require("../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs");
3
+ const require_SharedId_context = require("../../../Helpers/contexts/SharedId.context.cjs");
4
4
  const require_Field_context = require("../Context/Field.context.cjs");
5
5
  const require_InputValue_context = require("../Context/InputValue.context.cjs");
6
6
  const require_FormField_context = require("../../../FormField/FormField.context.cjs");
@@ -1,6 +1,6 @@
1
1
  import { useId } from "../../../node_modules/@radix-ui/react-id/dist/index.js";
2
- import { useSharedId } from "../../../Helpers/contexts/SharedId.context.js";
3
2
  import { VisuallyHidden } from "../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.js";
3
+ import { useSharedId } from "../../../Helpers/contexts/SharedId.context.js";
4
4
  import { useErrorContent, useFieldDisabled } from "../Context/Field.context.js";
5
5
  import { useInputValueProps } from "../Context/InputValue.context.js";
6
6
  import { useFieldAdditionTextId, useFieldRequired, useFieldStatus } from "../../../FormField/FormField.context.js";
@@ -1,5 +1,5 @@
1
- const require_react_utils = require("../../../../../Helpers/react.utils.cjs");
2
1
  const require_index = require("../../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs");
2
+ const require_react_utils = require("../../../../../Helpers/react.utils.cjs");
3
3
  const require_index$1 = require("../../../../../node_modules/@radix-ui/react-dialog/dist/index.cjs");
4
4
  const require_Text = require("./components/Text/Text.cjs");
5
5
  const require_Description_style = require("./Description.style.cjs");
@@ -1,5 +1,5 @@
1
- import { childrenToString } from "../../../../../Helpers/react.utils.js";
2
1
  import { VisuallyHidden } from "../../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.js";
2
+ import { childrenToString } from "../../../../../Helpers/react.utils.js";
3
3
  import { Description as Description$1 } from "../../../../../node_modules/@radix-ui/react-dialog/dist/index.js";
4
4
  import Text from "./components/Text/Text.js";
5
5
  import { DescriptionContainer } from "./Description.style.js";
@@ -1,5 +1,5 @@
1
- const require_react_utils = require("../../../../../../../Helpers/react.utils.cjs");
2
1
  const require_index = require("../../../../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs");
2
+ const require_react_utils = require("../../../../../../../Helpers/react.utils.cjs");
3
3
  const require_index$1 = require("../../../../../../../node_modules/@radix-ui/react-dialog/dist/index.cjs");
4
4
  const require_Title_style = require("./Title.style.cjs");
5
5
  let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
@@ -1,5 +1,5 @@
1
- import { childrenToString } from "../../../../../../../Helpers/react.utils.js";
2
1
  import { VisuallyHidden } from "../../../../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.js";
2
+ import { childrenToString } from "../../../../../../../Helpers/react.utils.js";
3
3
  import { Title as Title$1 } from "../../../../../../../node_modules/@radix-ui/react-dialog/dist/index.js";
4
4
  import { Title as Title$2 } from "./Title.style.js";
5
5
  import { useTheme } from "@redis-ui/styles";
@@ -1,6 +1,6 @@
1
1
  const require_index = require("../../../../../node_modules/@radix-ui/react-id/dist/index.cjs");
2
- const require_SharedId_context = require("../../../../../Helpers/contexts/SharedId.context.cjs");
3
2
  const require_index$1 = require("../../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs");
3
+ const require_SharedId_context = require("../../../../../Helpers/contexts/SharedId.context.cjs");
4
4
  const require_Field_context = require("../../../../../Inputs/components/Context/Field.context.cjs");
5
5
  const require_FormField_context = require("../../../../../FormField/FormField.context.cjs");
6
6
  const require_index$2 = require("../../../../../node_modules/@radix-ui/react-select/dist/index.cjs");
@@ -1,6 +1,6 @@
1
1
  import { useId } from "../../../../../node_modules/@radix-ui/react-id/dist/index.js";
2
- import { useSharedId } from "../../../../../Helpers/contexts/SharedId.context.js";
3
2
  import { VisuallyHidden } from "../../../../../packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.js";
3
+ import { useSharedId } from "../../../../../Helpers/contexts/SharedId.context.js";
4
4
  import { useErrorContent } from "../../../../../Inputs/components/Context/Field.context.js";
5
5
  import { useFieldAdditionTextId, useFieldRequired, useFieldStatus } from "../../../../../FormField/FormField.context.js";
6
6
  import { Trigger } from "../../../../../node_modules/@radix-ui/react-select/dist/index.js";
@@ -1,5 +1,5 @@
1
- const require_Tooltip = require("../../../Tooltip/Tooltip.cjs");
2
1
  const require_ScreenReaderAnnounce = require("../../../ScreenReaderAnnounce/ScreenReaderAnnounce.cjs");
2
+ const require_Tooltip = require("../../../Tooltip/Tooltip.cjs");
3
3
  const require_SideBar_context = require("../../SideBar.context.cjs");
4
4
  const require_Icon = require("../Item/components/Icon/Icon.cjs");
5
5
  const require_Text = require("../Item/components/Text/Text.cjs");
@@ -1,5 +1,5 @@
1
- import Tooltip from "../../../Tooltip/Tooltip.js";
2
1
  import { ScreenReaderAnnounce } from "../../../ScreenReaderAnnounce/ScreenReaderAnnounce.js";
2
+ import Tooltip from "../../../Tooltip/Tooltip.js";
3
3
  import { useSideBarContext } from "../../SideBar.context.js";
4
4
  import Icon from "../Item/components/Icon/Icon.js";
5
5
  import Text from "../Item/components/Text/Text.js";
package/dist/index.cjs CHANGED
@@ -20,7 +20,9 @@ const require_ActionIconButton = require("./Button/ActionIconButton/ActionIconBu
20
20
  const require_ActionIconButton_types = require("./Button/ActionIconButton/ActionIconButton.types.cjs");
21
21
  const require_ToggleButton_style = require("./Button/ToggleButton/ToggleButton.style.cjs");
22
22
  const require_ToggleButton = require("./Button/ToggleButton/ToggleButton.cjs");
23
+ const require_ScreenReaderAnnounce = require("./ScreenReaderAnnounce/ScreenReaderAnnounce.cjs");
23
24
  const require_CopyToClipboardButton = require("./Button/CopyToClipboardButton/CopyToClipboardButton.cjs");
25
+ const require_CopyToClipboardButton_types = require("./Button/CopyToClipboardButton/CopyToClipboardButton.types.cjs");
24
26
  const require_Link = require("./Link/Link.cjs");
25
27
  const require_react_utils = require("./Helpers/react.utils.cjs");
26
28
  const require_generateId = require("./Helpers/generateId.cjs");
@@ -69,6 +71,8 @@ const require_Compose_style = require("./Chip/components/Compose/Compose.style.c
69
71
  const require_Chip = require("./Chip/Chip.cjs");
70
72
  const require_Overflow = require("./Overflow/Overflow.cjs");
71
73
  const require_ChipList = require("./ChipList/ChipList.cjs");
74
+ const require_CodeBlock = require("./CodeBlock/CodeBlock.cjs");
75
+ const require_CodeBlock_types = require("./CodeBlock/CodeBlock.types.cjs");
72
76
  const require_CountryFlag = require("./CountryFlag/CountryFlag.cjs");
73
77
  const require_Drawer = require("./Drawer/Drawer.cjs");
74
78
  const require_TreeView = require("./TreeView/TreeView.cjs");
@@ -94,7 +98,6 @@ const require_MultiSelect = require("./MultiSelect/MultiSelect.cjs");
94
98
  const require_Pagination_context = require("./Pagination/Pagination.context.cjs");
95
99
  const require_Pagination = require("./Pagination/Pagination.cjs");
96
100
  const require_RadioGroup = require("./RadioGroup/RadioGroup.cjs");
97
- const require_ScreenReaderAnnounce = require("./ScreenReaderAnnounce/ScreenReaderAnnounce.cjs");
98
101
  const require_TableHeading = require("./TableHeading/TableHeading.cjs");
99
102
  const require_SearchBar = require("./SearchBar/SearchBar.cjs");
100
103
  const require_Section = require("./Section/Section.cjs");
@@ -161,6 +164,7 @@ exports.Checkbox = require_Checkbox.default;
161
164
  exports.Chip = require_Chip.default;
162
165
  exports.ChipContainer = require_Compose_style.ChipContainer;
163
166
  exports.ChipList = require_ChipList.default;
167
+ exports.CodeBlock = require_CodeBlock.default;
164
168
  exports.ContextProvider = require_InputValue_context.ContextProvider;
165
169
  exports.CopyToClipboardButton = require_CopyToClipboardButton.default;
166
170
  exports.CountryFlag = require_CountryFlag.default;
@@ -274,7 +278,9 @@ Object.defineProperty(exports, "cardVariants", {
274
278
  }
275
279
  });
276
280
  exports.childrenToString = require_react_utils.childrenToString;
281
+ exports.codeBlockSizes = require_CodeBlock_types.codeBlockSizes;
277
282
  exports.combineHandlers = require_react_utils.combineHandlers;
283
+ exports.copyToClipboardButtonVariants = require_CopyToClipboardButton_types.copyToClipboardButtonVariants;
278
284
  exports.createNullableContext = require_NullableContext.createNullableContext;
279
285
  exports.createPrimitiveContextState = require_PrimitiveContextState.createPrimitiveContextState;
280
286
  exports.debounce = require_debounce.debounce;
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from './Card';
11
11
  export * from './Checkbox';
12
12
  export * from './Chip';
13
13
  export * from './ChipList';
14
+ export * from './CodeBlock';
14
15
  export * from './CountryFlag';
15
16
  export * from './Drawer';
16
17
  export * from './Filters';
package/dist/index.js CHANGED
@@ -19,7 +19,9 @@ import ActionIconButton from "./Button/ActionIconButton/ActionIconButton.js";
19
19
  import { actionIconButtonSizes, buttonWithIconVariants } from "./Button/ActionIconButton/ActionIconButton.types.js";
20
20
  import { ToggleButton_style_exports } from "./Button/ToggleButton/ToggleButton.style.js";
21
21
  import ToggleButton from "./Button/ToggleButton/ToggleButton.js";
22
+ import { ScreenReaderAnnounce } from "./ScreenReaderAnnounce/ScreenReaderAnnounce.js";
22
23
  import CopyToClipboardButton from "./Button/CopyToClipboardButton/CopyToClipboardButton.js";
24
+ import { copyToClipboardButtonVariants } from "./Button/CopyToClipboardButton/CopyToClipboardButton.types.js";
23
25
  import Link from "./Link/Link.js";
24
26
  import { childrenToString, combineHandlers, forwardRefWithGenerics, handlePreventDefault, handleStopPropagation, isFragmentElement, isTextualNode, memoWithGenerics } from "./Helpers/react.utils.js";
25
27
  import { generateId, useGeneratedId } from "./Helpers/generateId.js";
@@ -69,6 +71,8 @@ import { ChipContainer } from "./Chip/components/Compose/Compose.style.js";
69
71
  import Chip from "./Chip/Chip.js";
70
72
  import { Overflow } from "./Overflow/Overflow.js";
71
73
  import ChipList from "./ChipList/ChipList.js";
74
+ import CodeBlock from "./CodeBlock/CodeBlock.js";
75
+ import { codeBlockSizes } from "./CodeBlock/CodeBlock.types.js";
72
76
  import CountryFlag from "./CountryFlag/CountryFlag.js";
73
77
  import Drawer from "./Drawer/Drawer.js";
74
78
  import TreeView from "./TreeView/TreeView.js";
@@ -94,7 +98,6 @@ import MultiSelect from "./MultiSelect/MultiSelect.js";
94
98
  import { usePaginationContext } from "./Pagination/Pagination.context.js";
95
99
  import { Pagination } from "./Pagination/Pagination.js";
96
100
  import RadioGroup from "./RadioGroup/RadioGroup.js";
97
- import { ScreenReaderAnnounce } from "./ScreenReaderAnnounce/ScreenReaderAnnounce.js";
98
101
  import TableHeading from "./TableHeading/TableHeading.js";
99
102
  import SearchBar from "./SearchBar/SearchBar.js";
100
103
  import Section from "./Section/Section.js";
@@ -114,4 +117,4 @@ import { ProgressBar } from "./ProgressBar/ProgressBar.js";
114
117
  import { ProfileIcon_style_exports } from "./ProfileIcon/ProfileIcon.style.js";
115
118
  import ProfileIcon from "./ProfileIcon/ProfileIcon.js";
116
119
  import Slider from "./Slider/Slider.js";
117
- export { ActionIconButton_style_exports as ActionButtonWithIconStyles, ActionIconButton, AppBar, AppBar_style_exports as AppBarStyles, AppSelectionMenu, AutoCompleteSelect, Badge, Badge_style_exports as BadgeStyles, Banner, BoxSelectionGroup, Breadcrumbs, Button, ButtonGroup, Button_style_exports as ButtonStyles, IconButton_style_exports as ButtonWithIconStyles, Card, CategoryValueList, Checkbox, Chip, ChipContainer, ChipList, ContextProvider, CopyToClipboardButton, CountryFlag, Drawer, ErrorContentProvider, FieldAdditionTextIdProvider, FieldAdditionTextIdTransProvider, FieldDisabledProvider, FieldDisabledTransProvider, FieldReadonlyProvider, FieldReadonlyTransProvider, FieldRequiredProvider, FieldRequiredTransProvider, FieldStatusProvider, FieldStatusTransProvider, Filters, FlexDivider, FlexGroup, FlexItem, FlexSplit, FormField, Gauge, Grid, Hero, HighlightedIcon, HighlightedIcon_style_exports as HighlightedIconStyles, IconButton, Input, KeyValueList, Label, Link, LinkStyler, Loader, Menu, MidBar, Modal, MoreInfoIcon, MultiBoxSelectionGroup, MultiSelect, NumericInput, Overflow, Pagination, PasswordInput, Popover, PopperProvider, ProfileIcon, ProfileIcon_style_exports as ProfileIconStyles, ProgressBar, QuantityCounter, RadioGroup, RestylableElement, ScreenReaderAnnounce, SearchBar, SearchInput, Section, Select, SelfContained, SharedIdProvider, SharedIdTransProvider, SideBar, Skeleton, Slider, Stepper, StepperStepState, Switch, TableHeading, Tabs, TextArea, TextButton, TextButton_style_exports as TextButtonStyles, ThemeModeSwitch, Toast, Toaster, ToggleButton, ToggleButton_style_exports as ToggleButtonStyles, Tooltip, TooltipCard, Provider as TooltipProvider, TreeView, Typography, actionIconButtonSizes, badgeVariants, bannerVariants, buttonSizes, buttonVariants, buttonWithIconVariants, cardVariants, childrenToString, combineHandlers, createNullableContext, createPrimitiveContextState, debounce, forwardRefWithGenerics, generateId, getClosestDivisibleNumber, handlePreventDefault, handleStopPropagation, iconButtonSizes, isFragmentElement, isTextualNode, memoWithGenerics, textButtonSizes, textButtonVariants, throttle, toast, typographyColors, useEllipsisTooltip, useErrorContent, useFieldAdditionTextId, useFieldDisabled, useFieldReadonly, useFieldRequired, useFieldStatus, useGeneratedId, useInputValueApi, useInputValueProps, useKeyValueList, useMultiSelectContext, usePaginationContext, usePopperContext, useScrollable, useSelectContext, useSharedId, useThemeModeSwitch, useToastParams };
120
+ export { ActionIconButton_style_exports as ActionButtonWithIconStyles, ActionIconButton, AppBar, AppBar_style_exports as AppBarStyles, AppSelectionMenu, AutoCompleteSelect, Badge, Badge_style_exports as BadgeStyles, Banner, BoxSelectionGroup, Breadcrumbs, Button, ButtonGroup, Button_style_exports as ButtonStyles, IconButton_style_exports as ButtonWithIconStyles, Card, CategoryValueList, Checkbox, Chip, ChipContainer, ChipList, CodeBlock, ContextProvider, CopyToClipboardButton, CountryFlag, Drawer, ErrorContentProvider, FieldAdditionTextIdProvider, FieldAdditionTextIdTransProvider, FieldDisabledProvider, FieldDisabledTransProvider, FieldReadonlyProvider, FieldReadonlyTransProvider, FieldRequiredProvider, FieldRequiredTransProvider, FieldStatusProvider, FieldStatusTransProvider, Filters, FlexDivider, FlexGroup, FlexItem, FlexSplit, FormField, Gauge, Grid, Hero, HighlightedIcon, HighlightedIcon_style_exports as HighlightedIconStyles, IconButton, Input, KeyValueList, Label, Link, LinkStyler, Loader, Menu, MidBar, Modal, MoreInfoIcon, MultiBoxSelectionGroup, MultiSelect, NumericInput, Overflow, Pagination, PasswordInput, Popover, PopperProvider, ProfileIcon, ProfileIcon_style_exports as ProfileIconStyles, ProgressBar, QuantityCounter, RadioGroup, RestylableElement, ScreenReaderAnnounce, SearchBar, SearchInput, Section, Select, SelfContained, SharedIdProvider, SharedIdTransProvider, SideBar, Skeleton, Slider, Stepper, StepperStepState, Switch, TableHeading, Tabs, TextArea, TextButton, TextButton_style_exports as TextButtonStyles, ThemeModeSwitch, Toast, Toaster, ToggleButton, ToggleButton_style_exports as ToggleButtonStyles, Tooltip, TooltipCard, Provider as TooltipProvider, TreeView, Typography, actionIconButtonSizes, badgeVariants, bannerVariants, buttonSizes, buttonVariants, buttonWithIconVariants, cardVariants, childrenToString, codeBlockSizes, combineHandlers, copyToClipboardButtonVariants, createNullableContext, createPrimitiveContextState, debounce, forwardRefWithGenerics, generateId, getClosestDivisibleNumber, handlePreventDefault, handleStopPropagation, iconButtonSizes, isFragmentElement, isTextualNode, memoWithGenerics, textButtonSizes, textButtonVariants, throttle, toast, typographyColors, useEllipsisTooltip, useErrorContent, useFieldAdditionTextId, useFieldDisabled, useFieldReadonly, useFieldRequired, useFieldStatus, useGeneratedId, useInputValueApi, useInputValueProps, useKeyValueList, useMultiSelectContext, usePaginationContext, usePopperContext, useScrollable, useSelectContext, useSharedId, useThemeModeSwitch, useToastParams };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/components",
3
3
  "license": "UNLICENSED",
4
- "version": "51.15.0",
4
+ "version": "51.16.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "repository": "git@github.com:redislabsdev/redis-ui.git",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@redis-ui/icons": "^8.0.0 || ^9.0.0 || ^10.0.0",
33
- "@redis-ui/styles": "^21.22.0",
33
+ "@redis-ui/styles": "^21.23.0",
34
34
  "react": "^18.0.0 || ^19.0.0",
35
35
  "react-dom": "^18.0.0 || ^19.0.0",
36
36
  "styled-components": "^5.0.0"
@@ -162,6 +162,7 @@ Always check the relevant component reference before using a component. The refe
162
162
 
163
163
  - [Badge](./references/Badge.md)
164
164
  - [Chip](./references/Chip.md)
165
+ - [CodeBlock](./references/CodeBlock.md)
165
166
  - [ChipList](./references/ChipList.md)
166
167
  - [Label](./references/Label.md)
167
168
  - [Link](./references/Link.md)
@@ -0,0 +1,79 @@
1
+ # CodeBlock
2
+
3
+ A multi-line code block for snippets, commands and JSON, with an optional copy button. Use `Typography.Code` for inline code.
4
+
5
+ ## Import
6
+ ```tsx
7
+ import { CodeBlock } from '@redis-ui/components';
8
+ ```
9
+
10
+ ## Props
11
+ | Prop | Type | Default | Description |
12
+ |------|------|---------|-------------|
13
+ | code | `string` | *required* | Text rendered in the block and copied by the copy button |
14
+ | copyLabel | `string` | - | Shows a copy button and is used as its accessible name |
15
+ | wrap | `boolean` | `false` | Wraps long lines instead of scrolling horizontally. Use for commands and prompts |
16
+ | maxHeight | `string` | - | Scrolls vertically past this height (any CSS length, e.g. `'19rem'`) |
17
+ | 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`) |
19
+
20
+ ## Examples
21
+
22
+ ### Playground
23
+
24
+ ```tsx
25
+ <CodeBlock code={lensSnippet} copyLabel="Copy code" wrap={false} size="M" />
26
+ ```
27
+
28
+ ### Default
29
+
30
+ ```tsx
31
+ <CodeBlock code={lensSnippet} />
32
+ ```
33
+
34
+ ### Copyable
35
+
36
+ ```tsx
37
+ <CodeBlock code={installCommand} copyLabel="Copy install command" />
38
+ <CodeBlock code={lensSnippet} copyLabel="Copy code" />
39
+ ```
40
+
41
+ ### WrappedCommand
42
+
43
+ > `wrap` breaks long lines anywhere. Use it for commands and prompts.
44
+
45
+ ```tsx
46
+ <CodeBlock code={initCommand} copyLabel="Copy command" wrap />
47
+ ```
48
+
49
+ ### HorizontalScroll
50
+
51
+ > Without `wrap`, long lines scroll horizontally, including inside flex and grid layouts.
52
+
53
+ ```tsx
54
+ <div style={{ display: 'flex', maxWidth: '48rem' }}>
55
+ <CodeBlock code={clientConfig} copyLabel="Copy code" style={{ flex: 1 }} />
56
+ </div>
57
+ ```
58
+
59
+ ### MaxHeight
60
+
61
+ ```tsx
62
+ <CodeBlock code={longJson} copyLabel="Copy JSON" maxHeight="19rem" />
63
+ ```
64
+
65
+ ### Sizes
66
+
67
+ ```tsx
68
+ import { CodeBlock, codeBlockSizes } from '@redis-ui/components';
69
+
70
+ {codeBlockSizes.map((size) => (
71
+ <CodeBlock key={size} code={lensSnippet} copyLabel="Copy code" size={size} />
72
+ ))}
73
+ ```
74
+
75
+ ## Notes
76
+ - The component forwards refs to the root element.
77
+ - When the content overflows, the block becomes keyboard-focusable so it can be scrolled with the keyboard.
78
+ - The copy button is `CopyToClipboardButton` with `variant="outline"`, pinned to the top-right corner.
79
+ - No syntax highlighting: `code` is rendered as plain text.
@@ -12,6 +12,7 @@ import { CopyToClipboardButton } from '@redis-ui/components';
12
12
  |------|------|---------|-------------|
13
13
  | textToCopy | `string` | *required* | Text copied to the clipboard when the button is clicked |
14
14
  | copiedLabel | `string` | - | Optional label shown while the copied success state is active |
15
+ | variant | `'default' \| 'outline'` | `'default'` | `outline` renders a bordered square button for copyable values and code blocks |
15
16
  | native button props | `Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>` | - | Standard button attributes except `onClick`, which is handled internally |
16
17
 
17
18
  ## Examples
@@ -21,7 +22,40 @@ import { CopyToClipboardButton } from '@redis-ui/components';
21
22
  ```tsx
22
23
  import { CopyToClipboardButton } from '@redis-ui/components';
23
24
 
24
- <CopyToClipboardButton disabled={false} textToCopy="Hello, World!" copiedLabel="Copied!" />
25
+ <CopyToClipboardButton
26
+ disabled={false}
27
+ textToCopy="Hello, World!"
28
+ copiedLabel="Copied!"
29
+ variant="default"
30
+ />
31
+ ```
32
+
33
+ ### Variants
34
+
35
+ > `outline` is a bordered square button for copyable values and code blocks.
36
+
37
+ ```tsx
38
+ import {
39
+ CopyToClipboardButton,
40
+ copyToClipboardButtonVariants
41
+ } from '@redis-ui/components';
42
+
43
+ <>
44
+ {copyToClipboardButtonVariants.map((variant) => (
45
+ <CopyToClipboardButton
46
+ key={variant}
47
+ textToCopy={`${variant} variant`}
48
+ aria-label={`Copy ${variant}`}
49
+ variant={variant}
50
+ />
51
+ ))}
52
+ <CopyToClipboardButton
53
+ textToCopy="disabled"
54
+ aria-label="Copy disabled"
55
+ variant="outline"
56
+ disabled
57
+ />
58
+ </>
25
59
  ```
26
60
 
27
61
  ### Disabled
@@ -45,3 +79,5 @@ import { CopyToClipboardButton } from '@redis-ui/components';
45
79
  - After a successful copy, the icon changes to a check mark for 1.5 seconds before reverting.
46
80
  - If `copiedLabel` is provided, it is also used as the accessible label while the copied state is active.
47
81
  - If `copiedLabel` is omitted, the accessible label falls back to `Copy`.
82
+ - A successful copy is announced to screen readers (`copiedLabel`, or `Copied`).
83
+ - Use `variant="outline"` for copyable values in Ultra surfaces; `CodeBlock` uses it for its copy button.