@redis-ui/components 51.15.0 → 51.17.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 +53 -0
  10. package/dist/CodeBlock/CodeBlock.d.ts +2 -0
  11. package/dist/CodeBlock/CodeBlock.js +53 -0
  12. package/dist/CodeBlock/CodeBlock.style.cjs +70 -0
  13. package/dist/CodeBlock/CodeBlock.style.d.ts +13 -0
  14. package/dist/CodeBlock/CodeBlock.style.js +65 -0
  15. package/dist/CodeBlock/CodeBlock.types.cjs +10 -0
  16. package/dist/CodeBlock/CodeBlock.types.d.ts +17 -0
  17. package/dist/CodeBlock/CodeBlock.types.js +9 -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 +8 -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 +93 -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,53 @@
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, overflow, 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 || overflow === "scroll" && 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
+ }, [
19
+ code,
20
+ overflow,
21
+ maxHeight
22
+ ]);
23
+ return [ref, isScrollable];
24
+ };
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
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CodeBlock_style.CodeBlock, {
28
+ ref,
29
+ ...restProps,
30
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockPre, {
31
+ 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
+ },
41
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockCode, { children: code })
42
+ }), copyLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock_style.CodeBlockCopy, {
43
+ $size: size,
44
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyToClipboardButton.default, {
45
+ textToCopy: code,
46
+ "aria-label": copyLabel
47
+ })
48
+ })]
49
+ });
50
+ });
51
+ CodeBlock.displayName = "CodeBlock";
52
+ //#endregion
53
+ 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,53 @@
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, overflow, 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 || overflow === "scroll" && 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
+ }, [
19
+ code,
20
+ overflow,
21
+ maxHeight
22
+ ]);
23
+ return [ref, isScrollable];
24
+ };
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
+ return /* @__PURE__ */ jsxs(CodeBlock$1, {
28
+ ref,
29
+ ...restProps,
30
+ children: [/* @__PURE__ */ jsx(CodeBlockPre, {
31
+ 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
+ },
41
+ children: /* @__PURE__ */ jsx(CodeBlockCode, { children: code })
42
+ }), copyLabel && /* @__PURE__ */ jsx(CodeBlockCopy, {
43
+ $size: size,
44
+ children: /* @__PURE__ */ jsx(CopyToClipboardButton, {
45
+ textToCopy: code,
46
+ "aria-label": copyLabel
47
+ })
48
+ })]
49
+ });
50
+ });
51
+ CodeBlock.displayName = "CodeBlock";
52
+ //#endregion
53
+ export { CodeBlock as default };
@@ -0,0 +1,70 @@
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
+ })(["", ""], () => {
10
+ const theme = (0, _redislabsdev_redis_ui_styles.useTheme)().components.codeBlock;
11
+ return styled_components.css`
12
+ position: relative;
13
+ min-width: 0;
14
+ background-color: ${theme.bgColor};
15
+ border: ${theme.border};
16
+ border-radius: ${theme.borderRadius};
17
+ `;
18
+ });
19
+ var CodeBlockPre = styled_components.default.pre.withConfig({
20
+ displayName: "CodeBlockstyle__CodeBlockPre",
21
+ componentId: "RedisUI__sc-16pq9cs-1"
22
+ })(["", ""], ({ $size, $overflow, $maxHeight, $withCopy }) => {
23
+ const theme = (0, _redislabsdev_redis_ui_styles.useTheme)().components.codeBlock;
24
+ return styled_components.css`
25
+ margin: 0;
26
+ padding: ${theme.paddingY} ${$withCopy ? theme.paddingRightWithCopy : theme.paddingX}
27
+ ${theme.paddingY} ${theme.paddingX};
28
+ color: ${theme.textColor};
29
+ border-radius: ${theme.borderRadius};
30
+ font-family: ${theme.fontFamily};
31
+ font-size: ${theme.sizes[$size].fontSize};
32
+ line-height: ${theme.lineHeight};
33
+ text-align: left;
34
+ overflow: auto;
35
+ max-height: ${$maxHeight ?? "none"};
36
+ white-space: ${$overflow === "wrap" ? "pre-wrap" : "pre"};
37
+ overflow-wrap: ${$overflow === "wrap" ? "anywhere" : "normal"};
38
+
39
+ ${$overflow === "ellipsis" && styled_components.css`
40
+ overflow-x: hidden;
41
+ text-overflow: ellipsis;
42
+ `}
43
+
44
+ ${(0, _redislabsdev_redis_ui_styles.getFocusStyle)()}
45
+ `;
46
+ });
47
+ var CodeBlockCode = styled_components.default.code.withConfig({
48
+ displayName: "CodeBlockstyle__CodeBlockCode",
49
+ componentId: "RedisUI__sc-16pq9cs-2"
50
+ })(["font:inherit;"]);
51
+ /** Spans the first code line, so the button centers on it */
52
+ var CodeBlockCopy = styled_components.default.div.withConfig({
53
+ displayName: "CodeBlockstyle__CodeBlockCopy",
54
+ componentId: "RedisUI__sc-16pq9cs-3"
55
+ })(["", ""], ({ $size }) => {
56
+ const theme = (0, _redislabsdev_redis_ui_styles.useTheme)().components.codeBlock;
57
+ return styled_components.css`
58
+ position: absolute;
59
+ top: ${theme.paddingY};
60
+ right: ${theme.paddingX};
61
+ height: calc(${theme.sizes[$size].fontSize} * ${theme.lineHeight});
62
+ display: flex;
63
+ align-items: center;
64
+ `;
65
+ });
66
+ //#endregion
67
+ exports.CodeBlock = CodeBlock;
68
+ exports.CodeBlockCode = CodeBlockCode;
69
+ exports.CodeBlockCopy = CodeBlockCopy;
70
+ exports.CodeBlockPre = CodeBlockPre;
@@ -0,0 +1,13 @@
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, {
4
+ $size: CodeBlockSize;
5
+ $overflow: CodeBlockOverflow;
6
+ $maxHeight?: string;
7
+ $withCopy: boolean;
8
+ }, never>;
9
+ export declare const CodeBlockCode: import("styled-components").StyledComponent<"code", any, {}, never>;
10
+ /** Spans the first code line, so the button centers on it */
11
+ export declare const CodeBlockCopy: import("styled-components").StyledComponent<"div", any, {
12
+ $size: CodeBlockSize;
13
+ }, never>;
@@ -0,0 +1,65 @@
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
+ })(["", ""], () => {
8
+ const theme = useTheme().components.codeBlock;
9
+ return css`
10
+ position: relative;
11
+ min-width: 0;
12
+ background-color: ${theme.bgColor};
13
+ border: ${theme.border};
14
+ border-radius: ${theme.borderRadius};
15
+ `;
16
+ });
17
+ var CodeBlockPre = _styled.pre.withConfig({
18
+ displayName: "CodeBlockstyle__CodeBlockPre",
19
+ componentId: "RedisUI__sc-16pq9cs-1"
20
+ })(["", ""], ({ $size, $overflow, $maxHeight, $withCopy }) => {
21
+ const theme = useTheme().components.codeBlock;
22
+ return css`
23
+ margin: 0;
24
+ padding: ${theme.paddingY} ${$withCopy ? theme.paddingRightWithCopy : theme.paddingX}
25
+ ${theme.paddingY} ${theme.paddingX};
26
+ color: ${theme.textColor};
27
+ border-radius: ${theme.borderRadius};
28
+ font-family: ${theme.fontFamily};
29
+ font-size: ${theme.sizes[$size].fontSize};
30
+ line-height: ${theme.lineHeight};
31
+ text-align: left;
32
+ overflow: auto;
33
+ max-height: ${$maxHeight ?? "none"};
34
+ white-space: ${$overflow === "wrap" ? "pre-wrap" : "pre"};
35
+ overflow-wrap: ${$overflow === "wrap" ? "anywhere" : "normal"};
36
+
37
+ ${$overflow === "ellipsis" && css`
38
+ overflow-x: hidden;
39
+ text-overflow: ellipsis;
40
+ `}
41
+
42
+ ${getFocusStyle()}
43
+ `;
44
+ });
45
+ var CodeBlockCode = _styled.code.withConfig({
46
+ displayName: "CodeBlockstyle__CodeBlockCode",
47
+ componentId: "RedisUI__sc-16pq9cs-2"
48
+ })(["font:inherit;"]);
49
+ /** Spans the first code line, so the button centers on it */
50
+ var CodeBlockCopy = _styled.div.withConfig({
51
+ displayName: "CodeBlockstyle__CodeBlockCopy",
52
+ componentId: "RedisUI__sc-16pq9cs-3"
53
+ })(["", ""], ({ $size }) => {
54
+ const theme = useTheme().components.codeBlock;
55
+ return css`
56
+ position: absolute;
57
+ top: ${theme.paddingY};
58
+ right: ${theme.paddingX};
59
+ height: calc(${theme.sizes[$size].fontSize} * ${theme.lineHeight});
60
+ display: flex;
61
+ align-items: center;
62
+ `;
63
+ });
64
+ //#endregion
65
+ export { CodeBlock, CodeBlockCode, CodeBlockCopy, CodeBlockPre };
@@ -0,0 +1,10 @@
1
+ //#region src/CodeBlock/CodeBlock.types.ts
2
+ var codeBlockSizes = ["M", "S"];
3
+ var codeBlockOverflows = [
4
+ "scroll",
5
+ "wrap",
6
+ "ellipsis"
7
+ ];
8
+ //#endregion
9
+ exports.codeBlockOverflows = codeBlockOverflows;
10
+ exports.codeBlockSizes = codeBlockSizes;
@@ -0,0 +1,17 @@
1
+ import { HTMLAttributes } from 'react';
2
+ export declare const codeBlockSizes: readonly ["M", "S"];
3
+ export type CodeBlockSize = (typeof codeBlockSizes)[number];
4
+ export declare const codeBlockOverflows: readonly ["scroll", "wrap", "ellipsis"];
5
+ export type CodeBlockOverflow = (typeof codeBlockOverflows)[number];
6
+ export type OwnCodeBlockProps = {
7
+ code: string;
8
+ /** Shows a copy button and is used as its accessible name */
9
+ copyLabel?: string;
10
+ /** How long lines behave: scroll horizontally, wrap, or truncate with an ellipsis */
11
+ overflow?: CodeBlockOverflow;
12
+ /** Scrolls vertically past this height */
13
+ maxHeight?: string;
14
+ size?: CodeBlockSize;
15
+ };
16
+ export type RestCodeBlockProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
17
+ export type CodeBlockProps = OwnCodeBlockProps & RestCodeBlockProps;
@@ -0,0 +1,9 @@
1
+ //#region src/CodeBlock/CodeBlock.types.ts
2
+ var codeBlockSizes = ["M", "S"];
3
+ var codeBlockOverflows = [
4
+ "scroll",
5
+ "wrap",
6
+ "ellipsis"
7
+ ];
8
+ //#endregion
9
+ export { codeBlockOverflows, 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,10 @@ Object.defineProperty(exports, "cardVariants", {
274
278
  }
275
279
  });
276
280
  exports.childrenToString = require_react_utils.childrenToString;
281
+ exports.codeBlockOverflows = require_CodeBlock_types.codeBlockOverflows;
282
+ exports.codeBlockSizes = require_CodeBlock_types.codeBlockSizes;
277
283
  exports.combineHandlers = require_react_utils.combineHandlers;
284
+ exports.copyToClipboardButtonVariants = require_CopyToClipboardButton_types.copyToClipboardButtonVariants;
278
285
  exports.createNullableContext = require_NullableContext.createNullableContext;
279
286
  exports.createPrimitiveContextState = require_PrimitiveContextState.createPrimitiveContextState;
280
287
  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 { codeBlockOverflows, 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, codeBlockOverflows, 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.17.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.24.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,93 @@
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
+ | overflow | `'scroll' \| 'wrap' \| 'ellipsis'` | `'scroll'` | How long lines behave: scroll horizontally, wrap (use for commands and prompts), or truncate with an ellipsis |
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
+ import { CodeBlock, codeBlockOverflows, codeBlockSizes } from '@redis-ui/components';
26
+
27
+ <CodeBlock code={lensSnippet} copyLabel="Copy code" overflow="scroll" size="M" />
28
+ ```
29
+
30
+ `codeBlockOverflows` and `codeBlockSizes` list the allowed `overflow` and `size` values, e.g. for controls.
31
+
32
+ ### Default
33
+
34
+ ```tsx
35
+ <CodeBlock code={lensSnippet} />
36
+ ```
37
+
38
+ ### Copyable
39
+
40
+ ```tsx
41
+ <CodeBlock code={installCommand} copyLabel="Copy install command" />
42
+ <CodeBlock code={lensSnippet} copyLabel="Copy code" />
43
+ ```
44
+
45
+ ### WrappedCommand
46
+
47
+ > `overflow="wrap"` breaks long lines anywhere. Use it for commands and prompts.
48
+
49
+ ```tsx
50
+ <CodeBlock code={initCommand} copyLabel="Copy command" overflow="wrap" />
51
+ ```
52
+
53
+ ### HorizontalScroll
54
+
55
+ > By default, long lines scroll horizontally, including inside flex and grid layouts.
56
+
57
+ ```tsx
58
+ <div style={{ display: 'flex', maxWidth: '48rem' }}>
59
+ <CodeBlock code={clientConfig} copyLabel="Copy code" style={{ flex: 1 }} />
60
+ </div>
61
+ ```
62
+
63
+ ### Ellipsis
64
+
65
+ > `overflow="ellipsis"` truncates long lines. Copy still copies the full code.
66
+
67
+ ```tsx
68
+ <div style={{ maxWidth: '48rem' }}>
69
+ <CodeBlock code={initCommand} copyLabel="Copy command" overflow="ellipsis" />
70
+ </div>
71
+ ```
72
+
73
+ ### MaxHeight
74
+
75
+ ```tsx
76
+ <CodeBlock code={longJson} copyLabel="Copy JSON" maxHeight="19rem" />
77
+ ```
78
+
79
+ ### Sizes
80
+
81
+ ```tsx
82
+ import { CodeBlock, codeBlockSizes } from '@redis-ui/components';
83
+
84
+ {codeBlockSizes.map((size) => (
85
+ <CodeBlock key={size} code={lensSnippet} copyLabel="Copy code" size={size} />
86
+ ))}
87
+ ```
88
+
89
+ ## Notes
90
+ - The component forwards refs to the root element.
91
+ - When the content scrolls, the block becomes keyboard-focusable so it can be scrolled with the keyboard. Truncated lines (`overflow="ellipsis"`) don't count.
92
+ - The copy button is `CopyToClipboardButton`, centered on the first code line in the top-right corner.
93
+ - No syntax highlighting: `code` is rendered as plain text.
@@ -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 |
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.
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.